MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMeshBoolean.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRContoursCut.h"
5#include "MRMesh.h"
6#include "MRBitSet.h"
7#include "MRExpected.h"
8#include <optional>
9#include <string>
10
11namespace MR
12{
13
19
22
30{
38 std::string errorString;
40 bool valid() const { return errorString.empty(); }
41 Mesh& operator*() { return mesh; }
42 const Mesh& operator*() const { return mesh; }
43 Mesh* operator->() { return &mesh; }
44 const Mesh* operator->() const { return &mesh; }
45 operator bool()const { return valid(); }
46};
47
63MR_BIND_OVERLOAD_SUFFIX(withXf) MRMESH_API BooleanResult boolean( const Mesh& meshA, const Mesh& meshB, BooleanOperation operation,
64 const AffineXf3f* rigidB2A, BooleanResultMapper* mapper = nullptr, ProgressCallback cb = {} );
66
67
72{
75
78
81
83 std::optional<AffineXf3f> rigidB2A;
84
86 size_t meshAVertsNum = 0;
87
89 bool isMeshA = false;
90
93 [[nodiscard]] SortIntersectionsData sortData( const Mesh& otherMesh ) const
94 { return { otherMesh, intersections, toInt, rigidB2A ? &*rigidB2A : nullptr, meshAVertsNum, !isMeshA }; }
95};
96
102{
104 const AffineXf3f* rigidB2A = nullptr;
105
108
111
114
116 std::vector<EdgeLoop>* outCutEdges = nullptr;
117
121
125 bool forceCut = false;
126
128};
129
132MR_BIND_OVERLOAD_SUFFIX() MRMESH_API BooleanResult boolean( const Mesh& meshA, const Mesh& meshB, BooleanOperation operation,
133 const BooleanParameters& params = {} );
136MR_BIND_OVERLOAD_SUFFIX(move) MRMESH_API BooleanResult boolean( Mesh&& meshA, Mesh&& meshB, BooleanOperation operation,
137 const BooleanParameters& params = {} );
139MR_BIND_OVERLOAD_SUFFIX(moveB) MRMESH_API BooleanResult boolean( const Mesh& meshA, Mesh&& meshB, BooleanOperation operation,
140 const BooleanParameters& params = {} );
143MR_BIND_OVERLOAD_SUFFIX(moveA) MRMESH_API BooleanResult boolean( Mesh&& meshA, const Mesh& meshB, BooleanOperation operation,
144 const BooleanParameters& params = {} );
145
149MRMESH_API BooleanResult forceBoolean( const Mesh& meshA, const Mesh& meshB, BooleanOperation operation,
150 const BooleanParameters& params = {} );
151
152
160MRMESH_API Expected<Mesh> selfBoolean( const Mesh& mesh, FaceMap* new2Old = nullptr );
161
163MRMESH_API Contours3f findIntersectionContours( const Mesh& meshA, const Mesh& meshB, const AffineXf3f* rigidB2A = nullptr );
164
167{
168 VertBitSet meshAVerts;
169 VertBitSet meshBVerts;
170 std::vector<Vector3f> intersectionPoints;
171};
172
184 const AffineXf3f* rigidB2A = nullptr );
185
186
192
194
195}
#define MRMESH_API
Definition MRMeshFwd.h:85
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:790
Contours3f findIntersectionContours(const Mesh &meshA, const Mesh &meshB, const AffineXf3f *rigidB2A=nullptr)
returns intersection contours of given meshes
BooleanResult boolean(const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const AffineXf3f *rigidB2A, BooleanResultMapper *mapper=nullptr, ProgressCallback cb={})
Performs CSG operation on two meshes.
BooleanResult forceBoolean(const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const BooleanParameters &params={})
BooleanOperation
Definition MRBooleanOperation.h:20
Expected< Mesh > selfBoolean(const Mesh &mesh, FaceMap *new2Old=nullptr)
Expected< BooleanResultPoints, std::string > getBooleanPoints(const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const AffineXf3f *rigidB2A=nullptr)
Returns the points of mesh boolean's result mesh.
void convertIntFloatAllVerts(Mesh &mesh, const CoordinateConverters &conv)
Vector< ContinuousContour > ContinuousContours
Definition MRIntersectionContour.h:15
Contours3< float > Contours3f
Definition MRMeshFwd.h:388
tl::expected< T, E > Expected
Definition MRExpected.h:31
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRMeshBoolean.h:102
BooleanPreCutResult * outPreCutB
Optional precut output of meshB, if present - does not perform boolean and just return them.
Definition MRMeshBoolean.h:113
ProgressCallback cb
Definition MRMeshBoolean.h:127
bool forceCut
Definition MRMeshBoolean.h:125
bool mergeAllNonIntersectingComponents
Definition MRMeshBoolean.h:120
std::vector< EdgeLoop > * outCutEdges
Optional output cut edges of booleaned meshes.
Definition MRMeshBoolean.h:116
const AffineXf3f * rigidB2A
Transform from mesh B space to mesh A space.
Definition MRMeshBoolean.h:104
BooleanResultMapper * mapper
Optional output structure to map mesh A and mesh B topology to result mesh topology.
Definition MRMeshBoolean.h:107
BooleanPreCutResult * outPreCutA
Optional precut output of meshA, if present - does not perform boolean and just return them.
Definition MRMeshBoolean.h:110
no version of the function with rvalue-referenced meshes, because meshes' copies are currently used f...
Definition MRMeshBoolean.h:72
size_t meshAVertsNum
the number of vertices of mesh A before any cut
Definition MRMeshBoolean.h:86
std::optional< AffineXf3f > rigidB2A
a copy of the boolean's transformation from mesh B to mesh A
Definition MRMeshBoolean.h:83
SortIntersectionsData sortData(const Mesh &otherMesh) const
Definition MRMeshBoolean.h:93
Mesh mesh
Definition MRMeshBoolean.h:73
ConvertToIntVector toInt
the boolean's conversion of the coordinates of both meshes to integers
Definition MRMeshBoolean.h:80
bool isMeshA
whether mesh is mesh A of the boolean
Definition MRMeshBoolean.h:89
ContinuousContours intersections
the boolean's ordered intersections of both meshes, without the closed contours of two points
Definition MRMeshBoolean.h:77
OneMeshContours contours
Definition MRMeshBoolean.h:74
Structure to map old mesh BitSets to new.
Definition MRBooleanOperation.h:59
vertices and points representing mesh intersection result
Definition MRMeshBoolean.h:167
VertBitSet meshBVerts
Definition MRMeshBoolean.h:169
VertBitSet meshAVerts
Definition MRMeshBoolean.h:168
std::vector< Vector3f > intersectionPoints
Definition MRMeshBoolean.h:170
Structure contain boolean result.
Definition MRMeshBoolean.h:30
Mesh mesh
Result mesh of boolean operation, if error occurred it would be empty.
Definition MRMeshBoolean.h:32
bool valid() const
Returns true if boolean succeed, false otherwise.
Definition MRMeshBoolean.h:40
FaceBitSet meshBBadContourFaces
If input contours have intersections, this face bit set presents faces of mesh B on which contours in...
Definition MRMeshBoolean.h:36
std::string errorString
Holds error message, empty if boolean succeed.
Definition MRMeshBoolean.h:38
FaceBitSet meshABadContourFaces
If input contours have intersections, this face bit set presents faces of mesh A on which contours in...
Definition MRMeshBoolean.h:34
Mesh * operator->()
Definition MRMeshBoolean.h:43
Mesh & operator*()
Definition MRMeshBoolean.h:41
const Mesh & operator*() const
Definition MRMeshBoolean.h:42
const Mesh * operator->() const
Definition MRMeshBoolean.h:44
translate then scale float-to-int coordinate converter
Definition MRPrecisePredicates3.h:100
this struct contains coordinate converters float-int-float
Definition MRPrecisePredicates3.h:145
Definition MRMesh.h:24
Special data type for MR::cutMesh: the intersections of all contours in one array,...
Definition MROneMeshContours.h:90
Special data to sort intersections more accurate.
Definition MROneMeshContours.h:18