MeshLib
 
Loading...
Searching...
No Matches
Mesh boolean

Example of Boolean operation

#include <MRMesh/MRMesh.h>
#include <iostream>
int main()
{
// create first sphere with radius of 1 unit
MR::Mesh sphere1 = MR::makeUVSphere( 1.0f, 64, 64 );
// create second sphere by cloning the first sphere and moving it in X direction
MR::Mesh sphere2 = sphere1;
sphere2.transform( xf );
// perform boolean operation
MR::Mesh resultMesh = *result;
if ( !result.valid() )
std::cerr << result.errorString << std::endl;
// save result to STL file
MR::MeshSave::toAnySupportedFormat( resultMesh, "out_boolean.stl" );
return 0;
}
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
MRMESH_API BooleanResult boolean(const Mesh &meshA, const Mesh &meshB, BooleanOperation operation, const AffineXf3f *rigidB2A, BooleanResultMapper *mapper=nullptr, ProgressCallback cb={})
Performs CSG operation on two meshes.
MRMESH_API VoidOrErrStr toAnySupportedFormat(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
detects the format from file extension and save mesh to it
MRMESH_API Mesh makeUVSphere(float radius=1.0, int horisontalResolution=16, int verticalResolution=16)
creates a mesh of sphere with regular triangulation (parallels and meridians)
static constexpr AffineXf translation(const Vector3f &b) noexcept
Definition MRMesh/MRAffineXf.h:26
Structure contain boolean result.
bool valid() const
Returns true if boolean succeed, false otherwise.
Definition MRMesh/MRMeshBoolean.h:37
std::string errorString
Holds error message, empty if boolean succeed.
Definition MRMesh/MRMeshBoolean.h:35
Definition MRMesh/MRMesh.h:23
MRMESH_API void transform(const AffineXf3f &xf, const VertBitSet *region=nullptr)