b311480e |
1 | // Created on: 1994-08-04 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <Standard_Stream.hxx> |
18 | #include <TopOpeBRepDS_Dumper.ixx> |
19 | #include <TopoDS_Edge.hxx> |
20 | |
21 | #include <TopOpeBRepDS_SurfaceCurveInterference.hxx> |
22 | #include <TopOpeBRepDS_CurveIterator.hxx> |
23 | #include <TopOpeBRepDS_Point.hxx> |
24 | #include <TopOpeBRepDS_Curve.hxx> |
25 | #include <TopOpeBRepDS_Surface.hxx> |
26 | #include <TopOpeBRepDS_PointExplorer.hxx> |
27 | #include <TopOpeBRepDS_CurveExplorer.hxx> |
28 | #include <TopOpeBRepDS_SurfaceExplorer.hxx> |
29 | #include <TopOpeBRepDS.hxx> |
30 | #include <TopAbs.hxx> |
31 | #include <TopoDS_Edge.hxx> |
32 | #include <TopoDS_Shape.hxx> |
33 | #include <TopOpeBRepTool_ShapeTool.hxx> |
34 | #include <gp_Pnt.hxx> |
35 | #include <Geom_Circle.hxx> |
36 | #include <Geom_Line.hxx> |
37 | #include <Geom_Ellipse.hxx> |
38 | #include <Geom_Parabola.hxx> |
39 | #include <Geom_Hyperbola.hxx> |
40 | #include <Geom_BezierCurve.hxx> |
41 | #include <Geom_BSplineCurve.hxx> |
42 | #include <Geom_TrimmedCurve.hxx> |
43 | #include <Geom_OffsetCurve.hxx> |
44 | #include <Geom2d_Circle.hxx> |
45 | #include <Geom2d_Line.hxx> |
46 | #include <Geom2d_Ellipse.hxx> |
47 | #include <Geom2d_Parabola.hxx> |
48 | #include <Geom2d_Hyperbola.hxx> |
49 | #include <Geom2d_BezierCurve.hxx> |
50 | #include <Geom2d_BSplineCurve.hxx> |
51 | #include <Geom2d_TrimmedCurve.hxx> |
52 | #include <Geom2d_OffsetCurve.hxx> |
53 | #include <GeomTools_CurveSet.hxx> |
54 | #include <GeomTools_Curve2dSet.hxx> |
55 | #include <string.h> |
56 | |
57 | #include <TopOpeBRepDS_define.hxx> |
ec357c5c |
58 | #include <TopOpeBRepDS_ShapeShapeInterference.hxx> |
7fd59977 |
59 | |
60 | //======================================================================= |
61 | //function : TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper |
62 | //purpose : |
63 | //======================================================================= |
64 | |
65 | TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper(const Handle(TopOpeBRepDS_HDataStructure)& HDS) |
66 | { |
67 | myHDS = HDS; |
68 | } |
69 | |
70 | //======================================================================= |
71 | //function : PrintType |
72 | //purpose : |
73 | //======================================================================= |
74 | |
75 | Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom_Curve)& |
0797d9d3 |
76 | #ifdef OCCT_DEBUG |
7fd59977 |
77 | C |
78 | #endif |
79 | ,Standard_OStream& OS) |
80 | { |
0797d9d3 |
81 | #ifdef OCCT_DEBUG |
7fd59977 |
82 | if (C.IsNull()) { |
83 | OS<<"NULL CURVE"; |
84 | return OS; |
85 | } |
86 | Handle(Standard_Type) T = C->DynamicType(); |
87 | if (T==STANDARD_TYPE(Geom_Circle)) OS<<"CIRCLE"; |
88 | else if (T==STANDARD_TYPE(Geom_Line)) OS<<"LINE"; |
89 | else if (T==STANDARD_TYPE(Geom_Ellipse)) OS<<"ELLIPSE"; |
90 | else if (T==STANDARD_TYPE(Geom_Parabola)) OS<<"ELLIPSE"; |
91 | else if (T==STANDARD_TYPE(Geom_Hyperbola)) OS<<"HYPERBOLA"; |
92 | else if (T==STANDARD_TYPE(Geom_BezierCurve)) OS<<"BEZIER"; |
93 | else if (T==STANDARD_TYPE(Geom_BSplineCurve)) |
94 | OS<<"BSPLINE("<<(*((Handle(Geom_BSplineCurve)*)&C))->Degree()<<")"; |
95 | else if (T==STANDARD_TYPE(Geom_TrimmedCurve)) |
96 | {OS<<"TRIMMED ";PrintType(Handle(Geom_TrimmedCurve)::DownCast(C)->BasisCurve(),OS);} |
97 | else if (T==STANDARD_TYPE(Geom_OffsetCurve)) OS<<"OFFSETCURVE"; |
98 | else OS<<"***UNKNOWN***"; |
99 | if (T!=STANDARD_TYPE(Geom_TrimmedCurve)) OS<<"3D"; |
100 | #endif |
101 | |
102 | return OS; |
103 | } |
104 | |
105 | //======================================================================= |
106 | //function : PrintType |
107 | //purpose : |
108 | //======================================================================= |
109 | |
110 | Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom2d_Curve)& |
0797d9d3 |
111 | #ifdef OCCT_DEBUG |
7fd59977 |
112 | C |
113 | #endif |
114 | ,Standard_OStream& OS) |
115 | { |
0797d9d3 |
116 | #ifdef OCCT_DEBUG |
7fd59977 |
117 | if (C.IsNull()) { |
118 | OS<<"NULL CURVE2d"; |
119 | return OS; |
120 | } |
121 | Handle(Standard_Type) T = C->DynamicType(); |
122 | if (T==STANDARD_TYPE(Geom2d_Circle)) OS<<"CIRCLE"; |
123 | else if (T==STANDARD_TYPE(Geom2d_Line)) OS<<"LINE"; |
124 | else if (T==STANDARD_TYPE(Geom2d_Ellipse)) OS<<"ELLIPSE"; |
125 | else if (T==STANDARD_TYPE(Geom2d_Parabola)) OS<<"ELLIPSE"; |
126 | else if (T==STANDARD_TYPE(Geom2d_Hyperbola)) OS<<"HYPERBOLA"; |
127 | else if (T==STANDARD_TYPE(Geom2d_BezierCurve)) OS<<"BEZIER"; |
128 | else if (T==STANDARD_TYPE(Geom2d_BSplineCurve)) |
129 | OS<<"BSPLINE("<<(*((Handle(Geom2d_BSplineCurve)*)&C))->Degree()<<")"; |
130 | else if (T==STANDARD_TYPE(Geom2d_TrimmedCurve)) |
131 | {OS<<"TRIMMED ";PrintType(Handle(Geom2d_TrimmedCurve)::DownCast(C)->BasisCurve(),OS);} |
132 | else if (T==STANDARD_TYPE(Geom2d_OffsetCurve)) OS<<"OFFSETCURVE"; |
133 | else OS<<"***UNKNOWN***"; |
134 | if (T!=STANDARD_TYPE(Geom2d_TrimmedCurve)) OS<<"2D"; |
135 | #endif |
136 | |
137 | return OS; |
138 | } |
139 | |
140 | //======================================================================= |
141 | //function : Print |
142 | //purpose : |
143 | //======================================================================= |
144 | |
145 | Standard_OStream& TopOpeBRepDS_Dumper::Print(const gp_Pnt& |
0797d9d3 |
146 | #ifdef OCCT_DEBUG |
7fd59977 |
147 | P |
148 | #endif |
149 | ,Standard_OStream& OS) |
150 | { |
0797d9d3 |
151 | #ifdef OCCT_DEBUG |
7fd59977 |
152 | OS<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" "; |
153 | #endif |
154 | |
155 | return OS; |
156 | } |
157 | |
158 | |
159 | //======================================================================= |
160 | //function : Print |
161 | //purpose : |
162 | //======================================================================= |
163 | |
164 | Standard_OStream& TopOpeBRepDS_Dumper::Print(const gp_Pnt2d& |
0797d9d3 |
165 | #ifdef OCCT_DEBUG |
7fd59977 |
166 | P |
167 | #endif |
168 | ,Standard_OStream& OS) |
169 | { |
0797d9d3 |
170 | #ifdef OCCT_DEBUG |
7fd59977 |
171 | OS<<P.X()<<" "<<P.Y()<<" "; |
172 | #endif |
173 | |
174 | return OS; |
175 | } |
176 | |
177 | |
178 | //======================================================================= |
179 | //function : Print |
180 | //purpose : |
181 | //======================================================================= |
182 | |
183 | Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom_BSplineCurve)& |
0797d9d3 |
184 | #ifdef OCCT_DEBUG |
7fd59977 |
185 | B |
186 | #endif |
187 | ,Standard_OStream& OS |
188 | ,const Standard_Boolean |
0797d9d3 |
189 | #ifdef OCCT_DEBUG |
7fd59977 |
190 | compact |
191 | #endif |
192 | ) |
193 | { |
0797d9d3 |
194 | #ifdef OCCT_DEBUG |
1d47d8d0 |
195 | Standard_Integer i,l,lb = 0,n; |
7fd59977 |
196 | |
197 | Standard_Integer degree = B->Degree(); |
198 | Standard_Integer nbpoles = B->NbPoles(); |
199 | Standard_Integer nbknots = B->NbKnots(); |
200 | Standard_Boolean rational = B->IsRational(); |
201 | Standard_Boolean periodic = B->IsPeriodic(); |
202 | |
203 | OS<<"BSplineCurve : "; |
204 | if (periodic) OS<<"periodic, "; |
205 | OS<<"degree "<<degree<<", "<<nbpoles<<" poles, "<<nbknots<<" knots"<<endl; |
206 | |
60be1f9b |
207 | //l = strlen("poles : ") + 1 |
208 | for (i = 1,OS<<"poles : ",l = 9,n = nbpoles; |
7fd59977 |
209 | i<=n; |
210 | i++) { |
211 | if (!compact) { if (i == 1) lb = 0; else lb = l; } |
212 | else if (i == 1) lb = 0; |
213 | else if (i == 2) lb = l; |
214 | else if (i == n-1) { |
215 | lb = l; |
216 | if(n > 4) OS << setw(lb) << "\t ...\n"; |
217 | } |
218 | else if (i == n) lb = l; |
219 | else continue; |
220 | |
221 | OS<<setw(lb)<<i<<" : "; |
222 | TopOpeBRepDS_Dumper::Print(B->Pole(i),OS); |
223 | if (rational) OS<<" "<<B->Weight(i); |
224 | |
225 | OS<<endl; |
226 | } |
227 | |
60be1f9b |
228 | //l = strlen("knots : ") + 1 |
229 | for (i = 1,OS<<"knots : ",l = 9,n = nbknots; |
7fd59977 |
230 | i<=n; |
231 | i++) { |
232 | if (!compact) { if (i == 1) lb = 0; else lb = l; } |
233 | else if (i == 1) lb = 0; |
234 | else if (i == 2) lb = l; |
235 | else if (i == n-1) { |
236 | if(n > 4) OS << setw(lb) << "\t ...\n"; |
237 | lb = l; |
238 | } |
239 | else if (i == n) lb = l; |
240 | else continue; |
241 | |
242 | OS<<setw(lb)<<i<<" : "; |
243 | OS<<B->Knot(i)<<" "<<B->Multiplicity(i); |
244 | |
245 | OS<<endl; |
246 | } |
247 | #endif |
248 | |
249 | return OS; |
250 | } |
251 | |
252 | |
253 | //======================================================================= |
254 | //function : Print |
255 | //purpose : |
256 | //======================================================================= |
257 | |
258 | Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom2d_BSplineCurve)& |
0797d9d3 |
259 | #ifdef OCCT_DEBUG |
7fd59977 |
260 | B |
261 | #endif |
262 | ,Standard_OStream& OS |
263 | ,const Standard_Boolean |
0797d9d3 |
264 | #ifdef OCCT_DEBUG |
7fd59977 |
265 | compact |
266 | #endif |
267 | ) |
268 | { |
0797d9d3 |
269 | #ifdef OCCT_DEBUG |
96a95605 |
270 | Standard_Integer i,l,lb=-1,n; |
7fd59977 |
271 | |
272 | Standard_Integer degree = B->Degree(); |
273 | Standard_Integer nbpoles = B->NbPoles(); |
274 | Standard_Integer nbknots = B->NbKnots(); |
275 | Standard_Boolean rational = B->IsRational(); |
276 | Standard_Boolean periodic = B->IsPeriodic(); |
277 | |
278 | OS<<"BSplineCurve : "; |
279 | if (periodic) OS<<"periodic, "; |
280 | OS<<"degree "<<degree<<", "<<nbpoles<<" poles, "<<nbknots<<" knots"<<endl; |
281 | |
60be1f9b |
282 | //l = strlen("poles : ") + 1 |
283 | for (i = 1,OS<<"poles : ",l = 9,n = nbpoles; |
7fd59977 |
284 | i<=n; |
285 | i++) { |
286 | if (!compact) { if (i == 1) lb = 0; else lb = l; } |
287 | else if (i == 1) lb = 0; |
288 | else if (i == 2) lb = l; |
289 | else if (i == n-1) { |
290 | lb = l; |
291 | if(n > 4) OS << setw(lb) << "\t ...\n"; |
292 | } |
293 | else if (i == n) lb = l; |
294 | else continue; |
295 | |
296 | OS<<setw(lb)<<i<<" : "; |
297 | TopOpeBRepDS_Dumper::Print(B->Pole(i),OS); |
298 | if (rational) OS<<" "<<B->Weight(i); |
299 | |
300 | OS<<endl; |
301 | } |
302 | |
60be1f9b |
303 | //l = strlen("knots : ") + 1 |
304 | for (i = 1,OS<<"knots : ",l = 9,n = nbknots; |
7fd59977 |
305 | i<=n; |
306 | i++) { |
307 | if (!compact) { if (i == 1) lb = 0; else lb = l; } |
308 | else if (i == 1) lb = 0; |
309 | else if (i == 2) lb = l; |
310 | else if (i == n-1) { |
311 | lb = l; |
312 | if(n > 4) OS << setw(lb) << "\t ...\n"; |
313 | } |
314 | else if (i == n) lb = l; |
315 | else continue; |
316 | |
317 | OS<<setw(lb)<<i<<" : "; |
318 | OS<<B->Knot(i)<<" "<<B->Multiplicity(i); |
319 | |
320 | OS<<endl; |
321 | } |
322 | #endif |
323 | |
324 | return OS; |
325 | } |
326 | |
327 | |
328 | //======================================================================= |
329 | //function : Print |
330 | //purpose : |
331 | //======================================================================= |
332 | |
333 | Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom_Curve)& |
0797d9d3 |
334 | #ifdef OCCT_DEBUG |
7fd59977 |
335 | C |
336 | #endif |
337 | ,Standard_OStream& OS |
338 | ,const Standard_Boolean |
0797d9d3 |
339 | #ifdef OCCT_DEBUG |
7fd59977 |
340 | compact |
341 | #endif |
342 | ) |
343 | { |
0797d9d3 |
344 | #ifdef OCCT_DEBUG |
7fd59977 |
345 | #define DBSP3D(tut) (*((Handle(Geom_BSplineCurve)*)&(tut))) |
346 | if (!C.IsNull()) { |
347 | if (C->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) |
348 | TopOpeBRepDS_Dumper::Print(DBSP3D(C),OS,compact); |
349 | else |
350 | GeomTools_CurveSet::PrintCurve(C,OS,Standard_False); |
351 | } |
352 | #endif |
353 | |
354 | return OS; |
355 | } |
356 | |
357 | |
358 | //======================================================================= |
359 | //function : Print |
360 | //purpose : |
361 | //======================================================================= |
362 | |
0797d9d3 |
363 | #ifdef OCCT_DEBUG |
7fd59977 |
364 | Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom2d_Curve)& C, |
365 | Standard_OStream& OS,const Standard_Boolean compact) |
366 | { |
367 | #define DBSP2D(tut) (*((Handle(Geom2d_BSplineCurve)*)&(tut))) |
368 | if (!C.IsNull()) { |
369 | if (C->DynamicType() == STANDARD_TYPE(Geom2d_BSplineCurve)) |
370 | TopOpeBRepDS_Dumper::Print(DBSP2D(C),OS,compact); |
371 | else |
372 | GeomTools_Curve2dSet::PrintCurve2d(C,OS,Standard_False); |
373 | } |
374 | |
375 | return OS; |
376 | } |
377 | #endif |
378 | |
379 | // DUMP OF HDATASTRUCTURE |
380 | |
381 | //----------------------------------------------------------------------- |
0797d9d3 |
382 | #ifdef OCCT_DEBUG |
7fd59977 |
383 | //unreferenced function, commented |
384 | /*static void souligne(const TCollection_AsciiString& t,Standard_OStream& OS,const char c = '-') |
385 | { for(char i=0;i<t.Length();i++)OS<<c; }*/ |
386 | //----------------------------------------------------------------------- |
387 | // print the name of a Kind on a AsciiString. |
388 | static TCollection_AsciiString& Print(const TopOpeBRepDS_Kind k,TCollection_AsciiString& s) |
389 | { |
390 | switch(k) { |
391 | case TopOpeBRepDS_SURFACE : s.AssignCat("SURFACE");break; |
392 | case TopOpeBRepDS_CURVE : s.AssignCat("CURVE");break; |
393 | case TopOpeBRepDS_POINT : s.AssignCat("POINT");break; |
394 | case TopOpeBRepDS_SOLID : s.AssignCat("SOLID");break; |
395 | case TopOpeBRepDS_SHELL : s.AssignCat("SHELL");break; |
396 | case TopOpeBRepDS_FACE : s.AssignCat("FACE");break; |
397 | case TopOpeBRepDS_WIRE : s.AssignCat("WIRE");break; |
398 | case TopOpeBRepDS_EDGE : s.AssignCat("EDGE");break; |
399 | case TopOpeBRepDS_VERTEX : s.AssignCat("VERTEX");break; |
400 | default: |
401 | break ; |
402 | } |
403 | return s; |
404 | } |
405 | #endif |
406 | |
407 | |
408 | //======================================================================= |
409 | //function : Dump |
410 | //purpose : |
411 | //======================================================================= |
412 | |
413 | Standard_OStream& TopOpeBRepDS_Dumper::Dump(Standard_OStream& OS |
414 | ,const Standard_Boolean |
0797d9d3 |
415 | #ifdef OCCT_DEBUG |
7fd59977 |
416 | findkeep |
417 | #endif |
418 | ,const Standard_Boolean |
0797d9d3 |
419 | #ifdef OCCT_DEBUG |
7fd59977 |
420 | compact |
421 | #endif |
422 | ) const |
423 | { |
0797d9d3 |
424 | #ifdef OCCT_DEBUG |
7fd59977 |
425 | OS<<endl<<"==== HDS start filling resume"<<endl; |
426 | DumpGeometry(OS,findkeep,compact); |
427 | DumpTopology(OS); |
428 | OS<<endl<<"==== HDS end filling resume"<<endl; |
429 | #endif |
430 | return OS; |
431 | } |
432 | |
433 | |
434 | //======================================================================= |
435 | //function : DumpGeometry |
436 | //purpose : |
437 | //======================================================================= |
438 | Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry(Standard_OStream& OS |
439 | ,const Standard_Boolean |
0797d9d3 |
440 | #ifdef OCCT_DEBUG |
7fd59977 |
441 | findkeep |
442 | #endif |
443 | ,const Standard_Boolean |
0797d9d3 |
444 | #ifdef OCCT_DEBUG |
7fd59977 |
445 | compact |
446 | #endif |
447 | ) const |
448 | { |
0797d9d3 |
449 | #ifdef OCCT_DEBUG |
7fd59977 |
450 | DumpGeometry(TopOpeBRepDS_POINT,OS,findkeep,compact); |
451 | DumpGeometry(TopOpeBRepDS_CURVE,OS,findkeep,compact); |
452 | DumpGeometry(TopOpeBRepDS_SURFACE,OS,findkeep,compact); |
453 | #endif |
454 | return OS; |
455 | } |
456 | |
457 | |
458 | //======================================================================= |
459 | //function : DumpGeometry |
460 | //purpose : |
461 | //======================================================================= |
462 | |
463 | Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry |
464 | (const TopOpeBRepDS_Kind |
0797d9d3 |
465 | #ifdef OCCT_DEBUG |
7fd59977 |
466 | K |
467 | #endif |
468 | ,Standard_OStream& OS |
469 | ,const Standard_Boolean |
0797d9d3 |
470 | #ifdef OCCT_DEBUG |
7fd59977 |
471 | findkeep |
472 | #endif |
473 | ,const Standard_Boolean |
0797d9d3 |
474 | #ifdef OCCT_DEBUG |
7fd59977 |
475 | compact |
476 | #endif |
477 | ) const |
478 | { |
0797d9d3 |
479 | #ifdef OCCT_DEBUG |
7fd59977 |
480 | if ( ! TopOpeBRepDS::IsGeometry(K) ) return OS; |
481 | Standard_Integer nt = myHDS->NbGeometry(K); |
482 | if (!nt) return OS; |
483 | |
484 | Standard_Integer n=0; |
485 | if (K==TopOpeBRepDS_POINT){TopOpeBRepDS_PointExplorer ex(myHDS->DS(),findkeep);n=ex.NbPoint();} |
486 | else if(K==TopOpeBRepDS_CURVE){TopOpeBRepDS_CurveExplorer ex(myHDS->DS());n=ex.NbCurve();} |
487 | else if(K==TopOpeBRepDS_SURFACE){TopOpeBRepDS_SurfaceExplorer ex(myHDS->DS());n=ex.NbSurface();} |
488 | if (!n) return OS; |
489 | TCollection_AsciiString s = "---- "; ::Print(K,s); |
490 | OS<<endl<<s<<" : "<<n<<endl; |
491 | for(Standard_Integer i=1;i<=nt;i++) DumpGeometry(K,i,OS,findkeep,compact); |
492 | #endif |
493 | return OS; |
494 | } |
495 | |
496 | //======================================================================= |
497 | //function : DumpGeometry |
498 | //purpose : |
499 | //======================================================================= |
500 | |
501 | Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry(const TopOpeBRepDS_Kind |
0797d9d3 |
502 | #ifdef OCCT_DEBUG |
7fd59977 |
503 | K |
504 | #endif |
505 | ,const Standard_Integer |
0797d9d3 |
506 | #ifdef OCCT_DEBUG |
7fd59977 |
507 | I |
508 | #endif |
509 | ,Standard_OStream& OS, |
510 | const Standard_Boolean |
0797d9d3 |
511 | #ifdef OCCT_DEBUG |
7fd59977 |
512 | findkeep |
513 | #endif |
514 | ,const Standard_Boolean |
0797d9d3 |
515 | #ifdef OCCT_DEBUG |
7fd59977 |
516 | compact |
517 | #endif |
518 | ) const |
519 | { |
0797d9d3 |
520 | #ifdef OCCT_DEBUG |
7fd59977 |
521 | if ( ! TopOpeBRepDS::IsGeometry(K) ) return OS; |
522 | |
523 | if ( K == TopOpeBRepDS_POINT ) { |
524 | TopOpeBRepDS_PointExplorer pex(myHDS->DS()); |
525 | Standard_Boolean isp = pex.IsPoint(I); |
526 | Standard_Boolean isk = pex.IsPointKeep(I); |
527 | if(!findkeep || isk) { |
528 | TCollection_AsciiString kstr;::Print(K,kstr);kstr=kstr+" "+I+" :"; |
529 | Standard_Integer lk = kstr.Length(); |
530 | OS<<kstr; |
531 | if (isp) { |
532 | const TopOpeBRepDS_Point& PDS = pex.Point(I); |
533 | OS<<" (K:"<<((isk)?"1":"0") <<")"<<endl; |
534 | OS<<"tol = "<<PDS.Tolerance()<<endl; |
535 | TCollection_AsciiString istr(lk,' '); |
536 | const gp_Pnt& P = PDS.Point(); |
537 | OS<<istr; OS<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl; |
538 | } |
539 | else OS<<"unbounded"<<endl; |
540 | } |
541 | } |
542 | else if ( K == TopOpeBRepDS_CURVE ) { |
543 | TopOpeBRepDS_CurveExplorer cex(myHDS->DS()); |
544 | Standard_Boolean isc = cex.IsCurve(I); |
545 | Standard_Boolean isk = cex.IsCurveKeep(I); |
546 | if(!findkeep || isk) { |
547 | TCollection_AsciiString kstr;::Print(K,kstr);kstr=kstr+" "+I+" :"; |
548 | Standard_Integer lk = kstr.Length(); |
549 | OS<<kstr; |
550 | if (isc) { |
551 | const TopOpeBRepDS_Curve& CDS = cex.Curve(I); |
552 | OS<<" (K:"<<((isk)?"1":"0")<<")"; |
553 | OS<<" (M:"<<CDS.Mother()<<")"<<endl; |
554 | TCollection_AsciiString istr(lk+1,' '); |
555 | OS<<istr;PrintType(CDS.Curve(),OS); |
556 | OS<<" tol = "<<CDS.Tolerance()<<endl; |
557 | Standard_Real first,last; |
558 | if(CDS.Range(first,last)) |
559 | OS<<istr<<"first = "<<first<<" last = "<<last<<endl; |
560 | TopOpeBRepDS_InterferenceIterator it(myHDS->DS().CurveInterferences(I)); |
561 | for (;it.More();it.Next()) it.Value()->Dump(OS,istr,"\n"); |
562 | { |
563 | const Handle(TopOpeBRepDS_Interference)& SCI1 = CDS.GetSCI1(); |
564 | const Handle(TopOpeBRepDS_Interference)& SCI2 = CDS.GetSCI2(); |
565 | Handle(Geom2d_Curve) PC1,PC2; |
566 | if ( !SCI1.IsNull()) |
567 | PC1 = Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(SCI1)->PCurve(); |
568 | if ( !SCI2.IsNull()) |
569 | PC2 = Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(SCI2)->PCurve(); |
570 | |
571 | OS<<istr;OS<<"PC(SCI1) : ";Print(PC1,cout,compact); |
572 | OS<<istr;OS<<"PC(SCI2) : ";Print(PC2,cout,compact); |
573 | OS<<endl; |
574 | } |
575 | } |
576 | else OS<<"unbounded"<<endl; |
577 | } |
578 | } |
579 | |
580 | else if ( K == TopOpeBRepDS_SURFACE ) { |
581 | TopOpeBRepDS_SurfaceExplorer sex(myHDS->DS()); |
582 | Standard_Boolean iss = sex.IsSurface(I); |
583 | Standard_Boolean isk = sex.IsSurfaceKeep(I); |
584 | if(!findkeep || isk) { |
585 | TCollection_AsciiString kstr; ::Print(K,kstr); kstr=kstr+" "+I+" : "; |
586 | Standard_Integer lk = kstr.Length(); |
587 | OS<<kstr; |
588 | if (iss) { |
589 | const TopOpeBRepDS_Surface& SDS = sex.Surface(I); |
590 | OS<<" (K:"<<((isk)?"1":"0") <<")"<<endl; |
591 | OS<<"tol = "<<SDS.Tolerance()<<endl; |
592 | { |
593 | TCollection_AsciiString istr(lk,' '); |
594 | TopOpeBRepDS_InterferenceIterator it(myHDS->SurfaceCurves(I)); |
595 | for (;it.More();it.Next()) { |
596 | OS<<istr; it.Value()->Dump(OS);OS<<endl; |
597 | } |
598 | } |
599 | } |
600 | else OS<<"unbounded"<<endl; |
601 | } |
602 | } |
603 | else { |
604 | return OS; |
605 | } |
606 | |
607 | #endif |
608 | return OS; |
609 | } |
610 | |
611 | // = = = = = = = T O P O L O G Y |
612 | |
613 | //======================================================================= |
614 | //function : DumpTopology |
615 | //purpose : |
616 | //======================================================================= |
617 | Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(Standard_OStream& OS) const |
618 | { |
0797d9d3 |
619 | #ifdef OCCT_DEBUG |
7fd59977 |
620 | DumpTopology(TopOpeBRepDS_VERTEX,OS); |
621 | DumpTopology(TopOpeBRepDS_EDGE,OS); |
622 | DumpTopology(TopOpeBRepDS_WIRE,OS); |
623 | DumpTopology(TopOpeBRepDS_FACE,OS); |
624 | DumpTopology(TopOpeBRepDS_SHELL,OS); |
625 | DumpTopology(TopOpeBRepDS_SOLID,OS); |
626 | DumpSectionEdge(TopOpeBRepDS_EDGE,OS); |
627 | #endif |
628 | return OS; |
629 | } |
630 | |
631 | //======================================================================= |
632 | //function : DumpTopology |
633 | //purpose : |
634 | //======================================================================= |
635 | Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopOpeBRepDS_Kind |
0797d9d3 |
636 | #ifdef OCCT_DEBUG |
7fd59977 |
637 | K |
638 | #endif |
639 | ,Standard_OStream& OS) const |
640 | { |
0797d9d3 |
641 | #ifdef OCCT_DEBUG |
7fd59977 |
642 | if ( ! TopOpeBRepDS::IsTopology(K) ) return OS; |
643 | Standard_Integer nk = myHDS->NbTopology(K); |
644 | if ( ! nk ) return OS; |
645 | |
646 | OS<<endl; |
647 | TCollection_AsciiString s = "---- "; ::Print(K,s); |
648 | Standard_Integer nt = myHDS->NbTopology(); |
649 | OS<<s<<" : "<<nk<<"/"<<nt<<" shapes"<<endl; |
650 | for(Standard_Integer i = 1; i <= nt; i++) DumpTopology(K,i,OS); |
651 | #endif |
652 | return OS; |
653 | } |
654 | |
655 | //======================================================================= |
656 | //function : DumpTopology |
657 | //purpose : |
658 | //======================================================================= |
659 | Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopAbs_ShapeEnum |
0797d9d3 |
660 | #ifdef OCCT_DEBUG |
7fd59977 |
661 | T |
662 | #endif |
663 | ,Standard_OStream& OS) const |
664 | { |
0797d9d3 |
665 | #ifdef OCCT_DEBUG |
7fd59977 |
666 | DumpTopology(TopOpeBRepDS::ShapeToKind(T),OS); |
667 | #endif |
668 | return OS; |
669 | } |
670 | |
671 | //======================================================================= |
672 | //function : DumpSectionEdge |
673 | //purpose : |
674 | //======================================================================= |
675 | |
676 | Standard_OStream& TopOpeBRepDS_Dumper::DumpSectionEdge(const TopOpeBRepDS_Kind |
0797d9d3 |
677 | #ifdef OCCT_DEBUG |
7fd59977 |
678 | K |
679 | #endif |
680 | ,Standard_OStream& OS) const |
681 | { |
0797d9d3 |
682 | #ifdef OCCT_DEBUG |
7fd59977 |
683 | Standard_Integer nse = myHDS->DS().NbSectionEdges(); |
684 | if ( ! nse ) return OS; |
685 | |
686 | OS<<endl; |
687 | TCollection_AsciiString s = "---- "; |
688 | OS<<s<<"Section Edges"<<" : "<<nse<<" edges"<<endl; |
689 | for(Standard_Integer i = 1; i <= nse; i++) { |
690 | DumpSectionEdge(K,i,OS); |
691 | } |
692 | #endif |
693 | return OS; |
694 | } |
695 | |
696 | //======================================================================= |
697 | //function : DumpSectionEdge |
698 | //purpose : |
699 | //======================================================================= |
700 | Standard_OStream& TopOpeBRepDS_Dumper::DumpSectionEdge(const TopOpeBRepDS_Kind K,const Standard_Integer I,Standard_OStream& OS) const |
701 | { |
702 | Standard_Boolean SEFindKeep = Standard_False; |
703 | const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); |
704 | const TopoDS_Shape& E = DS.SectionEdge(I,SEFindKeep); |
705 | if(E.IsNull()) return OS; |
706 | Standard_Integer it = myHDS->DS().Shape(E,SEFindKeep); |
707 | if (it == 0) { |
708 | // E trouvee "Restriction" par les intersections n'est pas dans la DS. |
709 | OS<<endl<<"EDGE section "<<I<<" non Shape()"<<endl; |
710 | } |
711 | else DumpTopology(K,it,OS); |
712 | return OS; |
713 | } |
714 | |
715 | Standard_EXPORT Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector = 0; // NYI arg of Dump method |
716 | |
717 | //======================================================================= |
718 | //function : DumpTopology |
719 | //purpose : |
720 | //======================================================================= |
721 | Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopOpeBRepDS_Kind |
0797d9d3 |
722 | #ifdef OCCT_DEBUG |
7fd59977 |
723 | K |
724 | #endif |
725 | ,const Standard_Integer |
0797d9d3 |
726 | #ifdef OCCT_DEBUG |
7fd59977 |
727 | I |
728 | #endif |
729 | ,Standard_OStream& OS) const |
730 | { |
0797d9d3 |
731 | #ifdef OCCT_DEBUG |
7fd59977 |
732 | Standard_Boolean fk = Standard_False; |
733 | const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); |
734 | if ( ! TopOpeBRepDS::IsTopology(K) ) return OS; |
735 | if ( I <= 0 ) return OS; |
736 | TopAbs_ShapeEnum t = TopOpeBRepDS::KindToShape(K); |
737 | |
738 | if ( DS.Shape(I,fk).ShapeType() != t ) return OS; |
739 | Standard_Integer rankI = DS.AncestorRank(I); |
740 | TCollection_AsciiString s1,s2; |
741 | if(DS.KeepShape(I)) { |
742 | s1 = ((rankI == 1) ? (char*) "*" : (char*) ""); |
743 | s2 = ((rankI == 2) ? (char*) "*" : (char*) ""); |
744 | } |
745 | else { |
746 | s1 = ((rankI == 1) ? (char*) "~" : (char*) ""); |
747 | s2 = ((rankI == 2) ? (char*) "~" : (char*) ""); |
748 | } |
749 | TCollection_AsciiString ss = TopOpeBRepDS::SPrint(K,I,s1,s2); |
750 | |
751 | if ( t == TopAbs_VERTEX ) { |
752 | Standard_Integer lk = ss.Length() + 3; |
753 | TCollection_AsciiString istr(lk,' '); |
754 | gp_Pnt P = TopOpeBRepTool_ShapeTool::Pnt(DS.Shape(I,fk)); |
755 | Standard_Real tol = TopOpeBRepTool_ShapeTool::Tolerance(DS.Shape(I,fk)); |
756 | OS<<"\n"<<ss<<" : "; |
757 | OS<<"tol = "<<tol<<endl; |
758 | OS<<istr; OS<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl; |
759 | } |
760 | |
761 | Standard_Integer lss = ss.Length();TCollection_AsciiString bss(lss,' '); |
762 | OS<<ss;OS.flush(); |
763 | |
764 | // Interferences |
765 | TopOpeBRepDS_InterferenceIterator it; it.Init(DS.ShapeInterferences(I)); |
766 | if (it.More()) { |
767 | OS<<" interferences :\n"; |
768 | for (;it.More();it.Next()) { |
769 | const Handle(TopOpeBRepDS_Interference)& IR = it.Value(); Standard_Boolean s = Standard_True; |
770 | if (TopOpeBRepDS_GLOBALHDSinterfselector == 1) |
771 | s = !(Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(IR)).IsNull(); |
772 | if (s) IR->Dump(OS,"","\n"); |
773 | } |
774 | } |
775 | else OS<<" has no interference\n"; |
776 | |
777 | // SameDomain |
778 | const TopoDS_Shape& S = myHDS->Shape(I,fk); |
779 | if ( myHDS->HasSameDomain(S) ) { |
780 | const TopTools_ListOfShape& L = myHDS->DS().ShapeSameDomain(S); |
781 | if ( L.Extent() ) { |
782 | OS<<ss<<" same domain (r,o) : "<<SDumpRefOri(S)<<endl; |
783 | OS<<SPrintShapeRefOri(L,bss+" same domain shapes : "); |
784 | } |
785 | } |
786 | |
787 | OS.flush(); |
788 | #endif |
789 | return OS; |
790 | } |
791 | |
792 | //======================================================================= |
793 | //function : DumpTopology |
794 | //purpose : |
795 | //======================================================================= |
796 | Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopAbs_ShapeEnum |
0797d9d3 |
797 | #ifdef OCCT_DEBUG |
7fd59977 |
798 | T |
799 | #endif |
800 | ,const Standard_Integer |
0797d9d3 |
801 | #ifdef OCCT_DEBUG |
7fd59977 |
802 | I |
803 | #endif |
804 | ,Standard_OStream& OS) const |
805 | { |
0797d9d3 |
806 | #ifdef OCCT_DEBUG |
7fd59977 |
807 | DumpTopology(TopOpeBRepDS::ShapeToKind(T),I,OS); |
808 | #endif |
809 | return OS; |
810 | } |
811 | |
812 | //======================================================================= |
813 | //function : SDumpRefOri |
814 | //purpose : |
815 | //======================================================================= |
816 | |
817 | TCollection_AsciiString TopOpeBRepDS_Dumper::SDumpRefOri(const TopOpeBRepDS_Kind K,const Standard_Integer I) const |
818 | { |
819 | TCollection_AsciiString SS; |
820 | Standard_Boolean fk = Standard_False; |
821 | const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); |
822 | if ( ! TopOpeBRepDS::IsTopology(K) ) return SS; |
823 | TopAbs_ShapeEnum t = TopOpeBRepDS::KindToShape(K); |
824 | if ( DS.Shape(I,fk).ShapeType() != t ) return SS; |
825 | const TopoDS_Shape& S = myHDS->Shape(I,fk); |
826 | Standard_Integer r = myHDS->SameDomainReference(S); |
827 | TopOpeBRepDS_Config o = myHDS->SameDomainOrientation(S); |
828 | SS=SS+"("+SPrintShape(r)+","+TopOpeBRepDS::SPrint(o)+")"; |
829 | return SS; |
830 | } |
831 | |
832 | //======================================================================= |
833 | //function : SDumpRefOri |
834 | //purpose : |
835 | //======================================================================= |
836 | |
837 | TCollection_AsciiString TopOpeBRepDS_Dumper::SDumpRefOri(const TopoDS_Shape& S) const |
838 | { |
839 | TCollection_AsciiString SS; |
840 | TopOpeBRepDS_Kind k = TopOpeBRepDS::ShapeToKind(S.ShapeType()); |
841 | Standard_Boolean fk = Standard_False; |
842 | Standard_Integer i = myHDS->Shape(S,fk); |
843 | SS = SDumpRefOri(k,i); |
844 | return SS; |
845 | } |
846 | |
847 | //======================================================================= |
848 | //function : DumpRefOri |
849 | //purpose : |
850 | //======================================================================= |
851 | |
852 | Standard_OStream& TopOpeBRepDS_Dumper::DumpRefOri(const TopOpeBRepDS_Kind |
0797d9d3 |
853 | #ifdef OCCT_DEBUG |
7fd59977 |
854 | K |
855 | #endif |
856 | ,const Standard_Integer |
0797d9d3 |
857 | #ifdef OCCT_DEBUG |
7fd59977 |
858 | I |
859 | #endif |
860 | ,Standard_OStream& OS) const |
861 | { |
0797d9d3 |
862 | #ifdef OCCT_DEBUG |
7fd59977 |
863 | OS<<SDumpRefOri(K,I);OS.flush(); |
864 | #endif |
865 | return OS; |
866 | } |
867 | |
868 | //======================================================================= |
869 | //function : DumpRefOri |
870 | //purpose : |
871 | //======================================================================= |
872 | |
873 | Standard_OStream& TopOpeBRepDS_Dumper::DumpRefOri(const TopoDS_Shape& |
0797d9d3 |
874 | #ifdef OCCT_DEBUG |
7fd59977 |
875 | S |
876 | #endif |
877 | ,Standard_OStream& OS) const |
878 | { |
0797d9d3 |
879 | #ifdef OCCT_DEBUG |
7fd59977 |
880 | OS<<SDumpRefOri(S);OS.flush(); |
881 | #endif |
882 | return OS; |
883 | } |
884 | |
885 | //======================================================================= |
886 | //function : DumpLOI |
887 | //purpose : |
888 | //======================================================================= |
889 | |
890 | Standard_OStream& TopOpeBRepDS_Dumper::DumpLOI( |
891 | const TopOpeBRepDS_ListOfInterference& |
0797d9d3 |
892 | #ifdef OCCT_DEBUG |
7fd59977 |
893 | L |
894 | #endif |
895 | ,Standard_OStream& OS, |
896 | const TCollection_AsciiString& |
0797d9d3 |
897 | #ifdef OCCT_DEBUG |
7fd59977 |
898 | str |
899 | #endif |
900 | ) const |
901 | { |
0797d9d3 |
902 | #ifdef OCCT_DEBUG |
7fd59977 |
903 | OS<<str; |
904 | TopOpeBRepDS_InterferenceIterator IT(L); if (!IT.More()) { OS<<"NO INTERFERENCE"<<endl; return OS; } |
905 | OS<<endl; |
906 | for (Standard_Integer ip = 1; IT.More(); IT.Next(),ip++ ) { |
907 | const Handle(TopOpeBRepDS_Interference)& I = IT.Value(); |
908 | TCollection_AsciiString s(ip); s = s + "/ "; |
909 | DumpI(I,OS,s,"\n"); |
910 | } |
911 | OS<<endl; |
912 | #endif |
913 | return OS; |
914 | } |
915 | |
916 | //======================================================================= |
917 | //function : DumpI |
918 | //purpose : |
919 | //======================================================================= |
920 | Standard_OStream& TopOpeBRepDS_Dumper::DumpI( |
921 | const Handle(TopOpeBRepDS_Interference)& |
0797d9d3 |
922 | #ifdef OCCT_DEBUG |
7fd59977 |
923 | I |
924 | #endif |
925 | ,Standard_OStream& OS |
926 | ,const TCollection_AsciiString& |
0797d9d3 |
927 | #ifdef OCCT_DEBUG |
7fd59977 |
928 | str1 |
929 | #endif |
930 | ,const TCollection_AsciiString& |
0797d9d3 |
931 | #ifdef OCCT_DEBUG |
7fd59977 |
932 | str2 |
933 | #endif |
934 | ) const |
935 | { |
0797d9d3 |
936 | #ifdef OCCT_DEBUG |
7fd59977 |
937 | Standard_Boolean fk = Standard_False; |
938 | OS<<str1; |
939 | if (I.IsNull()) { OS<<"NULL INTERFERENCE"<<str2; return OS; } |
940 | Standard_Integer G = I->Geometry(); TopOpeBRepDS_Kind GK = I->GeometryType(); |
941 | I->Dump(OS); |
942 | if (GK == TopOpeBRepDS_POINT) { |
943 | gp_Pnt P = myHDS->Point(G).Point(); |
944 | OS<<" P = "<<P.X()<<" "<<P.Y()<<" "<<P.Z(); |
945 | } |
946 | else if (GK == TopOpeBRepDS_VERTEX) { |
947 | gp_Pnt P = TopOpeBRepTool_ShapeTool::Pnt(myHDS->Shape(G,fk)); |
948 | OS<<" V = "<<P.X()<<" "<<P.Y()<<" "<<P.Z(); |
949 | } |
950 | OS<<str2; |
951 | OS.flush(); |
952 | #endif |
953 | return OS; |
954 | } |
955 | |
956 | //======================================================================= |
957 | //function : SPrintShape |
958 | //purpose : |
959 | //======================================================================= |
960 | |
961 | TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const Standard_Integer IS) const |
962 | { |
963 | TCollection_AsciiString SS; |
964 | const TopOpeBRepDS_DataStructure& BDS = myHDS->DS(); if ( IS<1 || IS>BDS.NbShapes()) return SS; |
965 | SS = SPrintShape(BDS.Shape(IS)); |
966 | return SS; |
967 | } |
968 | |
969 | //======================================================================= |
970 | //function : SPrintShape |
971 | //purpose : |
972 | //======================================================================= |
973 | |
974 | TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const TopoDS_Shape& S) const |
975 | { |
976 | const TopOpeBRepDS_DataStructure& BDS = myHDS->DS(); |
977 | const Standard_Integer IS = myHDS->DS().Shape(S); |
978 | Standard_Integer rankIS = BDS.AncestorRank(IS); |
979 | //JR/Hp TCollection_AsciiString s1,s2; |
980 | Standard_CString s1,s2; |
981 | if(BDS.KeepShape(IS)) { |
982 | s1 = (Standard_CString ) ((rankIS == 1) ? "*" : ""); |
983 | s2 = (Standard_CString ) ((rankIS == 2) ? "*" : ""); |
984 | } |
985 | else { |
986 | s1 = (Standard_CString ) ((rankIS == 1) ? "~" : ""); |
987 | s2 = (Standard_CString ) ((rankIS == 2) ? "~" : ""); |
988 | } |
989 | TCollection_AsciiString sse = TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(S.ShapeType()),IS,s1,s2); |
990 | return sse; |
991 | } |
992 | |
993 | //======================================================================= |
994 | //function : SPrintShapeRefOri |
995 | //purpose : |
996 | //======================================================================= |
997 | |
998 | TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShapeRefOri(const TopoDS_Shape& S,const TCollection_AsciiString& astr) const |
999 | { TCollection_AsciiString SS=astr+SPrintShape(S)+" "+SDumpRefOri(S); return SS; } |
1000 | |
1001 | //======================================================================= |
1002 | //function : SPrintShapeRefOri |
1003 | //purpose : |
1004 | //======================================================================= |
1005 | |
1006 | TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShapeRefOri(const TopTools_ListOfShape& L,const TCollection_AsciiString& astr) const |
1007 | { |
1008 | TCollection_AsciiString SS;TopTools_ListIteratorOfListOfShape it(L); if (!it.More()) return SS; |
1009 | SS=SS+astr; TCollection_AsciiString bst(astr.Length(),' '); |
1010 | for(Standard_Integer il = 0; it.More(); it.Next(),il++) { |
1011 | TCollection_AsciiString ss=SPrintShapeRefOri(it.Value());if (il) ss=bst+ss; SS=SS+ss+"\n"; |
1012 | } |
1013 | return SS; |
1014 | } |