Mon, 01/11/2021 - 19:51
Hello !
I'm trying to cut one a cylinder with a surface of revolution to get a cylinder with one round end.
Cylinder and surface of revolution are 100% OK when used alone. But I cannot get any result when trying to cut using : BRepAlgoAPI_Cut .
Code is below, any suggestion would help !!
Thanks, John
// 1- Create a surface of revolution along Z axis
// Define a curve by interpolating points.
Handle(TColgp_HArray1OfPnt) myArr = new TColgp_HArray1OfPnt(1, 3 );
myArr->SetValue(1, gp_Pnt(0.0, 1.0, 0 ));
myArr->SetValue(2, gp_Pnt(0.0, M_SQRT1_2, M_SQRT1_2 ));
myArr->SetValue(3, gp_Pnt(0.0, 0.0, 1.0 ));
Standard_Real Given_Tolerancing = 1.0e-7;
GeomAPI_Interpolate intp(myArr, Standard_False, Given_Tolerancing);
intp.Perform();
Handle( Geom_BSplineCurve ) myCurve = intp.Curve();
// Curve revolution to get the Surface.
TopoDS_Edge myEdge = BRepBuilderAPI_MakeEdge( myCurve );
auto myRevolAxis = gp_Ax1( gp_Pnt( 0.0, 0.0,0.),gp_Dir(0.0, 0.0 ,1.0));
TopoDS_Shape myRevol_Shape = BRepPrimAPI_MakeRevol( myEdge, myRevolAxis );
// 2- Create a Cylinder along Z axis.
Standard_Real Cylinder_Radius = 0.5;
Standard_Real Cylinder_Length = 5.0;
// Basis : Z axis is horizontal.
gp_Ax2 BasisZ( gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0) );
BRepPrimAPI_MakeCylinder cylinderMaker( BasisZ, Cylinder_Radius, Cylinder_Length);
TopoDS_Shape myCylinder = cylinderMaker.Shape();
// Boolean operation between Cylinder ans Surface of revolution.
BRepAlgoAPI_Cut boolMaker( myCylinder, myRevol_Shape);
TopoDS_Shape Returned_Shape = boolMaker.Shape();