0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IGESData / IGESData_Dump.hxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14// --------------------------
15// IGESData_Dump.hxx
16// --------------------------
17#include <gp_XY.hxx>
18#include <gp_Pnt2d.hxx>
19#include <gp_XYZ.hxx>
20#include <gp_Pnt.hxx>
21#include <gp_Vec.hxx>
22#include <gp_Dir.hxx>
23#include <gp_GTrsf.hxx>
24#include <Interface_MSG.hxx>
25
26// ###############################################################
7fd59977 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
31// IGESEntity
32
33// General Names are : IGESData_Dump***(S,arglist); S being an output Stream
34
35// ---------------------------------------------------------------
36// AVAILABLE MACROS
37
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)"
42
43// Dumping Simple Data : Level must be managed by the caller
44// (general rule : Transformed Display to be used if Level > 5)
45
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)
51
52// Dumping Simple Data with Level : first displays Immediate Value, then
53// if Level > 5 and Transformation is not Identity, displays Transformed Value
54
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 :."
58
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)
72
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
77
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
83
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
87
88// Dumping Complex Arrays : only the most useful cases are taken into account
89// Doubles Arrays (Rectangles) and Single Arrays of Single Arrays (Jagged)
90
91// IGESData_DumpRectVals(S,Level,LowerRow,UpperRow,LowerCol,UpperCol,Item)
92// LowerRow,LowerCol,UpperRow,UpperCol : effective values
93// Item : Real,Integer
94
95// ---------------------------------------------------------------
96
97#define IGESData_DumpString(S,str) \
b311480e 98if (str.IsNull()) S << "(undefined)";\
0ebe5b0a 99 else { S << '"' << str->String() << '"'; }
7fd59977 100
101#define IGESData_DumpXY(S,XYval) \
102 S << " (" << XYval.X() << "," << XYval.Y() << ")"
103
104#define IGESData_DumpXYZ(S,XYZval) \
105 S << " (" << XYZval.X() << "," << XYZval.Y() << "," << XYZval.Z() << ")"
106
107
108#define IGESData_DumpXYT(S,XYval,Trsf) \
109{\
110 gp_XYZ XYZval(XYval.X(),XYval.Y(),0.);\
111 Trsf.Transforms(XYZval);\
112 IGESData_DumpXY(S,XYZval);\
113}
114
115#define IGESData_DumpXYTZ(S,XYval,Trsf,Z) \
116{\
117 gp_XYZ XYZval(XYval.X(),XYval.Y(),Z);\
118 Trsf.Transforms(XYZval);\
119 IGESData_DumpXYZ(S,XYZval);\
120}
121
122#define IGESData_DumpXYZT(S,XYZval,Trsf) \
123{\
124 gp_XYZ XYZTval(XYZval.X(),XYZval.Y(),XYZval.Z());\
125 Trsf.Transforms(XYZTval);\
126 IGESData_DumpXYZ(S,XYZTval);\
127}
128
129
130#define IGESData_DumpXYL(S,Level,XYval,Trsf) \
131{\
132 IGESData_DumpXY(S,XYval);\
133 if (Level > 5 && Trsf.Form() != gp_Identity) {\
134 S << " Transformed :";\
135 IGESData_DumpXYT(S,XYval,Trsf);\
136 }\
137}
138
139#define IGESData_DumpXYLZ(S,Level,XYval,Trsf,Z) \
140{\
141 IGESData_DumpXY(S,XYval);\
142 if (Level > 5 && Trsf.Form() != gp_Identity) {\
143 S << " Transformed :";\
144 IGESData_DumpXYTZ(S,XYval,Trsf,Z);\
145 }\
146}
147
148#define IGESData_DumpXYZL(S,Level,XYZval,Trsf) \
149{\
150 IGESData_DumpXYZ(S,XYZval);\
151 if (Level > 5 && Trsf.Form() != gp_Identity) {\
152 S << " Transformed :";\
153 IGESData_DumpXYZT(S,XYZval,Trsf);\
154 }\
155}
156
157
158#define IGESData_DumpListHeader(S,lower,upper) \
159{\
160 if (lower > upper) S << " (Empty List)";\
161 else if (lower == 1) S << " (Count : " << upper << ")";\
162 else S << " (" << lower << " - " << upper << ")";\
163}
164
165
166#define IGESData_DumpListVal(S,lower,upper,item) \
167{\
168 Standard_Integer lo = lower; Standard_Integer up = upper;\
169 IGESData_DumpListHeader(S,lo,up);\
170 S << " :";\
171 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) S << " " << item(iopa);\
172}
173
174#define IGESData_DumpListXY(S,lower,upper,item) \
175{\
176 Standard_Integer lo = lower; Standard_Integer up = upper;\
177 IGESData_DumpListHeader(S,lo,up);\
178 S << " :";\
179 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXY(S,item(iopa));\
180}
181
182#define IGESData_DumpListXYZ(S,lower,upper,item) \
183{\
184 Standard_Integer lo = lower; Standard_Integer up = upper;\
185 IGESData_DumpListHeader(S,lo,up);\
186 S << " :";\
187 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXYZ(S,item(iopa));\
188}
189
190
191#define IGESData_DumpVals(S,Level,lower,upper,item) \
192{\
193 Standard_Integer lo = lower; Standard_Integer up = upper;\
194 IGESData_DumpListHeader(S,lo,up);\
195 if (lo > up) {}\
196 else if (Level == 4 || Level == -4) S <<" [content : ask level > 4]";\
197 else if (Level > 0) {\
198 S << " :";\
199 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) S << " " << item(iopa);\
200 }\
201}
202
203#define IGESData_DumpListXYL(S,Level,lower,upper,item,Trsf) \
204{\
205 Standard_Integer lo = lower; Standard_Integer up = upper;\
206 IGESData_DumpListHeader(S,lo,up);\
207 if (lo > up) {}\
208 else if (Level == 4 || Level == -4)\
209 S <<" [content : ask level > 4, transformed : level > 5]";\
210 else if (Level > 0) {\
211 S << " :";\
212 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXY(S,item(iopa));\
213 if (Trsf.Form() != gp_Identity) {\
0ebe5b0a 214 S << "\n Transformed :";\
215 if (Level == 5) S <<" [ask level > 5]";\
7fd59977 216 else\
217 for (Standard_Integer jopa = lo; jopa <= up; jopa ++)\
218 IGESData_DumpXYT(S,item(jopa),Trsf);\
219 }\
220 }\
221}
222
223#define IGESData_DumpListXYLZ(S,Level,lower,upper,item,Trsf,Z) \
224{\
225 Standard_Integer lo = lower; Standard_Integer up = upper;\
226 IGESData_DumpListHeader(S,lo,up);\
227 if (lo > up) {}\
228 else if (Level == 4 || Level == -4)\
229 S <<" [content : ask level > 4, transformed : level > 5]";\
230 else if (Level > 0) {\
231 S << " :";\
232 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXY(S,item(iopa));\
233 if (Trsf.Form() != gp_Identity) {\
0ebe5b0a 234 S << "\n Transformed :";\
235 if (Level == 5) S <<" [ask level > 5]";\
7fd59977 236 else\
237 for (Standard_Integer jopa = lo; jopa <= up; jopa ++)\
238 IGESData_DumpXYTZ(S,item(jopa),Trsf,Z);\
239 }\
240 }\
241}
242
243
244#define IGESData_DumpListXYZL(S,Level,lower,upper,item,Trsf) \
245{\
246 Standard_Integer lo = lower; Standard_Integer up = upper;\
247 IGESData_DumpListHeader(S,lo,up);\
248 if (lo > up) {}\
249 else if (Level == 4 || Level == -4)\
250 S <<" [content : ask level > 4, transformed : level > 5]";\
251 else if (Level > 0) {\
252 S << " :";\
253 for (Standard_Integer iopa = lo; iopa <= up; iopa ++) IGESData_DumpXYZ(S,item(iopa));\
254 if (Trsf.Form() != gp_Identity) {\
0ebe5b0a 255 S << "\n Transformed :";\
256 if (Level == 5) S <<" [ask level > 5]";\
7fd59977 257 else\
258 for (Standard_Integer jopa = lo; jopa <= up; jopa ++)\
259 IGESData_DumpXYZT(S,item(jopa),Trsf);\
260 }\
261 }\
262}
263
264
265#define IGESData_DumpStrings(S,Level,lower,upper,item) \
266{\
267 Standard_Integer lo = lower; Standard_Integer up = upper;\
268 IGESData_DumpListHeader(S,lo,up);\
269 if (lo > up) {}\
270 else if (Level == 4 || Level == -4) S <<" [content : ask level > 4]";\
271 else if (Level > 0) {\
272 S << " :";\
273 for (Standard_Integer iopa = lo; iopa <= up; iopa ++)\
0ebe5b0a 274 { S << "\n["<<Interface_MSG::Blanks(iopa,3)<<iopa<<"]:\"" << item(iopa)->String() << '"'; }\
7fd59977 275 S << "\n";\
276 }\
277}
278
279#define IGESData_DumpEntities(S,dumper,Level,lower,upper,item) \
280{\
281 Standard_Integer lo = lower; Standard_Integer up = upper;\
282 IGESData_DumpListHeader(S,lo,up);\
283 if (lo > up) {}\
284 else if (Level == 4 || Level == -4) S <<" [content : ask level > 4]";\
285 else if (Level > 0) {\
286 S << " :";\
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); }\
290 }\
291 }\
292}
293
294
295#define IGESData_DumpRectVals(S,Level,LowCol,UpCol,LowRow,UpRow,Item) \
296{\
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) {\
302 S << "\n";\
303 for (int ir = lor; ir <= upr; ir ++) {\
304 S << "Row "<<ir<<":[";\
305 for (int ic = loco; ic <= upc; ic ++) S << " " << Item(ic,ir);\
306 S << " ]\n";\
307 }\
308 }\
309}