0024331: CMake scripts improvements
[occt.git] / dox / technical_overview / technical_overview.md
CommitLineData
72b7576f 1Technical Overview {#technical_overview}
2========================================
3
e5bd0d98 4@tableofcontents
5
72b7576f 6@section OCCT_TOVW_SECTION_1 Product Overview
7
e5bd0d98 8Open CASCADE Technology is an object-oriented C++ class library designed for rapid production of sophisticated domain-specific design applications. A typical application developed using OCCT deals with two or three-dimensional (2D or 3D) geometric modeling
72b7576f 9in general-purpose or specialized Computer Aided Design (CAD) systems, manufacturing
10or analysis applications, simulation applications, or illustration tools. OCCT Object
11Libraries help you to develop your applications significantly faster.
12
dba69de2 13@image html /technical_overview/images/technical_overview_over.png
14@image latex /technical_overview/images/technical_overview_over.png
72b7576f 15
16The OCCT Library provides the following services:
17
18
19 * 2D and 3D geometric modeling toolkits which allow you to model any type of object:
20 * Creating primitives such as prism, cylinder, cone and torus
21 * Performing Boolean operations (addition, subtraction and intersection)
22 * Tweaking constructions using fillets, chamfers and drafts
23 * Modeling constructions using offsets, shelling, hollowing and sweeps
24 * Computing properties such as surface, volume, center of gravity, curvature
25 * Computing geometry using projection, interpolation, approximation
26 * Visualization services that allow you to manage object display and manipulate views, for example:
27 * 3D rotation
28 * Zoom
29 * Shading
30 * The application framework features:
31 * Association between non-geometric application data and geometry
32 * Parameterization of models
33 * Java Application Desktop (JAD), a framework for creating your Graphical User Interfaces (GUI)
34 * Data exchange providing import and export functions of OCCT models to and from standard formats such as IGES and STEP
35
36OCCT Library is developed and marketed by OPEN CASCADE Company. The library is designed
37to be truly modular and extensible. As such, they separate C++ classes for:
38
39 * Defining data structures (geometric modeling, display and graphic selection)
40 * Implementing complex algorithms
41 * Providing Application Programming Interfaces (APIs)
42
43
44Related classes are grouped into packages to prevent any class-name conflicts;
45C++ class-names are prefixed by a package name. For example, all classes defining
463D geometric objects belong to the Geompackage.
47In Geom, the class implementing Bezier surfaces is called BezierSurface, and its full name is <i> Geom_BezierSurface</i>.
48
49Packages are then archived into libraries, to which you can link your application.
50
51Finally, libraries are grouped into six modules: Foundation Classes,
52Modeling Data, Modeling Algorithms, Visualization, Data Exchange and Application Framework.
53
54In addition Draw Test Harness (Draw) provides testing tools for the Visualization,
55Modeling Algorithms, Application Framework and Data Exchange modules.
56These tools include a wide range of interpreted commands which allow experimenting with OCCT.
57
58Refer to the Technical Overview and OCCT documentation for details about the services provided in each module.
59
60@section OCCT_TOVW_SECTION_2 Foundation Classes
61
62
63Foundation Classes provide a variety of general-purpose services such as:
64
65 * Primitive types, strings and various types of quantities
66 * Automated management of heap memory
67 * Exception handling
68 * Classes for manipulating data collections
69 * Math tools such as vectors, matrices and primitive geometric types
70 * Basic services for saving data in ASCII files
71
72These services are organized into the following libraries:
73
74 * Kernel Classes
75 * Math Utilities
dba69de2 76 * Basic Persistence
72b7576f 77
78The technical overview provides only a basic description of the libraries. Please, refer for more details to Foundation Classes User's guide
79
80See also: our web site at E-learning and Training.
81
82@subsection OCCT_TOVW_SECTION_2_1 Kernel Classes
83
84
dba69de2 85### Root Classes
86
72b7576f 87
88Root Classes, primarily implemented in the Standard package, are the predefined classes on which
89all other Open CASCADE Technology classes are built. They provide:
90
91 * Primitive types such as Boolean, Character, Integer or Real
92 * Memory manager based on reference counting for optimizing the allocation and deallocation of large numbers of small C++ objects
93 * <i>Standard_Transient</i> class automating memory management through smart pointers
94 * OCCT <i>Handle</i>; most of OCCT classes inherit from this base class.
95 * Management of exceptions,
96 * Encapsulation of C++ streams.
97
dba69de2 98### Quantities
72b7576f 99
100Quantity classes provide the following services:
101
102 * Definition of primitive types representing most of mathematical and physical quantities
103 * Unit conversion tools.
104 * Resources to manage time information such as dates and time periods
105 * Resources to manage color definition
106
107A mathematical quantity is characterized by the name and the value (real).
dba69de2 108A physical quantity is characterized by the name, the value (real) and the unit.
72b7576f 109The unit may be either an international unit complying with the International Unit System (SI)
110or a user defined unit. The unit is managed by the physical quantity user.
111
112The fact that both physical and mathematical quantities are manipulated as real
113values means that :
114
115 * They are defined as aliases of real values, so all functions provided by the <i>Standard_Real</i> class are available on each quantity.
116 * It is possible to mix several physical quantities in a mathematical or physical formula involving real values.
117
118<i>Quantity</i> package includes all commonly used basic physical quantities.
119
dba69de2 120### Exceptions
72b7576f 121
122Exception classes list all the exceptions, which can be raised by any OCCT function.
123
124Each exception inherits from Standard_Failure either directly or by inheriting from
125another exception.
126
127Exceptions describe anomalies which can occur during the execution of a method. With
128the raising of an exception, the normal course of program execution is abandoned.
129The execution of actions in response to this situation is called the treatment of
130the exception.
131
132
133The methods try & catch are redefined in OCCT to work properly on any platform. Nevertheless
134they call native mechanisms each time it is possible. The only reason not to use
135native exceptions is that they may not work properly on some compilers. In this case,
136a specific OCCT code is used instead.
137
138
dba69de2 139### Strings
72b7576f 140
141Strings are classes that handle dynamically sized sequences of characters based on
142ASCII/Unicode UTF-8 (normal 8-bit character type)
143and UTF-16/UCS-2 (16-bit character type). They provide editing operations with built-in
144memory management which make the relative objects easier to use than ordinary character
145arrays.
146
147String classes provide the following services to manipulate character strings:
148 * Editing operations on string objects, using a built-in string manager
149 * Handling of dynamically-sized sequences of characters
150 * Conversion from/to ASCII and UTF-8 strings.
151
152Strings may also be manipulated by handles and therefore, can be shared.
153
154These classes are implemented in <i>TCollection</i> and <i>NCollection</i> packages.
155
156
dba69de2 157### Collections
72b7576f 158
159Apart from strings, the <i> TCollection</i> package contains classes of dynamically sized
160aggregates of data. They include a wide range of collections.
161
162 * Arrays (unidimensional and bidimensional) are generally used for quick access to an item.
163 Note that an array is a fixed-sized aggregate.
164 * Sequences are ordered collections of non-unique objects.
165 A sequence item is longer to access than an array item: only an exploration in sequence
166 is efficient (but sequences are not adapted for numerous explorations).
167 Arrays and sequences are commonly used as data structures for more complex objects.
168 * Maps are dynamic structures where the size is constantly adapted to the number of inserted
169 items and access to an item is the fastest. Maps structures are commonly used in
170 cases of numerous explorations: they are typically internal data structures for complex
171 algorithms. Sets generate the same results as maps but computation time is considerable.
172 * Lists, queues and stacks, which are minor structures similar to sequences but with different
173 algorithms to explore them
174 * Specific iterators for sequences, maps, and stacks.
175
176Most collections follow value semantics: their instances are the actual collections,
177not handles to a collection. Only arrays, sequences and sets may also be manipulated
178by handle, and therefore shared.
179
180
181Collection classes are generic (C++ template-like), so they can contain
182a variety of objects which do not necessarily inherit from
183a unique root class. When you need to use a collection of a given object type, you
184must instantiate the collection for this specific type. Once the code for this declaration
185is compiled, all functions available on the generic collection are available on your
186instantiated class.
187
188Each collection directly used as an argument in Open CASCADE Technology public syntax
189is instantiated in an OCCT component using the corresponding generic class in package
190<i> TCollection</i>, by means of compiling the CDL declaration of the instance.
191Thus OCCT generic classes require compilation of definitions in the CDL language and therefore
192can only be instantiated in WOK.
193
194If you are not using CDL in your project (CDL compilation under WOK is necessary
195to instantiate any generic Collection from package <i>TCollection</i>), then you should
196use the Collections defined in <i> NCollection</i> package. It contains definitions of the
197same generic collection classes described above, but in a form of C++ templates.
198Therefore, to instantiate any collection type no additional support is required beyond
199the ANSI C++ compiler.
200
201@subsection OCCT_TOVW_SECTION_2_2 Math Utilities
202
203
dba69de2 204### Vectors and Matrices
205
72b7576f 206
207The <i> Vector</i> and <i> Matrix </i> classes provide commonly used mathematical algorithms which
208include:
209
210 * Basic calculations involving vectors and matrices;
211 * Computation of eigenvalues and eigenvectors of a square matrix;
212 * Solvers for a set of linear algebraic equations;
213 * Algorithms to find the roots of a set of non-linear equations;
214 * Algorithms to find the minimum function of one or more independent variables.
215
216These classes also provide a data structure to represent any expression,
217relation, or function used in mathematics, including the assignment of variables.
218
219Vectors and matrices have arbitrary ranges which must be defined at declaration time
220and cannot be changed after declaration.
221
222~~~
223 math_Vector v(1, 3);
224 // a vector of dimension 3 with range (1..3)
225
226 math_Matrix m(0, 2, 0, 2);
227 // a matrix of dimension 3x3 with range (0..2, 0..2)
228
229 math_Vector v(N1, N2);
230 // a vector of dimension N2-N1+1 with range (N1..N2)
231~~~
232
233Vector and Matrix objects follow "value semantics", that is, they cannot be shared
234and are copied though assignment.
235
236~~~
237 math_Vector v1(1, 3), v2(0, 2);
238
239 v2 = v1; // v1 is copied into v2
dba69de2 240 // a modification of v1 does not affect v2
72b7576f 241~~~
242
243Vector and Matrix elements can be retrieved using indexes, which must be in the range
244defined upon Vector/Matrix creation. The elements can be initialized with some numerical
245value upon creation as well.
246
247~~~
248 math_Vector v(1, 3);
249 math_Matrix m(1, 3, 1, 3);
250 Standard_Real value;
251
252 v(2) = 1.0;
253 value = v(1);
254 m(1, 3) = 1.0;
255 value = m(2, 2);
256~~~
257
258Some operations on Vector and Matrix objects may not be legal. In this case an exception
259is raised. Two standard exceptions are used:
dba69de2 260 *<i>Standard_DimensionError</i> exception is raised when two matrices or vectors involved
72b7576f 261in an operation are of incompatible dimensions.
dba69de2 262 *<i>Standard_RangeError</i>exception is raised if an attempt to access outside the range
72b7576f 263defined upon creation of a vector or a matrix is made.
264
265~~~
266 math_Vector v1(1, 3), v2(1, 2), v3(0, 2);
267
dba69de2 268 v1 = v2; // error: Standard_DimensionError is raised
269 v1 = v3; // OK: ranges are not equal, but dimensions are compatible
270 v1(0) = 2.0; // error: Standard_RangeError is raised
72b7576f 271~~~
272
273
dba69de2 274### Fundamental Geometry Types
72b7576f 275
276The Fundamental Geometry Types component groups the following packages:
dba69de2 277* geometric processor package <i> gp</i>;
278* <i>GeomAbs</i> package, which provides enumerations generally used in geometry;
72b7576f 279
280<i>gp</i> package is a STEP-compliant implementation of basic geometric and algebraic
281entities, used to define and manipulate elementary data structures.
282
283In particular, <i>gp</i> provides:
284
285 * descriptions of primitive geometric shapes, such as:
dba69de2 286 * Points;
287 * Vectors;
288 * Lines;
289 * Circles and conics;
290 * Planes and elementary surfaces;
291 * positioning of these shapes in space or in a plane by means of an axis or a coordinate system;
292 * definition and application of geometric transformations to these shapes:
293 * Translations;
294 * Rotations;
295 * Symmetries;
296 * Scaling transformations;
297 * Composed transformations;
298 * Tools (coordinates and matrices) for algebraic computation.
72b7576f 299
300These functions are defined in 3D space and in the plane.
301
302<i> gp</i> curves and surfaces are analytic: there is no parameterization and no orientation
303on <i>gp</i> entities, i.e. these entities do not provide functions which work with these properties.
304If you need, you may use more evolved data structures provided by <i> Geom</i>
305(in 3D space) and <i> Geom2d</i> (in the plane). However, the definition of <i> gp</i> entities
306is identical to the one of equivalent <i> Geom</i> and <i> Geom2d</i> entities, and they are located
307in the plane or in space with the same kind of positioning systems.
308They implicitly contain the orientation, which they express
309on the <i> Geom </i> and <i> Geom2d </i> entities, and they induce the definition of their parameterization.
310
311
312Therefore, it is easy to give an implicit parameterization to <i> gp</i> curves and surfaces,
313which is the parametarization of the equivalent <i> Geom</i> or <i> Geom2d</i> entity. This property
314is particularly useful when computing projections or intersections, or for operations
315involving complex algorithms where it is particularly important to manipulate the
316simplest data structures, i.e. those of <i> gp</i>. Thus, the <i> ElCLib</i> and <i> ElSLib</i> packages
317provide functions to compute:
318
dba69de2 319 * the point of parameter u on a 2D or 3D gp curve,
320 * the point of parameter (u,v) on a gp elementary surface, and
321 * any derivative vector at this point.
72b7576f 322
323Note: the <i> gp</i> entities cannot be shared when they are inside more complex data structures.
324
325
dba69de2 326### Common Mathematical Algorithms
72b7576f 327
328Common mathematical algorithms provided in OCCT include:
329
330 * Algorithms to solve a set of linear algebraic equations,
331 * Algorithms to find the minimum of a function of one or more independent variables,
332 * Algorithms to find roots of one or of a set of non-linear equations,
333 * An algorithm to find the eigenvalues and eigenvectors of a square matrix.
334
72b7576f 335@section OCCT_TOVW_SECTION_3 Modeling Data
336
337Modeling Data supplies data structures to represent 2D and 3D geometric models.
338
dba69de2 339@image html /technical_overview/images/technical_overview_md.png
340@image latex /technical_overview/images/technical_overview_md.png
72b7576f 341
342These services are organized into the following libraries:
343
344 * 2D Geometry
345 * 3D Geometry
346 * Geometry Utilities
347 * Topology
348
349The technical overview provides only a basic description of the libraries. Please,
350refer for more details to Modeling Data User's guide
351
3523D geometric models are stored in OCCT native BREP format. It is possible to learn
353more about it in BREP Format Description White Paper
354
355See also: our web site at E-learning and Training.
356
357@subsection OCCT_TOVW_SECTION_3_1 2D Geometry Types
358
359<i> Geom2d</i> package provides an implementation of 2D geometric objects complying with
360STEP, part 42. In particular, it provides functions for:
dba69de2 361* description of points, vectors and curves,
362* their positioning in the plane using coordinate systems,
363* their geometric transformation, by applying translations, rotations, symmetries, scaling transformations and combinations thereof.
72b7576f 364
365The key characteristic of <i> Geom2d </i> curves is that they are parameterized.
366Each class provides functions to work with the parametric equation of the curve,
367and, in particular, to compute the point of parameter u on a curve and the derivative vectors of order 1, 2.., N at this point.
368
369As a consequence of the parameterization, a <i> Geom2d </i> curve is naturally oriented.
370
371Parameterization and orientation differentiate elementary <i>Geom2d </i>curves from their
372equivalent as provided by <i> gp</i> package. <i> Geom2d</i> package provides conversion
373functions to transform a <i> Geom2d</i> object into a <i> gp</i> object, and vice-versa, when this is possible.
374
375Moreover, <i> Geom2d</i> package provides more complex curves, including Bezier curves,
376BSpline curves, trimmed curves and offset curves.
377
378<i> Geom2d </i> objects are organized according to an inheritance structure over several levels.
379Thus, an ellipse (specific class <i> Geom2d_Ellipse</i>) is also a conical curve and inherits
380from the abstract class <i> Geom2d_Conic</i>, while a Bezier curve (concrete class <i> Geom2d_BezierCurve</i>)
381is also a bounded curve and inherits from the abstract class <i> Geom2d_BoundedCurve</i>;
382both these examples are also curves (abstract class <i>Geom2d_Curve</i>). Curves, points
dba69de2 383and vectors inherit from the abstract class <i> Geom2d_Geometry,</i> which describes the properties
72b7576f 384common to any geometric object from the <i>Geom2d</i> package.
385
386This inheritance structure is open and it is possible to describe new objects which
387inherit from those provided in the <i>Geom2d</i> package, provided that they respect the
388behavior of the classes from which they are to inherit.
389
390Finally, <i> Geom2d</i> objects can be shared within more complex data structures.
391This is why they are used within topological data structures, for example.
392
393<i> Geom2d </i>package uses the services of the <i> gp</i> package to:
394
395 * implement elementary algebraic calculus and basic analytic geometry,
396 * describe geometric transformations which can be applied to <i> Geom2d</i> objects,
397 * describe the elementary data structures of <i>Geom2d</i> objects.
398
399However, the <i> Geom2d</i> package essentially provides data structures and not algorithms.
400You can refer to the <i> GCE2d </i> package to find more evolved construction algorithms for <i> Geom2d </i> objects.
401
402@subsection OCCT_TOVW_SECTION_3_2 3D Geometry Types
403
404The <i> Geom</i> package provides an implementation of 3D geometric objects complying with
405STEP, part 42. In particular, it provides functions for:
406
407 * description of points, vectors, curves and surfaces,
408 * their positioning in 3D space using axis or coordinate systems, and
dba69de2 409 * their geometric transformation, by applying translations, rotations, symmetries, scaling transformations and combinations thereof.
72b7576f 410
411The key characteristic of Geom curves and surfaces is that they are parameterized.
412Each class provides functions to work with the parametric equation of the curve or
413surface, and, in particular, to compute:
414
dba69de2 415 * the point of parameter u on a curve, or
416 * the point of parameters (u, v) on a surface.
72b7576f 417
418together with the derivative vectors of order 1, 2, ... N at this point.
419
420As a consequence of this parameterization, a Geom curve or surface is naturally oriented.
421
422Parameterization and orientation differentiate elementary Geom curves and surfaces from the classes of the same (or similar) names found in the <i> gp</i> package.
423The <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.
424
425Moreover, the <i> Geom </i>package provides more complex curves and surfaces, including:
426 * Bezier and BSpline curves and surfaces,
427 * swept surfaces, for example surfaces of revolution and surfaces of linear extrusion,
428 * trimmed curves and surfaces, and
429 * offset curves and surfaces.
430
431Geom objects are organized according to an inheritance structure over several levels.
432Thus, 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.
433
434This 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.
435
436Finally, Geom objects can be shared within more complex data structures. This is why they are used within topological data structures, for example.
437
438The <i> Geom</i> package uses the services of the <i> gp</i> package to:
439 * implement elementary algebraic calculus and basic analytic geometry,
440 * describe geometric transformations which can be applied to Geom objects,
441 * describe the elementary data structures of Geom objects.
442
443However, the Geom package essentially provides data structures and not algorithms.
444You can refer to the <i> GC</i> package to find more evolved construction algorithms for
445Geom objects.
446
447
dba69de2 448### Adaptors for Curves and Surfaces
72b7576f 449
450Some Open CASCADE Technology general algorithms may work theoretically on numerous types of curves or surfaces.
451To do this, they simply get the services required of the analysed curve or surface through an interface so as to a single API, whatever the type of curve or surface. These interfaces are called adaptors.
452For example, <i> Adaptor3d_Curve </i> is the abstract class which provides the required services by an algorithm which uses any 3d curve.
453
454<i> GeomAdaptor </i>package provides interfaces:
455
456 * On a Geom curve;
457 * On a curve lying on a Geom surface;
458 * On a Geom surface;
459
460<i> Geom2dAdaptor</i> package provides interfaces :
461
462 * On a <i>Geom2d</i> curve.
463
464<i> BRepAdaptor </i> package provides interfaces:
465
466 * On a Face
467 * On an Edge
468
469When you write an algorithm which operates on geometric objects, use <i> Adaptor3d</i> (or <i> Adaptor2d</i>) objects.
470As a result, you can use the algorithm with any kind of object,
dba69de2 471if you provide for this object, an interface derived from *Adaptor3d* or *Adaptor2d*.
472These interfaces are easy to use: simply create an adapted curve or surface from a *Geom2d* curve,
72b7576f 473and then use this adapted curve as an argument for the algorithm which requires it.
474
475
476@subsection OCCT_TOVW_SECTION_3_3 Geometry Utilities
477
478This library provides standard high-level functions in 2D and 3D geometry such as:
479
480 * Direct construction of algorithms;
481 * Approximation of curves and surfaces from points;
482 * Conversion of more elementary geometry to BSpline curves and surfaces;
483 * Calculation of points on a 2D or 3D curve;
484 * Calculation of extrema between two geometries.
485
dba69de2 486### Direct Construction
72b7576f 487
488The <i> gp</i>, <i> Geom2d</i> and <i> Geom</i> packages describe elementary data structures of simple geometric
489objects. The constructors of these objects are elementary: the construction arguments
490are fields by which the objects are represented in their data structure.
491
492
493On the other hand, the <i> gce</i>, <i> GCE2d</i> and <i> GC</i> packages provided
494by the Direct Construction component construct the same types of objects
495as <i> gp</i>, <i> Geom2d </i>and <i> Geom</i> respectively.
496However, the former implement geometric construction algorithms that translate the
497constructor's arguments into the data structure specific to each object.
498
499
500Algorithms implemented by these packages are simple: there is no creation of objects
501defined by advanced positional constraints (for more information on this subject,
502see <i> Geom2dGcc</i> and <i> GccAna</i> which describe geometry by constraints).
503
504
505<i> gce</i>, <i> GCE2d</i> and <i> GC </i>each offer a series of classes of construction algorithms.
506
507
dba69de2 508For example, the class <i>gce_MakeCirc</i> provides a framework
72b7576f 509for defining eight problems encountered in the geometric construction of circles,
510and implementing the eight related construction algorithms.
511
512The object created (or implemented) is an algorithm which can be consulted to find out, in particular:
513
dba69de2 514 * its result, which is a <i>gp_Circ</i>, and
515 * its status. Here, the status indicates whether or not the construction was successful.
72b7576f 516
517If it was unsuccessful, the status gives the reason for the failure.
518
519~~~~
520 gp_Pnt P1 (0.,0.,0.);
521 gp_Pnt P2 (0.,10.,0.);
522 gp_Pnt P3 (10.,0.,0.);
523 gce_MakeCirc MC (P1,P2,P3);
524 if (MC.IsDone()) {
dba69de2 525 const gp_Circ& C = MC.Value();
72b7576f 526 }
527~~~~
528
529In addition, <i> gce</i>, <i> GCE2d</i> and <i> GC</i> each have a <i>Root</i> class. This class is the root of
530all the classes in the package which return a status. The returned status (successful
531construction or construction error) is described by the enumeration <i> gce_ErrorType</i>.
532
533Note: classes which construct geometric transformations do not return a status, and
534therefore do not inherit from Root.
535
dba69de2 536### Approximations
72b7576f 537
538Approximation of Curves and Surfaces groups together a variety of functions used in 2D and 3D geometry for:
539
540 * the interpolation of a set of 2D points using a 2D BSpline or Bezier curve;
541 * the approximation of a set of 2D points using a 2D BSpline or Bezier curve;
542 * the interpolation of a set of 3D points using a 3D BSpline or Bezier curve, or a BSpline surface;
543 * the approximation of a set of 3D points using a 3D BSpline or Bezier curve, or a BSpline surface.
544
545You can program approximations in two ways:
546
547 * Using high-level functions, designed to provide a simple method for obtaining approximations with minimal programming,
548 * Using low-level functions, designed for users requiring more control over the approximations.
549
550The low-level functions provide a second API with functions to:
551
552 * Define compulsory tangents for an approximation. These tangents have origins and extremities.
553 * Approximate a set of curves in parallel to respect identical parameterization.
554 * Smooth approximations. This is to produce a faired curve.
555
556The classes <i> AppDef_MultiPointConstraints</i> and <i> AppDef_MultiLines </i> allow organizing the data.
557The classes <i> AppDef_Compute</i>, <i> AppDef_BSplineCompute</i> and <i> AppDef_TheVariational </i>
558classes perform the approximation itself using Bezier curves, BSpline curves, and smooth BSpline curves, respectively.
559
560You can also find functions to compute:
561
562 * The minimal box which includes a set of points
563 * The mean plane, line or point of a set of coplanar, collinear or coincident points.
564
dba69de2 565### Conversion to and from BSplines
72b7576f 566
567The Conversion to and from BSplines component has the following two distinct purposes:
568 * Firstly, it provides a homogenous formulation which can be used to describe any curve or surface.
569 This is useful for writing algorithms for a single data structure model.
570 The BSpline formulation can be used to represent most basic geometric objects provided
571 by the components which describe geometric data structures ("Fundamental Geometry Types", "2D Geometry Types" and "3D Geometry Types" components).
572 * Secondly, it can be used to divide a BSpline curve or surface into a series of curves or surfaces,
573 thereby providing a higher degree of continuity. This is useful for writing algorithms
574 which require a specific degree of continuity in the objects to which they are applied.
575 Discontinuities are situated on the boundaries of objects only.
576
577The "Conversion to and from BSplines" component is composed of three packages.
578
579The <i> Convert </i> package provides algorithms to convert the following into a BSpline curve or surface:
580
581 * a bounded curve based on an elementary 2D curve (line, circle or conic) from the <i> gp </i> package,
582 * a bounded surface based on an elementary surface (cylinder, cone, sphere or torus) from the <i> gp</i> package,
583 * a series of adjacent 2D or 3D Bezier curves defined by their poles.
584
585These algorithms compute the data needed to define the resulting BSpline curve or surface.
586This elementary data (degrees, periodic characteristics, poles and weights, knots and multiplicities)
587may then be used directly in an algorithm, or can be used to construct the curve or the surface
588by calling the appropriate constructor provided by the classes <i>Geom2d_BSplineCurve, Geom_BSplineCurve </i> or <i>Geom_BSplineSurface</i>.
589
590The <i>Geom2dConvert</i> package provides the following:
591
592 * a global function which is used to construct a BSpline curve from a bounded curve based on a 2D curve from the Geom2d package,
593 * 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,
594 * global functions used to construct the BSpline curves created by this splitting algorithm, or by other types of segmentation of the BSpline curve,
595 * an algorithm which converts a 2D BSpline curve into a series of adjacent Bezier curves.
596
597The <i> GeomConvert</i> package also provides the following:
598
599 * a global function used to construct a BSpline curve from a bounded curve based on a curve from the Geom package,
600 * 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,
601 * global functions to construct BSpline curves created by this splitting algorithm, or by other types of BSpline curve segmentation,
602 * an algorithm, which converts a BSpline curve into a series of adjacent Bezier curves,
603 * a global function to construct a BSpline surface from a bounded surface based on a surface from the Geom package,
604 * 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,
605 * global functions to construct BSpline surfaces created by this splitting algorithm, or by other types of BSpline surface segmentation,
606 * an algorithm, which converts a BSpline surface into a series of adjacent Bezier surfaces,
607 * an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
608
dba69de2 609### Points on Curves
72b7576f 610
611The Making Points on Curves component comprises high level functions providing an Application Programming Interface for complex algorithms that compute points on a 2D or 3D curve. The functions use various methods.
612
613The algorithms result in the following:
614
615 * a point on a curve, situated at a given curvilinear distance from another point on the curve
616 * a distribution of points situated at constant curvilinear intervals along a curve
617 * a distribution of points at a constant rise (i.e. respecting a criterion of maximum rise between the curve and the polygon that results from the computed points) along a curve
618 * the length of a curve.
619
620@subsection OCCT_TOVW_SECTION_3_4 Topology
621
622Topological library allows you to build pure topological data structures..
623
624Topology defines relationships between simple geometric entities. In this way,
625you can model complex shapes as assemblies of simpler entities.
626Due to a built-in non-manifold (or mixed-dimensional) feature, you can build models mixing:
627
628 * 0D entities such as points;
629 * 1D entities such as curves;
630 * 2D entities such as surfaces;
631 * 3D entities such as volumes.
632
633You can, for example, represent a single object made of several distinct bodies
634containing embedded curves and surfaces connected or non-connected to an outer boundary.
635
636Abstract topological data structure describes a basic entity - a shape,
637which can be divided into the following component topologies:
638
dba69de2 639 * Vertex - a zero-dimensional shape corresponding to a point in geometry;
640 * Edge - a shape corresponding to a curve, and bound by a vertex at each extremity;
641 * Wire - a sequence of edges connected by their vertices;
642 * Face - part of a plane (in 2D geometry) or a surface (in 3D geometry) bounded by a closed wire;
643 * Shell - a collection of faces connected by some edges of their wire boundaries;
644 * Solid - a part of 3D space bound by a shell;
645 * Compound solid - a collection of solids.
72b7576f 646
647The wire and the solid can be either infinite or closed.
648
649A face with 3D underlying geometry may also refer to a collection of connected triangles
650that approximate the underlying surface. The surfaces can be undefined
651leaving the faces represented by triangles only. If so, the model is purely polyhedral.
652
653Topology defines the relationship between simple geometric entities,
654which can thus be linked together to represent complex shapes.
655
656Abstract Topology is provided by six packages.
657The first three packages describe the topological data structure used in Open CASCADE Technology:
658
659 * <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.
660 * <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.
661 * <i> TopoDS</i> package describes classes to model and build data structures that are purely topological.
662
663Three additional packages provide tools to access and manipulate this abstract topology:
664
665 * <i> TopTools</i> package provides basic tools to use on topological data structures.
666 * <i> TopExp</i> package provides classes to explore and manipulate the topological data structures described in the TopoDS package.
667 * <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.
668
669@subsection OCCT_TOVW_SECTION_3_5 Properties of Shapes
670
dba69de2 671### Local Properties of Shapes
72b7576f 672
673<i>BRepLProp</i> package provides the Local Properties of Shapes component,
674which contains algorithms computing various local properties on edges and faces in a BRep model.
675
676The local properties which may be queried are:
677
678 * for a point of parameter u on a curve which supports an edge :
679 * the point,
680 * the derivative vectors, up to the third degree,
681 * the tangent vector,
682 * the normal,
683 * the curvature, and the center of curvature;
684 * for a point of parameter (u, v) on a surface which supports a face :
685 * the point,
686 * the derivative vectors, up to the second degree,
687 * the tangent vectors to the u and v isoparametric curves,
688 * the normal vector,
689 * the minimum or maximum curvature, and the corresponding directions of curvature;
690 * the degree of continuity of a curve which supports an edge, built by the concatenation of two other edges, at their junction point.
691
692Analyzed edges and faces are described as <i> BRepAdaptor</i> curves and surfaces,
693which provide shapes with an interface for the description of their geometric support.
694The base point for local properties is defined by its u parameter value on a curve, or its (u, v) parameter values on a surface.
695
dba69de2 696### Local Properties of Curves and Surfaces
697
72b7576f 698
699The "Local Properties of Curves and Surfaces" component provides algorithms for computing various local
700properties on a Geom curve (in 2D or 3D space) or a surface. It is composed of:
701
702 * <i> Geom2dLProp</i> package, which provides local properties on 2D curves
703 * <i> GeomLProp </i> package, which provides local properties on 3D curves and surfaces
704 * <i> LProp </i> package, which provides an enumeration used to characterize a particular point on a 2D curve.
705
706Curves are either <i> Geom_Curve </i> curves (in 3D space) or <i> Geom2d_Curve </i> curves (in the plane).
707Surfaces are <i> Geom_Surface </i> surfaces. The point on which local properties are calculated
708is defined by its u parameter value on a curve, and its (u,v) parameter values on a surface.
709
710It is possible to query the same local properties for points as mentioned above, and additionally for 2D curves:
711
712 * the points corresponding to a minimum or a maximum of curvature;
713 * the inflection points.
714
dba69de2 715### Global Properties of Shapes
716
72b7576f 717The Global Properties of Shapes component provides algorithms for computing the global
718properties of a composite geometric system in 3D space, and frameworks to query the computed results.
719
720The global properties computed for a system are :
721
722 * mass,
723 * mass center,
724 * matrix of inertia,
725 * moment about an axis,
726 * radius of gyration about an axis,
727 * principal properties of inertia such as principal axis, principal moments, and principal radius of gyration.
728
729Geometric systems are generally defined as shapes. Depending on the way they are analyzed, these shapes will give properties of:
730
731 * lines induced from the edges of the shape,
732 * surfaces induced from the faces of the shape, or
733 * volumes induced from the solid bounded by the shape.
734
735The 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.
736
dba69de2 737The Global Properties of Shapes component is composed of:
738* 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),
739* a framework for computing global properties for a set of points (<i>GProp_PGProps</i>),
740* and 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.
72b7576f 741
742@subsection OCCT_TOVW_SECTION_3_6 Examples
743
dba69de2 744### How to compute the curve length
72b7576f 745
746To compute curve length, use the method <i>AbscissaPoint::Length</i> from <i> GCPnts</i>.
747
748This function is used only for initializing a framework to compute the length of a curve (or a series of curves).
749
750The adapted curves are:
751
752 * Adaptor_Curve2d for 2D curves
753 * Adaptor_Curve for 3D curves.
754
755The adapted curve is created in the following way:
756
757In 2D:
758
759~~~~~~~~~~~
760 Handle(Geom2d_Curve) mycurve = ... ;
761 Geom2dAdaptor_Curve C (mycurve) ;
762~~~~~~~~~~~
763
764In 3D:
765
766~~~~~~~~~
767 Handle(Geom_Curve) mycurve = ... ;
768 GeomAdaptor_Curve C (mycurve) ;
769~~~~~~~~~
770
771
772The length of the curve is then computed using this curve object:
773
774~~~~~~~~
775 GCPnts_AbscissaPoint myAlgo () ;
776 Standard_Real L = myAlgo.Length( C ) ;
777~~~~~~~~
778
dba69de2 779### How to check the surface concavity
72b7576f 780
781To check the concavity of a surface, proceed as follows:
782
783 1. Sample the surface and compute at each point the Gaussian curvature.
784 2. If the value of the curvature changes of sign, the surface is concave or convex depending on the point of view.
785 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>.
786
dba69de2 787### How to approximate a curve with respect to tangencies
788
72b7576f 789
790To approximate a curve with respect to tangencies, follow these steps:
791
792 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.
793 2. Create an object of type <i> AppDef_MultiLine </i>from the <i> AppDef_MultiPointConstraint</i>.
794 3. Use <i> AppDef_BSplineCompute</i>, which instantiates <i>Approx_BSplineComputeLine</i> to perform the approximation.
795
dba69de2 796### How to extract the underlying geometry from shapes
797
72b7576f 798
799To extract the underlying geometry from a Shape, use the following methods:
800
801 * <i> BRep_Tool::Surface</i> to get the geometric surface from a face.
802 * <i> BRep_Tool::Curve</i> to get the 3d geometric curve from an edge.
803 * <i> BRep_Tool::CurveOnSurface</i> to get the 2d geometric curve of an edge, defined in the parametric space of a face.
804 * <i> BRep_Tool::Pnt </i> to get the 3D point from a vertex.
805
806Some of these methods have a location as argument.
807
808For example, when you use <i> S1 = BRep_Tool::Surface(F,L), </i> you then get the surface stored in <i> TShape</i>.
809
810To use this surface in the same position as the face, you have to apply
811a transformation to it corresponding to the location of the face as follows:
812
813~~~~~~~~~~~~
814 gp_Trsf T(L) ;
815 S2 = S1->Moved(T) ;
816~~~~~~~~~~~~
817
818The same method used without location as argument is <i>S3 = BRep_Tool : : Surface(F)</i>
819returns a Surface in position, according to the location. S3 and S2 are geometrically equivalent surfaces.
820
821Warning: with the first method, you get a pointer on the surface stored in the shape.
822Do not modify the surface because you will modify the shape and may produce an inconsistent model.
823With the second method, you get a copy of the surface on which the location has been applied.
824Note: you can use also a topological object directly just as if it
825were a geometric one by using the services of <i> BRepAdaptor </i>classes.
826
dba69de2 827### How to get the coordinates of a vertex
828
72b7576f 829
830To recover the UV coordinates of vertices,
831use <i> BRep_Tool::Parameters const TopoDS_Vertex& V,const TopoDS_Face& F), </i>
832which returns the U and V parameters of the vertex V on the face F as a <i> gp_Pnt2d</i>.
833
dba69de2 834### How to explore a Wire
835
72b7576f 836
837To explore the edges of a wire in a contiguous order, use <i> BrepTools_WireExplorer</i> class.
838
839~~~~
840 TopoDS_Wire myWire =&ldots;.
841 BRepTools_WireExplorer Ex;
842 for (Ex.Init(myWire); Ex.More(); Ex.Next()) {
843 TopoDS_Edge currentedge = Ex.Current();
844 // Process current edge
845 }
846~~~~
847
dba69de2 848### How to merge bspline curves
849
72b7576f 850
851To merge joined bspline curves use the following methods:
852
853~~~~
854 void GeomConvert::ConcatG1
855 TColGeom_Array1OfBSplineCurve& ArrayOfCurves,
856 const TColStd_Array1OfReal& ArrayOfToler,
857 Handle(TColGeom_HArray1OfBSplineCurve) & ArrayOfConcatenated,
858 const Standard_Boolean ClosedG1Flag,
859 const Standard_Real ClosedTolerance)
860~~~~
861
862This method concatenates according to G1 (tangency continuity along the curve) the
863<i>ArrayOfCurves</i> as far as possible. The following arguments are used:
864
865 * <i> ArrayOfCurves</i> must have dimension bounds [0, N-1], N * number of curves to be merged.
866 * <i> ArrayOfToler</i> contains the biggest tolerance of the two points shared by two consecutive curves. Its dimension is: [0, N-2].
867 * <i> ArrayOfConcatenated</i> contains results of operation: one or more, when impossible to merge all curves from <i> ArrayOfCurves </i> into one, new bspline curves are created.
868 * <i> ClosedG1Flag </i> indicates if the <i> ArrayOfCurves </i> is closed or not.
869 * If <i> ClosedG1Flag = Standard_True, ClosedTolerance </i> contains the biggest tolerance of the two points which are at the closure, otherwise its value is 0.0.
870
871~~~~
872 void GeomConvert::ConcatC1
873 TColGeom_Array1OfBSplineCurve& ArrayOfCurves,
874 const TColStd_Array1OfReal& ArrayOfToler,
875 Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
876 Handle(TColGeom_HArray1OfBSplineCurve)& ArrayOfConcatenated,
877 const Standard_Boolean ClosedG1Flag,
878 const Standard_Real ClosedTolerance,
879 const Standard_Real AngularTolerance)
880~~~~
881
882This method concatenates according to C1 (first derivative continuity along the curve) the <i>
883ArrayOfCurves</i> as far possible. The following arguments are used (additionally to the mentioned above):
884
885* <i> ArrayOfIndices</i> contains indices that define curves from <i> ArrayOfCurves</i> which are beginning curves for each group of curves merged into a new curve.
886* <i> AngularTolerance</i> is used to check the continuity of tangencies.
887
888~~~~
889 void GeomConvert::ConcatC1
890 TColGeom_Array1OfBSplineCurve& ArrayOfCurves,
891 const TColStd_Array1OfReal& ArrayOfToler,
892 Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
893 Handle(TColGeom_HArray1OfBSplineCurve)& ArrayOfConcatenated,
894 const Standard_Boolean ClosedG1Flag,
895 const Standard_Real ClosedTolerance)
896~~~~
897This method is the same as the previous one, except for that <i> AngularTolerance = Precision::Angular() </i>
898
899It is also possible to use class <i> GeomConvert_CompCurveToBSplineCurve</i>.
900This class provides methods to concatenate several restricted curves to a bspline curve.
901Non-bspline curves are converted to bspline before concatenation.
902
903Constructor:
904~~~~~~~~~~
905 GeomConvert_CompCurveToBSplineCurve::
906 GeomConvert_CompCurveToBSplineCurve(const Handle(Geom_BoundedCurve)& BasisCurve, const Convert_ParameterisationType Parameterization)
907 BasisCurve * beginning curve;
908~~~~~~~~~~
909
910Parameterization defines the ways of conversion in bspline (by default <i> Convert_TgtThetaOver2</i>).
911
912The method to add a new curve is:
913~~~~
914 Standard_Boolean GeomConvert_CompCurveToBSplineCurve::
915 Add(const Handle(Geom_BoundedCurve)& NewCurve,
916 const Standard_Real Tolerance,
917 const Standard_Boolean After,
918 const Standard_Boolean WithRatio,
919 const Standard_Integer MinM)
920~~~~
921
922It returns False if the curve is not C0 with the <i> BSplineCurve</i>.
923
924Tolerance is used to check the continuity and decrease the Multiplicity
925at the common Knot until <i> MinM </i>. If <i> MinM = 0 </i>, the common Knot can be removed.
926
927The parameter after defines the place for a new curve when it is possible to put
928the new curve before or after the <i> BasisCurve</i> (in fact, it is case when concatenated curve can be closed).
929It does not change the shape of the curve, but defines its first and last points.
930
931If <i> WithRatio = Standard_True </i> the algorithm tries to reach C1 continuity.
932
933The method to get a result is <i> Handle(Geom_BSplineCurve) GeomConvert_CompCurveToBSplineCurve::BSplineCurve() const </i>
934
935@section OCCT_TOVW_SECTION_4 Modeling Algorithms
936
937Modeling Algorithms module groups a wide range of
938topological algorithms used in modeling and geometric algorithms, called by them.
939
940These services are organized into the following libraries:
941
942 * Geometric Tools
943 * Topological Tools
944 * Construction of Primitives
945 * Boolean Operations
946 * Fillets and Chamfers
947 * Offsets and Drafts
948 * Features
949 * Hidden Line Removal
950 * Shape Healing
951
dba69de2 952@image html /technical_overview/images/technical_overview_ma.png
953@image latex /technical_overview/images/technical_overview_ma.png
72b7576f 954
955The technical overview provides only a basic description of the libraries.
956Please, refer for more details to Modeling Algorithms User's guide
957
958See also: our web site at E-learning and Training.
959
960@subsection OCCT_TOVW_SECTION_4_1 Geometric Tools
961
962This library provides algorithms to:
963
964 * Calculate the intersection of two 2D curves, surfaces, or a 3D curve and a surface;
965 * Project points onto 2D and 3D curves, points onto surfaces, and 3D curves onto surfaces;
966 * Construct lines and circles from constraints;
967 * Construct curves and surfaces from constraints;
968 * Construct curves and surfaces by interpolation
969
970OPEN CASCADE company also provides a product known as Surfaces from Scattered Points
971(SSP), which allows constructing surfaces from scattered points. This algorithm accepts
972or constructs an initial B-Spline surface and looks for its deformation (finite elements
973method) which would satisfy the constraints. Using optimized computation methods,
974this algorithm is able to construct a surface from more than 500 000 points.
975
976SSP product is not supplied with Open CASCADE Technology, but can be purchased separately.
977
978@subsubsection OCCT_TOVW_SECTION_4_1_1 Intersections
979
980The Intersections component is used to compute intersections between 2D or 3D geometrical
981objects:
982
983 * the intersections between two 2D curves
984 * the self-intersections of a 2D curve
985 * the intersection between a 3D curve and a surface
986 * the intersection between two surfaces.
987
988@subsubsection OCCT_TOVW_SECTION_4_1_2 Projections
989
990The Projections component provides functionality for 2D and 3D geometry objects for computing the following:
991
992 * the projections of a 2D point onto a 2D curve
993 * the projections of a 3D point onto a 3D curve or surface
994 * the projection of a 3D curve onto a surface.
995 * the planar curve transposition from the 3D to the 2D parametric space of an underlying plane and v. s.
dba69de2 996 * the positioning of a 2D gp object in the 3D geometric space.
72b7576f 997
998@subsubsection OCCT_TOVW_SECTION_4_1_3 Lines and Circles from Constraints
999
1000The Lines and Circles from Constraints component provides numerous
1001construction algorithms for 2D circles or lines described with numeric or
1002geometric constraints in relation to other curves. These constraints enable the following to be imposed:
1003
dba69de2 1004 * the radius of a circle,
1005 * the angle that a straight line makes with another straight line,
1006 * the tangency of a straight line or circle in relation to a curve,
72b7576f 1007 * the passage of a straight line or circle through a point,
dba69de2 1008 * the circle with center in a point or curve.
72b7576f 1009
1010For example, these algorithms enable to easily construct a circle of a given radius,
1011centered on a straight line and tangential to another circle.
1012
1013The implemented algorithms are more complex than those provided
1014by the Direct Constructions component for building 2D circles or lines.
1015
1016The expression of a tangency problem generally leads to several results, according
1017to the relative positions of the solution and the circles or straight lines in relation
1018to which the tangency constraints are expressed. For example, consider the following
1019case of a circle of a given radius (a small one) which is tangential to two secant
1020circles C1 and C2:
1021
dba69de2 1022@image html /technical_overview/images/technical_overview_occ_0005.png "Example of a Tangency Constraint"
1023@image latex /technical_overview/images/technical_overview_occ_0005.png "Example of a Tangency Constraint"
72b7576f 1024
1025This diagram clearly shows that there are 8 possible solutions.
1026
1027In order to limit the number of solutions, we can try to express the relative position
1028of the required solution in relation to the circles to which it is tangential. For
1029example, if we specify that the solution is inside the circle C1 and outside the
1030circle C2, only two solutions referenced 3 and 4 on the diagram respond to the problem
1031posed.
1032
1033This technique of qualification of a solution, in relation to the curves to which
1034it is tangential, can be used in all algorithms for constructing a circle or a straight
1035line by geometric constraints. Four qualifiers are used, which specify the following:
1036
dba69de2 1037 * the solution(s) must enclose the argument, or
1038 * the solution(s) must be enclosed by the argument, or
1039 * the solution(s) and the argument must be external to one another, or
1040 * the relative position is not qualified, i.e. all solutions apply.
72b7576f 1041
1042These definitions are very easy to interpret on a circle, where it is easy to identify
1043the interior and exterior sides. In fact, for any kind of curve the interior is defined
1044as the left-hand side of the curve in relation to its orientation.
1045
1046OCCT implements several categories of algorithms:
1047
dba69de2 1048 * analytic algorithms, where solutions are obtained by the resolution of an equation, such algorithms are used when the geometries which are worked on (tangency arguments, position of the center, etc.) are points, lines or circles;
1049 * geometric algorithms, where the solution is generally obtained by calculating the intersection of parallel or bisecting curves built from geometric arguments;
1050 * iterative algorithms, where the solution is obtained by a process of iteration.
72b7576f 1051
1052For each kind of geometric construction of a constrained line or circle, OCCT provides
1053two types of access to the user:
1054
dba69de2 1055 * algorithms from the package <i> Geom2dGcc </i> automatically select the algorithm best suited to the problem to be treated, both in the general case and in all types of specific cases; the arguments used are Geom2d objects; the solutions computed are <i> gp </i> objects;
1056 * algorithms from the package <i> GccAna</i> resolve the problem analytically, and can only be used when the geometries to be worked on are lines or circles; the arguments used and solutions computed are <i> gp </i> objects.
72b7576f 1057
1058The provided algorithms compute all solutions, which correspond to the stated geometric
1059problem, unless the solution is found by an iterative algorithm.
1060
1061Iterative algorithms compute only one solution, closest to an initial
1062position. They can be used in the following cases:
1063
dba69de2 1064 * to build a circle, when an argument is more complex than a line or a circle, and where
72b7576f 1065 the radius is not known or difficult to determine: this is the case for a circle tangential
1066 to three geometric elements, or tangential to two geometric elements and centered on a curve;
dba69de2 1067 * to build a line, when a tangency argument is more complex than a line or a circle.
72b7576f 1068
1069Qualified curves (for tangency arguments) are provided either by:
1070
1071 * the <i> GccEnt</i> package, for direct use by <i> GccAna</i> algorithms, or
dba69de2 1072 * the <i> Geom2dGcc </i> package, for general use by <i> Geom2dGcc </i> algorithms.
72b7576f 1073
1074The <i> GccEnt</i> and <i> Geom2dGcc</i> packages also provide simple functions for building qualified curves in a very efficient way.
1075
1076The <i> GccAna </i>package also provides algorithms for constructing bisecting loci between
1077circles, lines or points. Bisecting loci between two geometric objects are such that
1078each of their points is at the same distance from the two geometric objects. They
1079are typically curves, such as circles, lines or conics for <i> GccAna</i> algorithms.
1080Each elementary solution is given as an elementary bisecting locus object (line, circle,
1081ellipse, hyperbola, parabola), described by the <i>GccInt</i> package.
1082
1083Note: Curves used by <i> GccAna </i> algorithms to define the geometric problem to be solved,
1084are 2D lines or circles from the <i> gp</i> package: they are not explicitly parameterized.
1085However, these lines or circles retain an implicit parameterization, corresponding
1086to that which they induce on equivalent Geom2d objects. This induced parameterization
1087is the one used when returning parameter values on such curves, for instance with
1088the functions <i> Tangency1, Tangency2, Tangency3, Intersection2</i> and <i> CenterOn3</i> provided
1089by construction algorithms from the <i> GccAna </i> or <i> Geom2dGcc</i> packages.
1090
1091@subsubsection OCCT_TOVW_SECTION_4_1_4 Curves and Surfaces from Constraints
1092
1093The Curves and Surfaces from Constraints component groups together high level functions
1094used in 2D and 3D geometry for:
1095
dba69de2 1096 * creation of faired and minimal variation 2D curves
72b7576f 1097 * construction of ruled surfaces
dba69de2 1098 * construction of pipe surfaces
1099 * filling of surfaces
72b7576f 1100 * construction of plate surfaces
dba69de2 1101 * extension of a 3D curve or surface beyond its original bounds.
1102
1103#### 2D Curves from constraints
72b7576f 1104
72b7576f 1105
1106Elastic beam curves have their origin in traditional methods of modeling applied
1107in boat-building, where a long thin piece of wood, a lathe, was forced to pass
1108between two sets of nails and in this way, take the form of a curve based on the
1109two points, the directions of the forces applied at those points, and the properties
1110of the wooden lathe itself.
1111
1112Maintaining these constraints requires both longitudinal and transversal forces to
1113be applied to the beam in order to compensate for its internal elasticity. The longitudinal
1114forces can be a push or a pull and the beam may or may not be allowed to slide over
1115these fixed points.
1116
1117The class <i> Batten</i> produces curves defined on the basis of one or more constraints
1118on each of the two reference points. These include point and angle of tangency settings.
1119The class <i> MinimalVariation</i> produces curves with minimal variation in curvature.
1120The exact degree of variation is provided by curvature settings.
1121
dba69de2 1122#### Ruled Surfaces
1123
72b7576f 1124A ruled surface is built by ruling a line along the length of two curves.
1125
dba69de2 1126#### Pipe Surfaces
1127
72b7576f 1128
1129A pipe is built by sweeping a curve (the section) along another curve (the path).
1130
1131The following types of construction are available:
1132 * pipes with a circular section of constant radius,
1133 * pipes with a constant section,
1134 * pipes with a section evolving between two given curves.
1135
1136
dba69de2 1137#### Surface filling
72b7576f 1138
1139It is often convenient to create a surface from two or more curves which will form
1140the boundaries that define the new surface.
1141
1142A case in point is the intersection of two fillets at a corner. If the radius of
1143the fillet on one edge is different from that of the fillet on another, it becomes
1144impossible to sew together all the edges of the resulting surfaces. This leaves a
1145gap in the overall surface of the object which you are constructing.
1146
dba69de2 1147@image html /technical_overview/images/technical_overview_occ_0006.png "Intersecting filleted edges with differing radiuses"
1148@image latex /technical_overview/images/technical_overview_occ_0006.png "Intersecting filleted edges with differing radiuses"
72b7576f 1149
1150These algorithms allow you to fill this gap from two, three or four curves. This
1151can be done with or without constraints, and the resulting surface will be either
1152a Bezier or a BSpline surface in one of a range of filling styles.
1153
1154
1155This package was designed with a view to handling gaps produced during fillet construction.
1156Satisfactory results cannot be guaranteed for other uses.
1157
dba69de2 1158#### Plate surfaces
1159
72b7576f 1160
1161In CAD, it is often necessary to generate a surface which has no exact mathematical
1162definition, but which is defined by respective constraints. These can be of a mathematical,
1163a technical or an aesthetic order.
1164
1165
1166Essentially, a plate surface is constructed by deforming a surface so that it conforms
1167to a given number of curve or point constraints. In the figure below, you can see
1168four segments of the outline of the plane, and a point which have been used as the
1169curve constraints and the point constraint respectively. The resulting surface can
1170be converted into a BSpline surface by using the function <i> MakeApprox </i>.
1171
1172
1173The surface is built using a variational spline algorithm. It uses the principle
1174of deformation of a thin plate by localised mechanical forces. If not already given
1175in the input, an initial surface is calculated. This corresponds to the plate prior
1176to deformation. Then, the algorithm is called to calculate the final surface. It
1177looks for a solution satisfying constraints and minimizing energy input.
1178
dba69de2 1179@image html /technical_overview/images/technical_overview_occ_0007.png "Surface generated from four curves and a point"
1180@image latex /technical_overview/images/technical_overview_occ_0007.png "Surface generated from four curves and a point"
72b7576f 1181
dba69de2 1182@image html /technical_overview/images/technical_overview_occ_0008.png "Surface generated from two curves and a point"
1183@image latex /technical_overview/images/technical_overview_occ_0008.png "Surface generated from two curves and a point"
72b7576f 1184
dba69de2 1185#### Extension of a 3D curve or surface beyond its original bounds
72b7576f 1186
1187The extension is performed according to a geometric requirement and a continuity
1188constraint. It should be a small extension with respect to the size of the original
1189curve or surface.
1190
dba69de2 1191@subsubsection OCCT_TOVW_SECTION_4_1_5 Interpolation
72b7576f 1192
1193The Interpolation Laws component provides definitions of functions: <i> y=f(x) </i>.
1194
1195In particular, it provides definitions of:
1196
1197 * a linear function,
1198 * an <i> S </i> function, and
1199 * an interpolation function for a range of values.
1200
1201Such functions can be used to define, for example, the evolution law of a fillet along the edge of a shape.
1202
72b7576f 1203The validity of the function built is never checked: the Law package does not know for what
1204application or to what end the function will be used. In particular, if the function is used
1205as the evolution law of a fillet, it is important that the function is always positive. The user must check this.
1206
1207@subsection OCCT_TOVW_SECTION_4_2 Topological Tools
1208
1209This library provides algorithms to:
1210
1211 * Tessellate shapes
1212 * Validate shapes
1213 * Determine the local properties of shapes
1214 * Determine the global properties of shapes
1215 * Perform geometric transformations
1216 * Find planes in which edges are located
1217 * Convert shapes to NURBS geometry.
1218
1219It also furnishes a complete brep data structure for topological data structures defined
1220in the Topology library of the Modeling Data module.
1221This linAllows you to create standard topological objects such as:
1222
1223 * Vertices
1224 * Edges
1225 * Faces
1226 * Wires
1227 * Polygonal wires
1228 * Shells
1229 * Solids.
1230
1231The API provides classes to build objects:
1232
1233 * The constructors of classes provide different construction methods;
1234 * The class retains different tools used to build objects as fields;
1235 * The class provides a casting method to obtain the result automatically with a function-like call.
1236
1237For example, to build a vertex V on a point P, you can use:
1238
1239~~~
1240 V = BRepBuilderAPI_MakeVertex(P);
1241~~~
1242or
1243
1244~~~
1245 BRepBuilderAPI_MakeVertex MV(P);
1246 V = MV.Vertex();
1247~~~
1248
1249For error handling, the <i> BRepBuilderAPI</i> commands raise only the
1250<i> 0StdFail_NotDone</i> exception. When <i> IsDone</i> is false for a command,
1251the error description can be requested from the command.
1252
1253@subsection OCCT_TOVW_SECTION_4_3 Construction of Primitives
1254
1255This library contained in <i> BRepPrimAPI</i> package provides an API (Application Programming Interface) for:
1256
1257 * Construction of primitives such as:
1258 * Boxes;
1259 * Cones;
1260 * Cylinders;
1261 * Prisms.
1262 * Construction by sweeping along a profile:
1263 * Linear;
1264 * Rotational (through an angle of rotation).
1265
1266Sweeps are objects obtained by sweeping a profile along a path.
1267The profile can be any topology and the path is usually a curve or a wire.
1268The profile generates objects according to the following rules:
1269
1270 * Vertices generate Edges
1271 * Edges generate Faces.
1272 * Wires generate Shells.
1273 * Faces generate Solids.
1274 * Shells generate Composite Solids.
1275
1276It is not allowed to sweep Solids and Composite Solids.
1277
1278Swept constructions along complex profiles such as
1279BSpline curves are also available in the <i> BRepOffsetAPI </i> package.
1280
1281This API provides simple, high level calls for the most common operations.
1282
1283@subsection OCCT_TOVW_SECTION_4_4 Boolean Operations
1284
1285Boolean operations to create new shapes from old ones by using:
1286
1287 * Common
1288 * Cut
1289 * Fuse
1290 * Section
1291
1292There are two libraries for Boolean Operations:
1293
1294 * Old Boolean Operations (BOA) provided by <i>BRepAlgo</i> package designed and developed in Open CASCADE 6x in 2000; its architecture and content are out of date.
1295 * New Boolean Operations (NBOA) provided by <i>BRepAlgoAPI</i> package designed and developed in 2009 and completely revised in 2013.
1296
dba69de2 1297New Boolean Operations provide the following major benefits:
72b7576f 1298
dba69de2 1299 * The NBOA have an expandable architecture of inner sub-algorithms, which allows to create specific algorithms for the Customers using existing inner sub-algorithms as root algorithms and to reduce the time for the development.
72b7576f 1300 * The architecture of inner sub-algorithms of NBOA provides their reusability with maximal independence from the environment of NBOA. The fact allows to create specific algorithms for the Customers using these sub-algorithms as they are or as root classes and thus to reduce the time for the development.
1301 * The architecture of NBOA is history-based. The implementation of NBOA internally sets up a correspondence between any sub-shape of the argument and its image in the result. The history is not imposed and thus it is not error-prone as it was in BOA. The fact allows direct and safely usage of the algorithm in parametric modeling.
dba69de2 1302 * NBOA provide a general algorithm. It correctly processes without using the workarounds even the cases that cannot be properly processed by BOA.
72b7576f 1303 * The implementation of NBOA is based on NCollection classes. The usage of opportunities given by local memory allocators ( <i> NCollection_IncAllocator</i>) allows improving memory management and saving memory resources.
dba69de2 1304 * NBOA use modern algorithms of OCC as auxiliary tools. For e.g. the algorithm of unbalanced binary tree of overlapped bounding boxes <i> NCollection_UBTree</i>. The usage of the algorithm allows to improve the performance of NBOA if there is a big number of sub-shapes in the arguments.
72b7576f 1305
dba69de2 1306Boolean Operations have the following types of the arguments and produce the following results:
1307* For arguments having the same shape type (e.g. SOLID / SOLID) the type of the resulting shape will be a COMPOUND, containing shapes of this type;
1308* For arguments having different shape types (e.g. SHELL / SOLID) the type of the resulting shape will be a COMPOUND, containing shapes of the type that is the same as that of the low type of the argument. Example: For SHELL/SOLID the result is a COMPOUND of SHELLs.
1309* For arguments with different shape types some of Boolean Operations can not be done using the default implementation, because of a non-manifold type of the result. Example: the FUSE operation for SHELL and SOLID can not be done, but the CUT operation can be done, where SHELL is the object and SOLID is the tool.
1310* It is possible to perform Boolean Operations on arguments of the COMPOUND shape type. In this case each compound must not be heterogeneous, i.e. it must contain equidimensional shapes (EDGEs or/and WIREs, FACEs or/and SHELLs, SOLIDs). SOLIDs inside the COMPOUND must not contact (intersect or touch) each other. The same condition should be respected for SHELLs or FACEs, WIREs or EDGEs.
1311* Boolean Operations for COMPSOLID type of shape are not supported.
72b7576f 1312
1313@subsection OCCT_TOVW_SECTION_4_5 Features
1314
1315This library contained in BRepFeat package is necessary for the creation
1316and manipulation of both form and mechanical features in a Boundary Representation framework.
1317
1318The form features are depressions or protrusions including the following types:
1319
1320 * Cylinder;
1321 * Draft Prism;
1322 * Prism;
1323 * Revolved feature;
1324 * Pipe.
1325
1326Depending on whether you wish to make a depression or a protrusion,
1327you can choose either to remove matter (Boolean cut: Fuse equal to 0) or to add it (Boolean fusion: Fuse equal to 1).
1328
1329The semantics of form feature creation is based on the construction of shapes:
1330
1331 * for a certain length in a certain direction;
1332 * up to the limiting face;
1333 * from the limiting face at a height;
1334 * above and/or below a plane.
1335
1336The shape defining the construction of a feature can be
1337either a supporting edge or a concerned area of a face.
1338
1339In case of supporting edge, this contour can be attached to a face
1340of the basis shape by binding. When the contour is bound to this face,
1341the information that the contour will slide on the face becomes available
1342to the relevant class methods. In case of the concerned area of a face, you could,
1343for example, cut it out and move it at a different height,
1344which will define the limiting face of a protrusion or depression.
1345
1346Topological definition with local operations of this sort makes calculations simpler
1347and faster than a global operation. The latter would entail a second phase
1348of removing unwanted matter to get the same result.
1349
1350Mechanical features include ribs, protrusions and grooves (or slots),
1351depressions along planar (linear) surfaces or revolution surfaces.
1352
1353The semantics of mechanical features is based on giving thickness to a contour.
1354This thickness can either be
1355
1356 * unilateral
1357 * on one side of the contour
1358 * or bilateral
1359 * on both sides.
1360
1361As in the semantics of form features, the thickness is defined
1362by construction of shapes in specific contexts.
1363
1364However, in case of mechanical features, development contexts differ.
1365Here they include extrusion:
1366
1367 * to a limiting face of the basis shape;
1368 * to or from a limiting plane;
1369 * to a height.
1370
1371@subsection OCCT_TOVW_SECTION_4_6 Hidden Line Removal
1372
1373This library provides two algorithms: <i> HLRBRep_Algo</i> and <i> HLRBRep_PolyAlgo</i> to define the lines of a shape hidden in a given projection. These lines can be shown or hidden to have the precision required in industrial design. To do this, the Hidden Line Removal component provides
1374
1375These algorithms remove or indicate lines hidden by surfaces.
1376For a given projection, they calculate a set of lines characteristic of the object being represented. They are also used in conjunction with extraction utilities, which reconstruct a new, simplified shape from a selection of calculation results.
1377This new shape is made up of edges, which represent the lines of the visualized shape in a plane. This plane is the projection plane.
1378
1379The algorithm <i> HLRBRep_Algo</i> allows working with the shape itself, while <i> HLRBRep_PolyAlgo </i>works with its polyhedral simplification. When you use <i> HLRBRep_Algo</i>, you obtain an exact result, whereas, when you use <i> HLRBRep_PolyAlgo</i>, you reduce computation time but obtain polygonal segments.
1380
1381@subsection OCCT_TOVW_SECTION_4_7 Shape Healing
1382
1383Shape Healing library provides algorithms to modify the geometry and topology of OCCT shapes.
1384Shape Healing adapts shapes to make them maximally appropriate for use by OCCT, for example:
1385
1386 * analyze shape characteristics and, in particular, identify the shapes that do not comply with OCCT validity rules;
1387 * fix incorrect or problem shapes;
1388 * upgrade and change shape characteristics if needed, for example a C0 supporting surface can become C1 continuous.
1389
1390It has several sub-domains, each with its own scope of functionality:
1391
1392 * analysis - exploring shape properties, computing shape features, detecting violation of OCCT requirements (the shape itself is not modified);
1393 * fixing - fixing shape to meet the OCCT requirements (the shape may change its original form: modifying, removing, constructing sub-shapes, etc.);
1394 * upgrade - shape improvement for better usability in OCCT or other algorithms (the shape is replaced with a new one, but geometrically they are the same);
1395 * customization - modifying shape representation to fit specific needs (the shape is not modified, only the form of its representation is modified);
1396 * processing - mechanism of shape modification via a user-editable resource file.
1397
1398The technical overview provides only a basic description of the libraries. Please, refer for more details to Shape Healing User's guide
1399
1400See also: our web site at E-learning and Training.
1401
1402
1403@subsection OCCT_TOVW_SECTION_4_8 Miscellaneous modelling algorithms.
1404
dba69de2 1405### Fillets and Chamfers
72b7576f 1406
1407This library provides algorithms to make fillets and chamfers on shape edges.
1408The following cases are addressed:
1409
1410 * Corners and apexes with different radii;
1411 * Corners and apexes with different concavity.
1412
1413If there is a concavity, both surfaces that need to be extended and those, which do not, are processed.
1414
dba69de2 1415### Offsets, Drafts, Sewing and Sweeps
72b7576f 1416
1417These classes provide the following services:
1418
1419 * Creation of offset shapes and their variants such as:
1420 * Hollowing;
1421 * Shelling;
1422 * Lofting;
1423 * Creation of tapered shapes using draft angles
1424 * Sewing
1425 * Creation of sweeps
1426
1427
1428@subsection OCCT_TOVW_SECTION_4_9 Examples
1429
dba69de2 1430### How to compute the state of a point on a face:
1431
72b7576f 1432
1433Use <i> BRepTools::Pnt </i> to get the point from your vertex.
1434Your shape must be of the <i> TopoDS_Shape </i>type.
1435If it is, you can use <i> BRepTopAdaptor_FClass2d </i>class. For example:
1436
1437~~~~~
1438 BRepTopAdaptor_FClass2d::Load (to load the solid )
1439 BRepTopAdaptor_FClass2d::Perform (to compute the state of the point )
1440 BRepTopAdaptor_FClass2d::State (to get the TopAbs_State).
1441~~~~~
1442
1443
dba69de2 1444### How to compute the state of a point in a solid:
1445
72b7576f 1446
1447Use <i>BRepTools::Pnt </i> to get the point from your vertex.
1448Your shape must be of the <i> TopoDS_Solid</i> type.
1449
1450If it is, you can use the <i> BRepClass3d_SolidClassifier </i> class, for example:
1451
1452~~~~~
1453 BRepClass3d_SolidClassifier::Load (to load the solid)
1454 BRepClass3d_SolidClassifier::Perform (to compute the state of the point)
1455 BRepClass3d_SolidClassifier::State (to get a TopAbs_State object)
1456 BRepClass3d_SolidClassifier inherits BRepclass3d_SClassifier
1457~~~~~
1458
dba69de2 1459### How to connect a set of contiguous but independent faces
1460
72b7576f 1461
1462A unique topological object can be obtained in this way using the class
1463<i> Sewing</i> from the <i> BRepOffsetAPI </i>package which produces a shell as a result.
1464
1465~~~~~
1466 BRepOffsetAPI_Sewing Sew;
1467 Sew.Add(Face1);
1468 Sew.Add(Face2);
1469 ...
1470 Sew.Add(Facen);
1471 Sew.Perform();
1472 TopoDS_Shape result= Sew.SewedShape();
1473~~~~~
1474
1475@note The sewing algorithm uses a tolerance to assemble the faces by sewing them along common edges. You must therefore check the gap between faces before sewing or adjust the value of the tolerance according to the real gap of the geometry.
1476
1477If all faces have been sewed correctly, the result is a shell. Otherwise, it is a compound. After a successful sewing operation all faces have a coherent orientation.
1478
1479For more information, refer to the entry for this class in reference documentation.
1480
dba69de2 1481### How to check the orientation of a solid
72b7576f 1482
1483If you want to create a solid from a closed shell, you must first check the orientation to determine if you have to reverse the shell or not (for example after creating a closed shell from a sewing operation). To do this, use the <i> PerformInfinitePoint</i> method from the <i> BrepClass3D_SolidClassifier</i> class.
1484
1485~~~~~
1486 BRepClass3d_SolidClassifier clas3d(aShell);
1487 clas3d.PerformInfinitePoint(Precision::Confusion());
1488 if (clas3d.State() == TopAbs_IN)
1489 newShell.Reverse();
1490 BRepBuilderAPI_MakeSolid aSolid(aShell);
1491~~~~~
1492
1493@section OCCT_TOVW_SECTION_5 Visualization
1494
1495Visualization in Open CASCADE Technology is based on the separation of modeling data you want to display and select, and on the graphical presentation of its structure.
1496
1497For visualizing data structures, OCCT provides ready-to-use algorithms, which create graphic presentations from geometric models. These data structures may be used with the viewers supplied, and can be customized to take the specificity of your application into account.
1498
1499Displaying is managed through presentation services, and selection in its turn is managed through selection services. With these services, data structures and algorithms are provided to display objects of an application, and to support graphical selection of these objects.
1500
1501Application Interactive Services (AIS) are provided to manage displaying, detection and selection of graphical presentations. These services associate data structures and interactive objects.
1502
1503Please, refer for more details to Visualization User's guide
1504
1505See also: our web site at E-learning and Training.
1506
dba69de2 1507@image html /technical_overview/images/technical_overview_viz.png
1508@image latex /technical_overview/images/technical_overview_viz.png
72b7576f 1509
1510@subsection OCCT_TOVW_SECTION_5_1 3D Graphics
1511
dba69de2 15123D Graphics provided by <i>Graphic3d</i> package supports three-dimensional manipulation of 3d graphic objects called structures. Structures, are made up of groups that unite primitives, such as polylines, planar polygons with or without holes, text and markers, and attributes, such as color, transparency, reflection, line type, line width, and text font.
72b7576f 1513A group is the smallest editable element of a structure.
1514
1515A structure can be displayed, erased, highlighted and transformed.
1516Structures can be connected to form a hierarchy of structures, composed by transformations.
1517The viewer can perform global manipulation of structures.
1518
1519<i> Visual3d </i> package contains the group of classes required to implement commands for 3D viewer. The viewer manages views and light sources.
1520
1521Most types of primitives supported by <i> Graphic3d</i> can be dumped to a vector file format such as PDF and PostScript. Export to vector formats is implemented with help of <i> GL2PS</i> library.
1522
dba69de2 1523@subsection OCCT_TOVW_SECTION_5_2 3D Visualization
72b7576f 1524
1525This library provides services for:
1526
1527 * Selection of 3D data structures
1528 * Presentation of 3D data structures
1529
1530Access to 3D presentation and selection is provided through AIS (Application Interactive Services).
1531This package is a high-level interface that offers access to the lower-level presentation and selection services.
1532AIS expand this underlying functionality with standard 3D selection attributes, presentation management, and standard 3D presentation attributes, and manages it in the definition of GUI viewers. To implement these services, AIS package includes the following:
1533
1534 * Interactive context
1535 * Interactive objects
1536 * A graphic attributes manager
1537 * Selection filters
1538
dba69de2 1539### Interactive Context
72b7576f 1540
1541Interactive context pilots 3D visualizations and selections.
1542The interactive context allows you to manage, in a transparent way, graphic and "selectable" behavior of interactive objects which is not yet defined in the predefined types of these objects.
1543
1544AIS have two operating context types. The default neutral point type allows easily visualizing and selecting entire interactive objects, which have been loaded into the context.
1545Opening a local context allows preparing and using a temporary selection environment to select a part of an interactive object.
1546
dba69de2 1547### Interactive Objects
72b7576f 1548
1549Entities which are visualized and selected in the AIS viewer are objects. They connect the underlying reference geometry of a model to its graphic representation in AIS. You can use predefined OCCT classes of standard interactive objects for which all necessary functions have already been programmed, or, in case you are an advanced user, you can implement your own classes of interactive objects.
1550
dba69de2 1551### Graphic Attributes Manager
72b7576f 1552
1553Graphic attributes manager, or AIS Drawer, stores graphic attributes for specific interactive objects and for interactive objects controlled by interactive context.
1554
1555Initially, all drawer attributes are filled out with the predefined values which will define the default 3D object appearance.
1556
1557When an interactive object is visualized, the required graphic attributes are first taken from its own drawer if one exists, or from the context drawer if no specific drawer for that type of object exists.
1558
dba69de2 1559### Selection Filters
72b7576f 1560
1561An important aspect in selection is the filtering of entities you to select.
1562Selection filters allow you to refine the dynamic detection context, which you want to put into effect. Some of these filters can be used at the Neutral Point, others in an open local context only. You can also program your own filters and load them into the context.
1563
1564
1565@subsection OCCT_TOVW_SECTION_5_3 Application Interactive Services (AIS)
1566
1567Application Interactive Services provide the means to create links between an application GUI viewer and the packages which are used to manage selection and presentation. The tools AIS defined for this include different sorts of entities: the selectable viewable objects themselves and the context and attribute managers to define their selection and display.
1568
1569To orient the user as he works in a modeling environment, views and selections must be comprehensible.
1570There must be several different sorts of selectable and viewable object defined.
1571These must also be interactive, that is, connecting graphic representation and the underlying reference geometry. These entities are called Interactive Objects, and are divided into four types:
1572 * the Datum
1573 * the Relation
1574 * the Object
1575 * None.
1576
1577The Datum groups together the construction elements such as lines, circles, points, trihedrons, plane trihedrons, planes and axes.
1578The Relation is made up of constraints on one or more interactive shapes and the corresponding reference geometry. For example, you might want to constrain two edges in a parallel relation. This constraint is considered as an object in its own right, and is shown as a sensitive primitive. This takes the graphic form of a perpendicular arrow marked with the || symbol and lying between the two edges.
1579
1580The Object type includes topological shapes, and connections between shapes.
1581
1582None, in order not to eliminate the object, tells the application to look further until it finds an object definition in its generation which is accepted.
1583
1584Inside these categories, you have the possibility of an additional characterization by means of a signature. The signature provides an index to the further characterization. By default, the Interactive Object has a None type and a signature of 0 (equivalent to None.)
1585If you want to give a particular type and signature to your interactive object, you must redefine the two virtual methods: <i> Type</i> and <i> Signature</i>.
1586
1587In the C++ inheritance structure of the package, each class representing a specific Interactive Object inherits <i> AIS_InteractiveObject</i>. Among these inheriting classes, <i> AIS_Relation</i> functions as the abstract mother class for inheriting classes defining display of specific relational constraints and types of dimension. Some of these include:
1588
1589 * display of constraints based on relations of symmetry, tangency, parallelism and concentricity
1590 * display of dimensions for angles, offsets, diameters, radii and chamfers.
1591
1592No viewer can show everything at once with any coherence or clarity.
1593Views must be managed carefully both sequentially and at any given instant.
1594Another function of the view is that of a context to carry out design in.
1595The design changes are applied to the objects in the view and then extended
1596to the underlying reference geometry by a solver.
1597To make sense of this complicated visual data, several display and selection tools are required.
1598To facilitate management, each object and each construction element has a selection priority.
1599There are also means to modify the default priority.
1600
1601To define an environment of dynamic detection, you can use standard filter classes or create your own.
1602A filter questions the owner of the sensitive primitive in local context to determine
1603if it has the desired qualities. If it answers positively, it is kept. If not, it is rejected.
1604
1605The standard filters supplied in AIS include:
1606
1607 * <i> AIS_AttributeFilter</i>
1608 * <i> AIS_SignatureFilter</i>
1609 * <i> AIS_TypeFilter</i>.
1610
1611Only the type filter can be used in the default operating mode, the neutral point.
1612The others can only be used in open local contexts.
1613
1614Neutral point and local context constitute the two operating modes of the
1615central entity which pilots visualizations and selections, the Interactive Context.
1616It is linked to a main viewer and if you like, a trash bin viewer as well.
1617
1618The neutral point, which is the default mode, allows you to easily visualize and select interactive objects which have been loaded into the context. Opening local contexts allows you to prepare and use a temporary selection environment without disturbing the neutral point.
1619A set of functions allows you to choose the interactive objects which you want to act on, the selection modes which you want to activate, and the temporary visualizations which you will execute. When the operation is finished, you close the current local context and return to the state in which you were before opening it (neutral point or previous local context).
1620
1621An interactive object can have a certain number of graphic attributes, which are specific to it, such as visualization mode, color, and material. By the same token, the interactive context has a set of graphic attributes, the Drawer which is valid by default for the objects it controls.
1622When an interactive object is visualized, the required graphic attributes are first taken from the object's own <i> Drawer</i> if one exists, or from the context drawer for the others.
1623
1624
1625@subsection OCCT_TOVW_SECTION_5_4 Presentation
1626
dba69de2 1627### Presentation Management
1628
72b7576f 1629<i> PrsMgr</i> package provides low level services and is only to be used when you do not want to use the services provided by AIS. It manages the display through the following services:
1630 * supplying a graphic structure for the object to be presented
1631 * recalculating presentations when required, e.g. by moving the object or changing its color
dba69de2 1632 * defining the display mode of the object to be presented; in the case of <i> AIS_Shape</i>, for example, this determines whether the object is to be displayed in wireframe (0) or shading (1) mode.
72b7576f 1633
1634Note that each new Interactive Object must have all its display modes defined.
1635
dba69de2 1636### Presentations of Geometry
1637
72b7576f 1638The Presentations of Geometry component provides services for advanced programmers to extend the Application Interactive Services component, AIS.
1639This would prove necessary in situations where new Interactive Objects were required.
1640
1641The <i> StdPrs </i>package provides standard display tools for specific geometries and topologies whereas <i> Prs3d</i> provides those for generic objects.
1642Among these classes are definitions of the display of the specific geometry or topology in various display modes such as wireframe, shading or hidden line removal mode.
1643
dba69de2 1644### Presentation of Dimensions
1645
72b7576f 1646 <i> DsgPrs </i> package provides tools for display of dimensions, relations and XYZ trihedrons.
1647
1648@subsection OCCT_TOVW_SECTION_5_5 Selection
1649
1650Selection of 3D data structures is provided using various algorithms.
1651
dba69de2 1652### Basic Selection
1653
72b7576f 1654
1655The <i> SelectBasics </i>package provides the following services:
1656
1657 * the root definition of the sensitive primitive, a selectable entity in a view
1658 * the definition of the owner of a sensitive primitive; this entity relates the primitive to the application entity which is to be selected in the view.
1659
dba69de2 1660### Standard Selections
1661
72b7576f 1662
1663The <i> StdSelect</i> package provides the following services:
1664
1665 * definition of selection modes for topological shapes
1666 * definition of several filter standard <i> Selection2d.ap </i> classes
1667 * 3D viewer selectors.
1668
1669Note that each new Interactive Object must have all its selection modes defined.
1670The <i>Select3D</i> package provides the following services:
1671
1672 * definition of standard 3D sensitive primitives such as points, curves and faces;
1673 * recovery of the bounding boxes in the 2D graphic selection space, if required;
1674 * a 3D-2D projector.
1675
dba69de2 1676### Selection Management
1677
72b7576f 1678
1679The <i> SelectMgr</i> package provides low level services and the classes
1680<i> SelectMgr_SelectionManager</i> and <i> SelectMgr_ViewerSelector </i>
1681in particular are only to be used when you do not want to use the services provided by <i> AIS</i>.
1682
1683<i> SelectMgr </i> manages the process of dynamic selection through the following services:
1684
1685 * activating and deactivating selection modes for Interactive Objects
1686 * adding and removing viewer selectors
1687 * definitions of abstract filter classes
1688
1689The principle of graphic selection consists in representing the objects which you want
1690to select by a bounding box in the selection view.
1691The object is selected when you use the mouse to designate the zone produced by the object.
1692
1693To realize this, the application creates a selection structure
1694which is independent of the point of view. This structure is made up
1695of sensitive primitives which have one owner object associated to each of them.
1696The role of the sensitive primitive is to reply to the requests of the selection algorithm
1697whereas the owner's purpose is to make the link between
1698the sensitive primitive and the object to be selected.
1699Each selection structure corresponds to a selection mode which defines the elements that can be selected.
1700
1701For example, to select a complete geometric model,
1702the application can create a sensitive primitive for each face
1703of the interactive object representing the geometric model.
1704In this case, all the primitives share the same owner.
1705On the other hand, to select an edge in a model,
1706the application must create one sensitive primitive per edge.
1707
1708~~~~
1709
1710void InteractiveBox::ComputeSelection
1711 (const Handle(SelectMgr_Selection)& Sel,
1712 const Standard_Integer Mode){
1713
1714switch(Mode){
1715case 0:
1716// locating the whole box by making its faces sensitive ...
1717 {
1718 Handle(SelectMgr_EntityOwner) Ownr = new
1719 SelectMgr_EntityOwner(this,5);
1720 for(Standard_Integer I=1;I<=Nbfaces;I++){
1721 Sel->Add(new Select3D_SensitiveFace
1722 (Ownr,[array of the vertices] face I);
1723 break;
1724 }
1725
1726case 1: // locates the edges
1727 {
1728
1729 for(Standard_Integer i=1;i<=12;i++){
1730 // 1 owner per edge...
1731 Handle(mypk_EdgeOwner) Ownr =
1732 new mypk_EdgeOwner(this,i,6);
1733 // 6->priority
1734 Sel->Add(new
1735 Select3D_SensitiveSegment
1736 (Ownr,firstpt(i),lastpt(i));
1737 }
1738 }
1739}
1740
1741~~~~
1742
1743The algorithms for creating selection structures store the sensitive primitives in a
1744<i> SelectMgr_Selection </i> object. To do this, a set of ready-made sensitive primitives is supplied
1745in the <i> Select2D </i>and <i> Select3D </i>packages. New sensitive primitives can be defined through inheritance
1746from <i> SensitiveEntity</i>. For the application to make its own objects selectable,
1747 it must define owner classes inheriting <i> SelectMgr_EntityOwner</i>.
1748
1749For any object inheriting from <i> AIS_InteractiveObject</i>, you redefine
1750its <i> ComputeSelection</i> functions. In the example below there are different modes
1751of selection on the topological shape contained within the interactive object,
1752selection of the shape itself, the vertices, the edges, the wires, the faces.
1753
1754~~~~
1755 void MyPack_MyClass::ComputeSelection(
1756 const Handle(SelectMgr_Selection)& aSelection,
1757 const Standard_Integer aMode)
1758 {
1759 switch(aMode){
1760 case 0:
1761 StdSelect_BRepSelectionTool::Load(
1762 aSelection,this,myShape,TopAbs_SHAPE);
1763 break;
1764 }
1765 case 1:
1766 StdSelect_BRepSelectionTool::Load(
1767 aSelection,this,myShape,TopAbs_VERTEX);
1768 break;
1769 }
1770 case 2:
1771 StdSelect_BRepSelectionTool::Load(
1772 aSelection,this,myShape,TopAbs_EDGE);
1773 break;
1774 }
1775 case 3:
1776 StdSelect_BRepSelectionTool::Load(
1777 aSelection,this,myShape,TopAbs_WIRE);
1778 break;
1779 }
1780 case 4:
1781 StdSelect_BRepSelectionTool::Load(
1782 aSelection,this,myShape,TopAbs_FACE);
1783 break;
1784 }
1785 }
1786~~~~
1787
1788The <i> StdSelect_BRepSelectionTool </i> object provides a high level service
1789which will make the shape <i> myShape</i> selectable when the <i> AIS_InteractiveContext</i> is asked to display your object.
1790
1791Note:
1792
1793The traditional way of highlighting selected entity owners
1794adopted by Open CASCADE Technology assumes that each entity owner
1795highlights itself on its own. This approach has two drawbacks:
1796
1797 * each entity owner has to maintain its own <i>Prs3d_Presentation object</i>, that results in large memory overhead for thousands of owners;
1798 * drawing selected owners one by one is not efficient from the OpenGL usage viewpoint.
1799
1800That is why a different method has been introduced.
1801On the basis of <i> SelectMgr_EntityOwner::IsAutoHilight() </i> return value
1802<i> AIS_LocalContext </i> object either uses the traditional way of highlighting
1803( <i> IsAutoHilight() </i> returned true) or groups such owners according to their
1804Selectable Objects and finally calls <i> SelectMgr_SelectableObject::HilightSelected()</i> or
1805<i> ClearSelected()</i>, passing a group of owners as an argument.
1806
1807Hence, an application can derive its own interactive object and redefine <i> HilightSelected()</i>,
1808 <i> ClearSelected()</i> and <i> HilightOwnerWithColor()</i> virtual methods
1809 to take advantage of such OpenGL technique as arrays of primitives.
1810 In any case, these methods should at least have empty implementation.
1811
1812 The <i> AIS_LocalContext::UpdateSelected(const Handle(AIS_InteratciveObject)&, Standard_Boolean)
1813 </i> method can be used for efficient redrawing a selection presentation for a given interactive object from an application code.
1814
1815Additionally, the <i> SelectMgr_SelectableObject::ClearSelections() </i>
1816method now accepts an optional Boolean argument.
1817This parameter defines whether all object selections should be flagged for further update or not.
1818This improved method can be used to re-compute an object selection (without redisplaying the object completely)
1819when some selection mode is activated not for the first time.
1820
1821
1822@subsection OCCT_TOVW_SECTION_5_6 Attribute Management
1823
1824The Attribute Management tool-kit provides services for advanced programmers to extend
1825the Application Interactive Services component, AIS. This would prove necessary
1826in situations where new Interactive Objects were required.
1827
1828The <i> Prs3d </i> package provides the following services:
1829
1830 * a presentation object (the context for all modifications to the display, its presentation will be displayed in every view of an active viewer)
1831 * an attribute manager governing how objects such as color, width, and type of line are displayed; these are generic objects, whereas those in <i>StdPrs </i> are specific geometries and topologies.
1832 * generic algorithms providing default settings for objects such as points, curves, surfaces and shapes
1833 * a root object which provides the abstract framework for the DsgPrs definitions at work in display of dimensions, relations and trihedrons.
1834
1835
1836@subsection OCCT_TOVW_SECTION_5_7 Mesh Visualization Services
1837
1838<i> MeshVS</i> (Mesh Visualization Service) component extends 3D visualization capabilities
1839of Open CASCADE Technology. It provides flexible means of displaying meshes along with associated pre- and post-processor data.
1840
1841From a developer's point of view, it is easy to integrate the MeshVS component i
1842nto any mesh-related application with the help of the following guidelines:
1843
1844Derive a data source class from the MeshVS_DataSource class.
1845Re-implement its virtual methods, so as to give the <i> MeshVS</i> component access
1846to the application data model. This is the most important part of the job,
1847since visualization performance is affected by performance of data retrieval methods of your data source class.
1848
1849Create an instance of the <i> MeshVS_Mesh</i> class.
1850
1851Create an instance of your data source class and pass it to a <i> MeshVS_Mesh </i> object through the <i> SetDataSource()</i> method.
1852
1853Create one or several objects of <i> MeshVS_PrsBuilder</i>-derived classes
1854(either standard, included in the <i> MeshVS</i> package, or your custom ones).
1855Each <i> PrsBuilder</i> is responsible for drawing a <i> MeshVS_Mesh</i> presentation
1856in certain display mode(s) specified as a <i> PrsBuilder</i> constructor's argument.
1857Display mode is treated by <i> MeshVS</i> classes as a combination of bit flags
1858(two least significant bits are used to encode standard display modes: wireframe, shading and shrink).
1859Pass these objects to the <i> MeshVS_Mesh::AddBuilder()</i> method. <i> MeshVS_Mesh</i>
1860takes advantage of improved selection highlighting mechanism: it highlights its selected entities itself,
1861with the help of so called "highlighter" object. You can set one of <i> PrsBuilder</i>
1862objects to act as a highlighter with the help of a corresponding argument of the <i> AddBuilder()</i> method.
1863
1864Visual attributes of the <i> MeshVS_Mesh </i> object (such as shading color, shrink coefficient and so on)
1865are controlled through <i> MeshVS_Drawer</i> object. It maintains a map "Attribute ID --> attribute value"
1866and can be easily extended with any number of custom attributes.
1867
1868In all other respects, <i> MeshVS_Mesh</i> is very similar to any other class derived
1869from <i> AIS_InteractiveObject</i> and it should be used accordingly
1870(refer to the description of <i> AIS package</i> in the documentation).
1871
1872@subsection OCCT_TOVW_SECTION_5_8 Images and Drivers
1873
dba69de2 1874### Images
72b7576f 1875
1876The <i> Image</i> package provides <i> PseudoColorImage</i>
1877and <i> ColorImage</i> definitions, and a set of key functions from the image fields.
1878
1879The <i> AlienImage</i> package allows importing images from other formats into OCCT format.
1880
dba69de2 1881### Drivers
1882
72b7576f 1883The <i> Xw </i>package contains the common X graphic interface. It uses <i> XWindow </i> bitmap fonts that cannot be modified.
1884
1885The <i> WNT</i> package contains the common Windows NT graphic interface.
1886
1887The <i> Cocoa</i> package provides interaction with Cocoa API on Mac OS X.
1888
1889@subsection OCCT_TOVW_SECTION_5_9 New Interactive Services (NIS)
1890
1891New Interactive Services package provides the API similar to the traditional AIS but with some important differences/improvements:
1892
1893 * Each type of <i> InteractiveObject</i> should have a corresponding Drawer class that defines the presentation of the Object type using direct OpenGl calls. This is a much faster way to display 3D objects, providing for more than 1 million separate selectable entities in one view.
1894 * The abstract type <i> NIS_InteractiveObject</i> does not support any properties (color, material, other aspects). The relevant properties should be defined in the specializations of the Drawer class, and the API to set/modify should be implemented in the specializations of InteractiveObject class.
1895 * Interactive selection is managed by <i> InteractiveObject</i> methods instead of special selector classes and data types. This is possible since in NIS the selection is based on 3D representation (by a ray or a box corresponding to the view direction) without intermediate 2D projection.
1896 * Many <i> InteractiveContext</i> instances can be attached to a <i> V3d_View</i>, these instances being independent containers of interactive objects; removal (detaching) of <i> InteractiveContext</i> instance destroys the contained objects.
1897 * All data types and algorithms are designed to provide the best performance for both OpenGl (server side) and application. On the other hand, the API is open to any feature supported by any version of OpenGl. This allows building custom presentations quickly and efficiently.
1898 * Standard <i> NIS_View</i> subclasses <i> V3d_View</i> thus providing all its public API, such as scene definition (view orientation, lights, background, etc.) and the standard view transformations (pan/zoom/rotate,fitAll,...). The traditional AIS-based presentations (e.g., <i> AIS_Shape</i>) are also supported, they can be rendered together with NIS presentations in the same view window.
1899
1900The DRAW test plugin, <i> TKViewerTest</i>, has been modified
1901to manage <i> AIS_InteractiveContext</i> and <i> NIS_InteractiveContext</i> together in one view window.
1902
1903@subsection OCCT_TOVW_SECTION_5_10 Voxels
1904
1905A voxel is a sub-volume box with constant scalar/vector value.
1906The object in voxel representation is split into many small sub-volumes (voxels) and its properties are distributed through voxels.
1907
1908Voxels are used for analysis and visualization of 3D-dimensional distribution of data.
1909Medicine (mainly, tomography), computational physics (hydrodynamics, aerodynamics, nuclear physics)
1910and many other industries use voxels for 3D data visualization and analysis of physical processes.
1911
1912Open CASCADE Technology provides several basic data containers for voxels
1913with fast access to the data and optimal allocation of data in memory.
1914Also, a special visualization toolkit allows visualizing voxels
1915as colored or black/white points and cubes, displaying only the voxels visible from the user's point of view.
1916
1917Please, see for more information Voxels User's Guide white paper.
1918
1919@subsection OCCT_TOVW_SECTION_5_11 Examples
1920
dba69de2 1921### How to change graphic attributes of an interactive object
1922
72b7576f 1923The set of graphic attributes of an interactive object is defined in AIS_Drawer.
1924Each interactive object can have its own visualization attributes.
1925
1926By default, the interactive object takes the graphic attributes of
1927the interactive context in which it is visualized
1928(visualization mode, deflection, values for the calculation of presentations,
1929number of isoparametric lines, color, type of line, material, etc.)
1930
1931In the <i> AIS_InteractiveObject</i> abstract class, several standard attributes
1932have been privileged. These include: color, thickness of line, material, and transparency.
1933Consequently, a certain number virtual functions which allow us to act on these attributes have been proposed.
1934Each new class of interactive object can use them as they are or
1935can redefine these functions to bring about the changes it should produce in the behavior of the class.
1936
1937Other attributes can be changed by acting directly on the drawer of the object.
1938An interactive object has a specific drawer as soon as you change an attribute on it.
1939If you do not modify any graphic attribute on it, the default drawer of the interactive context is referenced and used.
1940
1941To get the <i> AIS_Drawer</i> of an object, call method <i> AIS_InteractiveObject::Attributes </i>.
1942
1943To set the <i> AIS_Drawer</i> of an object, call method <i> AIS_InteractiveObject::SetLocalAttributes </i>.
1944
dba69de2 1945### How to dump a scene from the viewer
72b7576f 1946
1947You can dump the contents of a <i> V3D_View</i> in a file with the same scale or
1948with a different scale according to the required paper size (format)
1949and the aspect ratio of the view. This is provided by method <i>V3d_View::Dump</i>. For example:
1950
1951~~~~
1952CString filename ("myView3D.bmp");
1953myView->Dump (filename, Aspect_FOSP_A4);
1954~~~~
1955
1956<i> myView</i> is a <i> V3d_View</i>, where OCCT objects are displayed using, for example, AIS services.
1957
1958Please, note:
1959
1960 * The file name extension can be any among ".xwd", ".png", or ".bmp" formats both on UNIX or NT.
1961 * Be careful about dump time requirements of the resulting file, especially for the A formats.
1962 * The GIF format generates very small files, BMP and XWD generates much larger files (4 to 6 times the size of a GIF).
1963 * The time to generate these files is very short with the XWD format but 2 to 4 times longer for the other formats.
1964 * After getting an image file of your view, you can use any standard application for editing or sending the image file to a printer (i.e.: Microsoft Photo Editor on Windows or Image Viewer on SUN system)
1965
dba69de2 1966### How to add and remove objects from Selections
1967
72b7576f 1968
1969You can add or remove an object from a selection in one of two ways. You can use:
1970
1971 * <i> AIS_InteractiveContext::AddOrRemoveCurrentObject</i> method at neutral points;
1972 * <i> AddOrRemoveCurrent </i> method if a local context is opened.
1973
1974
dba69de2 1975### How to detect overlapped objects
1976
72b7576f 1977
1978When objects overlap each other and cause difficulties in selection,
1979you can use the mechanism provided with the <i> AIS_InteractiveContext</i>
1980to successively highlight all the objects found under the selection.
1981This allows you to choose and validate the required object.
1982
1983~~~~
1984 If ( myAISContext->HasNextDetected()) {
1985
1986 // if up key is pressed
1987 myAISContext ->HilightNextDetected(myView);
1988
1989 // if down key is pressed
1990 myAISContext ->HilightPreviousDetected(myView);
1991
1992 }
1993~~~~
1994
1995
1996
dba69de2 1997### Get mouse coordinates in 3D view
1998
72b7576f 1999
2000To switch from pixel mouse position on the screen to 3D coordinates
2001in <i> V3d_View</i>, use <i>V3d_View::Convert</i> method.
2002
2003~~~~
2004 Handle(V3d_View) aview
2005 aView->Convert(Xp,Yp,X,Y,Z)
2006~~~~
2007
2008Where <i> Xp</i>, <i> Yp</i> are the mouse coordinates in pixels and X,Y,Z the real coordinates in 3D space.
2009
dba69de2 2010### 3D Viewer Objects
2011
72b7576f 2012The <i> V3d </i> package contains the set of commands and services of the 3D Viewer.
2013It provides a set of high level commands to control views and viewing modes.
2014This package is complementary to the <i> Visual3D</i> graphic package.
2015
2016<i> CSF_WALKTHROUGH</i> variable enables you to manage the perspective of the view
2017in the viewer by defining <i> setenv CSF_WALKTHROUGH </i> "Yes".
2018
2019If you use the syntax <i> unsetenv CSF_WALKTHROUGH </i>, you make sure that the variable
2020is deactivated. In this case, the eye is located outside the 3D bounding box of the view.
2021This is the default behavior for managing the view perspective.
2022
2023@section OCCT_TOVW_SECTION_6 Data Exchange
2024
2025Data Exchange is a key factor in using Open CASCADE Technology (as well as applications based thereon)
2026concurrently with other software such as CAD systems. It provides the openness of OCCT in a multi-software environment,
2027by allowing it to process external data and providing a good level of integration.
2028
2029This means obtaining results of good quality, and covering the needs of exchanges
2030from OCCT-based applications regardless of external data quality or requirements,
2031in particular in respect of allowed data types and arrangements between them, accepted gaps between geometries.
2032
2033This matter is addressed by Data Exchange Module, which is organized in a modular way.
2034
dba69de2 2035@image html /technical_overview/images/technical_overview_de.png
2036@image latex /technical_overview/images/technical_overview_de.png
72b7576f 2037
2038Data Exchange interfaces in OCCT allow software based on OCCT
2039to exchange data with various CAD software, thus ensuring a good level of interoperability.
2040
2041Data Exchange interfaces function either in accordance with the standards (IGES, STEP),
2042which can be used by various software packages for CAD, PDM etc., or as direct connectors to proprietary formats.
2043
dba69de2 2044### Standardized Data Exchange
2045
72b7576f 2046
2047* STEP (AP203 : Mechanical Design, this covers General 3D CAD; AP214: Automotive Design)
2048* IGES (up to 5.3)
2049* STL
2050* VRML
2051
2052Data Exchange interfaces (STEP, IGES) allow to query and examine a file,
2053results of conversion and its validity. They are designed to support extensions (like new standards) in a common modular architecture.
2054
dba69de2 2055### Extended data exchange
2056
72b7576f 2057
2058Extended data exchange (XDE) allows you to extend the scope of exchange by translating
2059 additional data attached to geometric ("BREP") data, thereby improving the interoperability with external software.
2060Data types such as colors, assembly descriptions and validation properties
2061(i.e. center of gravity, etc.) are supported. These data are stored together with shapes in an OCAF (XCAF) document.
2062
2063
dba69de2 2064### Proprietary Data Exchange
72b7576f 2065
2066In addition to standard Data Exchange interfaces, separate components are available
2067to provide direct mapping and data adaptation (using Shape Healing) with CAD software supporting the following formats:
2068
2069* ACIS SAT
2070* Parasolid X_T
2071* DXF
2072
2073These components are based on the same architecture as interfaces with STEP and IGES.
2074
dba69de2 2075### Translating a shape to STL Format
2076
72b7576f 2077
2078OCCT includes a module for translating OCCT shapes to STL (Stereolithography) format.
2079STL is a format designed for rapid prototyping.
2080It is intended to send geometric data (volumic) to stereolithography machines,
2081which can read and interpret such data. These machines can transform a volumic model
2082to a physical prototype made of plastic, by using laser to coagulate material,
2083which corresponds to the volume, and set free the material around.
2084STL defines these surfaces by triangles.
2085Thus, no machining is required to switch from a virtual model to a physical one.
2086
2087Since STL files can only include solids described by their mesh structures,
2088OCCT shapes, which are intended to be written, must be solids,
2089components of solids or closed shells with a correct orientation.
2090
2091When translating shapes to STL format, remember that all references
2092to shapes mean references to OCCT shapes unless otherwise explicitly defined.
2093In addition, sets of faces or unclosed shells may also be translated but visualization in foreign viewers may be incorrect.
2094
dba69de2 2095### Translating a shape to VRML Format
72b7576f 2096
dba69de2 2097The Virtual Reality Modeling Language (VRML) is a language for describing multi-participant interactive simulations, virtual worlds networked via the Internet and hyperlinked with the World Wide Web. VRML is a format designed for animated visualization of solids.
72b7576f 2098OCCT includes a module for translating OCCT shapes to VRML (Virtual Reality Modeling Language).
2099OCCT shapes may be translated in two representations (states): shaded or wireframe.
2100Since shaded VRML format files include only solids described by their mesh structures, the OCCT shapes intended to be written must be solids, components of solids or closed shells with a correct orientation.
2101
2102@subsection OCCT_TOVW_SECTION_6_1 General Definitions
2103
2104OCCT general definitions for Data Exchange include several enumerations and classes used by IGES and STEP data exchange interfaces.
2105
2106To define translation parameters and file headers, you can use:
2107
2108 * <i> Interface_InterfaceModel</i>
2109 * <i> Interface_Static</i>
2110
2111To manage Message display, use class <i> Mesage_Messenger</i>.
2112
2113To define the type of analysis of the source file, and to ensure the success
2114of the loading operation, you use the following enumerations from the <i> IFSelect</i> package:
2115
2116 * <i> PrintCount</i>
2117 * <i> ReturnStatus</i>
2118
2119To read and write attributes such as names, colors, layers for IGES and STEP
2120and validation properties and structure of assemblies for STEP, you can use an XDE document.
2121
2122It is possible to learn more about XDE documents from XDE User's guide
2123
2124See also: our web site at E-learning and Training.
2125
2126
2127@subsection OCCT_TOVW_SECTION_6_2 IGES
2128
2129The IGES interface reads IGES files and translates them to Open CASCADE Technology models.
2130IGES files produced in accordance with IGES standard versions up to and including version 5.3 can be read.
2131The interface is able to translate one entity, a group of entities or a whole file.
2132Before beginning a translation, you can set a range of parameters to manage the translation process.
2133If you like, you can also check file consistency before translation.
2134
2135The IGES interface also translates OCCT models to IGES files.
2136IGES files produced by this component conform to IGES standard version 5.3.
2137
2138Other kinds of data such as colors and names can be read or written
2139with the help of XDE tools <i> IGESCAFControl_Reader</i> and <i> IGESCAFControl_Writer</i>.
2140
2141Please, note:
2142
2143 * an IGES model is an IGES file that has been loaded into memory.
2144 * an IGES entity is an entity in the IGES normal sense.
2145 * a root entity is the highest level entity of any given type, e.g. type 144 for surfaces and type 186 for solids. Roots are not referenced by other entities.
2146
2147It is possible to learn more about the IGES interface from IGES User's guide
2148
2149See also: our web site at E-learning and Training.
2150
2151@subsection OCCT_TOVW_SECTION_6_3 STEP
2152
2153The STEP interface reads STEP files produced in accordance with STEP Application Protocol 214
2154(Conformance Class 2 both CD and DIS versions of schema) and translates them
2155to Open CASCADE Technology models. STEP Application Protocol 203 is also supported.
2156
2157The STEP interface also translates OCCT models to STEP files. STEP files that are produced
2158by this interface conform to STEP AP 203 or AP 214 (
2159Conformance Class 2, either CD or DIS version of the schema) depending on the user's option.
2160
2161Basic interface reads and writes geometrical, topological STEP data and assembly structures.
2162
2163The interface is able to translate one entity, a group of entities or a whole file.
2164
2165Other kinds of data such as colors, validation properties, layers, names
2166and the structure of assemblies can be read or written
2167with the help of XDE tools - <i> STEPCAFControl_Reader</i> and <i> STEPCAFControl_Writer</i>.
2168
2169To choose a translation mode when exporting to a STEP format, use <i> STEPControl_STEPModelType</i>.
2170
2171There is a set of parameters that concern the translation and can be set before the beginning of the translation.
2172
2173Please, note:
2174* a STEP model is a STEP file that has been loaded into memory;
2175* all references to shapes indicate OCCT shapes unless otherwise explicitly stated;
2176* a root entity is the highest level entity of any given type, i.e. an entity that is not referenced by any other one.
2177
2178It is possible to learn more about the STEP interface from STEP User's guide
2179See also: our web site at E-learning and Training.
2180
2181@subsection OCCT_TOVW_SECTION_6_4 STL
2182
2183The STL component translates Open CASCADE Technology shapes to STL files. STL (Stereolithography) format is widely used for rapid prototyping.
2184
2185As STL files can only include solids described by their mesh structure,
2186the OCCT shapes to be written must be solids, components of solids or closed shells with a correct orientation.
2187
2188Note All references to shapes indicate OCCT shapes unless otherwise explicitly stated.
2189
2190Sets of faces or unclosed shells may also be translated to STL format but visualization with foreign viewers may be incorrect.
2191
2192@subsection OCCT_TOVW_SECTION_6_5 VRML
2193
2194The VRML component translates Open CASCADE Technology shapes to VRML 1.0 files
2195(Virtual Reality Modeling Language). OCCT shapes may be translated in two representations:
2196shaded or wireframe. A shaded representation present shapes as sets of triangles
2197computed by a mesh algorithm while a wireframe representation present shapes as sets of curves.
2198
2199As shaded VRML format files only include solids described by their mesh structures,
2200the OCCT shapes to be written must be solids, components of solids or closed shells with a correct orientation.
2201
2202Please, note:
2203
2204 * all references to shapes indicate OCCT shapes unless otherwise explicitly stated;
2205 * sets of faces or unclosed shells may also be translated to shaded VRML format but visualization with foreign viewers may be incorrect.
2206
2207@section OCCT_TOVW_SECTION_7 Application Framework
2208
2209The Application Framework uses an associativity engine to simplify the development of a CAD application.
2210Based on application/document architecture, it does this due to the following features:
2211
2212 * Application data is handled by the mechanism of attributes
2213 * Attributes may be organized according to your development needs
2214 * Multiple documents can be managed by an application
2215 * Ready-to-use modeling data attributes common to CAD/CAM applications
2216 * Document modification and recomputation
2217 * Data storage services
2218 * A ready-to-use Undo-Redo and Copy-Paste functions
2219
2220Since OCAF handles your application structure, your only major development task is the creation
2221of application-specific data and GUIs. It is the organization of application data
2222due to which OCAF differs from any other CAD framework. In OCAF, data structures are not shape-driven,
2223but reference-key driven. In this respect, attributes such as shape data, color, material,
2224are attached to a deeper invariant structure of a model than the shapes themselves.
2225Then OCAF organizes and embeds these attributes in a document.
2226For example, a geometry becomes the value of the Shape attribute,
2227in the same way as a number is the value of the Integer attribute and a string is the value of the Name attribute.
2228
2229OCAF documents are in their turn managed by an OCAF application.
2230
2231Please, refer for more details to OCAF User's guide and the OCAF white papers:
2232* Application Framework
2233* Distribution of Data through OCAF Tree
2234* Application Framework Function Mechanism
2235
2236See also: our web site at E-learning and Training.
2237
2238@subsection OCCT_TOVW_SECTION_7_1 How to start working with OCAF
2239
2240To create a useful OCAF-based application, it is necessary to redefine the following
2241two deferred methods: <i> Formats</i> and <i> ResourcesName</i>
2242
2243In the <i> Formats </i> method, it is necessary to add the format
2244of the documents to be read by the application and which may have been built in other applications.
2245
2246For example:
2247
2248~~~~
2249 void myApplication::Formats(TColStd_SequenceOfExtendedString& Formats)
2250 {
2251 Formats.Append(TCollection_ExtendedString ("OCAF-myApplication"));
2252 }
2253~~~~
2254
2255In the <i> ResourcesName</i> method, you only define the name of the resource file. This
2256file contains several definitions for the saving and opening mechanisms associated
2257with each format and calling of the plug-in file.
2258
2259~~~~
2260 Standard_CString myApplication::ResourcesName()
2261 {
2262 return Standard_CString ("Resources");
2263 }
2264~~~~
2265
2266To obtain the saving and opening mechanisms, it is necessary to set two environment
2267variables: <i> CSF_PluginDefaults</i>, which defines the path of the plug-in file and <i> CSF_ResourcesDefault</i>, which defines the resource file:
2268
2269~~~~
2270 SetEnvironmentVariable ( "CSF_ResourcesDefaults",myDirectory);
2271 SetEnvironmentVariable ( "CSF_PluginDefaults",myDirectory);
2272~~~~
2273
2274The plugin and the resource files of the application will be located in <i> myDirector</i>.
2275The name of the plugin file must be <i>Plugin</i>.
2276
dba69de2 2277### Resource File
72b7576f 2278
2279The resource file describes the documents (type and extension) and
2280the type of data that the application can manipulate
2281by identifying the storage and retrieval drivers appropriate for this data.
2282
2283Each driver is unique and identified by a GUID generated, for example, with the <i> uuidgen </i> tool in Windows.
2284
2285Five drivers are required to use all standard attributes provided within OCAF:
2286
2287 * the schema driver (ad696002-5b34-11d1-b5ba-00a0c9064368)
2288 * the document storage driver (ad696000-5b34-11d1-b5ba-00a0c9064368)
2289 * the document retrieval driver (ad696001-5b34-11d1-b5ba-00a0c9064368)
2290 * the attribute storage driver (47b0b826-d931-11d1-b5da-00a0c9064368)
2291 * the attribute retrieval driver (47b0b827-d931-11d1-b5da-00a0c9064368)
2292
2293These drivers are provided as plug-ins and are located in the <i> PappStdPlugin</i> library.
2294
2295
2296For example, this is a resource file, which declares a new model document OCAF-MyApplication:
2297
2298~~~~
2299formatlist:OCAF-MyApplication
2300OCAF-MyApplication.Description: MyApplication Document Version 1.0
2301OCAF-MyApplication.FileExtension: sta
2302OCAF-MyApplication.StoragePlugin: ad696000-5b34-11d1-b5ba-00a0c9064368
2303OCAF-MyApplication.RetrievalPlugin: ad696001-5b34-11d1-b5ba-00a0c9064368
2304OCAF-MyApplicationSchema: ad696002-5b34-11d1-b5ba-00a0c9064368
2305OCAF-MyApplication.AttributeStoragePlugin: 47b0b826-d931-11d1-b5da-00a0c9064368
2306OCAF-MyApplication.AttributeRetrievalPlugin: 47b0b827-d931-11d1-b5da-00a0c9064368
2307~~~~
2308
2309
dba69de2 2310### Plugin File
72b7576f 2311
2312The plugin file describes the list of required plug-ins to run the application and the
2313libraries in which plug-ins are located.
2314
2315You need at least the <i> FWOSPlugin</i> and the plug-in drivers to run an OCAF application.
2316
2317The syntax of each item is <i> Identification.Location Library_Name, </i> where:
2318* Identification is GUID.
2319* Location defines the location of the Identification (where its definition is found).
2320* Library_Name is the name (and path to) the library, where the plug-in is located.
2321
2322For example, this is a Plugin file:
2323
2324~~~~
2325a148e300-5740-11d1-a904-080036aaa103.Location: FWOSPlugin
2326! base document drivers plugin
2327ad696000-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin
2328ad696001-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin
2329ad696002-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin
233047b0b826-d931-11d1-b5da-00a0c9064368.Location: PAppStdPlugin
233147b0b827-d931-11d1-b5da-00a0c9064368.Location: PAppStdPlugin
2332~~~~
2333
2334@subsection OCCT_TOVW_SECTION_7_2 Data Attributes
2335
2336The following ready-to-use attributes are provided:
2337 * Shape attributes, which contain shapes and their evolution
2338 * Standard attributes, a collection of common CAD/CAM attributes including:
2339 * Real
2340 * Integer
2341 * Name
2342 * Constrain
2343 * Visualization attributes implement the Application Interactive Services in the context of Open CASCADE Application Framework.
2344 * Function attributes which regenerate any data affected by modifications made in a
2345document
2346
dba69de2 2347### Shape Attributes
72b7576f 2348
2349A topological attribute can be seen as a hook into the topological structure. To
2350this hook, data can be attached and references defined.
2351
2352
2353It is used for keeping and access to topological objects and their evolution. All
2354topological objects are stored in the one user-protected <i> TNaming_UsedShapes attribute</i>
2355at the root label of the data framework. This attribute contains map with all topological
2356shapes, used in this document.
2357
2358TNaming_NamedShape attribute can be added to any other attribute. This attribute contains
2359references (hooks) to shapes from the <i> TNaming_UsedShapes</i> attribute and evolution
2360of these shapes. <i> TNaming_NamedShape </i> attribute contains a set of pairs of hooks: old
2361shape and new shape (see the figure below). It allows not only get the topological
2362shapes by the labels, but also trace evolution of the shapes and correctly resolve
2363dependent shapes by the changed one.
2364
2365If a shape is newly created, the old shape for the corresponding named shape is an empty
2366shape. If a shape is deleted, then the new shape in this named shape is empty.
2367
dba69de2 2368@image html /technical_overview/images/technical_overview_shapeattrib.png
2369@image latex /technical_overview/images/technical_overview_shapeattrib.png
72b7576f 2370
2371
dba69de2 2372### Shape attributes in data framework.
72b7576f 2373
2374Algorithms can dispose sub-shapes of the result shape at the individual
2375label depending on necessity:
2376
2377 * If a sub-shape must have some extra attributes (material of each face or color of each edge). In this case a specific sub-shape is placed to the separate label (usually, sub-label of the result shape label) with all attributes of this sub-shape.
2378 * If topological naming is needed, a necessary and sufficient (for selected sub-shapes identification) set of sub-shapes is placed to the child labels of the result shape label. As usual, as far as basic solids and closed shells are concerned, all faces of the shape are disposed. Edges and vertices sub-shapes can be identified as intersection of contiguous faces. Modified/generated shapes may be placed to one named shape and identified as this named shape and source named shape that also can be identified with used algorithms.
2379
2380<i> TNaming_NamedShape </i> may contain a few pairs of hooks with the same evolution. In this
2381case topology shape, which belongs to the named shape, is a compound of new shapes.
2382
2383The data model contains both the topology and the hooks, and functions handle both
2384topological entities and hooks. Consider the case of a box function, which creates
2385a solid with six faces and six hooks. Each hook is attached to a face. If you want,
2386you can also have this function create hooks for edges and vertices as well as for
2387faces.
2388
2389Not all functions can define explicit hooks for all topological entities they create,
2390but all topological entities can be turned into hooks when necessary. This is where
2391topological naming is necessary.
2392
2393Consider the following example. A box defines six hooks for the six faces, but a
2394protrusion created on a face of the box can only define two hooks, one for the top
2395face, and one for all the lateral faces. As the basic wire defining the protrusion
2396may change in the future the protrusion function cannot designate the lateral faces
2397without ambiguity, their number may change. Figure 6 illustrates this example, faces
2398F1 to F6 of the box each have a hook. Faces F7 to F10, the lateral faces of the protrusion,
2399share a single hook, and face F11, the top face, has one hook.
2400
dba69de2 2401@image html /technical_overview/images/technical_overview_occ_0068.png
2402@image latex /technical_overview/images/technical_overview_occ_0068.png
72b7576f 2403
2404This structure raises two problems:
2405
2406 * the value of the face F6 attribute-hook has changed;
2407 * no data can be attached to F7.
2408
2409When a hook designates multiple faces like F7-F10 (or the hook on F6 if F6 was split)
2410it is impossible to attach data to an individual face like F7.
2411
2412In fact, the protrusion has a trimmed face F6. As a result, the value of this face
2413has changed and the current value of the hook attached to it needs to be found. Note
2414that this face could have been split in two faces (for example if the function had
2415been a slot) and both new faces would have been attached to the same hook.
2416
2417
dba69de2 2418### Standard Attributes
2419
72b7576f 2420
2421Standard attributes are already existing ready-to-use attributes, which allow you
2422to create and modify labels and attributes for many basic data types.
2423
2424To find an attribute attached to a specific label, you use the GUID of the type of
2425attribute you are looking for. For this, find this information using the method
2426<i> GetID</i> and the method <i> Find</i> for the label as follows:
2427
2428~~~~
2429 Standard_GUID anID = MyAttributeClass::GetID();
2430 Standard_Boolean HasAttribute = aLabel.Find(anID,anAttribute);
2431~~~~
2432
2433
dba69de2 2434### Function Attributes
2435
72b7576f 2436
2437A model consists of data and algorithms manipulating with data. OCAF attributes store
2438data. A Function attribute stores data corresponding to a Function (see the white
2439paper OCAF Function Mechanism User's Guide). This mechanism manipulates with algorithms
2440computing the model in the optimal way following the modifications.
2441
dba69de2 2442@subsection OCCT_TOVW_SECTION_7_3 Persistent Data Storage
72b7576f 2443
2444There are three schemas of persistence, which you can use to store and retrieve OCAF data (documents):
2445
2446 * <i> Standard</i> persistence schema, compatible with previous OCAF applications
2447 * <i> XmlOcaf</i> persistence, allowing the storage of all OCAF data in XML form
2448 * <i> BinOcaf</i> persistence, allowing the storage of all OCAF data in binary format form
2449
2450
2451All schemes are independent of each other, but they guarantee that the standard OCAF
2452attributes stored and retrieved by one schema will be storable and retrievable by
2453the other. Therefore in any OCAF application you can use any persistence schema or
2454even all three of them. The choice is made by the Format string of stored OCAF documents
2455or automatically by the file header data - * on retrieval.
2456
2457Persistent data storage in OCAF using the <i> Standard</i> package is presented in:
2458
2459 * Basic Data Storage
2460 * Persistent Collections
2461
2462Persistent storage of shapes is presented in the following chapters:
2463
2464 * Persistent Geometry
2465 * Persistent Topology
2466
2467Finally, information about opening and saving persistent data is presented in Standard
2468Documents.
2469
2470
dba69de2 2471@subsubsection OCCT_TOVW_SECTION_7_3_1 Basic Data Storage
72b7576f 2472
2473Normally, all data structures provided by Open CASCADE Technology are run-time structures,
2474in other words, transient data. As transient data, they exist only while an application
2475is running and are not stored permanently. However, the Data Storage module provides
2476resources, which enable an application to store data on disk as persistent data.
2477
2478Data storage services also provide libraries of persistent classes and translation
2479functions needed to translate data from transient to persistent state and vice-versa.
2480
dba69de2 2481#### Libraries of persistent classes
72b7576f 2482
2483Libraries of persistent classes are extensible libraries of elementary classes you
2484use to define the database schema of your application. They include:
2485* Unicode (8-bit or 16-bit character type) strings
2486* Collections of any kind of persistent data such as arrays, stacks, queues, and graphs.
2487
2488All persistent classes are derived from the \b Persistent base class, which defines
2489a unique way of creating and handling persistent objects. You create new persistent
2490classes by inheriting from this base class.
2491
dba69de2 2492#### Translation Functions
72b7576f 2493
2494Translation functions allow you to convert persistent objects to transient ones and
2495vice-versa. These translation functions are used to build Storage and Retrieval drivers
2496of an application.
2497
2498For each class of 2D and 3D geometric types, and for the general shape class in the
2499topological data structure library, there are corresponding persistent class libraries,
2500which allow you to translate your data with ease.
2501
dba69de2 2502#### Creation of Persistent Classes
72b7576f 2503
2504If you are using Unix platforms as well as WOK and CDL, you can create your own persistent
2505classes. In this case, data storage is achieved by implementing Storage and Retrieval
2506drivers.
2507
2508The <i> Storage </i> package is used to write and read persistent objects.
2509These objects are read and written by a retrieval or storage algorithm
2510(<i> Storage_Schema </i>object) in a container (disk, memory, network ...).
2511Drivers (<i> FSD_File</i> objects) assign a physical container for data to be stored or retrieved.
2512
2513The standard procedure for an application in reading a container is as follows:
2514
2515 *open the driver in reading mode,
2516 *call the Read function from the schema, setting the driver as a parameter. This function returns an instance of the <i> Storage_Data </i> class which contains the data being read,
2517 *close the driver.
2518
2519The standard procedure for an application in writing a container is as follows:
2520
2521 *open the driver in writing mode,
2522 *create an instance of the <i> Storage_Data </i> class, then add the persistent data to write with the function <i> AddRoot</i> ,
2523 *call the function <i> Write </i> from the schema, setting the driver and the <i> Storage_Data </i> instance as parameters,
2524 *close the driver.
2525
dba69de2 2526@subsubsection OCCT_TOVW_SECTION_7_3_2 Persistent Collections
72b7576f 2527
2528Persistent collections are classes which handle dynamically sized collections of
2529data that can be stored in the database. These collections provide three categories
2530of service:
2531
2532 * persistent strings,
2533 * generic arrays of data,
2534 * commonly used instantiations of arrays.
2535
2536Persistent strings are concrete classes that handle sequences of characters based
2537on both ASCII (normal 8-bit) and Unicode (16-bit) character sets.
2538
2539Arrays are generic classes, that is, they can hold a variety of objects not necessarily
2540inheriting from a unique root class. These arrays can be instantiated with any kind
2541of storable or persistent object, and then inserted into the persistent data model
2542of a user application.
2543
2544The purpose of these data collections is simply to convert transient data into its
2545persistent equivalent so that it can be stored in the database. To this end, the
2546collections are used to create the persistent data model and assure the link with
2547the database. They do not provide editing or query capabilities because it is more
2548efficient, within the operative data model of the application, to work with transient
2549data structures (from the <i> TCollection</i> package).
2550
2551For this reason:
2552
2553 * the persistent strings only provide constructors and functions to convert between transient and persistent strings, and
2554 * the persistent data collections are limited to arrays. In other words, <i> PCollection</i> does not include sequences, lists, queues, sets, stacks and so on (unlike <i> TCollection</i>).
2555
2556Persistent string and array classes are found in the <i> PCollection</i> package.
2557In addition, <i> PColStd</i> package provides standard,
2558and frequently used, instantiations of persistent arrays, for very simple objects.
2559
dba69de2 2560@subsubsection OCCT_TOVW_SECTION_7_3_3 Persistent Geometry
72b7576f 2561
2562The Persistent Geometry component describes geometric data structures which can be
2563stored in the database. These packages provide a way to convert data from the transient
2564"world" to the persistent "world".
2565
2566Persistent Geometry consists of a set of atomic data models parallel to the geometric
2567data structures described in the geometry packages. Geometric data models, independent
2568of each other, can appear within the data model of any application. The system provides
2569the means to convert each atomic transient data model into a persistent one, but
2570it does not provide a way for these data models to share data.
2571
2572Consequently, you can create a data model using these components, store data in,
2573and retrieve it from a file or a database, using the geometric components provided
2574in the transient and persistent "worlds". In other words, you customize the system
2575by declaring your own objects, and the conversion of the geometric components from
2576persistent to transient and vice versa is automatically managed for you by the system.
2577
2578However, these simple objects cannot be shared within a more complex data model.
2579To allow data to be shared, you must provide additional tools.
2580
2581Persistent Geometry is provided by several packages.
2582
2583The <i> PGeom</i> package describes geometric persistent objects in 3D space, such as points,
2584vectors, positioning systems, curves and surfaces.
2585
2586These objects are persistent versions of those provided by the <i> Geom</i> package: for
2587each type of transient object provided by Geom there is a corresponding type of persistent
2588object in the <i>PGeom</i> package. In particular the inheritance structure is parallel.
2589
2590However the <i> PGeom </i>package does not provide any functions to construct, edit or access
2591the persistent objects. Instead the objects are manipulated as follows:
2592
2593 * Persistent objects are constructed by converting the equivalent transient <i> Geom </i> objects. To do this you use the <i>MgtGeom::Translate</i> function.
2594 * Persistent objects created in this way are used to build persistent data structures that are then stored in a file or database.
2595 * When these objects are retrieved from the file or database, they are converted back into the corresponding transient objects from the Geom package. To do this, you use <i>MgtGeom::Translate</i> function.
2596
2597In other words, you always edit or query transient data structures within the transient
2598data model supplied by the session.
2599Consequently, the documentation for the <i> PGeom </i> package consists simply of a list of available objects.
2600
2601The <i> PGeom2d </i> package describes persistent geometric objects in 2D space, such as points,
2602vectors, positioning systems and curves. This package provides the same type of services
2603as the <i> PGeom</i> package, but for the 2D geometric objects provided by the <i> Geom2d</i> package.
2604Conversions are provided by the <i>MgtGeom::Translate</i> function.
2605
2606~~~~
2607//Create a coordinate system
2608Handle(Geom_Axis2Placement) aSys;
2609
2610
2611//Create a persistent coordinate PTopoDS_HShape.cdlsystem
2612Handle(PGeom_Axis2placement)
2613 aPSys = MgtGeom::Translate(aSys);
2614
2615//Restore a transient coordinate system
2616Handle(PGeom_Axis2Placement) aPSys;
2617
2618Handle(Geom_Axis2Placement)
2619 aSys = MgtGeom::Translate(aPSys);
2620~~~~
2621
2622
dba69de2 2623@subsubsection OCCT_TOVW_SECTION_7_3_4 Persistent Topology
72b7576f 2624
2625The Persistent Topology component describes topological data structures which can be stored in the database. These packages provide a way to convert data from the transient "world" to the persistent "world".
2626
2627Persistent Topology is based on the BRep concrete data model provided by the topology packages. Unlike the components of the Persistent Geometry package, topological components can be fully shared within a single model, as well as between several models.
2628
2629Each topological component is considered to be a shape: a <i> TopoDS_Shape</i> object. The system's capacity to convert a transient shape into a persistent shape and vice-versa applies to all objects, irrespective of their complexity: vertex, edge, wire, face, shell, solid, and so on.
2630
2631When a user creates a data model using BRep shapes, he uses the conversion functions that the system provides to store the data in, and retrieve it from the database. The data can also be shared.
2632
2633Persistent Topology is provided by several packages.
2634
2635The <i> PTopoDS</i> package describes the persistent data model associated with any BRep shape; it is the persistent version of any shape of type <i> TopoDS_Shape</i>. As is the case for persistent geometric models, this data structure is never edited or queried, it is simply stored in or retrieved from the database. It is created or converted by the <i>MgtBRep::Translate</i> function.
2636
2637The <i> MgtBRepAbs</i> and <i> PTColStd </i> packages provide tools used by the conversion functions of topological objects.
2638
2639~~~~
2640//Create a shape
2641TopoDS_Shape aShape;
2642
2643//Create a persistent shape
2644PtColStd_DoubleTransientPersistentMap aMap;
2645
2646Handle(PTopoDS_HShape) aPShape =
2647 aMap.Bind2(MgtBRep::Translate
2648 aShape,aMap,MgtBRepAbs_WithTriangle));
2649
2650aPShape.Nullify();
2651
2652//Restore a transient shape
2653Handle(PTopoDS_HShape) aPShape;
2654
2655Handle(TopoDS_HShape) aShape =
2656 aMap.Bind1(MgtBRep::Translate
2657 (aPShape,aMap,MgtBRepAbs_WithTriangle));
2658
2659aShape.Nullify();
2660~~~~
2661
dba69de2 2662@subsubsection OCCT_TOVW_SECTION_7_3_5 Standard Documents
72b7576f 2663
2664Standard documents offer you a ready-to-use document containing a TDF-based data
2665structure. The documents themselves are contained in a class inheriting from <i> TDocStd_Application</i>
2666which manages creation, storage and retrieval of documents.
2667
2668You can implement undo and redo in your document, and refer from the data framework
2669of one document to that of another one. This is done by means of external link attributes,
2670which store the path and the entry of external links. To sum up, standard documents
2671alone provide access to the data framework. They also allow you to:
2672*Update external links;
2673*Manage the saving and opening of data;
2674*Manage undo/redo functionality.
2675
2676@section OCCT_TOVW_SECTION_8 FAQ
2677
72b7576f 2678@subsection OCCT_TOVW_SECTION_8_1 Memory Management
2679
2680In a work-session, geometry modeling applications create and delete a certain number
2681of C++ objects. In this context, memory allocation and de-allocation standard functions
2682are not suited to the system's requirements and for this reason a specialized Memory
2683Manager is implemented into Open CASCADE Technology. The Memory Manager is based
2684on the following principles:
2685
2686 * small memory arrays are grouped into clusters and then recycled (clusters are never released to the system),
2687 * large arrays are allocated and de-allocated through the standard functions of the system (the arrays are released to system when they are no longer used).
2688
dba69de2 2689### The Reference Counter
2690
72b7576f 2691To lighten usual programming difficulties linked to the management of object life duration, before deleting an object, the user must ensure the object is no longer referenced and the delete function is secured by a reference counter.
dba69de2 2692A smart-pointer called *Handle* automates reference counter management and automatically deletes an object when it is no longer referenced. The application never calls the delete operator explicitly. To benefit from the memory manager in OCCT, transient classes must inherit from <i>TShared</i>. The principle of allocation is as follows:
72b7576f 2693
2694~~~~
2695 Handle (TColStd_HSequenceOfInteger) H1 = new TColStd_HSequenceOfInteger;
2696 // H1 has one reference and corresponds to 48 bytes of memory
2697 {
2698 Handle (TColStd_HSequenceOfInteger) H2;
2699 H2 = H1; // H1 has two references
2700 if (argc == 3)
2701 {
2702 Handle (TColStd_HSequenceOfInteger) H3;
2703 H3 = H1;
2704 // Here, H1 has three references
2705 }
2706 // Here, H1 has two references
2707 }
2708 // Here, H1 has 1 reference
2709 }
2710 // Here, H1 has no reference but the 48 bytes of memory are kept.
2711 Handle (TColStd_HSequenceOfInteger) H1 = new TColStd_HSequenceOfInteger;
2712 // Here, H1 has one reference and corresponds to the preceding 48 bytes of
2713 // memory. In this case, there is no allocation of memory.
2714~~~~
2715
dba69de2 2716### Cycles
2717
2718As cycles are objects which reference one another, memory management is impossible if the data structure contains any cycles, particularly if there are back references.
2719
2720For example, objects in a graph include primitives and each one of these primitives has to know the graphic object to which it belongs (i.e. a reference to this graphic object). With normal references, the classical handle is used. With back references, a pointer is used.
72b7576f 2721
dba69de2 2722### Memory Consumption
72b7576f 2723
72b7576f 2724
dba69de2 2725As a general rule, it is advisable to allocate memory through significant blocks.
2726In this way, the user can work with blocks of contiguous data and it facilitates memory page manager processing.
72b7576f 2727
2728@subsection OCCT_TOVW_SECTION_8_2 How to define a handled object without CDL
2729
2730You can create a class manipulated by handle even if you do not use CDL (Open CASCADE Definition Language).
2731To do that you have to use the <i>Define_Standard_Handle</i> macro which is defined in the include file <i> Standard_DefineHandle.hxx</i>.
2732
2733Here is an example which shows how to define a class <i> SamplePoint </i> manipulated by handle.
2734
72b7576f 2735Sample_Point.hxx:
2736---------------
2737
e5bd0d98 2738~~~~
2739
72b7576f 2740 #ifndef _Sample_Point_HeaderFile
2741 #define _Sample_Point_HeaderFile
2742 #ifndef _Standard_Macro_HeaderFile
2743 #include <Standard_Macro.hxx>
2744 #endif
2745 #include <MMgt_TShared.hxx>
2746 #include <Standard_DefineHandle.hxx>
2747 // Handle definition
2748 //
2749
2750 DEFINE_STANDARD_HANDLE(Sample_Point,MMgt_TShared)
2751 class Sample_Point: public MMgt_TShared {
2752 public:
2753 Sample_Point();
2754 Sample_Point(const Standard_Real, const
2755 Standard_Real);
2756 void SetX(const Standard_Real x) {
2757 myX = x;
2758 }
2759 void SetY(const Standard_Real y) {
2760 myY = y;
2761 }
2762 Standard_Real X() const {
2763 return myX;
2764 }
2765 Standard_Real Y() const {
2766 return myY;
2767 }
2768 // some methods like DynamicType() or
2769 IsKind()
2770 //
2771 DEFINE_STANDARD_RTTI(Sample_Point)
2772 private:
2773 Standard_Real myX;
2774 Standard_Real myY;
2775 };
2776 #endif
2777
e5bd0d98 2778~~~~
2779
72b7576f 2780Sample_Point.cxx:
2781----------------
2782
e5bd0d98 2783~~~~
2784
72b7576f 2785 #include <Sample_Point.hxx>
2786
2787 // Implementation of Handle and type mgt
2788
2789 IMPLEMENT_STANDARD_HANDLE(Sample_Point,MMgt_TShared)
2790 IMPLEMENT_STANDARD_RTTI(Sample_Point,MMgt_TShared)
2791
2792 // For ancestors, we add a IMPLEMENT_STANDARD_SUPERTYPE and
2793 // a IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY macro.
2794 // We must respect the order: from the direct ancestor class to the base class.
2795
2796 IMPLEMENT_STANDARD_TYPE(Sample_Point)
2797 IMPLEMENT_STANDARD_SUPERTYPE(MMgt_TShared)
2798 IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient)
2799 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
2800 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(MMgt_TShared)
2801 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient)
2802 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
2803 IMPLEMENT_STANDARD_TYPE_END(Sample_Point)
2804
2805 // Constructors implementation
2806
2807 Sample_Point::Sample_Point(const
2808 Standard_Real x, const Standard_Real y)
2809 {
2810 myX = x;
2811 myY = y;
2812 }
2813 Sample_Point::Sample_Point()
2814 {
2815 myX = 0.0;
2816 myY = 0.0;
2817 }
2818~~~~
2819
2820@subsection OCCT_TOVW_SECTION_8_3 When is it necessary to use a handle?
2821
2822When designing an object, the user is faced with the choice of manipulating that
2823object by value, or by handle.
2824
2825 * If your object may have a long lifetime within the application and you want to make multiple references to it, it would be preferable to manipulate this object with a handle. The memory for the object will be allocated on the heap. The handle which points to that memory is a light object which can be rapidly passed in argument. This avoids the penalty of copying a large object.
2826 * If your object will have a limited lifetime, for example, used within a single algorithm, it would be preferable to manipulate this object by value, non-regarding its size, because this object is allocated on the stack and the allocation and de-allocation of memory is extremely rapid, which avoids the implicit calls to 'new' and 'delete' occasioned by allocation on the heap.
2827 * Finally, if an object will be created only once during, but will exist throughout the lifetime of the application, the best choice may be a class manipulated by handle or a value declared as a global variable.
2828
2829
2830@subsection OCCT_TOVW_SECTION_8_4 How to cast shape handle to void
2831
2832You can easily cast a reference to the handle object to <i> void* </i> by defining the following:
2833
2834~~~~
2835 void *pointer;
2836 Handle(Some_class) aHandle;
2837 // Here only a pointer will be copied
2838 Pointer = &aHandle;
2839 // Here the Handle object will be copied
2840 aHandle = * (Handle(Some_Class) *)pointer;
2841~~~~
2842
2843@subsection OCCT_TOVW_SECTION_8_5 How to test correct ending of OCCT algorithms
2844
2845Generally OCCT algorithms implement <i> IsDone</i> method, which returns <i> true</i>
2846if computation has been performed successfully from beginning to end or <i> false</i> if computation has failed.
2847
2848When <i> IsDone</i> returns <i> true</i>, the computation is successful regarding
2849to the input data, but it does not necessary mean that you get a result. For example, if
2850you perform a cut algorithm between two shapes without any common part, the <i> IsDone</i>
2851method will return <i> true</i>, but the result will be empty.
2852
2853So, in some cases, it can be necessary to analyse the structure of a result before
2854using it again in following computations. These tests are not done systematically
2855into algorithms to get faster computations. The application performs necessary tests
2856depending on the context.
2857
2858@subsection OCCT_TOVW_SECTION_8_6 How to cut, copy and paste inside a document
2859
2860To cut, copy and paste inside a document, you must use the <i> CopyLabel</i> class from the <i> TDF</i> package.
2861In fact, you must define a Label which contains the temporary value a cut or
2862copy operation (say, in <i> Lab_Clipboard</i>). You must also define two other labels:
2863
2864* One containing the data (e.g. <i> Lab_source</i>)
2865* One for the destination of the copy (e.g. <i> Lab_ Target</i> )
2866
2867~~~~
2868 Copy = copy (Lab_Source => Lab_Clipboard)
2869 Cut = copy + Lab_Source.ForgetAll() // command clear the contents of LabelSource.
2870 Paste = copy (Lab_Clipboard => Lab_target)
2871~~~~
2872
2873So we need a tool to copy all (or a part) of the content of a label and its sub-label,
2874to another place defined by a label.
2875
2876~~~~
2877 TDF_CopyLabel aCopy;
2878 TDF_IDFilter aFilter (Standard_False);
2879
2880 //Don't copy TDataStd_TreeNode attribute
2881
2882 aFilter.Ignore(TDataStd_TreeNode::GetDefaultTreeID());
2883 aCopy.Load(aSource, aTarget); aCopy.UseFilter(aFilter); aCopy.Perform();
2884
2885 // copy the data structure to clipboard
2886
2887 return aCopy.IsDone(); }
2888~~~~
2889
2890The filter is used to forbid copying a specified type of attribute.
e5bd0d98 2891You can also have a look at *TDF_Closure**,
dba69de2 2892which can be useful to determine the dependencies of the part you want to cut from the document.
2893
2894@subsection OCCT_TOVW_SECTION_8_7 Platform-related problems
2895
2896### Dynamic library loading
2897
2898Open CASCADE Technology uses a dynamic library loading mode. Sometimes, the error message such as the following appears:
2899
2900~~~~
e5bd0d98 2901 "cannot map libname.so .. under any of the filenames .."
dba69de2 2902~~~~
2903
e5bd0d98 2904When this happens, check your *PATH* under Windows, *LD_LIBRARY_PATH* under UNIX ,
2905*SHLIB_PATH* under HP-UX or *LIBPATH* under IBM AIX .
dba69de2 2906It should contain the path where the required dynamic library is located.
2907
2908### Running Draw under Windows
2909
2910
2911When running <i> DRAWEXE</i> and using axo in the Command window you may see the "Invalid command name "axo" " message :
2912
2913Make sure that the OCCT directory name does not contain any blank spaces.
2914It causes some problems when reading the OCCT description TCL Commands files.
e5bd0d98 2915If you have set <i> DRAWHOME</i> and <i> DRAWDEFAULT</i>, replace \\ by / in the variable.
dba69de2 2916
2917### Error on application start on Windows
2918
2919If Windows shows an error message with the text *Application failed to initialize properly*
2920upon launching the application, check access rights for all libraries used in the application, in particular, third-party libraries.
2921
2922Make sure that you have all rights necessary to access these libraries.
2923It is recommended to use option *Inherit access rights from parent*.
2924
2925### Problems with 3D viewer
2926
2927
2928If the 3D viewer fails to display the scene properly, or works very slowly, or exhibits
2929another problem, make sure to have the latest version of the graphics card driver
2930installed. If this is not possible or does not help, try to decrease
2931hardware acceleration level (usually found in Troubleshooting section of the graphics card properties).