|To add a neck to the bottle, you will create a cylinder and fuse it to the body.|
|The cylinder is to be positioned on the top face of the body with a radius of myThickness / 4. and a height of myHeight / 10.|
To position the cylinder, you need to define a coordinate system with the gp_Ax2 class defining a right-handed coordinate system from a point and two directions - the normal and the X direction (the Y direction is computed from these two).
The center of the top face being, in the global coordinate system, (0 , 0 , myHeight) and its normal on the Z axis, your local coordinate system can be defined as follows:
gp_Pnt neckLocation(0 , 0 , myHeight);
gp_Dir neckNormal = gp::DZ();
gp_Ax2 neckAx2(neckLocation , neckNormal);
To create a cylinder, use another class from the primitives construction package: the BRepPrimAPI_MakeCylinder class. The information you must provide is:
- the coordinate system where the cylinder will be located
- the radius and height
Standard_Real myNeckRadius = myThickness / 4.;
Standard_Real myNeckHeight = myHeight / 10;
BRepPrimAPI_MakeCylinder MKCylinder(neckAx2 , myNeckRadius , myNeckHeight);
TopoDS_Shape myNeck = MKCylinder.Shape();
You now have two separate parts: a main body and a neck that you need to fuse together.
The BRepAlgoAPI package provides services to perform boolean operations between shapes, and especially: common (boolean intersection), cut (boolean substraction) and fuse (boolean union).
Use BRepAlgoAPI_Fuse to fuse the two shapes:
myBody = BRepAlgoAPI_Fuse(myBody , myNeck);