1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0026026: XtControl_Reader hangs when processing specific data

Small fix for a specific case (was missing).
This commit is contained in:
anv 2016-12-08 16:24:34 +03:00 committed by apn
parent 851f870162
commit a8b5267725
9 changed files with 77 additions and 27 deletions

View File

@ -535,9 +535,13 @@ void AppBlend_AppSurf::InternalPerform(const Handle(TheLine)& Lin,
for (k=1; k<=NbVPoles; k++) { for (k=1; k<=NbVPoles; k++) {
// pour les courbes rationnelles il faut maintenant diviser // pour les courbes rationnelles il faut maintenant diviser
// les poles par leurs poids respectifs // les poles par leurs poids respectifs
tabPoles->ChangeValue(j,k). tabPoles->ChangeValue(j,k).SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X());
SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X()); Standard_Real aWeight = newtabP2d->Value(k).X();
tabWeights->SetValue(j,k,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++) { for (k=1; k<=NbVPoles; k++) {
// pour les courbes rationnelles il faut maintenant diviser // pour les courbes rationnelles il faut maintenant diviser
// les poles par leurs poids respectifs // les poles par leurs poids respectifs
tabPoles->ChangeValue(j,k). tabPoles->ChangeValue(j,k).SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X());
SetXYZ(newtabP(k).XYZ()/newtabP2d->Value(k).X()); Standard_Real aWeight = newtabP2d->Value(k).X();
tabWeights->SetValue(j,k,newtabP2d->Value(k).X()); if (aWeight < gp::Resolution()) {
done = Standard_False;
return;
}
tabWeights->SetValue(j,k,aWeight);
} }
} }

View File

@ -1114,6 +1114,8 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Path,
// Calcul du tuyau // Calcul du tuyau
GeomFill_Pipe Pipe(HCP, HEdge1, HEdge2, Abs(Offset)); GeomFill_Pipe Pipe(HCP, HEdge1, HEdge2, Abs(Offset));
Pipe.Perform(Tol, Polynomial, Conti); Pipe.Perform(Tol, Polynomial, Conti);
if (!Pipe.IsDone())
Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface");
Standard_Real ErrorPipe = Pipe.ErrorOnSurf(); Standard_Real ErrorPipe = Pipe.ErrorOnSurf();
Handle(Geom_Surface) S = Pipe.Surface(); Handle(Geom_Surface) S = Pipe.Surface();
@ -1581,6 +1583,8 @@ void BRepOffset_Offset::Init(const TopoDS_Edge& Edge,
GeomFill_Pipe Pipe(CP,myOffset); GeomFill_Pipe Pipe(CP,myOffset);
Pipe.Perform(); Pipe.Perform();
if (!Pipe.IsDone())
Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface");
BRepLib_MakeFace MF(Pipe.Surface(), Precision::Confusion()); BRepLib_MakeFace MF(Pipe.Surface(), Precision::Confusion());
myFace = MF.Face(); myFace = MF.Face();

View File

@ -200,6 +200,11 @@ static Standard_Integer geompipe(Draw_Interpretor& ,
rotate = (Draw::Atoi(a[k++])==1); rotate = (Draw::Atoi(a[k++])==1);
GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate); GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate);
aPipe.Perform(Standard_True); aPipe.Perform(Standard_True);
if (!aPipe.IsDone())
{
cout << "GeomFill_Pipe cannot make a surface" << endl;
return 1;
}
Handle(Geom_Surface) Sur=aPipe.Surface(); Handle(Geom_Surface) Sur=aPipe.Surface();
TopoDS_Face F; TopoDS_Face F;
if(!Sur.IsNull()) if(!Sur.IsNull())

View File

@ -206,7 +206,7 @@ static Standard_Boolean CheckSense(const TColGeom_SequenceOfCurve& Seq1,
//purpose : constructor with no parameters. //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(); Init();
} }
@ -219,7 +219,7 @@ GeomFill_Pipe::GeomFill_Pipe() : myExchUV(Standard_False),myKPart(Standard_False
GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
const Standard_Real Radius) const Standard_Real Radius)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
{ {
Init(); Init();
Init(Path, Radius); 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, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& FirstSect,
const GeomFill_Trihedron Option) const GeomFill_Trihedron Option)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
{ {
Init(); Init();
Init(Path, FirstSect, Option); 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, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom2d_Curve)& Path,
const Handle(Geom_Surface)& Support, const Handle(Geom_Surface)& Support,
const Handle(Geom_Curve)& FirstSect) const Handle(Geom_Curve)& FirstSect)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
{ {
Init(); Init();
Init(Path, Support, FirstSect); 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, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& FirstSect,
const Handle(Geom_Curve)& LastSect) const Handle(Geom_Curve)& LastSect)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
{ {
Init(); Init();
Init(Path, FirstSect, LastSect); 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, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
const TColGeom_SequenceOfCurve& NSections) const TColGeom_SequenceOfCurve& NSections)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
{ {
Init(); Init();
Init(Path, NSections); 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, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
const Handle(Geom_Curve)& Curve1, const Handle(Geom_Curve)& Curve1,
const gp_Dir& Direction) const gp_Dir& Direction)
: myExchUV(Standard_False), myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False), myKPart(Standard_False)
{ {
Init(Path, Curve1, Direction); 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)& Curve1,
const Handle(Geom_Curve)& Curve2, const Handle(Geom_Curve)& Curve2,
const Standard_Real Radius) const Standard_Real Radius)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
{ {
Init(); Init();
Handle(GeomAdaptor_HCurve) AdpPath = 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)& Curve1,
const Handle(Adaptor3d_HCurve)& Curve2, const Handle(Adaptor3d_HCurve)& Curve2,
const Standard_Real Radius) const Standard_Real Radius)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
{ {
Init(); Init();
Init(Path,Curve1,Curve2,Radius); Init(Path,Curve1,Curve2,Radius);
@ -345,7 +345,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path,
const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& FirstSect,
const Standard_Boolean byACR, const Standard_Boolean byACR,
const Standard_Boolean rotat) const Standard_Boolean rotat)
: myExchUV(Standard_False),myKPart(Standard_False) : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False)
// Path : trajectoire // Path : trajectoire
// Guide : courbe guide // Guide : courbe guide
// FirstSect : section // FirstSect : section
@ -887,11 +887,11 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol,
App.UDegree(), App.UDegree(),
App.VDegree()); App.VDegree());
myError = App.MaxErrorOnSurf(); myError = App.MaxErrorOnSurf();
myIsDone = Standard_True;
} }
else { //else {
Standard_ConstructionError::Raise // Standard_ConstructionError::Raise ("GeomFill_Pipe::Perform : Cannot make a surface");
("GeomFill_Pipe::Perform : Cannot make a surface"); //}
}
} }
} }
else if ( (! myLoc.IsNull()) && (! mySec.IsNull()) ) { else if ( (! myLoc.IsNull()) && (! mySec.IsNull()) ) {
@ -901,11 +901,11 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol,
if (Sweep.IsDone()) { if (Sweep.IsDone()) {
mySurface = Sweep.Surface(); mySurface = Sweep.Surface();
myError = Sweep.ErrorOnSurface(); myError = Sweep.ErrorOnSurface();
myIsDone = Standard_True;
} }
else { //else {
Standard_ConstructionError::Raise // Standard_ConstructionError::Raise ("GeomFill_Pipe::Perform : Cannot make a surface");
("GeomFill_Pipe::Perform : Cannot make a surface"); //}
}
} }
else { else {
Perform(Standard_True, Polynomial); Perform(Standard_True, Polynomial);
@ -978,6 +978,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4()
myAdpPath->FirstParameter(), myAdpPath->FirstParameter(),
myAdpPath->LastParameter()); myAdpPath->LastParameter());
Ok = Standard_True; //C'est bien un cylindre Ok = Standard_True; //C'est bien un cylindre
myIsDone = Standard_True;
} }
// ----------- Cas du tore ---------------------------------- // ----------- Cas du tore ----------------------------------
else if (myAdpPath->GetType() == GeomAbs_Circle && else if (myAdpPath->GetType() == GeomAbs_Circle &&
@ -1040,6 +1041,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4()
myAdpPath->FirstParameter(),myAdpPath->LastParameter(),VV1,VV2); myAdpPath->FirstParameter(),myAdpPath->LastParameter(),VV1,VV2);
myExchUV = Standard_True; myExchUV = Standard_True;
Ok = Standard_True; Ok = Standard_True;
myIsDone = Standard_True;
} }
return Ok; return Ok;
@ -1121,7 +1123,7 @@ void GeomFill_Pipe::ApproxSurf(const Standard_Boolean WithParameters) {
#endif #endif
} }
#endif #endif
StdFail_NotDone::Raise("Pipe : App not done"); //StdFail_NotDone::Raise("Pipe : App not done");
} }
else { else {
Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots,
@ -1138,5 +1140,6 @@ void GeomFill_Pipe::ApproxSurf(const Standard_Boolean WithParameters) {
App.VDegree()); App.VDegree());
Standard_Real t2d; Standard_Real t2d;
App.TolReached(myError, t2d); App.TolReached(myError, t2d);
myIsDone = Standard_True;
} }
} }

View File

@ -254,6 +254,8 @@ public:
//! is plane, cylinder ... this error can be 0. //! is plane, cylinder ... this error can be 0.
Standard_Real ErrorOnSurf() const; Standard_Real ErrorOnSurf() const;
//! Returns whether approximation was done.
Standard_Boolean IsDone() const;
@ -278,6 +280,7 @@ private:
Standard_EXPORT Standard_Boolean KPartT4(); Standard_EXPORT Standard_Boolean KPartT4();
Standard_Boolean myIsDone;
Standard_Real myRadius; Standard_Real myRadius;
Standard_Real myError; Standard_Real myError;
Handle(Adaptor3d_HCurve) myAdpPath; Handle(Adaptor3d_HCurve) myAdpPath;

View File

@ -64,3 +64,12 @@ inline Standard_Real GeomFill_Pipe::ErrorOnSurf() const
return myError; return myError;
} }
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
inline Standard_Boolean GeomFill_Pipe::IsDone() const
{
return myIsDone;
}

View File

@ -78,7 +78,7 @@ Standard_IMPORT Draw_Viewer dout;
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Integer sweep (Draw_Interpretor&, static Standard_Integer sweep (Draw_Interpretor& di,
Standard_Integer n, const char** a) Standard_Integer n, const char** a)
{ {
GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet; GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet;
@ -148,6 +148,11 @@ static Standard_Integer sweep (Draw_Interpretor&,
Pipe.Perform(Tol, Standard_False, GeomAbs_C2, MaxDegree, NbSeg); 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()); DrawTrSurf::Set(a[1], Pipe.Surface());
return 0; return 0;
@ -157,7 +162,7 @@ static Standard_Integer sweep (Draw_Interpretor&,
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Integer tuyau (Draw_Interpretor&, static Standard_Integer tuyau (Draw_Interpretor& di,
Standard_Integer n, const char** a) Standard_Integer n, const char** a)
{ {
if ( n < 4) return 1; if ( n < 4) return 1;
@ -214,6 +219,10 @@ static Standard_Integer tuyau (Draw_Interpretor&,
} }
Pipe.Perform(1.e-4, Standard_False, Cont); 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()); DrawTrSurf::Set(a[indice_path-1], Pipe.Surface());
return 0; return 0;

View File

@ -203,6 +203,8 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F,
thePipe.GenerateParticularCase(Standard_True); thePipe.GenerateParticularCase(Standard_True);
thePipe.Init(theLinePipe,i2s.Line(1)); thePipe.Init(theLinePipe,i2s.Line(1));
thePipe.Perform(Standard_True); thePipe.Perform(Standard_True);
if (!thePipe.IsDone())
Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface");
Handle(Geom_Surface) Spl = thePipe.Surface(); Handle(Geom_Surface) Spl = thePipe.Surface();
AS.Load(Spl); AS.Load(Spl);
@ -415,6 +417,8 @@ void LocOpe_SplitDrafts::Perform(const TopoDS_Face& F,
thePipe.GenerateParticularCase(Standard_True); thePipe.GenerateParticularCase(Standard_True);
thePipe.Init(theLinePipe,C); thePipe.Init(theLinePipe,C);
thePipe.Perform(Standard_True); thePipe.Perform(Standard_True);
if (!thePipe.IsDone())
Standard_ConstructionError::Raise ("GeomFill_Pipe : Cannot make a surface");
Handle(Geom_Surface) thePS = thePipe.Surface(); Handle(Geom_Surface) thePS = thePipe.Surface();
if (thePS->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { if (thePS->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {

View File

@ -402,6 +402,11 @@ static int pipe_OCC9 (Draw_Interpretor& di,
aPipe.Perform(Standard_True/*, Standard_True*/); 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(); Handle(Geom_Surface) aSurf = aPipe.Surface();
DrawTrSurf::Set(a[1], aSurf); DrawTrSurf::Set(a[1], aSurf);