MeshLib C++ Docs
Loading...
Searching...
No Matches
MROneMeshContours.h
Go to the documentation of this file.
1#pragma once
2
5#include "MRExpected.h"
6#include "MREnums.h"
7#include <variant>
8
9namespace MR
10{
11
12// Special data to sort intersections more accurate
14{
18 const AffineXf3f* rigidB2A{nullptr};
20 bool isOtherA{false};
21};
22
23// Simple point on mesh, represented by primitive id and coordinate in mesh space
25{
26 std::variant<FaceId, EdgeId, VertId> primitiveId;
27
28 Vector3f coordinate;
29};
30
31// One contour on mesh
33{
34 std::vector<OneMeshIntersection> intersections;
35 bool closed{false};
36};
44using OneMeshContours = std::vector<OneMeshContour>;
45
46// Divides faces that fully own contours into 3 parts with center in center mass of one of the face contours
47// if there is more than one contour on face it guarantee to subdivide at least one lone contour on this face
48MRMESH_API void subdivideLoneContours( Mesh& mesh, const OneMeshContours& contours, FaceHashMap* new2oldMap = nullptr );
49
54MRMESH_API void getOneMeshIntersectionContours( const Mesh& meshA, const Mesh& meshB, const ContinuousContours& contours,
56 const CoordinateConverters& converters, const AffineXf3f* rigidB2A = nullptr,
57 Contours3f* outPtsA = nullptr,
58 bool addSelfyTerminalVerts = false );
59
60// Converts ordered continuous self contours of single meshes to OneMeshContours
61// converters are required for better precision in case of degenerations
62[[nodiscard]]
64 const CoordinateConverters& converters, const AffineXf3f* rigidB2A = nullptr );
65
66// Converts OneMeshContours contours representation to Contours3f: set of coordinates
67[[nodiscard]]
69
70using MeshTriPointsConnector = std::function<Expected<SurfacePath>( const MeshTriPoint& start, const MeshTriPoint& end, int startIndex, int endIndex )>;
78[[nodiscard]]
79MR_BIND_IGNORE MRMESH_API Expected<OneMeshContour> convertMeshTriPointsToMeshContour( const Mesh& mesh, const std::vector<MeshTriPoint>& surfaceLine,
80 MeshTriPointsConnector connectorFn, std::vector<int>* pivotIndices = nullptr );
81
88
96[[nodiscard]]
97MRMESH_API Expected<OneMeshContour> convertMeshTriPointsToMeshContour( const Mesh& mesh, const std::vector<MeshTriPoint>& surfaceLine,
98 SearchPathSettings searchSettings = {}, std::vector<int>* pivotIndices = nullptr );
99
107[[nodiscard]]
108MRMESH_API Expected<OneMeshContour> convertMeshTriPointsToClosedContour( const Mesh& mesh, const std::vector<MeshTriPoint>& surfaceLine,
109 SearchPathSettings searchSettings = {}, std::vector<int>* pivotIndices = nullptr );
110
129[[nodiscard]]
131 const MeshTriPoint& start,
132 const SurfacePath& surfacePath,
133 const MeshTriPoint& end );
134
140[[nodiscard]]
141MRMESH_API OneMeshContours convertSurfacePathsToMeshContours( const Mesh& mesh, const std::vector<SurfacePath>& surfacePaths );
142
143} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:310
MR_BIND_IGNORE MRMESH_API Expected< OneMeshContour > convertMeshTriPointsToMeshContour(const Mesh &mesh, const std::vector< MeshTriPoint > &surfaceLine, MeshTriPointsConnector connectorFn, std::vector< int > *pivotIndices=nullptr)
Makes continuous contour by mesh tri points, if first and last meshTriPoint is the same,...
MRMESH_API OneMeshContour convertSurfacePathWithEndsToMeshContour(const Mesh &mesh, const MeshTriPoint &start, const SurfacePath &surfacePath, const MeshTriPoint &end)
Converts SurfacePath to OneMeshContours.
MRMESH_API Expected< OneMeshContour > convertMeshTriPointsToClosedContour(const Mesh &mesh, const std::vector< MeshTriPoint > &surfaceLine, SearchPathSettings searchSettings={}, std::vector< int > *pivotIndices=nullptr)
Makes closed continuous contour by mesh tri points, note that first and last meshTriPoint should not ...
MRMESH_API OneMeshContours convertSurfacePathsToMeshContours(const Mesh &mesh, const std::vector< SurfacePath > &surfacePaths)
Converts SurfacePaths to OneMeshContours.
std::vector< OneMeshContour > OneMeshContours
Special data type for MR::cutMesh.
Definition MRMesh/MRIntersectionContour.h:10
Definition MRCameraOrientationPlugin.h:8
GeodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MREnums.h:76
@ DijkstraAStar
compute edge-only path using A*-search algorithm
std::function< Expected< SurfacePath >(const MeshTriPoint &start, const MeshTriPoint &end, int startIndex, int endIndex)> MeshTriPointsConnector
Definition MROneMeshContours.h:70
MRMESH_API void subdivideLoneContours(Mesh &mesh, const OneMeshContours &contours, FaceHashMap *new2oldMap=nullptr)
MRMESH_API Contours3f extractMeshContours(const OneMeshContours &meshContours)
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:383
tl::expected< T, E > Expected
Definition MRExpected.h:25
std::vector< MeshEdgePoint > SurfacePath
Definition MRMesh/MRMeshFwd.h:474
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMesh/MRMeshFwd.h:596
std::vector< ContinuousContour > ContinuousContours
Definition MRMesh/MRIntersectionContour.h:13
std::function< Vector3i(const Vector3f &)> ConvertToIntVector
float-to-int coordinate converter
Definition MRMesh/MRPrecisePredicates3.h:53
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
MRMESH_API void getOneMeshIntersectionContours(const Mesh &meshA, const Mesh &meshB, const ContinuousContours &contours, OneMeshContours *outA, OneMeshContours *outB, const CoordinateConverters &converters, const AffineXf3f *rigidB2A=nullptr, Contours3f *outPtsA=nullptr, bool addSelfyTerminalVerts=false)
if true, then open self-intersection contours will be prolonged to terminal vertices
MRMESH_API OneMeshContours getOneMeshSelfIntersectionContours(const Mesh &mesh, const ContinuousContours &contours, const CoordinateConverters &converters, const AffineXf3f *rigidB2A=nullptr)
this struct contains coordinate converters float-int-float
Definition MRMesh/MRPrecisePredicates3.h:58
Definition MRMesh/MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:23
Definition MROneMeshContours.h:33
std::vector< OneMeshIntersection > intersections
Definition MROneMeshContours.h:34
bool closed
Definition MROneMeshContours.h:35
Definition MROneMeshContours.h:25
std::variant< FaceId, EdgeId, VertId > primitiveId
Definition MROneMeshContours.h:26
Vector3f coordinate
Definition MROneMeshContours.h:28
Geo path search settings.
Definition MROneMeshContours.h:84
GeodesicPathApprox geodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MROneMeshContours.h:85
int maxReduceIters
the maximum number of iterations to reduce approximate path length and convert it in geodesic path
Definition MROneMeshContours.h:86
Definition MROneMeshContours.h:14
const AffineXf3f * rigidB2A
Definition MROneMeshContours.h:18
const ContinuousContours & contours
Definition MROneMeshContours.h:16
ConvertToIntVector converter
Definition MROneMeshContours.h:17
size_t meshAVertsNum
Definition MROneMeshContours.h:19
bool isOtherA
Definition MROneMeshContours.h:20
const Mesh & otherMesh
Definition MROneMeshContours.h:15