MeshLib Documentation
Loading...
Searching...
No Matches
MRMesh/MRContoursCut.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVector3.h"
4#include "MRId.h"
5#include "MRBitSet.h"
7#include "MRExtractIsolines.h"
9#include "MRSurfacePath.h"
10#include <variant>
11
12namespace MR
13{
14
15// Special data to sort intersections more accurate
17{
21 const AffineXf3f* rigidB2A{nullptr};
23 bool isOtherA{false};
24};
25
26// Simple point on mesh, represented by primitive id and coordinate in mesh space
28{
30 std::variant<FaceId, EdgeId, VertId> primitiveId;
31
32 Vector3f coordinate;
33};
34
35// One contour on mesh
37{
38 std::vector<OneMeshIntersection> intersections;
39 bool closed{false};
40};
48using OneMeshContours = std::vector<OneMeshContour>;
49
50// Divides faces that fully own contours into 3 parts with center in center mass of one of the face contours
51// if there is more than one contour on face it guarantee to subdivide at least one lone contour on this face
52MRMESH_API void subdivideLoneContours( Mesh& mesh, const OneMeshContours& contours, FaceMap* new2oldMap = nullptr );
53
54// Converts ordered continuous contours of two meshes to OneMeshContours
55// converters is required for better precision in case of degenerations
56// note that contours should not have intersections
57[[nodiscard]]
58MRMESH_API OneMeshContours getOneMeshIntersectionContours( const Mesh& meshA, const Mesh& meshB, const ContinuousContours& contours, bool getMeshAIntersections,
59 const CoordinateConverters& converters, const AffineXf3f* rigidB2A = nullptr );
60
67
75[[nodiscard]]
76MRMESH_API Expected<OneMeshContour, PathError> convertMeshTriPointsToMeshContour( const Mesh& mesh, const std::vector<MeshTriPoint>& meshTriPoints,
77 SearchPathSettings searchSettings = {}, std::vector<int>* pivotIndices = nullptr );
78
86[[nodiscard]]
87MRMESH_API Expected<OneMeshContour, PathError> convertMeshTriPointsToClosedContour( const Mesh& mesh, const std::vector<MeshTriPoint>& meshTriPoints,
88 SearchPathSettings searchSettings = {}, std::vector<int>* pivotIndices = nullptr );
89
108[[nodiscard]]
110 const MeshTriPoint& start,
111 const SurfacePath& surfacePath,
112 const MeshTriPoint& end );
113
119[[nodiscard]]
120MRMESH_API OneMeshContours convertSurfacePathsToMeshContours( const Mesh& mesh, const std::vector<SurfacePath>& surfacePaths );
121
130{
136 FaceMap* new2OldMap{nullptr};
141 enum class ForceFill
142 {
143 None, //< if bad faces occur does not fill anything
144 Good, //< fills all faces except bad ones
145 All //< fills all faces with bad ones, but on bad faces triangulation can also be bad (may have self-intersections or tunnels)
146 } forceFillMode{ ForceFill::None };
147};
148
153struct CutMeshResult
154{
156 std::vector<EdgePath> resultCut;
160};
161
178MRMESH_API CutMeshResult cutMesh( Mesh& mesh, const OneMeshContours& contours, const CutMeshParameters& params = {} );
179
190[[deprecated( "use trimWithPlane(...) instead" )]]
191MRMESH_API std::vector<EdgePath> cutMeshWithPlane( Mesh& mesh, const Plane3f& plane, FaceMap* mapNew2Old = nullptr );
192
193} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:282
MRMESH_API OneMeshContour convertSurfacePathWithEndsToMeshContour(const Mesh &mesh, const MeshTriPoint &start, const SurfacePath &surfacePath, const MeshTriPoint &end)
Converts SurfacePath to OneMeshContours.
MRMESH_API Expected< OneMeshContour, PathError > convertMeshTriPointsToMeshContour(const Mesh &mesh, const std::vector< MeshTriPoint > &meshTriPoints, SearchPathSettings searchSettings={}, std::vector< int > *pivotIndices=nullptr)
Makes continuous contour by mesh tri points, if first and last meshTriPoint is the same,...
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/MRContoursCut.h:48
MRMESH_API Expected< OneMeshContour, PathError > convertMeshTriPointsToClosedContour(const Mesh &mesh, const std::vector< MeshTriPoint > &meshTriPoints, 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 std::vector< EdgePath > cutMeshWithPlane(Mesh &mesh, const Plane3f &plane, FaceMap *mapNew2Old=nullptr)
Simple cut mesh by plane.
MRMESH_API CutMeshResult cutMesh(Mesh &mesh, const OneMeshContours &contours, const CutMeshParameters &params={})
Cuts mesh by given contours.
GeodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MRSurfacePath.h:41
@ DijkstraAStar
compute edge-only path using A*-search algorithm
Definition MRCameraOrientationPlugin.h:8
MRMESH_API void subdivideLoneContours(Mesh &mesh, const OneMeshContours &contours, FaceMap *new2oldMap=nullptr)
tl::expected< T, E > Expected
Definition MRExpected.h:58
std::vector< MeshEdgePoint > SurfacePath
Definition MRMesh/MRMeshFwd.h:350
std::vector< ContinuousContour > ContinuousContours
Definition MRMesh/MRIntersectionContour.h:17
std::function< Vector3i(const Vector3f &)> ConvertToIntVector
float-to-int coordinate converter
Definition MRMesh/MRPrecisePredicates3.h:47
MRMESH_API OneMeshContours getOneMeshIntersectionContours(const Mesh &meshA, const Mesh &meshB, const ContinuousContours &contours, bool getMeshAIntersections, const CoordinateConverters &converters, const AffineXf3f *rigidB2A=nullptr)
this struct contains coordinate converters float-int-float
Definition MRMesh/MRPrecisePredicates3.h:52
Parameters of MR::cutMesh.
const SortIntersectionsData * sortData
Definition MRMesh/MRContoursCut.h:134
enum MR::CutMeshParameters::ForceFill None
FaceMap * new2OldMap
This is optional output - map from newly generated faces to old faces (N-1)
Definition MRMesh/MRContoursCut.h:136
ForceFill
Definition MRMesh/MRContoursCut.h:142
std::vector< EdgePath > resultCut
Paths of new edges on mesh, they represent same contours as input, but already cut.
Definition MRMesh/MRContoursCut.h:156
FaceBitSet fbsWithCountourIntersections
Definition MRMesh/MRContoursCut.h:159
Definition MRMesh/MRMeshTriPoint.h:23
Definition MRMesh/MRMesh.h:23
Definition MRMesh/MRContoursCut.h:37
std::vector< OneMeshIntersection > intersections
Definition MRMesh/MRContoursCut.h:38
bool closed
Definition MRMesh/MRContoursCut.h:39
Definition MRMesh/MRContoursCut.h:28
VariantIndex
Definition MRMesh/MRContoursCut.h:29
@ Edge
Definition MRMesh/MRContoursCut.h:29
@ Vertex
Definition MRMesh/MRContoursCut.h:29
@ Face
Definition MRMesh/MRContoursCut.h:29
std::variant< FaceId, EdgeId, VertId > primitiveId
Definition MRMesh/MRContoursCut.h:30
Vector3f coordinate
Definition MRMesh/MRContoursCut.h:32
Geo path search settings.
Definition MRMesh/MRContoursCut.h:63
GeodesicPathApprox geodesicPathApprox
the algorithm to compute approximately geodesic path
Definition MRMesh/MRContoursCut.h:64
int maxReduceIters
the maximum number of iterations to reduce approximate path length and convert it in geodesic path
Definition MRMesh/MRContoursCut.h:65
Definition MRMesh/MRContoursCut.h:17
const AffineXf3f * rigidB2A
Definition MRMesh/MRContoursCut.h:21
const ContinuousContours & contours
Definition MRMesh/MRContoursCut.h:19
ConvertToIntVector converter
Definition MRMesh/MRContoursCut.h:20
size_t meshAVertsNum
Definition MRMesh/MRContoursCut.h:22
bool isOtherA
Definition MRMesh/MRContoursCut.h:23
const Mesh & otherMesh
Definition MRMesh/MRContoursCut.h:18