]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix the projection of periodic B-spline curve to non-orthogonal plane.
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Tue, 21 Jul 2020 08:36:51 +0000 (11:36 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Tue, 21 Jul 2020 08:36:51 +0000 (11:36 +0300)
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/Test/TestProjectionBSplinePeriodicError.py [new file with mode: 0644]

index d21adaf7175e5fe63457f566039b0f22bfa48b75..85715599a3ad59a2f4826293fb927fc86962cdf4 100644 (file)
@@ -335,6 +335,7 @@ ADD_UNIT_TESTS(
   TestProjection.py
   TestProjectionBSpline.py
   TestProjectionBSplinePeriodic.py
+  TestProjectionBSplinePeriodicError.py
   TestProjectionEllipse.py
   TestProjectionEllipticArc.py
   TestProjectionIntoResult.py
index 0ccd6ae4ff5bd36148b038447de7beaca06eba6f..18c9f81c248112f3850cf229782089f9d1ba88ae 100644 (file)
@@ -1284,7 +1284,7 @@ bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
       if (aBSplinePlane) {
         std::shared_ptr<GeomAPI_Dir> aBSplineNormal = aBSplinePlane->direction();
         double aDot = fabs(aNormal->dot(aBSplineNormal));
-        aValid = fabs(aDot - 1.0) <= tolerance * tolerance;
+        aValid = aDot > tolerance * tolerance;
         if (!aValid) {
           // B-spline's plane is orthogonal to the sketch plane,
           // thus, need to check whether B-spline is planar.
diff --git a/src/SketchPlugin/Test/TestProjectionBSplinePeriodicError.py b/src/SketchPlugin/Test/TestProjectionBSplinePeriodicError.py
new file mode 100644 (file)
index 0000000..9463efb
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright (C) 2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Sketch
+Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+
+### Create SketchBSpline
+SketchBSpline_1_poles = [(39.56361839352194, -91.51890167437574),
+                         (70.21199762078012, -72.31423451653721),
+                         (42.28382694294977, -41.98350738641304),
+                         (67.28504300461098, -31.5470157767404),
+                         (50.62385917039768, -3.473688794131494),
+                         (86.7958072325187, 15.01252243343181)
+                        ]
+SketchBSpline_1 = Sketch_1.addSpline(poles = SketchBSpline_1_poles)
+
+### Create SketchBSplinePeriodic
+SketchBSplinePeriodic_1_poles = [(42.08285838974091, 63.92994506772382),
+                                 (45.90231280862586, 109.3628979208621),
+                                 (103.3091534085915, 74.17970450461429),
+                                 (80.27079545144119, 67.78674592116529),
+                                 (119.1440714423075, 30.71538726951938),
+                                 (57.61745686692009, 20.1653082760922)
+                                ]
+SketchBSplinePeriodic_1 = Sketch_1.addSpline(poles = SketchBSplinePeriodic_1_poles, periodic = True)
+model.do()
+
+### Create Sketch
+Sketch_2 = model.addSketch(partSet, model.defaultPlane("YOZ"))
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchBSpline_1"), True)
+SketchBSpline_2 = SketchProjection_1.createdFeature()
+
+### Create SketchProjection
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchBSplinePeriodic_1"), True)
+model.do()
+model.end()
+
+assert(SketchProjection_1.feature().error() == "")
+assert(SketchProjection_2.feature().error() != "")