MeshLib C++ Docs
Loading...
Searching...
No Matches
MRSurfacePath.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRExpected.h"
4#include "MRMeshTriPoint.h"
5#include "MREnums.h"
6#include <vector>
7#include <string>
8
9namespace MR
10{
11
15
20{
24
25 [[nodiscard]] size_t numVertices() const { return start.valid() + mids.size() + end.valid(); }
26
27 [[nodiscard]] MeshTriPoint operator[]( size_t i ) const
28 {
29 if ( start.valid() )
30 {
31 if ( i == 0 )
32 return start;
33 --i;
34 }
35 if ( i < mids.size() )
36 return mids[i];
37 assert( end.valid() );
38 assert( i == mids.size() );
39 return end;
40 }
41};
42
48
49inline std::string toString(PathError error)
50{
51 switch (error)
52 {
53 case PathError::StartEndNotConnected: return "No path can be found from start to end, because they are not from the same connected component";
54 case PathError::InternalError: return "Report to developers for further investigations";
55 default: return "Unknown error. Please, report to developers for further investigations";
56 }
57}
58
63 const MeshTriPoint & start, const MeshTriPoint & end,
64 int maxGeodesicIters = 5,
65 const VertBitSet* vertRegion = nullptr, VertScalars * outSurfaceDistances = nullptr );
66
71 int maxGeodesicIters = 100 );
72
76 const MeshTriPoint & start, const MeshTriPoint & end, GeodesicPathApprox atype );
77
81 const MeshTriPoint & start, const MeshTriPoint & end, const VertBitSet* vertRegion = nullptr,
82 VertScalars * outSurfaceDistances = nullptr );
83
93
97[[nodiscard]] MRMESH_API SurfacePath computeSteepestDescentPath( const MeshPart & mp, const VertScalars & field,
98 const MeshTriPoint & start, const ComputeSteepestDescentPathSettings & settings = {} );
99
104MRMESH_API void computeSteepestDescentPath( const MeshPart & mp, const VertScalars & field,
105 const MeshTriPoint & start, SurfacePath * outPath, const ComputeSteepestDescentPathSettings & settings = {} );
106
108[[nodiscard]] MRMESH_API MeshEdgePoint findSteepestDescentPoint( const MeshPart & mp, const VertScalars & field, VertId v );
109
111[[nodiscard]] MRMESH_API MeshEdgePoint findSteepestDescentPoint( const MeshPart & mp, const VertScalars & field, const MeshEdgePoint & ep );
112
114[[nodiscard]] MRMESH_API MeshEdgePoint findSteepestDescentPoint( const MeshPart & mp, const VertScalars & field, const MeshTriPoint & tp );
115
117{
120};
121
123[[nodiscard]] MRMESH_API UndirectedEdgeBitSet findExtremeEdges( const Mesh & mesh, const VertScalars & field, ExtremeEdgeType type );
124
128 const VertBitSet & starts, const VertBitSet & ends, const VertBitSet * vertRegion = nullptr,
129 VertScalars * outSurfaceDistances = nullptr );
130
133[[nodiscard]] MRMESH_API SurfacePaths getSurfacePathsViaVertices( const Mesh & mesh, const VertBitSet & vs );
134
136[[nodiscard]] MRMESH_API float surfacePathLength( const Mesh& mesh, const SurfacePath& surfacePath );
137
139[[nodiscard]] MRMESH_API float geodesicPathLength( const Mesh& mesh, const GeodesicPath& path );
140
142[[nodiscard]] MRMESH_API Contour3f surfacePathToContour3f( const Mesh & mesh, const SurfacePath & line );
143[[nodiscard]] MRMESH_API Contours3f surfacePathsToContours3f( const Mesh & mesh, const SurfacePaths & lines );
144
146[[nodiscard]] MRMESH_API Contour3f geodesicPathToContour3f( const Mesh& mesh, const GeodesicPath& path );
147
149
150}
#define MRMESH_API
Definition MRMeshFwd.h:82
GeodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MREnums.h:106
std::vector< SurfacePath > SurfacePaths
Definition MRMeshFwd.h:477
Contour3< float > Contour3f
Definition MRMeshFwd.h:375
Contours3< float > Contours3f
Definition MRMeshFwd.h:385
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::vector< MeshEdgePoint > SurfacePath
Definition MRMeshFwd.h:476
EdgePoint MeshEdgePoint
Definition MRMeshFwd.h:475
std::string_view toString(DimensionsVisualizePropertyType value)
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMeshFwd.h:603
@ FastMarching
use Fast Marching algorithm
Definition MREnums.h:112
float geodesicPathLength(const Mesh &mesh, const GeodesicPath &path)
computes the length of the given geodesic path
Expected< SurfacePath, PathError > computeFastMarchingPath(const MeshPart &mp, const MeshTriPoint &start, const MeshTriPoint &end, const VertBitSet *vertRegion=nullptr, VertScalars *outSurfaceDistances=nullptr)
Contour3f geodesicPathToContour3f(const Mesh &mesh, const GeodesicPath &path)
returns coordinates of all vertices of the given path
float surfacePathLength(const Mesh &mesh, const SurfacePath &surfacePath)
computes the length of the given surface path
ExtremeEdgeType
Definition MRSurfacePath.h:117
HashMap< VertId, VertId > computeClosestSurfacePathTargets(const Mesh &mesh, const VertBitSet &starts, const VertBitSet &ends, const VertBitSet *vertRegion=nullptr, VertScalars *outSurfaceDistances=nullptr)
SurfacePaths getSurfacePathsViaVertices(const Mesh &mesh, const VertBitSet &vs)
SurfacePath computeSteepestDescentPath(const MeshPart &mp, const VertScalars &field, const MeshTriPoint &start, const ComputeSteepestDescentPathSettings &settings={})
Expected< SurfacePath, PathError > computeGeodesicPathApprox(const Mesh &mesh, const MeshTriPoint &start, const MeshTriPoint &end, GeodesicPathApprox atype)
Contours3f surfacePathsToContours3f(const Mesh &mesh, const SurfacePaths &lines)
Contour3f surfacePathToContour3f(const Mesh &mesh, const SurfacePath &line)
converts lines on mesh in 3D contours by computing coordinate of each point
MeshEdgePoint findSteepestDescentPoint(const MeshPart &mp, const VertScalars &field, VertId v)
finds the point along minus maximal gradient on the boundary of first ring boundary around given vert...
UndirectedEdgeBitSet findExtremeEdges(const Mesh &mesh, const VertScalars &field, ExtremeEdgeType type)
computes all edges in the mesh, where the field not-increases both in left and right triangles
Expected< SurfacePath, PathError > computeGeodesicPath(const Mesh &mesh, const MeshTriPoint &start, const MeshTriPoint &end, GeodesicPathApprox atype=GeodesicPathApprox::FastMarching, int maxGeodesicIters=100)
the maximum number of iterations to reduce approximate path length and convert it in geodesic path
Expected< SurfacePath, PathError > computeSurfacePath(const MeshPart &mp, const MeshTriPoint &start, const MeshTriPoint &end, int maxGeodesicIters=5, const VertBitSet *vertRegion=nullptr, VertScalars *outSurfaceDistances=nullptr)
PathError
Definition MRSurfacePath.h:44
@ Gorge
where the field not-increases both in left and right triangles
Definition MRSurfacePath.h:119
@ Ridge
Definition MRSurfacePath.h:118
@ InternalError
report to developers for investigation
Definition MRSurfacePath.h:46
@ StartEndNotConnected
no path can be found from start to end, because they are not from the same connected component
Definition MRSurfacePath.h:45
auto end(ViewportMask)
Definition MRViewportId.h:124
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRSurfacePath.h:85
EdgePoint * outBdReached
if not nullptr, then the descent is stopped as soon as any boundary point is reached,...
Definition MRSurfacePath.h:91
MeshTriPoint end
if valid, then the descent is stopped as soon as same triangle with (end) is reached
Definition MRSurfacePath.h:87
VertId * outVertexReached
if not nullptr, then the descent is stopped as soon as any vertex is reached, which is written in *ou...
Definition MRSurfacePath.h:89
encodes a point on an edge of mesh or of polyline
Definition MREdgePoint.h:14
Definition MRSurfacePath.h:20
MeshTriPoint start
can be invalid, then the path starts in mids.front()
Definition MRSurfacePath.h:21
size_t numVertices() const
Definition MRSurfacePath.h:25
MeshTriPoint end
can be invalid, then the path ends in mids.back()
Definition MRSurfacePath.h:23
MeshTriPoint operator[](size_t i) const
Definition MRSurfacePath.h:27
SurfacePath mids
Definition MRSurfacePath.h:22
Definition MRMeshTriPoint.h:26
Definition MRMesh.h:23