From b2ec2f5d42a53644a78a724843f67b2b2994d70a Mon Sep 17 00:00:00 2001 From: mgerus Date: Mon, 4 Apr 2022 10:00:24 +0300 Subject: [PATCH] 0031361: Modeling algorithms - An exception arise when building tube * Add status flag to GeomFill_Pipe * Add myIsPerform flag to GeomFill_Pipe * Add checking vectors in GeomFill_CorrectedFrenet * Add boolean return to SetCurve virtual methods * Add test case --- src/GeomFill/GeomFill_ConstantBiNormal.cxx | 8 +- src/GeomFill/GeomFill_ConstantBiNormal.hxx | 4 +- src/GeomFill/GeomFill_CorrectedFrenet.cxx | 58 +++++++------ src/GeomFill/GeomFill_CorrectedFrenet.hxx | 4 +- src/GeomFill/GeomFill_CurveAndTrihedron.cxx | 4 +- src/GeomFill/GeomFill_CurveAndTrihedron.hxx | 4 +- src/GeomFill/GeomFill_DiscreteTrihedron.cxx | 33 +++---- src/GeomFill/GeomFill_DiscreteTrihedron.hxx | 4 +- src/GeomFill/GeomFill_Frenet.cxx | 3 +- src/GeomFill/GeomFill_Frenet.hxx | 4 +- src/GeomFill/GeomFill_GuideTrihedronAC.cxx | 3 +- src/GeomFill/GeomFill_GuideTrihedronAC.hxx | 4 +- src/GeomFill/GeomFill_GuideTrihedronPlan.cxx | 3 +- src/GeomFill/GeomFill_GuideTrihedronPlan.hxx | 4 +- src/GeomFill/GeomFill_LocationDraft.cxx | 5 +- src/GeomFill/GeomFill_LocationDraft.hxx | 4 +- src/GeomFill/GeomFill_LocationGuide.cxx | 3 +- src/GeomFill/GeomFill_LocationGuide.hxx | 4 +- src/GeomFill/GeomFill_LocationLaw.hxx | 5 +- src/GeomFill/GeomFill_Pipe.cxx | 87 +++++++++++-------- src/GeomFill/GeomFill_Pipe.hxx | 12 +-- src/GeomFill/GeomFill_Pipe.lxx | 3 +- src/GeomFill/GeomFill_TrihedronLaw.cxx | 3 +- src/GeomFill/GeomFill_TrihedronLaw.hxx | 5 +- .../GeometryTest_SurfaceCommands.cxx | 4 +- tests/bugs/modalg_7/bug31361 | 11 +++ 26 files changed, 172 insertions(+), 114 deletions(-) create mode 100644 tests/bugs/modalg_7/bug31361 diff --git a/src/GeomFill/GeomFill_ConstantBiNormal.cxx b/src/GeomFill/GeomFill_ConstantBiNormal.cxx index 1873a29388..f7c73f2c5e 100644 --- a/src/GeomFill/GeomFill_ConstantBiNormal.cxx +++ b/src/GeomFill/GeomFill_ConstantBiNormal.cxx @@ -66,12 +66,14 @@ GeomFill_ConstantBiNormal::GeomFill_ConstantBiNormal(const gp_Dir& BiNormal) : B return copy; } - void GeomFill_ConstantBiNormal::SetCurve(const Handle(Adaptor3d_Curve)& C) + Standard_Boolean GeomFill_ConstantBiNormal::SetCurve(const Handle(Adaptor3d_Curve)& C) { + Standard_Boolean isOK = Standard_False; GeomFill_TrihedronLaw::SetCurve(C); - if (! C.IsNull()) { - frenet->SetCurve(C); + if (! C.IsNull()) { + isOK = frenet->SetCurve(C); } + return isOK; } Standard_Boolean GeomFill_ConstantBiNormal::D0(const Standard_Real Param,gp_Vec& Tangent,gp_Vec& Normal,gp_Vec& BiNormal) diff --git a/src/GeomFill/GeomFill_ConstantBiNormal.hxx b/src/GeomFill/GeomFill_ConstantBiNormal.hxx index eae75c66cf..79a77d2ba7 100644 --- a/src/GeomFill/GeomFill_ConstantBiNormal.hxx +++ b/src/GeomFill/GeomFill_ConstantBiNormal.hxx @@ -45,7 +45,9 @@ public: Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE; - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! initialize curve of trihedron law + //! @return Standard_True in case if execution end correctly + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; //! Computes Triedrhon on curve at parameter Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Vec& Tangent, gp_Vec& Normal, gp_Vec& BiNormal) Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_CorrectedFrenet.cxx b/src/GeomFill/GeomFill_CorrectedFrenet.cxx index e650e345f0..a16f352aec 100644 --- a/src/GeomFill/GeomFill_CorrectedFrenet.cxx +++ b/src/GeomFill/GeomFill_CorrectedFrenet.cxx @@ -337,34 +337,36 @@ Handle(GeomFill_TrihedronLaw) GeomFill_CorrectedFrenet::Copy() const return copy; } - void GeomFill_CorrectedFrenet::SetCurve(const Handle(Adaptor3d_Curve)& C) +Standard_Boolean GeomFill_CorrectedFrenet::SetCurve(const Handle(Adaptor3d_Curve)& C) { - GeomFill_TrihedronLaw::SetCurve(C); - if (! C.IsNull()) { + if (! C.IsNull()) + { frenet->SetCurve(C); GeomAbs_CurveType type; type = C->GetType(); - switch (type) { + switch (type) + { case GeomAbs_Circle: case GeomAbs_Ellipse: case GeomAbs_Hyperbola: case GeomAbs_Parabola: case GeomAbs_Line: - { - // No probleme isFrenet - isFrenet = Standard_True; - break; - } - default : - { - // We have to search singularities - isFrenet = Standard_True; - Init(); - } + { + // No probleme isFrenet + isFrenet = Standard_True; + break; + } + default : + { + // We have to search singularities + isFrenet = Standard_True; + Init(); + } } } + return isFrenet; } @@ -438,16 +440,20 @@ Handle(GeomFill_TrihedronLaw) GeomFill_CorrectedFrenet::Copy() const TLaw = EvolAroundT; //OCC78 Standard_Integer iEnd = SeqPoles.Length(); - HArrPoles = new TColStd_HArray1OfReal(1, iEnd); - HArrAngle = new TColStd_HArray1OfReal(1, iEnd); - HArrTangent = new TColgp_HArray1OfVec(1, iEnd); - HArrNormal = new TColgp_HArray1OfVec(1, iEnd); - for(i = 1; i <= iEnd; i++){ - HArrPoles->ChangeValue(i) = SeqPoles(i); - HArrAngle->ChangeValue(i) = SeqAngle(i); - HArrTangent->ChangeValue(i) = SeqTangent(i); - HArrNormal->ChangeValue(i) = SeqNormal(i); - }; + if (iEnd != 0) + { + HArrPoles = new TColStd_HArray1OfReal(1, iEnd); + HArrAngle = new TColStd_HArray1OfReal(1, iEnd); + HArrTangent = new TColgp_HArray1OfVec(1, iEnd); + HArrNormal = new TColgp_HArray1OfVec(1, iEnd); + for (i = 1; i <= iEnd; i++) { + HArrPoles->ChangeValue(i) = SeqPoles(i); + HArrAngle->ChangeValue(i) = SeqAngle(i); + HArrTangent->ChangeValue(i) = SeqTangent(i); + HArrNormal->ChangeValue(i) = SeqNormal(i); + }; + } + #ifdef DRAW if (Affich) { @@ -612,7 +618,7 @@ Standard_Real GeomFill_CorrectedFrenet::CalcAngleAT(const gp_Vec& Tangent, const Standard_Real angle; gp_Vec Normal_rot, cross; angle = Tangent.Angle(prevTangent); - if (Abs(angle) > Precision::Angular()) { + if (Abs(angle) > Precision::Angular() && Abs(angle) < M_PI - Precision::Angular()) { cross = Tangent.Crossed(prevTangent).Normalized(); Normal_rot = Normal + sin(angle)*cross.Crossed(Normal) + (1 - cos(angle))*cross.Crossed(cross.Crossed(Normal)); diff --git a/src/GeomFill/GeomFill_CorrectedFrenet.hxx b/src/GeomFill/GeomFill_CorrectedFrenet.hxx index eccd1595a1..4e51bea896 100644 --- a/src/GeomFill/GeomFill_CorrectedFrenet.hxx +++ b/src/GeomFill/GeomFill_CorrectedFrenet.hxx @@ -52,7 +52,9 @@ public: Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE; - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! initialize curve of frenet law + //! @return Standard_True in case if execution end correctly + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; Standard_EXPORT virtual void SetInterval (const Standard_Real First, const Standard_Real Last) Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_CurveAndTrihedron.cxx b/src/GeomFill/GeomFill_CurveAndTrihedron.cxx index fce6abc5b3..dfee3a53b2 100644 --- a/src/GeomFill/GeomFill_CurveAndTrihedron.cxx +++ b/src/GeomFill/GeomFill_CurveAndTrihedron.cxx @@ -63,11 +63,11 @@ Handle(GeomFill_LocationLaw) GeomFill_CurveAndTrihedron::Copy() const //Function: SetCurve //Purpose : //================================================================== - void GeomFill_CurveAndTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C) + Standard_Boolean GeomFill_CurveAndTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C) { myCurve = C; myTrimmed = C; - myLaw->SetCurve(C); + return myLaw->SetCurve(C); } const Handle(Adaptor3d_Curve)& GeomFill_CurveAndTrihedron::GetCurve() const diff --git a/src/GeomFill/GeomFill_CurveAndTrihedron.hxx b/src/GeomFill/GeomFill_CurveAndTrihedron.hxx index c035a47b6a..c2d4a74aea 100644 --- a/src/GeomFill/GeomFill_CurveAndTrihedron.hxx +++ b/src/GeomFill/GeomFill_CurveAndTrihedron.hxx @@ -52,7 +52,9 @@ public: Standard_EXPORT GeomFill_CurveAndTrihedron(const Handle(GeomFill_TrihedronLaw)& Trihedron); - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! initialize curve of trihedron law + //! @return Standard_True in case if execution end correctly + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_DiscreteTrihedron.cxx b/src/GeomFill/GeomFill_DiscreteTrihedron.cxx index 50f80df654..129aa83e0b 100755 --- a/src/GeomFill/GeomFill_DiscreteTrihedron.cxx +++ b/src/GeomFill/GeomFill_DiscreteTrihedron.cxx @@ -61,33 +61,36 @@ Handle(GeomFill_TrihedronLaw) GeomFill_DiscreteTrihedron::Copy() const //purpose : //======================================================================= -void GeomFill_DiscreteTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C) +Standard_Boolean GeomFill_DiscreteTrihedron::SetCurve(const Handle(Adaptor3d_Curve)& C) { GeomFill_TrihedronLaw::SetCurve(C); - if (! C.IsNull()) { + if (! C.IsNull()) + { GeomAbs_CurveType type; type = C->GetType(); - switch (type) { + switch (type) + { case GeomAbs_Circle: case GeomAbs_Ellipse: case GeomAbs_Hyperbola: case GeomAbs_Parabola: case GeomAbs_Line: - { - // No problem - myUseFrenet = Standard_True; - myFrenet->SetCurve(C); - break; - } + { + // No problem + myUseFrenet = Standard_True; + myFrenet->SetCurve(C); + break; + } default : - { - myUseFrenet = Standard_False; - // We have to fill and - Init(); - break; - } + { + myUseFrenet = Standard_False; + // We have to fill and + Init(); + break; + } } } + return myUseFrenet; } //======================================================================= diff --git a/src/GeomFill/GeomFill_DiscreteTrihedron.hxx b/src/GeomFill/GeomFill_DiscreteTrihedron.hxx index 2c19b64260..54c4785687 100644 --- a/src/GeomFill/GeomFill_DiscreteTrihedron.hxx +++ b/src/GeomFill/GeomFill_DiscreteTrihedron.hxx @@ -51,7 +51,9 @@ public: Standard_EXPORT void Init(); - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! initialize curve of trihedron law + //! @return Standard_True in case if execution end correctly + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; //! compute Trihedron on curve at parameter Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Vec& Tangent, gp_Vec& Normal, gp_Vec& BiNormal) Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_Frenet.cxx b/src/GeomFill/GeomFill_Frenet.cxx index a541ddcf34..7f7af57828 100644 --- a/src/GeomFill/GeomFill_Frenet.cxx +++ b/src/GeomFill/GeomFill_Frenet.cxx @@ -117,7 +117,7 @@ Handle(GeomFill_TrihedronLaw) GeomFill_Frenet::Copy() const //purpose : //======================================================================= - void GeomFill_Frenet::SetCurve(const Handle(Adaptor3d_Curve)& C) +Standard_Boolean GeomFill_Frenet::SetCurve(const Handle(Adaptor3d_Curve)& C) { GeomFill_TrihedronLaw::SetCurve(C); if (! C.IsNull()) { @@ -141,6 +141,7 @@ Handle(GeomFill_TrihedronLaw) GeomFill_Frenet::Copy() const } } } + return Standard_True; } //======================================================================= diff --git a/src/GeomFill/GeomFill_Frenet.hxx b/src/GeomFill/GeomFill_Frenet.hxx index 45560697b7..b87b8ed937 100644 --- a/src/GeomFill/GeomFill_Frenet.hxx +++ b/src/GeomFill/GeomFill_Frenet.hxx @@ -47,7 +47,9 @@ public: Standard_EXPORT void Init(); - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! initialize curve of frenet law + //! @return Standard_True + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; //! compute Triedrhon on curve at parameter Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Vec& Tangent, gp_Vec& Normal, gp_Vec& BiNormal) Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_GuideTrihedronAC.cxx b/src/GeomFill/GeomFill_GuideTrihedronAC.cxx index 909bee101b..f5c4cd054d 100644 --- a/src/GeomFill/GeomFill_GuideTrihedronAC.cxx +++ b/src/GeomFill/GeomFill_GuideTrihedronAC.cxx @@ -292,7 +292,7 @@ GeomFill_GuideTrihedronAC::GeomFill_GuideTrihedronAC(const Handle(Adaptor3d_Curv //function : SetCurve //purpose : //======================================================================= - void GeomFill_GuideTrihedronAC::SetCurve(const Handle(Adaptor3d_Curve)& C) + Standard_Boolean GeomFill_GuideTrihedronAC::SetCurve(const Handle(Adaptor3d_Curve)& C) { myCurve = C; myTrimmed = C; @@ -301,6 +301,7 @@ GeomFill_GuideTrihedronAC::GeomFill_GuideTrihedronAC(const Handle(Adaptor3d_Curv L = myCurveAC->GetLength(); // CorrectOrient(myGuide); } + return Standard_True; } diff --git a/src/GeomFill/GeomFill_GuideTrihedronAC.hxx b/src/GeomFill/GeomFill_GuideTrihedronAC.hxx index b9a66f6e05..be3e8957c4 100644 --- a/src/GeomFill/GeomFill_GuideTrihedronAC.hxx +++ b/src/GeomFill/GeomFill_GuideTrihedronAC.hxx @@ -44,7 +44,9 @@ public: Standard_EXPORT GeomFill_GuideTrihedronAC(const Handle(Adaptor3d_Curve)& guide); - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! initialize curve of trihedron law + //! @return Standard_True + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx b/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx index 2030c32f28..ed8458a869 100644 --- a/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx +++ b/src/GeomFill/GeomFill_GuideTrihedronPlan.cxx @@ -197,10 +197,11 @@ GeomFill_GuideTrihedronPlan::GeomFill_GuideTrihedronPlan (const Handle(Adaptor3d //function : SetCurve //purpose : calculation of trihedron //======================================================================= -void GeomFill_GuideTrihedronPlan::SetCurve(const Handle(Adaptor3d_Curve)& C) +Standard_Boolean GeomFill_GuideTrihedronPlan::SetCurve(const Handle(Adaptor3d_Curve)& C) { myCurve = C; if (!myCurve.IsNull()) Init(); + return Standard_True; } //======================================================================= diff --git a/src/GeomFill/GeomFill_GuideTrihedronPlan.hxx b/src/GeomFill/GeomFill_GuideTrihedronPlan.hxx index 7d3577dcba..6a72aad644 100644 --- a/src/GeomFill/GeomFill_GuideTrihedronPlan.hxx +++ b/src/GeomFill/GeomFill_GuideTrihedronPlan.hxx @@ -48,7 +48,9 @@ public: Standard_EXPORT GeomFill_GuideTrihedronPlan(const Handle(Adaptor3d_Curve)& theGuide); - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& thePath) Standard_OVERRIDE; + //! initialize curve of trihedron law + //! @return Standard_True in case if execution end correctly + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& thePath) Standard_OVERRIDE; Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_LocationDraft.cxx b/src/GeomFill/GeomFill_LocationDraft.cxx index b2a874dc26..93fb2d8f93 100644 --- a/src/GeomFill/GeomFill_LocationDraft.cxx +++ b/src/GeomFill/GeomFill_LocationDraft.cxx @@ -105,13 +105,14 @@ GeomFill_LocationDraft::GeomFill_LocationDraft //Purpose : Calcul des poles sur la surfaces d'arret (intersection // entre la generatrice et la surface en myNbPts points de la section) //================================================================== - void GeomFill_LocationDraft::SetCurve(const Handle(Adaptor3d_Curve)& C) + Standard_Boolean GeomFill_LocationDraft::SetCurve(const Handle(Adaptor3d_Curve)& C) { myCurve = C; myTrimmed = C; - myLaw->SetCurve(C); + Standard_Boolean isOK = myLaw->SetCurve(C); Prepare(); + return isOK; } //================================================================== diff --git a/src/GeomFill/GeomFill_LocationDraft.hxx b/src/GeomFill/GeomFill_LocationDraft.hxx index 7a1afa8439..d8fea7cdac 100644 --- a/src/GeomFill/GeomFill_LocationDraft.hxx +++ b/src/GeomFill/GeomFill_LocationDraft.hxx @@ -46,7 +46,9 @@ public: Standard_EXPORT void SetAngle (const Standard_Real Angle); - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! calculation of poles on locking surfaces (the intersection between the generatrixand the surface at the cross - section points myNbPts) + //! @return Standard_True in case if execution end correctly + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_LocationGuide.cxx b/src/GeomFill/GeomFill_LocationGuide.cxx index 17c2aca807..23d29741b8 100644 --- a/src/GeomFill/GeomFill_LocationGuide.cxx +++ b/src/GeomFill/GeomFill_LocationGuide.cxx @@ -537,7 +537,7 @@ static void InGoodPeriod(const Standard_Real Prec, //Purpose : Calcul des poles sur la surface d'arret (intersection // courbe guide / surface de revolution en myNbPts points) //================================================================== - void GeomFill_LocationGuide::SetCurve(const Handle(Adaptor3d_Curve)& C) +Standard_Boolean GeomFill_LocationGuide::SetCurve(const Handle(Adaptor3d_Curve)& C) { Standard_Real LastAngle; myCurve = C; @@ -550,6 +550,7 @@ static void InGoodPeriod(const Standard_Real Prec, if (rotation) SetRotation(myPoles2d->Value(1,1).X(), LastAngle); } + return myStatus == GeomFill_PipeOk; } //================================================================== diff --git a/src/GeomFill/GeomFill_LocationGuide.hxx b/src/GeomFill/GeomFill_LocationGuide.hxx index 12a7a47850..ea2c23c210 100644 --- a/src/GeomFill/GeomFill_LocationGuide.hxx +++ b/src/GeomFill/GeomFill_LocationGuide.hxx @@ -56,7 +56,9 @@ public: Standard_EXPORT void EraseRotation(); - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; + //! calculating poles on a surface (courbe guide / the surface of rotation in points myNbPts) + //! @return Standard_True + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) Standard_OVERRIDE; Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const Standard_OVERRIDE; diff --git a/src/GeomFill/GeomFill_LocationLaw.hxx b/src/GeomFill/GeomFill_LocationLaw.hxx index 38f020a9cd..b10cda48de 100644 --- a/src/GeomFill/GeomFill_LocationLaw.hxx +++ b/src/GeomFill/GeomFill_LocationLaw.hxx @@ -38,9 +38,8 @@ class GeomFill_LocationLaw : public Standard_Transient { public: - - - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C) = 0; + //! initialize curve of location law + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C) = 0; Standard_EXPORT virtual const Handle(Adaptor3d_Curve)& GetCurve() const = 0; diff --git a/src/GeomFill/GeomFill_Pipe.cxx b/src/GeomFill/GeomFill_Pipe.cxx index 6a25780047..bd7c1e16b9 100644 --- a/src/GeomFill/GeomFill_Pipe.cxx +++ b/src/GeomFill/GeomFill_Pipe.cxx @@ -205,7 +205,7 @@ static Standard_Boolean CheckSense(const TColGeom_SequenceOfCurve& Seq1, //purpose : constructor with no parameters. //======================================================================= -GeomFill_Pipe::GeomFill_Pipe() : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) +GeomFill_Pipe::GeomFill_Pipe() : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); } @@ -218,7 +218,7 @@ GeomFill_Pipe::GeomFill_Pipe() : myIsDone(Standard_False),myExchUV(Standard_Fals GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Standard_Real Radius) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, Radius); @@ -232,7 +232,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) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, FirstSect, Option); @@ -246,7 +246,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) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, Support, FirstSect); @@ -260,7 +260,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) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, FirstSect, LastSect); @@ -274,7 +274,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path, NSections); @@ -288,7 +288,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) - : myIsDone(Standard_False),myExchUV(Standard_False), myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False), myKPart(Standard_False) { Init(Path, Curve1, Direction); } @@ -301,7 +301,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& Curve1, const Handle(Geom_Curve)& Curve2, const Standard_Real Radius) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); Handle(GeomAdaptor_Curve) AdpPath = @@ -324,7 +324,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Adaptor3d_Curve)& Path, const Handle(Adaptor3d_Curve)& Curve1, const Handle(Adaptor3d_Curve)& Curve2, const Standard_Real Radius) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) { Init(); Init(Path,Curve1,Curve2,Radius); @@ -344,7 +344,7 @@ GeomFill_Pipe::GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Standard_Boolean byACR, const Standard_Boolean rotat) - : myIsDone(Standard_False),myExchUV(Standard_False),myKPart(Standard_False) + : myStatus(GeomFill_PipeNotOk), myExchUV(Standard_False),myKPart(Standard_False) // Path : trajectoire // Guide : courbe guide // FirstSect : section @@ -751,31 +751,37 @@ void GeomFill_Pipe::Init(const Handle(Geom_Curve)& Path, if (!TLaw.IsNull()) { myLoc = new (GeomFill_CurveAndTrihedron) (TLaw); - myLoc->SetCurve(myAdpPath); - TColGeom_SequenceOfCurve SeqC; - TColStd_SequenceOfReal SeqP; - SeqC.Clear(); - SeqP.Clear(); - // sequence des sections - GeomFill_SectionPlacement Pl1(myLoc, FirstSect); - Pl1.Perform(first,Precision::Confusion()); - SeqC.Append(Pl1.Section(Standard_False)); - GeomFill_SectionPlacement Pl2(myLoc, LastSect); - Pl2.Perform(first,Precision::Confusion()); - SeqC.Append(Pl2.Section(Standard_False)); - // sequence des parametres associes - SeqP.Append(first); - SeqP.Append(last); - // verification de l'orientation - TColGeom_SequenceOfCurve NewSeq; - if (CheckSense(SeqC,NewSeq)) SeqC = NewSeq; + if (!(myLoc->SetCurve(myAdpPath))) + { + myStatus = GeomFill_ImpossibleContact; + return; + } - // creation de la NSections - Standard_Real deb,fin; - deb = SeqC.First()->FirstParameter(); - fin = SeqC.First()->LastParameter(); - mySec = new (GeomFill_NSections) (SeqC,SeqP,deb,fin,first,last); + TColGeom_SequenceOfCurve SeqC; + TColStd_SequenceOfReal SeqP; + SeqC.Clear(); + SeqP.Clear(); + // sequence of sections + GeomFill_SectionPlacement Pl1(myLoc, FirstSect); + Pl1.Perform(first, Precision::Confusion()); + SeqC.Append(Pl1.Section(Standard_False)); + GeomFill_SectionPlacement Pl2(myLoc, LastSect); + Pl2.Perform(first, Precision::Confusion()); + SeqC.Append(Pl2.Section(Standard_False)); + // sequence of associated parameters + SeqP.Append(first); + SeqP.Append(last); + + // orientation verification + TColGeom_SequenceOfCurve NewSeq; + if (CheckSense(SeqC, NewSeq)) SeqC = NewSeq; + + // creation of the NSections + Standard_Real deb, fin; + deb = SeqC.First()->FirstParameter(); + fin = SeqC.First()->LastParameter(); + mySec = new (GeomFill_NSections) (SeqC, SeqP, deb, fin, first, last); } } @@ -831,6 +837,11 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol, const Standard_Integer DegMax, const Standard_Integer NbMaxSegment) { + if (myStatus == GeomFill_ImpossibleContact) + { + return; + } + GeomAbs_Shape TheConti; switch (Conti) { case GeomAbs_C0: @@ -884,7 +895,7 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol, App.UDegree(), App.VDegree()); myError = App.MaxErrorOnSurf(); - myIsDone = Standard_True; + myStatus = GeomFill_PipeOk; } //else { // throw Standard_ConstructionError("GeomFill_Pipe::Perform : Cannot make a surface"); @@ -898,7 +909,7 @@ void GeomFill_Pipe::Perform(const Standard_Real Tol, if (Sweep.IsDone()) { mySurface = Sweep.Surface(); myError = Sweep.ErrorOnSurface(); - myIsDone = Standard_True; + myStatus = GeomFill_PipeOk; } //else { // throw Standard_ConstructionError("GeomFill_Pipe::Perform : Cannot make a surface"); @@ -975,7 +986,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4() myAdpPath->FirstParameter(), myAdpPath->LastParameter()); Ok = Standard_True; //C'est bien un cylindre - myIsDone = Standard_True; + myStatus = GeomFill_PipeOk; } // ----------- Cas du tore ---------------------------------- else if (myAdpPath->GetType() == GeomAbs_Circle && @@ -1038,7 +1049,7 @@ Standard_Boolean GeomFill_Pipe::KPartT4() myAdpPath->FirstParameter(),myAdpPath->LastParameter(),VV1,VV2); myExchUV = Standard_True; Ok = Standard_True; - myIsDone = Standard_True; + myStatus = GeomFill_PipeOk; } return Ok; @@ -1137,6 +1148,6 @@ void GeomFill_Pipe::ApproxSurf(const Standard_Boolean WithParameters) { App.VDegree()); Standard_Real t2d; App.TolReached(myError, t2d); - myIsDone = Standard_True; + myStatus = GeomFill_PipeOk; } } diff --git a/src/GeomFill/GeomFill_Pipe.hxx b/src/GeomFill/GeomFill_Pipe.hxx index 0679fe099b..4a88b3e168 100644 --- a/src/GeomFill/GeomFill_Pipe.hxx +++ b/src/GeomFill/GeomFill_Pipe.hxx @@ -21,6 +21,7 @@ #include #include #include +#include class Geom_Surface; class GeomFill_LocationLaw; @@ -249,7 +250,11 @@ public: //! Returns whether approximation was done. Standard_Boolean IsDone() const; - + //! Returns execution status + GeomFill_PipeError GetStatus() const + { + return myStatus; + } protected: @@ -271,8 +276,7 @@ private: Standard_EXPORT Standard_Boolean KPartT4(); - - Standard_Boolean myIsDone; + GeomFill_PipeError myStatus;//!< Execution status Standard_Real myRadius; Standard_Real myError; Handle(Adaptor3d_Curve) myAdpPath; @@ -285,8 +289,6 @@ private: Standard_Boolean myExchUV; Standard_Boolean myKPart; Standard_Boolean myPolynomial; - - }; diff --git a/src/GeomFill/GeomFill_Pipe.lxx b/src/GeomFill/GeomFill_Pipe.lxx index 1344d09a2f..07cd0fa9b4 100644 --- a/src/GeomFill/GeomFill_Pipe.lxx +++ b/src/GeomFill/GeomFill_Pipe.lxx @@ -70,6 +70,5 @@ inline Standard_Real GeomFill_Pipe::ErrorOnSurf() const //======================================================================= inline Standard_Boolean GeomFill_Pipe::IsDone() const { - return myIsDone; + return myStatus == GeomFill_PipeOk; } - diff --git a/src/GeomFill/GeomFill_TrihedronLaw.cxx b/src/GeomFill/GeomFill_TrihedronLaw.cxx index 1a62448f68..853e513e37 100644 --- a/src/GeomFill/GeomFill_TrihedronLaw.cxx +++ b/src/GeomFill/GeomFill_TrihedronLaw.cxx @@ -24,10 +24,11 @@ IMPLEMENT_STANDARD_RTTIEXT(GeomFill_TrihedronLaw,Standard_Transient) -void GeomFill_TrihedronLaw::SetCurve(const Handle(Adaptor3d_Curve)& C) +Standard_Boolean GeomFill_TrihedronLaw::SetCurve(const Handle(Adaptor3d_Curve)& C) { myCurve = C; myTrimmed = myCurve; + return Standard_True; } //================================================================== diff --git a/src/GeomFill/GeomFill_TrihedronLaw.hxx b/src/GeomFill/GeomFill_TrihedronLaw.hxx index 2e9972743a..87e59f3da7 100644 --- a/src/GeomFill/GeomFill_TrihedronLaw.hxx +++ b/src/GeomFill/GeomFill_TrihedronLaw.hxx @@ -34,8 +34,9 @@ class GeomFill_TrihedronLaw : public Standard_Transient public: - - Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_Curve)& C); + //! initialize curve of trihedron law + //! @return Standard_True + Standard_EXPORT virtual Standard_Boolean SetCurve (const Handle(Adaptor3d_Curve)& C); Standard_EXPORT virtual Handle(GeomFill_TrihedronLaw) Copy() const = 0; diff --git a/src/GeometryTest/GeometryTest_SurfaceCommands.cxx b/src/GeometryTest/GeometryTest_SurfaceCommands.cxx index 5415293acc..766031a3eb 100644 --- a/src/GeometryTest/GeometryTest_SurfaceCommands.cxx +++ b/src/GeometryTest/GeometryTest_SurfaceCommands.cxx @@ -237,8 +237,8 @@ static Standard_Integer tuyau (Draw_Interpretor& di, Pipe.Perform(1.e-4, Standard_False, Cont); if (!Pipe.IsDone()) { - di << "GeomFill_Pipe cannot make a surface\n"; - return 1; + di << "Error: GeomFill_Pipe cannot make a surface\n"; + return 0; } Standard_Real Accuracy = Pipe.ErrorOnSurf(); diff --git a/tests/bugs/modalg_7/bug31361 b/tests/bugs/modalg_7/bug31361 new file mode 100644 index 0000000000..4a143b7cc2 --- /dev/null +++ b/tests/bugs/modalg_7/bug31361 @@ -0,0 +1,11 @@ +puts "=================================================" +puts "0031361: Modeling algorithms - A crash arise when building tube" +puts "=================================================" +puts "" + +puts "REQUIRED ALL: Error: GeomFill_Pipe cannot make a surface" + +circle c1 0 0 0 10 +circle c2 0 100 0 10 +beziercurve curve 4 0 0 0 100 0 0 100 100 0 0 100 0 +tuyau t curve c1 c2