|The edges of the bottle's body are very sharp. To replace them by rounded faces, you use the Fillet functionality of Open CASCADE Technology.|
|Depending on their location, fillets can be very complex - for example, they can follow linear or specific evolution laws between vertices of an edge - but for our purposes, you will simply specify that fillets must be:|
- applied on all edges of the shape
- have a radius of myThickness / 12
To apply fillets on the edges of a shape, you use the BRepFilletAPI_MakeFillet class. This class is normally used as follows:
- Specify the shape to be filleted in the BRepFilletAPI_MakeFillet constructor.
- Add the fillet descriptions (an edge and a radius) using the Add method (you can add as many edges as you need).
- Ask for the resulting filleted shape with the Shape method.
To add the fillet description, you need to know the edges belonging to your shape. The best solution is to explore your solid to retrieve its edges. This kind of functionality is provided with the TopExp_Explorer class which explores the data structure described in a TopoDS_Shape and extracts the sub-shapes you specifically need. Generally, this explorer is created by providing the following information:
- the shape to explore
- the type of sub-shapes to be found. This information is given with the TopAbs_ShapeEnum enumeration.
TopExp_Explorer aEdgeExplorer(myBody , TopAbs_EDGE);
An explorer is usually applied in a loop by using its three main methods:
- More - to know if there are more sub-shapes to explore.
- Current - to know which is the currently explored sub-shape.
- Next - to move onto the next sub-shape to explore (used only if the More method returns true).
TopoDS_Edge aEdge = TopoDS::Edge(aEdgeExplorer.Current());
//Add edge to fillet algorithm
In the explorer loop, you have found all the edges contained in the bottle. Each one must then be added in the BRepFilletAPI_MakeFillet instance with the Add method. Do not forget to specify the radius of the fillet along with it.
mkFillet.Add(myThickness / 12. , aEdge);
Once this is done, you perform the last step of the procedure by asking for the filleted shape.
myBody = mkFillet.Shape();