Update testing cases due to changes of issue 24130
[occt.git] / dox / user_guides / step / step.md
CommitLineData
72b7576f 1STEP processor {#user_guides__step}
2========================
3
dba69de2 4@section occt_step_1 Overview
72b7576f 5
6This manual is intended to provide technical documentation on the Open CASCADE Technology (**OCCT**) STEP processor and to help Open CASCADE Technology users with the use of the STEP processor (to read and write STEP files). STEP files conforming to AP 214, AP 203 and partially AP 209 can be read. STEP files that are produced by this interface conform to STEP AP 214 or AP 203, according to the user option.
dba69de2 7
8Only geometrical, topological STEP entities (shapes) and assembly structures are translated by the basic translator described in sections 2 to 6. Data that cannot be translated on this level are also loaded from a STEP file and can be translated later. XDE STEP translator (see section 7 <a href="#occt_step_7">Reading from and writing to XDE</a>) translates names, colors, layers, validation properties and other data associated with shapes and assemblies into XDE document.
9
72b7576f 10File translation is performed in the programming mode, via C++ calls.
72b7576f 11
dba69de2 12For testing the STEP component in DRAW Test Harness, a set of commands for reading and writing STEP files and analysis of relevant data are provided by the *TKXSDRAW* plugin.
13
14@section occt_step_2 Reading STEP
15@subsection occt_step_2_1 Procedure
72b7576f 16You can translate a STEP file into an OCCT shape in the following steps:
171. load the file,
182. check file consistency,
193. set the translation parameters,
204. perform the translation,
215. fetch the results.
dba69de2 22@subsection occt_step_2_2 Domain covered
23@subsubsection occt_step_2_2_1 Assemblies
24The **ProSTEP Round Table Agreement Log** (version July 1998), item 21, defines two alternatives for the implementation of assembly structure representations: using mapped_item entities and using representation_relationship_with_transformation entities. Both these alternative representations are recognized and processed at reading. On writing, the second alternative is always employed.
25
72b7576f 26Handling of assemblies is implemented in two separate levels: firstly STEP assembly structures are translated into OCCT shapes, and secondly the OCCT shape representing the assembly is converted into any data structure intended for representing assemblies (for example, OCAF).
dba69de2 27
72b7576f 28The first part of this document describes the basic STEP translator implementing translation of the first level, i.e. translation to OCCT Shapes. On this level, the acyclic graph representing the assembly structure in a STEP file is mapped into the structure of nested TopoDS_Compounds in Open CASCADE Technology. The (sub)assemblies become (sub)compounds containing shapes which are the results of translating components of that (sub)assembly. The sharing of components of assemblies is preserved as Open CASCADE Technology sharing of subshapes in compounds.
dba69de2 29
72b7576f 30The attributive information attached to assembly components in a STEP file (such as names and descriptions of products, colors, layers etc.) can be translatd after the translation of the shape itself by parsing the STEP model (loaded in memory). Several tools from the package STEPConstruct provide functionalities to read styles (colors), validation properties, product information etc.
dba69de2 31Implementation of the second level of translation (conversion to XDE data structure) is provided by XDE STEP translator.
32
33@subsubsection occt_step_2_2_2 Shape representations
72b7576f 34Length units, plane angle units and the uncertainty value are taken from shape_representation entities. This data is used in the translation process.
dba69de2 35
72b7576f 36The types of STEP representation entities that are recognized are:
37 * advanced_brep_shape_representation
38 * faceted_brep_shape_representation
39 * manifold_surface_shape_representation
40 * geometrically_bounded_wireframe_shape_representation
41 * geometrically_bounded_surface_shape_representation
42 * hybrid representations (shape_representation containing models of different type)
dba69de2 43
44@subsubsection occt_step_2_2_3 Topological entities
72b7576f 45The types of STEP topological entities that can be translated are:
46 * vertices
47 * edges
48 * loops
49 * faces
50 * shells
51 * solids
dba69de2 52For further information see <a href="#occt_step_2_4">Mapping STEP entities to Open CASCADE Technology shapes</a>.
53
54@subsubsection occt_step_2_2_4 Geometrical entities
72b7576f 55The types of STEP geometrical entities that can be translated are:
56 * points
57 * vectors
58 * directions
59 * curves
60 * surfaces
dba69de2 61
72b7576f 62For further information see 2.4 Mapping STEP entities to Open CASCADE Technology shapes.
dba69de2 63
64@subsection occt_step_2_3 Description of the process
65@subsubsection occt_step_2_3_1 Loading the STEP file
66
72b7576f 67Before performing any other operation you have to load the file with:
dba69de2 68~~~~~
72b7576f 69STEPControl_Reader reader;
70IFSelect_ReturnStatus stat = reader.ReadFile(;filename.stp;);
dba69de2 71~~~~~
72b7576f 72Loading the file only memorizes the data, it does not translate it.
dba69de2 73
74@subsubsection occt_step_2_3_2 Checking the STEP file
72b7576f 75This step is not obligatory. Check the loaded file with:
dba69de2 76~~~~~
72b7576f 77reader.PrintCheckLoad(failsonly,mode);
dba69de2 78~~~~~
72b7576f 79Error messages are displayed if there are invalid or incomplete STEP entities, giving you the information on the cause of error.
dba69de2 80
81If *failsonly* is true only fail messages are displayed. All messages are displayed if *failsonly* is false. Your analysis of the file can be either message-oriented or entity-oriented. Choose your preference with:
82~~~~~
72b7576f 83IFSelect_PrintCount mode = IFSelect_xxx
dba69de2 84~~~~~
72b7576f 85Where xxx can be one of the following:
dba69de2 86* *ItemsByEntity* - gives a sequential list of all messages per STEP entity,
87* *CountByItem* - gives the number of STEP entities with their types per message
88* *ListByItem* - gives the number of STEP entities with their types and rank numbers per message
89
90@subsubsection occt_step_2_3_3 Setting the translation parameters
72b7576f 91The following parameters can be used to translate a STEP file into an OCCT shape.
dba69de2 92
72b7576f 93If you give a value that is not within the range of possible values it will simply be ignored.
dba69de2 94
72b7576f 95<h4>read.precision.mode</h4>
96Defines which precision value will be used during translation (see section 2.5 below for details on precision and tolerances).
dba69de2 97* *File (0)* - the precision value is set to length_measure in uncertainty_measure_with_unit from STEP file.
98* *User (1)* - the precision value is that of the *read.precision.val* parameter.
99
72b7576f 100Read this parameter with:
dba69de2 101
102~~~~~
103Standard_Integer ic = Interface_Static::IVal("read.precision.mode");
104~~~~~
72b7576f 105Modify this parameter with:
dba69de2 106~~~~~
107if(!Interface_Static::SetIVal("read.precision.mode",1))
72b7576f 108.. error ..
dba69de2 109~~~~~
110Default value is File (0).
111
72b7576f 112<h4>read.precision.val:</h4>
dba69de2 113User defined precision value. This parameter gives the precision for shape construction when the read.precision.mode parameter value is 1. By default it is 0.0001, but can be any real positive (non null) value.
114
72b7576f 115This value is a basic value of tolerance in the processor. The value is in millimeters, independently of the length unit defined in the STEP file.
dba69de2 116
72b7576f 117Read this parameter with:
dba69de2 118~~~~~
119Standard_Real rp = Interface_Static::RVal("read.precision.val");
120~~~~~
72b7576f 121Modify this parameter with:
dba69de2 122~~~~~
123if(!Interface_Static::SetRVal("read.precision.val",0.01))
72b7576f 124.. error ..
dba69de2 125~~~~~
126By default this value is 0.0001.
127
72b7576f 128The value given to this parameter is a basic value for ShapeHealing algorithms and the processor. It does its best to reach it. Under certain circumstances, the value you give may not be attached to all of the entities concerned at the end of processing. STEP-to-OpenCASCADE translation does not improve the quality of the geometry in the original STEP file. This means that the value you enter may be impossible to attach to all shapes with the given quality of the geometry in the STEP file.
dba69de2 129
72b7576f 130<h4>read.maxprecision.val</h4>
dba69de2 131Defines the maximum allowed tolerance (in mm) of the shape. It should be not less than the basic value of tolerance set in the processor (either the uncertainty from the file or *read.precision.val*). Actually, the maximum between *read.maxprecision.val* and the basis tolerance is used to define the maximum allowed tolerance.
132
72b7576f 133Read this parameter with:
dba69de2 134~~~~~
135Standard_Real rp = Interface_Static::RVal("read.maxprecision.val");
136~~~~~
72b7576f 137Modify this parameter with:
dba69de2 138~~~~~
139if(!Interface_Static::SetRVal("read.maxprecision.val",0.1))
72b7576f 140.. error ..
dba69de2 141~~~~~
142
72b7576f 143Default value is 1.
144Note that maximum tolerance even explicitly defined by the user may be insufficient to ensure the validity of the shape (if real geometry is of bad quality). Therefore the user is provided with an additional parameter, which allows him to choose: either he prefers to ensure the shape validity or he rigidly sets the value of maximum tolerance. In the first case there is a possibility that the tolerance will not have any upper limit, in the second case the shape may be invalid.
dba69de2 145
72b7576f 146<h4>read.maxprecision.mode:</h4>
147Defines the mode of applying the maximum allowed tolerance. Its possible values are:
dba69de2 148* 0 (Preferred) - maximum tolerance is used as a limit but sometimes it can be exceeded (currently, only for deviation of a 3D curve and pcurves of an edge, and vertices of such edge) to ensure the shape validity,
149* 1 (Forced) - maximum tolerance is used as a rigid limit, i.e. no tolerance can exceed it and if it is the case, the tolerance is trimmed by the maximum tolerance.
150
72b7576f 151Read this parameter with:
dba69de2 152~~~~~
153Standard_Integer ic = Interface_Static::IVal("read.maxprecision.mode");
154~~~~~
72b7576f 155Modify this parameter with:
dba69de2 156~~~~~
157if(!Interface_Static::SetIVal("read.maxprecision.mode",1))
72b7576f 158.. error ..
dba69de2 159~~~~~
160Default value is 0 ("Preferred").
161
72b7576f 162<h4>read.stdsameparameter.mode</h4>
dba69de2 163defines the use of *BRepLib::SameParameter*. Its possible values are:
164
165* 0 (Off) - *BRepLib::SameParameter* is not called,
166* 1 (On) - *BRepLib::SameParameter* is called.
167The functionality of *BRepLib::SameParameter* is used through *ShapeFix_Edge::SameParameter*. It ensures that the resulting edge will have the lowest tolerance taking pcurves either unmodified from the STEP file or modified by *BRepLib::SameParameter*.
168
72b7576f 169Read this parameter with:
dba69de2 170~~~~~
171Standard_Integer mv = Interface_Static::IVal("read.stdsameparameter.mode");
172~~~~~
72b7576f 173Modify this parameter with:
dba69de2 174~~~~~
175if (!Interface_Static::SetIVal ("read.stdsameparameter.mode",1))
72b7576f 176.. error ..;
dba69de2 177~~~~~
178Default value is 0 (;Off;).
179
72b7576f 180<h4>read.surfacecurve.mode:</h4>
181a preference for the computation of curves in an entity which has both 2D and 3D representation.
dba69de2 182Each *TopoDS_Edge* in *TopoDS_Face* must have a 3D and 2D curve that references the surface.
183
72b7576f 184If both 2D and 3D representation of the entity are present, the computation of these curves depends on the following values of parameter:
dba69de2 185* *Default (0)* : no preference, both curves are taken (default value),
186* *3DUse_Preferred (3)* : 3D curves are used to rebuild 2D ones.
187
72b7576f 188Read this parameter with:
dba69de2 189~~~~~
190Standard_Integer rp = Interface_Static::IVal("read.surfacecurve.mode");
191~~~~~
72b7576f 192Modify this parameter with:
dba69de2 193~~~~~
194if(!Interface_Static::SetIVal("read.surfacecurve.mode",3))
72b7576f 195.. error ..
dba69de2 196~~~~~
72b7576f 197Default value is (0).
dba69de2 198
72b7576f 199<h4>read.encoderegularity.angle</h4>
dba69de2 200
201This parameter is used for call to *BRepLib::EncodeRegularity()* function which is called for the shape read from an IGES or a STEP file at the end of translation process. This function sets the regularity flag of the edge in the shell when this edge is shared by two faces. This flag shows the continuity these two faces are connected with at that edge.
72b7576f 202Read this parameter with:
dba69de2 203~~~~~
204Standard_Real era = Interface_Static::RVal("read.encoderegularity.angle");
205~~~~~
72b7576f 206Modify this parameter with:
dba69de2 207~~~~~
208if (!Interface_Static::SetRVal ("read.encoderegularity.angle",0.1))
72b7576f 209.. error ..;
dba69de2 210~~~~~
72b7576f 211Default value is 0.01.
dba69de2 212
72b7576f 213<h4>step.angleunit.mode</h4>
214This parameter is obsolete (it was required in the past for STEP files with a badly encoded angle unit). It indicates what angle units should be used when a STEP file is read: the units from file (default), or forced RADIANS or DEGREES.
dba69de2 215
72b7576f 216Default value is File
dba69de2 217
218<h4>read.step.resource.name and read.step.sequence</h4>
219
72b7576f 220These two parameters define the name of the resource file and the name of the sequence of operators (defined in that file) for Shape Processing, which is automatically performed by the STEP translator. Shape Processing is a user-configurable step, which is performed after translation and consists in applying a set of operators to a resulting shape. This is a very powerful tool allowing customizing the shape and adapting it to the needs of a receiving application. By default the sequence consists of a single operator ShapeFix - that is how Shape Healing is called from the STEP translator.
dba69de2 221
222Please find an example of the resource file for STEP (which defines parameters corresponding to the sequence applied by default, i.e. if the resource file is not found) in the Open CASCADE Technology installation, by the path <i>%CASROOT%/src/XSTEPResource/STEP</i>.
223
224In order for the STEP translator to use that file, you have to define the *CSF_STEPDefaults* environment variable, which should point to the directory where the resource file resides. Note that if you change parameter *read.step.resource.name*, you will change the name of the resource file and the environment variable correspondingly.
225
226Default values:
227* read.step.resource.name - STEP,
228* read.step.sequence - FromSTEP.
229
72b7576f 230<h4>read.scale.unit</h4>
dba69de2 231This parameter is obsolete (the parameter *xstep.cascade.unit* should be used instead when necessary). If it is set to 'M', the shape is scaled 0.001 times (as if it were in meters) after translation from IGES or STEP.
72b7576f 232Default value is MM.
dba69de2 233
72b7576f 234<h4>xstep.cascade.unit</h4>
235This parameter defines units to which a shape should be converted when translated from IGES or STEP to CASCADE. Normally it is MM; only those applications that work internally in units other than MM should use this parameter.
dba69de2 236
72b7576f 237Default value is MM.
dba69de2 238
72b7576f 239<h4>read.step.product.mode:</h4>
240Defines the approach used for selection of top-level STEP entities for translation, and for recognition of assembly structures
dba69de2 241* 1 (ON) - *PRODUCT_DEFINITION* entities are taken as top-level ones; assembly structure is recognized by *NEXT_ASSEMBLY_USAGE_OCCURRENCE* entities. This is regular mode for reading valid STEP files conforming to AP 214, AP203 or AP 209.
242* 0 (OFF) - *SHAPE_DEFINITION_REPRESENTATION* entities are taken as top-level ones; assembly is recognized by *CONTEXT_DEPENDENT_SHAPE_REPRESENTATION* entities. This is compatibility mode, which can be used for reading legacy STEP files produced by older versions of STEP translators and having incorrect or incomplete product information.
243
72b7576f 244Read this parameter with:
dba69de2 245~~~~~
246Standard_Integer ic = Interface_Static::IVal("read.step.product.mode");
247~~~~~
248
72b7576f 249Modify this parameter with:
dba69de2 250~~~~~
251if(!Interface_Static::SetIVal("read.step.product.mode",1))
72b7576f 252.. error ..
dba69de2 253~~~~~
254Default value is 1 (ON).
255
256Note that the following parameters have effect only if *read.step.product.mode* is ON.
257
72b7576f 258<h4>read.step.product.context:</h4>
dba69de2 259
72b7576f 260When reading AP 209 STEP files, allows selecting either only ‘design’ or ‘analysis’, or both types of products for translation
dba69de2 261* 1 (all) - translates all products;
262* 2 (design) - translates only products that have *PRODUCT_DEFINITION_CONTEXT* with field *life_cycle_stage* set to ‘design’;
263* 3 (analysis) - translates only products associated with *PRODUCT_DEFINITION_CONTEXT* entity whose field *life_cycle_stage* set to ‘analysis’.
264
72b7576f 265Note that in AP 203 and AP214 files all products should be marked as ‘design’, so if this mode is set to ‘analysis’, nothing will be read.
dba69de2 266
72b7576f 267Read this parameter with:
dba69de2 268~~~~~
269Standard_Integer ic = Interface_Static::IVal("read.step.product.context");
270~~~~~
271
72b7576f 272Modify this parameter with:
dba69de2 273~~~~~
72b7576f 274if(!Interface_Static::SetIVal(;read.step.product.context;,1))
275.. error ..
dba69de2 276~~~~~
277Default value is 1 (all).
278
72b7576f 279<h4>read.step.shape.repr:</h4>
dba69de2 280
72b7576f 281Specifies preferred type of representation of the shape of the product, in case if a STEP file contains more than one representation (i.e. multiple PRODUCT_DEFINITION_SHAPE entities) for a single product
dba69de2 282* 1 (All) - Translate all representations (if more than one, put in compound).
283* 2 (ABSR) - Prefer ADVANCED_BREP_SHAPE_REPRESENTATION
284* 3 (MSSR) - Prefer MANIFOLD_SURFACE_SHAPE_REPRESENTATION
285* 4 (GBSSR) - Prefer GEOMETRICALLY_BOUNDED_SURFACE_SHAPE_REPRESENTATION
286* 5 (FBSR) - Prefer FACETTED_BREP_SHAPE_REPRESENTATION
287* 6 (EBWSR) - Prefer EDGE_BASED_WIREFRAME_SHAPE_REPRESENTATION
288* 7 (GBWSR) - Prefer GEOMETRICALLY_BOUNDED_WIREFRAME _SHAPE_REPRESENTATION
289
72b7576f 290When this option is not equal to 1, for products with multiple representations the representation having a type closest to the selected one in this list will be translated.
dba69de2 291
72b7576f 292Read this parameter with:
dba69de2 293~~~~~
294Standard_Integer ic = Interface_Static::IVal("read.step.shape.repr");
295~~~~~
72b7576f 296Modify this parameter with:
dba69de2 297~~~~~
298if(!Interface_Static::SetIVal("read.step.shape.repr",1))
72b7576f 299.. error ..
dba69de2 300~~~~~
301Default value is 1 (All).
302
72b7576f 303<h4>read.step.assembly.level:</h4>
dba69de2 304
72b7576f 305Specifies which data should be read for the products found in the STEP file:
dba69de2 306* 1 (All) - Translate both the assembly structure and all associated shapes. If both shape and sub-assemblies are associated with the same product, all of them are read and put in a single compound. Note that this situation is confusing, as semantics of such configuration is not defined clearly by the STEP standard (whether this shape is an alternative representation of the assembly or is an addition to it), therefore warning will be issued in such case.
307* 2 (assembly) - Translate the assembly structure and shapes associated with parts only (not with sub-assemblies).
308* 3 (structure) - Translate only the assembly structure without shapes (a structure of empty compounds). This mode can be useful as an intermediate step in applications requiring specialized processing of assembly parts.
309* 4 (shape) - Translate only shapes associated with the product, ignoring the assembly structure (if any). This can be useful to translate only a shape associated with specific product, as a complement to *assembly* mode.
310
72b7576f 311Read this parameter with:
dba69de2 312~~~~~
313Standard_Integer ic = Interface_Static::IVal("read.step.assembly.level");
314~~~~~
72b7576f 315Modify this parameter with:
dba69de2 316~~~~~
317if(!Interface_Static::SetIVal("read.step.assembly.level",1))
72b7576f 318.. error ..
dba69de2 319~~~~~
320
321Default value is 1 (All).
322
72b7576f 323<h4>read.step.shape.relationship:</h4>
dba69de2 324Defines whether shapes associated with the main *SHAPE_DEFINITION_REPRESENTATION* entity of the product via *SHAPE_REPRESENTATIONSHIP_RELATION* should be translated. This kind of association is used for the representation of hybrid models (i.e. models whose shape is composed of different types of representations) in AP 203 files since 1998, but it can be also used to associate auxiliary data with the product. This parameter allows to avoid translation of such auxiliary data.
325* 1 (ON) - translate
326* 0 (OFF) - do not translate
327
72b7576f 328Read this parameter with:
dba69de2 329~~~~~
330Standard_Integer ic = Interface_Static::IVal("read.step.shape.relationship");
331~~~~~
72b7576f 332Modify this parameter with:
dba69de2 333~~~~~
72b7576f 334if(!Interface_Static::SetIVal(;read.step.shape.relationship;,1))
335.. error ..
dba69de2 336~~~~~
337Default value is 1 (ON).
338
72b7576f 339<h4>read.step.shape.aspect:</h4>
dba69de2 340Defines whether shapes associated with the *PRODUCT_DEFINITION_SHAPE* entity of the product via *SHAPE_ASPECT* should be translated. This kind of association was used for the representation of hybrid models (i.e. models whose shape is composed of different types of representations) in AP 203 files before 1998, but it is also used to associate auxiliary information with the sub-shapes of the part. Though STEP translator tries to recognize such cases correctly, this parameter may be useful to avoid unconditionally translation of shapes associated via *SHAPE_ASPECT* entities.
341
342* 1 (ON) - translate
343* 0 (OFF) - do not translate
344
72b7576f 345Read this parameter with:
dba69de2 346~~~~~
347Standard_Integer ic = Interface_Static::IVal("read.step.shape.aspect");
348~~~~~
349
72b7576f 350Modify this parameter with:
dba69de2 351~~~~~
72b7576f 352if(!Interface_Static::SetIVal(;read.step.shape.aspect;,1))
353.. error ..
dba69de2 354~~~~~
355Default value is 1 (ON).
356
357@subsubsection occt_step_2_3_4 Performing the STEP file translation
358
72b7576f 359Perform the translation according to what you want to translate. You can choose either root entities (all or selected by the number of root), or select any entity by its number in the STEP file. There is a limited set of types of entities that can be used as starting entities for translation. Only the following entities are recognized as transferable:
360 * product_definition
361 * next_assembly_usage_occurrence
362 * shape_definition_representation
363 * subtypes of shape_representation (only if referred representation is transferable)
364 * manifold_solid_brep
365 * brep_with_voids
366 * faceted_brep
367 * faceted_brep_and_brep_with_voids
368 * shell_based_surface_model
369 * geometric_set and geometric_curve_set
370 * mapped_item
371 * subtypes of face_surface (including advanced_face)
372 * subtypes of shape_representation_relationship
373 * context_dependent_shape_representation
dba69de2 374
375The following methods are used for translation:
376
377* *Standard_Boolean ok = reader.TransferRoot(rank)* - translates a root entity identified by its rank;
378* *Standard_Boolean ok = reader.TransferOne(rank)* - translates an entity identified by its rank;
379* *Standard_Integer num = reader.TransferList(list)* - translates a list of entities in one operation (this method returns the number of successful translations);
380* *Standard_Integer NbRoots = reader.NbRootsForTransfer()* and *Standard_Integer num = reader.TransferRoots()* - translate all transferable roots.
381
382@subsubsection occt_step_2_3_5 Getting the translation results
72b7576f 383Each successful translation operation outputs one shape. A series of translations gives a set of shapes.
dba69de2 384
385Each time you invoke *TransferOne(), TransferRoot()* or *TransferList()*, their results are accumulated and the counter of results increases. You can clear the results with:
386~~~~~
72b7576f 387reader.ClearShapes();
dba69de2 388~~~~~
72b7576f 389between two translation operations, if you do not, the results from the next translation will be added to the accumulation.
dba69de2 390
391*TransferRoots()* operations automatically clear all existing results before they start.
392* *Standard_Integer num = reader.NbShapes()* - gets the number of shapes recorded in the result;
393* *TopoDS_Shape shape = reader.Shape(rank)* gets the result identified by its rank, where rank is an integer between 1 and NbShapes;
394* *TopoDS_Shape shape = reader.Shape()* gets the first result of translation;
395* *TopoDS_Shape shape = reader.OneShape()* - gets all results in a single shape which is:
396 * a null shape if there are no results,
397 * in case of a single result, a shape that is specific to that result,
398 * a compound that lists the results if there are several results.
399
72b7576f 400<h5>Clearing the accumulation of results</h5>
dba69de2 401
402If several individual translations follow each other, the results give a list that can be purged with *reader.ClearShapes()*, which erases the existing results.
403
72b7576f 404<h5>Checking that translation was correctly performed</h5>
dba69de2 405Each time you invoke *Transfer* or *TransferRoots()*, you can display the related messages with the help of:
406~~~~~
72b7576f 407reader.PrintCheckTransfer(failsonly,mode);
dba69de2 408~~~~~
409
410This check concerns the last invocation of *Transfer* or *TransferRoots()* only.
411
412@subsubsection occt_step_2_3_6 Selecting STEP entities for translation
413
72b7576f 414<h4>Selection possibilities</h4>
dba69de2 415
72b7576f 416There are three selection possibilities. You can select:
417 * the whole file,
418 * a list of entities,
419 * one entity.
dba69de2 420
421<h5>Whole file</h5>
422
72b7576f 423Transferring the whole file means transferring all root entities. The number of roots can be evaluated when the file is loaded:
dba69de2 424~~~~~
72b7576f 425Standard_Integer NbRoots = reader.NbRootsForTransfer();
426Standard_Integer num = reader.TransferRoots();
dba69de2 427~~~~~
428
429<h4>List of entities</h4>
430A list of entities can be formed by invoking *STEP214Control_Reader::GiveList* (this is a method of the parent class).
431
72b7576f 432Here is a simple example of how a list is translated:
dba69de2 433~~~~~
72b7576f 434Handle(TColStd_HSequenceOfTransient) list = reader.GiveList();
dba69de2 435~~~~~
436The result is a *TColStd_HSequenceOfTransient*.
72b7576f 437You can either translate a list entity by entity or all at once. An entity-by-entity operation lets you check each individual entity translated.
dba69de2 438
72b7576f 439<h5>Translating a whole list in one operation</h5>
dba69de2 440~~~~~
72b7576f 441Standard_Integer nbtrans = reader.TransferList (list);
dba69de2 442~~~~~
443*nbtrans* gives the number of items in the list that produced a shape.
444
72b7576f 445<h5>Translating a list entity by entity:</h5>
dba69de2 446~~~~~
447Standard_Integer i,nb = list->Length();
448for (i = 1; i <= nb; i ++) {
449 Handle(Standard_Transient) ent = list->Value(i);
450 Standard_Boolean OK = reader.TransferEntity (ent);
451}
452~~~~~
453
72b7576f 454<h4>Selections</h4>
455There is a number of predefined operators that can be used. They are:
dba69de2 456 * *step214-placed-items* - selects all mapped_items or context_depended_shape_representations.
457 * *step214-shape-def-repr* - selects all shape_definition_representations.
458 * *step214-shape-repr* - selects all shape_representations.
459 * *step214-type(<entity_type>)* - selects all entities of a given type
460 * *step214-faces* - selects all faces_surface, advanced_face entities and the surface entity or any sub type if these entities are not shared by any face entity or shared by geometric_set entity.
461 * *step214-derived(<entity_type>)* - selects entities of a given type or any subtype.
462 * *step214-GS-curves* - selects all curve entities or any subtype except the composite_curve if these entities are shared by the geometric_set entity.
463 * *step214-assembly* - selects all mapped_items or context_depended_shape_representations involved into the assembly structure.
464 * *xst-model-all* - selects all entities.
465 * *xst-model-roots* - selects all roots.
466 * *xst-shared + <selection>* - selects all entities shared by at least one entity selected by selection.
467 * *xst-sharing + <selection>* - selects all entities sharing at least one entity selected by selection.
468 * *xst-transferrable-all* - selects all transferable entities.
469 * *xst-transferrable-roots* selects all translatable roots.
470Cumulative lists can be used as well.
471
472<h5>Single entities</h5>
473You can select an entity either by its rank or by its handle (an entity’s handle can be obtained by invoking the *StepData_StepModel::Entity* function).
474
72b7576f 475<h5>Selection by rank</h5>
dba69de2 476Use method *StepData_StepModel::NextNumberForLabel* to find its rank with the following:
477~~~~~
72b7576f 478Standard_CString label = ‘#...’;
479StepData_StepModel model = reader.StepModel();
dba69de2 480rank = model->NextNumberForLabe(label, 0, Standard_False);
481~~~~~
72b7576f 482Translate an entity specified by its rank:
dba69de2 483~~~~~
72b7576f 484Standard_Boolean ok = reader.Transfer (rank);
dba69de2 485~~~~~
486
72b7576f 487<h5>Direct selection of an entity</h5>
dba69de2 488*ent* is the entity. The argument is a *Handle(Standard_Transient)*.
489~~~~~
72b7576f 490Standard_Boolean ok = reader.TransferEntity (ent);
dba69de2 491~~~~~
492
493@subsection occt_step_2_4 Mapping STEP entities to Open CASCADE Technology shapes
72b7576f 494Tables given in this paragraph show the mapping of STEP entities to OCCT objects. Only topological and geometrical STEP entities and entities defining assembly structures are described in this paragraph. For a full list of STEP entities please refer to Appendix A.
dba69de2 495
496@subsubsection occt_step_2_4_1 Assembly structure representation entities
72b7576f 497Not all entities defining the assembly structure in the STEP file are translated to OCCT shapes, but they are used to identify the relationships between assemblies and their components. Since the graph of ‘natural’ dependencies of entities based on direct references between them does not include the references from assemblies to their components, these dependencies are introduced in addition to the former ones. This is made basing on the analysis of the following entities describing the structure of the assembly.
498
dba69de2 499| STEP entity type | CASCADE shape | Comments |
500
501product_definition For assemblies, a TopoDS_Compound,
502for components, a CASCADE shape corresponding to the type of component Each assembly or component has its own product_definition. It is used as a starting point for translation when read.step.product.mode is ON
503product_definition_shape This entity provides a link between product_definition and corresponding shape_definition_representation, or between next_assembly_usage_occurence and corresponding context_dependent_shape_representation
504shape_definition_representation For assemblies, a TopoDS_Compound,
505for components, a CASCADE shape corresponding to the type of component Each assembly or component has its own shape_definition_representation. The graph of dependencies is modified in such a way that shape_definition_representations of all components of the assembly are referred by the shape_definition_representation of the assembly.
506next_assembly_usage_occurence This entity defines a relationship between the assembly and its component. It is used to introduce (in the dependencies graph) the links between shape_definition_representation of the assembly and shape_definition_representations and context_dependent_shape_representations of all its components.
507mapped_item TopoDS_Shape This entity defines a mapping of the assembly component into the shape_representation of the assembly. The result of translation is a CASCADE shape translated from the component, to which transformation defined by the mapped_item is applied.
508context_dependent_shape_representation TopoDS_Shape This entity is associated with the next_assembly_usage_occurence entity and defines a placement of the component in the assembly. The graph of dependencies is modified so that each context_dependent_shape_representation is referred by shape_definition_representation of the corresponding assembly.
509shape_representation_relationship_with_transformation This entity is associated with context_dependent_shape_representation and defines a transformation necessary to apply to the component in order to locate it in its place in the assembly.
510item_defined_transformation This entity defines a transformation operator used by shape_representation_relationship_with_transformation or mapped_item entity
511cartesian_transformation_operator This entity defines a transformation operator used by shape_representation_relationship_with_transformation or mapped_item entity
512
513@subsubsection occt_step_2_4_2 Models
514STEP entity type CASCADE shape Comments
515Solid Models
516brep_with_voids TopoDS_Solid
517faceted_brep TopoDS_Solid
518manifold_solid_brep TopoDS_Solid
519Surface Models
520shell_based_surface_model TopoDS_Compound shell_based_surface_model is translated into one or more TopoDS_Shell grouped in a TopoDS_Compound
521geometric_set TopoDS_Compound TopoDS_Compound contains only TopoDS_Faces, TopoDS_Wires, TopoDS_Edges and/or TopoDS_Vertices
522Wireframe Models
523geometric_curve_set TopoDS_Compound TopoDS_Compound contains only TopoDS_Wires, TopoDS_Edges and/or TopoDS_Vertices
72b7576f 524
dba69de2 525@subsubsection occt_step_2_4_3 Topological entities
526STEP entity type CASCADE shape Comments
527Vertices
528vertex_point TopoDS_Vertex
529Edges
530oriented_edge TopoDS_Edge
531edge_curve TopoDS_Edge
532Loops
533face_bound TopoDS_Wire
534face_outer_bound TopoDS_Wire
535edge_loop TopoDS_Wire
536poly_loop TopoDS_Wire Each segment of poly_loop is translated into TopoDS_Edge with support of Geom_Line
537vertex_loop TopoDS_Wire Resulting TopoDS_Wire contains only one degenerated TopoDS_Edge
538Faces
539face_surface TopoDS_Face
540advanced_face TopoDS_Face
541Shells
542connected_face_set TopoDS_Shell
543oriented_closed_shell TopoDS_Shell
544closed_shell TopoDS_Shell
545open_shell TopoDS_Shell
72b7576f 546
547
dba69de2 548@subsubsection occt_step_2_4_4 Geometrical entities
72b7576f 5493D STEP entities are translated into geometrical objects from the Geom package while 2D entities are translated into objects from the Geom2d package.
dba69de2 550STEP entity type CASCADE object Comments
551Points
552cartesian_point Geom_CartesianPoint
553 Geom2d_CartesianPoint
554Directions
555direction Geom_Direction
556 Geom2d_Direction
557Vectors
558vector Geom_VectorWithMagnitude
559 Geom2d_VectorWithMagnitude
560Placements
561axis1_placement Geom_Axis1Placement
562axis2_placement_2d Geom2d_AxisPlacement
563axis2_placement_3d Geom_Axis2Placement
564Curves
565circle Geom_Circle
566 Geom2d_Circle
567 Geom2d_BsplineCurve Circle is translated into Geom2d_BSplineCurve when it references the surface of revolution (spherical surface, conical surface, etc.)
568ellipse Geom_Ellipse
569 Geom2d_Ellipse
570 Geom2d_BsplineCurve Ellipse is translated into Geom2d_BSplineCurve when it references the surface of revolution (spherical surface, conical surface, etc.)
571hyperbola Geom_Hyperbola
572 Geom2d_Hyperbola
573line Geom_Line
574 Geom2d_Line
575parabola Geom_Parabola
576 Geom2d_Parabola
577pcurve Geom2d_Curve Pcurve in edge
578curve_replica Geom_Curve Depending on the type of basis curve
579 Geom2d_Curve
580offset_curve_3d Geom_OffsetCurve
581trimmed_curve Geom_TrimmedCurve
582 Geom2d_BsplineCurve Only trimmed_curves trimmed by parameters are translated. All trimmed_curves are converted to Geom2d_BSplineCurve.
583b_spline_curve Geom_BsplineCurve
584 Geom2d_BsplineCurve
585b_spline_curve_with_
586knots Geom_BsplineCurve
587 Geom2d_BsplineCurve
588bezier_curve Geom_BsplineCurve
589 Geom2d_BsplineCurve
590rational_b_spline_curve Geom_BsplineCurve
591 Geom2d_BsplineCurve
592uniform_curve Geom_BsplineCurve
593 Geom2d_BsplineCurve
594quasi_ uniform_curve Geom_BsplineCurve
595 Geom2d_BsplineCurve
596surface_curve TopoDS_Edge surface_curve defines geometrical support of an edge and its pcurves.
597seam_curve TopoDS_Edge the same as surface_curve
598composite_curve_segment TopoDS_Edge as a segment of composite_curve
599composite_curve TopoDS_Wire
600composite_curve_on_surface TopoDS_Wire
601boundary_curve TopoDS_Wire
602Surfaces
603b_spline_surface Geom_BsplineSurface
604b_spline_surface_with_knots Geom_BsplineSurface
605bezier_surface Geom_BSplineSurface
606conical_surface Geom_ConicalSurface
607cylindrical_surface Geom_CylindricalSurface
608offset_surface Geom_OffsetSurface
609surface_replica Geom_Surface Depending on the type of basis surface
610plane Geom_Plane
611rational_b_spline_surface Geom_BSplineSurface
612rectangular_trimmed_
613surface Geom_RectangularTrimmedSurface
614spherical_surface Geom_SphericalSurface
615surface_of_linear_extrusion Geom_SurfaceOfLinearExtrusion
616surface_of_revolution Geom_SurfaceOfRevolution
617toroidal_surface Geom_ToroidalSurface
618degenerate_toroidal_surface Geom_ToroidalSurface
619uniform_surface Geom_BSplineSurface
620quasi_uniform_surface Geom_BSplineSurface
621rectangular_composite_surface TopoDS_Compound Contains TopoDS_Faces
622curve_bounded_surface TopoDS_Face
623
624
625@subsection occt_step_2_5 Tolerance management
626@subsubsection occt_step_2_5_1 Values used for tolerances during reading STEP
72b7576f 627
72b7576f 628During the STEP = OCCT translation several parameters are used as tolerances and precisions for different algorithms. Some of them are computed from other tolerances using specific functions.
dba69de2 629
72b7576f 630<h4>3D (spatial) tolerance</h4>
dba69de2 631* Package method *Precision::Confusion()* Value is 10-7. It is used as the minimal distance between points, which are considered to be distinct.
632* Uncertainty parameter is attached to each shape_representation entity in a STEP file and defined as *length_measure* in *uncertainty_measure_with_unit*. It is used as a fundamental value of precision during translation.
633* User - defined variable *read.precision.val* is used instead of uncertainty from a STEP file when parameter *read.precision.mode* is 1 (User).
634
72b7576f 635<h4>2D (parametric) tolerances</h4>
dba69de2 636* Package method *Precision::PConfusion()* is a value of *0.01\*Precision::Confusion()*. It is used to compare parametric bounds of curves.
637* Methods *UResolution* and *VResolution (tolerance3d)* of the class *GeomAdaptor_Surface* or *BRepAdaptor_Surface* - return tolerance in parametric space of a surface computed from 3d tolerance. When one tolerance value is to be used for both U and V parametric directions, the maximum or the minimum value of *UResolution* and *VResolution* is used.
638* Methods *Resolution (tolerance3d)* of the class *GeomAdaptor_Curve* or *BRepAdaptor_Curve* return tolerance in parametric space of a curve computed from 3d tolerance.
639
640@subsubsection occt_step_2_5_2 Initial setting of tolerances in translating objects
641In the STEP processor, the basic value of tolerance is set in method *STEPControl_ActorRead::Transfer()* to either value of uncertainty in shape_representation in STEP file (if parameter *read.precision.mode* is 0), or to a value of parameter *read.precision.val* (if *read.precision.mode* is 1 or if the uncertainty is not attached to the current entity in the STEP file).
642
643Translation starts from one entity translated as a root. *STEPControl_ActorRead::Transfer()*, function which performs the translation creates an object of the type *StepToTopoDS_Builder*, which is intended to translate topology.
644
645This object gets the initial tolerance value that is equal to *read.precision.val* or the uncertainty from shape_representation. During the translation of the entity, new objects of types *StepToTopoDS_Translate*... are created for translating sub-entities. All of them use the same tolerances as a *StepToTopoDS_Builder* object.
646
647@subsubsection occt_step_2_5_3 Transfer process
648
72b7576f 649<h4>Evolution of shape tolerances during transfer</h4>
650Let us follow the evolution of tolerances during the translation of STEP entities into an OCCT shape.
dba69de2 651
652If the starting STEP entity is a geometric_curve_set all the edges and vertices are constructed with *Precision::Confusion()*.
653
72b7576f 654If the starting STEP entity is not a geometric_curve_set the sub-shapes of the resulting shape have the following tolerance:
dba69de2 655 * all the faces are constructed with *Precision::Confusion()*,
656 * edges are constructed with *Precision::Confusion()*. It can be modified later by:
657 * *ShapeFix::SameParameter()* - the tolerance of edge shows real deviation of the 3D curve and pcurves.
658 * *ShapeFix_Wire::FixSelfIntersection()* if a pcurve of a self-intersecting edge is modified.
72b7576f 659 * vertices are constructed with Precision::Confusion(). It can be modified later by:
dba69de2 660 *StepToTopoDS_TranslateEdge*
661 *ShapeFix::SameParameter()*
662 *ShapeFix_Wire::FixSelfIntersection()*
663 *ShapeFix_Wire::FixLacking()*
664 *ShapeFix_Wire::Connected()*
665
72b7576f 666So, the final tolerance of sub-shapes shows the real local geometry of shapes (distance between vertices of adjacent edges, deviation of a 3D curve of an edge and its parametric curves and so on) and may be less or greater than the basic value of tolerance in the STEP processor.
dba69de2 667
72b7576f 668<h4>Translating into Geometry</h4>
dba69de2 669
670Geometrical entities are translated by classes *StepToGeom_Make...* Methods of these classes translate STEP geometrical entities into OCCT geometrical objects. Since these objects are not BRep objects, they do not have tolerances. Tolerance is used only as precision for detecting bad cases (such as points coincidence).
671
72b7576f 672<h4>Translating into Topology</h4>
dba69de2 673STEP topological entities are translated into OCCT shapes by use of classes from package *StepToTopoDS*.
674
72b7576f 675Although in a STEP file the uncertainty value is assigned to shape_representation entities and this value is applied to all entities in this shape_representation, OCCT shapes are produced with different tolerances. As a rule, updating the tolerance is fulfilled according to the local geometry of shapes (distance between vertices of adjacent edges, deviation of edge's 3D curve and its parametric curves and so on) and may be either less or greater than the uncertainty value assigned to the entity.
dba69de2 676
677The following default tolerances are used when creating shapes and how they are updated during translation.
678* *StepToTopoDS_TranslateVertex* constructs *TopoDS_Vertex* from a STEP *vertex_point* entity with *Precision::Confusion()*.
679* *StepToTopoDS_TranslateVertexLoop* creates degenerated *TopoDS_Edge* in *TopoDS_Wire* with tolerance *Precision::Confusion()*. *TopoDS_Vertex* of a degenerated edge is constructed with the initial value of tolerance.
680* *StepToTopoDS_TranslateEdge* constructs *TopoDS_Edge* only on the basis of 3D curve with *Precision::Confusion()*. Tolerance of the vertices can be increased up to a distance between their positions and ends of 3D curve.
681* *StepToTopoDS_TranslateEdgeLoop* constructs *TopoDS_Edges* in *TopoDS_Wire* with help of class *StepToTopoDS_TranslateEdge*. Pcurves from a STEP file are translated if they are present and *read.surfacecurve.mode* is 0. For each edge method *ShapeFix_Edge::FixSameParameter()* is called. If the resulting tolerance of the edge is greater than the maximum value between 1.0 and 2*Value of basis precision, then the pcurve is recomputed. The best of the original and the recomputed pcurve is put into *TopoDS_Edge*. The resulting tolerance of *TopoDS_Edge* is a maximal deviation of its 3D curve and its pcurve(s).
682* *StepToTopoDS_TranslatePolyLoop* constructs *TopoDS_Edges* in *TopoDS_Wire* with help of class *StepToTopoDS_TranslateEdge*. Their tolerances are not modified inside this method.
683* *StepToTopoDS_TranslateFace* constructs *TopoDS_Face* with the initial value of tolerance. *TopoDS_Wire* on *TopoDS_Face* is constructed with the help of classes *StepToTopoDS_TranslatePolyLoop, StepToTopoDS_TranslateEdgeLoop* or *StepToTopoDS_TranslateVertexLoop*.
684* *StepToTopoDS_TranslateShell* calls *StepToTopoDS_TranslateFace::Init* for each face. This class does not modify the tolerance value.
685* *StepToTopoDS_TranslateCompositeCurve* constructs *TopoDS_Edges* in *TopoDS_Wire* with help of class *BRepAPI_MakeEdge* and have a tolerance 10-7. Pcurves from a STEP file are translated if they are present and if *read.surfacecurve.mode* is not -3. The connection between segments of a composite curve (edges in the wire) is provided by calling method *ShapeFix_Wire::FixConnected()\** with a precision equal to the initial value of tolerance.
686* *StepToTopoDS_TranslateCurveBoundedSurface* constructs *TopoDS_Face* with tolerance *Precision::Confusion()*. *TopoDS_Wire* on *TopoDS_Face* is constructed with the help of class *StepToTopoDS_TranslateCompositeCurve*. Missing pcurves are computed using projection algorithm with the help of method *ShapeFix_Face::FixPcurves()*. For resulting face method *ShapeFix::SameParameter()* is called. It calls standard *BRepLib::SameParameter* for each edge in each wire, which can either increase or decrease the tolerances of the edges and vertices. *SameParameter* writes the tolerance corresponding to the real deviation of pcurves from 3D curve which can be less or greater than the tolerance in a STEP file.
687* *StepToTopoDS_Builder* a high level class. Its methods perform translation with the help of the classes listed above. If the value of *read.maxprecision.mode* is set to 1 then the tolerance of subshapes of the resulting shape is limited by 0 and *read.maxprecision.val*. Else this class does not change the tolerance value.
688* *StepToTopoDS_MakeTransformed* performs a translation of mapped_item entity and indirectly uses class *StepToTopoDS_Builder*. The tolerance of the resulting shape is not modified inside this method.
689
72b7576f 690<h4>Healing of resulting shape in ShapeHealing component</h4>
dba69de2 691##### ShapeFix_Wire::FixSelfIntersection()
692This method is intended for detecting and fixing self-intersecting edges and intersections of adjacent edges in a wire. It fixes self-intersections by cutting edges at the intersection point and/or by increasing the tolerance of the vertex (so that the vertex comprises the point of intersection). There is a maximum tolerance that can be set by this method transmitted as a parameter, currently is *read.maxprecision.value*.
693
72b7576f 694When a self-intersection of one edge is found, it is fixed by one of the two methods:
695 * tolerance of the vertex of that edge which is nearest to the point of self-intersection is increased so that it comprises both its own old position and the intersection point
696 * the self-intersecting loop on the pcurve is cut out and a new pcurve is constructed. This can increase the tolerance of the edge.
dba69de2 697
72b7576f 698The method producing a smaller tolerance is selected.
dba69de2 699
72b7576f 700When an intersection of two adjacent edges is detected, edges are cut at that point. Tolerance of the common vertex of these edges is increased in order to comprise both the intersection point and the old position.
dba69de2 701
702This method can increase the tolerance of the vertex up to a value of *read.maxprecision.value*.
703
704##### ShapeFix_Wire::FixLacking()
72b7576f 705This method is intended to detect gaps between pcurves of adjacent edges (with the precision of surface UVResolution computed from tolerance of a corresponding vertex) and to fix these gaps either by increasing the tolerance of the vertex, or by inserting a new degenerated edge (straight in parametric space).
dba69de2 706
72b7576f 707If it is possible to compensate a gap by increasing the tolerance of the vertex to a value of less than the initial value of tolerance, the tolerance of the vertex is increased. Else, if the vertex is placed in a degenerated point then a degenerated edge is inserted.
dba69de2 708
709##### ShapeFix_Wire::FixConnected()
710This method is intended to force two adjacent edges in the wire to share the same vertex. This method can increase the tolerance of the vertex. The maximal value of tolerance is *read.maxprecision.value*.
711
712@subsection occt_step_2_6 Code architecture
713
714The following diagram illustrates the structure of calls in reading STEP. The highlighted classes are intended to translate geometry
715
716@image html /user_guides/step/images/step_image003.jpg "The structure of calls in reading STEP"
717@image latex /user_guides/step/images/step_image003.jpg "The structure of calls in reading STEP"
718
719@subsection occt_step_2_7 Example
720~~~~~
72b7576f 721#include STEPControl_Reader.hxx
722#include TopoDS_Shape.hxx
723#include BRepTools.hxx
724
725Standard_Integer main()
726{
dba69de2 727 STEPControl_Reader reader;
728 reader.ReadFile(;MyFile.stp;);
72b7576f 729
dba69de2 730 // Loads file MyFile.stp
731 Standard_Integer NbRoots = reader.NbRootsForTransfer();
72b7576f 732
dba69de2 733 // gets the number of transferable roots
734 cout;Number of roots in STEP file: ; NbRootsendl;
72b7576f 735
dba69de2 736 Standard_Integer NbTrans = reader.TransferRoots();
737 // translates all transferable roots, and returns the number of //successful translations
738 cout;STEP roots transferred: ; NbTransendl;
739 cout;Number of resulting shapes is: ;reader.NbShapes()endl;
72b7576f 740
dba69de2 741 TopoDS_Shape result = reader.OneShape();
742 // obtain the results of translation in one OCCT shape
72b7576f 743
dba69de2 744 . . .
72b7576f 745
746}
dba69de2 747~~~~~
72b7576f 748
dba69de2 749
750@section occt_step_3 Writing STEP
751@subsection occt_step_3_1 Procedure
72b7576f 752You can translate OCCT shapes into STEP entities in the following steps:
dba69de2 753 1.initialize the process,
754 2.set the translation parameters,
755 3.perform the shape translation,
756 4.write the output file.
757
72b7576f 758You can translate several shapes before writing a file. All these translations output a separate shape_representation entity in STEP file.
dba69de2 759
760The user-defined option (parameter *write.step.schema*) is provided to define which version of schema (AP214 CD or DIS, or AP203) is used for the output STEP file.
761
762@subsection occt_step_3_2 Domain covered
763@subsubsection occt_step_3_2_1 Writing geometry and topology
72b7576f 764There are two families of OCCT objects that can be translated:
765 * geometrical objects,
766 * topological shapes.
dba69de2 767
768@subsubsection occt_step_3_2_2 Writing assembly structures
769The shapes organized in a structure of nested compounds can be translated either as simple compound shapes, or into the assembly structure, depending on the parameter *write.step.assembly*, which is described below.
72b7576f 770
771The assembly structure placed in the produced STEP file corresponds to the structure described in the ProSTEP Agreement Log (item 21) as the second alternative (assembly structure through representation_relationship / item_defined_transformation). To represent an assembly it uses entities of the representation_relationship_with_transformation type. Transformation operators used for locating assembly components are represented by item_defined_transformation entities.
772If mode ;write.step.assembly; is set to the values ON or Auto then an OCC shape consisting of nested compounds will be written as an assembly, otherwise it will be written as separate solids.
773
dba69de2 774Please see also <a href="#occt_step_3_4">Mapping OCCT shapes to STEP entities</a>
775
776@subsection occt_step_3_3 Description of the process
777@subsubsection occt_step_3_3_1 Initializing the process
72b7576f 778Before performing any other operation you have to create a writer object:
dba69de2 779~~~~~
72b7576f 780STEPControl_Writer writer;
dba69de2 781~~~~~
782@subsubsection occt_step_3_3_2 Setting the translation parameters
783
72b7576f 784The following parameters are used for the OCCT-to-STEP translation.
dba69de2 785
72b7576f 786<h4>write.precision.mode</h4>
dba69de2 787
72b7576f 788writes the precision value.
dba69de2 789* Least (-1) : the uncertainty value is set to the minimum tolerance of an OCCT shape
790* Average (0) : the uncertainty value is set to the average tolerance of an OCCT shape.
791* Greatest (1) : the uncertainty value is set to the maximum tolerance of an OCCT shape
792* Session (2) : the uncertainty value is that of the write.precision.val parameter.
793
72b7576f 794Read this parameter with:
dba69de2 795
796Standard_Integer ic = Interface_Static::IVal("write.precision.mode");
72b7576f 797Modify this parameter with:
dba69de2 798~~~~~
799if(!Interface_Static::SetIVal("write.precision.mode",1))
72b7576f 800.. error ..
dba69de2 801~~~~~
72b7576f 802Default value is 0.
dba69de2 803
72b7576f 804<h4>write.precision.val</h4>
805a user-defined precision value. This parameter gives the uncertainty for STEP entities constructed from OCCT shapes when the write.precision.mode parameter value is 1.
806 * 0.0001: default
807 * any real positive (non null) value.
dba69de2 808
72b7576f 809This value is stored in shape_representation in a STEP file as an uncertainty.
dba69de2 810
72b7576f 811Read this parameter with:
dba69de2 812~~~~~
813Standard_Real rp = Interface_Static::RVal("write.precision.val");
814~~~~~
815
72b7576f 816Modify this parameter with:
dba69de2 817~~~~~
818if(!Interface_Static::SetRVal("write.precision.val",0.01))
72b7576f 819.. error ..
dba69de2 820~~~~~
72b7576f 821Default value is 0.0001.
dba69de2 822
72b7576f 823<h4>write.step.assembly</h4>
824writing assembly mode.
dba69de2 825* 0 (Off) : (default) writes STEP files without assemblies.
826* 1 (On) : writes all shapes in the form of STEP assemblies.
827* 2 (Auto) : writes shapes having a structure of (possibly nested) *TopoDS_Compounds* in the form of STEP assemblies, single shapes are written without assembly structures.
828
72b7576f 829Read this parameter with:
dba69de2 830~~~~~
831Standard_Integer rp = Interface_Static::IVal("write.step.assembly");
832~~~~~
72b7576f 833Modify this parameter with:
dba69de2 834~~~~~
835if(!Interface_Static::SetIVal("write.step.assembly",1))
72b7576f 836.. error ..
dba69de2 837~~~~~
72b7576f 838Default value is 0.
dba69de2 839
72b7576f 840<h4>write.step.schema</h4>
841defines the version of schema used for the output STEP file:
dba69de2 842 * 1 or ;AP214CD; (default): AP214, CD version (dated 26 November 1996),
843 * 2 or ;AP214DIS;: AP214, DIS version (dated 15 September 1998).
844 * 3 or ;AP203;: AP203, possibly with modular extensions (depending on data written to a file).
845 * 4 or *AP214IS*: AP214, IS version (dated 2002)
72b7576f 846This parameter affects the following entities written to the STEP file:
847
dba69de2 848AP214, CD version AP214, DIS version AP214,IS version AP203
849FILE_SCHEMA( (`AUTOMOTIVE_DESIGN_CC2 { 1 2 10303 214 -1 1 5 4}')) FILE_SCHEMA( (`AUTOMOTIVE_DESIGN { 1 2 10303 214 0 1 1 1}')) FILE_SCHEMA(
850('AUTOMOTIVE_DESIGN
851 { 1 0 10303 214 1 1 1 1 }')) FILE_SCHEMA( (`CONFIG_CONTROL_DESIGN'))
852APPLICATION_PROTOCOL_ DEFINITION
853`committee draft',
854`automotive_design'
855,1997,##) APPLICATION_PROTOCOL_ DEFINITION(
856'draft international standard',
857'automotive_design',
8581998,##) APPLICATION_PROTOCOL_DEFINITION
859('international standard', ‘automotive_design',
8602000,##); APPLICATION_PROTOCOL_ DEFINITION
861('international standard', 'config_control_design',1994,##)
862APPLICATION_CONTEXT( 'core data for automotive mechanical design processes') APPLICATION_CONTEXT( ‘configuration controlled 3D designs of mechanical parts and assemblies' )
863PRODUCT_TYPE(`part',$,(##)) PRODUCT_RELATED_PRODUCT_CATEGORY( `part',$,(##))
864MECHANICAL_CONTEXT(`',##, 'mechanical') PRODUCT_CONTEXT(`',##, 'mechanical') PRODUCT_CONTEXT('',##,'mechanical'); MECHANICAL_CONTEXT(`',##, 'mechanical')
72b7576f 865
866In addition, in AP203 mode more product and organizational entities are generated (entities like PERSON_AND_ORGANIZATION, SECURITY_CLASSIFICATION etc., as required by AP203).
867Read this parameter with:
dba69de2 868~~~~~
869TCollection_AsciiString schema = Interface_Static::CVal("write.step.schema");
870~~~~~
72b7576f 871Modify this parameter with:
dba69de2 872~~~~~
873if(!Interface_Static::SetCVal("write.step.schema","DIS"))
72b7576f 874.. error ..
dba69de2 875~~~~~
72b7576f 876Default value is 1 (;CD;).
dba69de2 877For the parameter *write.step.schema* to take effect, method *STEPControl_Writer::Model(Standard_True)* should be called after changing this parameter (corresponding command in DRAW is *newmodel*).
878
72b7576f 879<h4>write.step.product.name</h4>
880Defines the text string that will be used for field ‘name’ of PRODUCT entities written to the STEP file.
dba69de2 881
882Default value: OCCT STEP translator (current OCCT version number).
883
72b7576f 884<h4>write.surfacecurve.mode</h4>
885This parameter indicates whether parametric curves (curves in parametric space of surface) should be written into the STEP file. This parameter can be set to Off in order to minimize the size of the resulting STEP file.
dba69de2 886
887* Off (0) : writes STEP files without pcurves. This mode decreases the size of the resulting STEP file .
888* On (1) : (default) writes pcurves to STEP file
889
72b7576f 890Read this parameter with:
dba69de2 891~~~~~
892Standard_Integer wp = Interface_Static::IVal("write.surfacecurve.mode");
893~~~~~
72b7576f 894Modify this parameter with:
dba69de2 895~~~~~
896if(!Interface_Static::SetIVal("write.surfacecurve.mode",1))
72b7576f 897.. error ..
dba69de2 898~~~~~
72b7576f 899Default value is On.
dba69de2 900
72b7576f 901<h4>write.step.unit</h4>
902Defines a unit in which the STEP file should be written. If set to unit other than MM, the model is converted to these units during the translation.
dba69de2 903
72b7576f 904Default value is MM.
dba69de2 905
906<h4>write.step.resource.name and write.step.sequence</h4>
72b7576f 907These two parameters define the name of the resource file and the name of the sequence of operators (defined in that file) for Shape Processing, which is automatically performed by the STEP translator before translating a shape to a STEP file. Shape Processing is a user-configurable step, which is performed before the translation and consists in applying a set of operators to a resulting shape. This is a very powerful tool allowing customizing the shape and adapting it to the needs of a receiving application. By default the sequence consists of two operators: SplitCommonVertex and DirectFaces, which convert some geometry and topological constructs valid in Open CASCADE Technology but not in STEP to equivalent definitions conforming to STEP format.
dba69de2 908
72b7576f 909See description of parameter read.step.resource.name above for more details on using resource files.
dba69de2 910
911Default values:
912* read.step.resource.name - STEP,
913* read.step.sequence - ToSTEP.
914
915@subsubsection occt_step_3_3_3 Performing the Open CASCADE Technology shape translation
72b7576f 916An OCCT shape can be translated to STEP using one of the following models (shape_representations):
917 * manifold_solid_brep (advanced_brep_shape_representation)
918 * brep_with_voids (advanced_brep_shape_representation)
919 * faceted_brep (faceted_brep_shape_representation)
920 * shell_based_surface_model (manifold_surface_shape_representation)
921 * geometric_curve_set (geometrically_bounded_wireframe_shape_representation)
dba69de2 922
923The enumeration **TEPControl_StepModelType* is intended to define a particular transferring model.
72b7576f 924The following values of enumeration are allowed:
dba69de2 925* *STEPControl_AsIs* Translator selects the resulting representation automatically, according to the type of CASCADE shape to translate it in its highest possible model;
926* *STEPControl_ManifoldSolidBrep* resulting entity is manifold_solid_brep or brep_with_voids
927* *STEPControl_FacetedBrep* resulting entity is *faceted_brep* or *faceted_brep_and_brep_with_voids* Note that only planar-face shapes with linear edges can be written;
928* *STEPControl_ShellBasedSurfaceModel* resulting entity is *shell_based_surface_model*;
929* *STEPControl_GeometricCurveSet* resulting entity is *geometric_curve_set*;
72b7576f 930
931The following table shows which shapes can be translated in which mode:
dba69de2 932* *STEP214Control_AsIs* - any OCCT shape
933* *STEP214Control_ManifoldSolidBrep* - *TopoDS_Solid, TopoDS_Shell, TopoDS_Compound* (if it contains *TopoDS_Solids* and *TopoDS_Shells*.
934* *STEP214Control_FacetedBrep* - *TopoDS_Solid* or *TopoDS_Compound* containing *TopoDS_Solids* if all its surfaces are *Geom_Planes* and all curves are *Geom_Lines*.
935* *STEP214Control_ShellBasedSurfaceModel* - *TopoDS_Solid, TopoDS_Shell, TopoDS_Face* and *TopoDS_Compound* (if it contains all mentioned shapes)
936* *STEP214Control_GeometricCurveSet* - any OCCT shape.
937
938If *TopoDS_Compound* contains any other types besides the ones mentioned in the table, these sub-shapes will be ignored.
939
72b7576f 940In case if an OCCT shape cannot be translated according to its mode the result of translation is void.
dba69de2 941~~~~~
72b7576f 942STEP214Control_StepModelTope mode = STEP214Control_ManifoldSolidBrep;
943IFSelect_ReturnStatus stat = writer.Transfer(shape,mode);
dba69de2 944~~~~~
945
946@subsubsection occt_step_3_3_4 Writing the STEP file
72b7576f 947Write the STEP file with:
dba69de2 948~~~~~
949IFSelect_ReturnStatus stat = writer.Write("filename.stp");
950~~~~~
72b7576f 951to give the file name.
dba69de2 952
953@subsection occt_step_3_4 Mapping Open CASCADE Technology shapes to STEP entities
72b7576f 954Only STEP entities that have a corresponding OCCT object and mapping of assembly structures are described in this paragraph. For a full list of STEP entities please refer to Appendix A.
dba69de2 955
956@subsubsection occt_step_3_4_1 Assembly structures and product information
957The assembly structures are written to the STEP file if parameter *write.step.assembly* is 1 or 2.
958Each *TopoDS_Compound* is written as an assembly with subshapes of that compound being components of the assembly. The structure of nested compounds is translated to the structure of nested assemblies. Shared subshapes are translated into shared components of assemblies. Shapes that are not compounds are translated into subtypes of shape_representation according to their type (see the next subchapter for details).
959
72b7576f 960A set of STEP entities describing general product information is written to the STEP file together with the entities describing the product geometry, topology and assembly structure. Most of these entities are attached to the entities being subtypes of shape_representation, but some of them are created only one per STEP file.
dba69de2 961
72b7576f 962The table below describes STEP entities, which are created when the assembly structure and product information are written to the STEP file, and shows how many of these entities are created. Note that the appearance of some of these entities depends on the version of the schema (AP214, CD, DIS or IS, or AP203).
72b7576f 963
dba69de2 964CASCADE shape STEP entity Comments
965 application_protocol_definition One per STEP file, defines the application protocol used (depends on the schema version)
966 application_context One per STEP file, defines the application generating the file (AP214 or AP203)
967TopoDS_Compound shape_representation Empty shape_representation describing the assembly. The components of that assembly are written as subtypes of shape_representation and are included to the assembly using next_assembly_usage_occurence entities.
968TopoDS_Shape subtypes of shape_representation Depending on the shape type, see the tables below for mapping details
969 next_assembly_usage_occurence Describes the instance of component in the assembly by referring corresponding product_definitions. If the same component is included in the assembly several times (for example, with different locations), several next_assembly_usage_occurences are created.
970 context_dependent_shape_representation Describes the placement of a component in the assembly. One context_dependent_shape_ representation corresponds to each next_assembly_usage_occurence entity.
971 shape_representation_relationship_with_transformation Together with the context_dependent_shape_ representation describes the location of a component in the assembly.
972 item_defined_transformation Defines a transformation used for the location of a component in the assembly. Is referred by shape_representation_relationship_with_transformation
973 shape_definition_representation One per shape_representation
974 product_definition_shape One per shape_definition_representation and context_dependent_shape_representation
975 product_definition Defines a product, one per shape_definition_representation
976 product_definition_formation One per product_definition. All product_definition_formations in the STEP file have unique names.
977 Product One per product_definition_formation. All products in the STEP file have unique names.
978 product_type (CD) or product_related_product_category (DIS,IS) One per product
979 Mechanical_context (CD) or product_context (DIS,IS) One per product.
980 product_definition_context One per product_definition.
981
982
983@subsubsection occt_step_3_4_2 Topological shapes
72b7576f 984
dba69de2 985CASCADE shape STEP entity Comments
986TopoDS_Compound geometric_curve_set If the write mode is STEP214Control_GeometricCurveSet only 3D curves of the edges found in TopoDS_Compound and all its subshapes are translated
987 manifold_solid_brep If the write mode is STEP214Control_AsIs and TopoDS_Compound consists only of TopoDS_Solids
988 shell_based_surface_model If the write mode is STEP214Control_AsIs and TopoDS_Compound consists of TopoDS_Solids, TopoDS_Shells and TopoDS_Faces
989 geometric_curve_set If the write mode is STEP214Control_AsIs and TopoDS_Compound contains TopoDS_Wires, TopoDS_Edges, TopoDS_Vertices
990 If the write mode is not STEP214Control_AsIs or STEP214Control_GeometricCurveSet TopoDS_Solids, TopoDS_Shells and TopoDS_Faces are translated according to this table.
991TopoDS_Solid manifold_solid_brep If the write mode is STEP214Control_AsIs or STEP214Control_ManifoldSolidBrep and CASCADE TopoDS_Solid has no voids.
992 faceted_brep If the write mode is STEP214Control_FacetedBrep.
993 brep_with_voids If the write mode is STEP214Control_AsIs or STEP214Control_ManifoldSolidBrep and CASCADE TopoDS_Solid has voids.
994 shell_based_surface_model If the write mode is STEP214Control_ShellBasedSurfaceModel.
995 geometric_curve_set If the write mode is STEP214Control_GeometricCurveSet. Only 3D curves of the edges are translated.
996TopoDS_Shell in a TopoDS_Solid closed_shell If TopoDS_Shell is closed shell.
997TopoDS_Shell manifold_solid_brep If the write mode is STEP214Control_ManifoldSolidBrep.
998 shell_based_surface_model If the write mode is STEP214Control_AsIs or STEP214Control_ShellBasedSurfaceModel.
999 geometric_curve_set If the write mode is STEP214Control_GeometricCurveSet. Only 3D curves of the edges are translated.
1000TopoDS_Face advanced_face
1001TopoDS_Wire in a TopoDS_Face face_bound The resulting face_bound contains poly_loop if write mode is faceted_brep or edge_loop if not .
1002TopoDS_Wire geometric_curve_set If the write mode is STEP214Control_GeometricCurveSet. Only 3D curves of the edges are translated.
1003TopoDS_Edge oriented_edge
1004TopoDS_Vertex vertex_point
72b7576f 1005
dba69de2 1006@subsubsection occt_step_3_4_3 Geometrical objects
1007CASCADE object STEP entity Comments
1008Points
1009Geom_CartesianPoint cartesian_point
1010Geom2d_CartesianPoint
1011TColgp_Array1OfPnt polyline
1012TColgp_Array1OfPnt2d
1013Placements
1014Geom_Axis1Plasement axis1_placement
1015Geom2d_AxisPlacement
1016Geom_Axis2Placement axis2_placement_3d
1017Directions
1018Geom_Direction direction
1019Geom2d_Direction
1020Vectors
1021Geom_Vector vector
1022Geom2d_Vector
1023Curves
1024Geom_Circle circle
1025Geom2d_Circle circle
1026 rational_b_spline_curve
1027Geom_Ellipse Ellipse
1028Geom2d_Ellipse Ellipse
1029 rational_b_spline_curve
1030Geom_Hyperbola Hyperbola
1031Geom2d_Hyperbola
1032Geom_Parabola Parabola
1033Geom2d_Parabola
1034Geom_BSplineCurve b_spline_curve_with_knots
1035 rational_b_spline_curve if Geom_BsplineCurve is a rational BSpline
1036Geom2d_BSplineCurve b_spline_curve_with_knots
1037 b_spline_curve_with_knots_ and_rational_b_spline_curve if Geom2d_BSplineCurve is a rational Bspline
1038Geom_BezierCurve b_spline_curve_with_knots
1039Geom_Line Line
1040Geom2d_Line
1041Surfaces
1042Geom_Plane Plane
1043Geom_OffsetSurface offset_surface
1044Geom_ConicalSurface conical_surface
1045Geom_CylindricalSurface cylindrical_surface
1046Geom_OffsetSurface offset_surface
1047Geom_RectangularTrimmedSurface rectangular_trimmed_surface
1048Geom_SphericalSurface spherical_surface
1049Geom_SurfaceOfLinear Extrusion surface_of_linear_extrusion
1050Geom_SurfaceOf Revolution surface_of_revolution
1051Geom_ToroidalSurface toroidal_surface
1052 degenerate_toroidal_surface if the minor radius is greater then the major one
1053Geom_BezierSurface b_spline_surface_with_knots
1054Geom_BsplineSurface b_spline_surface_with_knots
1055 b_spline_surface_with_knots_ and_rational_b_spline_surface if Geom_BSplineSurface is a rational Bspline
1056
1057
1058@subsection occt_step_3_5 Tolerance management
72b7576f 1059There are four possible values for the uncertainty when writing a STEP file:
1060 * user-defined value of the uncertainty
1061 * minimal value of sub-shapes tolerances
1062 * average value of sub-shapes tolerances
1063 * maximal value of sub-shapes tolerances
dba69de2 1064
72b7576f 1065The chosen value of the uncertainty is the final value that will be written into the STEP file.
dba69de2 1066See parameter *write.precision.mode*.
1067
1068
1069@subsection occt_step_3_6 Code architecture
1070
1071@subsubsection occt_step_3_6_1 Graph of calls
72b7576f 1072The following diagram illustrates the structure of calls in writing STEP.
1073The highlighted classes are intended to translate geometry.
1074
1075
dba69de2 1076@image html /user_guides/step/images/step_image004.jpg "The structure of calls in writing STEP"
1077@image latex /user_guides/step/images/step_image004.jpg "The structure of calls in writing STEP"
72b7576f 1078
dba69de2 1079
1080@subsection occt_step_3_7 Example
72b7576f 1081~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
1082#include STEPControl.hxx
1083#include STEPControl_Writer.hxx
1084#include TopoDS_Shape.hxx
1085#include BRepTools.hxx
1086#include BRep_Builder.hxx
1087
1088Standard_Integer main()
1089{
1090TopoDS_Solid source;
1091. . .
1092
1093STEPControl_Writer writer;
1094writer.Transfer(source, STEPControl_ManifoldSolidBrep);
1095
1096// Translates TopoDS_Shape into manifold_solid_brep entity
1097writer.Write(;Output.stp;);
1098// writes the resulting entity in the STEP file
1099
1100}
1101~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dba69de2 1102
1103@section occt_step_4 Physical STEP file reading and writing
1104
1105@subsection occt_step_4_1 Architecture of STEP Read and Write classes
1106@subsubsection occt_step_4_1_1 General principles
1107
72b7576f 1108To perform data loading from a STEP file and to translate this data it is necessary to create correspondence between the EXPRESS schema and the structure of CDL classes. There are two possibilities to organize such correspondence: the so-called early binding and late binding.
dba69de2 1109* Late binding means that the processor works with a description of the schema. The processor builds a dictionary of entities and can recognize and read any entity that is described in the schema. To change the behavior and the scope of processor based on late binding it is enough to change the description of the schema. However, this binding has some disadvantages (for example low speed of reading process).
1110* In case of early binding, the structure of CDL classes is created beforehand with the help of a specific automatic tool or manually. If the processor finds an entity that is not found in this schema, it will simply be ignored. The processor calls constructors of appropriate classes and their read methods. To add a new type in the scope of the processor it is necessary to create a class corresponding to the new entity.
1111
72b7576f 1112The STEP processor is based on early binding principles. It means that specific classes for each EXPRESS type have been created with the help of an automatic tool from the EXPRESS schema. There are two CDL classes for each EXPRESS type. The first class (named the representing class) represents the STEP entity in memory. The second one (RW - class) is intended to perform the initialization of the representing class and to output data to an intermediate structure to be written in a STEP file.
dba69de2 1113
1114@subsubsection occt_step_4_1_2 Complex entities
72b7576f 1115EXPRESS schema allows multiple inheritance. Entities that are built on the basis of multiple inheritance are called complex entities. Multiple inheritance is not available in CDL. EXPRESS enables any type of complex entities that can be inherited from any EXPRESS type. In the manner of early binding it is not possible to create a CDL class for any possible complex type. Thus, only widespread complex entities have corresponding representing classes and RW-classes that are created manually beforehand.
dba69de2 1116
1117@subsection occt_step_4_2 Physical file reading
72b7576f 1118Physical file reading consists of the following steps:
dba69de2 1119 1.Loading a STEP file and syntactic analysis of its contents
1120 2.Mapping STEP entities to the array of strings
1121 3.Creating empty OCCT objects representing STEP entities
1122 4.Initializing OCCT objects
1123 5.Building a references graph
1124
1125@subsubsection occt_step_4_2_1 Loading a STEP file and syntactic analysis of its contents
72b7576f 1126In the first phase, a STEP file is syntactically checked and loaded in memory as a sequence of strings.
dba69de2 1127
1128Syntactic check is performed on the basis of rules defined in *step.lex* and *step.yacc* files. Files *step.lex* and *step.yacc* are located in the StepFile nocdlpack development unit. These files describe text encoding of STEP data structure (for additional information see ISO 10303 Part 21). The *step.lex* file describes the lexical structure of the STEP file. It describes identifiers, numbers, delimiters, etc. The *step.yacc* file describes the syntactic structure of the file, such as entities, parameters, and headers.
1129
72b7576f 1130These files have been created only once and need to be updated only when norm ISO 10303-21 is changed.
dba69de2 1131
1132@subsubsection occt_step_4_2_2 Mapping STEP entities to arrays of strings
72b7576f 1133For each entity specified by its rank number the arrays storing its identifier, STEP type and parameters are filled.
dba69de2 1134@subsubsection occt_step_4_2_3 Creating empty Open CASCADE Technology objects that represent STEP entities
1135For each STEP entity an empty OCCT object representing this entity is created. A map of correspondence between entity rank and OCCT object is created and filled out. If a STEP entity is not recognized by the STEP processor then the *StepData_UndefinedEntity* object is created.
1136@subsubsection occt_step_4_2_4 Initializing Open CASCADE Technology objects
72b7576f 1137Each OCCT object (including StepData_UndefinedEntity) is initialized by its parameters with the help of the appropriate RW - class. If some entity has another entity as its parameter, the object that represents the latter entity will be initialized immediately. All initialized objects are put into a special map to avoid repeated initialization.
dba69de2 1138@subsubsection occt_step_4_2_5 Building a graph
72b7576f 1139The final phase is building a graph of references between entities. For each entity its RW-class is used to find entities referenced by this entity. Back references are built on the basis of direct references. In addition to explicit references defined in the STEP entities some additional (implicit) references are created for entities representing assembly structures (links from assemblies to their components).
dba69de2 1140@subsection occt_step_4_3 How to add a new entity in scope of the STEP processor
72b7576f 1141If it is necessary to read and translate a new entity by the STEP processor the Reader and Actor scope should be enhanced. Note that some actions to be made for adding a new type are different for simple and complex types.
1142The following steps should be taken:
dba69de2 1143* Create a CDL class representing a new entity. This can be *Stepxxx_NewEntity* class where xxx can be one of the following:
1144 * Basic
1145 * Geom
1146 * Shape
1147 * Visual
1148 * Repr
1149 * AP214
1150 * AP203
72b7576f 1151Each field of a STEP entity should be represented by a corresponding field of this class. The class should have methods for initializing, setting and obtaining fields and it should also have the default constructor.
dba69de2 1152* Create the *RWStepxxx_RWNewEntity* class with a default constructor and methods *ReadStep()*, *WriteStep()* and if the entity references other entities, then method *Share()*.
1153* Update file *StepAP214_Protocol.cxx*. In the constructor *StepAP214_Protocol::StepAP214_Protocol()* add the new type to the map of registered types and associate the unique integer identifier with this type.
1154* Update file *RWStepAP214_ReadWriteModule.cxx*. The changes should be the following:
1155 * For simple types:
1156 * Add a static object of class *TCollection_AsciiString* with name *Reco_NewEntity* and initialize it with a string containing the STEP type.
1157 * In constructor *WStepAP214_ReadWriteModule::RWStepAP214_ReadWriteModule()* add this object onto the list with the unique integer identifier of the new entity type.
1158 * In function *RWStepAP214_ReadWriteModule::StepType()* add a new C++ case operator for this identifier.
1159 * For complex types:
1160 * In the method *RWStepAP214_ReadWriteModule::CaseStep()* add a code for recognition the new entity type returning its unique integer identifier.
1161 * In the method *RWStepAP214_ReadWriteModule::IsComplex()* return True for this type.
1162 * In the method *RWStepAP214_ReadWriteModule::ComplexType()* fill the list of subtypes composing this complex type.
1163 * For both simple and complex types:
1164 * In function *RWStepAP214_ReadWriteModule::ReadStep()* add a new C++ case operator for the new identifier and call the *RWStepxxx_RWNewEntity* class, method *ReadStep* to initialize the new class.
1165* Update file *RWStepAP214_GeneralModule.cxx*. Add new C++ case operators to functions *NewVoid()* and *FillSharedCase()*, and in the method *CategoryNumber()* add a line defining a category of the new type.
1166* Enhance the *STEPControl_ActorRead class* (methods *Recognize()* and *Transfer()*), or class(es) translating some entities, to translate the new entity into an OCCT shape.
1167
1168@subsection occt_step_4_4 Physical file writing
72b7576f 1169Physical file writing consists of the following steps:
dba69de2 1170 1. Building a references graph. Physical writing starts when STEP model, which was either loaded from a STEP file or created from OCCT shape with the help of translator, is available together with corresponding graph of references. During this step the graph of references can be recomputed.
1171 2. Transferring data from a model to a sequence of strings. For each representing entity from the model a corresponding RW - class is called. RW - class performs the writing of data that is contained in the representing class into an intermediate data structure. The mentioned structure is a sequence of strings in memory.
1172 3. Writing the sequence of strings into the file. The sequence of strings is written into the file. This is the last phase of physical STEP writing.
1173
1174
1175@subsection occt_step_4_5 How to add a new entity to write in the STEP file.
1176
72b7576f 1177If it is necessary to write and translate an OCCT shape into a new entity by the STEP processor the Writer and Actor scope should be enhanced.
dba69de2 1178
1179For a description of steps, which should be taken for adding a new entity type to the STEP processor, see <a href="#occt_step_4_2">Physical file reading</a>. Then, enhance the *STEPControl_ActorWrite* class i.e. methods *Recognize()* and *Transfer()*, or other classes from *TopoDSToStep*, to translate the OCCT shape into a new STEP entity.
1180
1181@section occt_step_6 Using DRAW
1182@subsection occt_step_6_1 DRAW STEP Commands Overview
1183*TKXSDRAW* toolkit provides commands for testing XSTEP interfaces interactively in the DRAW environment. It provides an additional set of DRAW commands specific for data exchange tasks, which allows loading and writing data files and an analysis of the resulting data structures and shapes.
1184
72b7576f 1185This section is divided into five parts. Two of them deal with reading and writing a STEP file and are specific for the STEP processor. The first and the forth parts describe some general tools for setting parameters and analyzing the data. Most of them are independent of the norm being tested. Additionally, a table of mentioned DRAW commands is provided.
dba69de2 1186
1187In the description of commands, square brackets ([]) are used to indicate optional parameters. Parameters given in the angle brackets (\<\>) and sharps (#) are to be substituted by an appropriate value. When several exclusive variants are possible, a vertical dash (|) is used.
1188
1189@subsection occt_step_6_2 Setting the interface parameters
72b7576f 1190A set of parameters for importing and exporting STEP data is defined in the XSTEP resource file. In XSDRAW, these parameters can be viewed or changed using the command
dba69de2 1191~~~~~
1192Draw:> param [<parameter_name> [<value>]]
1193~~~~~
1194Command param with no arguments gives a list of all parameters with their values. When the argument *parameter_name* is specified, information about this parameter is printed (current value and short description).
1195
72b7576f 1196The third argument is used to set a new value of the given parameter. The result of the setting is printed immediately.
dba69de2 1197
72b7576f 1198During all interface operations, the protocol of the process (fail and warning messages, mapping of loaded entities into OCCT shapes etc.) can be output to the trace file. Two parameters are defined in the DRAW session: trace level (integer value from 0 to 9, default is 0), and trace file (default is standard output).
dba69de2 1199
72b7576f 1200Command xtrace is intended to view and change these parameters:
dba69de2 1201* *Draw:> xtrace* - prints current settings (e.g.: `Level=1 - Standard Output');
1202* *Draw:> xtrace \#* - sets trace level to the value #;
1203* *Draw:> xtrace tracefile.log* - sets the trace file as *tracefile.log*;
1204* *Draw:> xtrace.* - directs all messages to the standard output.
1205
1206@subsection occt_step_6_3 Reading a STEP file
1207
1208For a description of parameters used in reading a STEP file refer to <a href="#occt_step_2_3_3">Setting the translation parameters</a> section.
1209
1210For reading a STEP file, the following parameters are defined (see above, <a href="#occt_step_6_2">the command *param*</a>):
1211
1212Description Name Values Meaning
1213Precision for input entities read.precision.mode 0 or 1 If 0 (File), precision of the input STEP file will be used for the loaded shapes
1214If 1 (Session), the following parameter will be used as the precision value
1215 read.precision.val real Value of precision (used if the previous parameter is 1)
1216Surface curves read.surfacecurve.mode 0 or 3 Defines a preferable way of representing surface curves (2d or 3d representation).
1217If 0, no preference.
1218Maximal tolerance read.maxprecision.mode 0 or 1 If 1, maximum tolerance is used as a rigid limit
1219If 0, maximum tolerance is used as a limit but can be exceeded by some algorithms
1220 read.maxprecision.val real Value of maximum precision
1221
1222
72b7576f 1223It is possible either only to load a STEP file into memory (i.e. fill the *InterfaceModel* with data from the file), or to read it (i.e. load and convert all entities to OCCT shapes).
1224Loading is done by the command
dba69de2 1225~~~~~
1226Draw:> xload <file_name>
1227~~~~~
72b7576f 1228Once the file is loaded, it is possible to investigate the structure of the loaded data. To find out how you do it, look in the beginning of the analysis subsection.
1229Reading a STEP file is done by the command
dba69de2 1230~~~~~
1231Draw:> stepread <file_name> <result_shape_name> [selection]
1232~~~~~
72b7576f 1233Here a dot can be used instead of a filename if the file is already loaded by xload or stepread.
1234The optional selection (see below for a description of selections) specifies a set of entities to be translated. If an asterisk `*' is given, all transferable roots are translated. If a selection is not given, the user is prompted to define a scope of transfer interactively:
dba69de2 1235
1236N Mode Description
12370 End Finish transfer and exit stepread
12381 root with rank 1 Transfer first root
12392 root by its rank Transfer root specified by its rank
12403 One entity Transfer entity with a number provided by the user
12414 Selection Transfer only entities contained in selection
1242
72b7576f 1243* root is an entity in the STEP file which is not referenced by another entities
1244Second parameter of the stepread command defines the name of the loaded shape.
dba69de2 1245
72b7576f 1246During the STEP translation, a map of correspondence between STEP entities and OCCT shapes is created.
dba69de2 1247
1248To get information on the result of translation of a given STEP entity use the command *Draw:> tpent \#*.
1249
1250To create an OCCT shape, corresponding to a STEP entity, use the command *Draw:> tpdraw \#*.
1251To get the number of a STEP entity, corresponding to an OCCT shape, use the command *Draw:> fromshape <shape_name>*.
1252
1253To clear the map of correspondences between STEP entities and OCCT shapes use the command *Draw:> tpclear*.
1254
1255@subsection occt_step_6_4 Analyzing the transferred data
72b7576f 1256The procedure of analysis of data import can be divided into two stages:
dba69de2 1257 1.to check the file contents,
1258 2.to estimate the translation results (conversion and validated ratios).
1259
1260@subsubsection occt_step_6_4_1 Checking file contents
72b7576f 1261General statistics on the loaded data can be obtained by using the command
dba69de2 1262Draw:> data <symbol>
72b7576f 1263Information printed by this command depends on the symbol specified:
1264
dba69de2 1265* *g* - Prints the information contained in the header of the file;
1266* *c* or *f* - Prints messages generated during the loading of the STEP file (when the procedure of the integrity of the loaded data check is performed) and the resulting statistics (f works only with fails while c with both fail and warning messages) ;
1267* *t* - The same as *c* or *f*, with a list of failed or warned entities;
1268* *m* or *l* - The same as *t* but also prints a status for each entity;
1269* *e* - Lists all entities of the model with their numbers, types, validity status etc.
1270* *R* - The same as e but lists only root entities
1271
72b7576f 1272There is a set of special objects, which can be used to operate with a loaded model. They can be of the following types:
dba69de2 1273* Selection Filters - allow selecting subsets of entities of the loaded model;
1274* Counter - calculates some statistics on the model data.
1275
1276A list of these objects defined in the current session can be printed in DRAW by command *Draw:> listitems*.
72b7576f 1277
dba69de2 1278Command *Draw:> givelist <selection_name>* prints a list of a subset of loaded entities defined by the selection argument:
72b7576f 1279
dba69de2 1280* *xst-model-all* all entities of the model;
1281* *xst-model-roots* all roots;
1282* *xst-pointed* (Interactively) pointed entities (not used in DRAW);
1283* *xst-transferrable-all* all transferable (recognized) entities;
1284* *xst-transferrable-roots* Transferable roots.
1285
1286The command *listtypes* gives a list of entity types, which were encountered in the last loaded file (with a number of STEP entities of each type).
1287
1288The list cannot be shown for all entities but for a subset of them. This subset is defined by an optional selection argument (for the list of possible values for STEP, see the table above).
1289
72b7576f 1290Two commands are used to calculate statistics on the entities in the model:
dba69de2 1291~~~~~
1292Draw:> count <counter> [<selection>]
1293Draw:> listcount <counter> [<selection>]
1294~~~~~
72b7576f 1295The former only prints a count of entities while the latter also gives a list of them.
dba69de2 1296
72b7576f 1297The optional selection argument, if specified, defines a subset of entities, which are to be taken into account. The first argument should be one of the currently defined counters:
dba69de2 1298* *xst-types* - calculates how many entities of each OCCT type exist
1299* *step214-types* - calculates how many entities of each STEP type exist
1300
1301Entities in the STEP file are numbered in the succeeding order. An entity can be identified either by its number or by its label. Label is the letter \# followed by the rank.
1302* *Draw:> elab \#* outputs a label for an entity with a known number.
1303* *Draw:> enum \#* prints a number for the entity with a given label.
1304* *Draw:> entity \# <level_of_information>* outputs the contents of a STEP entity.
1305* *Draw: estat \#* outputs the list of entities referenced by a given entity and the list of entities referencing to it.
1306* *Draw: dumpassembly* prints a STEP assembly as a tree.
1307
1308Information about product names, *next_assembly_usage_occurence, shape_definition_representation, context_dependent_shape_representation* or *mapped_item entities* that are involved into the assembly structure will be printed.
1309
1310@subsubsection occt_step_6_4_2 Estimating the results of reading STEP
72b7576f 1311All the following commands are available only after data is converted into OCCT shapes (i.e. after command 214read).
72b7576f 1312
dba69de2 1313Command *Draw:> tpstat [*|?]<symbol> [<selection>]* is provided to get all statistics on the last transfer, including a list of transferred entities with mapping from STEP to OCCT types, as well as fail and warning messages. The parameter symbol defines what information will be printed:
1314
1315* *g* - General statistics (a list of results and messages)
1316* *c* - Count of all warning and fail messages
1317* *C* - List of all warning and fail messages
1318* *f* - Count of all fail messages
1319* *F* - List of all fail messages
1320* *n* - List of all transferred roots
1321* *s* - The same, with types of source entity and the type of result
1322* *b* - The same, with messages
1323* *t* - Count of roots for geometrical types
1324* *r* - Count of roots for topological types
1325* *l* - The same, with the type of the source entity
1326
1327The sign \* before parameters *n, s, b, t, r* makes it work on all entities (not only on roots).
1328
1329The sign ? before *n, s, b, t* limits the scope of information to invalid entities.
1330
1331Optional argument <selection> can limit the action of the command to the selection, not to all entities.
1332
72b7576f 1333To get help, run this command without arguments.
dba69de2 1334
1335The command *Draw:> tpstat \*1* gives statistics on the result of translation of different types of entities (taking check messages into account) and calculates summary translation ratios.
1336
1337To get information on OCCT shape contents use command *Draw:> statshape <shape_name>* . It outputs the number of each kind of shapes (vertex, edge, wire, etc.) in the shape and some geometrical data (number of C0 surfaces, curves, indirect surfaces, etc.).
1338
72b7576f 1339The number of faces is returned as a number of references. To obtain the number of single instances, the standard command (from TTOPOLOGY executable) nbshapes can be used.
dba69de2 1340
1341To analyze the internal validity of the shape, use command *Draw:> checkbrep <shape_name> <expurged_shape_name>*. It checks shape geometry and topology for different cases of inconsistency, like self-intersecting wires or wrong orientation of trimming contours. If an error is found, it copies bad parts of the shape with the names <i>expurged_subshape_name _\#</i> and generates an appropriate message. If possible this command also tries to find STEP entities the OCCT shape was produced from.
1342
1343<i><expurged_shape_name></i> will contain the original shape without invalid subshapes.
1344To get information on tolerances of the shape use command <i>Draw:> tolerance <shape_name> [<min> [<max>] [<symbol>]] </i>. It outputs maximum, average and minimum values of tolerances for each kind of subshapes having tolerances and for the whole shape in general.
1345
72b7576f 1346When specifying min and max arguments this command saves shapes with tolerances in the range [min, max] with names shape_name_... and gives their total number.
dba69de2 1347
1348<i><Symbol></i> is used for specifying the kind of sub-shapes to analyze:
1349* *v* - for vertices,
1350* *e* - for edges,
1351* *f* - for faces,
1352* *c* - for shells and faces.
1353
1354@subsection occt_step_6_5 Writing a STEP file
1355For writing shapes to a STEP file, the following parameters are defined (see above, <a href="#occt_step_6_2">the command *param*</a>):
1356
1357
1358Description Name Values Meaning
1359Uncertainty for resulting entities Write.precision.mode -1, 0, 1 or 2 If -1 the uncertainty value is set to the minimal tolerance of CASCADE subshapes.
1360If 0 the uncertainty value is set to the average tolerance of CASCADE subshapes.
1361If 1 the uncertainty value is set to the maximal tolerance of CASCADE subshapes.
1362If 2 the uncertainty value is set to write.precision.val
1363Value of uncertainty Write.precision.val real Value of uncertainty (used if previous parameter is 2)
1364
1365
1366Several shapes can be written in one file. To start writing a new file, enter command *Draw:> newmodel*.
1367Actually, command *newmodel* will clear the *InterfaceModel* to empty it, and the next command will convert the specified shape to STEP entities and add them to the *InterfaceModel*:
1368~~~~~
1369Draw:> stepwrite <mode> <shape_name> [<file_name>]
1370~~~~~
72b7576f 1371The available modes are following:
dba69de2 1372 * *a* - as is;
1373 * *m* - manifold_solid_brep or brep_with_voids
1374 * *f* - faceted_brep
1375 * *w* - geometric_curve_set
1376 * *s* - shell_based_surface_model
1377
72b7576f 1378After a successful translation, if file_name parameter is not specified, the procedure asks you whether to write a STEP model in the file or not:
dba69de2 1379~~~~~
72b7576f 1380execution status : 1
1381Mode (0 end, 1 file) :
dba69de2 1382~~~~~
1383It is necessary to call command *newmodel* to perform a new translation of the next OCCT shape.
1384
1385@section occt_step_7 Reading from and writing to XDE
1386The *STEPCAFControl* package (TKXDESTEP toolkit) provides tools to read and write STEP files to and from XDE format (see XDE User’s Guide).
72b7576f 1387
72b7576f 1388In addition to the translation of shapes implemented in basic translator, it provides the following:
dba69de2 1389 * STEP assemblies, read as OCCT compounds by basic translator, are translated to XDE assemblies;
1390 * Names of products are translated and assigned to assembly components and instances in XDE;
1391 * STEP external references are recognized and translated (if external documents are STEP files);
1392 * Colors, layers, materials and validation properties assigned to parts or subparts are translated;
1393 * STEP dimensional tolerances are translated.
1394
1395@subsection occt_step_7_1 Description of the process
1396
1397@subsubsection occt_step_7_1_1 Loading a STEP file
72b7576f 1398Before performing any other operation, you must load a STEP file with:
dba69de2 1399~~~~~
72b7576f 1400STEPCAFControl_Reader reader(XSDRAW::Session(), Standard_False);
dba69de2 1401IFSelect_ReturnStatus stat = reader.ReadFile("filename.stp");
1402~~~~~
72b7576f 1403Loading the file only memorizes the data, it does not translate it.
dba69de2 1404
1405@subsubsection occt_step_7_1_2 Checking the loaded STEP file
1406This step is not obligatory. See a description of this step in section <a href="#occt_step_2_3_2">Checking the STEP file</a>.
1407
1408@subsubsection occt_step_7_1_3 Setting the parameters for translation to XDE
1409See a description of this step in section <a href="#occt_step_2_3_3">Setting the translation parameters</a>.
1410
72b7576f 1411In addition, the following parameters can be set for XDE translation of attributes:
1412 * Parameter for transferring colors:
dba69de2 1413~~~~~
72b7576f 1414reader.SetColorMode(mode);
1415// mode can be Standard_True or Standard_False
dba69de2 1416~~~~~
72b7576f 1417 * Parameter for transferring names:
dba69de2 1418~~~~~
72b7576f 1419reader.SetNameMode(mode);
1420// mode can be Standard_True or Standard_False
dba69de2 1421~~~~~
1422@subsubsection occt_step_7_1_4 Performing the translation of a STEP file to XDE
72b7576f 1423The following function performs a translation of the whole document:
dba69de2 1424~~~~~
72b7576f 1425Standard_Boolean ok = reader.Transfer(doc);
dba69de2 1426~~~~~
1427where *doc* is a variable which contains a handle to the output document and should have a type *Handle(TDocStd_Document)*.
1428@subsubsection occt_step_7_1_5 Initializing the process of translation from XDE to STEP
72b7576f 1429Here is how to initialize the process:
dba69de2 1430~~~~~
72b7576f 1431STEPCAFControl_Writer aWriter(XSDRAW::Session(),Standard_False);
dba69de2 1432~~~~~
1433@subsubsection occt_step_7_1_6 Setting the parameters for translation from XDE to STEP
1434
72b7576f 1435The following parameters can be set for a translation of attributes to STEP:
1436 * Parameter for transferring colors:
dba69de2 1437~~~~~
72b7576f 1438aWriter.SetColorMode(mode);
1439// mode can be Standard_True or Standard_False
dba69de2 1440~~~~~
72b7576f 1441 * Parameter for transferring names:
dba69de2 1442~~~~~
72b7576f 1443aWriter.SetNameMode(mode);
1444// mode can be Standard_True or Standard_False
dba69de2 1445~~~~~
1446@subsubsection occt_step_7_1_7 Performing the translation of an XDE document to STEP
72b7576f 1447You can perform the translation of document by calling the function:
dba69de2 1448~~~~~
72b7576f 1449IFSelect_ReturnStatus aRetSt = aWriter.Transfer(doc);
dba69de2 1450~~~~~
1451where *doc* is a variable, which contains a handle to the input document for transferring and should have a type *Handle(TDocStd_Document)*.
1452
1453@subsubsection occt_step_7_18 Writing a STEP file
72b7576f 1454Write a STEP file with:
dba69de2 1455~~~~~
1456IFSelect_ReturnStatus statw = aWriter.WriteFile("filename.stp");
1457~~~~~
72b7576f 1458or
dba69de2 1459~~~~~
72b7576f 1460IFSelect_ReturnStatus statw = writer.WriteFile (S);
dba69de2 1461~~~~~
1462where *S* is *OStream*.
72b7576f 1463
1464
1465