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