MorphoGraphX  2.0-1-227
DivisionAnalysisUtils.hpp
Go to the documentation of this file.
1 #ifndef DivisionAnalysisUtils_H
2 #define DivisionAnalysisUtils_H
3 
4 #include <Process.hpp> // for vvGraph, forall, ...
5 #include <GraphUtils.hpp> // for neighborhoodGraph
6 #include <GraphAlgorithms.hpp>
7 
8 //#include "DivisionAnalysisData.hpp"
9 
10 
11 using namespace std;
12 
13 // DivisionAnalysisUtils contains typedefs and class-independent helper-functions for the DivisionAnalysis AddOn
14 namespace mgx
15 {
16 
17  typedef std::pair<Point3d, double> P3dDouble;
18 
19  typedef std::pair<cell, double> VtxDouble;
20  typedef std::pair<std::set<cell>, std::set<cell> > CellSetPair;
21  typedef std::pair<cell,cell> cCPair;
22  typedef std::pair<Point3d, bool> P3dboolPair;
23  typedef std::pair<cell, double> cellDPair;
24 
25  typedef std::pair<Point3d, int> P3dInt;
26  typedef std::pair<P3dDouble, double> P3dDD;
27  typedef std::pair<Point3d,Point3d> P3dP3d;
28 
29 
30  typedef std::pair<int, int> IntInt;
31  typedef std::pair<IntInt, double> IntIntDouble;
32  typedef std::pair<vertex, vertex> VtxVtx;
33  typedef std::pair<VtxVtx, vertex> Tri;
34  typedef std::pair<VtxVtx, vertex> Vtxvtxp;
35  typedef std::pair<vertex, int> VtxInt;
36 
37  // typedef pair<IntInt, double> IID;
38 
39  //typedef Vector<3, vertex> tri;
40  typedef pair<Triangle, int> TriInt;
41 
51  bool writeCsvFile(QString filename, QString header, vector<vector<double> >& data);
52 
61  double calcRatio(double value1, double value2);
62 
70  double avgCellSizeMGX3D(const cell &c);
71 
80  double divisionPlaneArea(Point3d cellCenter, const std::vector<Point3d>& v);
81 
90  double divisionPlaneAreaMulti(Point3d cellCenter, const std::vector<std::vector<Point3d> >& vMulti);
91 
102  bool findCell(cellGraph& C, cell& searchedCell, int label, int& maxLabel);
103 
113  void calcCellGraphJoinedCells(cellGraph &C, const cell& c1, const cell& c2);
114 
123  void copyCellGraph(CellTissue &orig, CellTissue &copy);
124 
132  std::vector<Point3d> getSharedVtxs(const cell& c1, const cell& c2);
133 
134  std::set<Triangle> getSharedTris(const cell& c1, const cell& c2);
135 
136  double calcTriArea(std::set<Triangle>& tris);
137 
145  void calcJoinedCell(const cell& c1, const cell& c2, vvGraph& result, bool simple);
146 
154  void generateSamplingDirectionsNew(int nrPlanes, int centerVarSteps, double centerVarStepSize, std::vector<P3dDouble>& samplingDirections);
155  void generateSamplingDirections(double resolution, int centerVarSteps, double centerVarStepSize, std::vector<P3dDouble>& samplingDirections);
156 
157  void generateSamplingDirections(double resolution, int centerVarSteps, double centerVarStepSize,
158  Point3d perpendicularPlane, std::set<Point3d> perpPlaneNormals2, bool enforceDivThroughNeighbor,
159  std::vector<P3dDouble>& samplingDirections);
160 
161 void addCenterDisplacementTestCut(int centerVarSteps, double centerVarStepSize, Point3d cellCenter, Point3d perpendicularPlane,
162  std::set<Point3d> perpPlaneNormals2,
163  std::unordered_map<Point3d, Point3d>& wallCenter, std::unordered_map<Point3d, std::vector<Point3d> > wallPoints,
164  std::vector<P3dDouble>& samplingDirections);
165 
166 double calcVolume(vector<Triangle> tris);
167 
168 bool planeSegmentIntersect(const Point3d &p, const Point3d &nrml, const Point3d &u1, const Point3d &u2, Point3d &intersectP);
169 
170 void findNeighbTris(cellGraph& C, const cell& c, std::map<cell, std::vector<Triangle> >& neighbTris);
171 
172 // creates a map of all tris of a cell to the label of the neighbor cell, -1 if theres none
173 void cellTriNeighbors(cellGraph& C, const cell& c, std::map<Triangle, int>& trisNeighbMap);
174 
175  // estimates the volume of a 3D body with 1 open side, open Edges need to be oriented right
176 double estimateVolumeOpenBody(std::vector<Triangle> tris, set<vertex>& exposedVtxs);
177 
178 // estimate the volume of the non-closed daughter cells
179 void estimateVolumeDaughterCells(std::vector<Triangle>& trisLeft, std::vector<Triangle>& trisRight, std::vector<Triangle>& trisSplit);
180 
181  // returns the labels of all neighbors of a vertex
182  //std::set<int> getNeighborLabels(vvGraph& S, const vertex& v);
183 
184  // calculates the random walk betweeness centrality for the (weighted) cell graph
186 
187  void calcRandWalkBetweenness(std::map<IntInt, double>& neighborhoodWeights, std::map<int, int>& labelPosMap, std::vector<int>& orderedLabels,
188  std::map<int, double>& cellBetweenessMap, bool useGPU);
189 
190 
191  void calcRandWalkBetweenness(cellGraph &C, std::map<IntInt, double>& weights, std::map<cell, double>& cellBetweenessMap,
192  bool useGPU, bool doRevCuthill);
193 
194  void calcRandWalkBetweenness(std::map<IntInt, double>& neighborhoodGraph, std::map<int, double>& labelBetweenessMap, bool useGPU);
195 
196 void separateIdenticalVtxs(const cell &c);
197 
198 bool planePolygonIntersect(Point3d planeNrml, Point3d planePos, std::vector<Point3d> polygonVtxs);
199 
200 std::vector<Triangle> getTrisOfCells(Mesh *m, int selectedLabel, bool parentMode);
201 
202 std::vector<vertex> getVtxsOfCells(Mesh *m, int selectedLabel, bool parentMode);
203 
204 std::vector<vertex> getOrRemoveCommonWall(Mesh *m, std::vector<vertex>& cellVtxs, bool removeCommon, bool includeEdgeOfShared);
205 
206 std::vector<Triangle> getOrRemoveCommonWall(Mesh *mesh, std::vector<Triangle>& cellTris, bool removeCommon, bool mergeDuplicated);
207 
208 typedef std::pair<Point3d, Point3d> PlaneNrmlPoint;
209 
210  void assembleCellFromWalls(vvGraph& S, std::vector<vertex> vtxs, std::vector<Point3i> tris,
211  std::set<vertex> &borderVtxs, double mergingThreshold, int labelCounter, bool orientCheck);
212 
213 
214 
215 }
216 
217 #endif
mgx::cCPair
std::pair< cell, cell > cCPair
Definition: DivisionAnalysisUtils.hpp:21
mgx::calcVolume
double calcVolume(vector< Triangle > tris)
mgx::avgCellSizeMGX3D
double avgCellSizeMGX3D(const cell &c)
returns an approximation of the 3D cell size (the average of the distance of every vertex to the cell...
mgx::cellDPair
std::pair< cell, double > cellDPair
Definition: DivisionAnalysisUtils.hpp:23
mgx::planeSegmentIntersect
bool planeSegmentIntersect(const Point3d &p, const Point3d &nrml, const Point3d &u1, const Point3d &u2, Point3d &intersectP)
mgx::generateSamplingDirectionsNew
void generateSamplingDirectionsNew(int nrPlanes, int centerVarSteps, double centerVarStepSize, std::vector< P3dDouble > &samplingDirections)
returns the area of a polygon
mgx::P3dP3d
std::pair< Point3d, Point3d > P3dP3d
Definition: DivisionAnalysisUtils.hpp:27
Process.hpp
mgx::getSharedVtxs
std::vector< Point3d > getSharedVtxs(const cell &c1, const cell &c2)
returns the area of a polygon
mgx::VtxInt
std::pair< vertex, int > VtxInt
Definition: DivisionAnalysisUtils.hpp:35
mgx::IntInt
std::pair< int, int > IntInt
Definition: GraphAlgorithms.hpp:27
mgx::getOrRemoveCommonWall
std::vector< Triangle > getOrRemoveCommonWall(Mesh *mesh, std::vector< Triangle > &cellTris, bool removeCommon, bool mergeDuplicated)
GraphUtils.hpp
mgx::divisionPlaneArea
double divisionPlaneArea(Point3d cellCenter, const std::vector< Point3d > &v)
returns the area of a polygon (=division plane)
mgx::CellTissue
Definition: CellTissue.hpp:46
mgx::c2
CU_HOST_DEVICE const const T T c2
Definition: Geometry.hpp:234
mgx::cellTriNeighbors
void cellTriNeighbors(cellGraph &C, const cell &c, std::map< Triangle, int > &trisNeighbMap)
mgx::findCell
bool findCell(cellGraph &C, cell &searchedCell, int label, int &maxLabel)
returns whether a cell with the specified label exists, also provides the cell and the max Label of a...
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::neighborhoodGraph
mgx_EXPORT bool neighborhoodGraph(const vvGraph &S, double tolerance, NhbdGraphInfo &info, bool throwError=true)
mgx::getSharedTris
std::set< Triangle > getSharedTris(const cell &c1, const cell &c2)
mgx::generateSamplingDirections
void generateSamplingDirections(double resolution, int centerVarSteps, double centerVarStepSize, Point3d perpendicularPlane, std::set< Point3d > perpPlaneNormals2, bool enforceDivThroughNeighbor, std::vector< P3dDouble > &samplingDirections)
mgx::VtxVtx
std::pair< vertex, vertex > VtxVtx
Definition: DivisionAnalysis.hpp:22
mgx::calcRatio
double calcRatio(double value1, double value2)
return the ratio ( = bigger value divided by smaller value)
mgx::assembleCellFromWalls
void assembleCellFromWalls(vvGraph &S, std::vector< vertex > vtxs, std::vector< Point3i > tris, std::set< vertex > &borderVtxs, double mergingThreshold, int labelCounter, bool orientCheck)
mgx::VtxDouble
std::pair< cell, double > VtxDouble
Definition: DivisionAnalysisUtils.hpp:19
mgx::estimateVolumeOpenBody
double estimateVolumeOpenBody(std::vector< Triangle > tris, set< vertex > &exposedVtxs)
mgx::writeCsvFile
bool writeCsvFile(QString filename, QString header, vector< vector< double > > &data)
write a 2D array to a (csv) file
mgx::nrml
nrml
Definition: Geometry.hpp:240
mgx::addCenterDisplacementTestCut
void addCenterDisplacementTestCut(int centerVarSteps, double centerVarStepSize, Point3d cellCenter, Point3d perpendicularPlane, std::set< Point3d > perpPlaneNormals2, std::unordered_map< Point3d, Point3d > &wallCenter, std::unordered_map< Point3d, std::vector< Point3d > > wallPoints, std::vector< P3dDouble > &samplingDirections)
mgx::P3dDouble
std::pair< Point3d, double > P3dDouble
Definition: DivisionAnalysisUtils.hpp:17
mgx::P3dDD
std::pair< P3dDouble, double > P3dDD
Definition: DivisionAnalysisUtils.hpp:26
mgx::calcCellGraphJoinedCells
void calcCellGraphJoinedCells(cellGraph &C, const cell &c1, const cell &c2)
add the neighbors of c2 to the cell graph of c1
mgx::separateIdenticalVtxs
void separateIdenticalVtxs(const cell &c)
mgx::copyCellGraph
void copyCellGraph(CellTissue &orig, CellTissue &copy)
copies the cell graph, used for simulating cell division (without altering the original)
mgx::c1
CU_HOST_DEVICE const const T c1
Definition: Geometry.hpp:234
mgx::calcRandWalkBetweenness
void calcRandWalkBetweenness(std::map< IntInt, double > &neighborhoodGraph, std::map< int, double > &labelBetweenessMap, bool useGPU)
mgx::P3dInt
std::pair< Point3d, int > P3dInt
Definition: DivisionAnalysisUtils.hpp:25
mgx::Vtxvtxp
std::pair< VtxVtx, vertex > Vtxvtxp
Definition: DivisionAnalysisUtils.hpp:34
mgx::Mesh
Definition: Mesh.hpp:54
mgx::getTrisOfCells
std::vector< Triangle > getTrisOfCells(Mesh *m, int selectedLabel, bool parentMode)
GraphAlgorithms.hpp
mgx::IntIntDouble
std::pair< IntInt, double > IntIntDouble
Definition: GraphAlgorithms.hpp:28
mgx::Vector< 3, double >
mgx::calcJoinedCell
void calcJoinedCell(const cell &c1, const cell &c2, vvGraph &result, bool simple)
returns the area of a polygon
mgx::estimateVolumeDaughterCells
void estimateVolumeDaughterCells(std::vector< Triangle > &trisLeft, std::vector< Triangle > &trisRight, std::vector< Triangle > &trisSplit)
mgx::TriInt
pair< Triangle, int > TriInt
Definition: DivisionAnalysisUtils.hpp:40
mgx::CellSetPair
std::pair< std::set< cell >, std::set< cell > > CellSetPair
Definition: DivisionAnalysisUtils.hpp:20
mgx::divisionPlaneAreaMulti
double divisionPlaneAreaMulti(Point3d cellCenter, const std::vector< std::vector< Point3d > > &vMulti)
returns the summed area of multiple polygons (=division planes)
mgx::getVtxsOfCells
std::vector< vertex > getVtxsOfCells(Mesh *m, int selectedLabel, bool parentMode)
mgx::calcTriArea
double calcTriArea(std::set< Triangle > &tris)
mgx::PlaneNrmlPoint
std::pair< Point3d, Point3d > PlaneNrmlPoint
Definition: DivisionAnalysisUtils.hpp:208
mgx::VVGraph
Definition: VVGraph.hpp:162
mgx::planePolygonIntersect
bool planePolygonIntersect(Point3d planeNrml, Point3d planePos, std::vector< Point3d > polygonVtxs)
mgx::Tri
std::pair< VtxVtx, vertex > Tri
Definition: DivisionAnalysisUtils.hpp:33
mgx::P3dboolPair
std::pair< Point3d, bool > P3dboolPair
Definition: DivisionAnalysisUtils.hpp:22
mgx::findNeighbTris
void findNeighbTris(cellGraph &C, const cell &c, std::map< cell, std::vector< Triangle > > &neighbTris)
mgx::Vertex
Definition: Vertex.hpp:58
mgx::map
CU_HOST_DEVICE Vector< dim, T > map(const T &(*fct)(const T1 &), const Vector< dim, T1 > &v)
Definition: Vector.hpp:1380