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
58// Converts ordered continuous self contours of single meshes to OneMeshContours
59// converters are required for better precision in case of degenerations
60[[nodiscard]]
62 const CoordinateConverters& converters, const AffineXf3f* rigidB2A = nullptr );
63
64// Converts OneMeshContours contours representation to Contours3f: set of coordinates
65[[nodiscard]]
67
68using MeshTriPointsConnector = std::function<Expected<SurfacePath>( const MeshTriPoint& start, const MeshTriPoint& end, int startIndex, int endIndex )>;
76[[nodiscard]]
77MR_BIND_IGNORE MRMESH_API Expected<OneMeshContour> convertMeshTriPointsToMeshContour( const Mesh& mesh, const std::vector<MeshTriPoint>& surfaceLine,
78 MeshTriPointsConnector connectorFn, std::vector<int>* pivotIndices = nullptr );
79
86
94[[nodiscard]]
95MRMESH_API Expected<OneMeshContour> convertMeshTriPointsToMeshContour( const Mesh& mesh, const std::vector<MeshTriPoint>& surfaceLine,
96 SearchPathSettings searchSettings = {}, std::vector<int>* pivotIndices = nullptr );
97
105[[nodiscard]]
106MRMESH_API Expected<OneMeshContour> convertMeshTriPointsToClosedContour( const Mesh& mesh, const std::vector<MeshTriPoint>& surfaceLine,
107 SearchPathSettings searchSettings = {}, std::vector<int>* pivotIndices = nullptr );
108
127[[nodiscard]]
129 const MeshTriPoint& start,
130 const SurfacePath& surfacePath,
131 const MeshTriPoint& end );
132
138[[nodiscard]]
139MRMESH_API OneMeshContours convertSurfacePathsToMeshContours( const Mesh& mesh, const std::vector<SurfacePath>& surfacePaths );
140
141} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:309
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:9
Definition MRCameraOrientationPlugin.h:8
GeodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MREnums.h:71
@ 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:68
MRMESH_API void subdivideLoneContours(Mesh &mesh, const OneMeshContours &contours, FaceHashMap *new2oldMap=nullptr)
MRMESH_API Contours3f extractMeshContours(const OneMeshContours &meshContours)
tl::expected< T, E > Expected
Definition MRExpected.h:25
std::vector< MeshEdgePoint > SurfacePath
Definition MRMesh/MRMeshFwd.h:416
HashMap< FaceId, FaceId > FaceHashMap
Definition MRMesh/MRMeshFwd.h:532
std::vector< ContinuousContour > ContinuousContours
Definition MRMesh/MRIntersectionContour.h:12
MRMESH_API void getOneMeshIntersectionContours(const Mesh &meshA, const Mesh &meshB, const ContinuousContours &contours, OneMeshContours *outA, OneMeshContours *outB, const CoordinateConverters &converters, const AffineXf3f *rigidB2A=nullptr)
std::function< Vector3i(const Vector3f &)> ConvertToIntVector
float-to-int coordinate converter
Definition MRMesh/MRPrecisePredicates3.h:47
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:325
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:52
Definition MRMesh/MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:22
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:82
GeodesicPathApprox geodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MROneMeshContours.h:83
int maxReduceIters
the maximum number of iterations to reduce approximate path length and convert it in geodesic path
Definition MROneMeshContours.h:84
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