MeshLib
 
Loading...
Searching...
No Matches
MREdgePaths.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRId.h"
4#include "MREdgeMetric.h"
6#include <cfloat>
7#include <vector>
8
9namespace MR
10{
11
14
16[[nodiscard]] MRMESH_API bool isEdgePath( const MeshTopology & topology, const std::vector<EdgeId> & edges );
17
19[[nodiscard]] MRMESH_API bool isEdgeLoop( const MeshTopology & topology, const std::vector<EdgeId> & edges );
20
22[[nodiscard]] MRMESH_API std::vector<EdgeLoop> splitOnSimpleLoops( const MeshTopology & topology, std::vector<EdgeLoop> && loops );
23
28MRMESH_API void reverse( std::vector<EdgePath> & paths );
29
31[[nodiscard]] MRMESH_API double calcPathMetric( const EdgePath & path, EdgeMetric metric );
32[[nodiscard]] inline double calcPathLength( const EdgePath & path, const Mesh & mesh ) { return calcPathMetric( path, edgeLengthMetric( mesh ) ); }
33
36[[nodiscard]] MRMESH_API Vector3d calcOrientedArea( const EdgeLoop & loop, const Mesh & mesh );
37
39MRMESH_API void sortPathsByMetric( std::vector<EdgePath> & paths, EdgeMetric metric );
40inline void sortPathsByLength( std::vector<EdgePath> & paths, const Mesh & mesh ) { sortPathsByMetric( paths, edgeLengthMetric( mesh ) ); }
41
43MRMESH_API void addLeftBand( const MeshTopology & topology, const EdgeLoop & loop, FaceBitSet & addHere );
44
48{
50 float metric = 0;
51};
52
55[[nodiscard]] MRMESH_API EdgePath buildShortestPath( const Mesh & mesh, VertId start, VertId finish, float maxPathLen = FLT_MAX );
59[[nodiscard]] MRMESH_API EdgePath buildShortestPathBiDir( const Mesh & mesh, VertId start, VertId finish, float maxPathLen = FLT_MAX );
64[[nodiscard]] MRMESH_API EdgePath buildShortestPathBiDir( const Mesh & mesh,
65 const MeshTriPoint & start, const MeshTriPoint & finish,
66 VertId * outPathStart = nullptr, // if the path is found then its start vertex will be written here (even if start vertex is the same as finish vertex and the path is empty)
67 VertId * outPathFinish = nullptr, // if the path is found then its finish vertex will be written here (even if start vertex is the same as finish vertex and the path is empty)
68 float maxPathLen = FLT_MAX );
72[[nodiscard]] MRMESH_API EdgePath buildShortestPathAStar( const Mesh & mesh, VertId start, VertId finish, float maxPathLen = FLT_MAX );
77[[nodiscard]] MRMESH_API EdgePath buildShortestPathAStar( const Mesh & mesh,
78 const MeshTriPoint & start, const MeshTriPoint & finish,
79 VertId * outPathStart = nullptr, // if the path is found then its start vertex will be written here (even if start vertex is the same as finish vertex and the path is empty)
80 VertId * outPathFinish = nullptr, // if the path is found then its finish vertex will be written here (even if start vertex is the same as finish vertex and the path is empty)
81 float maxPathLen = FLT_MAX );
82
84[[nodiscard]] MRMESH_API EdgePath buildShortestPath( const Mesh& mesh, VertId start, const VertBitSet& finish, float maxPathLen = FLT_MAX );
85
87[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPath( const MeshTopology & topology, const EdgeMetric & metric,
88 VertId start, VertId finish, float maxPathMetric = FLT_MAX );
92[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPathBiDir( const MeshTopology & topology, const EdgeMetric & metric,
93 VertId start, VertId finish, float maxPathMetric = FLT_MAX );
97[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPathBiDir( const MeshTopology & topology, const EdgeMetric & metric,
98 const TerminalVertex * starts, int numStarts,
99 const TerminalVertex * finishes, int numFinishes,
100 VertId * outPathStart = nullptr, // if the path is found then its start vertex will be written here (even if start vertex is the same as finish vertex and the path is empty)
101 VertId * outPathFinish = nullptr, // if the path is found then its finish vertex will be written here (even if start vertex is the same as finish vertex and the path is empty)
102 float maxPathMetric = FLT_MAX );
103
105[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPath( const MeshTopology& topology, const EdgeMetric& metric,
106 VertId start, const VertBitSet& finish, float maxPathMetric = FLT_MAX );
107
109[[nodiscard]] MRMESH_API std::vector<VertId> getVertexOrdering( const MeshTopology & topology, VertBitSet region );
110
112[[nodiscard]] MRMESH_API std::vector<EdgeLoop> extractClosedLoops( const MeshTopology & topology, EdgeBitSet & edges );
113[[nodiscard]] MRMESH_API std::vector<EdgeLoop> extractClosedLoops( const MeshTopology & topology, const std::vector<EdgeId> & inEdges,
114 EdgeBitSet * outNotLoopEdges = nullptr );
115[[nodiscard]] MRMESH_API EdgeLoop extractLongestClosedLoop( const Mesh & mesh, const std::vector<EdgeId> & inEdges );
116
118MRMESH_API bool dilateRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
119MRMESH_API bool dilateRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, VertBitSet& region, float dilation, ProgressCallback callback = {} );
120MRMESH_API bool dilateRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
121
123MRMESH_API bool erodeRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
124MRMESH_API bool erodeRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, VertBitSet& region, float dilation, ProgressCallback callback = {} );
125MRMESH_API bool erodeRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
126
128MRMESH_API bool dilateRegion( const Mesh& mesh, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
129MRMESH_API bool dilateRegion( const Mesh& mesh, VertBitSet& region, float dilation, ProgressCallback callback = {} );
130MRMESH_API bool dilateRegion( const Mesh& mesh, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
131
133MRMESH_API bool erodeRegion( const Mesh& mesh, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
134MRMESH_API bool erodeRegion( const Mesh& mesh, VertBitSet& region, float dilation, ProgressCallback callback = {} );
135MRMESH_API bool erodeRegion( const Mesh& mesh, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
136
138MRMESH_API int getPathPlaneIntersections( const Mesh & mesh, const EdgePath & path, const Plane3f & plane,
139 std::vector<MeshEdgePoint> * outIntersections = nullptr );
140
142MRMESH_API int getPathEdgesInPlane( const Mesh & mesh, const EdgePath & path, const Plane3f & plane, float tolerance = 0.0f,
143 std::vector<EdgeId> * outInPlaneEdges = nullptr );
144
146
147} // namespace MR
int VertId
Definition MRDotNet/MRMeshFwd.h:51
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRDotNet/MRBitSet.h:39
Definition MRMesh/MRMeshTopology.h:18
represents a mesh, including topology (connectivity) information and point coordinates,
Definition MRDotNet/MRMesh.h:30
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:589
R calcOrientedArea(const Contour2< T > &contour)
Definition MRContour.h:17
MRMESH_API int getPathEdgesInPlane(const Mesh &mesh, const EdgePath &path, const Plane3f &plane, float tolerance=0.0f, std::vector< EdgeId > *outInPlaneEdges=nullptr)
finds all path edges located in given plane with given tolerance, adds them in outInPlaneEdges and re...
double calcPathLength(const EdgePath &path, const Mesh &mesh)
Definition MREdgePaths.h:32
MRMESH_API EdgePath buildSmallestMetricPathBiDir(const MeshTopology &topology, const EdgeMetric &metric, VertId start, VertId finish, float maxPathMetric=FLT_MAX)
MRMESH_API double calcPathMetric(const EdgePath &path, EdgeMetric metric)
computes summed metric of all edges in the path
MRMESH_API EdgePath buildShortestPath(const Mesh &mesh, VertId start, VertId finish, float maxPathLen=FLT_MAX)
MRMESH_API void reverse(EdgePath &path)
MRMESH_API bool dilateRegionByMetric(const MeshTopology &topology, const EdgeMetric &metric, FaceBitSet &region, float dilation, ProgressCallback callback={})
expands the region (of faces or vertices) on given metric value. returns false if callback also retur...
MRMESH_API int getPathPlaneIntersections(const Mesh &mesh, const EdgePath &path, const Plane3f &plane, std::vector< MeshEdgePoint > *outIntersections=nullptr)
finds all intersection points between given path and plane, adds them in outIntersections and returns...
MRMESH_API std::vector< VertId > getVertexOrdering(const MeshTopology &topology, VertBitSet region)
returns all vertices from given region ordered in each connected component in breadth-first way
MRMESH_API bool isEdgePath(const MeshTopology &topology, const std::vector< EdgeId > &edges)
returns true if every next edge starts where previous edge ends
MRMESH_API EdgePath buildSmallestMetricPath(const MeshTopology &topology, const EdgeMetric &metric, VertId start, VertId finish, float maxPathMetric=FLT_MAX)
builds shortest path in given metric from start to finish vertices; if no path can be found then empt...
MRMESH_API EdgePath buildShortestPathBiDir(const Mesh &mesh, VertId start, VertId finish, float maxPathLen=FLT_MAX)
MRMESH_API bool erodeRegionByMetric(const MeshTopology &topology, const EdgeMetric &metric, FaceBitSet &region, float dilation, ProgressCallback callback={})
shrinks the region (of faces or vertices) on given metric value. returns false if callback also retur...
MRMESH_API std::vector< EdgeLoop > splitOnSimpleLoops(const MeshTopology &topology, std::vector< EdgeLoop > &&loops)
given a number of edge loops, splits every loop that passes via a vertex more than once on smaller lo...
void sortPathsByLength(std::vector< EdgePath > &paths, const Mesh &mesh)
Definition MREdgePaths.h:40
MRMESH_API bool erodeRegion(const Mesh &mesh, FaceBitSet &region, float dilation, ProgressCallback callback={})
shrinks the region (of faces or vertices) on given value (in meters). returns false if callback also ...
MRMESH_API EdgeMetric edgeLengthMetric(const Mesh &mesh)
MRMESH_API void addLeftBand(const MeshTopology &topology, const EdgeLoop &loop, FaceBitSet &addHere)
adds all faces incident to loop vertices and located to the left from the loop to given FaceBitSet
MRMESH_API EdgePath buildShortestPathAStar(const Mesh &mesh, VertId start, VertId finish, float maxPathLen=FLT_MAX)
MRMESH_API bool dilateRegion(const Mesh &mesh, FaceBitSet &region, float dilation, ProgressCallback callback={})
expands the region (of faces or vertices) on given value (in meters). returns false if callback also ...
MRMESH_API std::vector< EdgeLoop > extractClosedLoops(const MeshTopology &topology, EdgeBitSet &edges)
finds all closed loops from given edges and removes them from edges
MRMESH_API EdgeLoop extractLongestClosedLoop(const Mesh &mesh, const std::vector< EdgeId > &inEdges)
MRMESH_API void sortPathsByMetric(std::vector< EdgePath > &paths, EdgeMetric metric)
sorts given paths in ascending order of their metrics
MRMESH_API bool isEdgeLoop(const MeshTopology &topology, const std::vector< EdgeId > &edges)
returns true if every next edge starts where previous edge ends, and start vertex coincides with fini...
Definition MRCameraOrientationPlugin.h:7
std::vector< EdgeId > EdgeLoop
Definition MRMesh/MRMeshFwd.h:99
class MRMESH_CLASS MeshTopology
Definition MRMesh/MRMeshFwd.h:464
std::function< float(EdgeId)> EdgeMetric
Definition MRMesh/MRMeshFwd.h:428
std::vector< EdgeId > EdgePath
Definition MRMesh/MRMeshFwd.h:98
Definition MRMesh/MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:23
Definition MREdgePaths.h:48
float metric
Definition MREdgePaths.h:50
VertId v
Definition MREdgePaths.h:49