0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / dox / tutorial / tutorial.md
index 10e43f4..5447e2f 100644 (file)
@@ -1,4 +1,4 @@
- Tutorial {#tutorial}
+ Tutorial {#occt__tutorial}
 =======
 
 @tableofcontents
@@ -18,8 +18,7 @@ From a programming standpoint, Open CASCADE Technology is designed to enhance yo
 
 To illustrate the use of classes provided in the 3D geometric modeling toolkits, you will create a bottle as shown:
 
-@image html /tutorial/images/tutorial_image001.png
-@image latex /tutorial/images/tutorial_image001.png
+@figure{/tutorial/images/tutorial_image001.png,"",240}
 
 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.
 
@@ -35,8 +34,7 @@ We first define the bottle specifications as follows:
 
 In addition, we decide that the bottle's profile (base) will be centered on the origin of the global Cartesian coordinate system.
 
-@image html /tutorial/images/tutorial_image002.png
-@image latex /tutorial/images/tutorial_image002.png
+@figure{/tutorial/images/tutorial_image002.png,"",240}
 
 This modeling requires four steps:
 
@@ -52,8 +50,7 @@ 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.
 
-@image html /tutorial/images/tutorial_image003.png
-@image latex /tutorial/images/tutorial_image003.png
+@figure{tutorial/images/tutorial_image003.svg,"",466}
 
 There are two classes to describe a 3D Cartesian point from its X, Y and Z coordinates in Open CASCADE Technology:
 
@@ -67,7 +64,7 @@ To choose the best class for this application, consider the following:
   * *Geom_CartesianPoint* is manipulated by handle and may have multiple references and a long lifetime.
     
 Since all the points you will define are only used to create the profile's curves, an object with a limited lifetime 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:
+To instantiate a *gp_Pnt* object, just specify the X, Y, and Z coordinates of the points in the global Cartesian coordinate system:
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
     gp_Pnt aPnt1(-myWidth / 2., 0, 0);
@@ -86,8 +83,7 @@ Standard_Real xValue1 = aPnt1.X();
 @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.
 
-@image html /tutorial/images/tutorial_image004.png
-@image latex /tutorial/images/tutorial_image004.png
+@figure{/tutorial/images/tutorial_image004.png,"",240}
 
 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*).
@@ -143,8 +139,7 @@ Referring to the previous table, to build the profile, you will create:
   * Three edges out of the previously computed curves.
   * One wire with these edges.
 
-@image html /tutorial/images/tutorial_image005.png
-@image latex /tutorial/images/tutorial_image005.png
+@figure{/tutorial/images/tutorial_image005.png,"",240}
     
 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:
@@ -182,8 +177,7 @@ Once the first part of your wire is created you need to compute the complete pro
   * compute a new wire by reflecting the existing one.
   * add the reflected wire to the initial one.
 
-@image html /tutorial/images/tutorial_image006.png
-@image latex /tutorial/images/tutorial_image006.png
+@figure{/tutorial/images/tutorial_image006.png,"",377}
 
 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.
@@ -266,8 +260,7 @@ To compute the main body of the bottle, you need to create a solid shape. The si
 | Face   | Solid              |
 | Shell  | Compound of Solids |
 
-@image html /tutorial/images/tutorial_image007.png
-@image latex /tutorial/images/tutorial_image007.png
+@figure{/tutorial/images/tutorial_image007.png,"",240}
 
 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.
@@ -304,8 +297,7 @@ For our purposes, we will specify that fillets must be:
   * applied on all edges of the shape
   * have a radius of *myThickness* / 12
 
-@image html /tutorial/images/tutorial_image008.png
-@image latex /tutorial/images/tutorial_image008.png
+@figure{/tutorial/images/tutorial_image008.png,"",240}
 
 To apply fillets on the edges of a shape, you use the *BRepFilletAPI_MakeFillet* class. This class is normally used as follows:
 
@@ -361,8 +353,7 @@ Once this is done, you perform the last step of the procedure by asking for the
 
 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.
 
-@image html /tutorial/images/tutorial_image009.png
-@image latex /tutorial/images/tutorial_image009.png
+@figure{/tutorial/images/tutorial_image009.png,"",240}
 
 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:
@@ -404,8 +395,7 @@ In Open CASCADE Technology, a hollowed solid is called a *Thick* *Solid* and is
   * 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.
 
-@image html /tutorial/images/tutorial_image010.png
-@image latex /tutorial/images/tutorial_image010.png
+@figure{/tutorial/images/tutorial_image010.png,"",240}
     
 To compute a thick solid, you create an instance of the *BRepOffsetAPI_MakeThickSolid* class by giving the following information:
     
@@ -485,10 +475,12 @@ The collection for shapes can be found in the *TopTools* package. As *BRepOffset
     facesToRemove.Append(faceToRemove);
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-All the necessary data are now available so you can create your hollowed solid by calling the *BRepOffsetAPI_MakeThickSolid* constructor:
+All the necessary data are now available so you can create your hollowed solid by calling the *BRepOffsetAPI_MakeThickSolid* MakeThickSolidByJoin method:
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
-    MyBody = BRepOffsetAPI_MakeThickSolid(myBody, facesToRemove, -myThickness / 50, 1.e-3);
+    BRepOffsetAPI_MakeThickSolid BodyMaker;
+    BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
+    myBody = BodyMaker.Shape();
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
@@ -508,8 +500,7 @@ As a first step, you compute these cylindrical surfaces. You are already familia
 
 Using the same coordinate system *neckAx2* used to position the neck, you create two cylindrical surfaces *Geom_CylindricalSurface* with the following radii:
 
-@image html /tutorial/images/tutorial_image011.png
-@image latex /tutorial/images/tutorial_image011.png
+@figure{/tutorial/images/tutorial_image011.png,"",300}
 
 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.
 
@@ -534,8 +525,7 @@ P(U, V) = O + R * (cos(U) * xDir + sin(U) * yDir) + V * zDir, where :
   * R is the radius of the cylindrical surface.
   * U range is [0, 2PI] and V is infinite.
 
-@image html /tutorial/images/tutorial_image012.png
-@image latex /tutorial/images/tutorial_image012.png
+@figure{/tutorial/images/tutorial_image012.png,"",400}
 
 The advantage of having such parameterized geometries is that you can compute, for any (U, V) parameters of the surface:
 
@@ -544,8 +534,7 @@ The advantage of having such parameterized geometries is that you can compute, f
 
 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:
 
-@image html /tutorial/images/tutorial_image013.png
-@image latex /tutorial/images/tutorial_image013.png
+@figure{/tutorial/images/tutorial_image013.png,"",320}
 
 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:
 
@@ -560,16 +549,14 @@ The helicoidal curve type is exactly what you need. On the neck's surface, the e
   * 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:
 
-@image html /tutorial/images/tutorial_image014.png
-@image latex /tutorial/images/tutorial_image014.png
+@figure{/tutorial/images/tutorial_image014.png,"",440}
 
 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.
   
-@image html /tutorial/images/tutorial_image015.png
-@image latex /tutorial/images/tutorial_image015.png
+@figure{/tutorial/images/tutorial_image015.png,"",440}
   
 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:
 
@@ -585,8 +572,7 @@ To use 2D primitive geometry types of Open CASCADE Technology for defining a poi
 
 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).
 
-@image html /tutorial/images/tutorial_image016.png
-@image latex /tutorial/images/tutorial_image016.png
+@figure{/tutorial/images/tutorial_image016.png,"",440}
 
 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:
 
@@ -642,8 +628,7 @@ As you did when creating the base profile of the bottle, you can now:
   * compute the edges of the neck's threading.
   * compute two wires out of these edges.
 
-@image html /tutorial/images/tutorial_image017.png
-@image latex /tutorial/images/tutorial_image017.png
+@figure{/tutorial/images/tutorial_image017.png,"",440}
 
 Previously, you have built:
 
@@ -683,8 +668,7 @@ You have computed the wires of the threading. The threading will be a solid shap
 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:
   
-@image html /tutorial/images/tutorial_image018.png
-@image latex /tutorial/images/tutorial_image018.png
+@figure{/tutorial/images/tutorial_image018.png,"",285}
   
   * 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.
@@ -714,11 +698,10 @@ You are almost done building the bottle. Use the *TopoDS_Compound* and *BRep_Bui
 
 Congratulations! Your bottle is complete. Here is the result snapshot of the Tutorial application:
 
-@image html /tutorial/images/tutorial_image019.png
-@image latex /tutorial/images/tutorial_image019.png
+@figure{/tutorial/images/tutorial_image019.png,"",320}
 
 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.
+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 https://www.opencascade.com/content/technology-support. Our professional services can maximize the power of your Open CASCADE Technology applications.
 
 
 @section sec6 Appendix
@@ -813,7 +796,9 @@ Complete definition of MakeBottle function (defined in the file src/MakeBottle.c
 
         TopTools_ListOfShape facesToRemove;
         facesToRemove.Append(faceToRemove);
-        myBody = BRepOffsetAPI_MakeThickSolid(myBody, facesToRemove, -myThickness / 50, 1.e-3);
+        BRepOffsetAPI_MakeThickSolid BodyMaker;
+        BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
+        myBody = BodyMaker.Shape();
         // Threading : Create Surfaces
         Handle(Geom_CylindricalSurface) aCyl1 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 0.99);
         Handle(Geom_CylindricalSurface) aCyl2 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 1.05);
@@ -862,3 +847,4 @@ Complete definition of MakeBottle function (defined in the file src/MakeBottle.c
         return aRes;
     }
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+