1 // Created on: 1994-08-04
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Standard_Stream.hxx>
18 #include <TopOpeBRepDS_Dumper.ixx>
19 #include <TopoDS_Edge.hxx>
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>
31 #include <TopoDS_Edge.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopOpeBRepTool_ShapeTool.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>
57 #include <TopOpeBRepDS_define.hxx>
58 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
60 //=======================================================================
61 //function : TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper
63 //=======================================================================
65 TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
70 //=======================================================================
71 //function : PrintType
73 //=======================================================================
75 Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom_Curve)&
79 ,Standard_OStream& OS)
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)::DownCast (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";
105 //=======================================================================
106 //function : PrintType
108 //=======================================================================
110 Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom2d_Curve)&
114 ,Standard_OStream& OS)
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)::DownCast (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";
140 //=======================================================================
143 //=======================================================================
145 Standard_OStream& TopOpeBRepDS_Dumper::Print(const gp_Pnt&
149 ,Standard_OStream& OS)
152 OS<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" ";
159 //=======================================================================
162 //=======================================================================
164 Standard_OStream& TopOpeBRepDS_Dumper::Print(const gp_Pnt2d&
168 ,Standard_OStream& OS)
171 OS<<P.X()<<" "<<P.Y()<<" ";
178 //=======================================================================
181 //=======================================================================
183 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom_BSplineCurve)&
187 ,Standard_OStream& OS
188 ,const Standard_Boolean
195 Standard_Integer i,l,lb = 0,n;
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();
203 OS<<"BSplineCurve : ";
204 if (periodic) OS<<"periodic, ";
205 OS<<"degree "<<degree<<", "<<nbpoles<<" poles, "<<nbknots<<" knots"<<endl;
207 //l = strlen("poles : ") + 1
208 for (i = 1,OS<<"poles : ",l = 9,n = nbpoles;
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;
216 if(n > 4) OS << setw(lb) << "\t ...\n";
218 else if (i == n) lb = l;
221 OS<<setw(lb)<<i<<" : ";
222 TopOpeBRepDS_Dumper::Print(B->Pole(i),OS);
223 if (rational) OS<<" "<<B->Weight(i);
228 //l = strlen("knots : ") + 1
229 for (i = 1,OS<<"knots : ",l = 9,n = nbknots;
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;
236 if(n > 4) OS << setw(lb) << "\t ...\n";
239 else if (i == n) lb = l;
242 OS<<setw(lb)<<i<<" : ";
243 OS<<B->Knot(i)<<" "<<B->Multiplicity(i);
253 //=======================================================================
256 //=======================================================================
258 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom2d_BSplineCurve)&
262 ,Standard_OStream& OS
263 ,const Standard_Boolean
270 Standard_Integer i,l,lb=-1,n;
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();
278 OS<<"BSplineCurve : ";
279 if (periodic) OS<<"periodic, ";
280 OS<<"degree "<<degree<<", "<<nbpoles<<" poles, "<<nbknots<<" knots"<<endl;
282 //l = strlen("poles : ") + 1
283 for (i = 1,OS<<"poles : ",l = 9,n = nbpoles;
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;
291 if(n > 4) OS << setw(lb) << "\t ...\n";
293 else if (i == n) lb = l;
296 OS<<setw(lb)<<i<<" : ";
297 TopOpeBRepDS_Dumper::Print(B->Pole(i),OS);
298 if (rational) OS<<" "<<B->Weight(i);
303 //l = strlen("knots : ") + 1
304 for (i = 1,OS<<"knots : ",l = 9,n = nbknots;
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;
312 if(n > 4) OS << setw(lb) << "\t ...\n";
314 else if (i == n) lb = l;
317 OS<<setw(lb)<<i<<" : ";
318 OS<<B->Knot(i)<<" "<<B->Multiplicity(i);
328 //=======================================================================
331 //=======================================================================
333 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom_Curve)&
337 ,Standard_OStream& OS
338 ,const Standard_Boolean
345 #define DBSP3D(tut) (*((Handle(Geom_BSplineCurve)*)&(tut)))
347 if (C->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve))
348 TopOpeBRepDS_Dumper::Print(DBSP3D(C),OS,compact);
350 GeomTools_CurveSet::PrintCurve(C,OS,Standard_False);
358 //=======================================================================
361 //=======================================================================
364 Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom2d_Curve)& C,
365 Standard_OStream& OS,const Standard_Boolean compact)
367 #define DBSP2D(tut) (*((Handle(Geom2d_BSplineCurve)*)&(tut)))
369 if (C->DynamicType() == STANDARD_TYPE(Geom2d_BSplineCurve))
370 TopOpeBRepDS_Dumper::Print(DBSP2D(C),OS,compact);
372 GeomTools_Curve2dSet::PrintCurve2d(C,OS,Standard_False);
379 // DUMP OF HDATASTRUCTURE
381 //-----------------------------------------------------------------------
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)
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;
408 //=======================================================================
411 //=======================================================================
413 Standard_OStream& TopOpeBRepDS_Dumper::Dump(Standard_OStream& OS
414 ,const Standard_Boolean
418 ,const Standard_Boolean
425 OS<<endl<<"==== HDS start filling resume"<<endl;
426 DumpGeometry(OS,findkeep,compact);
428 OS<<endl<<"==== HDS end filling resume"<<endl;
434 //=======================================================================
435 //function : DumpGeometry
437 //=======================================================================
438 Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry(Standard_OStream& OS
439 ,const Standard_Boolean
443 ,const Standard_Boolean
450 DumpGeometry(TopOpeBRepDS_POINT,OS,findkeep,compact);
451 DumpGeometry(TopOpeBRepDS_CURVE,OS,findkeep,compact);
452 DumpGeometry(TopOpeBRepDS_SURFACE,OS,findkeep,compact);
458 //=======================================================================
459 //function : DumpGeometry
461 //=======================================================================
463 Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry
464 (const TopOpeBRepDS_Kind
468 ,Standard_OStream& OS
469 ,const Standard_Boolean
473 ,const Standard_Boolean
480 if ( ! TopOpeBRepDS::IsGeometry(K) ) return OS;
481 Standard_Integer nt = myHDS->NbGeometry(K);
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();}
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);
496 //=======================================================================
497 //function : DumpGeometry
499 //=======================================================================
501 Standard_OStream& TopOpeBRepDS_Dumper::DumpGeometry(const TopOpeBRepDS_Kind
505 ,const Standard_Integer
509 ,Standard_OStream& OS,
510 const Standard_Boolean
514 ,const Standard_Boolean
521 if ( ! TopOpeBRepDS::IsGeometry(K) ) return OS;
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();
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;
539 else OS<<"unbounded"<<endl;
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();
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");
563 const Handle(TopOpeBRepDS_Interference)& SCI1 = CDS.GetSCI1();
564 const Handle(TopOpeBRepDS_Interference)& SCI2 = CDS.GetSCI2();
565 Handle(Geom2d_Curve) PC1,PC2;
567 PC1 = Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(SCI1)->PCurve();
569 PC2 = Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(SCI2)->PCurve();
571 OS<<istr;OS<<"PC(SCI1) : ";Print(PC1,cout,compact);
572 OS<<istr;OS<<"PC(SCI2) : ";Print(PC2,cout,compact);
576 else OS<<"unbounded"<<endl;
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();
589 const TopOpeBRepDS_Surface& SDS = sex.Surface(I);
590 OS<<" (K:"<<((isk)?"1":"0") <<")"<<endl;
591 OS<<"tol = "<<SDS.Tolerance()<<endl;
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;
600 else OS<<"unbounded"<<endl;
611 // = = = = = = = T O P O L O G Y
613 //=======================================================================
614 //function : DumpTopology
616 //=======================================================================
617 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(Standard_OStream& OS) const
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);
631 //=======================================================================
632 //function : DumpTopology
634 //=======================================================================
635 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopOpeBRepDS_Kind
639 ,Standard_OStream& OS) const
642 if ( ! TopOpeBRepDS::IsTopology(K) ) return OS;
643 Standard_Integer nk = myHDS->NbTopology(K);
644 if ( ! nk ) return OS;
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);
655 //=======================================================================
656 //function : DumpTopology
658 //=======================================================================
659 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopAbs_ShapeEnum
663 ,Standard_OStream& OS) const
666 DumpTopology(TopOpeBRepDS::ShapeToKind(T),OS);
671 //=======================================================================
672 //function : DumpSectionEdge
674 //=======================================================================
676 Standard_OStream& TopOpeBRepDS_Dumper::DumpSectionEdge(const TopOpeBRepDS_Kind
680 ,Standard_OStream& OS) const
683 Standard_Integer nse = myHDS->DS().NbSectionEdges();
684 if ( ! nse ) return OS;
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);
696 //=======================================================================
697 //function : DumpSectionEdge
699 //=======================================================================
700 Standard_OStream& TopOpeBRepDS_Dumper::DumpSectionEdge(const TopOpeBRepDS_Kind K,const Standard_Integer I,Standard_OStream& OS) const
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);
708 // E trouvee "Restriction" par les intersections n'est pas dans la DS.
709 OS<<endl<<"EDGE section "<<I<<" non Shape()"<<endl;
711 else DumpTopology(K,it,OS);
715 Standard_EXPORT Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector = 0; // NYI arg of Dump method
717 //=======================================================================
718 //function : DumpTopology
720 //=======================================================================
721 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopOpeBRepDS_Kind
725 ,const Standard_Integer
729 ,Standard_OStream& OS) const
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);
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*) "");
746 s1 = ((rankI == 1) ? (char*) "~" : (char*) "");
747 s2 = ((rankI == 2) ? (char*) "~" : (char*) "");
749 TCollection_AsciiString ss = TopOpeBRepDS::SPrint(K,I,s1,s2);
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));
757 OS<<"tol = "<<tol<<endl;
758 OS<<istr; OS<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<endl;
761 Standard_Integer lss = ss.Length();TCollection_AsciiString bss(lss,' ');
765 TopOpeBRepDS_InterferenceIterator it; it.Init(DS.ShapeInterferences(I));
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");
775 else OS<<" has no interference\n";
778 const TopoDS_Shape& S = myHDS->Shape(I,fk);
779 if ( myHDS->HasSameDomain(S) ) {
780 const TopTools_ListOfShape& L = myHDS->DS().ShapeSameDomain(S);
782 OS<<ss<<" same domain (r,o) : "<<SDumpRefOri(S)<<endl;
783 OS<<SPrintShapeRefOri(L,bss+" same domain shapes : ");
792 //=======================================================================
793 //function : DumpTopology
795 //=======================================================================
796 Standard_OStream& TopOpeBRepDS_Dumper::DumpTopology(const TopAbs_ShapeEnum
800 ,const Standard_Integer
804 ,Standard_OStream& OS) const
807 DumpTopology(TopOpeBRepDS::ShapeToKind(T),I,OS);
812 //=======================================================================
813 //function : SDumpRefOri
815 //=======================================================================
817 TCollection_AsciiString TopOpeBRepDS_Dumper::SDumpRefOri(const TopOpeBRepDS_Kind K,const Standard_Integer I) const
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)+")";
832 //=======================================================================
833 //function : SDumpRefOri
835 //=======================================================================
837 TCollection_AsciiString TopOpeBRepDS_Dumper::SDumpRefOri(const TopoDS_Shape& S) const
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);
847 //=======================================================================
848 //function : DumpRefOri
850 //=======================================================================
852 Standard_OStream& TopOpeBRepDS_Dumper::DumpRefOri(const TopOpeBRepDS_Kind
856 ,const Standard_Integer
860 ,Standard_OStream& OS) const
863 OS<<SDumpRefOri(K,I);OS.flush();
868 //=======================================================================
869 //function : DumpRefOri
871 //=======================================================================
873 Standard_OStream& TopOpeBRepDS_Dumper::DumpRefOri(const TopoDS_Shape&
877 ,Standard_OStream& OS) const
880 OS<<SDumpRefOri(S);OS.flush();
885 //=======================================================================
888 //=======================================================================
890 Standard_OStream& TopOpeBRepDS_Dumper::DumpLOI(
891 const TopOpeBRepDS_ListOfInterference&
895 ,Standard_OStream& OS,
896 const TCollection_AsciiString&
904 TopOpeBRepDS_InterferenceIterator IT(L); if (!IT.More()) { OS<<"NO INTERFERENCE"<<endl; return OS; }
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 + "/ ";
916 //=======================================================================
919 //=======================================================================
920 Standard_OStream& TopOpeBRepDS_Dumper::DumpI(
921 const Handle(TopOpeBRepDS_Interference)&
925 ,Standard_OStream& OS
926 ,const TCollection_AsciiString&
930 ,const TCollection_AsciiString&
937 Standard_Boolean fk = Standard_False;
939 if (I.IsNull()) { OS<<"NULL INTERFERENCE"<<str2; return OS; }
940 Standard_Integer G = I->Geometry(); TopOpeBRepDS_Kind GK = I->GeometryType();
942 if (GK == TopOpeBRepDS_POINT) {
943 gp_Pnt P = myHDS->Point(G).Point();
944 OS<<" P = "<<P.X()<<" "<<P.Y()<<" "<<P.Z();
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();
956 //=======================================================================
957 //function : SPrintShape
959 //=======================================================================
961 TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const Standard_Integer IS) const
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));
969 //=======================================================================
970 //function : SPrintShape
972 //=======================================================================
974 TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const TopoDS_Shape& S) const
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) ? "*" : "");
986 s1 = (Standard_CString ) ((rankIS == 1) ? "~" : "");
987 s2 = (Standard_CString ) ((rankIS == 2) ? "~" : "");
989 TCollection_AsciiString sse = TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(S.ShapeType()),IS,s1,s2);
993 //=======================================================================
994 //function : SPrintShapeRefOri
996 //=======================================================================
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; }
1001 //=======================================================================
1002 //function : SPrintShapeRefOri
1004 //=======================================================================
1006 TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShapeRefOri(const TopTools_ListOfShape& L,const TCollection_AsciiString& astr) const
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";