|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.|
|There are two classes to describe a 3D cartesian point from its X, Y and Z coordinates in Open CASCADE Technology:|
- the primitive geometric gp_Pnt class
- the transient Geom_CartesianPoint class manipulated by a handle
A handle is a type of smart pointer that provides automatic memory management.
To choose the best class for this application, consider the following:
- gp_Pnt is manipulated by value. Like all objects of its kind, it will have a limited life time.
- Geom_CartesianPoint is manipulated by handle and may have multiple references and a long life time.
Since all points you will define are used only to create the profile's curves, an object with a limited life time will do. Choose the gp_Pnt class.
To instantiate a gp_Pnt object, just specify the X, Y, and Z coordinates of the points in the global cartesian coordinate system:
gp_Pnt aPnt1(-myWidth / 2. , 0 , 0);
gp_Pnt aPnt2(-myWidth / 2. , -myThickness / 4. , 0);
gp_Pnt aPnt3(0 , -myThickness / 2. , 0);
gp_Pnt aPnt4(myWidth / 2. , -myThickness / 4. , 0);
gp_Pnt aPnt5(myWidth / 2. , 0 , 0);
If you decide to use the Geom_CartesianPoint class, the syntax would be slightly different. All objects manipulated by handle must use the standard C++ operator new and are built as follows:
Handle(Geom_CartesianPoint) aPnt1 = new Geom_CartesianPoint(-myWidth /
2. , 0 , 0);
Once your objects are instantiated, you may need to apply methods to them. Here again, syntax is the same as in C++. For example, to get the X coordinate of a point:
gp_Pnt aPnt1(0 , 0 , 0);
Handle(Geom_CartesianPoint) aPnt2 = new Geom_CartesianPoint(0 , 0 , 0);
Standard_Real xValue1 = aPnt1.X();
Standard_Real xValue2 = aPnt2->X();