0027229: Extema documentation is out of date.
[occt.git] / dox / user_guides / modeling_data / modeling_data.md
CommitLineData
ba06f8bb 1Modeling Data {#occt_user_guides__modeling_data}
72b7576f 2========================
3
e5bd0d98 4@tableofcontents
5
ba06f8bb 6@section occt_modat_0 Introduction
72b7576f 7
e2b55410 8Modeling Data supplies data structures to represent 2D and 3D geometric models.
9
e2ba9cb1 10This manual explains how to use Modeling Data. For advanced information on modeling data, see our <a href="http://www.opencascade.com/content/tutorial-learning">E-learning & Training</a> offerings.
72b7576f 11
72b7576f 12@section occt_modat_1 Geometry Utilities
13
14Geometry Utilities provide the following services:
15 * Creation of shapes by interpolation and approximation
16 * Direct construction of shapes
e2b55410 17 * Conversion of curves and surfaces to BSpline curves and surfaces
72b7576f 18 * Computation of the coordinates of points on 2D and 3D curves
19 * Calculation of extrema between shapes.
20
21@subsection occt_modat_1_1 Interpolations and Approximations
22
e2b55410 23In modeling, it is often required to approximate or interpolate points into curves and surfaces. In interpolation, the process is complete when the curve or surface passes through all the points; in approximation, when it is as close to these points as possible.
24
25Approximation of Curves and Surfaces groups together a variety of functions used in 2D and 3D geometry for:
26 * the interpolation of a set of 2D points using a 2D BSpline or Bezier curve;
27 * the approximation of a set of 2D points using a 2D BSpline or Bezier curve;
28 * the interpolation of a set of 3D points using a 3D BSpline or Bezier curve, or a BSpline surface;
29 * the approximation of a set of 3D points using a 3D BSpline or Bezier curve, or a BSpline surface.
30
31You can program approximations in two ways:
32
33 * Using high-level functions, designed to provide a simple method for obtaining approximations with minimal programming,
34 * Using low-level functions, designed for users requiring more control over the approximations.
72b7576f 35
36@subsubsection occt_modat_1_1_1 Analysis of a set of points
37
e2b55410 38The class *PEquation* from *GProp* package allows analyzing a collection or cloud of points and verifying if they are coincident, collinear or coplanar within a given precision. If they are, the algorithm computes the mean point, the mean line or the mean plane of the points. If they are not, the algorithm computes the minimal box, which includes all the points.
72b7576f 39
40@subsubsection occt_modat_1_1_2 Basic Interpolation and Approximation
41
42Packages *Geom2dAPI* and *GeomAPI* provide simple methods for approximation and interpolation with minimal programming
43
dba69de2 44#### 2D Interpolation
45
72b7576f 46The class *Interpolate* from *Geom2dAPI* package allows building a constrained 2D BSpline curve, defined by a table of points through which the curve passes. If required, the parameter values and vectors of the tangents can be given for each point in the table.
47
dba69de2 48#### 3D Interpolation
49
72b7576f 50The class *Interpolate* from *GeomAPI* package allows building a constrained 3D BSpline curve, defined by a table of points through which the curve passes. If required, the parameter values and vectors of the tangents can be given for each point in the table.
51
e5bd0d98 52@image html /user_guides/modeling_data/images/modeling_data_image003.png "Approximation of a BSpline from scattered points"
53@image latex /user_guides/modeling_data/images/modeling_data_image003.png "Approximation of a BSpline from scattered points"
72b7576f 54
55This class may be instantiated as follows:
56~~~~~
57GeomAPI_Interpolate Interp(Points);
58~~~~~
59
60From this object, the BSpline curve may be requested as follows:
61~~~~~
62Handle(Geom_BSplineCurve) C = Interp.Curve();
63~~~~~
64
dba69de2 65#### 2D Approximation
66
72b7576f 67The class *PointsToBSpline* from *Geom2dAPI* package allows building a 2DBSpline curve, which approximates a set of points. You have to define the lowest and highest degree of the curve, its continuity and a tolerance value for it.The tolerance value is used to check that points are not too close to each other, or tangential vectors not too small. The resulting BSpline curve will beC2 or second degree continuous, except where a tangency constraint is defined on a point through which the curve passes. In this case, it will be only C1continuous.
68
dba69de2 69#### 3D Approximation
70
72b7576f 71The class *PointsToBSpline* from GeomAPI package allows building a 3D BSplinecurve, which approximates a set of points. It is necessary to define the lowest and highest degree of the curve, its continuity and tolerance. The tolerance value is used to check that points are not too close to each other,or that tangential vectors are not too small.
72
73The resulting BSpline curve will be C2 or second degree continuous, except where a tangency constraint is defined on a point, through which the curve passes. In this case, it will be only C1 continuous. This class is instantiated as follows:
74
75~~~~~
76GeomAPI_PointsToBSpline
77Approx(Points,DegMin,DegMax,Continuity, Tol);
78~~~~~
79
80From this object, the BSpline curve may be requested as follows:
e5bd0d98 81
72b7576f 82~~~~~
83Handle(Geom_BSplineCurve) K = Approx.Curve();
84~~~~~
85
dba69de2 86#### Surface Approximation
87
72b7576f 88The class **PointsToBSplineSurface** from GeomAPI package allows building a BSpline surface, which approximates or interpolates a set of points.
89
90@subsubsection occt_modat_1_1_3 Advanced Approximation
91
92Packages *AppDef* and *AppParCurves* provide low-level functions, allowing more control over the approximations.
93
e2b55410 94The low-level functions provide a second API with functions to:
95 * Define compulsory tangents for an approximation. These tangents have origins and extremities.
96 * Approximate a set of curves in parallel to respect identical parameterization.
97 * Smooth approximations. This is to produce a faired curve.
98
99You can also find functions to compute:
100 * The minimal box which includes a set of points
101 * The mean plane, line or point of a set of coplanar, collinear or coincident points.
102
dba69de2 103#### Approximation by multiple point constraints
104
72b7576f 105*AppDef* package provides low-level tools to allow parallel approximation of groups of points into Bezier or B-Spline curves using multiple point constraints.
106
107The following low level services are provided:
e5bd0d98 108
72b7576f 109* Definition of an array of point constraints:
72b7576f 110
e2b55410 111 The class *MultiLine* allows defining a given number of multi-point constraints in order to build the multi-line, multiple lines passing through ordered multiple point constraints.
e5bd0d98 112
113 @image html /user_guides/modeling_data/images/modeling_data_image004.png "Definition of a MultiLine using Multiple Point Constraints"
114 @image latex /user_guides/modeling_data/images/modeling_data_image004.png "Definition of a MultiLine using Multiple Point Constraints"
72b7576f 115
e5bd0d98 116 In this image:
117 * *Pi*, *Qi*, *Ri* ... *Si* can be 2D or 3D points.
72b7576f 118 * Defined as a group: *Pn*, *Qn*, *Rn,* ... *Sn* form a MultipointConstraint. They possess the same passage, tangency and curvature constraints.
119 * *P1*, *P2*, ... *Pn*, or the *Q*, *R*, ... or *S* series represent the lines to be approximated.
120
121* Definition of a set of point constraints:
e5bd0d98 122
e2b55410 123 The class *MultiPointConstraint* allows defining a multiple point constraint and computing the approximation of sets of points to several curves.
72b7576f 124
ba06f8bb 125* Computation of an approximation of a Bezier curve from a set of points:
e5bd0d98 126
127 The class *Compute* allows making an approximation of a set of points to a Bezier curve
72b7576f 128
129* Computation of an approximation of a BSpline curve from a set of points:
e5bd0d98 130
e2b55410 131 The class *BSplineCompute* allows making an approximation of a set of points to a BSpline curve.
72b7576f 132
133* Definition of Variational Criteria:
e5bd0d98 134
72b7576f 135The class *TheVariational* allows fairing the approximation curve to a given number of points using a least squares method in conjunction with a variational criterion, usually the weights at each constraint point.
136
dba69de2 137#### Approximation by parametric or geometric constraints
138
72b7576f 139
140*AppParCurves* package provides low-level tools to allow parallel approximation of groups of points into Bezier or B-Spline curve with parametric or geometric constraints, such as a requirement for the curve to pass through given points, or to have a given tangency or curvature at a particular point.
141
142The algorithms used include:
143- the least squares method
144- a search for the best approximation within a given tolerance value.
145
146The following low-level services are provided:
147
148* Association of an index to an object:
e5bd0d98 149
72b7576f 150The class *ConstraintCouple* allows you associating an index to an object to compute faired curves using *AppDef_TheVariational*.
151
152* Definition of a set of approximations of Bezier curves:
e5bd0d98 153
72b7576f 154The class *MultiCurve* allows defining the approximation of a multi-line made up of multiple Bezier curves.
155
156* Definition of a set of approximations of BSpline curves:
e5bd0d98 157
72b7576f 158The class *MultiBSpCurve* allows defining the approximation of a multi-line made up of multiple BSpline curves.
159
160* Definition of points making up a set of point constraints
e5bd0d98 161
72b7576f 162The class *MultiPoint* allows defining groups of 2D or 3D points making up a multi-line.
e2b55410 163
164#### Example: How to approximate a curve with respect to tangency
165
166To approximate a curve with respect to tangency, follow these steps:
167
168 1. Create an object of type <i> AppDef_MultiPointConstraints</i> from the set of points to approximate and use the method <i> SetTang </i>to set the tangency vectors.
169 2. Create an object of type <i> AppDef_MultiLine </i>from the <i> AppDef_MultiPointConstraint</i>.
170 3. Use <i> AppDef_BSplineCompute</i>, which instantiates <i>Approx_BSplineComputeLine</i> to perform the approximation.
72b7576f 171
172@subsection occt_modat_1_2 Direct Construction
173
4ee1bdf4 174Direct Construction methods from *gce*, *GC* and *GCE2d* packages provide simplified algorithms to build elementary geometric entities such as lines, circles and curves. They complement the reference definitions provided by the *gp*, *Geom* and *Geom2d* packages.
72b7576f 175
e2b55410 176The algorithms implemented by <i> gce</i>, <i> GCE2d</i> and <i> GC</i> packages are simple: there is no creation of objects defined by advanced positional constraints (for more information on this subject, see *Geom2dGcc* and *GccAna*, which describe geometry by constraints).
177
72b7576f 178For example, to construct a circle from a point and a radius using the *gp* package, it is necessary to construct axis *Ax2d* before creating the circle. If *gce* package is used, and *Ox* is taken for the axis, it is possible to create a circle directly from a point and a radius.
179
e2b55410 180Another example is the class <i>gce_MakeCirc</i> providing a framework for defining eight problems encountered in the geometric construction of circles and implementing the eight related construction algorithms.
181
182The object created (or implemented) is an algorithm which can be consulted to find out, in particular:
183
184 * its result, which is a <i>gp_Circ</i>, and
185 * its status. Here, the status indicates whether or not the construction was successful.
186
187If it was unsuccessful, the status gives the reason for the failure.
188
189~~~~
190 gp_Pnt P1 (0.,0.,0.);
191 gp_Pnt P2 (0.,10.,0.);
192 gp_Pnt P3 (10.,0.,0.);
193 gce_MakeCirc MC (P1,P2,P3);
194 if (MC.IsDone()) {
195 const gp_Circ& C = MC.Value();
196 }
197~~~~
198
199In addition, <i> gce</i>, <i> GCE2d</i> and <i> GC</i> each have a <i>Root</i> class. This class is the root of all classes in the package, which return a status. The returned status (successful
200construction or construction error) is described by the enumeration <i>gce_ErrorType</i>.
201
202Note, that classes, which construct geometric transformations do not return a status, and therefore do not inherit from *Root*.
203
204
d3013f55 205@subsubsection occt_modat_1_2_1 Simple geometric entities
72b7576f 206
d3013f55 207The following algorithms used to build entities from *gp* package are provided by *gce* package.
72b7576f 208- 2D line parallel to another at a distance,
209- 2D line parallel to another passing through a point,
210- 2D circle passing through two points,
211- 2D circle parallel to another at a distance,
212- 2D circle parallel to another passing through a point,
213- 2D circle passing through three points,
214- 2D circle from a center and a radius,
215- 2D hyperbola from five points,
216- 2D hyperbola from a center and two apexes,
217- 2D ellipse from five points,
218- 2D ellipse from a center and two apexes,
219- 2D parabola from three points,
220- 2D parabola from a center and an apex,
221- line parallel to another passing through a point,
222- line passing through two points,
223- circle coaxial to another passing through a point,
224- circle coaxial to another at a given distance,
225- circle passing through three points,
226- circle with its center, radius, and normal to the plane,
227- circle with its axis (center + normal),
228- hyperbola with its center and two apexes,
229- ellipse with its center and two apexes,
230- plane passing through three points,
231- plane from its normal,
232- plane parallel to another plane at a given distance,
233- plane parallel to another passing through a point,
234- plane from an array of points,
235- cylinder from a given axis and a given radius,
236- cylinder from a circular base,
237- cylinder from three points,
238- cylinder parallel to another cylinder at a given distance,
239- cylinder parallel to another cylinder passing through a point,
240- cone from four points,
241- cone from a given axis and two passing points,
242- cone from two points (an axis) and two radii,
243- cone parallel to another at a given distance,
244- cone parallel to another passing through a point,
245- all transformations (rotations, translations, mirrors,scaling transformations, etc.).
246
247Each class from *gp* package, such as *Circ, Circ2d, Mirror, Mirror2d*, etc., has the corresponding *MakeCirc, MakeCirc2d, MakeMirror, MakeMirror2d*, etc. class from *gce* package.
248
249It is possible to create a point using a *gce* package class, then question it to recover the corresponding *gp* object.
250
72b7576f 251~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
252 gp_Pnt2d Point1,Point2;
253 ...
254 //Initialization of Point1 and Point2
255 gce_MakeLin2d L = gce_MakeLin2d(Point1,Point2);
256 if (L.Status() == gce_Done() ){
257 gp_Lin2d l = L.Value();
258 }
259~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72b7576f 260
dba69de2 261This is useful if you are uncertain as to whether the arguments can create the *gp* object without raising an exception. In the case above, if *Point1* and *Point2* are closer than the tolerance value required by *MakeLin2d*, the function *Status* will return the enumeration *gce_ConfusedPoint*. This tells you why the *gp* object cannot be created. If you know that the points *Point1* and *Point2* are separated by the value exceeding the tolerance value, then you may create the *gp* object directly, as follows:
72b7576f 262
263~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
264gp_Lin2d l = gce_MakeLin2d(Point1,Point2);
265~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
266
d3013f55 267@subsubsection occt_modat_1_2_2 Geometric entities manipulated by handle
72b7576f 268
d3013f55 269*GC* and *GCE2d* packages provides an implementation of algorithms used to build entities from *Geom* and *Geom2D* packages.
270They implement the same algorithms as the *gce* package, and also contain algorithms for trimmed surfaces and curves.
271The following algorithms are available:
72b7576f 272- arc of a circle trimmed by two points,
273- arc of a circle trimmed by two parameters,
274- arc of a circle trimmed by one point and one parameter,
275- arc of an ellipse from an ellipse trimmed by two points,
276- arc of an ellipse from an ellipse trimmed by two parameters,
277- arc of an ellipse from an ellipse trimmed by one point and one parameter,
278- arc of a parabola from a parabola trimmed by two points,
279- arc of a parabola from a parabola trimmed by two parameters,
280- arc of a parabola from a parabola trimmed by one point and one parameter,
281- arc of a hyperbola from a hyperbola trimmed by two points,
282- arc of a hyperbola from a hyperbola trimmed by two parameters,
283- arc of a hyperbola from a hyperbola trimmed by one point and one parameter,
284- segment of a line from two points,
285- segment of a line from two parameters,
286- segment of a line from one point and one parameter,
287- trimmed cylinder from a circular base and a height,
288- trimmed cylinder from three points,
289- trimmed cylinder from an axis, a radius, and a height,
290- trimmed cone from four points,
291- trimmed cone from two points (an axis) and a radius,
292- trimmed cone from two coaxial circles.
293
294Each class from *GCE2d* package, such as *Circle, Ellipse, Mirror*, etc., has the corresponding *MakeCircle, MakeEllipse, MakeMirror*, etc. class from *Geom2d* package.
295Besides, the class *MakeArcOfCircle* returns an object of type *TrimmedCurve* from *Geom2d*.
296
297Each class from *GC* package, such as *Circle, Ellipse, Mirror*, etc., has the corresponding *MakeCircle, MakeEllipse, MakeMirror*, etc. class from *Geom* package.
298The following classes return objects of type *TrimmedCurve* from *Geom*:
299- *MakeArcOfCircle*
300- *MakeArcOfEllipse*
301- *MakeArcOfHyperbola*
302- *MakeArcOfParabola*
303- *MakeSegment*
304
305@subsection occt_modat_1_3 Conversion to and from BSplines
306
e2b55410 307The Conversion to and from BSplines component has two distinct purposes:
308 * Firstly, it provides a homogeneous formulation which can be used to describe any curve or surface.
309 This is useful for writing algorithms for a single data structure model.
310 The BSpline formulation can be used to represent most basic geometric objects provided
311 by the components which describe geometric data structures ("Fundamental Geometry Types", "2D Geometry Types" and "3D Geometry Types" components).
312 * Secondly, it can be used to divide a BSpline curve or surface into a series of curves or surfaces,
313 thereby providing a higher degree of continuity. This is useful for writing algorithms
314 which require a specific degree of continuity in the objects to which they are applied.
315 Discontinuities are situated on the boundaries of objects only.
316
317The "Conversion to and from BSplines" component is composed of three packages.
318
319The <i> Convert </i> package provides algorithms to convert the following into a BSpline curve or surface:
320
321 * a bounded curve based on an elementary 2D curve (line, circle or conic) from the <i> gp </i> package,
322 * a bounded surface based on an elementary surface (cylinder, cone, sphere or torus) from the <i> gp</i> package,
323 * a series of adjacent 2D or 3D Bezier curves defined by their poles.
324
325These algorithms compute the data needed to define the resulting BSpline curve or surface.
326This elementary data (degrees, periodic characteristics, poles and weights, knots and multiplicities)
327may then be used directly in an algorithm, or can be used to construct the curve or the surface
328by calling the appropriate constructor provided by the classes <i>Geom2d_BSplineCurve, Geom_BSplineCurve </i> or <i>Geom_BSplineSurface</i>.
329
330The <i>Geom2dConvert</i> package provides the following:
331
332 * a global function which is used to construct a BSpline curve from a bounded curve based on a 2D curve from the Geom2d package,
333 * a splitting algorithm which computes the points at which a 2D BSpline curve should be cut in order to obtain arcs with the same degree of continuity,
334 * global functions used to construct the BSpline curves created by this splitting algorithm, or by other types of segmentation of the BSpline curve,
335 * an algorithm which converts a 2D BSpline curve into a series of adjacent Bezier curves.
336
337The <i> GeomConvert</i> package also provides the following:
338
339 * a global function used to construct a BSpline curve from a bounded curve based on a curve from the Geom package,
340 * a splitting algorithm, which computes the points at which a BSpline curve should be cut in order to obtain arcs with the same degree of continuity,
341 * global functions to construct BSpline curves created by this splitting algorithm, or by other types of BSpline curve segmentation,
342 * an algorithm, which converts a BSpline curve into a series of adjacent Bezier curves,
343 * a global function to construct a BSpline surface from a bounded surface based on a surface from the Geom package,
344 * a splitting algorithm, which determines the curves along which a BSpline surface should be cut in order to obtain patches with the same degree of continuity,
345 * global functions to construct BSpline surfaces created by this splitting algorithm, or by other types of BSpline surface segmentation,
346 * an algorithm, which converts a BSpline surface into a series of adjacent Bezier surfaces,
347 * an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
72b7576f 348
349@subsection occt_modat_1_4 Points on Curves
350
e2b55410 351The Points on Curves component comprises high level functions providing an API for complex algorithms that compute points on a 2D or 3D curve.
352
72b7576f 353The following characteristic points exist on parameterized curves in 3d space:
354- points equally spaced on a curve,
355- points distributed along a curve with equal chords,
356- a point at a given distance from another point on a curve.
357
358*GCPnts* package provides algorithms to calculate such points:
359- *AbscissaPoint* calculates a point on a curve at a given distance from another point on the curve.
360- *UniformAbscissa* calculates a set of points at a given abscissa on a curve.
361- *UniformDeflection* calculates a set of points at maximum constant deflection between the curve and the polygon that results from the computed points.
362
dba69de2 363### Example: Visualizing a curve.
364
72b7576f 365Let us take an adapted curve **C**, i.e. an object which is an interface between the services provided by either a 2D curve from the package Geom2d (in case of an Adaptor_Curve2d curve) or a 3D curve from the package Geom (in case of an Adaptor_Curve curve), and the services required on the curve by the computation algorithm. The adapted curve is created in the following way:
366
dba69de2 367**2D case :**
72b7576f 368~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
369 Handle(Geom2d_Curve) mycurve = ... ;
370 Geom2dAdaptor_Curve C (mycurve) ;
371~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372
dba69de2 373**3D case :**
72b7576f 374~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
375 Handle(Geom_Curve) mycurve = ... ;
376 GeomAdaptor_Curve C (mycurve) ;
377~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
378
379The algorithm is then constructed with this object:
380
381~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
382 GCPnts_UniformDeflection myAlgo () ;
383 Standard_Real Deflection = ... ;
384 myAlgo.Initialize ( C , Deflection ) ;
385 if ( myAlgo.IsDone() )
386 {
387 Standard_Integer nbr = myAlgo.NbPoints() ;
388 Standard_Real param ;
4ee1bdf4 389 for ( Standard_Integer i = 1 ; i <= nbr ; i++ )
72b7576f 390 {
391 param = myAlgo.Parameter (i) ;
392 ...
393 }
394 }
395~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396
397
398@subsection occt_modat_1_5 Extrema
399
400The classes to calculate the minimum distance between points, curves, and surfaces in 2d and 3d are provided by *GeomAPI* and *Geom2dAPI* packages.
401
402These packages calculate the extrema of distance between:
403- point and a curve,
404- point and a surface,
405- two curves,
406- a curve and a surface,
407- two surfaces.
408
eb5c2ff4 409### Extrema between Point and Curve / Surface
410
411The *GeomAPI_ProjectPointOnCurve* class allows calculation of all extrema between a point and a curve. Extrema are the lengths of the segments orthogonal to the curve.
412The *GeomAPI_ProjectPointOnSurface* class allows calculation of all extrema between a point and a surface. Extrema are the lengths of the segments orthogonal to the surface.
413These classes use the "Projection" criteria for optimization.
72b7576f 414
eb5c2ff4 415### Extrema between Curves
72b7576f 416
eb5c2ff4 417The *Geom2dAPI_ExtremaCurveCurve* class allows calculation of all minimal distances between two 2D geometric curves.
418The *GeomAPI_ExtremaCurveCurve* class allows calculation of all minimal distances two 3D geometric curves.
419These classes use Euclidean distance as the criteria for optimization.
72b7576f 420
e2b55410 421### Extrema between Curve and Surface
72b7576f 422
eb5c2ff4 423The *GeomAPI_ExtremaCurveSurface* class allows calculation of one extrema between a 3D curve and a surface. Extrema are the lengths of the segments orthogonal to the curve and the surface.
424This class use the "Projection" criteria for optimization.
72b7576f 425
e2b55410 426### Extrema between Surfaces
72b7576f 427
eb5c2ff4 428The *GeomAPI_ExtremaSurfaceSurface* class allows calculation of one minimal and one maximal distance between two surfaces.
429This class use Euclidean distance to compute minimum and "Projection" criteria to compute maximum.
72b7576f 430
431@section occt_modat_2 2D Geometry
432
d3013f55 433*Geom2d* package defines geometric objects in 2dspace. All geometric entities are STEP processed. The objects are handled by reference.
e2b55410 434
435In particular, <i>Geom2d</i> package provides classes for:
436* description of points, vectors and curves,
437* their positioning in the plane using coordinate systems,
438* their geometric transformation, by applying translations, rotations, symmetries, scaling transformations and combinations thereof.
439
440The following objects are available:
72b7576f 441- point,
442- Cartesian point,
443- vector,
444- direction,
445- vector with magnitude,
446- axis,
447- curve,
448- line,
e2b55410 449- conic: circle, ellipse, hyperbola, parabola,
450- rounded curve: trimmed curve, NURBS curve, Bezier curve,
451- offset curve.
72b7576f 452
453Before creating a geometric object, it is necessary to decide how the object is handled.
454The objects provided by *Geom2d* package are handled by reference rather than by value. Copying an instance copies the handle, not the object, so that a change to one instance is reflected in each occurrence of it.
455If a set of object instances is needed rather than a single object instance, *TColGeom2d* package can be used. This package provides standard and frequently used instantiations of one-dimensional arrays and sequences for curves from *Geom2d* package. All objects are available in two versions:
456- handled by reference and
457- handled by value.
458
e2b55410 459The key characteristic of <i> Geom2d </i> curves is that they are parameterized.
460Each class provides functions to work with the parametric equation of the curve,
461and, in particular, to compute the point of parameter u on a curve and the derivative vectors of order 1, 2.., N at this point.
462
463As a consequence of the parameterization, a <i> Geom2d </i> curve is naturally oriented.
464
3f812249 465Parameterization and orientation differentiate elementary <i>Geom2d</i>curves from their
466equivalent as provided by <i> gp</i> package. <i>Geom2d</i> package provides conversion
e2b55410 467functions to transform a <i> Geom2d</i> object into a <i> gp</i> object, and vice-versa, when this is possible.
468
469Moreover, <i> Geom2d</i> package provides more complex curves, including Bezier curves,
470BSpline curves, trimmed curves and offset curves.
471
472<i> Geom2d </i> objects are organized according to an inheritance structure over several levels.
473
474Thus, an ellipse (specific class <i> Geom2d_Ellipse</i>) is also a conical curve and inherits from the abstract class <i> Geom2d_Conic</i>, while a Bezier curve (concrete class <i> Geom2d_BezierCurve</i>) is also a bounded curve and inherits from the abstract class <i> Geom2d_BoundedCurve</i>; both these examples are also curves (abstract class <i>Geom2d_Curve</i>). Curves, points and vectors inherit from the abstract class <i> Geom2d_Geometry,</i> which describes the properties common to any geometric object from the <i>Geom2d</i> package.
475
476This inheritance structure is open and it is possible to describe new objects, which inherit from those provided in the <i>Geom2d</i> package, provided that they respect the behavior of the classes from which they are to inherit.
477
478Finally, <i> Geom2d</i> objects can be shared within more complex data structures. This is why they are used within topological data structures, for example.
479
480<i>Geom2d</i>package uses the services of the <i> gp</i> package to:
481 * implement elementary algebraic calculus and basic analytic geometry,
482 * describe geometric transformations which can be applied to <i> Geom2d</i> objects,
483 * describe the elementary data structures of <i>Geom2d</i> objects.
484
485However, the <i> Geom2d</i> package essentially provides data structures and not algorithms.
486You can refer to the <i> GCE2d </i> package to find more evolved construction algorithms for <i> Geom2d </i> objects.
487
72b7576f 488@section occt_modat_3 3D Geometry
489
e2b55410 490The *Geom* package defines geometric objects in 3d space and contains all basic geometric transformations, such as identity, rotation, translation, mirroring, scale transformations, combinations of transformations, etc. as well as special functions depending on the reference definition of the geometric object (e.g. addition of a control point on a B-Spline curve,modification of a curve, etc.). All geometrical entities are STEP processed.
491
492In particular, it provides classes for:
493 * description of points, vectors, curves and surfaces,
494 * their positioning in 3D space using axis or coordinate systems, and
495 * their geometric transformation, by applying translations, rotations, symmetries, scaling transformations and combinations thereof.
496
d3013f55 497The following objects are available:
72b7576f 498- Point
499- Cartesian point
500- Vector
501- Direction
502- Vector with magnitude
503- Axis
504- Curve
505- Line
506- Conic: circle, ellipse, hyperbola, parabola
507- Offset curve
508- Elementary surface: plane, cylinder, cone, sphere, torus
509- Bounded curve: trimmed curve, NURBS curve, Bezier curve
510- Bounded surface: rectangular trimmed surface, NURBS surface,Bezier surface
511- Swept surface: surface of linear extrusion, surface of revolution
512- Offset surface.
513
e2b55410 514The key characteristic of *Geom* curves and surfaces is that they are parameterized.
515Each class provides functions to work with the parametric equation of the curve or
516surface, and, in particular, to compute:
517 * the point of parameter u on a curve, or
518 * the point of parameters (u, v) on a surface.
519together with the derivative vectors of order 1, 2, ... N at this point.
520
521As a consequence of this parameterization, a Geom curve or surface is naturally oriented.
522
523Parameterization and orientation differentiate elementary Geom curves and surfaces from the classes of the same (or similar) names found in <i> gp</i> package.
524<i>Geom</i> package also provides conversion functions to transform a Geom object into a <i> gp</i> object, and vice-versa, when such transformation is possible.
525
526Moreover, <i> Geom </i>package provides more complex curves and surfaces, including:
527 * Bezier and BSpline curves and surfaces,
528 * swept surfaces, for example surfaces of revolution and surfaces of linear extrusion,
529 * trimmed curves and surfaces, and
530 * offset curves and surfaces.
531
532Geom objects are organized according to an inheritance structure over several levels.
533Thus, a sphere (concrete class <i> Geom_SphericalSurface</i>) is also an elementary surface and inherits from the abstract class <i> Geom_ElementarySurface</i>, while a Bezier surface (concrete class <i> Geom_BezierSurface</i>) is also a bounded surface and inherits from the abstract class <i> Geom_BoundedSurface</i>; both these examples are also surfaces (abstract class <i> Geom_Surface</i>). Curves, points and vectors inherit from the abstract class <i> Geom_Geometry,</i> which describes the properties common to any geometric object from the <i>Geom</i> package.
534
535This inheritance structure is open and it is possible to describe new objects, which inherit from those provided in the Geom package, on the condition that they respect the behavior of the classes from which they are to inherit.
536
537Finally, Geom objects can be shared within more complex data structures. This is why they are used within topological data structures, for example.
538
72b7576f 539If a set of object instances is needed rather than a single object instance, *TColGeom* package can be used. This package provides instantiations of one- and two-dimensional arrays and sequences for curves from *Geom* package. All objects are available in two versions:
540- handled by reference and
541- handled by value.
542
e2b55410 543The <i> Geom</i> package uses the services of the <i> gp</i> package to:
544 * implement elementary algebraic calculus and basic analytic geometry,
545 * describe geometric transformations which can be applied to Geom objects,
546 * describe the elementary data structures of Geom objects.
547
548However, the Geom package essentially provides data structures, not algorithms.
549
550You can refer to the <i> GC</i> package to find more evolved construction algorithms for
551Geom objects.
552
553@section occt_modat_4 Properties of Shapes
554
555@subsection occt_modat_4_1 Local Properties of Shapes
556
557<i>BRepLProp</i> package provides the Local Properties of Shapes component,
558which contains algorithms computing various local properties on edges and faces in a BRep model.
559
560The local properties which may be queried are:
561
562 * for a point of parameter u on a curve which supports an edge :
563 * the point,
564 * the derivative vectors, up to the third degree,
565 * the tangent vector,
566 * the normal,
567 * the curvature, and the center of curvature;
568 * for a point of parameter (u, v) on a surface which supports a face :
569 * the point,
570 * the derivative vectors, up to the second degree,
571 * the tangent vectors to the u and v isoparametric curves,
572 * the normal vector,
573 * the minimum or maximum curvature, and the corresponding directions of curvature;
574 * the degree of continuity of a curve which supports an edge, built by the concatenation of two other edges, at their junction point.
575
576Analyzed edges and faces are described as <i> BRepAdaptor</i> curves and surfaces,
577which provide shapes with an interface for the description of their geometric support.
578The base point for local properties is defined by its u parameter value on a curve, or its (u, v) parameter values on a surface.
579
580@subsection occt_modat_4_2 Local Properties of Curves and Surfaces
581
582The "Local Properties of Curves and Surfaces" component provides algorithms for computing various local properties on a Geom curve (in 2D or 3D space) or a surface. It is composed of:
583
584 * <i> Geom2dLProp</i> package, which allows computing Derivative and Tangent vectors (normal and curvature) of a parametric point on a 2D curve;
585 * <i> GeomLProp </i> package, which provides local properties on 3D curves and surfaces
586 * <i> LProp </i> package, which provides an enumeration used to characterize a particular point on a 2D curve.
587
588Curves are either <i> Geom_Curve </i> curves (in 3D space) or <i> Geom2d_Curve </i> curves (in the plane).
589Surfaces are <i> Geom_Surface </i> surfaces. The point on which local properties are calculated
590is defined by its u parameter value on a curve, and its (u,v) parameter values on a surface.
591
592It is possible to query the same local properties for points as mentioned above, and additionally for 2D curves:
593
594 * the points corresponding to a minimum or a maximum of curvature;
595 * the inflection points.
596
597
598#### Example: How to check the surface concavity
599
600To check the concavity of a surface, proceed as follows:
601
602 1. Sample the surface and compute at each point the Gaussian curvature.
603 2. If the value of the curvature changes of sign, the surface is concave or convex depending on the point of view.
604 3. To compute a Gaussian curvature, use the class <i> SLprops</i> from <i> GeomLProp</i>, which instantiates the generic class <i> SLProps </i>from <i> LProp</i> and use the method <i> GaussianCurvature</i>.
605
606@subsection occt_modat_4_3 Global Properties of Shapes
607
608The Global Properties of Shapes component provides algorithms for computing the global
609properties of a composite geometric system in 3D space, and frameworks to query the computed results.
610
611The global properties computed for a system are :
612 * mass,
613 * mass center,
614 * matrix of inertia,
615 * moment about an axis,
616 * radius of gyration about an axis,
617 * principal properties of inertia such as principal axis, principal moments, and principal radius of gyration.
618
619Geometric systems are generally defined as shapes. Depending on the way they are analyzed, these shapes will give properties of:
620
621 * lines induced from the edges of the shape,
622 * surfaces induced from the faces of the shape, or
623 * volumes induced from the solid bounded by the shape.
624
625The global properties of several systems may be brought together to give the global properties of the system composed of the sum of all individual systems.
72b7576f 626
e2b55410 627The Global Properties of Shapes component is composed of:
628* seven functions for computing global properties of a shape: one function for lines, two functions for surfaces and four functions for volumes. The choice of functions depends on input parameters and algorithms used for computation (<i>BRepGProp</i> global functions),
629* a framework for computing global properties for a set of points (<i>GProp_PGProps</i>),
630* a general framework to bring together the global properties retained by several more elementary frameworks, and provide a general programming interface to consult computed global properties.
631
632Packages *GeomLProp* and *Geom2dLProp* provide algorithms calculating the local properties of curves and surfaces
72b7576f 633
634A curve (for one parameter) has the following local properties:
635- Point
636- Derivative
637- Tangent
638- Normal
639- Curvature
640- Center of curvature.
641
642A surface (for two parameters U and V) has the following local properties:
643- point
644- derivative for U and V)
645- tangent line (for U and V)
646- normal
647- max curvature
648- min curvature
649- main directions of curvature
650- mean curvature
651- Gaussian curvature
652
653The following methods are available:
3f812249 654* *CLProps* -- calculates the local properties of a curve (tangency, curvature,normal);
655* *CurAndInf2d* -- calculates the maximum and minimum curvatures and the inflection points of 2d curves;
656* *SLProps* -- calculates the local properties of a surface (tangency, the normal and curvature).
657* *Continuity* -- calculates regularity at the junction of two curves.
72b7576f 658
659Note that the B-spline curve and surface are accepted but they are not cut into pieces of the desired continuity. It is the global continuity, which is seen.
660
8d44b0a0 661@subsection occt_modat_4_4 Adaptors for Curves and Surfaces
e2b55410 662
663Some Open CASCADE Technology general algorithms may work theoretically on numerous types of curves or surfaces.
664
665To do this, they simply get the services required of the analyzed curve or surface through an interface so as to a single API, whatever the type of curve or surface. These interfaces are called adaptors.
666
667For example, <i> Adaptor3d_Curve </i> is the abstract class which provides the required services by an algorithm which uses any 3d curve.
668
669<i> GeomAdaptor </i> package provides interfaces:
670 * On a Geom curve;
671 * On a curve lying on a Geom surface;
672 * On a Geom surface;
673
674<i> Geom2dAdaptor</i> package provides interfaces :
675 * On a <i>Geom2d</i> curve.
676
677<i> BRepAdaptor </i> package provides interfaces:
678 * On a Face
679 * On an Edge
680
681When you write an algorithm which operates on geometric objects, use <i> Adaptor3d</i> (or <i> Adaptor2d</i>) objects.
682
683As a result, you can use the algorithm with any kind of object, if you provide for this object an interface derived from *Adaptor3d* or *Adaptor2d*.
684These interfaces are easy to use: simply create an adapted curve or surface from a *Geom2d* curve, and then use this adapted curve as an argument for the algorithm? which requires it.
685
72b7576f 686
687@section occt_modat_5 Topology
688
e2b55410 689OCCT Topology allows accessing and manipulating data of objects without dealing with their 2D or 3D representations. Whereas OCCT Geometry provides a description of objects in terms of coordinates or parametric values, Topology describes data structures of objects in parametric space. These descriptions use location in and restriction of parts of this space.
690
691Topological library allows you to build pure topological data structures. Topology defines relationships between simple geometric entities. In this way, you can model complex shapes as assemblies of simpler entities. Due to a built-in non-manifold (or mixed-dimensional) feature, you can build models mixing:
692 * 0D entities such as points;
693 * 1D entities such as curves;
694 * 2D entities such as surfaces;
695 * 3D entities such as volumes.
696
697You can, for example, represent a single object made of several distinct bodies containing embedded curves and surfaces connected or non-connected to an outer boundary.
72b7576f 698
3f812249 699Abstract topological data structure describes a basic entity -- a shape, which can be divided into the following component topologies:
700 * Vertex -- a zero-dimensional shape corresponding to a point in geometry;
701 * Edge -- a shape corresponding to a curve, and bound by a vertex at each extremity;
702 * Wire -- a sequence of edges connected by their vertices;
703 * Face -- part of a plane (in 2D geometry) or a surface (in 3D geometry) bounded by a closed wire;
704 * Shell -- a collection of faces connected by some edges of their wire boundaries;
705 * Solid -- a part of 3D space bound by a shell;
706 * Compound solid -- a collection of solids.
72b7576f 707
e2b55410 708The wire and the solid can be either infinite or closed.
709
710A face with 3D underlying geometry may also refer to a collection of connected triangles that approximate the underlying surface. The surfaces can be undefined leaving the faces represented by triangles only. If so, the model is purely polyhedral.
711
712Topology defines the relationship between simple geometric entities, which can thus be linked together to represent complex shapes.
713
714Abstract Topology is provided by six packages.
715The first three packages describe the topological data structure used in Open CASCADE Technology:
716
717 * <i> TopAbs</i> package provides general resources for topology-driven applications. It contains enumerations that are used to describe basic topological notions: topological shape, orientation and state. It also provides methods to manage these enumerations.
718 * <i> TopLoc </i>package provides resources to handle 3D local coordinate systems: <i> Datum3D</i>and <i> Location</i>. <i> Datum3D</i> describes an elementary coordinate system, while <i> Location</i> comprises a series of elementary coordinate systems.
719 * <i> TopoDS</i> package describes classes to model and build data structures that are purely topological.
720
721Three additional packages provide tools to access and manipulate this abstract topology:
722
723 * <i> TopTools</i> package provides basic tools to use on topological data structures.
724 * <i> TopExp</i> package provides classes to explore and manipulate the topological data structures described in the TopoDS package.
725 * <i> BRepTools </i> package provides classes to explore, manipulate, read and write BRep data structures. These more complex data structures combine topological descriptions with additional geometric information, and include rules for evaluating equivalence of different possible representations of the same object, for example, a point.
72b7576f 726
727@subsection occt_modat_5_1 Shape Location
728
729A local coordinate system can be viewed as either of the following:
e2b55410 730- A right-handed trihedron with an origin and three orthonormal vectors. The *gp_Ax2* package corresponds to this definition.
731- A transformation of a +1 determinant, allowing the transformation of coordinates between local and global references frames. This corresponds to the *gp_Trsf*.
72b7576f 732
733*TopLoc* package distinguishes two notions:
734- *TopLoc_Datum3D* class provides the elementary reference coordinate, represented by a right-handed orthonormal system of axes or by a right-handed unitary transformation.
735- *TopLoc_Location* class provides the composite reference coordinate made from elementary ones. It is a marker composed of a chain of references to elementary markers. The resulting cumulative transformation is stored in order to avoid recalculating the sum of the transformations for the whole list.
736
e5bd0d98 737@image html /user_guides/modeling_data/images/modeling_data_image005.png "Structure of TopLoc_Location"
738@image latex /user_guides/modeling_data/images/modeling_data_image005.png "Structure of TopLoc_Location"
72b7576f 739
740Two reference coordinates are equal if they are made up of the same elementary coordinates in the same order. There is no numerical comparison. Two coordinates can thus correspond to the same transformation without being equal if they were not built from the same elementary coordinates.
741
742For example, consider three elementary coordinates:
743R1, R2, R3
744The composite coordinates are:
745C1 = R1 * R2,
746C2 = R2 * R3
747C3 = C1 * R3
748C4 = R1 * C2
749
750**NOTE** C3 and C4 are equal because they are both R1 * R2 * R3.
751
e2b55410 752The *TopLoc* package is chiefly targeted at the topological data structure, but it can be used for other purposes.
72b7576f 753
754Change of coordinates
755---------------------
756
757*TopLoc_Datum3D* class represents a change of elementary coordinates. Such changes must be shared so this class inherits from *MMgt_TShared*. The coordinate is represented by a transformation *gp_Trsfpackage*. This transformation has no scaling factor.
758
72b7576f 759@subsection occt_modat_5_2 Naming shapes, sub-shapes, their orientation and state
760
761The **TopAbs** package provides general enumerations describing the basic concepts of topology and methods to handle these enumerations. It contains no classes. This package has been separated from the rest of the topology because the notions it contains are sufficiently general to be used by all topological tools. This avoids redefinition of enumerations by remaining independent of modeling resources. The TopAbs package defines three notions:
e2b55410 762- **Type** *TopAbs_ShapeEnum*;
763- **Orientation** *TopAbs_Orientation* ;
764- **State** *StateTopAbs_State*
72b7576f 765
766@subsubsection occt_modat_5_2_1 Topological types
767
768TopAbs contains the *TopAbs_ShapeEnum* enumeration,which lists the different topological types:
3f812249 769- COMPOUND -- a group of any type of topological objects.
770- COMPSOLID -- a composite solid is a set of solids connected by their faces. It expands the notions of WIRE and SHELL to solids.
771- SOLID -- a part of space limited by shells. It is three dimensional.
772- SHELL -- a set of faces connected by their edges. A shell can be open or closed.
773- FACE -- in 2D it is a part of a plane; in 3D it is a part of a surface. Its geometry is constrained (trimmed) by contours. It is two dimensional.
774- WIRE -- a set of edges connected by their vertices. It can be an open or closed contour depending on whether the edges are linked or not.
775- EDGE -- a topological element corresponding to a restrained curve. An edge is generally limited by vertices. It has one dimension.
776- VERTEX -- a topological element corresponding to a point. It has zero dimension.
777- SHAPE -- a generic term covering all of the above.
72b7576f 778
779A topological model can be considered as a graph of objects with adjacency relationships. When modeling a part in 2D or 3D space it must belong to one of the categories listed in the ShapeEnum enumeration. The TopAbspackage lists all the objects, which can be found in any model. It cannot be extended but a subset can be used. For example, the notion of solid is useless in 2D.
780
781The terms of the enumeration appear in order from the most complex to the most simple, because objects can contain simpler objects in their description. For example, a face references its wires, edges, and vertices.
e5bd0d98 782@image html /user_guides/modeling_data/images/modeling_data_image006.png "ShapeEnum"
783@image latex /user_guides/modeling_data/images/modeling_data_image006.png "ShapeEnum"
72b7576f 784
785@subsubsection occt_modat_5_2_2 Orientation
786
787The notion of orientation is represented by the **TopAbs_Orientation** enumeration. Orientation is a generalized notion of the sense of direction found in various modelers. This is used when a shape limits a geometric domain; and is closely linked to the notion of boundary. The three cases are the following:
788- Curve limited by a vertex.
789- Surface limited by an edge.
790- Space limited by a face.
791
792In each case the topological form used as the boundary of a geometric domain of a higher dimension defines two local regions of which one is arbitrarily considered as the **default region**.
793
794For a curve limited by a vertex the default region is the set of points with parameters greater than the vertex. That is to say it is the part of the curve after the vertex following the natural direction along the curve.
795
796For a surface limited by an edge the default region is on the left of the edge following its natural direction. More precisely it is the region pointed to by the vector product of the normal vector to the surface and the vector tangent to the curve.
797
798For a space limited by a face the default region is found on the negative side of the normal to the surface.
799
800Based on this default region the orientation allows definition of the region to be kept, which is called the *interior* or *material*. There are four orientations defining the interior.
801
e5bd0d98 802| Orientation | Description |
803| :--------- | :--------------------------------- |
dba69de2 804| FORWARD | The interior is the default region. |
805| REVERSED | The interior is the region complementary to the default. |
806| INTERNAL | The interior includes both regions. The boundary lies inside the material. For example a surface inside a solid. |
807| EXTERNAL | The interior includes neither region. The boundary lies outside the material. For example an edge in a wire-frame model. |
72b7576f 808
e5bd0d98 809@image html /user_guides/modeling_data/images/modeling_data_image007.png "Four Orientations"
810@image latex /user_guides/modeling_data/images/modeling_data_image007.png "Four Orientations"
72b7576f 811
3f812249 812The notion of orientation is a very general one, and it can be used in any context where regions or boundaries appear. Thus, for example, when describing the intersection of an edge and a contour it is possible to describe not only the vertex of intersection but also how the edge crosses the contour considering it as a boundary. The edge would therefore be divided into two regions: exterior and interior and the intersection vertex would be the boundary. Thus an orientation can be associated with an intersection vertex as in the following figure:
72b7576f 813
e5bd0d98 814| Orientation | Association |
815| :-------- | :-------- |
dba69de2 816| FORWARD | Entering |
817| REVERSED | Exiting |
818| INTERNAL | Touching from inside |
819| EXTERNAL | Touching from outside |
72b7576f 820
e5bd0d98 821@image html /user_guides/modeling_data/images/modeling_data_image008.png "Four orientations of intersection vertices"
822@image latex /user_guides/modeling_data/images/modeling_data_image008.png "Four orientations of intersection vertices"
72b7576f 823
824
825Along with the Orientation enumeration the *TopAbs* package defines four methods:
826
827@subsubsection occt_modat_5_2_3 State
828
829The **TopAbs_State** enumeration described the position of a vertex or a set of vertices with respect to a region. There are four terms:
dba69de2 830
e5bd0d98 831|Position | Description |
832| :------ | :------- |
dba69de2 833|IN | The point is interior. |
834|OUT | The point is exterior. |
835|ON | The point is on the boundary(within tolerance). |
836|UNKNOWN | The state of the point is indeterminate. |
837
72b7576f 838The UNKNOWN term has been introduced because this enumeration is often used to express the result of a calculation, which can fail. This term can be used when it is impossible to know if a point is inside or outside, which is the case with an open wire or face.
839
e5bd0d98 840@image html /user_guides/modeling_data/images/modeling_data_image009.png "The four states"
841@image latex /user_guides/modeling_data/images/modeling_data_image009.png "The four states"
72b7576f 842
843The State enumeration can also be used to specify various parts of an object. The following figure shows the parts of an edge intersecting a face.
844
e5bd0d98 845@image html /user_guides/modeling_data/images/modeling_data_image010.png "State specifies the parts of an edge intersecting a face"
846@image latex /user_guides/modeling_data/images/modeling_data_image010.png "State specifies the parts of an edge intersecting a face"
72b7576f 847
848@subsection occt_modat_5_3 Manipulating shapes and sub-shapes
849
850The *TopoDS* package describes the topological data structure with the following characteristics:
851- reference to an abstract shape with neither orientation nor location.
852- Access to the data structure through the tool classes.
853
854As stated above, OCCT Topology describes data structures of objects in parametric space. These descriptions use localization in and restriction of parts of this space. The types of shapes, which can be described in these terms, are the vertex, the face and the shape. The vertex is defined in terms of localization in parametric space, and the face and shape, in terms of restriction of this space.
855
856OCCT topological descriptions also allow the simple shapes defined in these terms to be combined into sets. For example, a set of edges forms a wire; a set of faces forms a shell, and a set of solids forms a composite solid (CompSolid in Open CASCADE Technology). You can also combine shapes of either sort into compounds. Finally, you can give a shape an orientation and a location.
857
858Listing shapes in order of complexity from vertex to composite solid leads us to the notion of the data structure as knowledge of how to break a shape down into a set of simpler shapes. This is in fact, the purpose of the *TopoDS* package.
859
3f812249 860The model of a shape is a shareable data structure because it can be used by other shapes. (An edge can be used by more than one face of a solid). A shareable data structure is handled by reference. When a simple reference is insufficient, two pieces of information are added: an orientation and a local coordinate reference.
72b7576f 861- An orientation tells how the referenced shape is used in a boundary (*Orientation* from *TopAbs*).
862- A local reference coordinate (*Location* from *TopLoc*) allows referencing a shape at a position different from that of its definition.
863
864The **TopoDS_TShape** class is the root of all shape descriptions. It contains a list of shapes. Classes inheriting **TopoDS_TShape** can carry the description of a geometric domain if necessary (for example, a geometric point associated with a TVertex). A **TopoDS_TShape** is a description of a shape in its definition frame of reference. This class is manipulated by reference.
865
866The **TopoDS_Shape** class describes a reference to a shape. It contains a reference to an underlying abstract shape, an orientation,and a local reference coordinate. This class is manipulated by value and thus cannot be shared.
867
868The class representing the underlying abstract shape is never referenced directly. The *TopoDS_Shape* class is always used to refer to it.
869
dba69de2 870The information specific to each shape (the geometric support) is always added by inheritance to classes deriving from **TopoDS_TShape**. The following figures show the example of a shell formed from two faces connected by an edge.
72b7576f 871
e5bd0d98 872@image html /user_guides/modeling_data/images/modeling_data_image011.png "Structure of a shell formed from two faces"
873@image latex /user_guides/modeling_data/images/modeling_data_image011.png "Structure of a shell formed from two faces"
72b7576f 874
e5bd0d98 875@image html /user_guides/modeling_data/images/modeling_data_image012.png "Data structure of the above shell"
876@image latex /user_guides/modeling_data/images/modeling_data_image012.png "Data structure of the above shell"
72b7576f 877
878In the previous diagram, the shell is described by the underlying shape TS, and the faces by TF1 and TF2. There are seven edges from TE1 to TE7 and six vertices from TV1 to TV6.
879
880The wire TW1 references the edges from TE1 to TE4; TW2 references from TE4 to TE7.
881
882The vertices are referenced by the edges as follows:TE1(TV1,TV4), TE2(TV1,TV2), TE3(TV2,TV3), TE4(TV3,TV4), TE5(TV4,TV5), TE6(T5,TV6),TE7(TV3,TV6).
883
884**Note** that this data structure does not contain any *back references*. All references go from more complex underlying shapes to less complex ones. The techniques used to access the information are described later. The data structure is as compact as possible. Sub-objects can be shared among different objects.
885
886Two very similar objects, perhaps two versions of the same object, might share identical sub-objects. The usage of local coordinates in the data structure allows the description of a repetitive sub-structure to be shared.
887
888The compact data structure avoids the loss of information associated with copy operations which are usually used in creating a new version of an object or when applying a coordinate change.
889
890The following figure shows a data structure containing two versions of a solid. The second version presents a series of identical holes bored at different positions. The data structure is compact and yet keeps all information on the sub-elements.
891
892The three references from *TSh2* to the underlying face *TFcyl* have associated local coordinate systems, which correspond to the successive positions of the hole.
e5bd0d98 893@image html /user_guides/modeling_data/images/modeling_data_image013.png "Data structure containing two versions of a solid"
894@image latex /user_guides/modeling_data/images/modeling_data_image013.png "Data structure containing two versions of a solid"
72b7576f 895
896Classes inheriting TopoDS_Shape
897------------------------------
898*TopoDS* is based on class *TopoDS_Shape* and the class defining its underlying shape. This has certain advantages, but the major drawback is that these classes are too general. Different shapes they could represent do not type them (Vertex, Edge, etc.) hence it is impossible to introduce checks to avoid incoherences such as inserting a face in an edge.
899
900 *TopoDS* package offers two sets of classes, one set inheriting the underlying shape with neither orientation nor location and the other inheriting *TopoDS_Shape*, which represent the standard topological shapes enumerated in *TopAbs* package.
901
902The following classes inherit Shape : *TopoDS_Vertex, TopoDS_Edge, TopoDS_Wire, TopoDS_Face, TopoDS_Shell, TopoDS_Solid,TopoDS_CompSolid,* and *TopoDS_Compound*. In spite of the similarity of names with those inheriting from **TopoDS_TShape** there is a profound difference in the way they are used.
903
904*TopoDS_Shape* class and the classes, which inherit from it, are the natural means to manipulate topological objects. *TopoDS_TShape* classes are hidden. *TopoDS_TShape* describes a class in its original local coordinate system without orientation. *TopoDS_Shape* is a reference to *TopoDS_TShape* with an orientation and a local reference.
905
906*TopoDS_TShape* class is deferred; *TopoDS_Shape* class is not. Using *TopoDS_Shape* class allows manipulation of topological objects without knowing their type. It is a generic form. Purely topological algorithms often use the *TopoDS_Shape* class.
907
908*TopoDS_TShape* class is manipulated by reference; TopoDS_Shape class by value. A TopoDS_Shape is nothing more than a reference enhanced with an orientation and a local coordinate. The sharing of *TopoDS_Shapes* is meaningless. What is important is the sharing of the underlying *TopoDS_TShapes*. Assignment or passage in argument does not copy the data structure: this only creates new *TopoDS_Shapes* which refer to the same *TopoDS_TShape*.
909
910Although classes inheriting *TopoDS_TShape* are used for adding extra information, extra fields should not be added in a class inheriting from TopoDS_Shape. Classes inheriting from TopoDS_Shape serve only to specialize a reference in order to benefit from static type control (carried out by the compiler). For example, a routine that receives a *TopoDS_Face* in argument is more precise for the compiler than the one, which receives a *TopoDS_Shape*. It is pointless to derive other classes than those found inTopoDS. All references to a topological data structure are made with the Shape class and its inheritors defined in *TopoDS*.
911
912There are no constructors for the classes inheriting from the *TopoDS_Shape* class, otherwise the type control would disappear through **implicit casting** (a characteristic of C++). The TopoDS package provides package methods for **casting** an object of the TopoDS_Shape class in one of these sub-classes, with type verification.
913
914The following example shows a routine receiving an argument of the *TopoDS_Shape* type, then putting it into a variable V if it is a vertex or calling the method ProcessEdge if it is an edge.
915
916
72b7576f 917~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
4ee1bdf4 918 #include <TopoDS_Vertex.hxx>
919 #include <TopoDS_Edge.hxx>
920 #include <TopoDS_Shape.hxx>
72b7576f 921
922
e5bd0d98 923 void ProcessEdge(const TopoDS_Edge&);
72b7576f 924
e5bd0d98 925 void Process(const TopoDS_Shape& aShape) {
72b7576f 926 if (aShape.Shapetype() == TopAbs_VERTEX) {
927 TopoDS_Vertex V;
928 V = TopoDS::Vertex(aShape); // Also correct
4ee1bdf4 929 TopoDS_Vertex V2 = aShape; // Rejected by the compiler
72b7576f 930 TopoDS_Vertex V3 = TopoDS::Vertex(aShape); // Correct
931 }
932 else if (aShape.ShapeType() == TopAbs_EDGE){
4ee1bdf4 933 ProcessEdge(aShape) ; // This is rejected
72b7576f 934 ProcessEdge(TopoDS::Edge(aShape)) ; // Correct
935 }
936 else {
4ee1bdf4 937 cout <<"Neither a vertex nor an edge ?";
72b7576f 938 ProcessEdge(TopoDS::Edge(aShape)) ;
4ee1bdf4 939 // OK for compiler but an exception will be raised at run-time
72b7576f 940 }
941 }
942~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
943
944
945
946@subsection occt_modat_5_4 Exploration of Topological Data Structures
947
948The *TopExp* package provides tools for exploring the data structure described with the *TopoDS* package. Exploring a topological structure means finding all sub-objects of a given type, for example, finding all the faces of a solid.
949
950The TopExp package provides the class *TopExp_Explorer* to find all sub-objects of a given type. An explorer is built with:
951- The shape to be explored.
952- The type of shapes to be found e.g. VERTEX, EDGE with the exception of SHAPE, which is not allowed.
953- The type of Shapes to avoid. e.g. SHELL, EDGE. By default, this type is SHAPE. This default value means that there is no restriction on the exploration.
954
955
956
957The Explorer visits the whole structure in order to find the shapes of the requested type not contained in the type to avoid. The example below shows how to find all faces in the shape *S*:
958
dba69de2 959
72b7576f 960~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
961 void test() {
962 TopoDS_Shape S;
963 TopExp_Explorer Ex;
964 for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next()) {
965 ProcessFace(Ex.Current());
966 }
967 }
968~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
969
dba69de2 970Find all the vertices which are not in an edge
72b7576f 971
72b7576f 972~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
973for (Ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ...)
974~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
975
976
dba69de2 977Find all the faces in a SHELL, then all the faces not in a SHELL:
72b7576f 978
72b7576f 979
980~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
981 void test() {
982 TopExp_Explorer Ex1, Ex2;
983 TopoDS_Shape S;
984 for (Ex1.Init(S,TopAbs_SHELL);Ex1.More(); Ex1.Next()){
985 // visit all shells
986 for (Ex2.Init(Ex1.Current(),TopAbs_FACE);Ex2.More();
987 Ex2.Next()){
988 //visit all the faces of the current shell
989 ProcessFaceinAshell(Ex2.Current());
990 ...
991 }
992 }
993 for(Ex1.Init(S,TopAbs_FACE,TopAbs_SHELL);Ex1.More(); Ex1.Next()){
994 // visit all faces not ina shell.
995 ProcessFace(Ex1.Current());
996 }
997 }
998~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
999
dba69de2 1000The Explorer presumes that objects contain only objects of an equal or inferior type. For example, if searching for faces it does not look at wires, edges, or vertices to see if they contain faces.
72b7576f 1001
1002The *MapShapes* method from *TopExp* package allows filling a Map. An exploration using the Explorer class can visit an object more than once if it is referenced more than once. For example, an edge of a solid is generally referenced by two faces. To process objects only once, they have to be placed in a Map.
1003
4ee1bdf4 1004**Example**
72b7576f 1005~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
e5bd0d98 1006 void TopExp::MapShapes (const TopoDS_Shape& S,
72b7576f 1007 const TopAbs_ShapeEnum T,
e5bd0d98 1008 TopTools_IndexedMapOfShape& M)
72b7576f 1009 {
1010 TopExp_Explorer Ex(S,T);
1011 while (Ex.More()) {
1012 M.Add(Ex.Current());
1013 Ex.Next();
1014 }
1015 }
1016~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1017
1018In the following example all faces and all edges of an object are drawn in accordance with the following rules:
1019- The faces are represented by a network of *NbIso* iso-parametric lines with *FaceIsoColor* color.
1020- The edges are drawn in a color, which indicates the number of faces sharing the edge:
dba69de2 1021 - *FreeEdgeColor* for edges, which do not belong to a face (i.e. wireframe element).
1022 - *BorderEdgeColor* for an edge belonging to a single face.
1023 - *SharedEdgeColor* for an edge belonging to more than one face.
1024- The methods *DrawEdge* and *DrawFaceIso* are also available to display individual edges and faces.
72b7576f 1025
1026The following steps are performed:
10271. Storing the edges in a map and create in parallel an array of integers to count the number of faces sharing the edge. This array is initialized to zero.
10282. Exploring the faces. Each face is drawn.
10293. Exploring the edges and for each of them increment the counter of faces in the array.
10304. From the Map of edges, drawing each edge with the color corresponding to the number of faces.
1031
72b7576f 1032~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
e5bd0d98 1033 void DrawShape ( const TopoDS_Shape& aShape,
72b7576f 1034 const Standard_Integer nbIsos,
1035 const Color FaceIsocolor,
1036 const Color FreeEdgeColor,
1037 const Color BorderEdgeColor,
1038 const Color SharedEdgeColor)
1039 {
1040 // Store the edges in aMap.
1041 TopTools_IndexedMapOfShape edgemap;
1042 TopExp::MapShapes(aShape,TopAbs_EDGE,edgeMap);
1043 // Create an array set to zero.
1044 TColStd_Array1OfInteger faceCount(1,edgeMap.Extent());
1045 faceCount.Init (0);
1046 // Explore the faces.
1047 TopExp_Explorer expFace(aShape,TopAbs_FACE);
1048 while (expFace.More()) {
1049 //Draw the current face.
1050 DrawFaceIsos(TopoDS::Face(expFace.Current()),nbIsos,FaceIsoColor);
1051 // Explore the edges ofthe face.
1052 TopExp_Explorer expEdge(expFace.Current(),TopAbs_EDGE);
1053 while (expEdge.More()) {
1054 //Increment the face count for this edge.
1055 faceCount(edgemap.FindIndex(expEdge.Current()))++;
1056 expEdge.Next();
1057 }
1058 expFace.Next();
1059 }
1060 //Draw the edges of theMap
1061 Standard_Integer i;
4ee1bdf4 1062 for (i=1;i<=edgemap.Extent();i++) {
72b7576f 1063 switch (faceCount(i)) {
1064 case 0 :
1065 DrawEdge(TopoDS::Edge(edgemap(i)),FreeEdgeColor);
1066 break;
1067 case 1 :
1068 DrawEdge(TopoDS::Edge(edgemap(i)),BorderEdgeColor);
1069 break;
1070 default :
1071 DrawEdge(TopoDS::Edge(edgemap(i)),SharedEdgeColor);
1072 break;
1073 }
1074 }
1075 }
1076~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1077
1078@subsection occt_modat_5_5 Lists and Maps of Shapes
1079
1080**TopTools** package contains tools for exploiting the *TopoDS* data structure. It is an instantiation of the tools from *TCollection* package with the Shape classes of *TopoDS*.
1081
e5bd0d98 1082
3f812249 1083* *TopTools_Array1OfShape, HArray1OfShape* -- instantiation of the *TCollection_Array1* and *TCollection_HArray1* with *TopoDS_Shape*.
1084* *TopTools_SequenceOfShape* -- instantiation of the *TCollection_Sequence* with *TopoDS_Shape*.
1085* *TopTools_MapOfShape* - instantiation of the *TCollection_Map*. Allows the construction of sets of shapes.
1086* *TopTools_IndexedMapOfShape* - instantiation of the *TCollection_IndexedMap*. Allows the construction of tables of shapes and other data structures.
72b7576f 1087
dba69de2 1088With a *TopTools_Map*, a set of references to Shapes can be kept without duplication.
1089The following example counts the size of a data structure as a number of *TShapes*.
1090
72b7576f 1091
72b7576f 1092~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
4ee1bdf4 1093 #include <TopoDS_Iterator.hxx>
e5bd0d98 1094 Standard_Integer Size(const TopoDS_Shape& aShape)
72b7576f 1095 {
1096 // This is a recursive method.
1097 // The size of a shape is1 + the sizes of the subshapes.
1098 TopoDS_Iterator It;
1099 Standard_Integer size = 1;
1100 for (It.Initialize(aShape);It.More();It.Next()) {
1101 size += Size(It.Value());
1102 }
1103 return size;
1104 }
1105~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1106
1107This program is incorrect if there is sharing in the data structure.
72b7576f 1108
dba69de2 1109Thus for a contour of four edges it should count 1 wire + 4 edges +4 vertices with the result 9, but as the vertices are each shared by two edges this program will return 13. One solution is to put all the Shapes in a Map so as to avoid counting them twice, as in the following example:
1110
1111
72b7576f 1112~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
4ee1bdf4 1113 #include <TopoDS_Iterator.hxx>
1114 #include <TopTools_MapOfShape.hxx>
72b7576f 1115
e5bd0d98 1116 void MapShapes(const TopoDS_Shape& aShape,
1117 TopTools_MapOfShape& aMap)
72b7576f 1118 {
1119 //This is a recursive auxiliary method. It stores all subShapes of aShape in a Map.
1120 if (aMap.Add(aShape)) {
1121 //Add returns True if aShape was not already in the Map.
1122 TopoDS_Iterator It;
1123 for (It.Initialize(aShape);It.More();It.Next()){
1124 MapShapes(It.Value(),aMap);
1125 }
1126 }
1127 }
1128
e5bd0d98 1129 Standard_Integer Size(const TopoDS_Shape& aShape)
72b7576f 1130 {
1131 // Store Shapes in a Mapand return the size.
1132 TopTools_MapOfShape M;
1133 MapShapes(aShape,M);
1134 return M.Extent();
1135 }
1136~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1137
dba69de2 1138**Note** For more details about Maps please, refer to the TCollection documentation. (Foundation Classes Reference Manual)
72b7576f 1139
dba69de2 1140The following example is more ambitious and writes a program which copies a data structure using an *IndexedMap*. The copy is an identical structure but it shares nothing with the original. The principal algorithm is as follows:
1141- All Shapes in the structure are put into an *IndexedMap*.
72b7576f 1142- A table of Shapes is created in parallel with the map to receive the copies.
1143- The structure is copied using the auxiliary recursive function,which copies from the map to the array.
1144
72b7576f 1145~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
4ee1bdf4 1146 #include <TopoDS_Shape.hxx>
1147 #include <TopoDS_Iterator.hxx>
1148 #include <TopTools_IndexedMapOfShape.hxx>
1149 #include <TopTools_Array1OfShape.hxx>
1150 #include <TopoDS_Location.hxx>
72b7576f 1151
e5bd0d98 1152 TopoDS_Shape Copy(const TopoDS_Shape& aShape,
1153 const TopoDS_Builder& aBuilder)
72b7576f 1154 {
1155 // Copies the wholestructure of aShape using aBuilder.
1156 // Stores all thesub-Shapes in an IndexedMap.
1157 TopTools_IndexedMapOfShape theMap;
1158 TopoDS_Iterator It;
1159 Standard_Integer i;
1160 TopoDS_Shape S;
1161 TopLoc_Location Identity;
1162 S = aShape;
1163 S.Location(Identity);
1164 S.Orientation(TopAbs_FORWARD);
1165 theMap.Add(S);
4ee1bdf4 1166 for (i=1; i<= theMap.Extent(); i++) {
72b7576f 1167 for(It.Initialize(theMap(i)); It.More(); It.Next()) {
1168 S=It.Value();
1169 S.Location(Identity);
1170 S.Orientation(TopAbs_FORWARD);
1171 theMap.Add(S);
1172 }
1173 }
1174 }
1175~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1176
1177
dba69de2 1178In the above example, the index *i* is that of the first object not treated in the Map. When *i* reaches the same size as the Map this means that everything has been treated. The treatment consists in inserting in the Map all the sub-objects, if they are not yet in the Map, they are inserted with an index greater than *i*.
72b7576f 1179
1180**Note** that the objects are inserted with a local reference set to the identity and a FORWARD orientation. Only the underlying TShape is of great interest.
1181
dba69de2 1182
72b7576f 1183~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
1184 //Create an array to store the copies.
1185 TopTools_Array1OfShapetheCopies(1,theMap.Extent());
1186
1187 // Use a recursivefunction to copy the first element.
1188 void AuxiliaryCopy (Standard_Integer,
e5bd0d98 1189 const TopTools_IndexedMapOfShape &,
1190 TopTools_Array1OfShape &,
1191 const TopoDS_Builder&);
72b7576f 1192
1193 AuxiliaryCopy(1,theMap,theCopies,aBuilder);
1194
1195 // Get the result with thecorrect local reference and orientation.
1196 S = theCopies(1);
1197 S.Location(aShape.Location());
1198 S.Orientation(aShape.Orientation());
1199 return S;
1200~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1201
1202Below is the auxiliary function, which copies the element of rank *i* from the map to the table. This method checks if the object has been copied; if not copied, then an empty copy is performed into the table and the copies of all the sub-elements are inserted by finding their rank in the map.
1203
dba69de2 1204
72b7576f 1205~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
1206 void AuxiliaryCopy(Standard_Integer index,
e5bd0d98 1207 const TopTools_IndexedMapOfShapes& sources,
1208 TopTools_Array1OfShape& copies,
1209 const TopoDS_Builder& aBuilder)
72b7576f 1210 {
1211 //If the copy is a null Shape the copy is not done.
1212 if (copies(index).IsNull()) {
1213 copies(index) =sources(index).EmptyCopied();
1214 //Insert copies of the sub-shapes.
1215 TopoDS_Iterator It;
1216 TopoDS_Shape S;
1217 TopLoc_Location Identity;
1218 for(It.Initialize(sources(index)),It.More(), It.Next ()) {
1219 S = It.Value();
1220 S.Location(Identity);
1221 S.Orientation(TopAbs_FORWARD);
1222 AuxiliaryCopy(sources.FindIndex(S),sources,copies,aBuilder);
1223 S.Location(It.Value().Location());S.Orientation(It.Value().Orientation()); aBuilder.Add(copies(index),S);
1224 }
1225 }
1226 }
1227~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1228
1229@subsubsection occt_modat_5_5_1 Wire Explorer
1230
e2b55410 1231*BRepTools_WireExplorer* class can access edges of a wire in their order of connection.
72b7576f 1232
1233For example, in the wire in the image we want to recuperate the edges in the order {e1, e2, e3,e4, e5} :
1234
e5bd0d98 1235@image html /user_guides/modeling_data/images/modeling_data_image014.png "A wire composed of 6 edges."
1236@image latex /user_guides/modeling_data/images/modeling_data_image014.png "A wire composed of 6 edges.
72b7576f 1237
dba69de2 1238*TopExp_Explorer*, however, recuperates the lines in any order.
72b7576f 1239
72b7576f 1240~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
1241 TopoDS_Wire W = ...;
1242 BRepTools_WireExplorer Ex;
1243 for(Ex.Init(W); Ex.More(); Ex.Next()) {
1244 ProcessTheCurrentEdge(Ex.Current());
1245 ProcessTheVertexConnectingTheCurrentEdgeToThePrevious
1246 One(Ex.CurrentVertex());
1247 }
e2b55410 1248~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1249
1250