1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 // --------------------------
16 // --------------------------
18 #include <gp_Pnt2d.hxx>
23 #include <gp_GTrsf.hxx>
24 #include <Interface_MSG.hxx>
26 // ###############################################################
27 // Macros to help Dumping Parts of IGES Entities
28 // (for usefull and repetitive cases but which apply to different classes
29 // but with similar signatures, such as Arrays)
30 // Remember that the class IGESDumper processes itself individual dump of
33 // General Names are : IGESData_Dump***(S,arglist); S being an output Stream
35 // ---------------------------------------------------------------
38 // Dumping simple IGESEntity : see the class IGESDumper itself
39 // Dumping a text as HAsciiString (either from PCollection or TCollection)
40 // (manages an empty pointer) :
41 // IGESData_DumpString(S,str) displays " "Content" " or "(undefined)"
43 // Dumping Simple Data : Level must be managed by the caller
44 // (general rule : Transformed Display to be used if Level > 5)
46 // IGESData_DumpXY(S,XYval) " (Xval,Yval)" (no Transf)
47 // IGESData_DumpXYT(S,XYVal,Trsf) " (Xval,Yval)" Z ignored
48 // IGESData_DumpXYTZ(S,XYVal,Trsf,Z) " (Xval,Yval,Zval)" Z combined
49 // IGESData_DumpXYZ(S,XYZval) " (Xval,Yval,Zval)" (no Transf)
50 // IGESData_DumpXYZT(S,XYZval,Trsf) " (Xval,Yval,Zval)" (Transf)
52 // Dumping Simple Data with Level : first displays Immediate Value, then
53 // if Level > 5 and Transformation is not Identity, displays Transformed Value
55 // IGESData_DumpXYL(S,Level,XYVal,Trsf) " (Xval,Yval) Transformed : (..)"
56 // IGESData_DumpXYLZ(S,Level,XYVal,Trsf,Z) " (Xval,Yval,Zval) Transformed :."
57 // IGESData_DumpXYZL(S,Level,XYZval,Trsf) " (Xval,Yval,Zval) Transformed :."
59 // Dumping Lists : general features
60 // Lower and Upper are effective Values (immediate or given by functions).
61 // Typically, give Lower = 1, Upper = ent->NbItems()
62 // Item is the name of the access fonction (without its Index)
63 // For Instance, Item = compcurve->Curve AND NOT compcurve->Curve(..)
64 // If Level is present, it commands more or less extensive display :
65 // Level = 4, only limits are displayed
66 // If it is a classic list, starting from 1 with a count (which can be 0),
67 // displays "Count <upper> ..." or "Empty". Else, display "(low - up) ..."
68 // Level = 5, in addfition items are displayed shortly
69 // (Entity Directory Numbers, XY/XYZ Coordinates)
70 // Level > 5, in some cases, items are displayed with more details
71 // (Entities with Type/Form, XY/XYZ with Transformed equivalents)
73 // IGESData_DumpListVal(S,Lower,Upper,Item) Item can be Real,Integer,
74 // more generally, any type having operator << to Handle(Message_Messenger)
75 // IGESData_DumpListXY(S,Lower,Upper,Item) Item : XY without Transformation
76 // IGESData_DumpListXYZ(S,Lower,Upper,Item) Item : XYZ without Transf
78 // IGESData_DumpVals(S,Level,Lower,Upper,Item) Item : Real,Integer
79 // IGESData_DumpListXYL(S,Level,Lower,Upper,Item,Trsf) Item : XY
80 // IGESData_DumpListXYLZ(S,Level,Lower,Upper,Item,Trsf,Z) Item : XY. Z is a
81 // Common Displacement
82 // IGESData_DumpListXYZL(S,Level,Lower,Upper,Item,Trsf) Item : XYZ
84 // IGESData_DumpStrings(S,Level,Lower,Upper,Item) Item : HAsciiString
85 // IGESData_DumpEntities(S,Dumper,Level,Lower,Upper,Item) Item : IGESEntity
86 // Dumper is an IGESDumper which displays IGES Entities
88 // Dumping Complex Arrays : only the most useful cases are taken into account
89 // Doubles Arrays (Rectangles) and Single Arrays of Single Arrays (Jagged)
91 // IGESData_DumpRectVals(S,Level,LowerRow,UpperRow,LowerCol,UpperCol,Item)
92 // LowerRow,LowerCol,UpperRow,UpperCol : effective values
93 // Item : Real,Integer
95 // ---------------------------------------------------------------
97 #define IGESData_DumpString(S,str) \
98 if (str.IsNull()) S << "(undefined)";\
99 else { S << '"' << str->String() << '"'; }
101 #define IGESData_DumpXY(S,XYval) \
102 S << " (" << XYval.X() << "," << XYval.Y() << ")"
104 #define IGESData_DumpXYZ(S,XYZval) \
105 S << " (" << XYZval.X() << "," << XYZval.Y() << "," << XYZval.Z() << ")"
108 #define IGESData_DumpXYT(S,XYval,Trsf) \
110 gp_XYZ XYZval(XYval.X(),XYval.Y(),0.);\
111 Trsf.Transforms(XYZval);\
112 IGESData_DumpXY(S,XYZval);\
115 #define IGESData_DumpXYTZ(S,XYval,Trsf,Z) \
117 gp_XYZ XYZval(XYval.X(),XYval.Y(),Z);\
118 Trsf.Transforms(XYZval);\
119 IGESData_DumpXYZ(S,XYZval);\
122 #define IGESData_DumpXYZT(S,XYZval,Trsf) \
124 gp_XYZ XYZTval(XYZval.X(),XYZval.Y(),XYZval.Z());\
125 Trsf.Transforms(XYZTval);\
126 IGESData_DumpXYZ(S,XYZTval);\
130 #define IGESData_DumpXYL(S,Level,XYval,Trsf) \
132 IGESData_DumpXY(S,XYval);\
133 if (Level > 5 && Trsf.Form() != gp_Identity) {\
134 S << " Transformed :";\
135 IGESData_DumpXYT(S,XYval,Trsf);\
139 #define IGESData_DumpXYLZ(S,Level,XYval,Trsf,Z) \
141 IGESData_DumpXY(S,XYval);\
142 if (Level > 5 && Trsf.Form() != gp_Identity) {\
143 S << " Transformed :";\
144 IGESData_DumpXYTZ(S,XYval,Trsf,Z);\
148 #define IGESData_DumpXYZL(S,Level,XYZval,Trsf) \
150 IGESData_DumpXYZ(S,XYZval);\
151 if (Level > 5 && Trsf.Form() != gp_Identity) {\
152 S << " Transformed :";\
153 IGESData_DumpXYZT(S,XYZval,Trsf);\
158 #define IGESData_DumpListHeader(S,lower,upper) \
160 if (lower > upper) S << " (Empty List)";\
161 else if (lower == 1) S << " (Count : " << upper << ")";\
162 else S << " (" << lower << " - " << upper << ")";\
166 #define IGESData_DumpListVal(S,lower,upper,item) \
168 Standard_Integer lo = lower; Standard_Integer up = upper;\
169 IGESData_DumpListHeader(S,lo,up);\
171 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) S << " " << item(iopa);\
174 #define IGESData_DumpListXY(S,lower,upper,item) \
176 Standard_Integer lo = lower; Standard_Integer up = upper;\
177 IGESData_DumpListHeader(S,lo,up);\
179 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXY(S,item(iopa));\
182 #define IGESData_DumpListXYZ(S,lower,upper,item) \
184 Standard_Integer lo = lower; Standard_Integer up = upper;\
185 IGESData_DumpListHeader(S,lo,up);\
187 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXYZ(S,item(iopa));\
191 #define IGESData_DumpVals(S,Level,lower,upper,item) \
193 Standard_Integer lo = lower; Standard_Integer up = upper;\
194 IGESData_DumpListHeader(S,lo,up);\
196 else if (Level == 4 || Level == -4) S <<" [content : ask level > 4]";\
197 else if (Level > 0) {\
199 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) S << " " << item(iopa);\
203 #define IGESData_DumpListXYL(S,Level,lower,upper,item,Trsf) \
205 Standard_Integer lo = lower; Standard_Integer up = upper;\
206 IGESData_DumpListHeader(S,lo,up);\
208 else if (Level == 4 || Level == -4)\
209 S <<" [content : ask level > 4, transformed : level > 5]";\
210 else if (Level > 0) {\
212 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXY(S,item(iopa));\
213 if (Trsf.Form() != gp_Identity) {\
214 S << "\n Transformed :";\
215 if (Level == 5) S <<" [ask level > 5]";\
217 for (Standard_Integer jopa = lo; jopa <= up; jopa ++)\
218 IGESData_DumpXYT(S,item(jopa),Trsf);\
223 #define IGESData_DumpListXYLZ(S,Level,lower,upper,item,Trsf,Z) \
225 Standard_Integer lo = lower; Standard_Integer up = upper;\
226 IGESData_DumpListHeader(S,lo,up);\
228 else if (Level == 4 || Level == -4)\
229 S <<" [content : ask level > 4, transformed : level > 5]";\
230 else if (Level > 0) {\
232 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXY(S,item(iopa));\
233 if (Trsf.Form() != gp_Identity) {\
234 S << "\n Transformed :";\
235 if (Level == 5) S <<" [ask level > 5]";\
237 for (Standard_Integer jopa = lo; jopa <= up; jopa ++)\
238 IGESData_DumpXYTZ(S,item(jopa),Trsf,Z);\
244 #define IGESData_DumpListXYZL(S,Level,lower,upper,item,Trsf) \
246 Standard_Integer lo = lower; Standard_Integer up = upper;\
247 IGESData_DumpListHeader(S,lo,up);\
249 else if (Level == 4 || Level == -4)\
250 S <<" [content : ask level > 4, transformed : level > 5]";\
251 else if (Level > 0) {\
253 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXYZ(S,item(iopa));\
254 if (Trsf.Form() != gp_Identity) {\
255 S << "\n Transformed :";\
256 if (Level == 5) S <<" [ask level > 5]";\
258 for (Standard_Integer jopa = lo; jopa <= up; jopa ++)\
259 IGESData_DumpXYZT(S,item(jopa),Trsf);\
265 #define IGESData_DumpStrings(S,Level,lower,upper,item) \
267 Standard_Integer lo = lower; Standard_Integer up = upper;\
268 IGESData_DumpListHeader(S,lo,up);\
270 else if (Level == 4 || Level == -4) S <<" [content : ask level > 4]";\
271 else if (Level > 0) {\
273 for (Standard_Integer iopa = lo; iopa <= up; iopa ++)\
274 { S << "\n["<<Interface_MSG::Blanks(iopa,3)<<iopa<<"]:\"" << item(iopa)->String() << '"'; }\
279 #define IGESData_DumpEntities(S,dumper,Level,lower,upper,item) \
281 Standard_Integer lo = lower; Standard_Integer up = upper;\
282 IGESData_DumpListHeader(S,lo,up);\
284 else if (Level == 4 || Level == -4) S <<" [content : ask level > 4]";\
285 else if (Level > 0) {\
287 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) {\
288 if (Level == 5) { S << " " ; dumper.PrintDNum (item(iopa),S); }\
289 else { S << "\n["<<Interface_MSG::Blanks(iopa,3)<<iopa<<"]:"; dumper.PrintShort (item(iopa),S); }\
295 #define IGESData_DumpRectVals(S,Level,LowCol,UpCol,LowRow,UpRow,Item) \
297 int loco = LowCol; int upc = UpCol; int lor = LowRow; int upr = UpRow;\
298 S <<" (Row :"<< lor <<" - "<< upr <<" ; Col :"<< loco <<" - "<< upc <<")";\
299 if (loco > upc || lor > upr) {}\
300 else if (Level == 4 || Level == -4) S <<" [content : ask level > 4]";\
301 else if (Level > 0) {\
303 for (int ir = lor; ir <= upr; ir ++) {\
304 S << "Row "<<ir<<":[";\
305 for (int ic = loco; ic <= upc; ic ++) S << " " << Item(ic,ir);\