MorphoGraphX
MeshProcessCreation.hpp
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef MESH_PROCESS_CREATION_HPP
12 #define MESH_PROCESS_CREATION_HPP
13 
14 #include <Process.hpp>
15 
16 #include <Polygonizer.hpp>
17 
18 namespace mgx {
19 namespace process {
22 
28 class mgxBase_EXPORT MarchingCubeSurface : public MeshProcess, public util::ImplicitFunction {
29 public:
31  : Process(process)
32  , MeshProcess(process)
33  , progress("Marching Cubes Surface", 0)
34  {
35  }
36 
37  bool operator()(const QStringList& parms)
38  {
39  if(!checkState().store(STORE_NON_EMPTY).mesh())
40  return false;
41 
42  _stack = currentStack();
43  _store = _stack->currentStore();
44  Mesh* mesh = currentMesh();
45 
46  bool result = (*this)(mesh, _store, parms[0].toFloat(), parms[1].toInt());
47  if(result)
48  mesh->showSignal();
49  if(result and not mesh->isSurfaceVisible() and not mesh->isMeshVisible())
50  mesh->showSurface();
51  return result;
52  }
53 
54  bool operator()(Mesh* mesh, const Store* store, float cubeSize, int threshold);
55 
56  QString folder() const {
57  return "Creation";
58  }
59  QString name() const {
60  return "Marching Cubes Surface";
61  }
63  {
64  return "Extract surface mesh with marching cubes. A threshold to 0 will interpret the image as binary.";
65  }
67  return QStringList() << QString("Cube size (%1)").arg(UM) << "Threshold";
68  }
70  {
71  return QStringList() << "Size for the marching cubes."
72  << "Minimal signal used for surface extraction.";
73  }
75  {
76  return QStringList() << "5.0"
77  << "5000";
78  }
79  QIcon icon() const {
80  return QIcon(":/images/MarchCubes.png");
81  }
82 
83  bool eval(Point3f p);
84 
85 private:
86  int _threshold;
87  const Stack* _stack;
88  const Store* _store;
89  Progress progress;
90 };
91 
98 class mgxBase_EXPORT MarchingCube3D : public MeshProcess, public util::ImplicitFunction {
99 public:
101  : Process(process)
102  , MeshProcess(process)
103  , progress("Marching Cubes 3D", 0)
104  {
105  }
106 
107  bool operator()(const QStringList& parms)
108  {
109  if(!checkState().store(STORE_LABEL).mesh())
110  return false;
111 
112  _stack = currentStack();
113  _store = _stack->currentStore();
114  Mesh* mesh = currentMesh();
115 
116  bool result = (*this)(mesh, _store, parms[0].toFloat(), parms[1].toInt(), parms[2].toInt(), parms[3].toInt());
117  if(result)
118  mesh->showLabel();
119  if(result and not mesh->isSurfaceVisible() and not currentMesh()->isMeshVisible())
120  currentMesh()->showSurface();
121  return result;
122  }
123 
124  bool operator()(Mesh* mesh, const Store* store, float cubeSize, int minVoxels, int smooth, int singleLabel);
125 
126  QString folder() const {
127  return "Creation";
128  }
129  QString name() const {
130  return "Marching Cubes 3D";
131  }
133  return "Extract 3D meshes with marching cubes";
134  }
136  {
137  return QStringList() << QString("Cube size (%1)").arg(UM) << "Min Voxels"
138  << "Smooth Passes"
139  << "Label";
140  }
142  {
143  return QStringList() << "Size for the marching cubes."
144  << "Minimal number of voxels for extracting surface."
145  << "Smooth Passes."
146  << "Extract surface only for this label.";
147  }
149  {
150  return QStringList() << "5.0"
151  << "0"
152  << "3"
153  << "0";
154  }
155  QIcon icon() const {
156  return QIcon(":/images/MarchCubes3D.png");
157  }
158 
159  bool eval(Point3f p);
160 
161 private:
162  int _label;
163  const Stack* _stack;
164  const Store* _store;
165  Progress progress;
166 };
167 
174 class mgxBase_EXPORT CuttingSurfMesh : public MeshProcess {
175 public:
177  : Process(process)
178  , MeshProcess(process)
179  {
180  }
181 
182  bool operator()(const QStringList& )
183  {
184  if(!checkState().mesh())
185  return false;
186  return (*this)(currentMesh());
187  }
188 
189  bool operator()(Mesh* mesh);
190 
191  QString folder() const {
192  return "Creation";
193  }
194  QString name() const {
195  return "Mesh Cutting Surface";
196  }
198  return "Make mesh from cutting surface";
199  }
201  return QStringList();
202  }
204  return QStringList();
205  }
206  QIcon icon() const {
207  return QIcon(":/images/MakePlane.png");
208  }
209 };
211 } // namespace process
212 } // namespace mgx
213 
214 #endif
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessCreation.hpp:37
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessCreation.hpp:206
Definition: Polygonizer.hpp:36
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessCreation.hpp:200
arg(const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char( ' ')
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessCreation.hpp:66
QString name() const
Returns the name of the process.
Definition: MeshProcessCreation.hpp:59
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessCreation.hpp:203
QString folder() const
Folder in which to place the process.
Definition: MeshProcessCreation.hpp:126
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessCreation.hpp:141
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:35
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:177
Definition: MeshProcessCreation.hpp:98
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessCreation.hpp:148
Create a surface matching the current cutting surface, whether it&#39;s a plane or a Bezier surface...
Definition: MeshProcessCreation.hpp:174
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessCreation.hpp:135
Definition: Progress.hpp:99
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessCreation.hpp:182
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessCreation.hpp:107
Find the surface of a volume defined by an iso-surface on the image intensity using a variation on th...
Definition: MeshProcessCreation.hpp:28
File containing the definition of a Process.
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:35
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessCreation.hpp:155
This is the main process class, the one all process inherit from.
Definition: Process.hpp:258
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessCreation.hpp:197
This namespace contains all the classes needed to define processes.
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessCreation.hpp:132
QString name() const
Returns the name of the process.
Definition: MeshProcessCreation.hpp:129
QString folder() const
Folder in which to place the process.
Definition: MeshProcessCreation.hpp:191
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessCreation.hpp:62
QString folder() const
Folder in which to place the process.
Definition: MeshProcessCreation.hpp:56
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessCreation.hpp:74
QString name() const
Returns the name of the process.
Definition: MeshProcessCreation.hpp:194
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:865
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessCreation.hpp:79
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessCreation.hpp:69