problem with BRepAlgoAPI_Common

I try to compute the common shape of two shapes built by BRepPrimAPI_MakePrism operations.
I am working with the OCC62 release.

The two shapes merge a section : a circle in this case.
The respective directions for sweeping (i.e. BRepPrimAPI_MakePrisme) are different.

The BRepAlgoAPI_Common operation does never furnish a result.
ErrorStatus returns 0.
HasGenerated returns Standard_False.

Here the c++ code :
//Definition of the merged section
gp_Pnt centre1 (0, 0, 0);
gp_Dir norm (0, 0, 1);
gce_MakeCirc MC1 (centre1, norm, 35);
gp_Circ C1 = MC1.Value();

//Definition of sweeping directions
gp_Vec vec1 (0, 0, 400);
gp_Vec vec2 (100, -100, 400);

//Defintion of the two shapes
gp_Vec vec3= vec1*(-0.5);
gp_Vec vec4= vec2*(-0.5);

gp_Circ C12 = C1.Translated(vec3);
gp_Circ C13 = C1.Translated(vec4);

TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge (C12);
TopoDS_Wire wire1 = BRepBuilderAPI_MakeWire (edge1);
TopoDS_Face face1= BRepBuilderAPI_MakeFace(wire1);

TopoDS_Edge edge2 = BRepBuilderAPI_MakeEdge (C13);
TopoDS_Wire wire2 = BRepBuilderAPI_MakeWire (edge2);
TopoDS_Face face2= BRepBuilderAPI_MakeFace(wire2);

BRepPrimAPI_MakePrism MPrisme1(wire1, vec1);
TopoDS_Shape prisme1 = MPrisme1.Shape();

BRepPrimAPI_MakePrism MPrisme2(wire2, vec2);
TopoDS_Shape prisme2 = MPrisme2.Shape();

//Calculation of the common shape
BRepAlgoAPI_Common anIntersection(prisme1, prisme2);
cout cout TopoDS_Shape Intersection= anIntersection.Shape();

Thank you for any help.

Denis

Torsten Sadowski's picture

What about anIntersection.Build()?

The constructor does not do the work.

Cheers, Torsten

Denis Teissandier's picture

With anIntersection.Build(), the result remains the same.

Are you sure that the constructor does not do the work ?

The algorithm BRepAlgoAPI_Section(prisme1, prisme2) gives a good result without the Build method ... but it is not the common shape.

Denis

Torsten Sadowski's picture

Yes you are right.

But on a closer look at your code you sweep wire in MakePrism which generates shells. Could you try to sweep the faces you create?

Cheers, Torsten

Denis Teissandier's picture

I have tried to sweep the two faces.
The result remains the same.

Denis.

Torsten Sadowski's picture

Now I'm out of ideas. Can your application display your created shapes so you can see they really intersect (which seems probable from the geometry data)?

Even better would be if you could run your app in a debugger and trace through the code. I find this always very useful, even meditative, recognising my mistake normally before the debugger hits the spot ;-)

Torsten

Stephen Leary's picture

I also had this problem.

I used the delete() function to test then checked the contents of Shape()

If you check the Shape() result you'll find that, unfortunately, the result is a shape with a compound and nothing else in it in the non intersection case. That's why it is not null.

If you check to see if that compound object is actually empty that should help.

I also set SetOperation(BOP_COMMON);

Hope this helps.

Stephen

Evgeny Lodyzhehsky's picture

Dear Denis Teissandier.

- Torsten Sadowski is quite right: the common between two shells in this case will be empty because there are not common parts between corresponding faces.

- I've tried to reproduce your case.
Here are Draw commands, that correspond to your code,
but I use the faces instead of wires.

circle c12 0 0 -200 0 0 1 35
circle c13 -50 50 -200 0 0 1 35

mkedge e1 c12
wire w1 e1
mkplane f1 w1

mkedge e2 c13
wire w2 e2
mkplane f2 w2

prism pr1 f1 0 0 400
prism pr2 f2 100 -100 400
bop pr1 pr2

bopcommon r
checkshape r

Using these commands I've obtained excellent result.
So, please, check your code.
IMHO:The best thing is to understand how these Draw commands
work and to try to copy C++ code from there.