OpenWalnut  1.5.0dev
WMReadMesh.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMREADMESH_H
26 #define WMREADMESH_H
27 
28 #include <fstream>
29 #include <memory>
30 #include <string>
31 
32 #include <osg/Geode>
33 
34 #include "WMeshReaderInterface.h"
35 #include "core/common/WObjectNDIP.h"
36 #include "core/common/WStrategyHelper.h"
37 #include "core/graphicsEngine/WTriangleMesh.h"
38 #include "core/kernel/WModule.h"
39 #include "core/kernel/WModuleInputData.h"
40 #include "core/kernel/WModuleOutputData.h"
41 
42 /**
43  * This module reads a file containing mesh data (several formats supported) and creates a mesh
44  * (or triangle mesh) object delivered through the output connector
45  *
46  * \ingroup modules
47  */
48 class WMReadMesh: public WModule
49 {
50 public:
51  /**
52  *
53  */
54  WMReadMesh();
55 
56  /**
57  *
58  */
59  virtual ~WMReadMesh();
60 
61  /**
62  * Gives back the name of this module.
63  * \return the module's name.
64  */
65  virtual const std::string getName() const;
66 
67  /**
68  * Gives back a description of this module.
69  * \return description to module.
70  */
71  virtual const std::string getDescription() const;
72 
73  /**
74  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
75  * should never be initialized or modified in some other way. A simple new instance is required.
76  *
77  * \return the prototype used to create every module in OpenWalnut.
78  */
79  virtual std::shared_ptr< WModule > factory() const;
80 
81  /**
82  * Get the icon for this module in XPM format.
83  * \return The icon.
84  */
85  virtual const char** getXPMIcon() const;
86 
87 protected:
88  /**
89  * Entry point after loading the module. Runs in separate thread.
90  */
91  virtual void moduleMain();
92 
93  /**
94  * Initialize the connectors this module is using.
95  */
96  virtual void connectors();
97 
98  /**
99  * Initialize the properties for this module.
100  */
101  virtual void properties();
102 
103 private:
104  std::shared_ptr< WTriangleMesh > m_triMesh; //!< This triangle mesh is provided as output through the connector.
105  std::shared_ptr< WModuleOutputData< WTriangleMesh > > m_output; //!< Output connector provided by this module.
106  std::shared_ptr< WCondition > m_propCondition; //!< A condition used to notify about changes in several properties.
107 
108  WPropTrigger m_readTriggerProp; //!< This property triggers the actual reading,
109  WPropFilename m_meshFile; //!< The mesh will be read from this file.
110 
111  /**
112  * A list of file type selection types
113  */
114  std::shared_ptr< WItemSelection > m_fileTypeSelectionsList;
115 
116  /**
117  * Selection property for file types
118  */
119  WPropSelection m_fileTypeSelection;
120 
121  WPropInt m_nbTriangles; //!< Info-property showing the number of triangles in the mesh.
122  WPropInt m_nbVertices; //!< Info-property showing the number of vertices in the mesh.
123 
124  /**
125  * Handle each loader as strategy.
126  */
128 };
129 
130 #endif // WMREADMESH_H
This module reads a file containing mesh data (several formats supported) and creates a mesh (or tria...
Definition: WMReadMesh.h:49
virtual void connectors()
Initialize the connectors this module is using.
Definition: WMReadMesh.cpp:92
WPropTrigger m_readTriggerProp
This property triggers the actual reading,.
Definition: WMReadMesh.h:108
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
Definition: WMReadMesh.cpp:75
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
Definition: WMReadMesh.h:106
virtual void properties()
Initialize the properties for this module.
Definition: WMReadMesh.cpp:103
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
Definition: WMReadMesh.cpp:69
WPropFilename m_meshFile
The mesh will be read from this file.
Definition: WMReadMesh.h:109
std::shared_ptr< WTriangleMesh > m_triMesh
This triangle mesh is provided as output through the connector.
Definition: WMReadMesh.h:104
virtual const std::string getDescription() const
Gives back a description of this module.
Definition: WMReadMesh.cpp:85
WStrategyHelper< WObjectNDIP< WMeshReaderInterface > > m_strategy
Handle each loader as strategy.
Definition: WMReadMesh.h:127
WPropInt m_nbVertices
Info-property showing the number of vertices in the mesh.
Definition: WMReadMesh.h:122
virtual void moduleMain()
Entry point after loading the module.
Definition: WMReadMesh.cpp:123
WPropInt m_nbTriangles
Info-property showing the number of triangles in the mesh.
Definition: WMReadMesh.h:121
virtual const std::string getName() const
Gives back the name of this module.
Definition: WMReadMesh.cpp:80
WPropSelection m_fileTypeSelection
Selection property for file types.
Definition: WMReadMesh.h:119
std::shared_ptr< WModuleOutputData< WTriangleMesh > > m_output
Output connector provided by this module.
Definition: WMReadMesh.h:105
std::shared_ptr< WItemSelection > m_fileTypeSelectionsList
A list of file type selection types.
Definition: WMReadMesh.h:114
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
This class allows for an easy strategy pattern-based switching between properties and strategy instan...