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
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.
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.
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.
22 #include <Standard_Stream.hxx>
23 #include <TopOpeBRepDS_Dumper.ixx>
24 #include <TopoDS_Edge.hxx>
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>
36 #include <TopoDS_Edge.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <TopOpeBRepTool_ShapeTool.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>
62 #include <TopOpeBRepDS_define.hxx>
64 //=======================================================================
65 //function : TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper
67 //=======================================================================
69 TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
74 //=======================================================================
75 //function : PrintType
77 //=======================================================================
79 Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom_Curve)&
83 ,Standard_OStream& OS)
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";
109 //=======================================================================
110 //function : PrintType
112 //=======================================================================
114 Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom2d_Curve)&
118 ,Standard_OStream& OS)
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";
144 //=======================================================================
147 //=======================================================================
149 Standard_OStream& TopOpeBRepDS_Dumper::Print(const gp_Pnt&
153 ,Standard_OStream& OS)
156 OS<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" ";
163 //=======================================================================
166 //=======================================================================
168 Standard_OStream& TopOpeBRepDS_Dumper::Print(const gp_Pnt2d&
172 ,Standard_OStream& OS)
175 OS<<P.X()<<" "<<P.Y()<<" ";
182 //=======================================================================
185 //=======================================================================
187 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom_BSplineCurve)&
191 ,Standard_OStream& OS
192 ,const Standard_Boolean
199 Standard_Integer i,l,lb,n;
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();
207 OS<<"BSplineCurve : ";
208 if (periodic) OS<<"periodic, ";
209 OS<<"degree "<<degree<<", "<<nbpoles<<" poles, "<<nbknots<<" knots"<<endl;
211 //l = strlen("poles : ") + 1
212 for (i = 1,OS<<"poles : ",l = 9,n = nbpoles;
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;
220 if(n > 4) OS << setw(lb) << "\t ...\n";
222 else if (i == n) lb = l;
225 OS<<setw(lb)<<i<<" : ";
226 TopOpeBRepDS_Dumper::Print(B->Pole(i),OS);
227 if (rational) OS<<" "<<B->Weight(i);
232 //l = strlen("knots : ") + 1
233 for (i = 1,OS<<"knots : ",l = 9,n = nbknots;
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;
240 if(n > 4) OS << setw(lb) << "\t ...\n";
243 else if (i == n) lb = l;
246 OS<<setw(lb)<<i<<" : ";
247 OS<<B->Knot(i)<<" "<<B->Multiplicity(i);
257 //=======================================================================
260 //=======================================================================
262 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom2d_BSplineCurve)&
266 ,Standard_OStream& OS
267 ,const Standard_Boolean
274 Standard_Integer i,l,lb,n;
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();
282 OS<<"BSplineCurve : ";
283 if (periodic) OS<<"periodic, ";
284 OS<<"degree "<<degree<<", "<<nbpoles<<" poles, "<<nbknots<<" knots"<<endl;
286 //l = strlen("poles : ") + 1
287 for (i = 1,OS<<"poles : ",l = 9,n = nbpoles;
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;
295 if(n > 4) OS << setw(lb) << "\t ...\n";
297 else if (i == n) lb = l;
300 OS<<setw(lb)<<i<<" : ";
301 TopOpeBRepDS_Dumper::Print(B->Pole(i),OS);
302 if (rational) OS<<" "<<B->Weight(i);
307 //l = strlen("knots : ") + 1
308 for (i = 1,OS<<"knots : ",l = 9,n = nbknots;
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;
316 if(n > 4) OS << setw(lb) << "\t ...\n";
318 else if (i == n) lb = l;
321 OS<<setw(lb)<<i<<" : ";
322 OS<<B->Knot(i)<<" "<<B->Multiplicity(i);
332 //=======================================================================
335 //=======================================================================
337 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom_Curve)&
341 ,Standard_OStream& OS
342 ,const Standard_Boolean
349 #define DBSP3D(tut) (*((Handle(Geom_BSplineCurve)*)&(tut)))
351 if (C->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve))
352 TopOpeBRepDS_Dumper::Print(DBSP3D(C),OS,compact);
354 GeomTools_CurveSet::PrintCurve(C,OS,Standard_False);
362 //=======================================================================
365 //=======================================================================
368 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom2d_Curve)& C,
369 Standard_OStream& OS,const Standard_Boolean compact)
371 #define DBSP2D(tut) (*((Handle(Geom2d_BSplineCurve)*)&(tut)))
373 if (C->DynamicType() == STANDARD_TYPE(Geom2d_BSplineCurve))
374 TopOpeBRepDS_Dumper::Print(DBSP2D(C),OS,compact);
376 GeomTools_Curve2dSet::PrintCurve2d(C,OS,Standard_False);
383 // DUMP OF HDATASTRUCTURE
385 //-----------------------------------------------------------------------
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)
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;
412 //=======================================================================
415 //=======================================================================
417 Standard_OStream& TopOpeBRepDS_Dumper::Dump(Standard_OStream& OS
418 ,const Standard_Boolean
422 ,const Standard_Boolean
429 OS<<endl<<"==== HDS start filling resume"<<endl;
430 DumpGeometry(OS,findkeep,compact);
432 OS<<endl<<"==== HDS end filling resume"<<endl;
438 //=======================================================================
439 //function : DumpGeometry
441 //=======================================================================
442 Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry(Standard_OStream& OS
443 ,const Standard_Boolean
447 ,const Standard_Boolean
454 DumpGeometry(TopOpeBRepDS_POINT,OS,findkeep,compact);
455 DumpGeometry(TopOpeBRepDS_CURVE,OS,findkeep,compact);
456 DumpGeometry(TopOpeBRepDS_SURFACE,OS,findkeep,compact);
462 //=======================================================================
463 //function : DumpGeometry
465 //=======================================================================
467 Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry
468 (const TopOpeBRepDS_Kind
472 ,Standard_OStream& OS
473 ,const Standard_Boolean
477 ,const Standard_Boolean
484 if ( ! TopOpeBRepDS::IsGeometry(K) ) return OS;
485 Standard_Integer nt = myHDS->NbGeometry(K);
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();}
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);
500 //=======================================================================
501 //function : DumpGeometry
503 //=======================================================================
505 Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry(const TopOpeBRepDS_Kind
509 ,const Standard_Integer
513 ,Standard_OStream& OS,
514 const Standard_Boolean
518 ,const Standard_Boolean
525 if ( ! TopOpeBRepDS::IsGeometry(K) ) return OS;
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();
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;
543 else OS<<"unbounded"<<endl;
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();
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");
567 const Handle(TopOpeBRepDS_Interference)& SCI1 = CDS.GetSCI1();
568 const Handle(TopOpeBRepDS_Interference)& SCI2 = CDS.GetSCI2();
569 Handle(Geom2d_Curve) PC1,PC2;
571 PC1 = Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(SCI1)->PCurve();
573 PC2 = Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(SCI2)->PCurve();
575 OS<<istr;OS<<"PC(SCI1) : ";Print(PC1,cout,compact);
576 OS<<istr;OS<<"PC(SCI2) : ";Print(PC2,cout,compact);
580 else OS<<"unbounded"<<endl;
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();
593 const TopOpeBRepDS_Surface& SDS = sex.Surface(I);
594 OS<<" (K:"<<((isk)?"1":"0") <<")"<<endl;
595 OS<<"tol = "<<SDS.Tolerance()<<endl;
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;
604 else OS<<"unbounded"<<endl;
615 // = = = = = = = T O P O L O G Y
617 //=======================================================================
618 //function : DumpTopology
620 //=======================================================================
621 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(Standard_OStream& OS) const
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);
635 //=======================================================================
636 //function : DumpTopology
638 //=======================================================================
639 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopOpeBRepDS_Kind
643 ,Standard_OStream& OS) const
646 if ( ! TopOpeBRepDS::IsTopology(K) ) return OS;
647 Standard_Integer nk = myHDS->NbTopology(K);
648 if ( ! nk ) return OS;
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);
659 //=======================================================================
660 //function : DumpTopology
662 //=======================================================================
663 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopAbs_ShapeEnum
667 ,Standard_OStream& OS) const
670 DumpTopology(TopOpeBRepDS::ShapeToKind(T),OS);
675 //=======================================================================
676 //function : DumpSectionEdge
678 //=======================================================================
680 Standard_OStream& TopOpeBRepDS_Dumper::DumpSectionEdge(const TopOpeBRepDS_Kind
684 ,Standard_OStream& OS) const
687 Standard_Integer nse = myHDS->DS().NbSectionEdges();
688 if ( ! nse ) return OS;
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);
700 //=======================================================================
701 //function : DumpSectionEdge
703 //=======================================================================
704 Standard_OStream& TopOpeBRepDS_Dumper::DumpSectionEdge(const TopOpeBRepDS_Kind K,const Standard_Integer I,Standard_OStream& OS) const
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);
712 // E trouvee "Restriction" par les intersections n'est pas dans la DS.
713 OS<<endl<<"EDGE section "<<I<<" non Shape()"<<endl;
715 else DumpTopology(K,it,OS);
719 Standard_EXPORT Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector = 0; // NYI arg of Dump method
721 //=======================================================================
722 //function : DumpTopology
724 //=======================================================================
725 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopOpeBRepDS_Kind
729 ,const Standard_Integer
733 ,Standard_OStream& OS) const
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);
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*) "");
750 s1 = ((rankI == 1) ? (char*) "~" : (char*) "");
751 s2 = ((rankI == 2) ? (char*) "~" : (char*) "");
753 TCollection_AsciiString ss = TopOpeBRepDS::SPrint(K,I,s1,s2);
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));
761 OS<<"tol = "<<tol<<endl;
762 OS<<istr; OS<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
765 Standard_Integer lss = ss.Length();TCollection_AsciiString bss(lss,' ');
769 TopOpeBRepDS_InterferenceIterator it; it.Init(DS.ShapeInterferences(I));
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");
779 else OS<<" has no interference\n";
782 const TopoDS_Shape& S = myHDS->Shape(I,fk);
783 if ( myHDS->HasSameDomain(S) ) {
784 const TopTools_ListOfShape& L = myHDS->DS().ShapeSameDomain(S);
786 OS<<ss<<" same domain (r,o) : "<<SDumpRefOri(S)<<endl;
787 OS<<SPrintShapeRefOri(L,bss+" same domain shapes : ");
796 //=======================================================================
797 //function : DumpTopology
799 //=======================================================================
800 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopAbs_ShapeEnum
804 ,const Standard_Integer
808 ,Standard_OStream& OS) const
811 DumpTopology(TopOpeBRepDS::ShapeToKind(T),I,OS);
816 //=======================================================================
817 //function : SDumpRefOri
819 //=======================================================================
821 TCollection_AsciiString TopOpeBRepDS_Dumper::SDumpRefOri(const TopOpeBRepDS_Kind K,const Standard_Integer I) const
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)+")";
836 //=======================================================================
837 //function : SDumpRefOri
839 //=======================================================================
841 TCollection_AsciiString TopOpeBRepDS_Dumper::SDumpRefOri(const TopoDS_Shape& S) const
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);
851 //=======================================================================
852 //function : DumpRefOri
854 //=======================================================================
856 Standard_OStream& TopOpeBRepDS_Dumper::DumpRefOri(const TopOpeBRepDS_Kind
860 ,const Standard_Integer
864 ,Standard_OStream& OS) const
867 OS<<SDumpRefOri(K,I);OS.flush();
872 //=======================================================================
873 //function : DumpRefOri
875 //=======================================================================
877 Standard_OStream& TopOpeBRepDS_Dumper::DumpRefOri(const TopoDS_Shape&
881 ,Standard_OStream& OS) const
884 OS<<SDumpRefOri(S);OS.flush();
889 //=======================================================================
892 //=======================================================================
894 Standard_OStream& TopOpeBRepDS_Dumper::DumpLOI(
895 const TopOpeBRepDS_ListOfInterference&
899 ,Standard_OStream& OS,
900 const TCollection_AsciiString&
908 TopOpeBRepDS_InterferenceIterator IT(L); if (!IT.More()) { OS<<"NO INTERFERENCE"<<endl; return OS; }
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 + "/ ";
920 //=======================================================================
923 //=======================================================================
924 Standard_OStream& TopOpeBRepDS_Dumper::DumpI(
925 const Handle(TopOpeBRepDS_Interference)&
929 ,Standard_OStream& OS
930 ,const TCollection_AsciiString&
934 ,const TCollection_AsciiString&
941 Standard_Boolean fk = Standard_False;
943 if (I.IsNull()) { OS<<"NULL INTERFERENCE"<<str2; return OS; }
944 Standard_Integer G = I->Geometry(); TopOpeBRepDS_Kind GK = I->GeometryType();
946 if (GK == TopOpeBRepDS_POINT) {
947 gp_Pnt P = myHDS->Point(G).Point();
948 OS<<" P = "<<P.X()<<" "<<P.Y()<<" "<<P.Z();
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();
960 //=======================================================================
961 //function : SPrintShape
963 //=======================================================================
965 TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const Standard_Integer IS) const
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));
973 //=======================================================================
974 //function : SPrintShape
976 //=======================================================================
978 TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const TopoDS_Shape& S) const
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) ? "*" : "");
990 s1 = (Standard_CString ) ((rankIS == 1) ? "~" : "");
991 s2 = (Standard_CString ) ((rankIS == 2) ? "~" : "");
993 TCollection_AsciiString sse = TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(S.ShapeType()),IS,s1,s2);
997 //=======================================================================
998 //function : SPrintShapeRefOri
1000 //=======================================================================
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; }
1005 //=======================================================================
1006 //function : SPrintShapeRefOri
1008 //=======================================================================
1010 TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShapeRefOri(const TopTools_ListOfShape& L,const TCollection_AsciiString& astr) const
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";