MorphoGraphX  2.0-1-227
MeshProcessCellAnalysis3D.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_ANALYSIS_3D_HPP
12 #define MESH_PROCESS_CELL_ANALYSIS_3D_HPP
13 
14 #include <Process.hpp>
15 
16 namespace mgx
17 {
18 
19 
20 class mgxBase_EXPORT ExplodeMesh : public Process
21  {
22  public:
23  ExplodeMesh(const Process& process) : Process(process)
24  {
25  setName("Mesh/Visualization 3D/Explode Mesh");
26  setDesc("Creates an exploded view on the mesh");
27  setIcon(QIcon(":/images/MakeHeatMap.png"));
28 
29  addParm("Factor X","Factor X","1");
30  addParm("Factor Y","Factor Y","1");
31  addParm("Factor Z","Factor Z","1");
32  addParm("Only Selected","Only Selected","No",booleanChoice());
33  addParm("Reverse Explosion","Reverse Explosion","Yes",booleanChoice());
34  addParm("Parents Together","Parents Together","No",booleanChoice());
35  }
36 
37  bool run()
38  {
39  Mesh* m = currentMesh();
40  return run(m, parm("Factor X").toDouble(), parm("Factor Y").toDouble(), parm("Factor Z").toDouble(), stringToBool(parm("Only Selected")), stringToBool(parm("Reverse Explosion")), stringToBool(parm("Parents Together")));
41  }
42 
43  bool run(Mesh* m, double factorX, double factorY, double factorZ, bool onlySelected, bool reverse, bool bundleParents);
44 
45  };
46 
47 class mgxBase_EXPORT TranslateByParent : public Process
48  {
49  public:
50  TranslateByParent(const Process& process) : Process(process)
51  {
52  setName("Mesh/Visualization 3D/Translate By Parent");
53  setDesc("Creates an exploded view on the mesh");
54  setIcon(QIcon(":/images/MakeHeatMap.png"));
55 
56  addParm("Transl X","Transl X","20");
57  addParm("Transl Y","Transl Y","0");
58  addParm("Transl Z","Transl Z","0");
59  addParm("Only Selected","Only Selected","No",booleanChoice());
60  addParm("Reverse Explosion","Reverse Explosion","Yes",booleanChoice());
61  addParm("Consider Rotation","Consider Rotation","Yes",booleanChoice());
62  }
63 
64  bool run()
65  {
66  Mesh* m = currentMesh();
67  Matrix4d rotMatrix;
68  m->stack()->getFrame().getMatrix(rotMatrix.data());
69  // set translation to 0, we only care about the rotation
70  rotMatrix[3][0] = 0;
71  rotMatrix[3][1] = 0;
72  rotMatrix[3][2] = 0;
73  return run(m, parm("Transl X").toDouble(), parm("Transl Y").toDouble(), parm("Transl Z").toDouble(), stringToBool(parm("Only Selected")), stringToBool(parm("Reverse Explosion")), stringToBool(parm("Consider Rotation")), rotMatrix);
74  }
75 
76  bool run(Mesh* m, double factorX, double factorY, double factorZ, bool onlySelected, bool reverse, bool rot, Matrix4d rotMatrix);
77 
78  };
79 
80 
81 class mgxBase_EXPORT RestoreOriginalMesh : public Process
82  {
83  public:
84  RestoreOriginalMesh(const Process& process) : Process(process)
85  {
86  setName("Mesh/Visualization 3D/Restore Original Mesh");
87  setDesc("Reverses any exloded view");
88  setIcon(QIcon(":/images/MakeHeatMap.png"));
89  }
90 
91  bool run()
92  {
93  Mesh* m = currentMesh();
94  return run(m, true);
95  }
96 
97  bool run(Mesh* m, bool vis);
98 
99  };
100 
101 class mgxBase_EXPORT SetParentExploded : public Process
102  {
103  public:
104  SetParentExploded(const Process& process) : Process(process)
105  {
106  setName("Mesh/Visualization 3D/Set Parent Exploded");
107  setDesc("Sets a parent label and update its position depending on the explosion");
108  setIcon(QIcon(":/images/MakeHeatMap.png"));
109 
110  addParm("Parent Label","Parent Label","0");
111  }
112 
113  bool run()
114  {
115  Mesh* m = currentMesh();
116  return run(m, parm("Parent Label").toInt());
117  }
118 
119  bool run(Mesh* m, int label);
120 
121  };
122 
128  class mgxBase_EXPORT LabelCellWalls : public Process
129  {
130  public:
131  LabelCellWalls(const Process& process) : Process(process)
132  {
133 
134  setName("Mesh/Cell Mesh/Tools/Label Cell Walls");
135  setDesc("Give each individual cell wall a separate label.\n"
136  "The Extend parameter extends walls that are not on the outside by x neighboring vertices.");
137  setIcon(QIcon(":/images/Hex.png"));
138 
139  addParm("Extend","Extend Side Wall Labels into unlabelled regions","0");
140  addParm("Only Attribute Map","If Yes, only the attribute maps are created, if No, the actual cell labels are changed","No",booleanChoice());
141  }
142 
143  bool run()
144  {
145  Mesh *m = currentMesh();
146  return run(m, parm("Extend").toInt(), stringToBool(parm("Only Attribute Map")));
147  }
148 
149  bool run(Mesh *mesh1, int extend, bool onlyAttr);
150 
151  };
152 
158  class mgxBase_EXPORT RestoreCellLabels : public Process
159  {
160  public:
161  RestoreCellLabels(const Process& process) : Process(process)
162  {
163  setName("Mesh/Cell Mesh/Tools/Restore Cell Labels");
164  setDesc("Restore the original cell labels of 3D cells.");
165  setIcon(QIcon(":/images/Hex.png"));
166  }
167 
168  bool run()
169  {
170  Mesh *m = currentMesh();
171  return run(m);
172  }
173 
174  bool run(Mesh *mesh1);
175 
176  };
177 
182  class mgxBase_EXPORT FindCellWallCenters : public Process
183  {
184  public:
185  FindCellWallCenters(const Process& process) : Process(process)
186  {
187  setName("Mesh/Cell Mesh/Tools/Cell Wall Centers");
188  setDesc("Find the centers of the cell walls");
189  setIcon(QIcon(":/images/Center.png"));
190 
191  addParm("Mode","TOREVISIT: Description missing","Average Tri Weighted", QStringList() << "Average Tri Weighted" << "Max Border Dis Vertex");
192  addParm("Create Vtxs in Mesh2","TOREVISIT: Description missing","No",booleanChoice());
193  }
194 
195  bool run()
196  {
197  Mesh *m = currentMesh();
198  Mesh *m2 = mesh(1);
199  if(m == mesh(1)) m2 = mesh(0);
200  return run(m, m2, parm("Mode"), stringToBool(parm("Create Vtxs in Mesh2")));
201  }
202 
203  bool run(Mesh *mesh1, Mesh *mesh2, QString mode, bool writeMesh);
204  };
205 
211  class mgxBase_EXPORT RotateCamera : public Process
212  {
213  public:
214  RotateCamera(const Process& process) : Process(process)
215  {
216  setName("Mesh/Visualization 3D/Rotate Camera");
217  setDesc("Rotates the camera to create simple anmations");
218  setIcon(QIcon(":/images/Hex.png"));
219 
220  addParm("X Axis","Rotation angle around x axis","0.0");
221  addParm("Y Axis","Rotation angle around y axis","0.0");
222  addParm("Z Axis","Rotation angle around z axis","360.0");
223  addParm("Steps","Rotation steps","360");
224  addParm("Break (ms)","pause between steps","100.0");
225  addParm("Stack 2","also rotate the other stack","No",booleanChoice());
226  }
227 
228  bool run()
229  {
230  Mesh *m = currentMesh();
231  Stack* s = currentStack();
232 
233  Mesh *m2 = otherMesh();
234  Stack* s2 = otherStack();
235  return run(s, m, s2, m2, parm("X Axis").toDouble(), parm("Y Axis").toDouble(), parm("Z Axis").toDouble(), parm("Steps").toInt(),
236  parm("Break (ms)").toInt(), stringToBool(parm("Stack 2")));
237  }
238 
239  bool run(Stack *s1, Mesh *m1, Stack *s2, Mesh *m2, double xRot, double yRot, double zRot, int steps, int breakStep, bool cameraStack2);
240 
241  };
242 
243 
244  class mgxBase_EXPORT LabelNuclei : public Process
245  {
246  public:
247  LabelNuclei(const Process& process) : Process(process)
248  {
249  setName("Mesh/Nucleus/Label Nuclei");
250  setDesc("Label the nuclei in mesh 2 like the cells they are located in.");
251  setIcon(QIcon(":/images/MakeHeatMap.png"));
252  }
253 
254  bool run()
255  {
256  Mesh* m = currentMesh();
257  Mesh* m2 = otherMesh();
258  return run(m, m2);
259  }
260 
261  bool run(Mesh* m, Mesh* m2);
262 
263  };
264 
265  class mgxBase_EXPORT DistanceNuclei : public Process
266  {
267  public:
268  DistanceNuclei(const Process& process) : Process(process)
269  {
270  setName("Mesh/Nucleus/Distance Nuclei");
271  setDesc("Compute distance from nucleus centroid to cell centroid. Cells in active mesh, nuclei in other mesh with cell parent labels.");
272  setIcon(QIcon(":/images/MakeHeatMap.png"));
273  }
274 
275  bool run()
276  {
277  Mesh* m = currentMesh();
278  Mesh* m2 = otherMesh();
279  return run(m, m2);
280  }
281  bool run(Mesh* m, Mesh* m2);
282  };
283 
284  class mgxBase_EXPORT SelectDuplicatedNuclei : public Process
285  {
286  public:
287  SelectDuplicatedNuclei(const Process& process) : Process(process)
288  {
289  setName("Mesh/Nucleus/Select Duplicated Nuclei");
290  setDesc("Select Duplicated Nuclei");
291  setIcon(QIcon(":/images/MakeHeatMap.png"));
292 
293  addParm("Distance Threshold","Distance Threshold","1.0"); // 0
294  }
295 
296  bool run()
297  {
298  Mesh* m = currentMesh();
299  return run(m, parm("Distance Threshold").toDouble());
300  }
301 
302  bool run(Mesh* m, double disThreshold);
303  };
304 }
305 
306 #endif
mgx::FindCellWallCenters::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:195
mgx::LabelCellWalls::LabelCellWalls
LabelCellWalls(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:131
mgx::RotateCamera::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:228
Process.hpp
mgx::TranslateByParent::TranslateByParent
TranslateByParent(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:50
mgx::RestoreCellLabels::RestoreCellLabels
RestoreCellLabels(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:161
mgx::ExplodeMesh::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:37
mgx::RestoreCellLabels
Definition: MeshProcessCellAnalysis3D.hpp:158
mgx::Mesh::stack
const Stack * stack() const
Returns the stack associated to this mesh.
Definition: Mesh.hpp:119
mgx::SetParentExploded
Definition: MeshProcessCellAnalysis3D.hpp:101
mgx::RestoreCellLabels::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:168
mgx::LabelCellWalls::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:143
mgx::RotateCamera
Definition: MeshProcessCellAnalysis3D.hpp:211
mgx::SelectDuplicatedNuclei::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:296
mgx::Stack
Definition: Stack.hpp:33
mgx::RestoreOriginalMesh::RestoreOriginalMesh
RestoreOriginalMesh(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:84
mgx::ExplodeMesh
Definition: MeshProcessCellAnalysis3D.hpp:20
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::RotateCamera::RotateCamera
RotateCamera(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:214
mgx::DistanceNuclei::DistanceNuclei
DistanceNuclei(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:268
mgx::SelectDuplicatedNuclei::SelectDuplicatedNuclei
SelectDuplicatedNuclei(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:287
mgx::LabelNuclei
Definition: MeshProcessCellAnalysis3D.hpp:244
mgx::TranslateByParent
Definition: MeshProcessCellAnalysis3D.hpp:47
mgx::Matrix::data
CU_HOST_DEVICE T * data()
Returns a raw pointer on the data.
Definition: Matrix.hpp:188
mgx::Process
Definition: Process.hpp:219
mgx::FindCellWallCenters::FindCellWallCenters
FindCellWallCenters(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:185
mgx::stringToBool
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
mgx::RestoreOriginalMesh::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:91
mgx::SetParentExploded::SetParentExploded
SetParentExploded(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:104
mgx::TranslateByParent::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:64
mgx::ExplodeMesh::ExplodeMesh
ExplodeMesh(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:23
mgx::DistanceNuclei
Definition: MeshProcessCellAnalysis3D.hpp:265
mgx::SelectDuplicatedNuclei
Definition: MeshProcessCellAnalysis3D.hpp:284
mgx::Mesh
Definition: Mesh.hpp:54
mgx::DistanceNuclei::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:275
mgx::LabelNuclei::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:254
mgx::RestoreOriginalMesh
Definition: MeshProcessCellAnalysis3D.hpp:81
mgx::LabelNuclei::LabelNuclei
LabelNuclei(const Process &process)
Definition: MeshProcessCellAnalysis3D.hpp:247
mgx::Matrix< 4, 4, double >
mgx::LabelCellWalls
Definition: MeshProcessCellAnalysis3D.hpp:128
mgx::SetParentExploded::run
bool run()
Runs the process.
Definition: MeshProcessCellAnalysis3D.hpp:113
mgx::Stack::getFrame
qglviewer::ManipulatedFrame & getFrame()
Returns the active frame (i.e.
Definition: Stack.hpp:416
mgx::FindCellWallCenters
Definition: MeshProcessCellAnalysis3D.hpp:182