0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / IGESData / IGESData_IGESEntity.hxx
1 // Created on: 1992-04-07
2 // Created by: Christian CAILLET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _IGESData_IGESEntity_HeaderFile
18 #define _IGESData_IGESEntity_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <IGESData_DefSwitch.hxx>
25 #include <Interface_EntityList.hxx>
26 #include <Standard_Transient.hxx>
27 #include <IGESData_DefType.hxx>
28 #include <IGESData_DefList.hxx>
29 #include <Standard_CString.hxx>
30 class TCollection_HAsciiString;
31 class IGESData_IGESType;
32 class IGESData_LineFontEntity;
33 class IGESData_LevelListEntity;
34 class IGESData_ViewKindEntity;
35 class IGESData_TransfEntity;
36 class IGESData_LabelDisplayEntity;
37 class IGESData_ColorEntity;
38 class gp_GTrsf;
39 class Interface_EntityIterator;
40
41
42 class IGESData_IGESEntity;
43 DEFINE_STANDARD_HANDLE(IGESData_IGESEntity, Standard_Transient)
44
45 //! defines root of IGES Entity definition, including Directory
46 //! Part, lists of (optional) Properties and Associativities
47 class IGESData_IGESEntity : public Standard_Transient
48 {
49
50 public:
51
52   
53   //! gives IGES typing info (includes "Type" and "Form" data)
54   Standard_EXPORT IGESData_IGESType IGESType() const;
55   
56   //! gives IGES Type Number (often coupled with Form Number)
57   Standard_EXPORT Standard_Integer TypeNumber() const;
58   
59   //! Returns the form number for that
60   //! type of an IGES entity. The default form number is 0.
61   Standard_EXPORT Standard_Integer FormNumber() const;
62   
63   //! Returns the Entity which has been recorded for a given
64   //! Field Number, i.e. without any cast. Maps with :
65   //! 3 : Structure   4 : LineFont     5 : LevelList     6 : View
66   //! 7 : Transf(ormation Matrix)      8 : LabelDisplay
67   //! 13 : Color.  Other values give a null handle
68   //! It can then be of any kind, while specific items have a Type
69   Standard_EXPORT Handle(IGESData_IGESEntity) DirFieldEntity (const Standard_Integer fieldnum) const;
70   
71   //! returns True if an IGESEntity is defined with a Structure
72   //! (it is normally reserved for certain classes, such as Macros)
73   Standard_EXPORT Standard_Boolean HasStructure() const;
74   
75   //! Returns Structure (used by some types of IGES Entities only)
76   //! Returns a Null Handle if Structure is not defined
77   Standard_EXPORT Handle(IGESData_IGESEntity) Structure() const;
78   
79   //! Returns the definition status of LineFont
80   Standard_EXPORT virtual IGESData_DefType DefLineFont() const;
81   
82   //! Returns LineFont definition as an Integer (if defined as Rank)
83   //! If LineFont is defined as an Entity, returns a negative value
84   Standard_EXPORT Standard_Integer RankLineFont() const;
85   
86   //! Returns LineFont as an Entity (if defined as Reference)
87   //! Returns a Null Handle if DefLineFont is not "DefReference"
88   Standard_EXPORT Handle(IGESData_LineFontEntity) LineFont() const;
89   
90   //! Returns the definition status of Level
91   Standard_EXPORT virtual IGESData_DefList DefLevel() const;
92   
93   //! Returns the level the entity
94   //! belongs to. Returns -1 if the entity belongs to more than one  level.
95   Standard_EXPORT Standard_Integer Level() const;
96   
97   //! Returns LevelList if Level is
98   //! defined as a list. Returns a null handle if DefLevel is not DefSeveral.
99   Standard_EXPORT Handle(IGESData_LevelListEntity) LevelList() const;
100   
101   //! Returns the definition status of
102   //! the view. This can be: none, one or several.
103   Standard_EXPORT virtual IGESData_DefList DefView() const;
104   
105   //! Returns the view of this IGES entity.
106   //! This view can be a single view or a list of views.
107   //! Warning A null handle is returned if the view is not defined.
108   Standard_EXPORT Handle(IGESData_ViewKindEntity) View() const;
109   
110   //! Returns the view as a single view
111   //! if it was defined as such and not as a list of views.
112   //! Warning A null handle is returned if DefView does not have the value DefOne.
113   Standard_EXPORT Handle(IGESData_ViewKindEntity) SingleView() const;
114   
115   //! Returns the view of this IGES entity as a list.
116   //! Warning A null handle is returned if the
117   //! definition status does not have the value DefSeveral.
118   Standard_EXPORT Handle(IGESData_ViewKindEntity) ViewList() const;
119   
120   //! Returns True if a Transformation Matrix is defined
121   Standard_EXPORT Standard_Boolean HasTransf() const;
122   
123   //! Returns the Transformation Matrix (under IGES definition)
124   //! Returns a Null Handle if there is none
125   //! for a more complete use, see Location & CompoundLocation
126   Standard_EXPORT Handle(IGESData_TransfEntity) Transf() const;
127   
128   //! Returns True if a LabelDisplay mode is defined for this entity
129   Standard_EXPORT Standard_Boolean HasLabelDisplay() const;
130   
131   //! Returns the Label Display
132   //! Associativity Entity if there is one. Returns a null handle if there is none.
133   Standard_EXPORT Handle(IGESData_LabelDisplayEntity) LabelDisplay() const;
134   
135   //! gives Blank Status (0 visible, 1 blanked)
136   Standard_EXPORT Standard_Integer BlankStatus() const;
137   
138   //! gives Subordinate Switch (0-1-2-3)
139   Standard_EXPORT Standard_Integer SubordinateStatus() const;
140   
141   //! gives Entity's Use Flag (0 to 5)
142   Standard_EXPORT Standard_Integer UseFlag() const;
143   
144   //! gives Hierarchy status (0-1-2)
145   Standard_EXPORT Standard_Integer HierarchyStatus() const;
146   
147   //! Returns the LineWeight Number (0  not defined), see also LineWeight
148   Standard_EXPORT Standard_Integer LineWeightNumber() const;
149   
150   //! Returns the true Line Weight, computed from LineWeightNumber and
151   //! Global Parameter in the Model by call to SetLineWeight
152   Standard_EXPORT Standard_Real LineWeight() const;
153   
154   //! Returns the definition status of Color.
155   Standard_EXPORT virtual IGESData_DefType DefColor() const;
156   
157   //! Returns the color definition as
158   //! an integer value if the color was defined as a rank.
159   //! Warning A negative value is returned if the color was defined as an entity.
160   Standard_EXPORT Standard_Integer RankColor() const;
161   
162   //! Returns the IGES entity which
163   //! describes the color of the entity.
164   //! Returns a null handle if this entity was defined as an integer.
165   Standard_EXPORT Handle(IGESData_ColorEntity) Color() const;
166   
167   //! returns "reserved" alphanumeric values res1 and res2
168   //! res1 and res2 have to be reserved as Character[9 at least]
169   //! (remark : their content is changed)
170   //! returned values are ended by null character in 9th
171   //! returned Boolean is False if res1 and res2 are blank, true else
172   Standard_EXPORT Standard_Boolean CResValues (const Standard_CString res1, const Standard_CString res2) const;
173   
174   //! Returns true if a short label is defined.
175   //! A short label is a non-blank 8-character string.
176   Standard_EXPORT Standard_Boolean HasShortLabel() const;
177   
178   //! Returns the label value for this IGES entity as a string.
179   //! Warning If the label is blank, this string is null.
180   Standard_EXPORT Handle(TCollection_HAsciiString) ShortLabel() const;
181   
182   //! Returns true if a subscript number is defined.
183   //! A subscript number is an integer used to identify a label.
184   Standard_EXPORT virtual Standard_Boolean HasSubScriptNumber() const;
185   
186   //! Returns the integer subscript number used to identify this IGES entity.
187   //! Warning 0 is returned if no subscript number is defined for this IGES entity.
188   Standard_EXPORT Standard_Integer SubScriptNumber() const;
189   
190   //! Initializes a directory field as an Entiy of any kind
191   //! See DirFieldEntity for more details
192   Standard_EXPORT void InitDirFieldEntity (const Standard_Integer fieldnum, const Handle(IGESData_IGESEntity)& ent);
193   
194   //! Initializes Transf, or erases it if <ent> is given Null
195   Standard_EXPORT void InitTransf (const Handle(IGESData_TransfEntity)& ent);
196   
197   //! Initializes View, or erases it if <ent> is given Null
198   Standard_EXPORT void InitView (const Handle(IGESData_ViewKindEntity)& ent);
199   
200   //! Initializes LineFont : if <ent> is not Null, it gives LineFont,
201   //! else <rank> gives or erases (if zero) RankLineFont
202   Standard_EXPORT void InitLineFont (const Handle(IGESData_LineFontEntity)& ent, const Standard_Integer rank = 0);
203   
204   //! Initializes Level : if <ent> is not Null, it gives LevelList,
205   //! else <val> gives or erases (if zero) unique Level
206   Standard_EXPORT void InitLevel (const Handle(IGESData_LevelListEntity)& ent, const Standard_Integer val = 0);
207   
208   //! Initializes Color data : if <ent> is not Null, it gives Color,
209   //! else <rank> gives or erases (if zero) RankColor
210   Standard_EXPORT void InitColor (const Handle(IGESData_ColorEntity)& ent, const Standard_Integer rank = 0);
211   
212   //! Initializes the Status of Directory Part
213   Standard_EXPORT void InitStatus (const Standard_Integer blank, const Standard_Integer subordinate, const Standard_Integer useflag, const Standard_Integer hierarchy);
214   
215   //! Sets a new Label to an IGES Entity
216   //! If <sub> is given, it sets value of SubScriptNumber
217   //! else, SubScriptNumber is erased
218   Standard_EXPORT void SetLabel (const Handle(TCollection_HAsciiString)& label, const Standard_Integer sub = -1);
219   
220   //! Initializes various data (those not yet seen above), or erases
221   //! them if they are given as Null (Zero for <weightnum>) :
222   //! <str> for Structure, <lab> for LabelDisplay, and
223   //! <weightnum> for WeightNumber
224   Standard_EXPORT void InitMisc (const Handle(IGESData_IGESEntity)& str, const Handle(IGESData_LabelDisplayEntity)& lab, const Standard_Integer weightnum);
225   
226   //! Returns True if an entity has one and only one parent, defined
227   //! by a SingleParentEntity Type Associativity (explicit sharing).
228   //! Thus, implicit sharing remains defined at model level
229   //! (see class ToolLocation)
230   Standard_EXPORT Standard_Boolean HasOneParent() const;
231   
232   //! Returns the Unique Parent (in the sense given by HasOneParent)
233   //! Error if there is none or several
234   Standard_EXPORT Handle(IGESData_IGESEntity) UniqueParent() const;
235   
236   //! Returns Location given by Transf in Directory Part (see above)
237   //! It must be considered for local definition : if the Entity is
238   //! set in a "Parent", that one can add its one Location, but this
239   //! is not taken in account here : see CompoundLocation for that.
240   //! If no Transf is defined, returns Identity
241   //! If Transf is itself compound, gives the final result
242   Standard_EXPORT gp_GTrsf Location() const;
243   
244   //! Returns Location considered for Vectors, i.e. without its
245   //! Translation Part. As Location, it gives local definition.
246   Standard_EXPORT gp_GTrsf VectorLocation() const;
247   
248   //! Returns Location by taking in account a Parent which has its
249   //! own Location : that one will be combined to that of <me>
250   //! The Parent is considered only if HasOneParent is True,
251   //! else it is ignored and CompoundLocation = Location
252   Standard_EXPORT gp_GTrsf CompoundLocation() const;
253   
254   //! says if a Name is defined, as Short Label or as Name Property
255   //! (Property is looked first, else ShortLabel is considered)
256   Standard_EXPORT Standard_Boolean HasName() const;
257   
258   //! returns Name value as a String (Property Name or ShortLabel)
259   //! if SubNumber is defined, it is concatenated after ShortLabel
260   //! as follows label(number). Ignored with a Property Name
261   Standard_EXPORT Handle(TCollection_HAsciiString) NameValue() const;
262   
263   //! Returns True if the Entity is defined with an Associativity
264   //! list, even empty (that is, file contains its length 0)
265   //! Else, the file contained NO idencation at all about this list.
266   Standard_EXPORT Standard_Boolean ArePresentAssociativities() const;
267   
268   //! gives number of recorded associativities (0  no list defined)
269   Standard_EXPORT Standard_Integer NbAssociativities() const;
270   
271   //! Returns the Associativity List under the form of an EntityIterator.
272   Standard_EXPORT Interface_EntityIterator Associativities() const;
273   
274   //! gives how many Associativities have a given type
275   Standard_EXPORT Standard_Integer NbTypedAssociativities (const Handle(Standard_Type)& atype) const;
276   
277   //! returns the Associativity of a given Type (if only one exists)
278   //! Error if none or more than one
279   Standard_EXPORT Handle(IGESData_IGESEntity) TypedAssociativity (const Handle(Standard_Type)& atype) const;
280   
281   //! Sets "me" in the Associativity list of another Entity
282   Standard_EXPORT void Associate (const Handle(IGESData_IGESEntity)& ent) const;
283   
284   //! Resets "me" from the Associativity list of another Entity
285   Standard_EXPORT void Dissociate (const Handle(IGESData_IGESEntity)& ent) const;
286   
287   //! Returns True if the Entity is defined with a Property list,
288   //! even empty (that is, file contains its length 0)
289   //! Else, the file contained NO idencation at all about this list
290   Standard_EXPORT Standard_Boolean ArePresentProperties() const;
291   
292   //! Gives number of recorded properties (0  no list defined)
293   Standard_EXPORT Standard_Integer NbProperties() const;
294   
295   //! Returns Property List under the form of an EntityIterator
296   Standard_EXPORT Interface_EntityIterator Properties() const;
297   
298   //! gives how many Properties have a given type
299   Standard_EXPORT Standard_Integer NbTypedProperties (const Handle(Standard_Type)& atype) const;
300   
301   //! returns the Property of a given Type
302   //! Error if none or more than one
303   Standard_EXPORT Handle(IGESData_IGESEntity) TypedProperty (const Handle(Standard_Type)& atype, const Standard_Integer anum = 0) const;
304   
305   //! Adds a Property in the list
306   Standard_EXPORT void AddProperty (const Handle(IGESData_IGESEntity)& ent);
307   
308   //! Removes a Property from the list
309   Standard_EXPORT void RemoveProperty (const Handle(IGESData_IGESEntity)& ent);
310   
311   //! computes and sets "true" line weight according IGES rules from
312   //! global data MaxLineWeight (maxv) and LineWeightGrad (gradw),
313   //! or sets it to defw (Default) if LineWeightNumber is null
314   Standard_EXPORT void SetLineWeight (const Standard_Real defw, const Standard_Real maxw, const Standard_Integer gradw);
315
316
317 friend class IGESData_ReadWriteModule;
318 friend class IGESData_GeneralModule;
319 friend class IGESData_IGESReaderTool;
320 friend class IGESData_DirChecker;
321
322
323   DEFINE_STANDARD_RTTIEXT(IGESData_IGESEntity,Standard_Transient)
324
325 protected:
326
327   
328   //! prepares lists of optional data, set values to defaults
329   Standard_EXPORT IGESData_IGESEntity();
330   
331   //! Initializes Type and Form Numbers to new values. Reserved for
332   //! special uses
333   Standard_EXPORT void InitTypeAndForm (const Standard_Integer typenum, const Standard_Integer formnum);
334   
335   //! Loads a complete, already loaded, List of Asociativities
336   //! (used during Read or Copy Operations)
337   Standard_EXPORT void LoadAssociativities (const Interface_EntityList& list);
338   
339   //! Loads a complete, already loaded, List of Properties
340   //! (used during Read or Copy Operations)
341   Standard_EXPORT void LoadProperties (const Interface_EntityList& list);
342   
343   //! Removes all properties in once
344   Standard_EXPORT void ClearProperties();
345
346
347
348 private:
349
350   
351   //! Clears specific IGES data
352   Standard_EXPORT void Clear();
353   
354   //! Adds an Associativity in the list (called by Associate only)
355   Standard_EXPORT void AddAssociativity (const Handle(IGESData_IGESEntity)& ent);
356   
357   //! Removes an Associativity from the list (called by Dissociate)
358   Standard_EXPORT void RemoveAssociativity (const Handle(IGESData_IGESEntity)& ent);
359   
360   //! Removes all associativities in once
361   Standard_EXPORT void ClearAssociativities();
362
363   Standard_Integer theType;
364   Standard_Integer theForm;
365   Handle(IGESData_IGESEntity) theStructure;
366   IGESData_DefSwitch theDefLineFont;
367   Handle(IGESData_IGESEntity) theLineFont;
368   Standard_Integer theDefLevel;
369   Handle(IGESData_IGESEntity) theLevelList;
370   Handle(IGESData_IGESEntity) theView;
371   Handle(IGESData_IGESEntity) theTransf;
372   Handle(IGESData_IGESEntity) theLabDisplay;
373   Standard_Integer theStatusNum;
374   Standard_Integer theLWeightNum;
375   Standard_Real theLWeightVal;
376   IGESData_DefSwitch theDefColor;
377   Handle(IGESData_IGESEntity) theColor;
378   Standard_Character theRes1[9];
379   Standard_Character theRes2[9];
380   Handle(TCollection_HAsciiString) theShortLabel;
381   Standard_Integer theSubScriptN;
382   Interface_EntityList theAssocs;
383   Interface_EntityList theProps;
384
385
386 };
387
388
389
390
391
392
393
394 #endif // _IGESData_IGESEntity_HeaderFile