From f24150b851a4fa78e36bb58b7f8702a32d57a9bd Mon Sep 17 00:00:00 2001 From: nbv Date: Tue, 16 Jan 2018 16:03:01 +0300 Subject: [PATCH] 0029430: [Regression] Curve evaluation at boundary point. Before the fix, BRepAdaptor_CompCurve considered the input wire to be periodic with period LastParameter()-FirstParameter(). Now, method IsPeriodic will always return FALSE because it is impossible to obtain correspondence between the members of BRepAdaptor_CompCurve class and its periodicity status. New behavior has been documented in upgrade-guide. --- dox/dev_guides/upgrade/upgrade.md | 5 +++ src/BRepAdaptor/BRepAdaptor_CompCurve.cxx | 38 +++---------------- src/BRepAdaptor/BRepAdaptor_CompCurve.hxx | 11 ++---- src/BRepFill/BRepFill_PipeShell.cxx | 6 +-- src/QABugs/QABugs_20.cxx | 38 +++++++++++++++++++ tests/bugs/modalg_7/bug29430 | 46 +++++++++++++++++++++++ 6 files changed, 99 insertions(+), 45 deletions(-) create mode 100644 tests/bugs/modalg_7/bug29430 diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 5812e38a2a..970fc6ab96 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1524,3 +1524,8 @@ Multiple changes have been applied to lights management within TKV3d and TKOpenG @subsection upgrade_730_BOPAlgo_Section Changes in BOPAlgo_Section The public method *BuildSection()* in the class *BOPAlgo_Section* has became protected. The methods *Perform()* or *PerformWithFiller()* should be called for construction of the result of SECTION operation. + +@subsection upgrade_730_BRepAdaptor_CompCurve Changes in BRepAdaptor_CompCurve + +The method BRepAdaptor_CompCurve::SetPeriodic has been eliminated. +Since new version, the method BRepAdaptor_CompCurve::IsPeriodic() will always return FALSE. Earlier, it could return TRUE in case if the wire contained only one edge based on periodic curve. diff --git a/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx b/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx index bb72836bda..e4068ac95c 100644 --- a/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx +++ b/src/BRepAdaptor/BRepAdaptor_CompCurve.cxx @@ -46,11 +46,9 @@ BRepAdaptor_CompCurve::BRepAdaptor_CompCurve() : TFirst (0.0), TLast (0.0), PTol (0.0), - myPeriod(0.0), CurIndex(-1), Forward (Standard_False), - IsbyAC (Standard_False), - Periodic(Standard_False) + IsbyAC (Standard_False) { } @@ -60,11 +58,9 @@ BRepAdaptor_CompCurve::BRepAdaptor_CompCurve(const TopoDS_Wire& theWire, TFirst (0.0), TLast (0.0), PTol (0.0), - myPeriod(0.0), CurIndex(-1), Forward (Standard_False), - IsbyAC (theIsAC), - Periodic(Standard_False) + IsbyAC (theIsAC) { Initialize(theWire, theIsAC); } @@ -78,11 +74,9 @@ BRepAdaptor_CompCurve::BRepAdaptor_CompCurve(const TopoDS_Wire& theWire, TFirst (theFirst), TLast (theLast), PTol (theTolerance), - myPeriod(0.0), CurIndex(-1), Forward (Standard_False), - IsbyAC (theIsAC), - Periodic(Standard_False) + IsbyAC (theIsAC) { Initialize(theWire, theIsAC, theFirst, theLast, theTolerance); } @@ -144,13 +138,6 @@ BRepAdaptor_CompCurve::BRepAdaptor_CompCurve(const TopoDS_Wire& theWire, TFirst = 0; TLast = myKnots->Value(myKnots->Length()); - myPeriod = TLast - TFirst; - if (NbEdge == 1) { - Periodic = myCurves->Value(1).IsPeriodic(); - } - else { - Periodic = Standard_False; - } } void BRepAdaptor_CompCurve::Initialize(const TopoDS_Wire& W, @@ -200,15 +187,6 @@ BRepAdaptor_CompCurve::BRepAdaptor_CompCurve(const TopoDS_Wire& theWire, } } - -void BRepAdaptor_CompCurve::SetPeriodic(const Standard_Boolean isPeriodic) -{ - if (myWire.Closed()) { - Periodic = isPeriodic; - } -} - - const TopoDS_Wire& BRepAdaptor_CompCurve::Wire() const { return myWire; @@ -308,13 +286,13 @@ const TopoDS_Wire& BRepAdaptor_CompCurve::Wire() const Standard_Boolean BRepAdaptor_CompCurve::IsPeriodic() const { - return Periodic; + return Standard_False; } Standard_Real BRepAdaptor_CompCurve::Period() const { - return myPeriod; + return (TLast - TFirst); } gp_Pnt BRepAdaptor_CompCurve::Value(const Standard_Real U) const @@ -475,12 +453,6 @@ const TopoDS_Wire& BRepAdaptor_CompCurve::Wire() const Wtest = W+Eps; //Offset to discriminate the nodes - if(Periodic){ - Wtest = ElCLib::InPeriod(Wtest, - 0, - myPeriod); - W = Wtest-Eps; - } // Find the index Standard_Boolean Trouve = Standard_False; diff --git a/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx b/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx index 5de39ef909..ca46e6e36b 100644 --- a/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx +++ b/src/BRepAdaptor/BRepAdaptor_CompCurve.hxx @@ -53,6 +53,9 @@ class Geom_BSplineCurve; //! of the BRep topology like a 3D curve. //! Warning: With this class of curve, C0 and C1 continuities //! are not assumed. So be carful with some algorithm! +//! Please note that BRepAdaptor_CompCurve cannot be +//! periodic curve at all (even if it contains single +//! periodic edge). class BRepAdaptor_CompCurve : public Adaptor3d_Curve { public: @@ -75,10 +78,6 @@ public: //! Sets wire and trimmed parameter. Standard_EXPORT void Initialize (const TopoDS_Wire& W, const Standard_Boolean KnotByCurvilinearAbcissa, const Standard_Real First, const Standard_Real Last, const Standard_Real Tol); - //! Set the flag Periodic. - //! Warning: This method has no effect if the wire is not closed - Standard_EXPORT void SetPeriodic (const Standard_Boolean Periodic); - //! Returns the wire. Standard_EXPORT const TopoDS_Wire& Wire() const; @@ -197,15 +196,11 @@ private: Standard_Real TFirst; Standard_Real TLast; Standard_Real PTol; - Standard_Real myPeriod; Handle(BRepAdaptor_HArray1OfCurve) myCurves; Handle(TColStd_HArray1OfReal) myKnots; Standard_Integer CurIndex; Standard_Boolean Forward; Standard_Boolean IsbyAC; - Standard_Boolean Periodic; - - }; diff --git a/src/BRepFill/BRepFill_PipeShell.cxx b/src/BRepFill/BRepFill_PipeShell.cxx index 65ff2b28a0..01abed3e4e 100644 --- a/src/BRepFill/BRepFill_PipeShell.cxx +++ b/src/BRepFill/BRepFill_PipeShell.cxx @@ -385,10 +385,8 @@ BRepFill_PipeShell::BRepFill_PipeShell(const TopoDS_Wire& Spine) if (Affich) DBRep::Set("theguide", TheGuide); #endif - // transform the guide in a single curve (periodic if posssible) - Handle(BRepAdaptor_HCompCurve) Guide = - new (BRepAdaptor_HCompCurve) (TheGuide); - Guide->ChangeCurve().SetPeriodic(Standard_True); + // transform the guide in a single curve + Handle(BRepAdaptor_HCompCurve) Guide = new (BRepAdaptor_HCompCurve) (TheGuide); if (CurvilinearEquivalence) { // trihedron by curvilinear reduced abscissa if (KeepContact == BRepFill_Contact || diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index 2f014583c4..7a5e33bee5 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -2768,6 +2768,40 @@ static Standard_Integer OCC29371 (Draw_Interpretor& di, Standard_Integer n, cons return 0; } +#include +#include +#include +#include +//======================================================================= +//function : OCC29430 +//purpose : +//======================================================================= +static Standard_Integer OCC29430(Draw_Interpretor& theDI, + Standard_Integer /*theNArg*/, + const char** theArgVal) +{ + const Standard_Real r45 = M_PI / 4.0, r225 = 3.0*M_PI / 4.0; + + GC_MakeArcOfCircle arcMaker(gp_Circ(gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 0.0, 1.0), gp_Dir(1.0, 0.0, 0.0)), 1.0), r45, r225, Standard_True); + BRepBuilderAPI_MakeEdge edgeMaker(arcMaker.Value()); + BRepBuilderAPI_MakeWire wireMaker(edgeMaker.Edge()); + const TopoDS_Wire circle = wireMaker.Wire(); + + DBRep::Set(theArgVal[1], circle); + + BRepAdaptor_CompCurve curve(circle); + theDI << "Curve.FirstParameter() = " << curve.FirstParameter() << "\n"; + theDI << "Curve.LastParameter() = " << curve.LastParameter() << "\n"; + theDI << "Curve.Period() = " << (curve.IsPeriodic()? curve.Period() : 0.0) << "\n"; + const gp_Pnt aStartPt = curve.Value(curve.FirstParameter()); + const gp_Pnt anEndPt = curve.Value(curve.LastParameter()); + + DrawTrSurf::Set(theArgVal[2], aStartPt); + DrawTrSurf::Set(theArgVal[3], anEndPt); + + return 0; +} + void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2798,5 +2832,9 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { theCommands.Add("OCC28131", "OCC28131 name: creates face problematic for offset", __FILE__, OCC28131, group); theCommands.Add("OCC29289", "OCC29289 : searching trigonometric root by Newton iterations", __FILE__, OCC29289, group); theCommands.Add ("OCC29371", "OCC29371", __FILE__, OCC29371, group); + theCommands.Add("OCC29430", "OCC29430 " + " ", + __FILE__, OCC29430, group); + return; } diff --git a/tests/bugs/modalg_7/bug29430 b/tests/bugs/modalg_7/bug29430 new file mode 100644 index 0000000000..b29c40fe85 --- /dev/null +++ b/tests/bugs/modalg_7/bug29430 @@ -0,0 +1,46 @@ +puts "========" +puts "OCC29430" +puts "========" +puts "" +################################################# +# [Regression] Curve evaluation at boundary point. +################################################# + +pload QAcommands + +# After launching the command below we will obtain +# some wire (stored in "result" variable) containing +# a single edge based on arc of circle and its first and last +# 3D-points (p1 and p2 correspondingly) taken from +# composite curve (BRepAdaptor_CompCurve) built on this wire. + +OCC29430 result p1 p2 + +vertex v1 p1 +vertex v2 p2 + +explode result v + +# Now, let's check +# 1. whether p1 and p2 match the vertices of the wire; +# 2. whether p1 and p2 are different points. + +distmini d11 result_1 v1 +distmini d12 result_1 v2 +distmini d21 result_2 v1 +distmini d22 result_2 v2 +distmini dv12 v1 v2 + + +if { ([dval d11_val] > 1.0e-7) && ([dval d21_val] > 1.0e-7) } { + puts "Error: Start point of the wire does not match any its vertex." +} +if { ([dval d12_val] > 1.0e-7) && ([dval d22_val] > 1.0e-7) } { + puts "Error: End point of the wire does not match any its vertex." +} + +if { [dval dv12_val] < 1.0e-7 } { + puts "Error: Start and End points of the wire are the same." +} + +