// File: TopOpeBRepDS_Dumper.cxx // Created: Thu Aug 4 19:32:36 1994 // Author: Jean Yves LEBEY // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //======================================================================= //function : TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper //purpose : //======================================================================= TopOpeBRepDS_Dumper::TopOpeBRepDS_Dumper(const Handle(TopOpeBRepDS_HDataStructure)& HDS) { myHDS = HDS; } //======================================================================= //function : PrintType //purpose : //======================================================================= Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom_Curve)& #ifdef DEB C #endif ,Standard_OStream& OS) { #ifdef DEB if (C.IsNull()) { OS<<"NULL CURVE"; return OS; } Handle(Standard_Type) T = C->DynamicType(); if (T==STANDARD_TYPE(Geom_Circle)) OS<<"CIRCLE"; else if (T==STANDARD_TYPE(Geom_Line)) OS<<"LINE"; else if (T==STANDARD_TYPE(Geom_Ellipse)) OS<<"ELLIPSE"; else if (T==STANDARD_TYPE(Geom_Parabola)) OS<<"ELLIPSE"; else if (T==STANDARD_TYPE(Geom_Hyperbola)) OS<<"HYPERBOLA"; else if (T==STANDARD_TYPE(Geom_BezierCurve)) OS<<"BEZIER"; else if (T==STANDARD_TYPE(Geom_BSplineCurve)) OS<<"BSPLINE("<<(*((Handle(Geom_BSplineCurve)*)&C))->Degree()<<")"; else if (T==STANDARD_TYPE(Geom_TrimmedCurve)) {OS<<"TRIMMED ";PrintType(Handle(Geom_TrimmedCurve)::DownCast(C)->BasisCurve(),OS);} else if (T==STANDARD_TYPE(Geom_OffsetCurve)) OS<<"OFFSETCURVE"; else OS<<"***UNKNOWN***"; if (T!=STANDARD_TYPE(Geom_TrimmedCurve)) OS<<"3D"; #endif return OS; } //======================================================================= //function : PrintType //purpose : //======================================================================= Standard_OStream& TopOpeBRepDS_Dumper::PrintType(const Handle(Geom2d_Curve)& #ifdef DEB C #endif ,Standard_OStream& OS) { #ifdef DEB if (C.IsNull()) { OS<<"NULL CURVE2d"; return OS; } Handle(Standard_Type) T = C->DynamicType(); if (T==STANDARD_TYPE(Geom2d_Circle)) OS<<"CIRCLE"; else if (T==STANDARD_TYPE(Geom2d_Line)) OS<<"LINE"; else if (T==STANDARD_TYPE(Geom2d_Ellipse)) OS<<"ELLIPSE"; else if (T==STANDARD_TYPE(Geom2d_Parabola)) OS<<"ELLIPSE"; else if (T==STANDARD_TYPE(Geom2d_Hyperbola)) OS<<"HYPERBOLA"; else if (T==STANDARD_TYPE(Geom2d_BezierCurve)) OS<<"BEZIER"; else if (T==STANDARD_TYPE(Geom2d_BSplineCurve)) OS<<"BSPLINE("<<(*((Handle(Geom2d_BSplineCurve)*)&C))->Degree()<<")"; else if (T==STANDARD_TYPE(Geom2d_TrimmedCurve)) {OS<<"TRIMMED ";PrintType(Handle(Geom2d_TrimmedCurve)::DownCast(C)->BasisCurve(),OS);} else if (T==STANDARD_TYPE(Geom2d_OffsetCurve)) OS<<"OFFSETCURVE"; else OS<<"***UNKNOWN***"; if (T!=STANDARD_TYPE(Geom2d_TrimmedCurve)) OS<<"2D"; #endif return OS; } //======================================================================= //function : Print //purpose : //======================================================================= Standard_OStream& TopOpeBRepDS_Dumper::Print(const gp_Pnt& #ifdef DEB P #endif ,Standard_OStream& OS) { #ifdef DEB OS<Degree(); Standard_Integer nbpoles = B->NbPoles(); Standard_Integer nbknots = B->NbKnots(); Standard_Boolean rational = B->IsRational(); Standard_Boolean periodic = B->IsPeriodic(); OS<<"BSplineCurve : "; if (periodic) OS<<"periodic, "; OS<<"degree "< 4) OS << setw(lb) << "\t ...\n"; } else if (i == n) lb = l; else continue; OS<Pole(i),OS); if (rational) OS<<" "<Weight(i); OS< 4) OS << setw(lb) << "\t ...\n"; lb = l; } else if (i == n) lb = l; else continue; OS<Knot(i)<<" "<Multiplicity(i); OS<Degree(); Standard_Integer nbpoles = B->NbPoles(); Standard_Integer nbknots = B->NbKnots(); Standard_Boolean rational = B->IsRational(); Standard_Boolean periodic = B->IsPeriodic(); OS<<"BSplineCurve : "; if (periodic) OS<<"periodic, "; OS<<"degree "< 4) OS << setw(lb) << "\t ...\n"; } else if (i == n) lb = l; else continue; OS<Pole(i),OS); if (rational) OS<<" "<Weight(i); OS< 4) OS << setw(lb) << "\t ...\n"; } else if (i == n) lb = l; else continue; OS<Knot(i)<<" "<Multiplicity(i); OS<DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) TopOpeBRepDS_Dumper::Print(DBSP3D(C),OS,compact); else GeomTools_CurveSet::PrintCurve(C,OS,Standard_False); } #endif return OS; } //======================================================================= //function : Print //purpose : //======================================================================= #ifdef DEB Standard_OStream& TopOpeBRepDS_Dumper::Print(const Handle(Geom2d_Curve)& C, Standard_OStream& OS,const Standard_Boolean compact) { #define DBSP2D(tut) (*((Handle(Geom2d_BSplineCurve)*)&(tut))) if (!C.IsNull()) { if (C->DynamicType() == STANDARD_TYPE(Geom2d_BSplineCurve)) TopOpeBRepDS_Dumper::Print(DBSP2D(C),OS,compact); else GeomTools_Curve2dSet::PrintCurve2d(C,OS,Standard_False); } return OS; } #endif // DUMP OF HDATASTRUCTURE //----------------------------------------------------------------------- #ifdef DEB //unreferenced function, commented /*static void souligne(const TCollection_AsciiString& t,Standard_OStream& OS,const char c = '-') { for(char i=0;iNbGeometry(K); if (!nt) return OS; Standard_Integer n=0; if (K==TopOpeBRepDS_POINT){TopOpeBRepDS_PointExplorer ex(myHDS->DS(),findkeep);n=ex.NbPoint();} else if(K==TopOpeBRepDS_CURVE){TopOpeBRepDS_CurveExplorer ex(myHDS->DS());n=ex.NbCurve();} else if(K==TopOpeBRepDS_SURFACE){TopOpeBRepDS_SurfaceExplorer ex(myHDS->DS());n=ex.NbSurface();} if (!n) return OS; TCollection_AsciiString s = "---- "; ::Print(K,s); OS<DS()); Standard_Boolean isp = pex.IsPoint(I); Standard_Boolean isk = pex.IsPointKeep(I); if(!findkeep || isk) { TCollection_AsciiString kstr;::Print(K,kstr);kstr=kstr+" "+I+" :"; Standard_Integer lk = kstr.Length(); OS<DS()); Standard_Boolean isc = cex.IsCurve(I); Standard_Boolean isk = cex.IsCurveKeep(I); if(!findkeep || isk) { TCollection_AsciiString kstr;::Print(K,kstr);kstr=kstr+" "+I+" :"; Standard_Integer lk = kstr.Length(); OS<PCurve(); if ( !SCI2.IsNull()) PC2 = Handle(TopOpeBRepDS_SurfaceCurveInterference)::DownCast(SCI2)->PCurve(); OS<DS()); Standard_Boolean iss = sex.IsSurface(I); Standard_Boolean isk = sex.IsSurfaceKeep(I); if(!findkeep || isk) { TCollection_AsciiString kstr; ::Print(K,kstr); kstr=kstr+" "+I+" : "; Standard_Integer lk = kstr.Length(); OS<NbTopology(K); if ( ! nk ) return OS; OS<NbTopology(); OS<DS().NbSectionEdges(); if ( ! nse ) return OS; OS<DS(); const TopoDS_Shape& E = DS.SectionEdge(I,SEFindKeep); if(E.IsNull()) return OS; Standard_Integer it = myHDS->DS().Shape(E,SEFindKeep); if (it == 0) { // E trouvee "Restriction" par les intersections n'est pas dans la DS. OS<DS(); if ( ! TopOpeBRepDS::IsTopology(K) ) return OS; if ( I <= 0 ) return OS; TopAbs_ShapeEnum t = TopOpeBRepDS::KindToShape(K); if ( DS.Shape(I,fk).ShapeType() != t ) return OS; Standard_Integer rankI = DS.AncestorRank(I); TCollection_AsciiString s1,s2; if(DS.KeepShape(I)) { s1 = ((rankI == 1) ? (char*) "*" : (char*) ""); s2 = ((rankI == 2) ? (char*) "*" : (char*) ""); } else { s1 = ((rankI == 1) ? (char*) "~" : (char*) ""); s2 = ((rankI == 2) ? (char*) "~" : (char*) ""); } TCollection_AsciiString ss = TopOpeBRepDS::SPrint(K,I,s1,s2); if ( t == TopAbs_VERTEX ) { Standard_Integer lk = ss.Length() + 3; TCollection_AsciiString istr(lk,' '); gp_Pnt P = TopOpeBRepTool_ShapeTool::Pnt(DS.Shape(I,fk)); Standard_Real tol = TopOpeBRepTool_ShapeTool::Tolerance(DS.Shape(I,fk)); OS<<"\n"<Dump(OS,"","\n"); } } else OS<<" has no interference\n"; // SameDomain const TopoDS_Shape& S = myHDS->Shape(I,fk); if ( myHDS->HasSameDomain(S) ) { const TopTools_ListOfShape& L = myHDS->DS().ShapeSameDomain(S); if ( L.Extent() ) { OS<DS(); if ( ! TopOpeBRepDS::IsTopology(K) ) return SS; TopAbs_ShapeEnum t = TopOpeBRepDS::KindToShape(K); if ( DS.Shape(I,fk).ShapeType() != t ) return SS; const TopoDS_Shape& S = myHDS->Shape(I,fk); Standard_Integer r = myHDS->SameDomainReference(S); TopOpeBRepDS_Config o = myHDS->SameDomainOrientation(S); SS=SS+"("+SPrintShape(r)+","+TopOpeBRepDS::SPrint(o)+")"; return SS; } //======================================================================= //function : SDumpRefOri //purpose : //======================================================================= TCollection_AsciiString TopOpeBRepDS_Dumper::SDumpRefOri(const TopoDS_Shape& S) const { TCollection_AsciiString SS; TopOpeBRepDS_Kind k = TopOpeBRepDS::ShapeToKind(S.ShapeType()); Standard_Boolean fk = Standard_False; Standard_Integer i = myHDS->Shape(S,fk); SS = SDumpRefOri(k,i); return SS; } //======================================================================= //function : DumpRefOri //purpose : //======================================================================= Standard_OStream& TopOpeBRepDS_Dumper::DumpRefOri(const TopOpeBRepDS_Kind #ifdef DEB K #endif ,const Standard_Integer #ifdef DEB I #endif ,Standard_OStream& OS) const { #ifdef DEB OS<Geometry(); TopOpeBRepDS_Kind GK = I->GeometryType(); I->Dump(OS); if (GK == TopOpeBRepDS_POINT) { gp_Pnt P = myHDS->Point(G).Point(); OS<<" P = "<Shape(G,fk)); OS<<" V = "<DS(); if ( IS<1 || IS>BDS.NbShapes()) return SS; SS = SPrintShape(BDS.Shape(IS)); return SS; } //======================================================================= //function : SPrintShape //purpose : //======================================================================= TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShape(const TopoDS_Shape& S) const { const TopOpeBRepDS_DataStructure& BDS = myHDS->DS(); const Standard_Integer IS = myHDS->DS().Shape(S); Standard_Integer rankIS = BDS.AncestorRank(IS); //JR/Hp TCollection_AsciiString s1,s2; Standard_CString s1,s2; if(BDS.KeepShape(IS)) { s1 = (Standard_CString ) ((rankIS == 1) ? "*" : ""); s2 = (Standard_CString ) ((rankIS == 2) ? "*" : ""); } else { s1 = (Standard_CString ) ((rankIS == 1) ? "~" : ""); s2 = (Standard_CString ) ((rankIS == 2) ? "~" : ""); } TCollection_AsciiString sse = TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(S.ShapeType()),IS,s1,s2); return sse; } //======================================================================= //function : SPrintShapeRefOri //purpose : //======================================================================= TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShapeRefOri(const TopoDS_Shape& S,const TCollection_AsciiString& astr) const { TCollection_AsciiString SS=astr+SPrintShape(S)+" "+SDumpRefOri(S); return SS; } //======================================================================= //function : SPrintShapeRefOri //purpose : //======================================================================= TCollection_AsciiString TopOpeBRepDS_Dumper::SPrintShapeRefOri(const TopTools_ListOfShape& L,const TCollection_AsciiString& astr) const { TCollection_AsciiString SS;TopTools_ListIteratorOfListOfShape it(L); if (!it.More()) return SS; SS=SS+astr; TCollection_AsciiString bst(astr.Length(),' '); for(Standard_Integer il = 0; it.More(); it.Next(),il++) { TCollection_AsciiString ss=SPrintShapeRefOri(it.Value());if (il) ss=bst+ss; SS=SS+ss+"\n"; } return SS; }