MorphoGraphX  2.0-1-227
MeshProcessCellMesh.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2016 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_CELL_MESH_HPP
12 #define MESH_PROCESS_CELL_MESH_HPP
13 
14 #include <Process.hpp>
15 
17 
18 namespace mgx
19 {
22 
32  class mgxBase_EXPORT FixMeshCorners : public Process
33  {
34  public:
35  FixMeshCorners(const Process& process) : Process(process)
36  {
37  setName("Mesh/Cell Mesh/Fix Corners Classic");
38  setDesc("Fix labelling of cell corners.");
39  setIcon(QIcon(":/images/FixCorners.png"));
40 
41  addParm("Auto segmentation?","Re-run watershed automatically at each turn.","Yes",booleanChoice());
42  addParm("Select bad vertices","Select remaining bad vertices at the end. \n"
43  "Helps in deleting bad vertices that cannot be segmented properly.","Yes",booleanChoice());
44  addParm("Max iterations","Maximal number of turns.","5");
45  }
46 
47  bool run()
48  {
49  if(!checkState().mesh(MESH_NON_EMPTY))
50  return false;
51  if(parm("Max iterations").toInt() < 1) {
52  setErrorMessage("Number of runs must be at least one.");
53  return false;
54  }
55  return run(currentMesh(), stringToBool(parm("Auto segmentation?")),
56  stringToBool(parm("Select bad vertices")), parm("Max iterations").toInt());
57  }
58 
59  bool run(Mesh* mesh, bool autoSegment, bool selectBadVertices, int maxRun);
60 
61  };
62 
69  class mgxBase_EXPORT FixBorderTriangles : public Process
70  {
71  public:
72  FixBorderTriangles(const Process& process) : Process(process)
73  {
74  setName("Mesh/Cell Mesh/Fix Corner Triangles");
75  setDesc("Fix labelling of triangles in the cell corners.");
76  setIcon(QIcon(":/images/FixCorners.png"));
77  }
78 
79  bool run()
80  {
81  if(!checkState().mesh(MESH_NON_EMPTY))
82  return false;
83  return run(currentMesh());
84  }
85 
86  bool run(Mesh* mesh);
87 
88  };
89 
90  // Convert to a normal mesh
91  class mgxBase_EXPORT ConvertToMgxm : public Process
92  {
93  public:
94  ConvertToMgxm(const Process &process) : Process(process)
95  {
96  setName("Mesh/Cell Mesh/Convert to a normal mesh");
97  setDesc("Convert any mesh back to a normal (MGXM) mesh");
98  setIcon(QIcon(":/images/MakeCells.png"));
99  }
100 
101  // Process default parameters
102  bool run()
103  {
104  if(!checkState().mesh(MESH_NON_EMPTY))
105  return(false);
106  return run(currentMesh());
107  }
108  // Convert the mesh
109  bool run(Mesh* mesh);
110 
111  };
112 
120  class mgxBase_EXPORT ConvertToMgxc : public Process
121  {
122  public:
123  ConvertToMgxc(const Process &process) : Process(process)
124  {
125  setName("Mesh/Cell Mesh/Convert to a cell mesh");
126  setDesc("Convert a segmented mesh into a cell mesh (MGXC). \n"
127  "The simplified mesh contains only vertices for cell centers and cell outlines."
128  "The process will also convert a 2D cell tissue (MGX2D) back to a cell mesh (MGXC).");
129  setIcon(QIcon(":/images/MakeCells.png"));
130 
131  addParm("Max Wall Length (µm)","Length between vertices to keep, 0 keeps only junctions, -1 keeps everything.","-1"); // 0
132  }
133 
134  bool run()
135  {
136  if(!checkState().mesh(MESH_NON_EMPTY))
137  return false;
138  return run(currentMesh(), parm("Max Wall Length (µm)").toDouble());
139  }
140 
141  bool run(Mesh* mesh, double wallMax);
142 
143  };
144 
145  // Convert to 2D cell tissue
146  class mgxBase_EXPORT ConvertToMgx2d : public Process
147  {
148  public:
149  ConvertToMgx2d(const Process &process) : Process(process)
150  {
151  setName("Mesh/Cell Mesh/Convert to 2D Cell Tissue");
152  setDesc("Convert a cell (MGXC) mesh to a 2D Cellular Tissue (MGX2D)");
153  setIcon(QIcon(":/images/MakeCells.png"));
154 
155  addParm("Max Wall Length (µm)","Length between vertices to keep, 0 keeps only junctions, -1 keeps everything.","-1"); // 0
156  }
157 
158  // Process default parameters
159  bool run()
160  {
161  if(!checkState().mesh(MESH_NON_EMPTY))
162  return(false);
163  return run(currentMesh(), parm("Max Wall Length (µm)").toDouble());
164  }
165  // Convert the mesh
166  bool run(Mesh* mesh, double wallMax);
167 
168  };
169 
170  // Convert to 3D cell tissue
171  class mgxBase_EXPORT ConvertToMgx3d : public Process
172  {
173  public:
174  ConvertToMgx3d(const Process &process) : Process(process)
175  {
176  setName("Mesh/Cell Mesh/Convert to 3D Cell Tissue");
177  setDesc("Convert a (MGXM) mesh that is a group of closed 3D cells to a 3D Cellular Tissue (MGX3D)");
178  setIcon(QIcon(":/images/MakeCells.png"));
179 
180  addParm("Tolerance (µm)","Tolerance for merging vertices. Vertices closer than this will be merged.",".01");
181  addParm("Neighbour Min Area","Cells with at least this shared area will be considered as neighbors",".01");
182  }
183 
184  // Process default parameters
185  bool run()
186  {
187  if(!checkState().mesh(MESH_NON_EMPTY))
188  return(false);
189  return run(currentMesh(), parm("Tolerance (µm)").toDouble(), parm("Neighbour Min Area").toDouble());
190  }
191  // Convert the mesh
192  bool run(Mesh* mesh, double tolerance, double neighborMinArea);
193 
194  };
195 
204  class mgxBase_EXPORT SurfaceFromMGX3D : public Process
205  {
206  public:
207  SurfaceFromMGX3D(const Process& process) : Process(process)
208  {
209  setName("Mesh/Cell Mesh/Tools/Surface mesh from MGX3D");
210  setDesc("Convert MGX3D to normal mesh, keeping only triangles not shared between cells.");
211  setIcon(QIcon(":/images/MakeCells.png"));
212  }
213 
214  bool run()
215  {
216  if(!checkState().mesh(MESH_NON_EMPTY))
217  return false;
218  Mesh* mesh1, *mesh2;
219  if(currentMesh() == mesh(0)) {
220  mesh1 = mesh(0);
221  mesh2 = mesh(1);
222  } else if(currentMesh() == mesh(1)) {
223  mesh2 = mesh(0);
224  mesh1 = mesh(1);
225  } else
226  return false;
227 
228  return run(mesh1, mesh2);
229  }
230 
231  bool run(Mesh* mesh1, Mesh* mesh2);
232 
233  };
234 
235 
241  class mgxBase_EXPORT RelabelFragments : public Process
242  {
243  public:
244  RelabelFragments(const Process& process)
245  : Process(process)
246  {
247  setName("Mesh/Cell Mesh/Tools/Relabel Fragments");
248  setDesc("Find multiple separate pieces of the same label, keep largest piece and relabel or unlabel (label 0) the rest \n"
249  "Unlabel for Threshold -1, Relabel for > -1");
250  setIcon(QIcon(":/images/CHull.png"));
251 
252  addParm("Relabel Threshold","Relabel Threshold in Vtxs. Set to -1 if pieces should be unlabeled.","-1"); // 0
253  }
254 
255  bool run(){
256  Mesh *m = currentMesh();
257  return run(m, parm("Relabel Threshold").toInt());
258  }
259  bool run(Mesh *mesh1, int relabelThreshold);
260 
261  };
262 
263 
269  class mgxBase_EXPORT ExtendCells : public Process
270  {
271  public:
272  ExtendCells(const Process& process) : Process(process)
273  {
274  setName("Mesh/Cell Mesh/Tools/Extend Cells");
275  setDesc("Extends cells into unlabeled regions");
276  setIcon(QIcon(":/images/CHull.png"));
277  }
278 
279  bool run(){
280  Mesh *m = currentMesh();
281  return run(m);
282  }
283  bool run(Mesh *m);
284 
285  };
286 
287 }
288 #endif
mgx::ConvertToMgxc::ConvertToMgxc
ConvertToMgxc(const Process &process)
Definition: MeshProcessCellMesh.hpp:123
mgx::FixMeshCorners
Definition: MeshProcessCellMesh.hpp:32
Process.hpp
mgx::FixBorderTriangles::FixBorderTriangles
FixBorderTriangles(const Process &process)
Definition: MeshProcessCellMesh.hpp:72
mgx::ConvertToMgxm
Definition: MeshProcessCellMesh.hpp:91
mgx::FixBorderTriangles
Definition: MeshProcessCellMesh.hpp:69
mgx::ConvertToMgx3d::ConvertToMgx3d
ConvertToMgx3d(const Process &process)
Definition: MeshProcessCellMesh.hpp:174
mgx::ConvertToMgxm::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:102
mgx::ExtendCells::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:279
mgx::ConvertToMgx2d::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:159
mgx::ExtendCells
Definition: MeshProcessCellMesh.hpp:269
mgx::RelabelFragments::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:255
mgx::FixBorderTriangles::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:79
mgx::ConvertToMgx3d
Definition: MeshProcessCellMesh.hpp:171
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::ConvertToMgxc
Definition: MeshProcessCellMesh.hpp:120
mgx::ConvertToMgx3d::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:185
mgx::RelabelFragments::RelabelFragments
RelabelFragments(const Process &process)
Definition: MeshProcessCellMesh.hpp:244
mgx::ExtendCells::ExtendCells
ExtendCells(const Process &process)
Definition: MeshProcessCellMesh.hpp:272
mgx::Process
Definition: Process.hpp:219
mgx::stringToBool
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
mgx::FixMeshCorners::FixMeshCorners
FixMeshCorners(const Process &process)
Definition: MeshProcessCellMesh.hpp:35
mgx::SurfaceFromMGX3D::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:214
mgx::Mesh
Definition: Mesh.hpp:54
MeshProcessSegmentation.hpp
mgx::ConvertToMgxc::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:134
mgx::ConvertToMgx2d
Definition: MeshProcessCellMesh.hpp:146
mgx::SurfaceFromMGX3D
Definition: MeshProcessCellMesh.hpp:204
mgx::ConvertToMgxm::ConvertToMgxm
ConvertToMgxm(const Process &process)
Definition: MeshProcessCellMesh.hpp:94
mgx::SurfaceFromMGX3D::SurfaceFromMGX3D
SurfaceFromMGX3D(const Process &process)
Definition: MeshProcessCellMesh.hpp:207
mgx::RelabelFragments
Definition: MeshProcessCellMesh.hpp:241
mgx::FixMeshCorners::run
bool run()
Runs the process.
Definition: MeshProcessCellMesh.hpp:47
mgx::ConvertToMgx2d::ConvertToMgx2d
ConvertToMgx2d(const Process &process)
Definition: MeshProcessCellMesh.hpp:149