From ffe74e4685355b779f5d87ec51944806de72b4dc Mon Sep 17 00:00:00 2001 From: KGV <> Date: Fri, 18 Nov 2011 14:33:55 +0000 Subject: [PATCH] 0022726: Exception on restoring shape --- src/DBRep/DBRep_IsoBuilder.cxx | 145 ++++++++++++++++++--------------- 1 file changed, 81 insertions(+), 64 deletions(-) diff --git a/src/DBRep/DBRep_IsoBuilder.cxx b/src/DBRep/DBRep_IsoBuilder.cxx index f16fa56c9d..693be7d785 100755 --- a/src/DBRep/DBRep_IsoBuilder.cxx +++ b/src/DBRep/DBRep_IsoBuilder.cxx @@ -89,82 +89,99 @@ DBRep_IsoBuilder::DBRep_IsoBuilder (const TopoDS_Face& TopologicalFace, // Retreiving the edges and loading them into the hatcher. //----------------------------------------------------------------------- - TopExp_Explorer ExpEdges ; - for (ExpEdges.Init (TopologicalFace, TopAbs_EDGE) ; ExpEdges.More() ; ExpEdges.Next()) { - const TopoDS_Edge& TopologicalEdge = TopoDS::Edge (ExpEdges.Current()) ; - Standard_Real U1, U2 ; - const Handle(Geom2d_Curve) PCurve = BRep_Tool::CurveOnSurface (TopologicalEdge, TopologicalFace, U1, U2) ; + TopExp_Explorer ExpEdges; + for (ExpEdges.Init (TopologicalFace, TopAbs_EDGE); ExpEdges.More(); ExpEdges.Next()) + { + const TopoDS_Edge& TopologicalEdge = TopoDS::Edge (ExpEdges.Current()); + Standard_Real U1, U2; + const Handle(Geom2d_Curve) PCurve = BRep_Tool::CurveOnSurface (TopologicalEdge, TopologicalFace, U1, U2); - if ( PCurve.IsNull() ) { -#ifdef DEB - cout<<"DBRep_IsoBuilder : PCurve nulle"<FirstParameter()-U1)<= Precision::PConfusion() - && Abs(PCurve->LastParameter()-U2)<= Precision::PConfusion()) { -#ifdef DEB - Standard_Integer IndE = -#endif - AddElement (PCurve, TopologicalEdge.Orientation()) ; + if (Abs(PCurve->FirstParameter()-U1)<= Precision::PConfusion() + && Abs(PCurve->LastParameter()-U2)<= Precision::PConfusion()) + { + AddElement (PCurve, TopologicalEdge.Orientation()); } - else { - if (!PCurve->IsPeriodic()) { - Handle (Geom2d_TrimmedCurve) TrimPCurve =Handle(Geom2d_TrimmedCurve)::DownCast(PCurve); - if (!TrimPCurve.IsNull()) { - if (TrimPCurve->BasisCurve()->FirstParameter()-U1 > Precision::PConfusion() || - U2-TrimPCurve->BasisCurve()->LastParameter() > Precision::PConfusion()) { -#ifdef DEB - Standard_Integer IndE = -#endif - AddElement (PCurve, TopologicalEdge.Orientation()) ; -#ifdef DEB - cout<<"DBRep_IsoBuilder TrimPCurve : parameters out of range "<FirstParameter() - <<"), U2("<LastParameter()<<")"<FirstParameter()-U1 > Precision::PConfusion()){ -#ifdef DEB - cout<<"DBRep_IsoBuilder PCurve : U1 parameters out of range "<FirstParameter()<<")"<FirstParameter(); - } - if (U2-PCurve->LastParameter() > Precision::PConfusion()){ -#ifdef DEB - cout<<"DBRep_IsoBuilder PCurve : U2 parameters out of range "<LastParameter()<<")"<LastParameter(); - } - } + else + { + if (!PCurve->IsPeriodic()) + { + Handle (Geom2d_TrimmedCurve) TrimPCurve = Handle(Geom2d_TrimmedCurve)::DownCast (PCurve); + if (!TrimPCurve.IsNull()) + { + if (TrimPCurve->BasisCurve()->FirstParameter() - U1 > Precision::PConfusion() || + TrimPCurve->BasisCurve()->FirstParameter() - U2 > Precision::PConfusion() || + U1 - TrimPCurve->BasisCurve()->LastParameter() > Precision::PConfusion() || + U2 - TrimPCurve->BasisCurve()->LastParameter() > Precision::PConfusion()) + { + AddElement (PCurve, TopologicalEdge.Orientation()); + #ifdef DEB + cout << "DBRep_IsoBuilder TrimPCurve : parameters out of range\n"; + cout << " U1(" << U1 << "), Umin(" << PCurve->FirstParameter() + << "), U2(" << U2 << "), Umax(" << PCurve->LastParameter() << ")\n"; + #endif + return; + } + } + else + { + if (PCurve->FirstParameter() - U1 > Precision::PConfusion()) + { + #ifdef DEB + cout << "DBRep_IsoBuilder PCurve : parameters out of range\n"; + cout << " U1(" << U1 << "), Umin(" << PCurve->FirstParameter() << ")\n"; + #endif + U1 = PCurve->FirstParameter(); + } + if (PCurve->FirstParameter() - U2 > Precision::PConfusion()) + { + #ifdef DEB + cout << "DBRep_IsoBuilder PCurve : parameters out of range\n"; + cout << " U2(" << U2 << "), Umin(" << PCurve->FirstParameter() << ")\n"; + #endif + U2 = PCurve->FirstParameter(); + } + if (U1 - PCurve->LastParameter() > Precision::PConfusion()) + { + #ifdef DEB + cout << "DBRep_IsoBuilder PCurve : parameters out of range\n"; + cout << " U1(" << U1 << "), Umax(" << PCurve->LastParameter() << ")\n"; + #endif + U1 = PCurve->LastParameter(); + } + if (U2 - PCurve->LastParameter() > Precision::PConfusion()) + { + #ifdef DEB + cout << "DBRep_IsoBuilder PCurve : parameters out of range\n"; + cout << " U2(" << U2 << "), Umax(" << PCurve->LastParameter() << ")\n"; + #endif + U2 = PCurve->LastParameter(); + } + } } - - //if U1 and U2 coincide-->do nothing - if (Abs(U1-U2) <= Precision::PConfusion()) continue; - - Handle (Geom2d_TrimmedCurve) TrimPCurve = new Geom2d_TrimmedCurve (PCurve, U1, U2) ; -#ifdef DEB - Standard_Integer IndE = -#endif - AddElement (TrimPCurve, TopologicalEdge.Orientation()) ; + + // if U1 and U2 coincide-->do nothing + if (Abs (U1 - U2) <= Precision::PConfusion()) continue; + Handle (Geom2d_TrimmedCurve) TrimPCurve = new Geom2d_TrimmedCurve (PCurve, U1, U2); + AddElement (TrimPCurve, TopologicalEdge.Orientation()); } } - //----------------------------------------------------------------------- // Loading and trimming the hatchings. //----------------------------------------------------------------------- -- 2.20.1