A big trouble with fusion

Hi,

the following code in Visual C++ fuses a cylinder with a ball and tries to visualize the result in OCC v.4.0. However the sample bails out with an unhanded exception somewhere in the poly_triangulation module. It works fine if Xc is 1e-3 and the visible result is also correct. If Xc is 0 then the visualized solid disintegrates into a disk and a half of a sphere - the result of the fusion which is (supposed to be) a solid is turned in two faces!

The questions are:

1. Is it a problem with visualization (triangulation?) or the underlying topological structure is broken?
2. What is the workaround?

With the hope to get help,
Aleksey

P.S. I am not very much familiar with OpenCascade yet but have to decide either it is a suitable library for our project related to 3D modeling. It is confusing that such a simple example is so troublesome and the first idea is that I am doing something wrong but checking the OCC docs does not reveal that I use the OCC objects in any non-natural way.

void CTestViewerView::OnTest() {
Standard_Real r = 10;
Standard_Real h = 50;
Standard_Real Xc = 1e-6;
Handle(AIS_InteractiveContext)aContext;
aContext = this->GetDocument()->GetAISContext();
BRepPrimAPI_MakeCylinder cyl (r,h);
BRepPrimAPI_MakeSphere sphere (gp_Pnt(Xc,0,0),r);
BRepAlgoAPI_Fuse fused (cyl.Solid(),sphere.Solid());
aContext->Display(new AIS_Shape(fused.Shape()),1); // crashes
}

jerome dufaure's picture

Hello
your problem is probably that you use BRepAlgoAPI_Fuse with TopoDS_Solid
BRepAlgoAPI_Fuse need TopoDS_Shape arguments
Create (S1,S2 : Shape from TopoDS) returns Fuse from BRepAlgoAPI;

---Purpose: Fuse S1 and S2.

---Level: Public

viviana's picture

Hi both of you,

I have a similar problem, but I am using BrepAlgo_Cut. Sincerely, I don't think that this is caused by using TopoDS_Solid, since this has the inheritance of TopoDS_Shape and all methods that work whit TopoDS_Shape should work with TopoDS_Solid. My problem is more serious because I can not achieve display the final resut of a cutting opperation. Maybe one of you can help me.

Thanks.

Mikael Aronsson's picture

Hi !

So far, the boolean support in OCC has never worked very well, there was a new implementation in the latest versions of OCC, but as far as I understand it still does not work all the times, correct me if I am wrong.

In older versions there where lots of problems when ever you tried to use a spherical shape in a boolean operation, this might still be a problem.

If you do need boolean operations to work I would suggest that you look into some other library with better support for it.

Mikael

a-helcman's picture

100% agreement.
adrian