To illustrate the use of classes provided in the 3D geometric modeling toolkits, you will create a bottle as shown:
-![](/overview/tutorial/images/tutorial_image001.png "")
+@image html /overview/tutorial/images/tutorial_image001.png
+@image latex /overview/tutorial/images/tutorial_image001.png
In the tutorial we will create, step-by-step, a function that will model a bottle as shown above. You will find the complete source code of this tutorial, including the very function *MakeBottle* in the distribution of Open CASCADE Technology. The function body is provided in the file samples/qt/Tutorial/src/MakeBottle.cxx.
In addition, we decide that the bottle's profile (base) will be centered on the origin of the global Cartesian coordinate system.
-![](/overview/tutorial/images/tutorial_image002.png "")
+@image html /overview/tutorial/images/tutorial_image002.png
+@image latex /overview/tutorial/images/tutorial_image002.png
This modeling requires four steps:
To create the bottle's profile, you first create characteristic points with their coordinates as shown below in the (XOY) plane. These points will be the supports that define the geometry of the profile.
-![](/overview/tutorial/images/tutorial_image003.png "")
+@image html /overview/tutorial/images/tutorial_image003.png
+@image latex /overview/tutorial/images/tutorial_image003.png
There are two classes to describe a 3D Cartesian point from its X, Y and Z coordinates in Open CASCADE Technology:
@subsection OCCT_TUTORIAL_SUB2_2 Profile: Defining the Geometry
With the help of the previously defined points, you can compute a part of the bottle's profile geometry. As shown in the figure below, it will consist of two segments and one arc.
-![](/overview/tutorial/images/tutorial_image004.png "")
+@image html /overview/tutorial/images/tutorial_image004.png
+@image latex /overview/tutorial/images/tutorial_image004.png
To create such entities, you need a specific data structure, which implements 3D geometric objects. This can be found in the Geom package of Open CASCADE Technology.
In Open CASCADE Technology a package is a group of classes providing related functionality. The classes have names that start with the name of a package they belong to. For example, *Geom_Line* and *Geom_Circle* classes belong to the *Geom* package. The *Geom* package implements 3D geometric objects: elementary curves and surfaces are provided as well as more complex ones (such as *Bezier* and *BSpline*).
* Three edges out of the previously computed curves.
* One wire with these edges.
-![](/overview/tutorial/images/tutorial_image005.png "")
+@image html /overview/tutorial/images/tutorial_image005.png
+@image latex /overview/tutorial/images/tutorial_image005.png
However, the *TopoDS* package provides only the data structure of the topological entities. Algorithm classes available to compute standard topological objects can be found in the *BRepBuilderAPI* package.
To create an edge, you use the BRepBuilderAPI_MakeEdge class with the previously computed curves:
* compute a new wire by reflecting the existing one.
* add the reflected wire to the initial one.
-![](/overview/tutorial/images/tutorial_image006.png "")
+@image html /overview/tutorial/images/tutorial_image006.png
+@image latex /overview/tutorial/images/tutorial_image006.png
To apply a transformation on shapes (including wires), you first need to define the properties of a 3D geometric transformation by using the gp_Trsf class. This transformation can be a translation, a rotation, a scale, a reflection, or a combination of these.
In our case, we need to define a reflection with respect to the X axis of the global coordinate system. An axis, defined with the gp_Ax1 class, is built out of a point and has a direction (3D unitary vector). There are two ways to define this axis.
| Face | Solid |
| Shell | Compound of Solids |
-![](/overview/tutorial/images/tutorial_image007.png "")
+@image html /overview/tutorial/images/tutorial_image007.png
+@image latex /overview/tutorial/images/tutorial_image007.png
Your current profile is a wire. Referring to the Shape/Generates table, you need to compute a face out of its wire to generate a solid.
To create a face, use the *BRepBuilderAPI_MakeFace* class. As previously explained, a face is a part of a surface bounded by a closed wire. Generally, *BRepBuilderAPI_MakeFace* computes a face out of a surface and one or more wires.
* applied on all edges of the shape
* have a radius of *myThickness* / 12
-![](/overview/tutorial/images/tutorial_image008.png "")
+@image html /overview/tutorial/images/tutorial_image008.png
+@image latex /overview/tutorial/images/tutorial_image008.png
To apply fillets on the edges of a shape, you use the *BRepFilletAPI_MakeFillet* class. This class is normally used as follows:
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.
-![](/overview/tutorial/images/tutorial_image009.png "")
+@image html /overview/tutorial/images/tutorial_image009.png
+@image latex /overview/tutorial/images/tutorial_image009.png
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 main (Z) axis direction and the X direction (the Y direction is computed from these two).
To align the neck with the center of the top face, being in the global coordinate system (0, 0, *myHeight*), with its normal on the global Z axis, your local coordinate system can be defined as follows:
* Create a parallel wall W2 from W1 at a distance D. If D is positive, W2 will be outside the initial solid, otherwise it will be inside.
* Compute a solid from the two walls W1 and W2.
-![](/overview/tutorial/images/tutorial_image010.png "")
+@image html /overview/tutorial/images/tutorial_image010.png
+@image latex /overview/tutorial/images/tutorial_image010.png
To compute a thick solid, you create an instance of the *BRepOffsetAPI_MakeThickSolid* class by giving the following information:
Using the same coordinate system *neckAx2* used to position the neck, you create two cylindrical surfaces *Geom_CylindricalSurface* with the following radii:
-![](/overview/tutorial/images/tutorial_image011.png "")
+@image html /overview/tutorial/images/tutorial_image011.png
+@image latex /overview/tutorial/images/tutorial_image011.png
Notice that one of the cylindrical surfaces is smaller than the neck. There is a good reason for this: after the thread creation, you will fuse it with the neck. So, we must make sure that the two shapes remain in contact.
* R is the radius of the cylindrical surface.
* U range is [0, 2PI] and V is infinite.
-![](/overview/tutorial/images/tutorial_image012.png "")
+@image html /overview/tutorial/images/tutorial_image012.png
+@image latex /overview/tutorial/images/tutorial_image012.png
The advantage of having such parameterized geometries is that you can compute, for any (U, V) parameters of the surface:
There is another advantage of these parametric equations: you can consider a surface as a 2D parametric space defined with a (U, V) coordinate system. For example, consider the parametric ranges of the neck's surface:
-![](/overview/tutorial/images/tutorial_image013.png "")
+@image html /overview/tutorial/images/tutorial_image013.png
+@image latex /overview/tutorial/images/tutorial_image013.png
Suppose that you create a 2D line on this parametric (U, V) space and compute its 3D parametric curve. Depending on the line definition, results are as follows:
* In V parameter: between 0 and myHeighNeck for the height description
* In U parameter: between 0 and 2PI for the angle description. But, since a cylindrical surface is U periodic, you can decide to extend this angle evolution to 4PI as shown in the following drawing:
-![](/overview/tutorial/images/tutorial_image014.png "")
+@image html /overview/tutorial/images/tutorial_image014.png
+@image latex /overview/tutorial/images/tutorial_image014.png
In this (U, V) parametric space, you will create a local (X, Y) coordinate system to position the curves to be created. This coordinate system will be defined with:
* A center located in the middle of the neck's cylinder parametric space at (2*PI, myNeckHeight / 2) in U, V coordinates.
* A X direction defined with the (2*PI, myNeckHeight/4) vector in U, V coordinates, so that the curves occupy half of the neck's surfaces.
-![](/overview/tutorial/images/tutorial_image015.png "")
+@image html /overview/tutorial/images/tutorial_image015.png
+@image latex /overview/tutorial/images/tutorial_image015.png
To use 2D primitive geometry types of Open CASCADE Technology for defining a point and a coordinate system, you will once again instantiate classes from gp:
You will now define the curves. As previously mentioned, these thread profiles are computed on two cylindrical surfaces. In the following figure, curves on the left define the base (on *aCyl1* surface) and the curves on the right define the top of the thread's shape (on *aCyl2* surface).
-![](/overview/tutorial/images/tutorial_image016.png "")
+@image html /overview/tutorial/images/tutorial_image016.png
+@image latex /overview/tutorial/images/tutorial_image016.png
You have already used the *Geom* package to define 3D geometric entities. For 2D, you will use the *Geom2d* package. As for *Geom*, all geometries are parameterized. For example, a *Geom2d_Ellipse* ellipse is defined from:
* compute the edges of the neck's threading.
* compute two wires out of these edges.
-![](/overview/tutorial/images/tutorial_image017.png "")
+@image html /overview/tutorial/images/tutorial_image017.png
+@image latex /overview/tutorial/images/tutorial_image017.png
Previously, you have built:
There are always faster ways to build a solid when the base topology is defined. You would like to create a solid out of two wires. Open CASCADE Technology provides a quick way to do this by building a loft: a shell or a solid passing through a set of wires in a given sequence.
The loft function is implemented in the *BRepOffsetAPI_ThruSections* class, which you use as follows:
-![](/overview/tutorial/images/tutorial_image018.png "")
+@image html /overview/tutorial/images/tutorial_image018.png
+@image latex /overview/tutorial/images/tutorial_image018.png
* Initialize the algorithm by creating an instance of the class. The first parameter of this constructor must be specified if you want to create a solid. By default, *BRepOffsetAPI_ThruSections* builds a shell.
* Add the successive wires using the AddWire method.
Congratulations! Your bottle is complete. Here is the result snapshot of the Tutorial application:
-![](/overview/tutorial/images/tutorial_image019.png "")
+@image html /overview/tutorial/images/tutorial_image019.png
+@image latex /overview/tutorial/images/tutorial_image019.png
We hope that this tutorial has provided you with a feel for the industrial strength power of Open CASCADE Technology.
If you want to know more and develop major projects using Open CASCADE Technology, we invite you to study our training, support, and consulting services on our site at http://www.opencascade.org/support. Our professional services can maximize the power of your Open CASCADE Technology applications.