MorphoGraphX  2.0-1-227
MeshProcessCreation.hpp
Go to the documentation of this file.
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 {
22 
28  class mgxBase_EXPORT MarchingCubeSurface : public Process, public ImplicitFunction
29  {
30  public:
31  MarchingCubeSurface(const Process& process) : Process(process)
32  {
33 
34  setName("Mesh/Creation/Marching Cubes Surface");
35  setDesc("Extract surface mesh with marching cubes. A threshold to 0 will interpret the image as binary.");
36  setIcon(QIcon(":/images/MarchCubes.png"));
37  addParm("Cube size (µm)","Size for the marching cubes.","5.0"); // 0
38  addParm("Threshold","Minimal signal used for surface extraction.","5000"); // 1
39 
40  }
41 
42  bool run()
43  {
44  if(!checkState().store(STORE_NON_EMPTY).mesh())
45  return false;
46 
47  _stack = currentStack();
48  _store = _stack->currentStore();
49  Mesh* mesh = currentMesh();
50 
51  bool result = run(mesh, _store, parm("Cube size (µm)").toFloat(), parm("Threshold").toInt());
52  if(result)
53  mesh->setShowVertex("Signal");
54  if(result and not mesh->showSurface() and not mesh->showMesh())
55  mesh->setShowSurface(true);
56  return result;
57  }
58 
59  bool run(Mesh* mesh, const Store* store, float cubeSize, int threshold);
60 
61  bool eval(Point3f p);
62 
63  private:
64  int _threshold;
65  const Stack* _stack;
66  const Store* _store;
67  };
68 
75  class mgxBase_EXPORT MarchingCube3D : public Process, public ImplicitFunction
76  {
77  public:
78  MarchingCube3D(const Process& process) : Process(process)
79  {
80  setName("Mesh/Creation/Marching Cubes 3D");
81  setDesc("Extract 3D meshes with marching cubes");
82  setIcon(QIcon(":/images/MarchCubes3D.png"));
83 
84  addParm("Cube size (µm)","Size for the marching cubes.","5.0"); // 0
85  addParm("Min Voxels","Minimal number of voxels for extracting surface.","0"); // 1
86  addParm("Smooth Passes","Smooth Passes.","3"); // 2
87  addParm("Label","Extract surface only for this label.","0"); // 3
88  }
89 
90  bool run()
91  {
92  if(!checkState().store(STORE_LABEL).mesh())
93  return false;
94 
95  _stack = currentStack();
96  _store = _stack->currentStore();
97  Mesh* mesh = currentMesh();
98 
99  bool result = run(mesh, _store, parm("Cube size (µm)").toFloat(), parm("Min Voxels").toInt(),
100  parm("Smooth Passes").toInt(), parm("Label").toInt());
101  if(result)
102  mesh->setShowLabel();
103  if(result and not mesh->showSurface() and not currentMesh()->showMesh())
104  currentMesh()->setShowSurface(true);
105  return result;
106  }
107 
108  bool run(Mesh* mesh, const Store* store, float cubeSize, int minVoxels,
109  int smooth, int singleLabel);
110 
111  bool eval(Point3f p);
112 
113  private:
114  int _label;
115  const Stack* _stack;
116  const Store* _store;
117  };
118 
125  class mgxBase_EXPORT CuttingSurfMesh : public Process
126  {
127  public:
128  CuttingSurfMesh(const Process& process) : Process(process)
129  {
130  setName("Mesh/Creation/Mesh Cutting Surface");
131  setDesc("Make mesh from cutting surface");
132  }
133 
134  bool run()
135  {
136  if(!checkState().mesh())
137  return false;
138  return run(currentMesh());
139  }
140 
141  bool run(Mesh* mesh);
142  };
143 
149  class mgxBase_EXPORT VoxelFaceMesh : public Process
150  {
151  public:
152  VoxelFaceMesh(const Process& process) : Process(process)
153  {
154  setName("Mesh/Creation/Voxel Face Mesh");
155  setDesc("Extract a mesh from the faces of the voxels.");
156  }
157 
158  bool run()
159  {
160  if(!checkState().mesh().store(STORE_LABEL))
161  return false;
162  return run(currentStack(), currentStack()->currentStore(), currentMesh());
163  }
164 
165  bool run(Stack *stack, Store *store, Mesh *mesh);
166  };
167 
168 
169  class mgxBase_EXPORT MeshFromLocalMaxima : public Process {
170  public:
171  MeshFromLocalMaxima(const Process& process) : Process(process)
172  {
173  setName("Mesh/Creation/Mesh From Local Maxima");
174  setDesc("Create a Mesh from Local Maxima");
175 
176  addParm("Radius (µm)","Radius (µm)","3.0");
177 
178  }
179 
180  bool run()
181  {
182  if(!checkState().store(STORE_NON_EMPTY))
183  return false;
184  return run(currentMesh(), currentStack()->currentStore(), parm("Radius (µm)").toFloat());
185  }
186 
187  bool run(Mesh* mesh, const Store* store, float radius);
188  };
190 }
191 
192 #endif
mgx::MarchingCubeSurface
Definition: MeshProcessCreation.hpp:28
mgx::ImplicitFunction
Definition: Polygonizer.hpp:36
Process.hpp
mgx::MeshFromLocalMaxima::MeshFromLocalMaxima
MeshFromLocalMaxima(const Process &process)
Definition: MeshProcessCreation.hpp:171
Polygonizer.hpp
mgx::Mesh::showMesh
bool showMesh() const
Is the mesh currently visible to the user.
Definition: Mesh.hpp:733
mgx::Mesh::setShowLabel
void setShowLabel(const QString &s="", bool setView=true)
Set the surface label display.
Definition: Mesh.hpp:621
mgx::MeshFromLocalMaxima
Definition: MeshProcessCreation.hpp:169
mgx::Mesh::showSurface
bool showSurface() const
True if the surface is currently visible to the user.
Definition: Mesh.hpp:589
mgx::Mesh::setShowSurface
void setShowSurface(bool val=true)
Show the surface to the user.
Definition: Mesh.hpp:594
mgx::CuttingSurfMesh::CuttingSurfMesh
CuttingSurfMesh(const Process &process)
Definition: MeshProcessCreation.hpp:128
mgx::MarchingCubeSurface::run
bool run()
Runs the process.
Definition: MeshProcessCreation.hpp:42
mgx::MarchingCubeSurface::MarchingCubeSurface
MarchingCubeSurface(const Process &process)
Definition: MeshProcessCreation.hpp:31
mgx::Stack
Definition: Stack.hpp:33
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::MarchingCube3D::run
bool run()
Runs the process.
Definition: MeshProcessCreation.hpp:90
mgx::MarchingCube3D
Definition: MeshProcessCreation.hpp:75
mgx::CuttingSurfMesh
Definition: MeshProcessCreation.hpp:125
mgx::CuttingSurfMesh::run
bool run()
Runs the process.
Definition: MeshProcessCreation.hpp:134
mgx::MeshFromLocalMaxima::run
bool run()
Runs the process.
Definition: MeshProcessCreation.hpp:180
mgx::Process
Definition: Process.hpp:219
mgx::Mesh
Definition: Mesh.hpp:54
mgx::MarchingCube3D::MarchingCube3D
MarchingCube3D(const Process &process)
Definition: MeshProcessCreation.hpp:78
mgx::Vector< 3, float >
mgx::VoxelFaceMesh::run
bool run()
Runs the process.
Definition: MeshProcessCreation.hpp:158
mgx::Mesh::setShowVertex
void setShowVertex(const QString &s="", bool setView=true)
Set the surface vertex display.
Definition: Mesh.hpp:599
mgx::VoxelFaceMesh::VoxelFaceMesh
VoxelFaceMesh(const Process &process)
Definition: MeshProcessCreation.hpp:152
mgx::VoxelFaceMesh
Definition: MeshProcessCreation.hpp:149
mgx::Store
Definition: Store.hpp:33