Go to the documentation of this file.
11 #ifndef GRAPH_UTILS_HPP
12 #define GRAPH_UTILS_HPP
21 typedef std::pair<int, int>
IntInt;
50 template<
typename GraphT>
51 bool spliceNhbs(GraphT &S,
typename GraphT::vertex_t a,
typename GraphT::vertex_t b)
53 typename GraphT::vertex_t
n = S.nextTo(b, a);
54 typename GraphT::vertex_t pv = b;
56 if(!S.edge(a,b) or !S.edge(b,a))
61 S.spliceAfter(a, pv,
n);
62 S.spliceAfter(
n, b, a);
254 std::map<IntInt, std::set<std::pair<Triangle,Triangle> > >
sharedTris;
295 mgx_EXPORT
void neighborhood2D(
vvGraph& S, std::map<IntInt, double>& neighMap, QString weightType =
"",
bool ignoreOutside =
true);
302 mgx_EXPORT std::map<int, double>
dijkstra
303 (
vvGraph& S, std::map<IntInt, double>& wallAreas, std::set<int>& selectedCells,
304 bool equalWeights,
double cutOffDistance,
double wallThreshold);
307 mgx_EXPORT std::map<int, double>
dijkstra
308 (std::set<int>& allCellLabels, std::map<IntInt, double>& wallAreas, std::set<int>& selectedCells,
309 bool equalWeights,
double cutOffDistance,
double wallThreshold);
312 mgx_EXPORT std::map<int, double>
dijkstra
313 (std::set<int>& allCellLabels, std::map<IntInt, double>& wallAreas, std::map<int, double>& initialCells,
314 bool equalWeights,
double cutOffDistance,
double wallThreshold);
316 mgx_EXPORT std::set<int>
aStar
317 (std::vector<int>& uniqueLabels, std::map<int, Point3d>& cellCentroids, std::map<IntInt, double>& wallAreas,
318 int label1,
int label2,
double wallThreshold,
bool equalWeights);
368 mgx_EXPORT std::map<int,int>
shiftMap(std::map<int, double>& mapToShift,
int shift);
vvGraph::vertex_t vertex
Type of a vertex.
mgx_EXPORT bool deleteCells(vvGraph &S, const VtxVec &V)
Check for unlabeled vertices, border triangles and islands of label in preparation to make a cell mes...
std::vector< vertex > VtxVec
Vector of vertices.
std::pair< int, int > IntInt
std::map< int, double > outsideWallArea
mgx_EXPORT bool findIntersectPoint(Point3d coordCellCentroid, Point3d &dirVec, std::vector< Triangle > &cellTriangles, int &stopCounter, Point3d &intersectP)
shoots rays from the cell centroid along a direction and checks if it hits any of the cell triangles ...
mgx_EXPORT bool mgxmToMgxc(const vvGraph &srcS, vvGraph &S, double wallMax=0)
Convert a normal (MGXM) mesh to a cell (MGXC) mesh.
std::map< IntInt, std::set< std::pair< Triangle, Triangle > > > sharedTris
mgx_EXPORT void findBorderVerticesOfCell(vvGraph &S, int cellLabel, std::set< vertex > &verticesCell, std::vector< vertex > &borderVerticesOrdered)
mgx_EXPORT std::set< int > findAllLabelsSet(const vvGraph &S)
bool spliceNhbs(GraphT &S, typename GraphT::vertex_t a, typename GraphT::vertex_t b)
Splice the neighborhood of b into a (so we can delete b)
mgx_EXPORT void correctNormals(vvGraph &S)
Correct MGXC normals (happens for non-star shaped cells)
mgx_EXPORT std::vector< int > findAllLabels(const vvGraph &S)
return ALL labels of a vvGraph originally in CellAtlas, now also used in other AddOns
Distributed matrix library.
mgx_EXPORT bool neighborhoodGraph(const vvGraph &S, double tolerance, NhbdGraphInfo &info, bool throwError=true)
mgx_EXPORT int vIndex(const Point3d &pos, Point3dIntMap &vMap, float tolerance)
mgx_EXPORT std::map< int, std::vector< vertex > > generateLabelVertexMap(const vvGraph &S)
goes through all vertices of the vvGraph and builds up a map from label to vertex vector
mgx_EXPORT IntVtxMap * vMap
Maps for saveId for vertices and cells, created when file is read Globals required for overloads of r...
mgx_EXPORT int getLabel(const vertex &v1, const vertex &v2, const vertex &v3)
Return the label for a triangle.
std::vector< Triangle > triVector
mgx_EXPORT void markMargin(vvGraph &S, vertex v, bool remborders=true)
Mark the cells and tissue margin vertices.
std::map< vertex, int > vtxNewLabelMap
mgx_EXPORT bool subdivideBisect(vvGraph &S, const vertex &v1, const vertex &v2, const vertex &v3, VtxVec *vs=0, Subdivide *sDiv=0)
Subdivide triangle with a propagating bisection that gives good triangles.
mgx_EXPORT Point3i triIndex(Point3i t)
Vector< 3, double > Point3d
mgx_EXPORT void findBorderVerticesOfCellsCombined(vvGraph &S, std::set< int > cellLabels, std::set< vertex > &verticesCells, std::vector< vertex > &borderVerticesOrdered)
VVGraph< VertexData, EdgeData > vvGraph
Simpler names for the various containers and iterators related to vertices and VV.
mgx_EXPORT int setNormals(const vvGraph &S)
Set the normals in a graph.
mgx_EXPORT std::map< int, double > dijkstra(vvGraph &S, std::map< IntInt, double > &wallAreas, std::set< int > &selectedCells, bool equalWeights, double cutOffDistance, double wallThreshold)
std::map< IntInt, double > sharedWallArea
std::map< IntInt, int > allWalls
mgx_EXPORT Point3d nearestPointOnMesh(const Point3d &targetPoint, const vvGraph &S)
mgx_EXPORT bool checkBorderTris(const vvGraph &S, bool select=true)
Check for unlabeled vertices, border triangles and islands of label in preparation to make a cell mes...
std::map< int, double > cellWallArea
std::pair< IntInt, double > IntIntDouPair
mgx_EXPORT std::map< int, int > shiftMap(std::map< int, double > &mapToShift, int shift)
std::pair< Point3i, std::set< int > > Point3iIntSetPair
mgx_EXPORT vertex nearestVertexOnMesh(const Point3d &targetPoint, const vvGraph &S)
mgx_EXPORT bool setNormal(const vvGraph &S, const vertex &v)
Set the normal in a single vertex.
std::unordered_map< vertex, int > VtxIntMap
Map of vertex to int.
mgx_EXPORT void generateLabelTriangleMap(const vvGraph &S, std::map< int, triVector > &cellTriangles)
goes through all triangles of the vvGraph and builds up a map from label to triangle vector
mgx_EXPORT int fixBorderTris(vvGraph &S)
Check for border triangles with all labels -1 and merge their vertices together.
mgx_EXPORT void markMargins(vvGraph &M, vvGraph &S, bool remborders=true)
Mark the cells and tissue margin vertices.
mgx_EXPORT std::set< int > findAllSelectedLabels(const vvGraph &S)
return ALL labels of selected vertices of a vvGraph originally in CellAtlas, now also used in other A...
mgx_EXPORT int mergeVertices(vvGraph &S, const VtxVec &vs)
Merge vertices, returns number of vertices deleted.
std::map< vertex, int > vtxCellCounterMap
std::map< Point3i, std::set< int > > Point3iIntSetMap
calculate properties of the neighborhood of a vvGraph such as: cell wall area, shared wall areas,...
mgx_EXPORT bool getLabelCount(const vvGraph &S, VtxIntMap &labCount)
Count labels for each vertex in the graph.
mgx_EXPORT bool calcNormal(const vvGraph &S, const vertex &v, Point3d &nrml)
Set the normal in a single vertex.
mgx_EXPORT double estimateCellLength(int currentLabel, Point3d coordCellCentroid, Point3d &dirVec, triVector &cellTriangles)
estimates the size of the cell in a given direction by shooting two rays in a specified direction and...
mgx_EXPORT int getKeyOfMaxValue(const std::map< int, double > &mapToTest)
std::map< Point3d, int > Point3dIntMap
Map of Point3d to int.
mgx_EXPORT bool splitEdge(vvGraph &S, vertex v1, vertex v2, Subdivide *sDiv=0)
Split an edge in the S graph.
mgx_EXPORT void neighborhood2D(vvGraph &S, std::map< IntInt, double > &neighMap, QString weightType="", bool ignoreOutside=true)
creates a wall map with the neighboring cells as key (pair) and the wall length as value
mgx_EXPORT std::set< int > aStar(std::vector< int > &uniqueLabels, std::map< int, Point3d > &cellCentroids, std::map< IntInt, double > &wallAreas, int label1, int label2, double wallThreshold, bool equalWeights)