X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_ShapeExplorer.cpp;h=a604f7663ad11fd4da45fe6d3ab305dde6e58c40;hb=f60dc9dd94d5d4b0ea07e3e3cbfd5b3028f0942d;hp=3732d5afe2cbf8bbe34dd0b6c61721a5cde72b6c;hpb=7b575e65da4aaf7e4cbf41ccf7d61b83c5842b7f;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_ShapeExplorer.cpp b/src/GeomAPI/GeomAPI_ShapeExplorer.cpp index 3732d5afe..a604f7663 100644 --- a/src/GeomAPI/GeomAPI_ShapeExplorer.cpp +++ b/src/GeomAPI/GeomAPI_ShapeExplorer.cpp @@ -1,15 +1,29 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAPI_ShapeExplorer.cpp -// Created: 5 June 2015 -// Author: Dmitry Bobylev +// Copyright (C) 2014-2017 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 +// #include #include #include -#define MY_EXPLORER static_cast(myImpl) +#define MY_EXPLORER implPtr() //================================================================================================= GeomAPI_ShapeExplorer::GeomAPI_ShapeExplorer() @@ -17,12 +31,29 @@ GeomAPI_ShapeExplorer::GeomAPI_ShapeExplorer() { } +// returns a type of shape to expolode, but if toFind==SHAPE, it will return the type +// of the first sub-element of compoud if theSHape is compound +static TopAbs_ShapeEnum ShapeType(const std::shared_ptr& theShape, + const GeomAPI_Shape::ShapeType toFind) +{ + if (toFind == GeomAPI_Shape::SHAPE) { + TopoDS_Shape aShape = theShape->impl(); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator anIter(aShape); + if (anIter.More()) { + return anIter.Value().ShapeType(); + } + } + } + return (TopAbs_ShapeEnum)toFind; +} + //================================================================================================= GeomAPI_ShapeExplorer::GeomAPI_ShapeExplorer(const std::shared_ptr& theShape, const GeomAPI_Shape::ShapeType toFind, const GeomAPI_Shape::ShapeType toAvoid) : GeomAPI_Interface(new TopExp_Explorer(theShape->impl(), - (TopAbs_ShapeEnum)toFind, + ShapeType(theShape, toFind), (TopAbs_ShapeEnum)toAvoid)) { } @@ -33,7 +64,7 @@ void GeomAPI_ShapeExplorer::init(const std::shared_ptr& theShape, const GeomAPI_Shape::ShapeType toAvoid) { MY_EXPLORER->Init(theShape->impl(), - (TopAbs_ShapeEnum)toFind, + ShapeType(theShape, toFind), (TopAbs_ShapeEnum)toAvoid); }