Salome HOME
07709d1ed7fa2a2056346f9e0f0c28ebed31b07e
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Tools.cpp
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include "FeaturesPlugin_Tools.h"
22
23 #include <ModelAPI_ResultBody.h>
24
25 #include <GeomAPI_ShapeIterator.h>
26
27 void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo,
28                                                std::shared_ptr<ModelAPI_ResultBody> theResultBody,
29                                                std::shared_ptr<GeomAPI_Shape> theBaseShape,
30                                                const int theFaceTag,
31                                                const int theEdgeTag,
32                                                const int theVertexTag,
33                                                const std::string theName,
34                                                GeomAPI_DataMapOfShapeShape& theSubShapes)
35 {
36   switch(theBaseShape->shapeType()) {
37     case GeomAPI_Shape::COMPOUND: {
38       for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next())
39       {
40         storeModifiedShapes(theAlgo,
41                             theResultBody,
42                             anIt.current(),
43                             theFaceTag,
44                             theEdgeTag,
45                             theVertexTag,
46                             theName,
47                             theSubShapes);
48       }
49       break;
50     }
51     case GeomAPI_Shape::COMPSOLID:
52     case GeomAPI_Shape::SOLID:
53     case GeomAPI_Shape::SHELL: {
54       theResultBody->loadAndOrientModifiedShapes(&theAlgo,
55                                 theBaseShape, GeomAPI_Shape::FACE,
56                                 theFaceTag, theName + "_Face", theSubShapes, false, true);
57     }
58     case GeomAPI_Shape::FACE:
59     case GeomAPI_Shape::WIRE: {
60       theResultBody->loadAndOrientModifiedShapes(&theAlgo,
61                                 theBaseShape, GeomAPI_Shape::EDGE,
62                                 theEdgeTag, theName + "_Edge", theSubShapes, false, true);
63     }
64     case GeomAPI_Shape::EDGE: {
65       theResultBody->loadAndOrientModifiedShapes(&theAlgo,
66                               theBaseShape, GeomAPI_Shape::VERTEX,
67                               theVertexTag, theName + "_Vertex", theSubShapes, false, true);
68     }
69   }
70 }