MeshLib C++ Docs
Loading...
Searching...
No Matches
MREdgePaths.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRId.h"
5#include <cfloat>
6#include <vector>
7
8namespace MR
9{
12
13
16
18[[nodiscard]] MRMESH_API bool isEdgePath( const MeshTopology & topology, const std::vector<EdgeId> & edges );
19
21[[nodiscard]] MRMESH_API bool isEdgeLoop( const MeshTopology & topology, const std::vector<EdgeId> & edges );
22
24[[nodiscard]] MRMESH_API std::vector<EdgeLoop> splitOnSimpleLoops( const MeshTopology & topology, std::vector<EdgeLoop> && loops );
25
30MRMESH_API void reverse( std::vector<EdgePath> & paths );
31
33[[nodiscard]] MRMESH_API double calcPathMetric( const EdgePath & path, EdgeMetric metric );
34[[nodiscard]] MRMESH_API double calcPathLength( const EdgePath & path, const Mesh & mesh );
35
38[[nodiscard]] MRMESH_API Vector3d calcOrientedArea( const EdgeLoop & loop, const Mesh & mesh );
39
41MRMESH_API void sortPathsByMetric( std::vector<EdgePath> & paths, EdgeMetric metric );
42MRMESH_API void sortPathsByLength( std::vector<EdgePath> & paths, const Mesh & mesh );
43
45MRMESH_API void addLeftBand( const MeshTopology & topology, const EdgeLoop & loop, FaceBitSet & addHere );
46
50{
51 VertId v;
52 float metric = 0;
53};
54
57[[nodiscard]] MRMESH_API EdgePath buildShortestPath( const Mesh & mesh, VertId start, VertId finish, float maxPathLen = FLT_MAX );
61[[nodiscard]] MRMESH_API EdgePath buildShortestPathBiDir( const Mesh & mesh, VertId start, VertId finish, float maxPathLen = FLT_MAX );
66[[nodiscard]] MRMESH_API EdgePath buildShortestPathBiDir( const Mesh & mesh,
67 const MeshTriPoint & start, const MeshTriPoint & finish,
68 VertId * outPathStart = nullptr,
69 VertId * outPathFinish = nullptr,
70 float maxPathLen = FLT_MAX );
74[[nodiscard]] MRMESH_API EdgePath buildShortestPathAStar( const Mesh & mesh, VertId start, VertId finish, float maxPathLen = FLT_MAX );
79[[nodiscard]] MRMESH_API EdgePath buildShortestPathAStar( const Mesh & mesh,
80 const MeshTriPoint & start, const MeshTriPoint & finish,
81 VertId * outPathStart = nullptr,
82 VertId * outPathFinish = nullptr,
83 float maxPathLen = FLT_MAX );
84
86[[nodiscard]] MRMESH_API EdgePath buildShortestPath( const Mesh& mesh, VertId start, const VertBitSet& finish, float maxPathLen = FLT_MAX );
87
89[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPath( const MeshTopology & topology, const EdgeMetric & metric,
90 VertId start, VertId finish, float maxPathMetric = FLT_MAX );
94[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPathBiDir( const MeshTopology & topology, const EdgeMetric & metric,
95 VertId start, VertId finish, float maxPathMetric = FLT_MAX );
99[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPathBiDir( const MeshTopology & topology, const EdgeMetric & metric,
100 const TerminalVertex * starts, int numStarts,
101 const TerminalVertex * finishes, int numFinishes,
102 VertId * outPathStart = nullptr,
103 VertId * outPathFinish = nullptr,
104 float maxPathMetric = FLT_MAX );
105
107[[nodiscard]] MRMESH_API EdgePath buildSmallestMetricPath( const MeshTopology& topology, const EdgeMetric& metric,
108 VertId start, const VertBitSet& finish, float maxPathMetric = FLT_MAX );
109
111[[nodiscard]] MRMESH_API std::vector<VertId> getVertexOrdering( const MeshTopology & topology, VertBitSet region );
112
114[[nodiscard]] MRMESH_API std::vector<EdgeLoop> extractClosedLoops( const MeshTopology & topology, EdgeBitSet & edges );
115[[nodiscard]] MRMESH_API std::vector<EdgeLoop> extractClosedLoops( const MeshTopology & topology, const std::vector<EdgeId> & inEdges,
116 EdgeBitSet * outNotLoopEdges = nullptr );
117[[nodiscard]] MRMESH_API EdgeLoop extractLongestClosedLoop( const Mesh & mesh, const std::vector<EdgeId> & inEdges );
118
120MRMESH_API bool dilateRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
121MRMESH_API bool dilateRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, VertBitSet& region, float dilation, ProgressCallback callback = {} );
122MRMESH_API bool dilateRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
123
125MRMESH_API bool erodeRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
126MRMESH_API bool erodeRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, VertBitSet& region, float dilation, ProgressCallback callback = {} );
127MRMESH_API bool erodeRegionByMetric( const MeshTopology& topology, const EdgeMetric& metric, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
128
130MRMESH_API bool dilateRegion( const Mesh& mesh, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
131MRMESH_API bool dilateRegion( const Mesh& mesh, VertBitSet& region, float dilation, ProgressCallback callback = {} );
132MRMESH_API bool dilateRegion( const Mesh& mesh, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
133MRMESH_API bool dilateRegion( const MeshTopology& topology, const VertCoords& points, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
134MRMESH_API bool dilateRegion( const MeshTopology& topology, const VertCoords& points, VertBitSet& region, float dilation, ProgressCallback callback = {} );
135MRMESH_API bool dilateRegion( const MeshTopology& topology, const VertCoords& points, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
136
138MRMESH_API bool erodeRegion( const Mesh& mesh, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
139MRMESH_API bool erodeRegion( const Mesh& mesh, VertBitSet& region, float dilation, ProgressCallback callback = {} );
140MRMESH_API bool erodeRegion( const Mesh& mesh, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
141MRMESH_API bool erodeRegion( const MeshTopology& topology, const VertCoords& points, FaceBitSet& region, float dilation, ProgressCallback callback = {} );
142MRMESH_API bool erodeRegion( const MeshTopology& topology, const VertCoords& points, VertBitSet& region, float dilation, ProgressCallback callback = {} );
143MRMESH_API bool erodeRegion( const MeshTopology& topology, const VertCoords& points, UndirectedEdgeBitSet& region, float dilation, ProgressCallback callback = {} );
144
146MRMESH_API int getPathPlaneIntersections( const Mesh & mesh, const EdgePath & path, const Plane3f & plane,
147 std::vector<MeshEdgePoint> * outIntersections = nullptr );
148
151 std::vector<Vector3f> * outIntersections = nullptr );
152
154MRMESH_API int getPathEdgesInPlane( const Mesh & mesh, const EdgePath & path, const Plane3f & plane, float tolerance = 0.0f,
155 std::vector<EdgeId> * outInPlaneEdges = nullptr );
156
158[[nodiscard]] MRMESH_API Contour3f edgePathToContour3f( const Mesh& mesh, const EdgePath& line );
159[[nodiscard]] MRMESH_API Contours3f edgePathsToContours3f( const Mesh& mesh, const std::vector<EdgePath>& lines );
160
162
163}
#define MRMESH_API
Definition MRMeshFwd.h:80
Definition MRMeshTopology.h:23
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:758
R calcOrientedArea(const Contour2< T > &contour)
Definition MRContour.h:18
std::vector< EdgeId > EdgeLoop
Definition MRMeshFwd.h:150
Contour3< float > Contour3f
Definition MRMeshFwd.h:384
Contours3< float > Contours3f
Definition MRMeshFwd.h:392
Plane3f
Definition MRMeshFwd.h:395
std::function< float(EdgeId)> EdgeMetric
Definition MRMeshFwd.h:588
std::vector< EdgeId > EdgePath
Definition MRMeshFwd.h:149
float metric
Definition MREdgePaths.h:52
VertId v
Definition MREdgePaths.h:51
EdgePath buildShortestPathBiDir(const Mesh &mesh, VertId start, VertId finish, float maxPathLen=FLT_MAX)
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...
EdgeLoop extractLongestClosedLoop(const Mesh &mesh, const std::vector< EdgeId > &inEdges)
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...
std::vector< VertId > getVertexOrdering(const MeshTopology &topology, VertBitSet region)
returns all vertices from given region ordered in each connected component in breadth-first way
double calcPathLength(const EdgePath &path, const Mesh &mesh)
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...
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...
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...
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 ...
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 ...
void sortPathsByMetric(std::vector< EdgePath > &paths, EdgeMetric metric)
sorts given paths in ascending order of their metrics
Contours3f edgePathsToContours3f(const Mesh &mesh, const std::vector< EdgePath > &lines)
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
EdgePath buildSmallestMetricPathBiDir(const MeshTopology &topology, const EdgeMetric &metric, VertId start, VertId finish, float maxPathMetric=FLT_MAX)
bool isEdgePath(const MeshTopology &topology, const std::vector< EdgeId > &edges)
returns true if every next edge starts where previous edge ends
EdgePath buildShortestPathAStar(const Mesh &mesh, VertId start, VertId finish, float maxPathLen=FLT_MAX)
void sortPathsByLength(std::vector< EdgePath > &paths, const Mesh &mesh)
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...
EdgePath buildShortestPath(const Mesh &mesh, VertId start, VertId finish, float maxPathLen=FLT_MAX)
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...
int getContourPlaneIntersections(const Contour3f &path, const Plane3f &plane, std::vector< Vector3f > *outIntersections=nullptr)
finds all intersection points between given contour and plane, adds them in outIntersections and retu...
Contour3f edgePathToContour3f(const Mesh &mesh, const EdgePath &line)
converts lines on mesh in 3D contours by computing coordinate of each point
std::vector< EdgeLoop > extractClosedLoops(const MeshTopology &topology, EdgeBitSet &edges)
finds all closed loops from given edges and removes them from edges
double calcPathMetric(const EdgePath &path, EdgeMetric metric)
computes summed metric of all edges in the path
void reverse(EdgePath &path)
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRMeshTriPoint.h:26
Definition MRMesh.h:23
Definition MREdgePaths.h:50