Salome HOME
322a10b043806c7049f289aa846d7f2dbee19717
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_MapShapesAndAncestors.cpp
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "GeomAlgoAPI_MapShapesAndAncestors.h"
21
22 #include <GeomAPI_ShapeExplorer.h>
23
24 GeomAlgoAPI_MapShapesAndAncestors::GeomAlgoAPI_MapShapesAndAncestors(
25     const std::shared_ptr<GeomAPI_Shape> theShape,
26     const GeomAPI_Shape::ShapeType theShapeType,
27     const GeomAPI_Shape::ShapeType theAncestorType)
28 {
29   perform(theShape, theShapeType, theAncestorType);
30 }
31
32 void GeomAlgoAPI_MapShapesAndAncestors::perform(
33     const std::shared_ptr<GeomAPI_Shape> theShape,
34     const GeomAPI_Shape::ShapeType theShapeType,
35     const GeomAPI_Shape::ShapeType theAncestorType)
36 {
37   myMap.clear();
38
39   GeomAPI_ShapeExplorer anAncIt(theShape, theAncestorType);
40   for (; anAncIt.more(); anAncIt.next()) {
41     GeomAPI_ShapeExplorer aShIt(anAncIt.current(), theShapeType);
42     for (; aShIt.more(); aShIt.next())
43       myMap[aShIt.current()].insert(anAncIt.current());
44   }
45 }