OpenWalnut  1.5.0dev
WMWriteTracts.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 WMWRITETRACTS_H
26 #define WMWRITETRACTS_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <osg/Geode>
32 
33 #include "core/dataHandler/WDataSetFibers.h"
34 #include "core/dataHandler/datastructures/WFiberCluster.h"
35 #include "core/kernel/WModule.h"
36 #include "core/kernel/WModuleInputData.h"
37 #include "core/kernel/WModuleOutputData.h"
38 
39 /**
40  * This module writes the tracts of either a fiber cluster or directly out of a
41  * WDataSetFibers at its connector to a file.
42  *
43  * \ingroup modules
44  */
45 class WMWriteTracts: public WModule
46 {
47 public:
48  /**
49  * Constructs an instance to write tracts to a file.
50  */
51  WMWriteTracts();
52 
53  /**
54  * Destructs this instance.
55  */
56  virtual ~WMWriteTracts();
57 
58  /**
59  * Gives back the name of this module.
60  * \return the module's name.
61  */
62  virtual const std::string getName() const;
63 
64  /**
65  * Gives back a description of this module.
66  * \return description to module.
67  */
68  virtual const std::string getDescription() const;
69 
70  /**
71  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
72  * should never be initialized or modified in some other way. A simple new instance is required.
73  *
74  * \return the prototype used to create every module in OpenWalnut.
75  */
76  virtual std::shared_ptr< WModule > factory() const;
77 
78  /**
79  * Get the icon for this module in XPM format.
80  * \return The icon.
81  */
82  virtual const char** getXPMIcon() const;
83 
84 protected:
85  /**
86  * Entry point after loading the module. Runs in separate thread.
87  */
88  virtual void moduleMain();
89 
90  /**
91  * Initialize the connectors this module is using.
92  */
93  virtual void connectors();
94 
95  /**
96  * Initialize the properties for this module.
97  */
98  virtual void properties();
99 
100 private:
101  /**
102  * Store the mesh in a json (javascript object notation) file
103  *
104  * \return true if successful
105  */
106  bool saveJson() const;
107 
108  /**
109  * Store the mesh in a json (javascript object notation) file
110  * using only every other vertex
111  *
112  * \return true if successful
113  */
114  bool saveJson2() const;
115 
116  /**
117  * Store the mesh in a json (javascript object notation) file
118  *
119  * \return true if successful
120  */
121  bool saveJsonTriangles() const;
122 
123  /**
124  * Saves the fiber tracts as POVRAY SDL.
125  *
126  * \param fibers the fibers to write
127  *
128  * \return true if successful.
129  */
130  bool savePOVRay( std::shared_ptr< const WDataSetFibers > fibers ) const;
131 
132  /**
133  * Input connector for writing the tracts out of a WFiberCluster to a file.
134  */
135  std::shared_ptr< WModuleInputData< const WFiberCluster > > m_clusterIC;
136 
137  /**
138  * Input connector for writing directly tracts to a file.
139  */
140  std::shared_ptr< WModuleInputData< const WDataSetFibers > > m_tractIC;
141 
142  WPropTrigger m_run; //!< Button to start saving
143  WPropFilename m_savePath; //!< Path where tracts should be stored
144 
145  /**
146  * A list of file type selection types
147  */
148  std::shared_ptr< WItemSelection > m_fileTypeSelectionsList;
149 
150  /**
151  * Selection property for file types
152  */
153  WPropSelection m_fileTypeSelection;
154 
155  /**
156  * Groups all the options for the povray exporter.
157  */
158  WPropGroup m_povrayOptions;
159 
160  /**
161  * Enables radiosity renderer in povray
162  */
163  WPropBool m_povrayRadiosity;
164 
165  /**
166  * The tube diameter in povray export
167  */
168  WPropDouble m_povrayTubeDiameter;
169 
170  /**
171  * Allows thinning of the data. Often useful for testing povray settings as small scenes render faster.
172  */
174 
175  /**
176  * Handles updates in filetype property. Used to hide and unhide certain property groups.
177  */
178  void fileTypeChanged();
179 };
180 
181 #endif // WMWRITETRACTS_H
This module writes the tracts of either a fiber cluster or directly out of a WDataSetFibers at its co...
Definition: WMWriteTracts.h:46
std::shared_ptr< WModuleInputData< const WDataSetFibers > > m_tractIC
Input connector for writing directly tracts to a file.
std::shared_ptr< WModuleInputData< const WFiberCluster > > m_clusterIC
Input connector for writing the tracts out of a WFiberCluster to a file.
WMWriteTracts()
Constructs an instance to write tracts to a file.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
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...
bool savePOVRay(std::shared_ptr< const WDataSetFibers > fibers) const
Saves the fiber tracts as POVRAY SDL.
virtual void moduleMain()
Entry point after loading the module.
bool saveJson() const
Store the mesh in a json (javascript object notation) file.
std::shared_ptr< WItemSelection > m_fileTypeSelectionsList
A list of file type selection types.
WPropGroup m_povrayOptions
Groups all the options for the povray exporter.
bool saveJson2() const
Store the mesh in a json (javascript object notation) file using only every other vertex.
WPropTrigger m_run
Button to start saving.
virtual void properties()
Initialize the properties for this module.
WPropInt m_povraySaveOnlyNth
Allows thinning of the data.
WPropFilename m_savePath
Path where tracts should be stored.
WPropDouble m_povrayTubeDiameter
The tube diameter in povray export.
virtual void connectors()
Initialize the connectors this module is using.
WPropBool m_povrayRadiosity
Enables radiosity renderer in povray.
virtual const std::string getDescription() const
Gives back a description of this module.
void fileTypeChanged()
Handles updates in filetype property.
virtual const std::string getName() const
Gives back the name of this module.
virtual ~WMWriteTracts()
Destructs this instance.
WPropSelection m_fileTypeSelection
Selection property for file types.
bool saveJsonTriangles() const
Store the mesh in a json (javascript object notation) file.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72