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
13struct SortIntersectionsData
14{
15 const Mesh& otherMesh;
16 const ContinuousContours& contours;
17 ConvertToIntVector converter;
18 const AffineXf3f* rigidB2A{nullptr};
19 size_t meshAVertsNum;
20 bool isOtherA{false};
21};
22
23// Simple point on mesh, represented by primitive id and coordinate in mesh space
24struct OneMeshIntersection
25{
26 std::variant<FaceId, EdgeId, VertId> primitiveId;
27
28 Vector3f coordinate;
29};
30
31// One contour on mesh
32struct OneMeshContour
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,
55 OneMeshContours* outA, OneMeshContours* outB,
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]]
63MRMESH_API OneMeshContours getOneMeshSelfIntersectionContours( const Mesh& mesh, const ContinuousContours& contours,
64 const CoordinateConverters& converters, const AffineXf3f* rigidB2A = nullptr );
65
66// Converts OneMeshContours contours representation to Contours3f: set of coordinates
67[[nodiscard]]
68MRMESH_API Contours3f extractMeshContours( const OneMeshContours& meshContours );
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
84{
85 GeodesicPathApprox geodesicPathApprox{ GeodesicPathApprox::DijkstraAStar };
86 int maxReduceIters{ 100 };
87};
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 MRMeshFwd.h:80
Definition MRPrecisePredicates3.h:58
Definition MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:23
Definition MROneMeshContours.h:33
Definition MROneMeshContours.h:84
new unsafe ref MR.GeodesicPathApprox geodesicPathApprox
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:382
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.
Definition MRCameraOrientationPlugin.h:8
MRMESH_API void subdivideLoneContours(Mesh &mesh, const OneMeshContours &contours, FaceHashMap *new2oldMap=nullptr)
MRMESH_API Contours3f extractMeshContours(const OneMeshContours &meshContours)
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)