Different result for the same shapes with BrepCompute and MeshCompute

unhandled
(Viktor Kovacs) #1

Hi All,

I’ve done some experiments with boolean operations and I found one interesting thing. If I do the same boolean operation with BrepCompute and MeshCompute on the same shapes I get different results.

Here is my code with BrepCompute

var cube = new Box(new BoundingBox(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5));
var sphere = new Sphere(new Point3d(0.5, 0.5, 0.5), 0.8);

Brep[] cubeBrep = new Brep[] { cube.ToBrep() };
Brep[] sphereBrep = new Brep[] { sphere.ToBrep() };

const double tolerance = 1.0e-8;
Brep[] difference = BrepCompute.CreateBooleanDifference(cubeBrep, sphereBrep, tolerance);
ExportBrepsToObj("cube_sphere_difference_brep.obj", difference);

And here is the code with MeshCompute:

var cube = new Box(new BoundingBox(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5));
var sphere = new Sphere(new Point3d(0.5, 0.5, 0.5), 0.8);

Mesh[] difference = MeshCompute.CreateBooleanDifference(MeshCompute.CreateFromBrep (cube.ToBrep ()), MeshCompute.CreateFromBrep (sphere.ToBrep ()));
ExportMeshesToObj("cube_sphere_difference_mesh.obj", difference);

It produces these results (Brep and Mesh):

So you can see MeshCompute produces bad result. Do you know why it works this way?

0 Likes