0032340: OCCT Documentation - highlight C++ code snippets
[occt.git] / dox / user_guides / iges / iges.md
1 IGES Translator  {#occt_user_guides__iges}
2 ==================
3
4 @tableofcontents
5
6 @section occt_iges_1 Introduction
7
8 The 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. 
9
10 Other 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>. 
11
12 **Note** :
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
18 This 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.
19
20 IGES 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). 
21
22 This 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.
25   
26 File translation is  performed in the programming mode, via C++ calls, and the resulting OCCT  objects are shapes. 
27
28 All 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. 
29
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
32 @section occt_iges_2 Reading IGES
33 @subsection occt_iges_2_1 Procedure
34 You 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.
40 @subsection occt_iges_2_2 Domain covered
41 @subsubsection occt_iges_2_2_1 Translatable entities
42 The 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.
49   * Subfigures. Each entity  defined in a sub-figure outputs a shape
50   * Transformation Matrix.
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
55 Entity attributes in the Directory Entry Section of the  IGES file (such as layers, colors and thickness) are translated to Open CASCADE  Technology using XDE. 
56 @subsubsection occt_iges_2_2_3 Administrative data
57 Administrative 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
60 @subsection occt_iges_2_3 Description of the process
61 @subsubsection occt_iges_2_3_1 Loading the IGES file
62 Before performing any  other operation, you have to load the file using the syntax below. 
63 ~~~~{.cpp}
64 IGESControl_Reader reader; 
65 IFSelect_ReturnStatus stat  = reader.ReadFile(“filename.igs”); 
66 ~~~~
67 The loading operation  only loads the IGES file into computer memory; it does not translate it. 
68
69 @subsubsection occt_iges_2_3_2 Checking the IGES file
70 This step is not obligatory.  Check the loaded file with:  
71 ~~~~{.cpp}
72 Standard_Boolean ok =  reader.Check(Standard_True); 
73 ~~~~
74 The 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.  
75 ~~~~{.cpp}
76 reader.PrintCheckLoad  (failsonly, mode); 
77 ~~~~
78 Error messages are  displayed if there are invalid or incomplete IGES entities, giving you  information on the cause of the error.  
79 ~~~~{.cpp}
80 Standard_Boolean failsonly  = Standard_True or Standard_False; 
81 ~~~~
82 If you give True, you  will see fail messages only. If you give False, you will see both fail and  warning messages.  
83
84 Your 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
92 The 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. 
93
94 <h4>read.iges.bspline.continuity</h4>
95 manages 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).  
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
100 Read this parameter  with:  
101 ~~~~{.cpp}
102 Standard_Integer ic =  Interface_Static::IVal("read.iges.bspline.continuity"); 
103 ~~~~
104 Modify this value with:  
105 ~~~~{.cpp}
106 if  (!Interface_Static::SetIVal ("read.iges.bspline.continuity",2))  
107 .. error ..; 
108 ~~~~
109 Default value is 1. 
110
111 This 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
114 <h4>read.precision.mode</h4>
115 reads the precision  value.  
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
119 Read this parameter  with:  
120 ~~~~{.cpp}
121 Standard_Integer ic =  Interface_Static::IVal("read.precision.mode"); 
122 ~~~~
123 Modify this value with:  
124 ~~~~{.cpp}
125 if  (!Interface_Static::SetIVal ("read.precision.mode",1))  
126 .. error ..; 
127 ~~~~
128 Default value is  *File* (0).  
129
130 <h4>read.precision.val</h4>
131 User 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
133 This value is in the  measurement unit defined in the IGES file header.  
134
135 Read this parameter  with:  
136 ~~~~{.cpp}
137 Standard_Real rp =  Interface_Static::RVal("read.precision.val"); 
138 ~~~~
139 Modify this parameter  with:  
140 ~~~~{.cpp}
141 if  (!Interface_Static::SetRVal ("read.precision.val",0.001))  
142 .. error ..; 
143 ~~~~
144 Default value is 0.0001.   
145
146 The 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
148 Value 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
150 <h4>read.maxprecision.mode</h4>
151 defines the mode of  applying the maximum allowed tolerance. Its possible values are:  
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
156 Read this parameter  with:  
157 ~~~~{.cpp}
158 Standard_Integer mv =  Interface_Static::IVal("read.maxprecision.mode"); 
159 ~~~~
160 Modify this parameter  with:  
161 ~~~~{.cpp}
162 if  (!Interface_Static::SetIVal ("read.maxprecision.mode",1))  
163 .. error ..; 
164 ~~~~
165 Default value is  *Preferred (0)*.  
166
167 <h4>read.maxprecision.val</h4>
168 defines the maximum  allowable tolerance (in mm) of the shape. It should be not less than the basis  value of tolerance set in processor (either Resolution from the file or  *read.precision.val*). Actually, the maximum between *read.maxprecision.val* and  basis tolerance is used to define maximum allowed tolerance.  
169 Read this parameter  with:  
170 ~~~~{.cpp}
171 Standard_Real rp =  Interface_Static::RVal("read.maxprecision.val"); 
172 ~~~~
173 Modify this parameter with:  
174 ~~~~{.cpp}
175 if  (!Interface_Static::SetRVal ("read.maxprecision.val",0.1))  
176 .. error ..; 
177 ~~~~
178 Default value is 1.  
179
180 <h4>read.stdsameparameter.mode</h4>
181 defines the using of  *BRepLib\::SameParameter*. Its possible values are:  
182 * 0 (Off) -- *BRepLib\::SameParameter* is not called,  
183 * 1 (On) -- *BRepLib\::SameParameter* is called.  
184 *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*.  
185 Read this parameter  with:  
186 ~~~~{.cpp}
187 Standard_Integer mv =  Interface_Static::IVal("read.stdsameparameter.mode"); 
188 ~~~~
189 Modify this parameter  with:  
190 ~~~~{.cpp}
191 if  (!Interface_Static::SetIVal ("read.stdsameparameter.mode",1))  
192 .. error ..; 
193 ~~~~
194 Deafault value is 0 (Off).  
195
196 <h4>read.surfacecurve.mode</h4>
197 preference for the  computation of curves in case of 2D/3D inconsistency in an entity which has  both 2D and 3D representations.  
198
199 Here 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.  
200
201 The 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:  
202   * 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. 
203   * 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).
204   
205 The parameter  *read.surfacecurve.mode* defines which curve (3D or 2D) is used for re-computing  the other one:
206 * *Default(0)* use  the preference flag value in the entity's Parameter Data section. The flag  values are:  
207   * 0: no preference given, 
208   * 1: use 2D for 142 entities  and 3D for 141 entities, 
209   * 2: use 3D for 142 entities  and 2D for 141 entities, 
210   * 3: both representations are  equally preferred. 
211 * *2DUse_Preferred (2)* : the 2D is used to rebuild the 3D in case of their inconsistency,  
212 * *2DUse_Forced (-2)*: the 2D is always used to rebuild the 3D (even if 3D is present in the  file),  
213 * *3DUse_Preferred (3)*: the 3D is used to rebuild the 2D in case of their inconsistency,  
214 * *3DUse_Forced  (-3)*: the 3D is always used to rebuild the 2D (even if 2D is present in the  file),  
215
216 If 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. 
217  
218 The 3D representation is  preferred to the 2D in two cases:  
219   * if 3D and 2D contours in the  file have a different number of curves, 
220   * if the 2D curve is a Circular  Arc (entity type 100) starting and ending in the same point and the 3D one is  not. 
221
222 In any other case, the  2D representation is preferred to the 3D.  
223
224 If 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.  
225
226 Read this parameter  with:  
227 ~~~~{.cpp}
228 Standard_Integer ic =  Interface_Static::IVal("read.surfacecurve.mode"); 
229 ~~~~
230 Modify this value with:  
231 ~~~~{.cpp}
232 if  (!Interface_Static::SetIVal ("read.surfacecurve.mode",3))  
233 .. error ..; 
234 ~~~~
235 Default value is  Default (0). 
236
237 <h4>read.encoderegularity.angle</h4>
238 This 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.  
239
240 Read this parameter  with:  
241 ~~~~{.cpp}
242 Standard_Real era =   Interface_Static::RVal("read.encoderegularity.angle"); 
243 ~~~~
244 Modify this parameter with:  
245 ~~~~{.cpp}
246 if  (!Interface_Static::SetRVal ("read.encoderegularity.angle",0.1))   
247 .. error ..; 
248 ~~~~
249 Default value is 0.01.  
250
251 <h4>read.iges.bspline.approxd1.mode</h4>
252 This 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.  
253
254 Read this parameter with:  
255 ~~~~{.cpp}
256 Standard_Real bam =   Interface_Static::CVal("read.iges.bspline.approxd1.mode"); 
257 ~~~~
258 Modify this parameter with:  
259 ~~~~{.cpp}
260 if  (!Interface_Static::SetRVal ("read.encoderegularity.angle","On"))   
261 .. error ..; 
262 ~~~~
263 Default value is Off.  
264
265
266 <h4>read.iges.resource.name and read.iges.sequence</h4>
267 These 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.  
268
269 Find 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>. 
270
271 IGES 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. 
272
273 Default values:  
274 * read.iges.resource.name -- IGES,  
275 * read.iges.sequence -- FromIGES. 
276
277 <h4>xstep.cascade.unit</h4>
278 This 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.
279   
280 Default value is MM. 
281
282 @subsubsection occt_iges_2_3_4 Selecting entities
283
284 A list of entities can  be formed by invoking the method *IGESControl_Reader::GiveList*.
285 ~~~~{.cpp}
286 Handle(TColStd_HSequenceOfTransient)  list = reader.GiveList(); 
287 ~~~~
288 Several predefined  operators can be used to select a list of entities of a specific type. 
289 To 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:
290 1. Requesting the faces in the  file: 
291 ~~~~{.cpp}
292 faces =  Reader.GiveList("iges-faces"); 
293 ~~~~
294 2. Requesting the visible roots  in the file: 
295 ~~~~{.cpp}
296 visibles =  Reader.GiveList(iges-visible-roots); 
297 ~~~~
298 3.  Requesting the visible faces:
299 ~~~~{.cpp}
300 visfac =  Reader.GiveList(iges-visible-roots,faces); 
301 ~~~~
302 Using 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. 
303 ~~~~{.cpp}
304 faces =  Reader.GiveList(“xst-type(SurfaceOfRevolution)”); 
305 faces =  Reader.GiveList(“iges-type(120)”); 
306 ~~~~
307 You can also look for: 
308   * values returned by your  signature which match your criterion exactly
309 ~~~~{.cpp}
310 faces =  Reader.GiveList(“xst-type(=SurfaceOfRevolution)”); 
311 ~~~~
312   * values returned by your  signature which do not contain your criterion
313 ~~~~{.cpp}
314 faces = Reader.GiveList(“xst-type(!SurfaceOfRevolution)”); 
315 ~~~~
316   * values returned by your  signature which do not exactly match your criterion.
317 ~~~~{.cpp}
318 faces =  Reader.GiveList(“xst-type(!=SurfaceOfRevolution)”); 
319 ~~~~
320
321 <h4>List of predefined operators that can be used:</h4>
322   * *xst-model-all* -- selects all entities. 
323   * *xst-model-roots* -- selects all roots. 
324   * *xst-transferrable-all* -- selects all translatable entities. 
325   * *xst-transferrable-roots* -- selects all translatable roots (default). 
326   * *xst-sharing + \<selection\>* -- selects all entities sharing at least one entity selected by  \<selection\>. 
327   * *xst-shared + \<selection\>* -- selects all entities shared by at least one entity selected  by \<selection\>. 
328   * *iges-visible-roots* -- selects all visible roots, whether translatable or not. 
329   * *iges-visible-transf-roots* -- selects all visible and translatable roots. 
330   * *iges-blanked-roots* -- selects all blank roots, whether translatable or not. 
331   * *iges-blanked-transf-roots* -- selects all blank and translatable roots. 
332   * *iges-status-independent* -- selects entities whose IGES Subordinate Status = 0.
333   * *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. 
334   * *iges-bypass-subfigure* -- selects all root entities. If a root entity is a subfigure  definition (308), the entities in the subfigure definition are selected. 
335   * *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. 
336   * *iges-curves-3d* -- selects 3D curves, whether they are roots or not (e.g. a 3D  curve on a surface). 
337   * *iges-basic-geom* -- selects 3D curves and untrimmed surfaces. 
338   * *iges-faces* -- selects face-supporting surfaces (trimmed or not). 
339   * *iges-surfaces* -- selects surfaces not supporting faces (i.e. with natural  bounds). 
340   * *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. 
341   
342 @subsubsection occt_iges_2_3_5 Performing the  IGES file translation
343 Perform translation  according to what you want to translate:  
344 1.  Translate an entity identified  by its rank with:  
345 ~~~~{.cpp}
346 Standard_Boolean ok =  reader.Transfer (rank); 
347 ~~~~
348 2.  Translate an entity  identified by its handle with: 
349 ~~~~{.cpp}
350 Standard_Boolean ok =  reader.TransferEntity (ent); 
351 ~~~~
352 3. Translate a list of entities  in one operation with:  
353 ~~~~{.cpp}
354 Standard_Integer nbtrans =  reader.TransferList (list); 
355 reader.IsDone(); 
356 ~~~~
357 where *nbtrans* returns the number of items  in the list that produced a shape and    *reader.IsDone()* indicates  whether at least one entity was translated. 
358 4. Translate a list of entities,  entity by entity: 
359 ~~~~{.cpp}
360 Standard_Integer i,nb =  list-Length();  
361 for (i = 1; i  <= nb; i ++) {  
362     Handle(Standard_Transient) ent = list-Value(i);  
363     Standard_Boolean OK = reader.TransferEntity (ent);  
364
365 ~~~~
366 5.  Translate the whole file (all  entities or only visible entities) with:  
367 ~~~~{.cpp}
368 Standard_Boolean  onlyvisible = Standard_True or Standard_False;  
369 reader.TransferRoots(onlyvisible) 
370 ~~~~
371
372 @subsubsection occt_iges_2_3_6 Getting the  translation results
373 Each successful  translation operation outputs one shape. A series of translations gives a  series of shapes.  
374 Each 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.  
375 ~~~~{.cpp}
376 Standard_Integer nbs =  reader.NbShapes(); 
377 ~~~~
378 returns the number of  shapes recorded in the result.  
379 ~~~~{.cpp}
380 TopoDS_Shape shape =  reader.Shape(num);, 
381 ~~~~
382 returns the result *num*, where *num* is an integer between 1 and *NbShapes*.  
383 ~~~~{.cpp}
384 TopoDS_Shape shape =  reader.Shape(); 
385 ~~~~
386 returns the first result  in a translation operation.  
387 ~~~~{.cpp}
388 TopoDS_Shape shape =  reader.OneShape(); 
389 ~~~~
390 returns all results in a  single shape which is:  
391   * a null shape if there are no  results, 
392   * in case of a single result, a  shape that is specific to that result, 
393   * a compound that lists the  results if there are several results. 
394 ~~~~{.cpp}
395 reader.Clear(); 
396 ~~~~
397 erases the existing  results.  
398 ~~~~{.cpp}
399 reader.PrintTransferInfo  (failsonly, mode); 
400 ~~~~
401 displays the messages  that appeared during the last invocation of *Transfer* or *TransferRoots*.  
402
403 If *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:
404   * *GeneralCount* -- gives general statistics  on the transfer (number of translated IGES entities, number of fails and  warnings, etc)  
405   * *CountByItem* -- gives the number of IGES  entities with their types per message. 
406   * *ListByItem* -- gives the number of IGES  entities with their type and DE numbers per message.  
407   * *ResultCount*  -- gives the number of  resulting OCCT shapes per type.  
408   * *Mapping* -- gives mapping between  roots of the IGES file and the resulting OCCT shape per IGES and OCCT type.
409  
410 @subsection occt_iges_2_4 Mapping of IGES  entities to Open CASCADE Technology shapes
411
412 *NOTE* that IGES entity types  that are not given in the following tables are not translatable. 
413
414 @subsubsection occt_iges_2_4_1 Points
415
416 | IGES entity type | CASCADE shape  | Comments |
417 | :---------------- | :------------- | --------- |
418 | 116: Point     | TopoDS_Vertex  | |
419
420 @subsubsection occt_iges_2_4_2 Curves
421 Curves, which form the 2D of face boundaries, are translated  as *Geom2D_Curves* (Geom2D circles, etc.). 
422
423 | IGES entity type | CASCADE shape | Comments |
424 | :---------------- | :------------ | :------- |
425 | 100: Circular Arc | TopoDS_Edge | The geometrical support is a *Geom_Circle* or a *Geom_TrimmedCurve* (if the arc is not closed). |
426 | 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*. |
427 | 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. |
428 | 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. |
429 | 110: Line | TopoDS_Edge | The supporting curve is a *Geom_TrimmedCurve* whose basis curve is a *Geom_Line*. |
430 | 112: Parametric Spline Curve | TopoDS_Edge or TopoDS_Wire | The geometric support is a Geom_BsplineCurve. |
431 | 126: BSpline Curve | TopoDS_Edge or TopoDS_Wire | |
432 | 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. |
433 | 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*. |
434 | 142: Curve On Surface | TopoDS_Wire | Each *TopoDS_Edge* is defined by a 3D curve and by a 2D curve that references the surface. |
435
436 The 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. 
437
438 @subsubsection occt_iges_2_4_3 Surfaces
439 Translation of a surface outputs either a *TopoDS_Face* or a  *TopoDS_Shell*.  
440 If 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*. 
441
442 | IGES entity type | CASCADE shape | Comments |
443 | :--------------  | :------------ | :--------- |
444 | 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. |
445 | 114: Parametric Spline Surface | TopoDS_Face | The geometrical support of a *TopoDS_Face* is a *Geom_BSplineSurface*. |
446 | 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.  |
447 | 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). | 
448 | 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. |
449 | 128: BSpline Surface | TopoDS_Face | The geometrical support of the *TopoDS_Face* is a *Geom_BsplineSurface*. |
450 | 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. |
451 | 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. |
452 | 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. |
453 | 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*. | 
454
455
456 @subsubsection occt_iges_2_4_4 Boundary Representation  Solid Entities
457
458 | IGES entity type | CASCADE shape | Comments |
459 | :---------------- | :------------ | :------- |
460 | 186: ManifoldSolid | TopoDS_Solid | |
461 | 514: Shell | TopoDS_Shell | |
462 | 510: Face | TopoDS_Face | This is the lowest IGES entity in the BRep structure that can be specified as a starting point for translation. |
463 | 508: Loop | TopoDS_Wire | | 
464 | 504: Edge List | | |
465 | 502: Vertex List | | | 
466
467
468 @subsubsection occt_iges_2_4_5 Structure Entities
469
470 | IGES entity type | CASCADE shape | Comments | 
471 | :---------------- | :------------ | :------- |
472 | 402/1: Associativity Instance: Group with back pointers |  TopoDS_Compound | |
473 | 402/7: Associativity Instance: Group without back pointers | TopoDS_Compound | |
474 | 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. |
475
476 @subsubsection occt_iges_2_4_6 Subfigures
477
478 | IGES entity type | CASCADE shape | Comments |
479 | :---------------- | :------------ | :------- |
480 | 308: Subfigure Definition | TopoDS_Compound | This IGES entity is only translated when there are no Singular Subfigure Instance entities. |
481 | 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. |
482
483 @subsubsection occt_iges_2_4_7 Transformation Matrix  
484
485 | IGES entity type | CASCADE shape | Comments |
486 | :---------------  | :------------ | :------- |
487 | 124: Transformation Matrix | Geom_Transformation | This entity is never translated alone. It must be included in the definition of another entity. |
488
489
490 @subsection occt_iges_2_5 Messages
491 Messages are displayed concerning the normal functioning of  the processor (transfer, loading, etc.).  
492 You must declare an include file: 
493 ~~~~{.cpp}
494 #include \<Interface_DT.hxx\> 
495 ~~~~
496
497 You have the choice of the following options for messages: 
498 ~~~~{.cpp}
499 IDT_SetLevel (level); 
500 ~~~~
501 level modifies the level of messages: 
502   * 0: no messages
503   * 1: raise and fail messages are displayed, as are messages  concerning file access,
504   * 2: warnings are also displayed.
505 ~~~~{.cpp}
506 IDT_SetFile (“tracefile.log”); 
507 ~~~~
508 prints the messages in a file, 
509 ~~~~{.cpp}
510 IDT_SetStandard(); 
511 ~~~~
512 restores screen output. 
513
514 @subsection occt_iges_2_6 Tolerance management
515 @subsubsection occt_iges_2_6_1 Values used for tolerances during reading IGES
516
517 During 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. 
518
519 <h4>3D (spatial) tolerances</h4>
520
521 * Package method  *Precision\::Confusion* equal to 10<sup>-7</sup> is used as a minimal  distance between points, which are considered distinct. 
522 * 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. 
523 * 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"). 
524 * 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. 
525 * 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*.
526  
527 <h4>2D (parametric) tolerances</h4>
528
529 * 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. 
530 * 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). 
531 * 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.
532 * Methods *Resolution(tolerance3d)* of the class *GeomAdaptor_Curve* or *BRepAdaptor_Curve* return tolerance in the parametric space of a curve computed  from 3d tolerance. 
533
534 <h4>Zero-dimensional tolerances</h4>
535 * 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>.
536  
537 @subsubsection occt_iges_2_6_2 Initial setting of tolerances in translating  objects
538
539 Transfer 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. 
540
541 This object contains three tolerances: *Epsilon, EpsGeom* and  *EpsCoeff*. 
542
543 Parameter *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. 
544
545 Parameter *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*.
546  
547 Parameter *EpsCoeff* is set by default to 10<sup>-6</sup> and  is not changed. 
548
549 During 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. 
550
551 @subsubsection occt_iges_2_6_3 Transfer process
552 <h4>Translating into Geometry</h4>
553 Geometrical 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*.
554  
555 Since 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). 
556
557 Use of precision parameters is reflected in the following  classes: 
558 * *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). 
559 * *IGESToBRep_BasicCurve::TransferBSplineCurve* -- all weights of *BSplineCurve* are assumed to be more than *Precision::PConfusion* (else the curve is not translated). 
560 * *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>. 
561 * *IGESToBRep_BasicSurface::TransferBSplineSurface* -- all weights of *BSplineSurface* are assumed to be more than  *Precision::PConfusion* (else the surface is not translated). 
562
563
564 <h4>Translating into Topology</h4>
565
566 IGES 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*. 
567
568 Class *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. 
569
570 Although 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. 
571
572 The following classes show what default tolerances are used  when creating shapes and how they are updated during transfer. 
573
574 <h5>Class  IGESToBRep_TopoCurve</h5>
575
576 All  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>. 
577   * *IGESToBRep_TopoCurve::TransferPoint* -- vertex is constructed from a Point entity with tolerance *EpsGeom*UnitFactor*. 
578   * *IGESToBRep_TopoCurve::Transfer2dPoint* -- vertex is constructed from a Point entity with tolerance *EpsCoeff*. 
579   * *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*. 
580   * *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*. 
581   * *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*.
582   
583   
584 <h5>Class  IGESToBRep_TopoSurface</h5>
585
586 All faces created by this class have tolerance  *Precision::Confusion*.
587
588 <h5>Class  IGESToBRep_BRepEntity</h5>
589
590   * *IGESToBRep_BRepEntity::TransferVertex* -- the vertices from the *VertexList* entity are constructed with  tolerance *EpsGeom*UnitFactor*. 
591   * *IGESToBRep_BRepEntity::TransferEdge* -- the edges from the *EdgeList* entity are constructed with  tolerance *Precision::Confusion*.
592   * *IGESToBRep_BRepEntity::TransferLoop* -- this function works like  *IGESToBRep_TopoCurve::TransferCurveOnFace* and *IGESToBRep_TopoCurve::TransferBoundaryOnFace*. 
593   * *IGESToBRep_BRepEntity::TransferFace* -- the face from the *Face* IGES entity is constructed with  tolerance *Precision::Confusion*.
594   
595 <h5>Shape Healing classes</h5>
596 After 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.  
597 Class *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()* ). 
598
599 @subsection occt_iges_2_7 Code architecture
600
601 The following diagram illustrates the structure of calls in  reading IGES. 
602 The highlighted classes produce OCCT geometry. 
603
604 @figure{/user_guides/iges/images/iges_image003.png,"The structure of calls in reading IGES",420}
605
606 @subsection occt_iges_2_8 Example
607
608 ~~~~{.cpp}
609 #include “IGESControl_Reader.hxx” 
610 #include “TColStd_HSequenceOfTransient.hxx” 
611 #include “TopoDS_Shape.hxx” 
612
613 IGESControl_Reader myIgesReader; 
614 Standard_Integer nIgesFaces,nTransFaces; 
615
616 myIgesReader.ReadFile (“MyFile.igs”); 
617 //loads file MyFile.igs 
618
619 Handle(TColStd_HSequenceOfTransient) myList =  myIgesReader.GiveList(“iges-faces”); 
620 //selects all IGES faces in the file and puts them into a list  called //MyList, 
621
622 nIgesFaces = myList-Length();  
623 nTransFaces = myIgesReader.TransferList(myList); 
624 //translates MyList, 
625
626 cout<<"IGES Faces: "<<nIgesFaces<<"   Transferred:"<<nTransFaces<<endl; 
627 TopoDS_Shape sh = myIgesReader.OneShape(); 
628 //and obtains the results in an OCCT shape. 
629
630 ~~~~
631
632 @section occt_iges_3 Writing IGES
633 @subsection occt_iges_3_1 Procedure
634
635 You can translate OCCT shapes to IGES entities in the  following steps: 
636 1. Initialize  the process. 
637 2. Set  the translation parameters, 
638 3. Perform  the model translation, 
639 4. Write  the output IGES file. 
640
641 You can translate several shapes before writing a file. Each  shape will be a root entity in the IGES model. 
642
643 @subsection occt_iges_3_2 Domain covered
644 There are two families of OCCT objects that can be  translated: 
645   * geometrical,
646   * topological.
647   
648 @subsection occt_iges_3_3 Description of the process
649 @subsubsection occt_iges_3_3_1 Initializing the process
650
651 Choose the unit and the mode you want to use to write the  output file as follows: 
652 * *IGESControl_Controller::Init* performs standard initialization. Returns False if an error  occurred. 
653 * *IGESControl_Writer writer* uses the default unit (millimeters) and the default write  mode (Face). 
654 * *IGESControl_Writer writer (UNIT)* uses the Face write mode and any of the units that are  accepted by IGES.  
655 * *IGESControl_Writer writer (UNIT,modecr)* uses the unit (accepted by IGES) and the write mode of your  choice. 
656   *  0: Faces,
657   *  1: BRep
658 The result is an *IGESControl_Writer* object. 
659
660 @subsubsection occt_iges_3_3_2 Setting the translation parameters 
661
662 The following parameters are used for the OCCT-to-IGES  translation. 
663
664 * *write.iges.brep.mode:* allows choosing the  write mode:  
665  * "Faces" (0): OCCT *TopoDS_Faces* will be translated into IGES 144 (Trimmed Surface) entities, no BRep entities  will be written to the IGES file,  
666  * "BRep" (1): OCCT *TopoDS_Faces*  will be translated into IGES 510 (Face) entities, the IGES file will contain  BRep entities.  
667 Read this parameter  with:  
668 ~~~~{.cpp}
669 Standard_Integer byvalue =  Interface_Static::IVal("write.iges.brep.mode"); 
670 ~~~~
671 Modify this parameter  with:  
672 ~~~~{.cpp}
673 Interface_Static::SetIVal  ("write.iges.brep.mode", 1); 
674 ~~~~
675 Default value is "Faces" (0).  
676 * *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). 
677 * *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.  
678  * Read this parameter  with *Standard_String byvalue =  Interface_Static::CVal("write.iges.unit")*; 
679  * Modify this parameter  with *Interface_Static::SetCVal ("write.iges.unit", "INCH");* 
680 * *write.iges.header.author:* gives the name of the  author of the file. The default value is the system name of the user.
681  * Read this parameter  with  *Standard_String byvalue =  Interface_Static::CVal("write.iges.header.author")*; 
682  * Modify this value with  *Interface_Static::SetCVal  ("write.iges.header.author", "name")*; 
683 * *write.iges.header.company:* gives the name of the  sending company.  The default value is  "" (empty).
684  * Read this parameter  with *Standard_String byvalue =  Interface_Static::CVal("write.iges.header.company");*
685  * Modify this value with *Interface_Static::SetCVal ("write.iges.header.company", "Open CASCADE");* 
686 * *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.  
687  * Read this parameter  with *Standard_String byvalue =  Interface_Static::CVal("write.iges.header.product")*; 
688  * Modify this value with *Interface_Static::SetCVal  ("write.iges.header.product", "product name")*; 
689 * *write.iges.header.receiver:* -- gives the name of the  receiving company.  The default value is  "" (empty).
690  * Read this parameter  with *Standard_String byvalue =  Interface_Static::CVal("write.iges.header.receiver");* 
691  * Modify this value with *Interface_Static::SetCVal  ("write.iges.header.receiver", "receiver name");*
692 * *write.precision.mode:* specifies the mode of  writing the resolution value into the IGES file.  
693  * "Least" (-1):       resolution value is  set to the minimum tolerance of all edges and all vertices in an OCCT shape.  
694  * "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.  
695  * "Greatest" (1):   resolution value is  set to the maximum tolerance of all edges and all vertices in an OCCT shape.  
696  * "Session" (2):    resolution  value is that of the write.precision.val parameter.  
697  
698  * Read this parameter  with <i>Standard_Integer ic =  Interface_Static::IVal("write.precision.mode");</i> 
699  * Modify this parameter  with <i>if  (!Interface_Static\::SetIVal("write.precision.mode",1))  .. error .. </i>
700 * *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.  
701
702 Read this parameter  with:  
703 ~~~~{.cpp}
704 Standard_Real rp =  Interface_Static::RVal(;write.precision.val;); 
705 ~~~~
706 Modify this parameter  with:  
707 ~~~~{.cpp}
708 if  (!Interface_Static::SetRVal(;write.precision.val;,0.01))  
709 .. error .. 
710 ~~~~
711 Default value is 0.0001. 
712
713 <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). 
714
715 Default values : 
716 ~~~~{.cpp}
717 write.iges.resource.name - IGES,
718 write.iges.sequence - ToIGES. 
719 ~~~~
720
721 @subsubsection occt_iges_3_3_3 Performing the Open  CASCADE Technology shape translation
722
723 You can perform the  translation in one or several operations. Here is how you translate topological  and geometrical objects:  
724 ~~~~{.cpp}
725 Standard_Boolean ok =  writer.AddShape (TopoDS_Shape); 
726 ~~~~
727 *ok* is True if translation was correctly performed and False if there was at least one entity that was not translated.  
728 ~~~~{.cpp}
729 Standard_Boolean ok =  writer.AddGeom (geom); 
730 ~~~~
731 where *geom* is *Handle(Geom_Curve)* or *Handle(Geom_Surface)*;  
732 *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. 
733
734 @subsubsection occt_iges_3_3_4 Writing the IGES  file
735 Write the IGES file  with:  
736 ~~~~{.cpp}
737 Standard_Boolean ok =  writer.Write ("filename.igs"); 
738 ~~~~
739 to give the file name.  
740 ~~~~{.cpp}
741 Standard_Boolean ok =  writer.Write (S); 
742 ~~~~
743 where *S* is *Standard_OStream*  
744 *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). 
745
746 @subsection occt_iges_3_4 Mapping Open CASCADE  Technology shapes to IGES entities
747
748 Translated 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. 
749
750 @subsubsection occt_iges_3_4_1 Curves
751
752 | CASCADE shape | IGES entity type | Comments |
753 | :------------ | :---------------- | :------- | 
754 | Geom_BsplineCurve | 126: BSpline Curve | |
755 | Geom_BezierCurve | 126: BSpline Curve | |
756 | 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. |
757 | Geom_Circle | 100: Circular Arc or 126: BSpline Curve | A BSpline Curve is output if the *Geom_Circle* is closed |
758 | 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. |
759 | Geom_Hyperbola | 104: Conic Arc | Form 2 |
760 | Geom_Parabola | 104: Conic Arc | Form 3 | 
761 | Geom_Line | 110: Line | |
762 | Geom_OffsetCurve | 130: Offset Curve | |
763
764 @subsubsection occt_iges_3_4_2 Surfaces
765
766 | CASCADE shapes | IGES entity type | Comments |
767 | :------------- | :--------------- | :------- |
768 | Geom_BSplineSurface | 128: BSpline Surface | |
769 | Geom_BezierSurface | 128: BSpline Surface | |
770 | 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. |
771 | 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. |
772 | Geom_CylindricalSurface | 120: Surface Of Revolution | |
773 | Geom_ConicalSurface | 120: Surface Of Revolution | | 
774 | Geom_SphericalSurface | 120: Surface Of Revolution | |
775 | Geom_ToroidalSurface | 120: Surface Of Revolution | |
776 | Geom_SurfaceOfLinearExtrusion | 122: Tabulated Cylinder | |
777 | Geom_SurfaceOfRevolution | 120: Surface Of Revolution | |
778 | Geom_OffsetSurface | 140: Offset Surface | |
779
780 @subsubsection occt_iges_3_4_3 Topological entities -- Translation in Face mode
781
782 | CASCADE shapes | IGES entity type | Comments |
783 | :------------- | :--------------- | :------- |
784 | Single TopoDS_Vertex | 116: 3D Point | |
785 | TopoDS_Vertex in a TopoDS_Edge | No equivalent | Not transferred. |
786 | TopoDS_Edge | All types of translatable IGES curves | The output IGES curve will be the one that corresponds to the Open CASCADE Technology definition. |
787 | Single TopoDS_Wire | 102: Composite Curve | Each *TopoDS_Edge* in the *TopoDS_Wire* results in a curve. |
788 | 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. |
789 | TopoDS_Face | 144: Trimmed Surface | |
790 | 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. |
791 | 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*. |
792 | 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*. |
793 | 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. |
794
795 @subsubsection occt_iges_3_4_4 Topological entities -- Translation in BRep mode
796
797 | CASCADE shapes | IGES entity type | Comments |
798 | :------------- | :--------------- | :------- |
799 | Single TopoDS_Vertex | No equivalent | Not transferred. |
800 | TopoDS_Vertex in a TopoDS_Edge | One item in a 502: *VertexList* | | 
801 | TopoDS_Edge | No equivalent | Not transferred as such. This entity serves as a part of a Loop entity. |
802 | TopoDS_Edge in a TopoDS_Wire | One item in a 504: EdgeList | |
803 | TopoDS_Wire | 508: Loop | |
804 | TopoDS_Face | 510: Face | If the geometrical support of the face is a plane, it will be translated as a 190 entity *PlaneSurface*. |
805 | TopoDS_Shell | 514: Shell | |
806 | TopoDS_Solid | 186: Manifold Solid | |
807 | 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*. |
808 | 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. | 
809
810 @subsection occt_iges_3_5 Tolerance  management
811 @subsubsection occt_iges_3_5_1 Setting  resolution in an IGES file
812
813 There 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". 
814
815 If 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.  
816
817 @subsection occt_iges_3_6 Code architecture
818 @subsubsection occt_iges_3_6_1 Graph of calls
819 The following diagram illustrates the class structure in  writing IGES. 
820 The highlighted classes are intended to translate geometry. 
821
822 @figure{/user_guides/iges/images/iges_image004.png,"The class structure in writing IGES",420}
823       
824 @subsection occt_iges_3_7 Example
825
826 ~~~~{.cpp}
827 #include <IGESControl_Controller.hxx> 
828 #include <IGESControl_Writer.hxx> 
829 #include <TopoDS_Shape.hxx> 
830 Standard_Integer main() 
831
832   IGESControl_Controller::Init(); 
833   IGESControl_Writer ICW (;MM;, 0); 
834   //creates a writer object for writing in Face mode with  millimeters 
835   TopoDS_Shape sh; 
836   ICW.AddShape (sh); 
837   //adds shape sh to IGES model 
838   ICW.ComputeModel(); 
839   Standard_Boolean OK = ICW.Write (;MyFile.igs;); 
840   //writes a model to the file MyFile.igs 
841
842 ~~~~
843
844
845 @section occt_iges_4 Using XSTEPDRAW
846
847 XSTEPDRAW 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.  
848
849 In 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.  
850
851 @subsection occt_iges_4_2 Setting interface  parameters
852
853 A 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  
854
855 ~~~~{.php}
856 Draw> param [<parameter_name> [<value>]]  
857 ~~~~
858
859 Command *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).  
860
861 The third argument is  used to set a new value of the given parameter. The result of the setting is  printed immediately.  
862
863 During 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).  
864
865 Command *xtrace* is  intended to view and change these parameters:  
866 * *Draw> xtrace* --  prints current settings (e.g.: "Level=0 -  Standard Output");  
867 * *Draw> xtrace #* --  sets the trace level to the value #;  
868 * *Draw> xtrace  tracefile.log* -- sets the trace file as *tracefile.log*;  
869 * *Draw xtrace* -- directs all messages to the standard output.  
870
871 @subsection occt_iges_4_3 Reading IGES files
872 For a description of  parameters used in reading an IGES file refer to @ref occt_iges_2_3_3 "Setting the translation parameters".  
873
874 These parameters are set  by command *param* :  
875
876 | Description | Name | Values |
877 | :------------ | :---- | :----- |
878 | Precision for input entities | read.precision.mode | 0 or 1 |
879 | | read.precision.val | real |
880 | Continuity of B splines | read.iges.bspline.continuity | 0-2 |
881 | Surface curves | read.surfacecurve.mode | 2, 3 or 0 |
882
883 It 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).  
884
885 Loading is done by the command 
886 ~~~~{.php}
887 Draw> xload <file_name>
888 ~~~~
889 Once 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".
890  
891 Reading of an IGES file is done by the command  
892 ~~~~{.php}
893 Draw> igesbrep <file_name> <result_shape_name> [<selection>]
894 ~~~~
895 Here 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. 
896
897 Command *igesbrep* will interactively ask the user to  select a set of entities to be converted: 
898
899 | N | Mode | Description |
900 | :-- | :-- | :---------- |
901 | 0 | End | finish conversion and exit igesbrep |
902 | 1 | Visible roots | convert only visible roots |
903 | 2 | All roots | convert all roots |
904 | 3 | One entity | convert entity with number provided by the user |
905 | 4 | Selection | convert only entities contained in selection |
906
907 After 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. 
908
909 The 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> 
910
911 <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. 
912
913
914 Instead of *igesbrep* it is possible to use commands:
915 ~~~~{.php}
916 Draw> trimport <file_name> <result_shape_name> <selection>
917 ~~~~
918 which outputs the result of translation of each selected  entity into one shape, or
919 ~~~~{.php}
920 Draw> trimpcomp <file_name> <result_shape_name> <selection>
921 ~~~~
922 which outputs the result of translation of all selected  entities into one shape (*TopoDS_Compound* for several entities). 
923
924 An asterisk “*” can be specified instead of  *selection*, it means *xst-transferrable-roots*.
925  
926 During the IGES translation, a map of correspondence between  IGES entities and OCCT shapes is created. 
927 The following commands are available:  
928
929 * *Draw> tpent \#* -- provides information on the result of translation of the given  IGES entity;
930 * *Draw> tpdraw \#* --creates an OCCT shape corresponding to an IGES entity;
931 * *Draw> fromshape \<shape_name\>* -- provides the number of an IGES entity corresponding to an OCCT  shape;
932 * *Draw> tpclear* -- clears the map of correspondences between IGES entities  and OCCT shapes. 
933
934 @subsection occt_iges_4_4  Analyzing the transferred data
935
936 The procedure of analysis of the data import can be divided  into two stages: 
937 1. Checking the file contents;
938 2. Estimation of translation results (conversion and validated  ratios). 
939
940 @subsubsection occt_iges_4_4_1 Checking file contents
941
942 General statistics on the loaded data can be obtained by  using command  
943 ~~~~{.php}
944 Draw> data <symbol> 
945 ~~~~
946 The information printed by this command depends on the  symbol specified: 
947
948 | Symbol | Output |
949 | :-------- | :----- |
950 | g | Prints information contained in the header of the file (Start and Global sections) |
951 | 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) |
952 | t | The same as c or f, with a list of failed or warned entities |
953 | m or l | The same as t but also prints a status for each entity |
954 | e  | Lists all entities of the model with their numbers, types, status of validity etc. |
955 | r | The same as e but lists only root entities |
956
957
958 There is a set of special objects, which can be used to  operate with the loaded model. They can be of the following types: 
959 | Special object type | Operation |
960 | :------------------ | :---------- |
961 | Selection Filters | allow selecting subsets of entities of the loaded model |
962 | Counters | Calculate statistics on the model data |
963
964
965 A list of these objects defined in the current session can  be printed in DRAW by command 
966 ~~~~{.php}
967 Draw> listitems 
968 ~~~~
969 In 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. 
970 ~~~~{.php}
971 Draw> givelist <selection_name> [<selection_name>]
972 ~~~~
973 prints a list of loaded entities defined by selection argument. 
974
975 ~~~~{.php}
976 Draw> givecount <selection_name> [<selection_name>]
977 ~~~~
978 prints a number of loaded entities defined by <i>selection</i> argument. 
979
980 Three commands are used to calculate statistics on the entities in the model:
981 * *Draw> count \<counter\> [\<selection\> ...]* -- prints only a number of entities per each type matching the criteria defined by arguments.
982 * *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.
983 * *Draw> listcount \<counter\> [\<selection\> ...]* -- prints a list of entities per each type matching the criteria defined by arguments.
984
985 Optional <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:
986
987 | Counter | Operation |
988 | :-------- | :-------- |
989 | xst-types | Calculates how much entities of each OCCT type exist |
990 | iges-types | Calculates how much entities of each IGES type and form exist |
991 | iges-levels | Calculates how much entities lie in different IGES levels |
992
993 The command:
994 ~~~~{.php}
995 Draw> listtypes <selection_name> ...
996 ~~~~
997 gives 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. 
998
999 Entities 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. 
1000
1001 * *Draw> elab \#*  -- provides  a label for an entity with a known number;
1002 * *Draw> enum \#* -- prints a number for an entity with the given label; 
1003 * *Draw> entity \# \<level_of_information\>*  -- gives the content of an IGES entity;
1004 * *Draw> estat \#* -- provides the list of entities referenced by a given entity and the list of entities referencing to it.
1005
1006 @subsubsection occt_iges_4_4_2 Estimating the results of reading IGES
1007 All of the following commands are available only after the  data are converted into OCCT shapes (i.e. after command **igesbrep**). 
1008
1009 ~~~~{.php}
1010 Draw> tpstat [*|?]<symbol> [<selection>]
1011 ~~~~
1012 provides 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: 
1013 * G -- General statistics (list of results and messages)
1014 * C -- Count of all warning and fail messages
1015 * C -- List of all warning and fail messages
1016 * F -- Count of all fail messages
1017 * F -- List of all fail messages
1018 * N -- List of all transferred roots
1019 * S -- The same, with types of source entity and result type
1020 * B -- The same, with messages
1021 * T -- Count of roots for geometrical types
1022 * R -- Count of roots for topological types
1023 * l -- The same, with a type of the source entity
1024
1025 The 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. 
1026
1027 Optional argument <i>\<selection\></i> can limit the action of  the command with a selected subset of entities. 
1028 To get help, run this command without arguments. 
1029
1030 For example, to get translation ratio on IGES faces, you can use. 
1031 ~~~~{.php}
1032 Draw:> tpstat *l iges-faces
1033 ~~~~
1034 The second version of the same command is TPSTAT (not  capital spelling). 
1035 ~~~~{.php}
1036 Draw:> TPSTAT <symbol> 
1037 ~~~~
1038 Symbol can be of the following values: 
1039 * g --  General statistics (list of results and messages)
1040 * c -- Count of all warning and fail messages
1041 * C -- List of all warning and fail messages
1042 * r -- Count of resulting OCCT shapes per each type
1043 * s -- Mapping of IGES roots and resulting OCCT shapes
1044
1045 Sometimes the trimming contours of IGES faces (i.e., entity  141 for 143, 142 for 144) can be lost during translation due to fails. 
1046
1047 The number of lost trims and the corresponding IGES entities can be obtained by the command:
1048 ~~~~{.php}
1049 Draw> tplosttrim [<IGES_type>] 
1050 ~~~~
1051 It 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. 
1052
1053 Optional parameter <i>\<IGES_type\></i> can be *TrimmedSurface,  BoundedSurface* or *Face* to specify the only type of IGES faces. 
1054
1055 For example, to get untrimmed 144 entities, use command 
1056 ~~~~{.php}
1057 Draw> tplosttrim TrimmedSurface 
1058 ~~~~
1059 To get the information on OCCT shape contents, use command 
1060 ~~~~{.php}
1061 Draw> statshape <shape_name> 
1062 ~~~~
1063 It 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.). 
1064
1065 Note. 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. 
1066
1067 To analyze the internal validity of a shape, use command  
1068 ~~~~{.php}
1069 Draw> checkbrep <shape_name> <expurged_shape_name>
1070 ~~~~
1071 It 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. 
1072
1073 <i>\<expurged_shape_name\></i> will contain the original shape  without invalid subshapes. 
1074
1075 To get information on tolerances of subshapes, use command 
1076 ~~~~{.php}
1077 Draw> tolerance <shape_name> [<min> [<max>] [<symbol>]]
1078 ~~~~
1079 It 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. 
1080
1081 When 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>. 
1082
1083 <i>\<Symbol\></i> is used for specifying the kind of sub-shapes to analyze: 
1084 * v -- for vertices,
1085 * e -- for edges,
1086 * f -- for faces,
1087 * c -- for shells and faces. 
1088
1089 @subsection occt_iges_4_5 Writing an IGES file
1090
1091 Refer 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*: 
1092
1093 | Description | Name | Values |
1094 | :-----------  | :---- | :----- |
1095 | Author | XSTEP.iges.header.author | String |
1096 | Company | XSTEP.iges.header.company | String |
1097 | Receiver | XSTEP.iges.header.receiver | String |
1098 | Write mode for shapes | XSTEP.iges.writebrep.mode | 0/Faces or 1/BRep |
1099 | Measurement units | XSTEP.iges.unit | 1-11 (or a string value) |
1100
1101 Several shapes can be written in one file. To start writing  a new file, enter command 
1102 ~~~~{.php}
1103 Draw> newmodel 
1104 ~~~~
1105 This command clears the *InterfaceModel* to make it empty.
1106
1107 ~~~~{.php}
1108 Draw> brepiges <shape_name_1> [<filename.igs>]
1109 ~~~~
1110 Converts the  specified shapes into IGES entities and puts them into the *InterfaceModel*.
1111
1112 ~~~~{.php}
1113 Draw> writeall <filename.igs>
1114 ~~~~
1115 Allows writing the prepared model to a file with name *filename.igs*.
1116
1117 @section occt_iges_5 Reading from and writing to IGES
1118
1119 @subsection occt_iges_5_1 Reading from IGES
1120
1121 ### Load an IGES file
1122
1123 Before performing any other operation, you must load an IGES  file with: 
1124 ~~~~{.cpp}
1125 IGESCAFControl_Reader reader(XSDRAW::Session(),  Standard_False); 
1126 IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”); 
1127 ~~~~
1128 Loading the file only memorizes, but does not translate the  data. 
1129
1130 ### Check the loaded IGES file
1131
1132 This step is not obligatory. See the description of @ref occt_iges_2_3_2 "Checking the IGES file" above. 
1133
1134 ### Set parameters for translation to XDE
1135
1136 See the description of @ref occt_iges_2_3_3 "Setting translation parameters" above. 
1137
1138 In  addition, the following parameters can be set for XDE translation of  attributes: 
1139 * For transferring colors: 
1140 ~~~~{.cpp}
1141 reader.SetColorMode(mode); 
1142 // mode can be Standard_True or Standard_False 
1143 ~~~~
1144 * For transferring names: 
1145 ~~~~{.cpp}
1146 reader.SetNameMode(mode); 
1147 // mode can be Standard_True or Standard_False 
1148 ~~~~
1149
1150 ### Translate an IGES file to XDE
1151
1152 The following function performs a translation of the whole  document: 
1153 ~~~~{.cpp}
1154 Standard_Boolean ok = reader.Transfer(doc);  
1155 ~~~~
1156 where *doc* is a variable which contains a handle to the output document and should have a  type *Handle(TDocStd_Document)*. 
1157
1158
1159 @subsection occt_iges_5_2 Writing to IGES
1160
1161 The translation from XDE to IGES can be initialized as follows: 
1162 ~~~~{.cpp}
1163 IGESCAFControl_Writer aWriter(XSDRAW::Session(),Standard_False); 
1164 ~~~~
1165
1166 ### Set parameters for translation from XDE to IGES
1167
1168 The  following parameters can be set for translation of attributes to IGES: 
1169 * For transferring colors: 
1170 ~~~~{.cpp}
1171 aWriter.SetColorMode(mode); 
1172 // mode can be Standard_True or Standard_False 
1173 ~~~~
1174 * For transferring names: 
1175 ~~~~{.cpp}
1176 aWriter.SetNameMode(mode); 
1177 // mode can be Standard_True or Standard_False 
1178 ~~~~
1179
1180 ### Translate an XDE  document to IGES
1181
1182 You can perform the translation of a document by calling the  function: 
1183 ~~~~{.cpp}
1184 IFSelect_ReturnStatus aRetSt = aWriter.Transfer(doc); 
1185 ~~~~
1186 where "doc" is a variable which contains a handle to the input document for transferring  and should have a type *Handle(TDocStd_Document)*.
1187  
1188 ### Write an IGES file
1189
1190 Write an IGES file with: 
1191 ~~~~{.cpp}
1192 IFSelect_ReturnStatus statw =  aWriter.WriteFile("filename.igs"); 
1193 ~~~~
1194 or 
1195 ~~~~{.cpp}
1196 IFSelect_ReturnStatus statw = writer.WriteFile (S); 
1197 ~~~~
1198 where S is OStream.  
1199
1200
1201