From: Artem Zhidkov Date: Fri, 29 May 2020 20:29:47 +0000 (+0300) Subject: Issue #19207: planes of imported STEP not usable X-Git-Tag: V9_5_0rc1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cd3e66b2f07a49646c344406b7236819d53f5ae9;p=modules%2Fshaper.git Issue #19207: planes of imported STEP not usable Make linear B-spline surfaces usable as sketch planes or as planar entities for otheroperations. --- diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt index 3f75a54af..dfed17f15 100644 --- a/src/ConstructionPlugin/CMakeLists.txt +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -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 index 000000000..f4dd3c785 --- /dev/null +++ b/src/ConstructionPlugin/Test/Test19207.py @@ -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())) diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 99d21c307..4ddbe474e 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -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;