OpenWalnut  1.5.0dev
WMPartition2Mesh.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 //---------------------------------------------------------------------------
26 //
27 // This file is also part of the
28 // Whole-Brain Connectivity-Based Hierarchical Parcellation Project
29 // David Moreno-Dominguez
30 // Ralph Schurade
31 // moreno@cbs.mpg.de
32 // www.cbs.mpg.de/~moreno
33 //
34 //---------------------------------------------------------------------------
35 
36 #ifndef WMPARTITION2MESH_H
37 #define WMPARTITION2MESH_H
38 
39 #include <memory>
40 #include <string>
41 #include <vector>
42 
43 #include <osg/Geode>
44 
45 #include "core/dataHandler/WDataSetScalar.h"
46 #include "core/dataHandler/WDataSetVector.h"
47 #include "core/dataHandler/WValueSet.h"
48 #include "core/graphicsEngine/WTriangleMesh.h"
49 #include "core/kernel/WModule.h"
50 #include "core/kernel/WModuleInputData.h"
51 #include "core/kernel/WModuleOutputData.h"
52 
53 
54 /**
55  * This module projects a clustering partition result onto a (freesurfer) mesh
56  * Meant to work with hierchClustDisplay. It accepts 4 different inputs:
57  * - A vector with the cluster color of each data point
58  * - A vector with the voxel positions from the clustering data points
59  * - The reference mesh to project the results to (normaly an original surface mesh)
60  * - The Visualization Mesh. Can be equal to the reference mesh or can be a 1-1 matched mesh (inflated, pial. etc...)
61  *
62  * \ingroup modules
63  */
65 {
66 public:
67  /**
68  *
69  */
71 
72  /**
73  *
74  */
75  virtual ~WMPartition2Mesh();
76 
77  /**
78  * Gives back the name of this module.
79  * \return the module's name.
80  */
81  virtual const std::string getName() const;
82 
83  /**
84  * Gives back a description of this module.
85  * \return description to module.
86  */
87  virtual const std::string getDescription() const;
88 
89  /**
90  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
91  * should never be initialized or modified in some other way. A simple new instance is required.
92  *
93  * \return the prototype used to create every module in OpenWalnut.
94  */
95  virtual std::shared_ptr< WModule > factory() const;
96 
97 protected:
98  /**
99  * Entry point after loading the module. Runs in separate thread.
100  */
101  virtual void moduleMain();
102 
103  /**
104  * Initialize the connectors this module is using.
105  */
106  virtual void connectors();
107 
108  /**
109  * Initialize the properties for this module.
110  */
111  virtual void properties();
112 
113  /**
114  * Initialize requirements for this module.
115  */
116  virtual void requirements();
117 
118 
119 private:
120  void writeLabels(); //!< writes a freesurfer set of labels and tcl loading file
121 
122 #if 0
123  void writeAnnotation(); //!< writes a freesurfer annotation file (NOT WORKING)
124 #endif
125 
126  std::shared_ptr< WModuleInputData< WDataSetScalar > > m_coordInput; //!< An input connector that accepts order 1 datasets.
127  std::shared_ptr< WModuleInputData< WTriangleMesh > > m_meshInput1; //!< An input connector for the reference mesh
128  std::shared_ptr< WModuleInputData< WTriangleMesh > > m_meshInput2; //!< An input connector for the mesh
129  std::shared_ptr< WModuleInputData< WDataSetVector > > m_colorInput; //!< This is a pointer to the color input dataset.
130 
131  std::shared_ptr< WDataSetScalar > m_coordinateVector; //!< This is a pointer to the coord vector.
132  std::shared_ptr< WDataSetVector > m_colorVector; //!< This is a pointer to the color vector.
133  std::shared_ptr< WModuleOutputData< WTriangleMesh > > m_meshOutput; //!< Output connector provided by this module.
134 
135  std::shared_ptr< WTriangleMesh > m_referenceMesh; //!< A pointer to the currently processed tri mesh
136  std::shared_ptr< WTriangleMesh > m_outMesh; //!< A pointer to the currently processed tri mesh
137  std::vector<size_t>m_refs; //!< a vector holding the cluster id corresponding to each vertex
138 
139  unsigned int m_datasetSizeX; //!< Size of the dataset (X)
140  unsigned int m_datasetSizeY; //!< Size of the dataset (Y)
141  unsigned int m_datasetSizeZ; //!< Size of the dataset (Z)
142  bool m_blankOutMesh; //!< if set mesh colors must be initialized
143 
144  std::shared_ptr< WCondition > m_propCondition; //!< A condition used to notify about changes in several properties.
145  WPropColor m_propNonActiveColor; //!< color for the non labeled texture voxels
146  WPropColor m_propHoleColor; //!< color for the non labeled texture voxels
147  WPropBool m_monochrome; //!< if used all labels will have m_propNonActiveColor
148  WPropDouble m_propProjectDistance; //!< maximum distance to project the voxels
149  WPropFilename m_propLabelFolder; //!< folder where the labels will be written
150  WPropFilename m_propAnnotationFile; //!< filename for the annotation file
151  WPropTrigger m_propWriteTrigger; //!< trigger the writing of the labels
152  WPropInt m_infoTotalVertices; //!< Info property: number of vertices
153  WPropInt m_infoUnassignedVertices; //!< Info property: number of vertices without match
154 };
155 
156 #endif // WMPARTITION2MESH_H
This module projects a clustering partition result onto a (freesurfer) mesh Meant to work with hierch...
virtual const std::string getDescription() const
Gives back a description of this module.
std::vector< size_t > m_refs
a vector holding the cluster id corresponding to each vertex
unsigned int m_datasetSizeZ
Size of the dataset (Z)
std::shared_ptr< WModuleInputData< WDataSetVector > > m_colorInput
This is a pointer to the color input dataset.
virtual void connectors()
Initialize the connectors this module is using.
std::shared_ptr< WModuleInputData< WTriangleMesh > > m_meshInput2
An input connector for the mesh.
std::shared_ptr< WDataSetVector > m_colorVector
This is a pointer to the color vector.
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...
std::shared_ptr< WDataSetScalar > m_coordinateVector
This is a pointer to the coord vector.
unsigned int m_datasetSizeX
Size of the dataset (X)
WPropBool m_monochrome
if used all labels will have m_propNonActiveColor
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
std::shared_ptr< WTriangleMesh > m_outMesh
A pointer to the currently processed tri mesh.
virtual void moduleMain()
Entry point after loading the module.
void writeLabels()
writes a freesurfer set of labels and tcl loading file
virtual void requirements()
Initialize requirements for this module.
unsigned int m_datasetSizeY
Size of the dataset (Y)
WPropFilename m_propLabelFolder
folder where the labels will be written
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_coordInput
An input connector that accepts order 1 datasets.
WPropInt m_infoUnassignedVertices
Info property: number of vertices without match.
WPropColor m_propNonActiveColor
color for the non labeled texture voxels
std::shared_ptr< WModuleInputData< WTriangleMesh > > m_meshInput1
An input connector for the reference mesh.
WPropInt m_infoTotalVertices
Info property: number of vertices.
WPropTrigger m_propWriteTrigger
trigger the writing of the labels
WPropDouble m_propProjectDistance
maximum distance to project the voxels
virtual void properties()
Initialize the properties for this module.
WPropFilename m_propAnnotationFile
filename for the annotation file
std::shared_ptr< WTriangleMesh > m_referenceMesh
A pointer to the currently processed tri mesh.
WPropColor m_propHoleColor
color for the non labeled texture voxels
std::shared_ptr< WModuleOutputData< WTriangleMesh > > m_meshOutput
Output connector provided by this module.
bool m_blankOutMesh
if set mesh colors must be initialized
virtual const std::string getName() const
Gives back the name of this module.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72