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