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
66 const MeshTriPoint & start, const MeshTriPoint & end,
67 int maxGeodesicIters = 5,
68 const VertBitSet* vertRegion = nullptr, VertScalars * outSurfaceDistances = nullptr );
69
74 int maxGeodesicIters = 100 );
75
81 const MeshTriPoint & start, const MeshTriPoint & end, const VertBitSet* vertRegion = nullptr );
82
87 const MeshTriPoint & start, const MeshTriPoint & end, GeodesicPathApprox atype );
88
94 const MeshTriPoint & start, const MeshTriPoint & end, const VertBitSet* vertRegion = nullptr,
95 VertScalars * outSurfaceDistances = nullptr );
96
106
110[[nodiscard]] MRMESH_API SurfacePath computeSteepestDescentPath( const MeshPart & mp, const VertScalars & field,
111 const MeshTriPoint & start, const ComputeSteepestDescentPathSettings & settings = {} );
112
117MRMESH_API void computeSteepestDescentPath( const MeshPart & mp, const VertScalars & field,
118 const MeshTriPoint & start, SurfacePath * outPath, const ComputeSteepestDescentPathSettings & settings = {} );
119
121[[nodiscard]] MRMESH_API MeshEdgePoint findSteepestDescentPoint( const MeshPart & mp, const VertScalars & field, VertId v );
122
124[[nodiscard]] MRMESH_API MeshEdgePoint findSteepestDescentPoint( const MeshPart & mp, const VertScalars & field, const MeshEdgePoint & ep );
125
127[[nodiscard]] MRMESH_API MeshEdgePoint findSteepestDescentPoint( const MeshPart & mp, const VertScalars & field, const MeshTriPoint & tp );
128
130{
133};
134
136[[nodiscard]] MRMESH_API UndirectedEdgeBitSet findExtremeEdges( const Mesh & mesh, const VertScalars & field, ExtremeEdgeType type );
137
141 const VertBitSet & starts, const VertBitSet & ends, const VertBitSet * vertRegion = nullptr,
142 VertScalars * outSurfaceDistances = nullptr );
143
146[[nodiscard]] MRMESH_API SurfacePaths getSurfacePathsViaVertices( const Mesh & mesh, const VertBitSet & vs );
147
150[[nodiscard]] MRMESH_API bool isConnectedPath( const MeshTopology& topology, const MeshTriPoint& start, const SurfacePath& path, const MeshTriPoint& end );
151
153[[nodiscard]] MRMESH_API float surfacePathLength( const Mesh& mesh, const SurfacePath& surfacePath );
154
156[[nodiscard]] MRMESH_API float geodesicPathLength( const Mesh& mesh, const GeodesicPath& path );
157
159[[nodiscard]] MRMESH_API Contour3f surfacePathToContour3f( const Mesh & mesh, const SurfacePath & line );
160[[nodiscard]] MRMESH_API Contours3f surfacePathsToContours3f( const Mesh & mesh, const SurfacePaths & lines );
161
163[[nodiscard]] MRMESH_API Contour3f geodesicPathToContour3f( const Mesh& mesh, const GeodesicPath& path );
164
166
167}
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRMeshTopology.h:31
GeodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MREnums.h:114
std::vector< SurfacePath > SurfacePaths
Definition MRMeshFwd.h:491
Contour3< float > Contour3f
Definition MRMeshFwd.h:378
EdgePoint
Definition MRMeshFwd.h:477
MeshTriPoint
Definition MRMeshFwd.h:515
Contours3< float > Contours3f
Definition MRMeshFwd.h:388
tl::expected< T, E > Expected
Definition MRExpected.h:31
std::vector< MeshEdgePoint > SurfacePath
Definition MRMeshFwd.h:490
EdgePoint MeshEdgePoint
Definition MRMeshFwd.h:486
phmap::flat_hash_map< K, V, Hash, Eq, Allocator< std::pair< const K, V > > > HashMap
Definition MRMeshFwd.h:631
std::string_view toString(DimensionsVisualizePropertyType value)
@ FastMarching
use Fast Marching algorithm
Definition MREnums.h:120
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
bool isConnectedPath(const MeshTopology &topology, const MeshTriPoint &start, const SurfacePath &path, const MeshTriPoint &end)
float surfacePathLength(const Mesh &mesh, const SurfacePath &surfacePath)
computes the length of the given surface path
ExtremeEdgeType
Definition MRSurfacePath.h:130
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 > computeShortestEdgePath(const MeshPart &mp, const MeshTriPoint &start, const MeshTriPoint &end, const VertBitSet *vertRegion=nullptr)
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:132
@ Ridge
Definition MRSurfacePath.h:131
@ 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 strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRSurfacePath.h:98
EdgePoint * outBdReached
if not nullptr, then the descent is stopped as soon as any boundary point is reached,...
Definition MRSurfacePath.h:104
MeshTriPoint end
if valid, then the descent is stopped as soon as same triangle with (end) is reached
Definition MRSurfacePath.h:100
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:102
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 MRMesh.h:24