X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=e114d961c424f65983dd49dd54d98fb09ac0c045;hb=77ce6d35ac8d2f0fdaecb4f23e0870bf74e36103;hp=c03fd9d7aede5337b5164dcc3ff57705ce47d210;hpb=9afbc5fb015e5ff91689e1ef3f4da286347fbda5;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index c03fd9d7a..e114d961c 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2023 CEA, EDF +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -326,23 +326,50 @@ bool GeomAPI_Shape::isPlanar() const BRepBuilderAPI_FindPlane aFindPlane(aShape); bool isFound = aFindPlane.Found() == Standard_True; - if(!isFound && aShapeType == TopAbs_EDGE) { - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aFirst, aLast); - Handle(Standard_Type) aType = aCurve->DynamicType(); + if(!isFound) { - if(aType == STANDARD_TYPE(Geom_TrimmedCurve)) { - Handle(Geom_TrimmedCurve) aTrimCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve); - aType = aTrimCurve->BasisCurve()->DynamicType(); - } + auto checkEdge = [](const TopoDS_Shape& theShape){ + if(theShape.ShapeType()!= TopAbs_EDGE) + return false; + + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(theShape), aFirst, aLast); + Handle(Standard_Type) aType = aCurve->DynamicType(); + if(aType == STANDARD_TYPE(Geom_TrimmedCurve)) { + Handle(Geom_TrimmedCurve) aTrimCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve); + aType = aTrimCurve->BasisCurve()->DynamicType(); + } - if(aType == STANDARD_TYPE(Geom_Line) - || aType == STANDARD_TYPE(Geom_Conic) - || aType == STANDARD_TYPE(Geom_Circle) - || aType == STANDARD_TYPE(Geom_Ellipse) - || aType == STANDARD_TYPE(Geom_Hyperbola) - || aType == STANDARD_TYPE(Geom_Parabola)) { - isFound = true; + if(aType == STANDARD_TYPE(Geom_Line) + || aType == STANDARD_TYPE(Geom_Conic) + || aType == STANDARD_TYPE(Geom_Circle) + || aType == STANDARD_TYPE(Geom_Ellipse) + || aType == STANDARD_TYPE(Geom_Hyperbola) + || aType == STANDARD_TYPE(Geom_Parabola)) { + return true; + } + return false; + }; + + if(aShapeType == TopAbs_WIRE){ + //check if wire consist of only one edge + int aNbEdges = 0; + TopExp_Explorer anExp(aShape, TopAbs_EDGE); + for (TopExp_Explorer anExp(aShape, TopAbs_EDGE); anExp.More(); anExp.Next()) { + aNbEdges++; + if(aNbEdges == 1){ + const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current()); + isFound = checkEdge(anEdge); + } + else{ + //if more than one edge, check is not valid + isFound = false; + break; + } + } + } + else if(aShapeType == TopAbs_EDGE){ + isFound = checkEdge(aShape); } }