A possible bug in intersection of cone and cylinder

I meet a problem when making the intersection of cylinder with a cone, following is the code:

// make cone

TopoDS_Shape box1 = BRepPrimAPI_MakeCone(100, 0, 400);

// make a cylinder with a offset from X axis

gp_Ax2 ax2( gp_Pnt(-10, 0, -20), gp_Dir(0, 0, 1) );

TopoDS_Shape box2 = BRepPrimAPI_MakeCylinder(ax2, 10, 2000);

// make the intersection

TopoDS_Shape result;

BRepAlgoAPI_Common mkCommon( box1 /*main*/, box2 /*tool*/ );

result = mkCommon.Shape();

// calculate the volume of the intersection

GProp_GProps massProps;

BRepGProp::VolumeProperties( result, massProps );

double vol = massProps.Mass();


here, I get the volume of the intersection is 0; there is wrong.

However, when I make the offset of the cylinder as gp_Pnt(0, 0, 0), or gp_Pnt(10, 0, -20); which means the the offset for X >=0;  the volume of the intersection will become a reasonable value.

I also test the intersection of this cylinder with torus, box, etc., they are good, only cylinder meets this problem.

Whether I make any mistake in using the code, or there is a bug in the OCCT?  

BTW, I am using the OCCT v7.4.0.

Many thanks!

Thomas Anderson's picture

I am running 7.4.0 also and it appears to be a bug in the boolean operation.

pcone aCone 100 0 400
plane aPlane -10 0 -20 0 0 1
pcylinder aCylinder aPlane 10 500
bcommon aCommon aCone aCylinder

#vdisplay aCone
#vdisplay aCylinder
#vsetdispmode 1

nbshapes aCommon
Guido van Hilst not specified's picture


I tried it in OCCT v6.9.0 and seems ok?
See: IntersectionTest

Maybe a bug introduced after 690?

xiao pangzi's picture

More tests show that, this bug happen on cylinder boolean with cone or sphere, when the cylinder is exactly on -X axis and with a radius == abs(x_pos).  For other situations, looks fine.

liuhuiwei's picture

I use OCC 7.5,the code get null shape,but before result = mkCommon.Shape() add mkCommon.Build(),I get a shape,but the mkCommon.HasWarnings() return some warnings below:

Unable to orient the shape correctly
Some of the faces passed to the Solid Builder algorithm have not been classified and not used for solids creation