From a8b52677250dad4ea1a92f0729638fbecba0cd14 Mon Sep 17 00:00:00 2001 From: anv Date: Thu, 8 Dec 2016 16:24:34 +0300 Subject: [PATCH] 0026026: XtControl_Reader hangs when processing specific data Small fix for a specific case (was missing). --- src/AppBlend/AppBlend_AppSurf.gxx | 20 ++++++--- src/BRepOffset/BRepOffset_Offset.cxx | 4 ++ src/BRepTest/BRepTest_SweepCommands.cxx | 5 +++ src/GeomFill/GeomFill_Pipe.cxx | 41 ++++++++++--------- src/GeomFill/GeomFill_Pipe.hxx | 3 ++ src/GeomFill/GeomFill_Pipe.lxx | 9 ++++ .../GeometryTest_SurfaceCommands.cxx | 13 +++++- src/LocOpe/LocOpe_SplitDrafts.cxx | 4 ++ src/QABugs/QABugs_11.cxx | 5 +++ 9 files changed, 77 insertions(+), 27 deletions(-) diff --git a/src/AppBlend/AppBlend_AppSurf.gxx b/src/AppBlend/AppBlend_AppSurf.gxx index 318c59720e..fd8a7f9672 100644 --- a/src/AppBlend/AppBlend_AppSurf.gxx +++ b/src/AppBlend/AppBlend_AppSurf.gxx @@ -535,9 +535,13 @@ void AppBlend_AppSurf::InternalPerform(const Handle(TheLine)& Lin, for (k=1; k<=NbVPoles; k++) { // pour les courbes rationnelles il faut maintenant diviser // les poles par leurs poids respectifs - tabPoles->ChangeValue(j,k). - SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X()); - tabWeights->SetValue(j,k,newtabP2d->Value(k).X()); + tabPoles->ChangeValue(j,k).SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X()); + Standard_Real aWeight = newtabP2d->Value(k).X(); + if (aWeight < gp::Resolution()) { + done = Standard_False; + return; + } + tabWeights->SetValue(j,k,aWeight); } } @@ -870,9 +874,13 @@ void AppBlend_AppSurf::Perform(const Handle(TheLine)& Lin, for (k=1; k<=NbVPoles; k++) { // pour les courbes rationnelles il faut maintenant diviser // les poles par leurs poids respectifs - tabPoles->ChangeValue(j,k). - SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X()); - tabWeights->SetValue(j,k,newtabP2d->Value(k).X()); + tabPoles->ChangeValue(j,k).SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X()); + Standard_Real aWeight = newtabP2d->Value(k).X(); + if (aWeight < gp::Resolution()) { + done = Standard_False; + return; + } + tabWeights->SetValue(j,k,aWeight); } } diff --git a/src/BRepOffset/BRepOffset_Offset.cxx b/src/BRepOffset/BRepOffset_Offset.cxx index b1e8df348c..989c2a844a 100644 --- a/src/BRepOffset/BRepOffset_Offset.cxx +++ b/src/BRepOffset/BRepOffset_Offset.cxx @@ -1114,6 +1114,8 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path, // Calcul du tuyau GeomFill_Pipe Pipe(HCP, HEdge1, HEdge2, Abs(Offset)); Pipe.Perform(Tol, Polynomial, Conti); + if (!Pipe.IsDone()) + Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface"); Standard_Real ErrorPipe = Pipe.ErrorOnSurf(); Handle(Geom_Surface) S = Pipe.Surface(); @@ -1581,6 +1583,8 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Edge, GeomFill_Pipe Pipe(CP,myOffset); Pipe.Perform(); + if (!Pipe.IsDone()) + Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface"); BRepLib_MakeFace MF(Pipe.Surface(), Precision::Confusion()); myFace = MF.Face(); diff --git a/src/BRepTest/BRepTest_SweepCommands.cxx b/src/BRepTest/BRepTest_SweepCommands.cxx index 1c225caa8f..eb869eea8b 100644 --- a/src/BRepTest/BRepTest_SweepCommands.cxx +++ b/src/BRepTest/BRepTest_SweepCommands.cxx @@ -200,6 +200,11 @@ static Standard_Integer geompipe(Draw_Interpretor& , rotate = (Draw::Atoi(a[k++])==1); GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate); aPipe.Perform(Standard_True); + if (!aPipe.IsDone()) + { + cout << "GeomFill_Pipe cannot make a surface" << endl; + return 1; + } Handle(Geom_Surface) Sur=aPipe.Surface(); TopoDS_Face F; if(!Sur.IsNull()) diff --git a/src/GeomFill/GeomFill_Pipe.cxx b/src/GeomFill/GeomFill_Pipe.cxx index 2ff4e72690..6c122e1b12 100644 --- a/src/GeomFill/GeomFill_Pipe.cxx +++ b/src/GeomFill/GeomFill_Pipe.cxx @@ -206,7 +206,7 @@ static Standard_Boolean CheckSense(const TColGeom_SequenceOfCurve& Seq1, //purpose : constructor with no parameters. //======================================================================= -GeomFill_Pipe::GeomFill_Pipe() : myExchUV(Standard_False),myKPart(Standard_False) +GeomFill_Pipe::GeomFill_Pipe() : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); } @@ -219,7 +219,7 @@ GeomFill_Pipe::GeomFill_Pipe() : myExchUV(Standard_False),myKPart(Standard_False GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Standard_Real Radius) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, Radius); @@ -233,7 +233,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const GeomFill_Trihedron Option) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, FirstSect, Option); @@ -247,7 +247,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom2d_Curve)& Path, const Handle(Geom_Surface)& Support, const Handle(Geom_Curve)& FirstSect) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, Support, FirstSect); @@ -261,7 +261,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom2d_Curve)& Path, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& LastSect) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, FirstSect, LastSect); @@ -275,7 +275,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, NSections); @@ -289,7 +289,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& Curve1, const gp_Dir& Direction) - : myExchUV(Standard_False), myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False), myKPart(Standard_False) { Init(Path, Curve1, Direction); } @@ -302,7 +302,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& Curve1, const Handle(Geom_Curve)& Curve2, const Standard_Real Radius) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); Handle(GeomAdaptor_HCurve) AdpPath = @@ -325,7 +325,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Adaptor3d_HCurve)& Path, const Handle(Adaptor3d_HCurve)& Curve1, const Handle(Adaptor3d_HCurve)& Curve2, const Standard_Real Radius) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path,Curve1,Curve2,Radius); @@ -345,7 +345,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Standard_Boolean byACR, const Standard_Boolean rotat) - : myExchUV(Standard_False),myKPart(Standard_False) + : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) // Path : trajectoire // Guide : courbe guide // FirstSect : section @@ -887,11 +887,11 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol, App.UDegree(), App.VDegree()); myError = App.MaxErrorOnSurf(); + myIsDone = Standard_True; } - else { - Standard_ConstructionError::Raise - ("GeomFill_Pipe::Perform : Cannot make a surface"); - } + //else { + // Standard_ConstructionError::Raise ("GeomFill_Pipe::Perform : Cannot make a surface"); + //} } } else if ( (! myLoc.IsNull()) && (! mySec.IsNull()) ) { @@ -901,11 +901,11 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol, if (Sweep.IsDone()) { mySurface = Sweep.Surface(); myError = Sweep.ErrorOnSurface(); + myIsDone = Standard_True; } - else { - Standard_ConstructionError::Raise - ("GeomFill_Pipe::Perform : Cannot make a surface"); - } + //else { + // Standard_ConstructionError::Raise ("GeomFill_Pipe::Perform : Cannot make a surface"); + //} } else { Perform(Standard_True, Polynomial); @@ -978,6 +978,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4() myAdpPath->FirstParameter(), myAdpPath->LastParameter()); Ok = Standard_True; //C'est bien un cylindre + myIsDone = Standard_True; } // ----------- Cas du tore ---------------------------------- else if (myAdpPath->GetType() == GeomAbs_Circle && @@ -1040,6 +1041,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4() myAdpPath->FirstParameter(),myAdpPath->LastParameter(),VV1,VV2); myExchUV = Standard_True; Ok = Standard_True; + myIsDone = Standard_True; } return Ok; @@ -1121,7 +1123,7 @@ void GeomFill_Pipe::ApproxSurf(const Standard_Boolean WithParameters) { #endif } #endif - StdFail_NotDone::Raise("Pipe : App not done"); + //StdFail_NotDone::Raise("Pipe : App not done"); } else { Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, @@ -1138,5 +1140,6 @@ void GeomFill_Pipe::ApproxSurf(const Standard_Boolean WithParameters) { App.VDegree()); Standard_Real t2d; App.TolReached(myError, t2d); + myIsDone = Standard_True; } } diff --git a/src/GeomFill/GeomFill_Pipe.hxx b/src/GeomFill/GeomFill_Pipe.hxx index 7ff433b229..6fea1bca0d 100644 --- a/src/GeomFill/GeomFill_Pipe.hxx +++ b/src/GeomFill/GeomFill_Pipe.hxx @@ -254,6 +254,8 @@ public: //! is plane, cylinder ... this error can be 0. Standard_Real ErrorOnSurf() const; + //! Returns whether approximation was done. + Standard_Boolean IsDone() const; @@ -278,6 +280,7 @@ private: Standard_EXPORT Standard_Boolean KPartT4(); + Standard_Boolean myIsDone; Standard_Real myRadius; Standard_Real myError; Handle(Adaptor3d_HCurve) myAdpPath; diff --git a/src/GeomFill/GeomFill_Pipe.lxx b/src/GeomFill/GeomFill_Pipe.lxx index 6345133d54..1344d09a2f 100644 --- a/src/GeomFill/GeomFill_Pipe.lxx +++ b/src/GeomFill/GeomFill_Pipe.lxx @@ -64,3 +64,12 @@ inline Standard_Real GeomFill_Pipe::ErrorOnSurf() const return myError; } +//======================================================================= +//function : IsDone +//purpose : +//======================================================================= +inline Standard_Boolean GeomFill_Pipe::IsDone() const +{ + return myIsDone; +} + diff --git a/src/GeometryTest/GeometryTest_SurfaceCommands.cxx b/src/GeometryTest/GeometryTest_SurfaceCommands.cxx index cdc55d0c2c..5b5636ffa9 100644 --- a/src/GeometryTest/GeometryTest_SurfaceCommands.cxx +++ b/src/GeometryTest/GeometryTest_SurfaceCommands.cxx @@ -78,7 +78,7 @@ Standard_IMPORT Draw_Viewer dout; //purpose : //======================================================================= -static Standard_Integer sweep (Draw_Interpretor&, +static Standard_Integer sweep (Draw_Interpretor& di, Standard_Integer n, const char** a) { GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet; @@ -148,6 +148,11 @@ static Standard_Integer sweep (Draw_Interpretor&, Pipe.Perform(Tol, Standard_False, GeomAbs_C2, MaxDegree, NbSeg); + if (!Pipe.IsDone()) { + di << "GeomFill_Pipe cannot make a surface\n"; + return 1; + } + DrawTrSurf::Set(a[1], Pipe.Surface()); return 0; @@ -157,7 +162,7 @@ static Standard_Integer sweep (Draw_Interpretor&, //purpose : //======================================================================= -static Standard_Integer tuyau (Draw_Interpretor&, +static Standard_Integer tuyau (Draw_Interpretor& di, Standard_Integer n, const char** a) { if ( n < 4) return 1; @@ -214,6 +219,10 @@ static Standard_Integer tuyau (Draw_Interpretor&, } Pipe.Perform(1.e-4, Standard_False, Cont); + if (!Pipe.IsDone()) { + di << "GeomFill_Pipe cannot make a surface\n"; + return 1; + } DrawTrSurf::Set(a[indice_path-1], Pipe.Surface()); return 0; diff --git a/src/LocOpe/LocOpe_SplitDrafts.cxx b/src/LocOpe/LocOpe_SplitDrafts.cxx index ea3c6b8776..e6418e8fe3 100644 --- a/src/LocOpe/LocOpe_SplitDrafts.cxx +++ b/src/LocOpe/LocOpe_SplitDrafts.cxx @@ -203,6 +203,8 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F, thePipe.GenerateParticularCase(Standard_True); thePipe.Init(theLinePipe,i2s.Line(1)); thePipe.Perform(Standard_True); + if (!thePipe.IsDone()) + Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface"); Handle(Geom_Surface) Spl = thePipe.Surface(); AS.Load(Spl); @@ -415,6 +417,8 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F, thePipe.GenerateParticularCase(Standard_True); thePipe.Init(theLinePipe,C); thePipe.Perform(Standard_True); + if (!thePipe.IsDone()) + Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface"); Handle(Geom_Surface) thePS = thePipe.Surface(); if (thePS->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 0a9849907d..74c8ad23ba 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -402,6 +402,11 @@ static int pipe_OCC9 (Draw_Interpretor& di, aPipe.Perform(Standard_True/*, Standard_True*/); } + if (!aPipe.IsDone()) { + di << "GeomFill_Pipe cannot make a surface\n"; + return 1; + } + Handle(Geom_Surface) aSurf = aPipe.Surface(); DrawTrSurf::Set(a[1], aSurf);