0032452: Data Exchange - IGES reader returns invalid shapes if xstep.cascade.unit...
[occt.git] / dox / user_guides / iges / iges.md
CommitLineData
e6c8fcfe 1IGES Translator {#occt_user_guides__iges}
72b7576f 2==================
3
e5bd0d98 4@tableofcontents
5
dba69de2 6@section occt_iges_1 Introduction
7
e2b55410 8The IGES interface reads IGES files and translates them to Open CASCADE Technology models. The interface is able to translate one entity, a group of entities or a whole file. Before beginning a translation, you can set a range of parameters to manage the translation process. If you like, you can also check file consistency before translation. The IGES interface also translates OCCT models to IGES files.
72b7576f 9
e2b55410 10Other kinds of data such as colors and names can be read or written with the help of XDE tools <i> IGESCAFControl_Reader</i> and <i> IGESCAFControl_Writer</i>.
72b7576f 11
07f2b741 12**Note** :
e2b55410 13
14 * an IGES model is an IGES file that has been loaded into memory.
15 * an IGES entity is an entity in the IGES normal sense.
16 * a root entity is the highest level entity of any given type, e.g. type 144 for surfaces and type 186 for solids. Roots are not referenced by other entities.
17
e6c8fcfe 18This manual mainly explains how to convert an IGES file to an Open CASCADE Technology (**OCCT**) shape and vice versa. It provides basic documentation on conversion.
e2b55410 19
20IGES files produced in accordance with IGES standard versions up to and including version 5.3 can be read. IGES files that are produced by this interface conform to IGES version 5.3 (Initial Graphics Exchange Specification, IGES 5.3. ANS US PRO/IPO-100-1996).
dba69de2 21
72b7576f 22This manual principally deals with two OCCT classes:
23 * The Reader class, which loads IGES files and translates their contents to OCCT shapes,
24 * The Writer class, which translates OCCT shapes to IGES entities and then writes these entities to IGES files.
dba69de2 25
72b7576f 26File translation is performed in the programming mode, via C++ calls, and the resulting OCCT objects are shapes.
dba69de2 27
72b7576f 28All definitions in IGES version 5.3 are recognized but only 3D geometric entities are translated. When the processor encounters data, which is not translated, it ignores it and writes a message identifying the types of data, which was not handled. This message can be written either to a log file or to screen output.
dba69de2 29
e2b55410 30@ref occt_user_guides__shape_healing "Shape Healing" toolkit provides tools to heal various problems, which may be encountered in translated shapes, and to make them valid in Open CASCADE. The Shape Healing is smoothly connected to IGES translator using the same API, only the names of API packages change.
31
dba69de2 32@section occt_iges_2 Reading IGES
33@subsection occt_iges_2_1 Procedure
72b7576f 34You can translate an IGES file to an OCCT shape by following the steps below:
35 -# Load the file,
36 -# Check file consistency,
37 -# Set the translation parameters,
38 -# Perform the file translation,
39 -# Fetch the results.
dba69de2 40@subsection occt_iges_2_2 Domain covered
41@subsubsection occt_iges_2_2_1 Translatable entities
72b7576f 42The types of IGES entities, which can be translated, are:
43 * Points
44 * Lines
45 * Curves
46 * Surfaces
47 * B-Rep entities
48 * Structure entities (groups). Each entity in the group outputs a shape. There can be a group of groups.
e5bd0d98 49 * Subfigures. Each entity defined in a sub-figure outputs a shape
72b7576f 50 * Transformation Matrix.
dba69de2 51
52**Note** that all non-millimeter length unit values in the IGES file are converted to millimeters.
53
54@subsubsection occt_iges_2_2_2 Attributes
72b7576f 55Entity attributes in the Directory Entry Section of the IGES file (such as layers, colors and thickness) are translated to Open CASCADE Technology using XDE.
dba69de2 56@subsubsection occt_iges_2_2_3 Administrative data
72b7576f 57Administrative data, in the Global Section of the IGES file (such as the file name, the name of the author, the date and time a model was created or last modified) is not translated to Open CASCADE Technology. Administrative data can, however, be consulted in the IGES file.
58
59
dba69de2 60@subsection occt_iges_2_3 Description of the process
61@subsubsection occt_iges_2_3_1 Loading the IGES file
72b7576f 62Before performing any other operation, you have to load the file using the syntax below.
77d94fd1 63~~~~{.cpp}
72b7576f 64IGESControl_Reader reader;
65IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”);
77d94fd1 66~~~~
72b7576f 67The loading operation only loads the IGES file into computer memory; it does not translate it.
dba69de2 68
69@subsubsection occt_iges_2_3_2 Checking the IGES file
72b7576f 70This step is not obligatory. Check the loaded file with:
77d94fd1 71~~~~{.cpp}
72b7576f 72Standard_Boolean ok = reader.Check(Standard_True);
77d94fd1 73~~~~
72b7576f 74The variable “ok is True” is returned if no fail message was found; “ok is False” is returned if there was at least one fail message.
77d94fd1 75~~~~{.cpp}
72b7576f 76reader.PrintCheckLoad (failsonly, mode);
77d94fd1 77~~~~
72b7576f 78Error messages are displayed if there are invalid or incomplete IGES entities, giving you information on the cause of the error.
77d94fd1 79~~~~{.cpp}
72b7576f 80Standard_Boolean failsonly = Standard_True or Standard_False;
77d94fd1 81~~~~
72b7576f 82If you give True, you will see fail messages only. If you give False, you will see both fail and warning messages.
dba69de2 83
84Your analysis of the file can be either message-oriented or entity-oriented. Choose your preference with *IFSelect_PrintCount mode = IFSelect_xxx*, where *xxx* can be any of the following:
85* *ItemsByEntity* gives a sequential list of all messages per IGES entity.
86* *CountByItem* gives the number of IGES entities with their types per message.
87* *ShortByItem* gives the number of IGES entities with their types per message and displays rank numbers of the first five IGES entities per message.
88* *ListByItem* gives the number of IGES entities with their type and rank numbers per message.
89* *EntitiesByItem* gives the number of IGES entities with their types, rank numbers and Directory Entry numbers per message.
90
91@subsubsection occt_iges_2_3_3 Setting translation parameters
72b7576f 92The following parameters can be used to translate an IGES file to an OCCT shape. If you give a value that is not within the range of possible values, it will be ignored.
dba69de2 93
72b7576f 94<h4>read.iges.bspline.continuity</h4>
95manages the continuity of BSpline curves (IGES entities 106, 112 and 126) after translation to Open CASCADE Technology (Open CASCADE Technology requires that the curves in a model be at least C1 continuous; no such requirement is made by IGES).
dba69de2 96* 0: no change; the curves are taken as they are in the IGES file. C0 entities of Open CASCADE Technology may be produced.
97* 1: if an IGES BSpline, Spline or CopiousData curve is C0 continuous, it is broken down into pieces of C1 continuous *Geom_BSplineCurve*.
98* 2: This option concerns IGES Spline curves only. IGES Spline curves are broken down into pieces of C2 continuity. If C2 cannot be ensured, the Spline curves will be broken down into pieces of C1 continuity.
99
72b7576f 100Read this parameter with:
77d94fd1 101~~~~{.cpp}
dba69de2 102Standard_Integer ic = Interface_Static::IVal("read.iges.bspline.continuity");
77d94fd1 103~~~~
72b7576f 104Modify this value with:
77d94fd1 105~~~~{.cpp}
dba69de2 106if (!Interface_Static::SetIVal ("read.iges.bspline.continuity",2))
72b7576f 107.. error ..;
77d94fd1 108~~~~
72b7576f 109Default value is 1.
dba69de2 110
111This parameter does not change the continuity of curves that are used in the construction of IGES BRep entities. In this case, the parameter does not influence the continuity of the resulting OCCT curves (it is ignored).
112
113
72b7576f 114<h4>read.precision.mode</h4>
115reads the precision value.
dba69de2 116* File (0) the precision value is read in the IGES file header (default).
117* User (1) the precision value is that of the read.precision.val parameter.
118
72b7576f 119Read this parameter with:
77d94fd1 120~~~~{.cpp}
dba69de2 121Standard_Integer ic = Interface_Static::IVal("read.precision.mode");
77d94fd1 122~~~~
72b7576f 123Modify this value with:
77d94fd1 124~~~~{.cpp}
dba69de2 125if (!Interface_Static::SetIVal ("read.precision.mode",1))
72b7576f 126.. error ..;
77d94fd1 127~~~~
dba69de2 128Default value is *File* (0).
129
72b7576f 130<h4>read.precision.val</h4>
dba69de2 131User 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.
132
72b7576f 133This value is in the measurement unit defined in the IGES file header.
dba69de2 134
72b7576f 135Read this parameter with:
77d94fd1 136~~~~{.cpp}
dba69de2 137Standard_Real rp = Interface_Static::RVal("read.precision.val");
77d94fd1 138~~~~
72b7576f 139Modify this parameter with:
77d94fd1 140~~~~{.cpp}
dba69de2 141if (!Interface_Static::SetRVal ("read.precision.val",0.001))
72b7576f 142.. error ..;
77d94fd1 143~~~~
72b7576f 144Default value is 0.0001.
dba69de2 145
146The value given to this parameter is a target value that is applied to *TopoDS_Vertex, TopoDS_Edge* and *TopoDS_Face* entities. The processor 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. IGES-to-OCCT translation does not improve the quality of the geometry in the original IGES file. This means that the value you enter may be impossible to attain the given quality of geometry in the IGES file.
147
148Value of tolerance used for computation is calculated by multiplying the value of *read.precision.val* and the value of coefficient of transfer from the file units to millimeters.
149
72b7576f 150<h4>read.maxprecision.mode</h4>
151defines the mode of applying the maximum allowed tolerance. Its possible values are:
dba69de2 152
153* *Preferred(0)* maximum tolerance is used as a limit but sometimes it can be exceeded (currently, only for deviation of a 3D curve of an edge from its pcurves and from vertices of such edge) to ensure shape validity;
154* *Forced(1)* maximum tolerance is used as a rigid limit, i.e. it can not be exceeded and, if this happens, tolerance is trimmed to suit the maximum-allowable value.
155
72b7576f 156Read this parameter with:
77d94fd1 157~~~~{.cpp}
dba69de2 158Standard_Integer mv = Interface_Static::IVal("read.maxprecision.mode");
77d94fd1 159~~~~
72b7576f 160Modify this parameter with:
77d94fd1 161~~~~{.cpp}
dba69de2 162if (!Interface_Static::SetIVal ("read.maxprecision.mode",1))
72b7576f 163.. error ..;
77d94fd1 164~~~~
dba69de2 165Default value is *Preferred (0)*.
72b7576f 166
167<h4>read.maxprecision.val</h4>
468856bf 168defines the maximum allowable tolerance (in internal units, which are specified in xstep.cascade.unit) of the shape.
169It should be not less than the basis value of tolerance set in processor (either Resolution from the file or *read.precision.val*).
170Actually, the maximum between *read.maxprecision.val* and basis tolerance is used to define maximum allowed tolerance.
72b7576f 171Read this parameter with:
77d94fd1 172~~~~{.cpp}
dba69de2 173Standard_Real rp = Interface_Static::RVal("read.maxprecision.val");
77d94fd1 174~~~~
72b7576f 175Modify this parameter with:
77d94fd1 176~~~~{.cpp}
dba69de2 177if (!Interface_Static::SetRVal ("read.maxprecision.val",0.1))
72b7576f 178.. error ..;
77d94fd1 179~~~~
72b7576f 180Default value is 1.
181
182<h4>read.stdsameparameter.mode</h4>
458ff6a6 183defines the using of *BRepLib\::SameParameter*. Its possible values are:
184* 0 (Off) -- *BRepLib\::SameParameter* is not called,
185* 1 (On) -- *BRepLib\::SameParameter* is called.
186*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 IGES file or modified by *BRepLib\::SameParameter*.
72b7576f 187Read this parameter with:
77d94fd1 188~~~~{.cpp}
dba69de2 189Standard_Integer mv = Interface_Static::IVal("read.stdsameparameter.mode");
77d94fd1 190~~~~
72b7576f 191Modify this parameter with:
77d94fd1 192~~~~{.cpp}
dba69de2 193if (!Interface_Static::SetIVal ("read.stdsameparameter.mode",1))
72b7576f 194.. error ..;
77d94fd1 195~~~~
dba69de2 196Deafault value is 0 (Off).
72b7576f 197
198<h4>read.surfacecurve.mode</h4>
199preference for the computation of curves in case of 2D/3D inconsistency in an entity which has both 2D and 3D representations.
dba69de2 200
201Here we are talking about entity types 141 (Boundary), 142 (CurveOnSurface) and 508 (Loop). These are entities representing a contour lying on a surface, which is translated to a *TopoDS_Wire*, formed by *TopoDS_Edges*. Each *TopoDS_Edge* must have a 3D curve and a 2D curve that reference the surface.
202
72b7576f 203The processor also decides to re-compute either the 3D or the 2D curve even if both curves are translated successfully and seem to be correct, in case there is inconsistency between them. The processor considers that there is inconsistency if any of the following conditions is satisfied:
204 * the number of sub-curves in the 2D curve is different from the number of sub-curves in the 3D curve. This can be either due to different numbers of sub-curves given in the IGES file or because of splitting of curves during translation.
dba69de2 205 * 3D or 2D curve is a Circular Arc (entity type 100) starting and ending in the same point (note that this case is incorrect according to the IGES standard).
206
458ff6a6 207The parameter *read.surfacecurve.mode* defines which curve (3D or 2D) is used for re-computing the other one:
dba69de2 208* *Default(0)* use the preference flag value in the entity's Parameter Data section. The flag values are:
72b7576f 209 * 0: no preference given,
210 * 1: use 2D for 142 entities and 3D for 141 entities,
211 * 2: use 3D for 142 entities and 2D for 141 entities,
212 * 3: both representations are equally preferred.
dba69de2 213* *2DUse_Preferred (2)* : the 2D is used to rebuild the 3D in case of their inconsistency,
bf62b306 214* *2DUse_Forced (-2)*: the 2D is always used to rebuild the 3D (even if 3D is present in the file),
dba69de2 215* *3DUse_Preferred (3)*: the 3D is used to rebuild the 2D in case of their inconsistency,
216* *3DUse_Forced (-3)*: the 3D is always used to rebuild the 2D (even if 2D is present in the file),
217
218If no preference is defined (if the value of *read.surfacecurve.mode* is *Default* and the value of the preference flag in the entity's Parameter Data section is 0 or 3), an additional analysis is performed.
219
72b7576f 220The 3D representation is preferred to the 2D in two cases:
221 * if 3D and 2D contours in the file have a different number of curves,
222 * if the 2D curve is a Circular Arc (entity type 100) starting and ending in the same point and the 3D one is not.
dba69de2 223
72b7576f 224In any other case, the 2D representation is preferred to the 3D.
225
226If either a 3D or a 2D contour is absent in the file or cannot be translated, then it is re-computed from another contour. If the translation of both 2D and 3D contours fails, the whole curve (type 141 or 142) is not translated. If this curve is used for trimming a face, the face will be translated without this trimming and will have natural restrictions.
dba69de2 227
72b7576f 228Read this parameter with:
77d94fd1 229~~~~{.cpp}
dba69de2 230Standard_Integer ic = Interface_Static::IVal("read.surfacecurve.mode");
77d94fd1 231~~~~
72b7576f 232Modify this value with:
77d94fd1 233~~~~{.cpp}
dba69de2 234if (!Interface_Static::SetIVal ("read.surfacecurve.mode",3))
72b7576f 235.. error ..;
77d94fd1 236~~~~
dba69de2 237Default value is Default (0).
238
72b7576f 239<h4>read.encoderegularity.angle</h4>
dba69de2 240This parameter is used within the *BRepLib::EncodeRegularity()* function which is called for a shape read from an IGES or a STEP file at the end of translation process. This function sets the regularity flag of an edge in a shell when this edge is shared by two faces. This flag shows the continuity, which these two faces are connected with at that edge.
241
72b7576f 242Read this parameter with:
77d94fd1 243~~~~{.cpp}
dba69de2 244Standard_Real era = Interface_Static::RVal("read.encoderegularity.angle");
77d94fd1 245~~~~
72b7576f 246Modify this parameter with:
77d94fd1 247~~~~{.cpp}
dba69de2 248if (!Interface_Static::SetRVal ("read.encoderegularity.angle",0.1))
72b7576f 249.. error ..;
77d94fd1 250~~~~
72b7576f 251Default value is 0.01.
dba69de2 252
72b7576f 253<h4>read.iges.bspline.approxd1.mode</h4>
254This parameter is obsolete (it is rarely used in real practice). If set to True, it affects the translation of bspline curves of degree 1 from IGES: these curves (which geometrically are polylines) are split by duplicated points, and the translator attempts to convert each of the obtained parts to a bspline of a higher continuity.
dba69de2 255
07f2b741 256Read this parameter with:
77d94fd1 257~~~~{.cpp}
dba69de2 258Standard_Real bam = Interface_Static::CVal("read.iges.bspline.approxd1.mode");
77d94fd1 259~~~~
72b7576f 260Modify this parameter with:
77d94fd1 261~~~~{.cpp}
dba69de2 262if (!Interface_Static::SetRVal ("read.encoderegularity.angle","On"))
72b7576f 263.. error ..;
77d94fd1 264~~~~
72b7576f 265Default value is Off.
dba69de2 266
267
268<h4>read.iges.resource.name and read.iges.sequence</h4>
269These 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 IGES translator. The Shape Processing is a user-configurable step, which is performed after the translation and consists in application of a set of operators to a resulting shape. This is a very powerful tool allowing to customize the shape and to adapt it to the needs of a receiving application. By default, the sequence consists of a single operator *ShapeFix* that calls Shape Healing from the IGES translator.
270
07f2b741 271Find an example of the resource file for IGES (which defines parameters corresponding to the sequence applied by default, i.e. if the resource file is not found) in the Open CASCADE Technology sources by the path <i>%CASROOT%/src/XSTEPResource/IGES</i>.
dba69de2 272
07f2b741 273IGES translator will use that file if you define the environment variable *CSF_IGESDefaults*, which should point to the directory where the resource file resides. Note that if you change parameter *read.iges.resource.name*, you should change the name of the resource file and the name of the environment variable correspondingly. The variable should contain a path to the resource file.
dba69de2 274
275Default values:
3f812249 276* read.iges.resource.name -- IGES,
277* read.iges.sequence -- FromIGES.
dba69de2 278
72b7576f 279<h4>xstep.cascade.unit</h4>
dba69de2 280This 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.
281
72b7576f 282Default value is MM.
dba69de2 283
284@subsubsection occt_iges_2_3_4 Selecting entities
285
286A list of entities can be formed by invoking the method *IGESControl_Reader::GiveList*.
77d94fd1 287~~~~{.cpp}
72b7576f 288Handle(TColStd_HSequenceOfTransient) list = reader.GiveList();
77d94fd1 289~~~~
72b7576f 290Several predefined operators can be used to select a list of entities of a specific type.
77d94fd1 291To make a selection, use the method *IGESControl_Reader::GiveList* with the selection type in quotation marks as an argument. You can also make cumulative selections. For example, you would use the following Syntax:
dba69de2 2921. Requesting the faces in the file:
77d94fd1 293~~~~{.cpp}
dba69de2 294faces = Reader.GiveList("iges-faces");
77d94fd1 295~~~~
dba69de2 2962. Requesting the visible roots in the file:
77d94fd1 297~~~~{.cpp}
dba69de2 298visibles = Reader.GiveList(iges-visible-roots);
77d94fd1 299~~~~
dba69de2 3003. Requesting the visible faces:
77d94fd1 301~~~~{.cpp}
dba69de2 302visfac = Reader.GiveList(iges-visible-roots,faces);
77d94fd1 303~~~~
72b7576f 304Using a signature, you can define a selection dynamically, filtering the string by means of a criterion. When you request a selection using the method GiveList, you can give either a predefined selection or a selection by signature. You make your selection by signature using the predefined signature followed by your criterion in parentheses as shown in the example below. The syntaxes given are equivalent to each other.
77d94fd1 305~~~~{.cpp}
72b7576f 306faces = Reader.GiveList(“xst-type(SurfaceOfRevolution)”);
307faces = Reader.GiveList(“iges-type(120)”);
77d94fd1 308~~~~
72b7576f 309You can also look for:
310 * values returned by your signature which match your criterion exactly
77d94fd1 311~~~~{.cpp}
72b7576f 312faces = Reader.GiveList(“xst-type(=SurfaceOfRevolution)”);
77d94fd1 313~~~~
72b7576f 314 * values returned by your signature which do not contain your criterion
77d94fd1 315~~~~{.cpp}
72b7576f 316faces = Reader.GiveList(“xst-type(!SurfaceOfRevolution)”);
77d94fd1 317~~~~
72b7576f 318 * values returned by your signature which do not exactly match your criterion.
77d94fd1 319~~~~{.cpp}
72b7576f 320faces = Reader.GiveList(“xst-type(!=SurfaceOfRevolution)”);
77d94fd1 321~~~~
72b7576f 322
323<h4>List of predefined operators that can be used:</h4>
3f812249 324 * *xst-model-all* -- selects all entities.
325 * *xst-model-roots* -- selects all roots.
326 * *xst-transferrable-all* -- selects all translatable entities.
327 * *xst-transferrable-roots* -- selects all translatable roots (default).
328 * *xst-sharing + \<selection\>* -- selects all entities sharing at least one entity selected by \<selection\>.
329 * *xst-shared + \<selection\>* -- selects all entities shared by at least one entity selected by \<selection\>.
330 * *iges-visible-roots* -- selects all visible roots, whether translatable or not.
331 * *iges-visible-transf-roots* -- selects all visible and translatable roots.
332 * *iges-blanked-roots* -- selects all blank roots, whether translatable or not.
333 * *iges-blanked-transf-roots* -- selects all blank and translatable roots.
2641792e 334 * *iges-status-independent* -- selects entities whose IGES Subordinate Status = 0.
3f812249 335 * *iges-bypass-group* -- selects all root entities. If a root entity is a group (402/7 or 402/9), the entities in the group are selected.
336 * *iges-bypass-subfigure* -- selects all root entities. If a root entity is a subfigure definition (308), the entities in the subfigure definition are selected.
337 * *iges-bypass-group-subfigure* -- selects all root entities. If a root entity is a group (402/7 or 402/9) or a subfigure definition (308), the entities in the group and in the subfigure definition are selected.
338 * *iges-curves-3d* -- selects 3D curves, whether they are roots or not (e.g. a 3D curve on a surface).
339 * *iges-basic-geom* -- selects 3D curves and untrimmed surfaces.
340 * *iges-faces* -- selects face-supporting surfaces (trimmed or not).
341 * *iges-surfaces* -- selects surfaces not supporting faces (i.e. with natural bounds).
342 * *iges-basic-curves-3d* -- selects the same entities as iges-curves-3d. Composite Curves are broken down into their components and the components are selected.
dba69de2 343
344@subsubsection occt_iges_2_3_5 Performing the IGES file translation
72b7576f 345Perform translation according to what you want to translate:
dba69de2 3461. Translate an entity identified by its rank with:
77d94fd1 347~~~~{.cpp}
72b7576f 348Standard_Boolean ok = reader.Transfer (rank);
77d94fd1 349~~~~
dba69de2 3502. Translate an entity identified by its handle with:
77d94fd1 351~~~~{.cpp}
72b7576f 352Standard_Boolean ok = reader.TransferEntity (ent);
77d94fd1 353~~~~
dba69de2 3543. Translate a list of entities in one operation with:
77d94fd1 355~~~~{.cpp}
72b7576f 356Standard_Integer nbtrans = reader.TransferList (list);
357reader.IsDone();
77d94fd1 358~~~~
dba69de2 359where *nbtrans* returns the number of items in the list that produced a shape and *reader.IsDone()* indicates whether at least one entity was translated.
3604. Translate a list of entities, entity by entity:
77d94fd1 361~~~~{.cpp}
72b7576f 362Standard_Integer i,nb = list-Length();
4ee1bdf4 363for (i = 1; i <= nb; i ++) {
dba69de2 364 Handle(Standard_Transient) ent = list-Value(i);
365 Standard_Boolean OK = reader.TransferEntity (ent);
366}
77d94fd1 367~~~~
dba69de2 3685. Translate the whole file (all entities or only visible entities) with:
77d94fd1 369~~~~{.cpp}
72b7576f 370Standard_Boolean onlyvisible = Standard_True or Standard_False;
371reader.TransferRoots(onlyvisible)
77d94fd1 372~~~~
dba69de2 373
e5bd0d98 374@subsubsection occt_iges_2_3_6 Getting the translation results
72b7576f 375Each successful translation operation outputs one shape. A series of translations gives a series of shapes.
dba69de2 376Each time you invoke *TransferEntity, Transfer* or *Transferlist*, their results are accumulated and NbShapes increases. You can clear the results (Clear function) between two translation operations, if you do not do this, the results from the next translation will be added to the accumulation. *TransferRoots* operations automatically clear all existing results before they start.
77d94fd1 377~~~~{.cpp}
72b7576f 378Standard_Integer nbs = reader.NbShapes();
77d94fd1 379~~~~
72b7576f 380returns the number of shapes recorded in the result.
77d94fd1 381~~~~{.cpp}
72b7576f 382TopoDS_Shape shape = reader.Shape(num);,
77d94fd1 383~~~~
4ee1bdf4 384returns the result *num*, where *num* is an integer between 1 and *NbShapes*.
77d94fd1 385~~~~{.cpp}
72b7576f 386TopoDS_Shape shape = reader.Shape();
77d94fd1 387~~~~
72b7576f 388returns the first result in a translation operation.
77d94fd1 389~~~~{.cpp}
72b7576f 390TopoDS_Shape shape = reader.OneShape();
77d94fd1 391~~~~
72b7576f 392returns all results in a single shape which is:
393 * a null shape if there are no results,
394 * in case of a single result, a shape that is specific to that result,
395 * a compound that lists the results if there are several results.
77d94fd1 396~~~~{.cpp}
72b7576f 397reader.Clear();
77d94fd1 398~~~~
72b7576f 399erases the existing results.
77d94fd1 400~~~~{.cpp}
72b7576f 401reader.PrintTransferInfo (failsonly, mode);
77d94fd1 402~~~~
dba69de2 403displays the messages that appeared during the last invocation of *Transfer* or *TransferRoots*.
404
458ff6a6 405If *failsonly* is *IFSelect_FailOnly*, only fail messages will be output, if it is *IFSelect_FailAndWarn*, all messages will be output. Parameter “mode” can have *IFSelect_xxx* values where *xxx* can be:
406 * *GeneralCount* -- gives general statistics on the transfer (number of translated IGES entities, number of fails and warnings, etc)
407 * *CountByItem* -- gives the number of IGES entities with their types per message.
408 * *ListByItem* -- gives the number of IGES entities with their type and DE numbers per message.
409 * *ResultCount* -- gives the number of resulting OCCT shapes per type.
410 * *Mapping* -- gives mapping between roots of the IGES file and the resulting OCCT shape per IGES and OCCT type.
dba69de2 411
412@subsection occt_iges_2_4 Mapping of IGES entities to Open CASCADE Technology shapes
413
414*NOTE* that IGES entity types that are not given in the following tables are not translatable.
72b7576f 415
dba69de2 416@subsubsection occt_iges_2_4_1 Points
417
ba06f8bb 418| IGES entity type | CASCADE shape | Comments |
e5bd0d98 419| :---------------- | :------------- | --------- |
ba06f8bb 420| 116: Point | TopoDS_Vertex | |
dba69de2 421
422@subsubsection occt_iges_2_4_2 Curves
423Curves, which form the 2D of face boundaries, are translated as *Geom2D_Curves* (Geom2D circles, etc.).
424
ba06f8bb 425| IGES entity type | CASCADE shape | Comments |
e5bd0d98 426| :---------------- | :------------ | :------- |
ba06f8bb 427| 100: Circular Arc | TopoDS_Edge | The geometrical support is a *Geom_Circle* or a *Geom_TrimmedCurve* (if the arc is not closed). |
e5bd0d98 428| 102: Composite Curve | TopoDS_Wire | The resulting shape is always a *TopoDS_Wire* that is built from a set of *TopoDS_Edges*. Each *TopoDS_Edge* is connected to the preceding and to the following edge by a common *TopoDS_Vertex*. |
ba06f8bb 429| 104: Conic Arc | TopoDS_Edge | The geometric support depends on whether the IGES entity's form is 0 (*Geom_Circle*), 1 (*Geom_Ellipse*), 2 (*Geom_Hyperbola*), or 3 (*Geom_Parabola*). A *Geom_TrimmedCurve* is output if the arc is not closed. |
430| 106: Copious Data | TopoDS_Edge or TopoDS_Wire | IGES entity Copious Data (type 106, forms 1-3) is translated just as the IGES entities Linear Path (106/11-13) and the Simple Closed Planar Curve (106/63). Vectors applying to forms other than 11,12 or 63 are ignored. The *Geom_BSplineCurve* (geometrical support) has C0 continuity. If the Copious Data has vectors (DataType = 3) they will be ignored. |
431| 110: Line | TopoDS_Edge | The supporting curve is a *Geom_TrimmedCurve* whose basis curve is a *Geom_Line*. |
432| 112: Parametric Spline Curve | TopoDS_Edge or TopoDS_Wire | The geometric support is a Geom_BsplineCurve. |
433| 126: BSpline Curve | TopoDS_Edge or TopoDS_Wire | |
434| 130: Offset Curve | TopoDS_Edge or TopoDS_Wire | The resulting shape is a *TopoDS_Edge* or a *TopoDS_Wire* (depending on the translation of the basis curve) whose geometrical support is a *Geom_OffsetCurve* built from a basis *Geom_Curve*. Limitation: The IGES Offset Type value must be 1. |
435| 141: Boundary | TopoDS_Wire | Same behavior as for the Curve On Surface (see below). The translation of a non-referenced Boundary IGES entity in a *BoundedSurface* IGES entity outputs a *TopoDS_Edge* or a *TopoDS_Wire* with a *Geom_Curve*. |
436| 142: Curve On Surface | TopoDS_Wire | Each *TopoDS_Edge* is defined by a 3D curve and by a 2D curve that references the surface. |
dba69de2 437
438The type of OCCT shapes (either *TopDS_Edges* or *TopoDS_Wires*) that result from the translation of IGES entities 106, 112 and 126 depends on the continuity of the curve in the IGES file and the value of the *read.iges.bspline.continuity* translation parameter.
439
440@subsubsection occt_iges_2_4_3 Surfaces
e5bd0d98 441Translation of a surface outputs either a *TopoDS_Face* or a *TopoDS_Shell*.
442If a *TopoDS_Face* is output, its geometrical support is a *Geom_Surface* and its outer and inner boundaries (if it has any) are *TopoDS_Wires*.
443
ba06f8bb 444| IGES entity type | CASCADE shape | Comments |
e5bd0d98 445| :-------------- | :------------ | :--------- |
ba06f8bb 446| 108: Plane | TopoDS_Face | The geometrical support for the *TopoDS_Face* is a *Geom_Plane* and the orientation of its *TopoDS_Wire* depends on whether it is an outer *TopoDS_Wire* or whether it is a hole. |
447| 114: Parametric Spline Surface | TopoDS_Face | The geometrical support of a *TopoDS_Face* is a *Geom_BSplineSurface*. |
448| 118: Ruled Surface | TopoDS_Face or TopoDS_Shell | The translation of a Ruled Surface outputs a *TopoDS_Face* if the profile curves become *TopoDS_Edges*, or a *TopoDS_Shell* if the profile curves become *TopoDS_Wires*. Limitation: This translation cannot be completed when these two *TopoDS_Wires* are oriented in different directions. |
668c2575 449| 120: Surface Of Revolution | TopoDS_Face or TopoDS_Shell | The translation of a Surface Of Revolution outputs: a *TopoDS_Face* if the generatrix becomes a *TopoDS_Edge*, a *TopoDS_Shell* if the generatrix becomes a *TopoDS_Wire*. The geometrical support may be: *Geom_CylindricalSurface, Geom_ConicalSurface, Geom_SphericalSurface, Geom_ToroidalSurface* or a *Geom_SurfaceOfRevolution* depending on the result of the CASCADE computation (based on the generatrix type). |
ba06f8bb 450| 122: Tabulated Cylinder | TopoDS_Face or TopoDS_Shell | The translation outputs a *TopoDS_Face* if the base becomes a *TopoDS_Edge* or a *TopoDS_Shell* if the base becomes a *TopoDS_Wire*. The geometrical support may be *Geom_Plane, Geom_Cylindrical Surface* or a *Geom_SurfaceOfLinearExtrusion* depending on the result of the CASCADE computation (based on the generatrix type). The *Geom_Surface* geometrical support is limited according to the generatrix. |
451| 128: BSpline Surface | TopoDS_Face | The geometrical support of the *TopoDS_Face* is a *Geom_BsplineSurface*. |
452| 140: Offset Surface | TopoDS_Face | The translation of an Offset Surface outputs a *TopoDS_Face* whose geometrical support is a *Geom_OffsetSurface*. Limitations: For OCCT algorithms, the original surface must be C1-continuous so that the *Geom_OffsetSurface* can be created. If the basis surface is not C1-continuous, its translation outputs a *TopoDS_Shell* and only the first *TopoDS_Face* in the *TopoDS_Shell* is offset. |
453| 143: Bounded Surface | TopoDS_Face or TopoDS_Shell | If the basis surface outputs a *TopoDS_Shell* (that has more than one *TopoDS_Face*), the IGES boundaries are not translated. Limitations: If the bounding curves define holes, natural bounds are not created. If the orientation of the contours is wrong, it is not corrected. |
454| 144: Trimmed Surface | TopoDS_Face or TopoDS_Shell | For the needs of interface processing, the basis surface must be a face. Shells are only processed if they are single-face. The contours (wires that are correctly oriented according to the definition of the IGES 142: Curve On Surface entity) are added to the face that is already created. If the orientation of the contours is wrong, it is corrected. |
455| 190: Plane Surface | TopoDS_Face | This type of IGES entity can only be used in BRep entities in place of an IGES 108 type entity. The geometrical support of the face is a *Geom_Plane*. |
dba69de2 456
457
458@subsubsection occt_iges_2_4_4 Boundary Representation Solid Entities
459
ba06f8bb 460| IGES entity type | CASCADE shape | Comments |
668c2575 461| :---------------- | :------------ | :------- |
ba06f8bb 462| 186: ManifoldSolid | TopoDS_Solid | |
463| 514: Shell | TopoDS_Shell | |
464| 510: Face | TopoDS_Face | This is the lowest IGES entity in the BRep structure that can be specified as a starting point for translation. |
465| 508: Loop | TopoDS_Wire | |
466| 504: Edge List | | |
467| 502: Vertex List | | |
dba69de2 468
469
470@subsubsection occt_iges_2_4_5 Structure Entities
471
ba06f8bb 472| IGES entity type | CASCADE shape | Comments |
668c2575 473| :---------------- | :------------ | :------- |
ba06f8bb 474| 402/1: Associativity Instance: Group with back pointers | TopoDS_Compound | |
475| 402/7: Associativity Instance: Group without back pointers | TopoDS_Compound | |
668c2575 476| 402/9: Associativity Instance: Single Parent | TopoDS_Face | The translation of a *SingleParent* entity is only performed for 402 form 9 with entities 108/1 and 108/-1. The geometrical support for the *TopoDS_Face* is a *Geom_Plane* with boundaries: the parent plane defines the outer boundary; the child planes define the inner boundaries. |
dba69de2 477
478@subsubsection occt_iges_2_4_6 Subfigures
479
ba06f8bb 480| IGES entity type | CASCADE shape | Comments |
668c2575 481| :---------------- | :------------ | :------- |
ba06f8bb 482| 308: Subfigure Definition | TopoDS_Compound | This IGES entity is only translated when there are no Singular Subfigure Instance entities. |
483| 408: Singular Subfigure Instance | TopoDS_Compound | This shape has the Subfigure Definition Compound as its origin and is positioned in space by its translation vector and its scale factor. |
dba69de2 484
485@subsubsection occt_iges_2_4_7 Transformation Matrix
486
ba06f8bb 487| IGES entity type | CASCADE shape | Comments |
668c2575 488| :--------------- | :------------ | :------- |
ba06f8bb 489| 124: Transformation Matrix | Geom_Transformation | This entity is never translated alone. It must be included in the definition of another entity. |
dba69de2 490
491
492@subsection occt_iges_2_5 Messages
72b7576f 493Messages are displayed concerning the normal functioning of the processor (transfer, loading, etc.).
494You must declare an include file:
77d94fd1 495~~~~{.cpp}
4ee1bdf4 496#include \<Interface_DT.hxx\>
77d94fd1 497~~~~
dba69de2 498
72b7576f 499You have the choice of the following options for messages:
77d94fd1 500~~~~{.cpp}
72b7576f 501IDT_SetLevel (level);
77d94fd1 502~~~~
72b7576f 503level modifies the level of messages:
504 * 0: no messages
505 * 1: raise and fail messages are displayed, as are messages concerning file access,
506 * 2: warnings are also displayed.
77d94fd1 507~~~~{.cpp}
72b7576f 508IDT_SetFile (“tracefile.log”);
77d94fd1 509~~~~
72b7576f 510prints the messages in a file,
77d94fd1 511~~~~{.cpp}
72b7576f 512IDT_SetStandard();
77d94fd1 513~~~~
72b7576f 514restores screen output.
dba69de2 515
516@subsection occt_iges_2_6 Tolerance management
517@subsubsection occt_iges_2_6_1 Values used for tolerances during reading IGES
518
72b7576f 519During the transfer of IGES to Open CASCADE Technology several parameters are used as tolerances and precisions for different algorithms. Some of them are computed from other using specific functions.
dba69de2 520
72b7576f 521<h4>3D (spatial) tolerances</h4>
dba69de2 522
e5bd0d98 523* Package method *Precision\::Confusion* equal to 10<sup>-7</sup> is used as a minimal distance between points, which are considered distinct.
dba69de2 524* Resolution in the IGES file is defined in the Global section of an IGES file. It is used as a fundamental value of precision during the transfer.
525* User-defined variable *read.precision.val* can be used instead of resolution from the file when parameter *read.precision.mode* is set to 1 ("User").
526* Field *EpsGeom* of the class *IGESToBRep_CurveAndSurface* is a basic precision for translating an IGES object. It is set for each object of class *IGESToBRep_CurveAndSurface* and its derived classes. It is initialized for the root of transfer either by value of resolution from the file or by value of *read.precision.val*, depending on the value of *read.precision.mode* parameter. It is returned by call to method *IGESToBRep_CurvAndSurface::GetEpsGeom*. As this value belongs to measurement units of the IGES file, it is usually multiplied by the coefficient *UnitFactor* (returned by method *IGESToBRep_CurvAndSurface::GetUnitFactor*) to convert it to Open CASCADE Technology units.
4ee1bdf4 527* Field *MaxTol* of the class *IGESToBRep_CurveAndSurface* is used as the maximum tolerance for some algorithms. Currently, it is computed as the maximum between 1 and *GetEpsGeom* \* *GetUnitFactor*. This field is returned by method *IGESToBRep_CurvAndSurface::GetMaxTol*.
dba69de2 528
72b7576f 529<h4>2D (parametric) tolerances</h4>
dba69de2 530
e5bd0d98 531* Package method *Precision\::PConfusion* equal to <i> 0.01*Precision\::Confusion</i>, i.e. 10<sup>-9</sup>. It is used to compare parametric bounds of curves.
dba69de2 532* Field *EpsCoeff* of the class *IGESToBRep_CurveAndSurface* is a parametric precision for translating an IGES object. It is set for each object of class *IGESToBRep_CurveAndSurface* and its derived classes. Currently, it always has its default value 10<sup>-6</sup>. It is returned by call to method *IGESToBRep_CurvAndSurface::GetEpsCoeff*. This value is used for translating 2d objects (for instance, parametric curves).
533* Methods *UResolution(tolerance3d)* 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.
534* Methods *Resolution(tolerance3d)* of the class *GeomAdaptor_Curve* or *BRepAdaptor_Curve* return tolerance in the parametric space of a curve computed from 3d tolerance.
535
72b7576f 536<h4>Zero-dimensional tolerances</h4>
dba69de2 537* Field *Epsilon* of the class *IGESToBRep_CurveAndSurface* is set for each object of class *IGESToBRep_CurveAndSurface* and returned by call to method *GetEpsilon*. It is used in comparing angles and converting transformation matrices. In most cases, it is reset to a fixed value (10<sup>-5</sup> - 10<sup>-3</sup>) right before use. The default value is 10<sup>-4</sup>.
538
539@subsubsection occt_iges_2_6_2 Initial setting of tolerances in translating objects
540
541Transfer starts from one entity treated as a root (either the actual root in the IGES file or an entity selected by the user). The function which performs the transfer (that is *IGESToBRep_Actor::Transfer* or *IGESToBRep_Reader::Transfer*) creates an object of the type *IGESToBRep_CurveAndSurface*, which is intended for translating geometry.
542
543This object contains three tolerances: *Epsilon, EpsGeom* and *EpsCoeff*.
544
545Parameter *Epsilon* is set by default to value 10<sup>-4</sup>. In most cases when it is used in the package *IGESToBRep*, it is reset to a fixed value, either 10<sup>-5</sup> or 10<sup>-4</sup> or 10<sup>-3</sup>. It is used as precision when comparing angles and transformation matrices and does not have influence on the tolerance of the resulting shape.
546
547Parameter *EpsGeom* is set right after creating a *IGESToBRep_CurveAndSurface* object to the value of resolution, taken either from the Global section of an IGES file, or from the *XSTEP.readprecision.val* parameter, depending on the value of *XSTEP.readprecision.mode*.
548
549Parameter *EpsCoeff* is set by default to 10<sup>-6</sup> and is not changed.
550
551During the transfer of a shape, new objects of type *IGESToBRep_CurveAndSurface* are created for translating subshapes. All of them have the same tolerances as the root object.
552
553@subsubsection occt_iges_2_6_3 Transfer process
72b7576f 554<h4>Translating into Geometry</h4>
dba69de2 555Geometrical entities are translated by classes *IGESToBRep_BasicCurve* and *IGESToBRep_BasicSurface*. Methods of these classes convert curves and surfaces of an IGES file to Open CASCADE Technology geometry objects: *Geom_Curve, Geom_Surface,* and *Geom_Transformation*.
556
72b7576f 557Since these objects are not BRep objects, they do not have tolerances. Hence, tolerance parameters are used in these classes only as precisions: to detect specific cases (e.g., to distinguish a circle, an ellipse, a parabola and a hyperbola) and to detect bad cases (such as coincident points).
dba69de2 558
72b7576f 559Use of precision parameters is reflected in the following classes:
3f812249 560* *IGESToBRep_BasicCurve* -- all parameters and points are compared with precision *EpsGeom*. All transformations (except *IGESToBRep_BasicCurve::TransferTransformation*) are fulfilled with precision *Epsilon* which is set to 10<sup>-3</sup> (in the *IGESToBRep_BasicCurve::TransferTransformation* the value 10<sup>-5</sup> is used).
561* *IGESToBRep_BasicCurve::TransferBSplineCurve* -- all weights of *BSplineCurve* are assumed to be more than *Precision::PConfusion* (else the curve is not translated).
562* *IGESToBRep_BasicSurface* -- all parameters and points are compared with precision *EpsGeom*. All transformations are fulfilled with precision *Epsilon*, which is set to 10<sup>-3</sup>.
563* *IGESToBRep_BasicSurface::TransferBSplineSurface* -- all weights of *BSplineSurface* are assumed to be more than *Precision::PConfusion* (else the surface is not translated).
dba69de2 564
565
72b7576f 566<h4>Translating into Topology</h4>
dba69de2 567
e5bd0d98 568IGES entities represented as topological shapes and geometrical objects are translated into OCCT shapes by use of the classes *IGESToBRep_TopoCurve, IGESToBRep_TopoSurface, IGESToBRep_BRepEntity* and *ShapeFix_Wire*.
569
4ee1bdf4 570Class *IGESToBRep_BRepEntity* is intended for transferring BRep entities (IGES version is 5.1 or greater) while the two former are used for translating geometry and topology defined in IGES versions prior to 5.1. Methods from *IGESToBRep_BRepEntity* call methods from *IGESToBRep_TopoCurve* and *IGESToBRep_TopoSurface*, while those call methods from *IGESToBRep_BasicCurve* and *IGESToBRep_BasicSurface* to translate IGES geometry into OCCT geometry.
e5bd0d98 571
72b7576f 572Although the IGES file contains only one parameter for tolerance in the Global Section, OCCT shapes are produced with different tolerances. As a rule, updating the tolerance is fulfilled according to local distances between shapes (distance between vertices of adjacent edges, deviation of edge’s 3D curve and its parametric curve and so on) and may be less or greater than precision in the file.
e5bd0d98 573
72b7576f 574The following classes show what default tolerances are used when creating shapes and how they are updated during transfer.
e5bd0d98 575
72b7576f 576<h5>Class IGESToBRep_TopoCurve</h5>
e5bd0d98 577
4ee1bdf4 578All methods are in charge of transferring curves from IGES curve entities <i>(TransferCompositeCurve, Transfer2dCompositeCurve, TransferCurveOnFace, TransferBoundaryOnFace, TransferOffsetCurve, TransferTopoBasicCurve)</i> if an entity has transformation call to *IGESData_ToolLocation::ConvertLocation* with *Epsilon* value set to 10<sup>-4</sup>.
3f812249 579 * *IGESToBRep_TopoCurve::TransferPoint* -- vertex is constructed from a Point entity with tolerance *EpsGeom*UnitFactor*.
580 * *IGESToBRep_TopoCurve::Transfer2dPoint* -- vertex is constructed from a Point entity with tolerance *EpsCoeff*.
581 * *IGESToBRep_TopoCurve::TransferCompositeCurveGeneral* -- obtains shapes (edges or wires) from other methods and adds them into the resulting wire. Two adjacent edges of the wire can be connected with tolerance up to *MaxTol*.
07f2b741 582 * *IGESToBRep_TopoCurve::TransferCurveOnFace* and *IGESToBRep_TopoCurve::TransferBoundaryOnFace* build a wire from 3D and 2D representations of a curve on surface. Edges and vertices of the wire cannot have tolerance larger than *MaxTol*. The value *EpsGeom*UnitFactor* is passed into *ShapeFix_Wire::SetPrecision* and *MaxTol* is passed into *ShapeFix_Wire::MaxTolerance*. To find out how these parameters affect the resulting tolerance changes, refer to class *ShapeFix_Wire*.
3f812249 583 * *IGESToBRep_TopoCurve::TransferTopoBasicCurve* and *IGESToBRep_TopoCurve::Transfer2dTopoBasicCurve* -- the boundary vertices of an edge (or a wire if a curve was of C0 continuity) translated from a basis IGES curve (*BSplineCurve, CopiousData, Line,* etc.) are built with tolerance *EpsGeom*UnitFactor*, the edge tolerance is *Precision::Confusion*. If a curve was divided into several edges, the common vertices of such adjacent edges have tolerance *Precision::Confusion*.
e5bd0d98 584
585
72b7576f 586<h5>Class IGESToBRep_TopoSurface</h5>
e5bd0d98 587
588All faces created by this class have tolerance *Precision::Confusion*.
589
72b7576f 590<h5>Class IGESToBRep_BRepEntity</h5>
e5bd0d98 591
3f812249 592 * *IGESToBRep_BRepEntity::TransferVertex* -- the vertices from the *VertexList* entity are constructed with tolerance *EpsGeom*UnitFactor*.
593 * *IGESToBRep_BRepEntity::TransferEdge* -- the edges from the *EdgeList* entity are constructed with tolerance *Precision::Confusion*.
594 * *IGESToBRep_BRepEntity::TransferLoop* -- this function works like *IGESToBRep_TopoCurve::TransferCurveOnFace* and *IGESToBRep_TopoCurve::TransferBoundaryOnFace*.
595 * *IGESToBRep_BRepEntity::TransferFace* -- the face from the *Face* IGES entity is constructed with tolerance *Precision::Confusion*.
e5bd0d98 596
72b7576f 597<h5>Shape Healing classes</h5>
e5bd0d98 598After performing a simple mapping, shape-healing algorithms are called (class *ShapeFix_Shape*) by *IGESToBRep_Actor::Transfer()*. Shape-healing algorithm performs the correction of the resulting OCCT shape.
599Class *ShapeFix_Wire* can increase the tolerance of a shape. This class is used in *IGESToBRep_BRepEntity::TransferLoop*, *IGESToBRep_TopoCurve::TransferBoundaryOnFace* and *IGESToBRep_TopoCurve::TransferCurveOnFace* for correcting a wire. The maximum possible tolerance applied to the edges or vertices after invoking the methods of this class is *MaxTolerance* (set by method *ShapeFix_Wire::MaxTolerance()* ).
72b7576f 600
dba69de2 601@subsection occt_iges_2_7 Code architecture
e5bd0d98 602
72b7576f 603The following diagram illustrates the structure of calls in reading IGES.
604The highlighted classes produce OCCT geometry.
e5bd0d98 605
d6b4d3d0 606@figure{/user_guides/iges/images/iges_image003.png,"The structure of calls in reading IGES",420}
72b7576f 607
dba69de2 608@subsection occt_iges_2_8 Example
e5bd0d98 609
77d94fd1 610~~~~{.cpp}
72b7576f 611#include “IGESControl_Reader.hxx”
612#include “TColStd_HSequenceOfTransient.hxx”
613#include “TopoDS_Shape.hxx”
614{
615IGESControl_Reader myIgesReader;
616Standard_Integer nIgesFaces,nTransFaces;
617
618myIgesReader.ReadFile (“MyFile.igs”);
619//loads file MyFile.igs
620
621Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList(“iges-faces”);
622//selects all IGES faces in the file and puts them into a list called //MyList,
623
624nIgesFaces = myList-Length();
625nTransFaces = myIgesReader.TransferList(myList);
626//translates MyList,
627
4ee1bdf4 628cout<<"IGES Faces: "<<nIgesFaces<<" Transferred:"<<nTransFaces<<endl;
72b7576f 629TopoDS_Shape sh = myIgesReader.OneShape();
630//and obtains the results in an OCCT shape.
631}
77d94fd1 632~~~~
72b7576f 633
e5bd0d98 634@section occt_iges_3 Writing IGES
635@subsection occt_iges_3_1 Procedure
72b7576f 636
72b7576f 637You can translate OCCT shapes to IGES entities in the following steps:
e5bd0d98 6381. Initialize the process.
6392. Set the translation parameters,
6403. Perform the model translation,
6414. Write the output IGES file.
642
72b7576f 643You can translate several shapes before writing a file. Each shape will be a root entity in the IGES model.
e5bd0d98 644
645@subsection occt_iges_3_2 Domain covered
72b7576f 646There are two families of OCCT objects that can be translated:
647 * geometrical,
648 * topological.
e5bd0d98 649
650@subsection occt_iges_3_3 Description of the process
651@subsubsection occt_iges_3_3_1 Initializing the process
652
72b7576f 653Choose the unit and the mode you want to use to write the output file as follows:
e5bd0d98 654* *IGESControl_Controller::Init* performs standard initialization. Returns False if an error occurred.
655* *IGESControl_Writer writer* uses the default unit (millimeters) and the default write mode (Face).
656* *IGESControl_Writer writer (UNIT)* uses the Face write mode and any of the units that are accepted by IGES.
657* *IGESControl_Writer writer (UNIT,modecr)* uses the unit (accepted by IGES) and the write mode of your choice.
658 * 0: Faces,
659 * 1: BRep
660The result is an *IGESControl_Writer* object.
661
662@subsubsection occt_iges_3_3_2 Setting the translation parameters
663
72b7576f 664The following parameters are used for the OCCT-to-IGES translation.
72b7576f 665
e5bd0d98 666* *write.iges.brep.mode:* allows choosing the write mode:
3f812249 667 * "Faces" (0): OCCT *TopoDS_Faces* will be translated into IGES 144 (Trimmed Surface) entities, no BRep entities will be written to the IGES file,
668 * "BRep" (1): OCCT *TopoDS_Faces* will be translated into IGES 510 (Face) entities, the IGES file will contain BRep entities.
72b7576f 669Read this parameter with:
77d94fd1 670~~~~{.cpp}
e5bd0d98 671Standard_Integer byvalue = Interface_Static::IVal("write.iges.brep.mode");
77d94fd1 672~~~~
72b7576f 673Modify this parameter with:
77d94fd1 674~~~~{.cpp}
e5bd0d98 675Interface_Static::SetIVal ("write.iges.brep.mode", 1);
77d94fd1 676~~~~
e5bd0d98 677Default value is "Faces" (0).
678* *write.convertsurface.mode* when writing to IGES in the BRep mode, this parameter indicates whether elementary surfaces (cylindrical, conical, spherical, and toroidal) are converted into corresponding IGES 5.3 entities (if the value of a parameter value is On), or written as surfaces of revolution (by default).
679* *write.iges.unit:* allows choosing the unit. The default unit for Open CASCADE Technology is "MM" (millimeter). You can choose to write a file into any unit accepted by IGES.
ba06f8bb 680 * Read this parameter with *Standard_String byvalue = Interface_Static::CVal("write.iges.unit")*;
681 * Modify this parameter with *Interface_Static::SetCVal ("write.iges.unit", "INCH");*
a25d5aaa 682* *write.iges.header.author:* gives the name of the author of the file. The default value is the system name of the user.
ba06f8bb 683 * Read this parameter with *Standard_String byvalue = Interface_Static::CVal("write.iges.header.author")*;
684 * Modify this value with *Interface_Static::SetCVal ("write.iges.header.author", "name")*;
e5bd0d98 685* *write.iges.header.company:* gives the name of the sending company. The default value is "" (empty).
ba06f8bb 686 * Read this parameter with *Standard_String byvalue = Interface_Static::CVal("write.iges.header.company");*
687 * Modify this value with *Interface_Static::SetCVal ("write.iges.header.company", "Open CASCADE");*
e5bd0d98 688* *write.iges.header.product:* gives the name of the sending product. The default value is "CAS.CADE IGES processor Vx.x", where *x.x* means the current version of Open CASCADE Technology.
ba06f8bb 689 * Read this parameter with *Standard_String byvalue = Interface_Static::CVal("write.iges.header.product")*;
690 * Modify this value with *Interface_Static::SetCVal ("write.iges.header.product", "product name")*;
3f812249 691* *write.iges.header.receiver:* -- gives the name of the receiving company. The default value is "" (empty).
ba06f8bb 692 * Read this parameter with *Standard_String byvalue = Interface_Static::CVal("write.iges.header.receiver");*
a25d5aaa 693 * Modify this value with *Interface_Static::SetCVal ("write.iges.header.receiver", "receiver name");*
e5bd0d98 694* *write.precision.mode:* specifies the mode of writing the resolution value into the IGES file.
ba06f8bb 695 * "Least" (-1): resolution value is set to the minimum tolerance of all edges and all vertices in an OCCT shape.
696 * "Average" (0): resolution value is set to average between the average tolerance of all edges and the average tolerance of all vertices in an OCCT shape. This is the default value.
697 * "Greatest" (1): resolution value is set to the maximum tolerance of all edges and all vertices in an OCCT shape.
698 * "Session" (2): resolution value is that of the write.precision.val parameter.
699
4ee1bdf4 700 * Read this parameter with <i>Standard_Integer ic = Interface_Static::IVal("write.precision.mode");</i>
701 * Modify this parameter with <i>if (!Interface_Static\::SetIVal("write.precision.mode",1)) .. error .. </i>
e5bd0d98 702* *write.precision.val:* is the user precision value. This parameter gives the resolution value for an IGES file when the *write.precision.mode* parameter value is 1. It is equal to 0.0001 by default, but can take any real positive (non null) value.
703
72b7576f 704Read this parameter with:
77d94fd1 705~~~~{.cpp}
72b7576f 706Standard_Real rp = Interface_Static::RVal(;write.precision.val;);
77d94fd1 707~~~~
72b7576f 708Modify this parameter with:
77d94fd1 709~~~~{.cpp}
72b7576f 710if (!Interface_Static::SetRVal(;write.precision.val;,0.01))
711.. error ..
77d94fd1 712~~~~
72b7576f 713Default value is 0.0001.
668c2575 714
07f2b741 715<h4>write.iges.resource.name</h4> and <h4>write.iges.sequence</h4> are the same as the corresponding read.iges.\* parameters. Note that the default sequence for writing contains *DirectFaces* operator, which converts elementary surfaces based on left-hand axes (valid in CASCADE) to right-hand axes (which are valid only in IGES).
668c2575 716
717Default values :
77d94fd1 718~~~~{.cpp}
3f812249 719write.iges.resource.name - IGES,
720write.iges.sequence - ToIGES.
77d94fd1 721~~~~
668c2575 722
723@subsubsection occt_iges_3_3_3 Performing the Open CASCADE Technology shape translation
724
72b7576f 725You can perform the translation in one or several operations. Here is how you translate topological and geometrical objects:
77d94fd1 726~~~~{.cpp}
668c2575 727Standard_Boolean ok = writer.AddShape (TopoDS_Shape);
77d94fd1 728~~~~
668c2575 729*ok* is True if translation was correctly performed and False if there was at least one entity that was not translated.
77d94fd1 730~~~~{.cpp}
72b7576f 731Standard_Boolean ok = writer.AddGeom (geom);
77d94fd1 732~~~~
668c2575 733where *geom* is *Handle(Geom_Curve)* or *Handle(Geom_Surface)*;
734*ok* is True if the translation was correctly performed and False if there was at least one entity whose geometry was not among the allowed types.
735
736@subsubsection occt_iges_3_3_4 Writing the IGES file
72b7576f 737Write the IGES file with:
77d94fd1 738~~~~{.cpp}
668c2575 739Standard_Boolean ok = writer.Write ("filename.igs");
77d94fd1 740~~~~
72b7576f 741to give the file name.
77d94fd1 742~~~~{.cpp}
72b7576f 743Standard_Boolean ok = writer.Write (S);
77d94fd1 744~~~~
668c2575 745where *S* is *Standard_OStream*
746*ok* is True if the operation was correctly performed and False if an error occurred (for instance, if the processor could not create the file).
747
748@subsection occt_iges_3_4 Mapping Open CASCADE Technology shapes to IGES entities
749
72b7576f 750Translated objects depend on the write mode that you chose. If you chose the Face mode, all of the shapes are translated, but the level of topological entities becomes lower (geometrical one). If you chose the BRep mode, topological OCCT shapes become topological IGES entities.
668c2575 751
752@subsubsection occt_iges_3_4_1 Curves
753
ba06f8bb 754| CASCADE shape | IGES entity type | Comments |
668c2575 755| :------------ | :---------------- | :------- |
ba06f8bb 756| Geom_BsplineCurve | 126: BSpline Curve | |
757| Geom_BezierCurve | 126: BSpline Curve | |
758| Geom_TrimmedCurve | All types of translatable IGES curves | The type of entity output depends on the type of the basis curve. If the curve is not trimmed, limiting points will be defined by the CASCADE RealLast value. |
759| Geom_Circle | 100: Circular Arc or 126: BSpline Curve | A BSpline Curve is output if the *Geom_Circle* is closed |
760| Geom_Ellipse | 104: Conic Arc or 126: BSpline Curve | A Conic Arc has Form 1. A BSpline Curve is output if the *Geom_Ellipse* is closed. |
668c2575 761| Geom_Hyperbola | 104: Conic Arc | Form 2 |
ba06f8bb 762| Geom_Parabola | 104: Conic Arc | Form 3 |
763| Geom_Line | 110: Line | |
764| Geom_OffsetCurve | 130: Offset Curve | |
668c2575 765
766@subsubsection occt_iges_3_4_2 Surfaces
767
ba06f8bb 768| CASCADE shapes | IGES entity type | Comments |
668c2575 769| :------------- | :--------------- | :------- |
770| Geom_BSplineSurface | 128: BSpline Surface | |
ba06f8bb 771| Geom_BezierSurface | 128: BSpline Surface | |
668c2575 772| Geom_RectangularTrimmedSurface | All types of translatable IGES surfaces. | The type of entity output depends on the type of the basis surface. If the surface is not trimmed and has infinite edges/sides, the coordinates of the sides in IGES will be limited to the CASCADE *RealLast* value. |
773| Geom_Plane | 128: BSpline Surface or 190: Plane Surface | A BSpline Surface (of degree 1 in U and V) is output if you are working in the face mode. A Plane Surface is output if you are working in the BRep mode. |
774| Geom_CylindricalSurface | 120: Surface Of Revolution | |
ba06f8bb 775| Geom_ConicalSurface | 120: Surface Of Revolution | |
776| Geom_SphericalSurface | 120: Surface Of Revolution | |
777| Geom_ToroidalSurface | 120: Surface Of Revolution | |
778| Geom_SurfaceOfLinearExtrusion | 122: Tabulated Cylinder | |
779| Geom_SurfaceOfRevolution | 120: Surface Of Revolution | |
668c2575 780| Geom_OffsetSurface | 140: Offset Surface | |
781
3f812249 782@subsubsection occt_iges_3_4_3 Topological entities -- Translation in Face mode
668c2575 783
ba06f8bb 784| CASCADE shapes | IGES entity type | Comments |
668c2575 785| :------------- | :--------------- | :------- |
ba06f8bb 786| Single TopoDS_Vertex | 116: 3D Point | |
668c2575 787| TopoDS_Vertex in a TopoDS_Edge | No equivalent | Not transferred. |
788| TopoDS_Edge | All types of translatable IGES curves | The output IGES curve will be the one that corresponds to the Open CASCADE Technology definition. |
ba06f8bb 789| Single TopoDS_Wire | 102: Composite Curve | Each *TopoDS_Edge* in the *TopoDS_Wire* results in a curve. |
668c2575 790| TopoDS_Wire in a TopoDS_Face | 142: Curve On Surface | Both curves (3D and pcurve) are transferred if they are defined and result in a simple curve or a composite curve depending on whether there is one or more edges in the wire.Note: if the basis surface is a plane (108), only the 3D curve is used. |
791| TopoDS_Face | 144: Trimmed Surface | |
ba06f8bb 792| TopoDS_Shell | 402: Form 1 Group or no equivalent | Group is created only if *TopoDS_Shell* contains more than one *TopoDS_Face*. The IGES group contains Trimmed Surfaces. |
793| TopoDS_Solid | 402: Form 1 Group or no equivalent | Group is created only if *TopoDS_Solid* contains more than one *TopoDS_Shell*. One IGES entity is created per *TopoDS_Shell*. |
794| TopoDS_CompSolid | 402: Form 1 Group or no equivalent | Group is created only if *TopoDS_CompSolid* contains more than one *TopoDS_Solid*. One IGES entity is created per *TopoDS_Solid*. |
668c2575 795| TopoDS_Compound | 402: Form 1 Group or no equivalent | Group is created only if *TopoDS_Compound* contains more than one item. One IGES entity is created per *TopoDS_Shape* in the *TopoDS_Compound*. If *TopoDS_Compound* is nested into another *TopoDS_Compound*, it is not mapped. |
796
3f812249 797@subsubsection occt_iges_3_4_4 Topological entities -- Translation in BRep mode
668c2575 798
ba06f8bb 799| CASCADE shapes | IGES entity type | Comments |
668c2575 800| :------------- | :--------------- | :------- |
ba06f8bb 801| Single TopoDS_Vertex | No equivalent | Not transferred. |
802| TopoDS_Vertex in a TopoDS_Edge | One item in a 502: *VertexList* | |
803| TopoDS_Edge | No equivalent | Not transferred as such. This entity serves as a part of a Loop entity. |
668c2575 804| TopoDS_Edge in a TopoDS_Wire | One item in a 504: EdgeList | |
805| TopoDS_Wire | 508: Loop | |
ba06f8bb 806| TopoDS_Face | 510: Face | If the geometrical support of the face is a plane, it will be translated as a 190 entity *PlaneSurface*. |
807| TopoDS_Shell | 514: Shell | |
668c2575 808| TopoDS_Solid | 186: Manifold Solid | |
809| TopoDS_CompSolid | 402 Form1 Group or no equivalent | Group is created only if *TopoDS_Compound* contains more than one item. One IGES Manifold Solid is created for each *TopoDS_Solid* in the *TopoDS_CompSolid*. |
810| TopoDS_Compound | 402 Form1 Group or no equivalent | Group is created only if *TopoDS_Compound* contains more than one item. One IGES entity is created per *TopoDS_Shape* in the *TopoDS_Compound*. If *TopoDS_Compound* is nested into another *TopoDS_Compound* it is not mapped. |
811
812@subsection occt_iges_3_5 Tolerance management
813@subsubsection occt_iges_3_5_1 Setting resolution in an IGES file
814
67d7f07f 815There are several possibilities to set resolution in an IGES file. They are controlled by write.precision.mode parameter; the dependence between the value of this parameter and the set resolution is described in paragraph @ref occt_iges_3_3_2 "Setting the translation parameters".
668c2575 816
817If the value of parameter *write.precision.mode* is -1, 0 or 1, resolution is computed from tolerances of sub-shapes inside the shape to be translated. In this computation, only tolerances of *TopoDS_Edges* and *TopoDS_Vertices* participate since they reflect the accuracy of the shape. *TopoDS_Faces* are ignored in computations since their tolerances may have influence on resulting computed resolution while IGES resolution mainly concerns points and curves but not surfaces.
818
819@subsection occt_iges_3_6 Code architecture
820@subsubsection occt_iges_3_6_1 Graph of calls
72b7576f 821The following diagram illustrates the class structure in writing IGES.
822The highlighted classes are intended to translate geometry.
dba69de2 823
d6b4d3d0 824@figure{/user_guides/iges/images/iges_image004.png,"The class structure in writing IGES",420}
dba69de2 825
668c2575 826@subsection occt_iges_3_7 Example
e5bd0d98 827
77d94fd1 828~~~~{.cpp}
4ee1bdf4 829#include <IGESControl_Controller.hxx>
830#include <IGESControl_Writer.hxx>
831#include <TopoDS_Shape.hxx>
72b7576f 832Standard_Integer main()
833{
dba69de2 834 IGESControl_Controller::Init();
835 IGESControl_Writer ICW (;MM;, 0);
836 //creates a writer object for writing in Face mode with millimeters
837 TopoDS_Shape sh;
838 ICW.AddShape (sh);
839 //adds shape sh to IGES model
840 ICW.ComputeModel();
841 Standard_Boolean OK = ICW.Write (;MyFile.igs;);
842 //writes a model to the file MyFile.igs
72b7576f 843}
77d94fd1 844~~~~
e5bd0d98 845
668c2575 846
67d7f07f 847@section occt_iges_4 Using XSTEPDRAW
668c2575 848
72b7576f 849XSTEPDRAW UL is intended for creating executables for testing XSTEP interfaces interactively in the DRAW environment. It provides an additional set of DRAW commands specific for the data exchange tasks, which allow loading and writing data files and analysis of resulting data structures and shapes.
668c2575 850
851In 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, vertical dash (|) is used.
852
853@subsection occt_iges_4_2 Setting interface parameters
854
72b7576f 855A set of parameters for importing and exporting IGES files is defined in the XSTEP resource file. In XSTEPDRAW, these parameters can be viewed or changed using command
ba06f8bb 856
77d94fd1 857~~~~{.php}
668c2575 858Draw> param [<parameter_name> [<value>]]
ba06f8bb 859~~~~
860
668c2575 861Command *param* with no arguments gives a list of all parameters with their values. When argument *parameter_name* is specified, information about this parameter is printed (current value and short description).
862
72b7576f 863The third argument is used to set a new value of the given parameter. The result of the setting is printed immediately.
668c2575 864
72b7576f 865During all interface operations, the protocol of the process (fail and warning messages, mapping of the 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 a standard output).
72b7576f 866
668c2575 867Command *xtrace* is intended to view and change these parameters:
3f812249 868* *Draw> xtrace* -- prints current settings (e.g.: "Level=0 - Standard Output");
869* *Draw> xtrace #* -- sets the trace level to the value #;
870* *Draw> xtrace tracefile.log* -- sets the trace file as *tracefile.log*;
871* *Draw xtrace* -- directs all messages to the standard output.
668c2575 872
873@subsection occt_iges_4_3 Reading IGES files
67d7f07f 874For a description of parameters used in reading an IGES file refer to @ref occt_iges_2_3_3 "Setting the translation parameters".
668c2575 875
876These parameters are set by command *param* :
72b7576f 877
ba06f8bb 878| Description | Name | Values |
668c2575 879| :------------ | :---- | :----- |
ba06f8bb 880| Precision for input entities | read.precision.mode | 0 or 1 |
881| | read.precision.val | real |
668c2575 882| Continuity of B splines | read.iges.bspline.continuity | 0-2 |
883| Surface curves | read.surfacecurve.mode | 2, 3 or 0 |
72b7576f 884
885It is possible either only to load an IGES file into memory (i.e. to fill the model with data from the file), or to read it (i.e. to load and convert all entities to OCCT shapes).
668c2575 886
72b7576f 887Loading is done by the command
77d94fd1 888~~~~{.php}
668c2575 889Draw> xload <file_name>
77d94fd1 890~~~~
67d7f07f 891Once the file is loaded, it is possible to investigate the structure of the loaded data. To learn how to do it see @ref occt_iges_4_4 "Analyzing the transferred".
668c2575 892
72b7576f 893Reading of an IGES file is done by the command
77d94fd1 894~~~~{.php}
668c2575 895Draw> igesbrep <file_name> <result_shape_name> [<selection>]
77d94fd1 896~~~~
668c2575 897Here a dot can be used instead of a filename if the file is already loaded by *xload* or *igesbrep* command. In that case, only conversion of IGES entities to OCCT shapes will be done.
898
899Command *igesbrep* will interactively ask the user to select a set of entities to be converted:
72b7576f 900
ba06f8bb 901| N | Mode | Description |
668c2575 902| :-- | :-- | :---------- |
ba06f8bb 903| 0 | End | finish conversion and exit igesbrep |
904| 1 | Visible roots | convert only visible roots |
905| 2 | All roots | convert all roots |
906| 3 | One entity | convert entity with number provided by the user |
907| 4 | Selection | convert only entities contained in selection |
72b7576f 908
909After the selected set of entities is loaded the user will be asked how loaded entities should be converted into OCCT shapes (e.g., one shape per root or one shape for all the entities). It is also possible to save loaded shapes in files, and to cancel loading.
668c2575 910
4ee1bdf4 911The second parameter of the *igesbrep* command defines the name of the loaded shape. If several shapes are created, they will get indexed names. For instance, if the last parameter is ‘s’, they will be <i>s_1, ... s_N.</i>
668c2575 912
67d7f07f 913<i>\<selection\></i> specifies the scope of selected entities in the model, it is *xst-transferrable-roots* by default. An asterisk “*” can be specified instead of *iges-visible-transf-roots*. For possible values of *selection* refer to @ref occt_iges_2_3_4 "Selecting entities" section.
668c2575 914
915
916Instead of *igesbrep* it is possible to use commands:
77d94fd1 917~~~~{.php}
668c2575 918Draw> trimport <file_name> <result_shape_name> <selection>
77d94fd1 919~~~~
668c2575 920which outputs the result of translation of each selected entity into one shape, or
77d94fd1 921~~~~{.php}
668c2575 922Draw> trimpcomp <file_name> <result_shape_name> <selection>
77d94fd1 923~~~~
668c2575 924which outputs the result of translation of all selected entities into one shape (*TopoDS_Compound* for several entities).
925
4ee1bdf4 926An asterisk “*” can be specified instead of *selection*, it means *xst-transferrable-roots*.
668c2575 927
72b7576f 928During the IGES translation, a map of correspondence between IGES entities and OCCT shapes is created.
668c2575 929The following commands are available:
930
3f812249 931* *Draw> tpent \#* -- provides information on the result of translation of the given IGES entity;
932* *Draw> tpdraw \#* --creates an OCCT shape corresponding to an IGES entity;
933* *Draw> fromshape \<shape_name\>* -- provides the number of an IGES entity corresponding to an OCCT shape;
934* *Draw> tpclear* -- clears the map of correspondences between IGES entities and OCCT shapes.
668c2575 935
936@subsection occt_iges_4_4 Analyzing the transferred data
937
72b7576f 938The procedure of analysis of the data import can be divided into two stages:
668c2575 9391. Checking the file contents;
9402. Estimation of translation results (conversion and validated ratios).
941
942@subsubsection occt_iges_4_4_1 Checking file contents
943
72b7576f 944General statistics on the loaded data can be obtained by using command
77d94fd1 945~~~~{.php}
668c2575 946Draw> data <symbol>
77d94fd1 947~~~~
72b7576f 948The information printed by this command depends on the symbol specified:
949
ba06f8bb 950| Symbol | Output |
668c2575 951| :-------- | :----- |
ba06f8bb 952| g | Prints information contained in the header of the file (Start and Global sections) |
668c2575 953| c or f | Runs check procedure of the integrity of the loaded data and prints the resulting statistics (f works only with fails while c with both fail and warning messages) |
ba06f8bb 954| t | The same as c or f, with a list of failed or warned entities |
668c2575 955| m or l | The same as t but also prints a status for each entity |
956| e | Lists all entities of the model with their numbers, types, status of validity etc. |
ba06f8bb 957| r | The same as e but lists only root entities |
668c2575 958
72b7576f 959
960There is a set of special objects, which can be used to operate with the loaded model. They can be of the following types:
ba06f8bb 961| Special object type | Operation |
668c2575 962| :------------------ | :---------- |
ba06f8bb 963| Selection Filters | allow selecting subsets of entities of the loaded model |
964| Counters | Calculate statistics on the model data |
668c2575 965
72b7576f 966
967A list of these objects defined in the current session can be printed in DRAW by command
77d94fd1 968~~~~{.php}
668c2575 969Draw> listitems
77d94fd1 970~~~~
ba06f8bb 971In the following commands if several <i>\<selection\></i> arguments are specified the results of each following selection are applied to the results of the previous one.
77d94fd1 972~~~~{.php}
668c2575 973Draw> givelist <selection_name> [<selection_name>]
77d94fd1 974~~~~
668c2575 975prints a list of loaded entities defined by selection argument.
976
77d94fd1 977~~~~{.php}
668c2575 978Draw> givecount <selection_name> [<selection_name>]
77d94fd1 979~~~~
668c2575 980prints a number of loaded entities defined by <i>selection</i> argument.
981
982Three commands are used to calculate statistics on the entities in the model:
3f812249 983* *Draw> count \<counter\> [\<selection\> ...]* -- prints only a number of entities per each type matching the criteria defined by arguments.
984* *Draw> sumcount \<counter\> [\<selection\> ...]* -- prints the total number of entities of all types matching the criteria defined by arguments and the largest number corresponding to one type.
985* *Draw> listcount \<counter\> [\<selection\> ...]* -- prints a list of entities per each type matching the criteria defined by arguments.
668c2575 986
ba06f8bb 987Optional <i>\<selection\></i> argument, if specified, defines a subset of entities, which are to be taken into account. Argument <i>\<counter\></i> should be one of the currently defined counters:
668c2575 988
ba06f8bb 989| Counter | Operation |
668c2575 990| :-------- | :-------- |
ba06f8bb 991| xst-types | Calculates how much entities of each OCCT type exist |
668c2575 992| iges-types | Calculates how much entities of each IGES type and form exist |
993| iges-levels | Calculates how much entities lie in different IGES levels |
994
995The command:
77d94fd1 996~~~~{.php}
668c2575 997Draw> listtypes <selection_name> ...
77d94fd1 998~~~~
72b7576f 999gives a list of entity types which were encountered in the last loaded file (with a number of IGES entities of each type). The list can be shown not for all entities but for a subset of them. This subset is defined by an optional selection argument.
1000
668c2575 1001Entities in the IGES file are numbered in the succeeding order. An entity can be identified either by its number (#) or by its label. Label is the letter ‘D’ followed by the index of the first line with the data for this entity in the Directory Entry section of the IGES file. The label can be calculated on the basis of the number as ‘D(2*# -1)’. For example, entity # 6 has label D11.
1002
3f812249 1003* *Draw> elab \#* -- provides a label for an entity with a known number;
1004* *Draw> enum \#* -- prints a number for an entity with the given label;
1005* *Draw> entity \# \<level_of_information\>* -- gives the content of an IGES entity;
1006* *Draw> estat \#* -- provides the list of entities referenced by a given entity and the list of entities referencing to it.
668c2575 1007
1008@subsubsection occt_iges_4_4_2 Estimating the results of reading IGES
72b7576f 1009All of the following commands are available only after the data are converted into OCCT shapes (i.e. after command **igesbrep**).
72b7576f 1010
77d94fd1 1011~~~~{.php}
668c2575 1012Draw> tpstat [*|?]<symbol> [<selection>]
77d94fd1 1013~~~~
ba06f8bb 1014provides all statistics on the last transfer, including the list of transferred entities with mapping from IGES to OCCT types, as well as fail and warning messages. The parameter <i>\<symbol\></i> defines what information will be printed:
3f812249 1015* G -- General statistics (list of results and messages)
1016* C -- Count of all warning and fail messages
1017* C -- List of all warning and fail messages
1018* F -- Count of all fail messages
1019* F -- List of all fail messages
1020* N -- List of all transferred roots
1021* S -- The same, with types of source entity and result type
1022* B -- The same, with messages
1023* T -- Count of roots for geometrical types
1024* R -- Count of roots for topological types
1025* l -- The same, with a type of the source entity
72b7576f 1026
1027The sign ‘*’ before the parameters **n**, **s**, **b**, **t**, **r** makes it work on all entities (not only on roots). The sign ‘?’ before **n**, **s**, **b**, **t** limits the scope of information to invalid entities.
668c2575 1028
ba06f8bb 1029Optional argument <i>\<selection\></i> can limit the action of the command with a selected subset of entities.
72b7576f 1030To get help, run this command without arguments.
668c2575 1031
1032For example, to get translation ratio on IGES faces, you can use.
77d94fd1 1033~~~~{.php}
668c2575 1034Draw:> tpstat *l iges-faces
77d94fd1 1035~~~~
72b7576f 1036The second version of the same command is TPSTAT (not capital spelling).
77d94fd1 1037~~~~{.php}
4ee1bdf4 1038Draw:> TPSTAT <symbol>
77d94fd1 1039~~~~
72b7576f 1040Symbol can be of the following values:
3f812249 1041* g -- General statistics (list of results and messages)
1042* c -- Count of all warning and fail messages
1043* C -- List of all warning and fail messages
1044* r -- Count of resulting OCCT shapes per each type
1045* s -- Mapping of IGES roots and resulting OCCT shapes
72b7576f 1046
668c2575 1047Sometimes the trimming contours of IGES faces (i.e., entity 141 for 143, 142 for 144) can be lost during translation due to fails.
1048
1049The number of lost trims and the corresponding IGES entities can be obtained by the command:
77d94fd1 1050~~~~{.php}
668c2575 1051Draw> tplosttrim [<IGES_type>]
77d94fd1 1052~~~~
668c2575 1053It outputs the rank and DE numbers of faces that lost their trims and their numbers for each type (143, 144, 510) and their total number. If a face lost several of its trims it is output only once.
1054
ba06f8bb 1055Optional parameter <i>\<IGES_type\></i> can be *TrimmedSurface, BoundedSurface* or *Face* to specify the only type of IGES faces.
668c2575 1056
1057For example, to get untrimmed 144 entities, use command
77d94fd1 1058~~~~{.php}
668c2575 1059Draw> tplosttrim TrimmedSurface
77d94fd1 1060~~~~
668c2575 1061To get the information on OCCT shape contents, use command
77d94fd1 1062~~~~{.php}
668c2575 1063Draw> statshape <shape_name>
77d94fd1 1064~~~~
72b7576f 1065It outputs the number of each kind of shapes (vertex, edge, wire, etc.) in a shape and some geometrical data (number of C0 surfaces, curves, indirect surfaces, etc.).
668c2575 1066
72b7576f 1067Note. The 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.
72b7576f 1068
668c2575 1069To analyze the internal validity of a shape, use command
77d94fd1 1070~~~~{.php}
668c2575 1071Draw> checkbrep <shape_name> <expurged_shape_name>
77d94fd1 1072~~~~
668c2575 1073It checks the geometry and topology of a shape 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 "expurged_subshape_name _#" and generates an appropriate message. If possible, this command also tries to find IGES entities the OCCT shape was produced from.
1074
ba06f8bb 1075<i>\<expurged_shape_name\></i> will contain the original shape without invalid subshapes.
668c2575 1076
1077To get information on tolerances of subshapes, use command
77d94fd1 1078~~~~{.php}
668c2575 1079Draw> tolerance <shape_name> [<min> [<max>] [<symbol>]]
77d94fd1 1080~~~~
668c2575 1081It outputs maximum, average and minimum values of tolerances for each kind of subshapes having tolerances or it can output tolerances of all subshapes of the whole shape.
1082
4ee1bdf4 1083When specifying *min* and *max* arguments this command outputs shapes with names <i>\<shape_name\>...</i> and their total number with tolerances in the range <i>[min, max]</i>.
668c2575 1084
ba06f8bb 1085<i>\<Symbol\></i> is used for specifying the kind of sub-shapes to analyze:
3f812249 1086* v -- for vertices,
1087* e -- for edges,
1088* f -- for faces,
1089* c -- for shells and faces.
668c2575 1090
1091@subsection occt_iges_4_5 Writing an IGES file
1092
67d7f07f 1093Refer to @ref occt_iges_3_3_2 "Setting the translation parameters" for a description of parameters used in reading an IGES file. The parameters are set by command *param*:
668c2575 1094
ba06f8bb 1095| Description | Name | Values |
668c2575 1096| :----------- | :---- | :----- |
ba06f8bb 1097| Author | XSTEP.iges.header.author | String |
1098| Company | XSTEP.iges.header.company | String |
1099| Receiver | XSTEP.iges.header.receiver | String |
1100| Write mode for shapes | XSTEP.iges.writebrep.mode | 0/Faces or 1/BRep |
1101| Measurement units | XSTEP.iges.unit | 1-11 (or a string value) |
72b7576f 1102
1103Several shapes can be written in one file. To start writing a new file, enter command
77d94fd1 1104~~~~{.php}
668c2575 1105Draw> newmodel
77d94fd1 1106~~~~
668c2575 1107This command clears the *InterfaceModel* to make it empty.
72b7576f 1108
77d94fd1 1109~~~~{.php}
668c2575 1110Draw> brepiges <shape_name_1> [<filename.igs>]
77d94fd1 1111~~~~
668c2575 1112Converts the specified shapes into IGES entities and puts them into the *InterfaceModel*.
72b7576f 1113
77d94fd1 1114~~~~{.php}
668c2575 1115Draw> writeall <filename.igs>
77d94fd1 1116~~~~
668c2575 1117Allows writing the prepared model to a file with name *filename.igs*.
72b7576f 1118
251a7984 1119@section occt_iges_5 Reading from and writing to IGES
668c2575 1120
251a7984 1121@subsection occt_iges_5_1 Reading from IGES
1122
1123### Load an IGES file
72b7576f 1124
72b7576f 1125Before performing any other operation, you must load an IGES file with:
77d94fd1 1126~~~~{.cpp}
72b7576f 1127IGESCAFControl_Reader reader(XSDRAW::Session(), Standard_False);
1128IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”);
77d94fd1 1129~~~~
72b7576f 1130Loading the file only memorizes, but does not translate the data.
668c2575 1131
251a7984 1132### Check the loaded IGES file
668c2575 1133
67d7f07f 1134This step is not obligatory. See the description of @ref occt_iges_2_3_2 "Checking the IGES file" above.
668c2575 1135
251a7984 1136### Set parameters for translation to XDE
1137
67d7f07f 1138See the description of @ref occt_iges_2_3_3 "Setting translation parameters" above.
668c2575 1139
72b7576f 1140In addition, the following parameters can be set for XDE translation of attributes:
668c2575 1141* For transferring colors:
77d94fd1 1142~~~~{.cpp}
72b7576f 1143reader.SetColorMode(mode);
1144// mode can be Standard_True or Standard_False
77d94fd1 1145~~~~
668c2575 1146* For transferring names:
77d94fd1 1147~~~~{.cpp}
72b7576f 1148reader.SetNameMode(mode);
1149// mode can be Standard_True or Standard_False
77d94fd1 1150~~~~
251a7984 1151
1152### Translate an IGES file to XDE
1153
72b7576f 1154The following function performs a translation of the whole document:
77d94fd1 1155~~~~{.cpp}
72b7576f 1156Standard_Boolean ok = reader.Transfer(doc);
77d94fd1 1157~~~~
668c2575 1158where *doc* is a variable which contains a handle to the output document and should have a type *Handle(TDocStd_Document)*.
1159
251a7984 1160
1161@subsection occt_iges_5_2 Writing to IGES
1162
1163The translation from XDE to IGES can be initialized as follows:
77d94fd1 1164~~~~{.cpp}
72b7576f 1165IGESCAFControl_Writer aWriter(XSDRAW::Session(),Standard_False);
77d94fd1 1166~~~~
251a7984 1167
1168### Set parameters for translation from XDE to IGES
668c2575 1169
72b7576f 1170The following parameters can be set for translation of attributes to IGES:
668c2575 1171* For transferring colors:
77d94fd1 1172~~~~{.cpp}
72b7576f 1173aWriter.SetColorMode(mode);
1174// mode can be Standard_True or Standard_False
77d94fd1 1175~~~~
668c2575 1176* For transferring names:
77d94fd1 1177~~~~{.cpp}
72b7576f 1178aWriter.SetNameMode(mode);
1179// mode can be Standard_True or Standard_False
77d94fd1 1180~~~~
251a7984 1181
1182### Translate an XDE document to IGES
668c2575 1183
72b7576f 1184You can perform the translation of a document by calling the function:
77d94fd1 1185~~~~{.cpp}
72b7576f 1186IFSelect_ReturnStatus aRetSt = aWriter.Transfer(doc);
77d94fd1 1187~~~~
668c2575 1188where "doc" is a variable which contains a handle to the input document for transferring and should have a type *Handle(TDocStd_Document)*.
1189
251a7984 1190### Write an IGES file
1191
72b7576f 1192Write an IGES file with:
77d94fd1 1193~~~~{.cpp}
668c2575 1194IFSelect_ReturnStatus statw = aWriter.WriteFile("filename.igs");
77d94fd1 1195~~~~
72b7576f 1196or
77d94fd1 1197~~~~{.cpp}
72b7576f 1198IFSelect_ReturnStatus statw = writer.WriteFile (S);
77d94fd1 1199~~~~
668c2575 1200where S is OStream.
72b7576f 1201
1202
d6b4d3d0 1203