
Mon, 12/21/2020 - 18:30
Forums:
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!
Mon, 12/21/2020 - 21:36
I am running 7.4.0 also and it appears to be a bug in the boolean operation.
Mon, 12/21/2020 - 22:44
Hi,
I tried it in OCCT v6.9.0 and seems ok?
See: IntersectionTest
Maybe a bug introduced after 690?
Tue, 12/22/2020 - 02:13
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.
Wed, 12/30/2020 - 04:19
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