Chapter about Constructive Solid Geometry operations. More...
Classes | |
| struct | MR::BooleanResultMapper |
| Structure to map old mesh BitSets to new. More... | |
| struct | MR::BooleanInternalParameters |
| Parameters will be useful if specified. More... | |
| struct | MR::NewEdgesMap |
| struct | MR::OneMeshContours |
| Special data type for MR::cutMesh: the intersections of all contours in one array, one contour after another. More... | |
| struct | MR::CutMeshParameters |
| Parameters of MR::cutMesh. More... | |
| struct | MR::CutMeshResult |
| struct | MR::BooleanResult |
| Structure contain boolean result. More... | |
Functions | |
| Expected< Mesh > | MR::doBooleanOperation (Mesh &&meshACut, Mesh &&meshBCut, std::vector< EdgePath > &&cutEdgesA, std::vector< EdgePath > &&cutEdgesB, BooleanOperation operation, const AffineXf3f *rigidB2A=nullptr, BooleanResultMapper *mapper=nullptr, bool mergeAllNonIntersectingComponents=false, const BooleanInternalParameters &intParams={}) |
| CutMeshResult | MR::cutMesh (Mesh &mesh, const OneMeshContours &contours, const CutMeshParameters ¶ms={}) |
| Cuts mesh by given contours. | |
| void | MR::reserveForCut (Mesh &mesh, const Mesh &sizeOf, const OneMeshContours &contours) |
| Expected< OneMeshContours > | MR::offsetSurfaceLineToMeshContours (const Mesh &mesh, const std::vector< MeshTriPoint > &surfaceLine, float offset, SearchPathSettings searchSettings={}) |
| Makes continuous contour by iso-line from mesh tri points, if first and last meshTriPoint is the same, makes closed contour. | |
| Expected< OneMeshContours > | MR::offsetSurfaceLineToMeshContours (const Mesh &mesh, const std::vector< MeshTriPoint > &surfaceLine, const std::function< float(int)> &offsetAtPoint, SearchPathSettings searchSettings={}) |
| Makes continuous contour by iso-line from mesh tri points, if first and last meshTriPoint is the same, makes closed contour. | |
| Expected< OneMeshContour > | MR::surfaceLineToMeshContour (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, makes closed contour. | |
| Expected< OneMeshContour > | MR::surfaceLineToMeshContour (const Mesh &mesh, const std::vector< MeshTriPoint > &surfaceLine, SearchPathSettings searchSettings={}, std::vector< int > *pivotIndices=nullptr) |
| Makes continuous contour by mesh tri points, if first and last meshTriPoint is the same, makes closed contour. | |
| Expected< OneMeshContour > | MR::surfaceLineToClosedMeshContour (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 be same. | |
| OneMeshContour | MR::surfacePathWithEndsToMeshContour (const Mesh &mesh, const MeshTriPoint &start, const SurfacePath &surfacePath, const MeshTriPoint &end) |
| Converts SurfacePath to OneMeshContours. | |
| OneMeshContours | MR::surfacePathsToMeshContours (const Mesh &mesh, const std::vector< SurfacePath > &surfacePaths) |
| Converts SurfacePaths to OneMeshContours. | |
| BooleanResult | MR::boolean (const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const AffineXf3f *rigidB2A, BooleanResultMapper *mapper=nullptr, ProgressCallback cb={}) |
| Performs CSG operation on two meshes. | |
| Expected< BooleanResultPoints, std::string > | MR::getBooleanPoints (const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const AffineXf3f *rigidB2A=nullptr) |
| Returns the points of mesh boolean's result mesh. | |
| BooleanResult | MR::boolean (const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const BooleanParameters ¶ms={}) |
| BooleanResult | MR::boolean (Mesh &&meshA, Mesh &&meshB, BooleanOperation operation, const BooleanParameters ¶ms={}) |
| BooleanResult | MR::boolean (const Mesh &meshA, Mesh &&meshB, BooleanOperation operation, const BooleanParameters ¶ms={}) |
| keeps meshA as the first overload does (its whole tree is cached in it) and consumes meshB as the second one does | |
| BooleanResult | MR::boolean (Mesh &&meshA, const Mesh &meshB, BooleanOperation operation, const BooleanParameters ¶ms={}) |
| BooleanResult | MR::forceBoolean (const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const BooleanParameters ¶ms={}) |
| Expected< Mesh > | MR::selfBoolean (const Mesh &mesh, FaceMap *new2Old=nullptr) |
| Contours3f | MR::findIntersectionContours (const Mesh &meshA, const Mesh &meshB, const AffineXf3f *rigidB2A=nullptr) |
| returns intersection contours of given meshes | |
| void | MR::convertIntFloatAllVerts (Mesh &mesh, const CoordinateConverters &conv) |
Chapter about Constructive Solid Geometry operations.
This chapter represents documentation of MeshLib CSG
|
strong |
#include <MRMesh/MRBooleanOperation.h>
Enum class of available CSG operations
| BooleanResult MR::boolean | ( | const Mesh & | meshA, |
| const Mesh & | meshB, | ||
| BooleanOperation | operation, | ||
| const AffineXf3f * | rigidB2A, | ||
| BooleanResultMapper * | mapper = nullptr, | ||
| ProgressCallback | cb = {} ) |
#include <MRMesh/MRMeshBoolean.h>
Performs CSG operation on two meshes.
Makes new mesh - result of boolean operation on mesh A and mesh B
| meshA | Input mesh A |
| meshB | Input mesh B |
| operation | CSG operation to perform |
| rigidB2A | Transform from mesh B space to mesh A space |
| mapper | Optional output structure to map mesh A and mesh B topology to result mesh topology |
| BooleanResult MR::boolean | ( | const Mesh & | meshA, |
| const Mesh & | meshB, | ||
| BooleanOperation | operation, | ||
| const BooleanParameters & | params = {} ) |
#include <MRMesh/MRMeshBoolean.h>
constructs the AABB trees of the whole meshes if they are not cached yet and caches them in the meshes, so that the next calls of Boolean with the same meshes are faster
| BooleanResult MR::boolean | ( | const Mesh & | meshA, |
| Mesh && | meshB, | ||
| BooleanOperation | operation, | ||
| const BooleanParameters & | params = {} ) |
#include <MRMesh/MRMeshBoolean.h>
keeps meshA as the first overload does (its whole tree is cached in it) and consumes meshB as the second one does
| BooleanResult MR::boolean | ( | Mesh && | meshA, |
| const Mesh & | meshB, | ||
| BooleanOperation | operation, | ||
| const BooleanParameters & | params = {} ) |
#include <MRMesh/MRMeshBoolean.h>
consumes meshA as the second overload does and keeps meshB as the first one does (its whole tree is cached in it), e.g. for many subtractions of the same small mesh in different positions from a large mesh
| BooleanResult MR::boolean | ( | Mesh && | meshA, |
| Mesh && | meshB, | ||
| BooleanOperation | operation, | ||
| const BooleanParameters & | params = {} ) |
#include <MRMesh/MRMeshBoolean.h>
consumes the meshes; if a mesh has no cached AABB tree and only a small part of it is near the other mesh, then only a temporary tree of that part is constructed, which is much faster
| void MR::convertIntFloatAllVerts | ( | Mesh & | mesh, |
| const CoordinateConverters & | conv ) |
#include <MRMesh/MRMeshBoolean.h>
converts all vertices of the mesh first in integer-coordinates, and then back in float-coordinates; this is necessary to avoid small self-intersections near newly introduced vertices on cut-contours; this actually sligntly moves only small perentage of vertices near x=0 or y=0 or z=0 planes, where float-precision is higher than int-precision; newly introduced vertices on cut-contours are also converted, but we expected that they remain unchanged due to idempotent property of the conversion
| CutMeshResult MR::cutMesh | ( | Mesh & | mesh, |
| const OneMeshContours & | contours, | ||
| const CutMeshParameters & | params = {} ) |
#include <MRMesh/MRContoursCut.h>
Cuts mesh by given contours.
This function cuts mesh making new edges paths on place of input contours; a contour inside one face is connected with the rest of the face by new edges
| mesh | Input mesh that will be cut |
| contours | Input contours to cut mesh with, find more MR::OneMeshContours |
| params | Parameters describing some cut options, find more MR::CutMeshParameters |
| Expected< Mesh > MR::doBooleanOperation | ( | Mesh && | meshACut, |
| Mesh && | meshBCut, | ||
| std::vector< EdgePath > && | cutEdgesA, | ||
| std::vector< EdgePath > && | cutEdgesB, | ||
| BooleanOperation | operation, | ||
| const AffineXf3f * | rigidB2A = nullptr, | ||
| BooleanResultMapper * | mapper = nullptr, | ||
| bool | mergeAllNonIntersectingComponents = false, | ||
| const BooleanInternalParameters & | intParams = {} ) |
#include <MRMesh/MRBooleanOperation.h>
Perform boolean operation on cut meshes
| Contours3f MR::findIntersectionContours | ( | const Mesh & | meshA, |
| const Mesh & | meshB, | ||
| const AffineXf3f * | rigidB2A = nullptr ) |
#include <MRMesh/MRMeshBoolean.h>
returns intersection contours of given meshes
| BooleanResult MR::forceBoolean | ( | const Mesh & | meshA, |
| const Mesh & | meshB, | ||
| BooleanOperation | operation, | ||
| const BooleanParameters & | params = {} ) |
#include <MRMesh/MRMeshBoolean.h>
calls boolean in force mode, also unites close vertices and fills holes afterwards
| Expected< BooleanResultPoints, std::string > MR::getBooleanPoints | ( | const Mesh & | meshA, |
| const Mesh & | meshB, | ||
| BooleanOperation | operation, | ||
| const AffineXf3f * | rigidB2A = nullptr ) |
#include <MRMesh/MRMeshBoolean.h>
Returns the points of mesh boolean's result mesh.
Returns vertices and intersection points of mesh that is result of boolean operation of mesh A and mesh B. Can be used as fast alternative for cases where the mesh topology can be ignored (bounding box, convex hull, etc.)
| meshA | Input mesh A |
| meshB | Input mesh B |
| operation | Boolean operation to perform |
| rigidB2A | Transform from mesh B space to mesh A space |
|
nodiscard |
#include <MRMesh/MRContoursCut.h>
Makes continuous contour by iso-line from mesh tri points, if first and last meshTriPoint is the same, makes closed contour.
Finds shortest paths between neighbor surfaceLine and build offset contour on surface for MR::cutMesh input. An isoline that reaches the mesh boundary is an open contour (closed = false) from a boundary edge to a boundary edge; the other isolines are closed, with the last intersection equal to the first one
| offsetAtPoint | functor that returns amount of offset form arg point, note that absolute value is used and isoline in both direction returned |
| searchSettings | settings for search geodesic path |
|
nodiscard |
#include <MRMesh/MRContoursCut.h>
Makes continuous contour by iso-line from mesh tri points, if first and last meshTriPoint is the same, makes closed contour.
Finds shortest paths between neighbor surfaceLine and build offset contour on surface for MR::cutMesh input. An isoline that reaches the mesh boundary is an open contour (closed = false) from a boundary edge to a boundary edge; the other isolines are closed, with the last intersection equal to the first one
| offset | amount of offset form given point, note that absolute value is used and isoline in both direction returned |
| searchSettings | settings for search geodesic path |
| void MR::reserveForCut | ( | Mesh & | mesh, |
| const Mesh & | sizeOf, | ||
| const OneMeshContours & | contours ) |
#include <MRMesh/MRContoursCut.h>
reserves the capacity in mesh for a mesh with the sizes of sizeOf (e.g. mesh itself, or the mesh to be copied in it) together with the elements that cutMesh by contours adds, so the cut does not reallocate the mesh
#include <MRMesh/MRMeshBoolean.h>
performs boolean operation on mesh with itself, cutting its self-intersection contours and flipping their connectivity; the contours may cross one another where three sheets of the mesh meet at a point (nested intersections); two triangles with the same vertices glued along two edges or all three (a part without volume) that cross other parts are eliminated, see eliminateDoubleTris this function is experimental and likely to change signature and/or behavior in future
| new2Old | optional output, set on success: for every valid face of the result, the face of the input mesh that it is or is a part of; the faces with new ids (not less than the face size of the input mesh) are the parts of the cut input faces |
|
nodiscard |
#include <MRMesh/MROneMeshContours.h>
Makes closed continuous contour by mesh tri points, note that first and last meshTriPoint should not be same.
Finds shortest paths between neighbor surfaceLine and build closed contour MR::cutMesh input
| pivotIndices | optional output indices of given surfaceLine in result OneMeshContour |
|
nodiscard |
#include <MRMesh/MROneMeshContours.h>
Makes continuous contour by mesh tri points, if first and last meshTriPoint is the same, makes closed contour.
Finds paths between neighbor surfaceLine with MeshTriPointsConnector function and build contour MR::cutMesh input
| connectorFn | function to build path between neighbor surfaceLine, if not present simple geodesic path function is used |
| pivotIndices | optional output indices of given surfaceLine in result OneMeshContour |
|
nodiscard |
#include <MRMesh/MROneMeshContours.h>
Makes continuous contour by mesh tri points, if first and last meshTriPoint is the same, makes closed contour.
Finds shortest paths between neighbor surfaceLine and build contour MR::cutMesh input
| searchSettings | settings for search geo path |
| pivotIndices | optional output indices of given surfaceLine in result OneMeshContour |
|
nodiscard |
#include <MRMesh/MROneMeshContours.h>
Converts SurfacePaths to OneMeshContours.
Creates MR::OneMeshContours object from given surface paths for MR::cutMesh input
|
nodiscard |
#include <MRMesh/MROneMeshContours.h>
Converts SurfacePath to OneMeshContours.
Creates MR::OneMeshContour object from given surface path with ends for MR::cutMesh input start and surfacePath.front() should be from same face surfacePath.back() and end should be from same face
note that whole path (including start and end) should not have self-intersections also following case is not supported (vertex -> edge (incident with vertex)):
vert path edge point path edge end o-------—o- – – – – O \ \ / \ \ / \ \ / \/ o path