From b939a13923e9630064b6840e1b46ceea8e4dc8d6 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 7 Jul 2020 17:40:50 +0300 Subject: [PATCH] 0031016: Projection of an ellipse is a B-spline in some cases Improve projection of ellipse and circle on a plane in case of the same parametrization of the original curve and the projected one is not necessary. Now the projection is a canonical curve instead of B-spline. --- src/ProjLib/ProjLib_ProjectOnPlane.cxx | 146 +++++++++++++++++++------ tests/bugs/modalg_7/begin | 50 +++++++-- tests/bugs/modalg_7/bug31016_01 | 27 +++++ tests/bugs/modalg_7/bug31016_02 | 29 +++++ tests/bugs/modalg_7/bug31016_03 | 27 +++++ tests/bugs/modalg_7/bug31016_04 | 29 +++++ tests/bugs/modalg_7/bug31016_05 | 27 +++++ tests/bugs/modalg_7/bug31016_06 | 29 +++++ tests/bugs/modalg_7/bug31016_07 | 23 ++++ tests/bugs/modalg_7/bug31016_08 | 25 +++++ tests/bugs/modalg_7/bug31016_09 | 23 ++++ tests/bugs/modalg_7/bug31016_10 | 25 +++++ tests/bugs/modalg_7/bug31016_11 | 23 ++++ tests/bugs/modalg_7/bug31016_12 | 25 +++++ tests/bugs/modalg_7/bug31016_13 | 32 ++++++ tests/bugs/modalg_7/bug31016_14 | 33 ++++++ tests/bugs/modalg_7/bug31016_15 | 32 ++++++ tests/bugs/modalg_7/bug31016_16 | 33 ++++++ tests/bugs/modalg_7/bug31016_17 | 32 ++++++ tests/bugs/modalg_7/bug31016_18 | 33 ++++++ tests/bugs/modalg_7/bug31016_19 | 27 +++++ tests/bugs/modalg_7/bug31016_20 | 28 +++++ tests/bugs/modalg_7/bug31016_21 | 27 +++++ tests/bugs/modalg_7/bug31016_22 | 28 +++++ tests/bugs/modalg_7/bug31016_23 | 27 +++++ tests/bugs/modalg_7/bug31016_24 | 28 +++++ 26 files changed, 826 insertions(+), 42 deletions(-) create mode 100644 tests/bugs/modalg_7/bug31016_01 create mode 100644 tests/bugs/modalg_7/bug31016_02 create mode 100644 tests/bugs/modalg_7/bug31016_03 create mode 100644 tests/bugs/modalg_7/bug31016_04 create mode 100644 tests/bugs/modalg_7/bug31016_05 create mode 100644 tests/bugs/modalg_7/bug31016_06 create mode 100644 tests/bugs/modalg_7/bug31016_07 create mode 100644 tests/bugs/modalg_7/bug31016_08 create mode 100644 tests/bugs/modalg_7/bug31016_09 create mode 100644 tests/bugs/modalg_7/bug31016_10 create mode 100644 tests/bugs/modalg_7/bug31016_11 create mode 100644 tests/bugs/modalg_7/bug31016_12 create mode 100644 tests/bugs/modalg_7/bug31016_13 create mode 100644 tests/bugs/modalg_7/bug31016_14 create mode 100644 tests/bugs/modalg_7/bug31016_15 create mode 100644 tests/bugs/modalg_7/bug31016_16 create mode 100644 tests/bugs/modalg_7/bug31016_17 create mode 100644 tests/bugs/modalg_7/bug31016_18 create mode 100644 tests/bugs/modalg_7/bug31016_19 create mode 100644 tests/bugs/modalg_7/bug31016_20 create mode 100644 tests/bugs/modalg_7/bug31016_21 create mode 100644 tests/bugs/modalg_7/bug31016_22 create mode 100644 tests/bugs/modalg_7/bug31016_23 create mode 100644 tests/bugs/modalg_7/bug31016_24 diff --git a/src/ProjLib/ProjLib_ProjectOnPlane.cxx b/src/ProjLib/ProjLib_ProjectOnPlane.cxx index b059fcadfa..7a876ab7e8 100644 --- a/src/ProjLib/ProjLib_ProjectOnPlane.cxx +++ b/src/ProjLib/ProjLib_ProjectOnPlane.cxx @@ -44,6 +44,9 @@ #include #include #include +#include +#include +#include @@ -516,10 +519,7 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, gp_Ax2 Axis; Standard_Real R1 =0., R2 =0.; - if ( Type != GeomAbs_Line) // on garde le parametrage - myKeepParam = Standard_True; - else // on prend le choix utilisateur. - myKeepParam = KeepParametrization; + myKeepParam = KeepParametrization; switch ( Type) { case GeomAbs_Line: @@ -648,12 +648,14 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, Standard_Real Tol2 = myTolerance*myTolerance; if (VDx.SquareMagnitude() < Tol2 || - VDy.SquareMagnitude() < Tol2 ) { - myIsApprox = Standard_True; + VDy.SquareMagnitude() < Tol2 || + VDx.CrossSquareMagnitude(VDy) < Tol2) + { + myIsApprox = Standard_True; } - if (!myIsApprox && - gp_Dir(VDx).IsNormal(gp_Dir(VDy),Precision::Angular())) { + if (!myIsApprox) + { Dx = gp_Dir(VDx); Dy = gp_Dir(VDy); gp_Pnt O = Axis.Location(); @@ -662,39 +664,93 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, gp_Pnt Py = ProjectPnt(myPlane,myDirection,O.Translated(R2*gp_Vec(Y))); Standard_Real Major = P.Distance(Px); Standard_Real Minor = P.Distance(Py); - gp_Ax2 Axe( P, Dx^Dy,Dx); - if ( Abs( Major - Minor) < Precision::Confusion()) { - myType = GeomAbs_Circle; - gp_Circ Circ(Axe, Major); - GeomCirclePtr = new Geom_Circle(Circ); -// Modified by Sergey KHROMOV - Tue Jan 29 16:57:29 2002 Begin - GeomAdaptor_Curve aGACurve(GeomCirclePtr); - myResult = new GeomAdaptor_HCurve(aGACurve); -// Modified by Sergey KHROMOV - Tue Jan 29 16:57:30 2002 End - } - else if ( Major > Minor) { - myType = GeomAbs_Ellipse; - Elips = gp_Elips( Axe, Major, Minor); - - GeomEllipsePtr = new Geom_Ellipse(Elips) ; + if (myKeepParam) + { + myIsApprox = !gp_Dir(VDx).IsNormal(gp_Dir(VDy), Precision::Angular()); + } + else + { + // Since it is not necessary to keep the same parameter for the point on the original and on the projected curves, + // we will use the following approach to find axes of the projected ellipse and provide the canonical curve: + // https://www.geometrictools.com/Documentation/ParallelProjectionEllipse.pdf + math_Matrix aMatrA(1, 2, 1, 2); + // A = Jp^T * Pr(Je), where + // Pr(Je) - projection of axes of original ellipse to the target plane + // Jp - X and Y axes of the target plane + aMatrA(1, 1) = myPlane.XDirection().XYZ().Dot(VDx.XYZ()); + aMatrA(1, 2) = myPlane.XDirection().XYZ().Dot(VDy.XYZ()); + aMatrA(2, 1) = myPlane.YDirection().XYZ().Dot(VDx.XYZ()); + aMatrA(2, 2) = myPlane.YDirection().XYZ().Dot(VDy.XYZ()); + + math_Matrix aMatrDelta2(1, 2, 1, 2, 0.0); + // | 1/MajorRad^2 0 | + // Delta^2 = | | + // | 0 1/MajorRad^2 | + aMatrDelta2(1, 1) = 1.0 / (R1 * R1); + aMatrDelta2(2, 2) = 1.0 / (R2 * R2); + + math_Matrix aMatrAInv = aMatrA.Inverse(); + math_Matrix aMatrM = aMatrAInv.Transposed() * aMatrDelta2 * aMatrAInv; + + // perform eigenvalues calculation + math_Jacobi anEigenCalc(aMatrM); + if (anEigenCalc.IsDone()) + { + // radii of the projected ellipse + Minor = 1.0 / Sqrt(anEigenCalc.Value(1)); + Major = 1.0 / Sqrt(anEigenCalc.Value(2)); + + // calculate the rotation angle for the plane axes to meet the correct axes of the projected ellipse + // (swap eigenvectors in respect to major and minor axes) + const math_Matrix& anEigenVec = anEigenCalc.Vectors(); + gp_Trsf2d aTrsfInPlane; + aTrsfInPlane.SetValues(anEigenVec(1, 2), anEigenVec(1, 1), 0.0, + anEigenVec(2, 2), anEigenVec(2, 1), 0.0); + gp_Trsf aRot; + aRot.SetRotation(gp_Ax1(P, myPlane.Direction()), aTrsfInPlane.RotationPart()); + + Dx = myPlane.XDirection().Transformed(aRot); + Dy = myPlane.YDirection().Transformed(aRot); + } + else + { + myIsApprox = Standard_True; + } + } + + if (!myIsApprox) + { + gp_Ax2 Axe(P, Dx^Dy, Dx); + + if (Abs(Major - Minor) < Precision::Confusion()) { + myType = GeomAbs_Circle; + gp_Circ Circ(Axe, Major); + GeomCirclePtr = new Geom_Circle(Circ); // Modified by Sergey KHROMOV - Tue Jan 29 16:57:29 2002 Begin - GeomAdaptor_Curve aGACurve(GeomEllipsePtr); - myResult = new GeomAdaptor_HCurve(aGACurve); + GeomAdaptor_Curve aGACurve(GeomCirclePtr); + myResult = new GeomAdaptor_HCurve(aGACurve); // Modified by Sergey KHROMOV - Tue Jan 29 16:57:30 2002 End - } - else { - myIsApprox = Standard_True; - myType = GeomAbs_BSplineCurve; - PerformApprox(myCurve,myPlane,myDirection,ApproxCurve); + } + else if ( Major > Minor) { + myType = GeomAbs_Ellipse; + Elips = gp_Elips( Axe, Major, Minor); + + GeomEllipsePtr = new Geom_Ellipse(Elips); // Modified by Sergey KHROMOV - Tue Jan 29 16:57:29 2002 Begin - GeomAdaptor_Curve aGACurve(ApproxCurve); - myResult = new GeomAdaptor_HCurve(aGACurve); + GeomAdaptor_Curve aGACurve(GeomEllipsePtr); + myResult = new GeomAdaptor_HCurve(aGACurve); // Modified by Sergey KHROMOV - Tue Jan 29 16:57:30 2002 End - } + } + else { + myIsApprox = Standard_True; + } + } } - else { - myIsApprox = Standard_True; + + // No way to build the canonical curve, approximate as B-spline + if (myIsApprox) + { myType = GeomAbs_BSplineCurve; PerformApprox(myCurve,myPlane,myDirection,ApproxCurve); // Modified by Sergey KHROMOV - Tue Jan 29 16:57:29 2002 Begin @@ -702,10 +758,26 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, myResult = new GeomAdaptor_HCurve(aGACurve); // Modified by Sergey KHROMOV - Tue Jan 29 16:57:30 2002 End } + else if (GeomCirclePtr || GeomEllipsePtr) + { + Handle(Geom_Curve) aResultCurve = GeomCirclePtr; + if (aResultCurve.IsNull()) + aResultCurve = GeomEllipsePtr; + // start and end parameters of the projected curve + Standard_Real aParFirst = myCurve->FirstParameter(); + Standard_Real aParLast = myCurve->LastParameter(); + gp_Pnt aPntFirst = ProjectPnt(myPlane, myDirection, myCurve->Value(aParFirst)); + gp_Pnt aPntLast = ProjectPnt(myPlane, myDirection, myCurve->Value(aParLast)); + GeomLib_Tool::Parameter(aResultCurve, aPntFirst, Precision::Confusion(), myFirstPar); + GeomLib_Tool::Parameter(aResultCurve, aPntLast, Precision::Confusion(), myLastPar); + while (myLastPar <= myFirstPar) + myLastPar += myResult->Period(); + } } break; case GeomAbs_Parabola: { + myKeepParam = Standard_True; // P(u) = O + (u*u)/(4*f) * Xc + u * Yc // ==> Q(u) = f(P(u)) // = f(O) + (u*u)/(4*f) * f(Xc) + u * f(Yc) @@ -757,6 +829,7 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, break; case GeomAbs_Hyperbola: { + myKeepParam = Standard_True; // P(u) = O + R1 * Cosh(u) * Xc + R2 * Sinh(u) * Yc // ==> Q(u) = f(P(u)) // = f(O) + R1 * Cosh(u) * f(Xc) + R2 * Sinh(u) * f(Yc) @@ -824,6 +897,7 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, Handle(Geom_BezierCurve) ProjCu = Handle(Geom_BezierCurve)::DownCast(BezierCurvePtr->Copy()); + myKeepParam = Standard_True; myIsApprox = Standard_False; myType = Type; for ( Standard_Integer i = 1; i <= NbPoles; i++) { @@ -847,6 +921,7 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, Handle(Geom_BSplineCurve) ProjectedBSplinePtr = Handle(Geom_BSplineCurve)::DownCast(BSplineCurvePtr->Copy()) ; + myKeepParam = Standard_True; myIsApprox = Standard_False; myType = Type; for ( Standard_Integer i = 1; i <= BSplineCurvePtr->NbPoles(); i++) { @@ -862,6 +937,7 @@ void ProjLib_ProjectOnPlane::Load(const Handle(Adaptor3d_HCurve)& C, break; default: { + myKeepParam = Standard_True; myIsApprox = Standard_True; myType = GeomAbs_BSplineCurve; PerformApprox(myCurve,myPlane,myDirection,ApproxCurve); diff --git a/tests/bugs/modalg_7/begin b/tests/bugs/modalg_7/begin index f40c35f0a3..80bc788a08 100644 --- a/tests/bugs/modalg_7/begin +++ b/tests/bugs/modalg_7/begin @@ -10,11 +10,47 @@ proc OFFSETSHAPE {distance faces calcul type} { uplevel #0 offsetperform result } +proc ProjectCurvePointToPlaneAlongDir {curve param pln {dir {}}} { + upvar $pln p + upvar $curve c + cvalue c $param x y z + if {[llength $dir] == 0 } { + # project to plane along the normal + regexp {Axis :([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} [dump p] full dx dy dz + lappend dir $dx $dy $dz + } + line ln x y z [lindex $dir 0] [lindex $dir 1] [lindex $dir 2] + intersect pt ln p + regexp {Point : ([-0-9.+eE]+), ([-0-9.+eE]+), ([-0-9.+eE]+)} [dump pt] full x y z + + set pntOnPlane {} + lappend pntOnPlane $x $y $z + return $pntOnPlane +} - - - - - - - +proc CheckProjectionToPlane {nbSamples origCurve origParam0 origParam1 projCurve projParam0 projParam1 pln {dir {}} {tolerance 1.e-7}} { + upvar $pln p + upvar $origCurve origC + upvar $projCurve projC + + set isOk 1 + for {set i 0} {$i <= $nbSamples} {incr i} { + set parOrig [expr $origParam0 + ($origParam1 - $origParam0) * $i / $nbSamples] + set parProj [expr $projParam0 + ($projParam1 - $projParam0) * $i / $nbSamples] + + set pnt [ProjectCurvePointToPlaneAlongDir origC $parOrig p $dir] + cvalue projC $parProj X Y Z + + set dx [expr [lindex $pnt 0]-[dval X]] + set dy [expr [lindex $pnt 1]-[dval Y]] + set dz [expr [lindex $pnt 2]-[dval Z]] + + if {[expr $dx*$dx + $dy*$dy + $dz*$dz] < [expr $tolerance*$tolerance]} { + puts "OK: Projection correct" + } else { + puts "ERROR: Projection incorrect" + set isOk 0 + } + } + return $isOk +} diff --git a/tests/bugs/modalg_7/bug31016_01 b/tests/bugs/modalg_7/bug31016_01 new file mode 100644 index 0000000000..f446bbfe96 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_01 @@ -0,0 +1,27 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +plane p 0 0 0 0 1 10 +projonplane r c p 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c 0 p] +parameters r [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r [dval shift] [expr [dval shift]+2*[dval pi]] p]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_02 b/tests/bugs/modalg_7/bug31016_02 new file mode 100644 index 0000000000..3feaaa5eb8 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_02 @@ -0,0 +1,29 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +plane p 0 0 0 0 1 10 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c 0 p $projDir] +parameters r [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r [dval shift] [expr [dval shift]+2*[dval pi]] p $projDir]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_03 b/tests/bugs/modalg_7/bug31016_03 new file mode 100644 index 0000000000..6e137104e0 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_03 @@ -0,0 +1,27 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +circle c 0 0 0 10 +plane p 0 0 0 1 0 1 +projonplane r c p 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c 0 p] +parameters r [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r [dval shift] [expr [dval shift]+2*[dval pi]] p]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_04 b/tests/bugs/modalg_7/bug31016_04 new file mode 100644 index 0000000000..90a241b3c0 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_04 @@ -0,0 +1,29 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } + +circle c 0 0 0 10 +plane p 0 0 0 1 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c 0 p $projDir] +parameters r [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r [dval shift] [expr [dval shift]+2*[dval pi]] p $projDir]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_05 b/tests/bugs/modalg_7/bug31016_05 new file mode 100644 index 0000000000..3177ee9635 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_05 @@ -0,0 +1,27 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +ellipse c 0 0 0 0.866025403784439 0 0.5 0.5 0 -0.866025403784439 20 10 +plane p 0 0 0 0 0 1 +projonplane r c p 0 + +if {![regexp {Circle} [dump r]]} { + puts "ERROR: Projected curve is not a circle" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c 0 p] +parameters r [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r [dval shift] [expr [dval shift]+2*[dval pi]] p]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_06 b/tests/bugs/modalg_7/bug31016_06 new file mode 100644 index 0000000000..5b9c24a5ab --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_06 @@ -0,0 +1,29 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +plane p 0 0 0 0 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c 0 p $projDir] +parameters r [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r [dval shift] [expr [dval shift]+2*[dval pi]] p $projDir]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_07 b/tests/bugs/modalg_7/bug31016_07 new file mode 100644 index 0000000000..9c05fd689e --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_07 @@ -0,0 +1,23 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +plane p 0 0 0 0 1 10 +projonplane r c p 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r 0 [expr 2*[dval pi]] p {} 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_08 b/tests/bugs/modalg_7/bug31016_08 new file mode 100644 index 0000000000..79b282cf8f --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_08 @@ -0,0 +1,25 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +plane p 0 0 0 0 1 10 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r 0 [expr 2*[dval pi]] p $projDir 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_09 b/tests/bugs/modalg_7/bug31016_09 new file mode 100644 index 0000000000..e2aa57772a --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_09 @@ -0,0 +1,23 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +circle c 0 0 0 10 +plane p 0 0 0 1 0 1 +projonplane r c p 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r 0 [expr 2*[dval pi]] p {} 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_10 b/tests/bugs/modalg_7/bug31016_10 new file mode 100644 index 0000000000..164266e769 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_10 @@ -0,0 +1,25 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } + +circle c 0 0 0 10 +plane p 0 0 0 1 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r 0 [expr 2*[dval pi]] p $projDir 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_11 b/tests/bugs/modalg_7/bug31016_11 new file mode 100644 index 0000000000..eff29bc8e2 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_11 @@ -0,0 +1,23 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +ellipse c 0 0 0 0.866025403784439 0 0.5 0.5 0 -0.866025403784439 20 10 +plane p 0 0 0 0 0 1 +projonplane r c p 1 + +if {![regexp {Circle} [dump r]]} { + puts "ERROR: Projected curve is not a circle" +} + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r 0 [expr 2*[dval pi]] p {} 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_12 b/tests/bugs/modalg_7/bug31016_12 new file mode 100644 index 0000000000..d8c1ae564e --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_12 @@ -0,0 +1,25 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +plane p 0 0 0 0 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 1 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +if {[CheckProjectionToPlane 100 c 0 [expr 2*[dval pi]] r 0 [expr 2*[dval pi]] p $projDir 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_13 b/tests/bugs/modalg_7/bug31016_13 new file mode 100644 index 0000000000..204ef081e5 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_13 @@ -0,0 +1,32 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 1 10 +projonplane r c p 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c $startPar p] +trim ru r +parameters ru [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c $startPar $endPar r [dval shift] [expr $endPar-$startPar+[dval shift]] p]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_14 b/tests/bugs/modalg_7/bug31016_14 new file mode 100644 index 0000000000..18727e59ac --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_14 @@ -0,0 +1,33 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 1 10 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c $startPar p $projDir] +trim ru r +parameters ru [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c $startPar $endPar r [dval shift] [expr $endPar-$startPar+[dval shift]] p $projDir]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_15 b/tests/bugs/modalg_7/bug31016_15 new file mode 100644 index 0000000000..d5d1373ae9 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_15 @@ -0,0 +1,32 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set startPar 1 +set endPar 4.5 + +circle c 0 0 0 10 +trim c c $startPar $endPar +plane p 0 0 0 1 0 1 +projonplane r c p 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c $startPar p] +trim ru r +parameters ru [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c $startPar $endPar r [dval shift] [expr $endPar-$startPar+[dval shift]] p]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_16 b/tests/bugs/modalg_7/bug31016_16 new file mode 100644 index 0000000000..ef07e64465 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_16 @@ -0,0 +1,33 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } +set startPar 1 +set endPar 4.5 + +circle c 0 0 0 10 +trim c c $startPar $endPar +plane p 0 0 0 1 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c $startPar p $projDir] +trim ru r +parameters ru [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c $startPar $endPar r [dval shift] [expr $endPar-$startPar+[dval shift]] p $projDir]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_17 b/tests/bugs/modalg_7/bug31016_17 new file mode 100644 index 0000000000..12c4e5e60f --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_17 @@ -0,0 +1,32 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0.866025403784439 0 0.5 0.5 0 -0.866025403784439 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 0 1 +projonplane r c p 0 + +if {![regexp {Circle} [dump r]]} { + puts "ERROR: Projected curve is not a circle" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c $startPar p] +trim ru r +parameters ru [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c $startPar $endPar r [dval shift] [expr $endPar-$startPar+[dval shift]] p]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_18 b/tests/bugs/modalg_7/bug31016_18 new file mode 100644 index 0000000000..a2c20a000e --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_18 @@ -0,0 +1,33 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 0 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +# calculate a parametric shift on the projected curve +set pnt [ProjectCurvePointToPlaneAlongDir c $startPar p $projDir] +trim ru r +parameters ru [lindex $pnt 0] [lindex $pnt 1] [lindex $pnt 2] 0.1 shift + +if {[CheckProjectionToPlane 100 c $startPar $endPar r [dval shift] [expr $endPar-$startPar+[dval shift]] p $projDir]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_19 b/tests/bugs/modalg_7/bug31016_19 new file mode 100644 index 0000000000..1c7471763b --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_19 @@ -0,0 +1,27 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 1 10 +projonplane r c p 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c $startPar $endPar r $startPar $endPar p {} 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_20 b/tests/bugs/modalg_7/bug31016_20 new file mode 100644 index 0000000000..f7afbd1dec --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_20 @@ -0,0 +1,28 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 1 10 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c $startPar $endPar r $startPar $endPar p $projDir 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_21 b/tests/bugs/modalg_7/bug31016_21 new file mode 100644 index 0000000000..6e8cbc0a8e --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_21 @@ -0,0 +1,27 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set startPar 1 +set endPar 4.5 + +circle c 0 0 0 10 +trim c c $startPar $endPar +plane p 0 0 0 1 0 1 +projonplane r c p 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c $startPar $endPar r $startPar $endPar p {} 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_22 b/tests/bugs/modalg_7/bug31016_22 new file mode 100644 index 0000000000..84e87c19ea --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_22 @@ -0,0 +1,28 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } +set startPar 1 +set endPar 4.5 + +circle c 0 0 0 10 +trim c c $startPar $endPar +plane p 0 0 0 1 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 1 + +if {![regexp {BSplineCurve} [dump r]]} { + puts "ERROR: Projected curve is not a B-spline curve" +} + +if {[CheckProjectionToPlane 100 c $startPar $endPar r $startPar $endPar p $projDir 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_23 b/tests/bugs/modalg_7/bug31016_23 new file mode 100644 index 0000000000..04b0d5cbf8 --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_23 @@ -0,0 +1,27 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0.866025403784439 0 0.5 0.5 0 -0.866025403784439 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 0 1 +projonplane r c p 1 + +if {![regexp {Circle} [dump r]]} { + puts "ERROR: Projected curve is not a circle" +} + +if {[CheckProjectionToPlane 100 c $startPar $endPar r $startPar $endPar p {} 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} diff --git a/tests/bugs/modalg_7/bug31016_24 b/tests/bugs/modalg_7/bug31016_24 new file mode 100644 index 0000000000..b733a6dcae --- /dev/null +++ b/tests/bugs/modalg_7/bug31016_24 @@ -0,0 +1,28 @@ +puts "" +puts "==========================================================================" +puts "OCC31016: Projection of an ellipse or a circle is a B-spline in some cases" +puts "==========================================================================" +puts "" + +set projDir { 1 1 1 } +set startPar 1 +set endPar 4.5 + +ellipse c 0 0 0 0 0 1 2 1 0 20 10 +trim c c $startPar $endPar +plane p 0 0 0 0 0 1 +projonplane r c p [lindex $projDir 0] [lindex $projDir 1] [lindex $projDir 2] 1 + +if {![regexp {Ellipse} [dump r]]} { + puts "ERROR: Projected curve is not an ellipse" +} + +if {[CheckProjectionToPlane 100 c $startPar $endPar r $startPar $endPar p $projDir 1.e-6]} { + puts "" + puts "OK: All sample points are projected correctly" + puts "" +} else { + puts "" + puts "ERROR: Projection is incorrect for some points" + puts "" +} -- 2.20.1