Salome HOME
Issue #19207: planes of imported STEP not usable
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 29 May 2020 20:29:47 +0000 (23:29 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 29 May 2020 20:29:47 +0000 (23:29 +0300)
Make linear B-spline surfaces usable as sketch planes or as planar entities for otheroperations.

src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/Test/Test19207.py [new file with mode: 0644]
src/GeomAPI/GeomAPI_Shape.cpp

index 3f75a54afae774dd9d2c590c733f35b85f7dcfd5..dfed17f152c283e6b3c3241f7ba2789a664fef93 100644 (file)
@@ -97,4 +97,5 @@ ADD_UNIT_TESTS(TestAxisCreation.py
                TestPlane.py
                TestPlane_ErrorMsg.py
                TestPlane_FaceValidator.py
+               Test19207.py
 )
diff --git a/src/ConstructionPlugin/Test/Test19207.py b/src/ConstructionPlugin/Test/Test19207.py
new file mode 100644 (file)
index 0000000..f4dd3c7
--- /dev/null
@@ -0,0 +1,36 @@
+# 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()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-27.27564593372983, -98.06529667720862, 118.6032908025252, -158.4943424420008)
+SketchLine_2 = Sketch_1.addLine(48.47982068764622, 136.9061129612801, 209.0029126232743, 12.63448992263632)
+model.do()
+Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")])
+Plane_1 = model.addPlane(Part_1_doc, model.selection("FACE", "Filling_1_1"), 10, False)
+model.end()
+
+from ModelAPI import *
+factory = ModelAPI_Session.get().validators()
+assert(factory.validate(Plane_1.feature()))
index 99d21c30741cc5a9d7e0f54221b6b3c07eca86a2..4ddbe474e83b8a396880f1cf503837213033f630 100644 (file)
@@ -46,6 +46,7 @@
 #include <Geom_Plane.hxx>
 #include <Geom_RectangularTrimmedSurface.hxx>
 #include <Geom_TrimmedCurve.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Iterator.hxx>
@@ -287,15 +288,13 @@ bool GeomAPI_Shape::isPlanar() const
   if(aShapeType == TopAbs_VERTEX) {
     return true;
   } else if(aShapeType == TopAbs_FACE) {
-    const Handle(Geom_Surface)& aSurface = BRep_Tool::Surface(TopoDS::Face(aShape));
-    Handle(Standard_Type) aType = aSurface->DynamicType();
-
-    if(aType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
+    Handle(Geom_Surface) aSurface = BRep_Tool::Surface(TopoDS::Face(aShape));
+    if(aSurface->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
       Handle(Geom_RectangularTrimmedSurface) aTrimSurface =
-        Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
-      aType = aTrimSurface->BasisSurface()->DynamicType();
+          Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
+      aSurface = aTrimSurface->BasisSurface();
     }
-    return (aType == STANDARD_TYPE(Geom_Plane)) == Standard_True;
+    return GeomLib_IsPlanarSurface(aSurface).IsPlanar();
   } else {
     BRepBuilderAPI_FindPlane aFindPlane(aShape);
     bool isFound = aFindPlane.Found() == Standard_True;