3D modeling & numerical simulation

### Threading - defining 2D curves

 To create the neck of the bottle, you made a solid cylinder based on a cylindrical surface. You will create the threading's profile by creating 2D curves on such a surface.

 All geometries defined in the Geom package are parameterized. This means that each curve or surface from Geom is computed with a parametric equation. A Geom_CylindricalSurface surface is defined with the following parametric equation: P(U , V) = O + R * (cos(U) * xDir + sin(U) * yDir) + V * zDir , where : - P is the point of parameter (U , V). - O , xDir, yDir and zDir are respectively the origin, the X direction, Y direction and Z direction of the cylindrical surface local coordinate system. - R is the radius of the cylindrical surface. - U range is [0 , 2PI] and V is infinite.

 The advantage of having such parameterized geometries is that you can compute, on any (U , V)parameter of the surface: - the related point - the derivative vectors of order 1, 2 to N at this point - more pertinent data There is another advantage to 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:

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:

 Case Parametric Equation Parametric Curve U = 0 P(V) = O + V * zDir Line parallel to the Z direction V = 0 P(U) = O + R * (cos(U) * xDir + sin(U) * yDir) Circle parallel to the (O , X , Y) plane U != 0 V != 0 P(U , V) = O + R * (cos(U) * xDir + sin(U) * yDir) + V * zDir Helicoidal curve describing the evolution of height and angle on the cylinder

The helicoidal curve type is exactly what you need. On the neck's surface, the evolution laws of this curve will be:

In V parameter: between 0 and myHeighNeck for the height description

In U parameter: between 0 and 2PI for the angle description. But, as a cylindrical surface is U
periodic, you can decide to extend this angle evolution to 4PI as shown in the following drawing:

 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.

 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: - To define a 2D point from its X and Y coordinates, use the gp_Pnt2d class. - To define a 2D direction (unit vector) from its X and Y coordinates, use the gp_Dir2d class. The coordinates will automatically be normalized. - To define a 2D right handed coordinate system, use the gp_Ax2d class which is computed from a point (origin of the coordinate system) and a direction - X direction of the coordinate system. The Y direction will be automatically computed. gp_Pnt2d aPnt(2. * PI , myNeckHeight / 2.); gp_Dir2d aDir(2. * PI , myNeckHeight / 4.); gp_Ax2d aAx2d(aPnt , aDir); 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 the top of the thread's shape (on aCyl2 surface).

 You 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: - a coordinate system whose origin is the ellipse center - a major radius on the major axis defined by the X direction of the coordinate system - a minor radius on the minor axis defined by the Y direction of the coordinate system Supposing that : - Both ellipses have the same major radius of 2*PI. - Minor radius of the first ellipse is myNeckHeight / 10 - And minor radius value of the second ellipse is a fourth of the first one Your ellipses are defined as follows: Standard_Real aMajor = 2. * PI; Standard_Real aMinor = myNeckHeight / 10; Handle(Geom2d_Ellipse) anEllipse1 = new Geom2d_Ellipse(aAx2d , aMajor , aMinor); Handle(Geom2d_Ellipse) anEllipse2 = new Geom2d_Ellipse(aAx2d , aMajor , aMinor / 4); To describe portions of curves for the arcs drawn above, you define Geom2d_TrimmedCurve trimmed curves out of the created ellipses and two parameters to limit them. As the parametric equation of an ellipse is P(U) = O + (MajorRadius * cos(U) * XDirection) + (MinorRadius * sin(U) * YDirection), the ellipses are limited between 0 and PI. Handle(Geom2d_TrimmedCurve) aArc1 = new Geom2d_TrimmedCurve(anEllipse1 , 0 , PI); Handle(Geom2d_TrimmedCurve) aArc2 = new Geom2d_TrimmedCurve(anEllipse2 , 0 , PI); The last step consists in defining the segment, which is the same for the two profiles: a line limited by the first and last point of one of the arcs. To access the point corresponding to the parameter of a curve or a surface, you use the Value or D0 method (meaning 0th derivative), D1 method is for first derivative, D2 for the second. gp_Pnt2d anEllipsePnt1 = anEllipse1->Value(0); gp_Pnt2d anEllipsePnt2; anEllipse1->D0(PI , anEllipsePnt2); When creating the bottle's profile, you used classes from the GC package, providing algorithms to create elementary geometries. In 2D geometry, this kind of algorithms is found in the GCE2d package. Class names and behaviors are almost the same as in GC. For example, to create a 2D segment out of two points: Handle(Geom2d_TrimmedCurve) aSegment = GCE2d_MakeSegment (anEllipsePnt1 , anEllipsePnt2); next step previous step