1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef FeaturesPlugin_Extrusion_H_
21 #define FeaturesPlugin_Extrusion_H_
23 #include "FeaturesPlugin.h"
25 #include "FeaturesPlugin_CompositeSketch.h"
27 #include <GeomAlgoAPI_MakeShape.h>
29 /// \class FeaturesPlugin_Extrusion
31 /// \brief Feature for creation of extrusion from the planar face.
32 /// Extrusion creates the lateral faces based on edges of the base face and
33 /// the top and bottom faces equal to the base face or this faces can be projection on the
34 /// bounding planes if they were set. Direction of extrusion is taken from the face
35 /// plane or if the bounding faces were set then it will be from the bottom to the top plane.
36 class FeaturesPlugin_Extrusion: public FeaturesPlugin_CompositeSketch
39 /// Use plugin manager for features creation
40 FeaturesPlugin_Extrusion();
43 inline static const std::string& ID()
45 static const std::string MY_ID("Extrusion");
49 /// Attribute name for creation method.
50 inline static const std::string& CREATION_METHOD()
52 static const std::string MY_CREATION_METHOD_ID("CreationMethod");
53 return MY_CREATION_METHOD_ID;
56 /// Attribute name for creation method.
57 inline static const std::string& CREATION_METHOD_BY_SIZES()
59 static const std::string MY_CREATION_METHOD_BY_SIZES("BySizes");
60 return MY_CREATION_METHOD_BY_SIZES;
63 /// Attribute name for creation method.
64 inline static const std::string& CREATION_METHOD_BY_PLANES()
66 static const std::string MY_CREATION_METHOD_BY_PLANES("ByPlanesAndOffsets");
67 return MY_CREATION_METHOD_BY_PLANES;
70 /// Attribute name for creation method.
71 inline static const std::string& CREATION_METHOD_THROUGH_ALL()
73 static const std::string MY_CREATION_METHOD_THROUGH_ALL("ThroughAll");
74 return MY_CREATION_METHOD_THROUGH_ALL;
77 /// Attribute name of an object to which the extrusion grows.
78 inline static const std::string& DIRECTION_OBJECT_ID()
80 static const std::string MY_DIRECTION_OBJECT_ID("direction_object");
81 return MY_DIRECTION_OBJECT_ID;
84 /// Attribute name of extrusion to size.
85 inline static const std::string& TO_SIZE_ID()
87 static const std::string MY_TO_SIZE_ID("to_size");
91 /// Attribute name of extrusion from size.
92 inline static const std::string& FROM_SIZE_ID()
94 static const std::string MY_FROM_SIZE_ID("from_size");
95 return MY_FROM_SIZE_ID;
98 /// Attribute name of an object to which the extrusion grows.
99 inline static const std::string& TO_OBJECT_ID()
101 static const std::string MY_TO_OBJECT_ID("to_object");
102 return MY_TO_OBJECT_ID;
105 /// Attribute name of extrusion offset.
106 inline static const std::string& TO_OFFSET_ID()
108 static const std::string MY_TO_OFFSET_ID("to_offset");
109 return MY_TO_OFFSET_ID;
112 /// Attribute name of an object from which the extrusion grows.
113 inline static const std::string& FROM_OBJECT_ID()
115 static const std::string MY_FROM_OBJECT_ID("from_object");
116 return MY_FROM_OBJECT_ID;
119 /// Attribute name of extrusion offset.
120 inline static const std::string& FROM_OFFSET_ID()
122 static const std::string MY_FROM_OFFSET_ID("from_offset");
123 return MY_FROM_OFFSET_ID;
126 /// \return the kind of a feature.
127 FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
129 static std::string MY_KIND = FeaturesPlugin_Extrusion::ID();
133 /// Request for initialization of data model of the feature: adding all attributes.
134 FEATURESPLUGIN_EXPORT virtual void initAttributes();
136 /// Performs the algorithm and stores results it in the data structure.
137 FEATURESPLUGIN_EXPORT virtual void execute();
140 /// Generates extrusions.
141 /// \param[out] theBaseShapes list of base shapes.
142 /// \param[out] theBoundaryShapes list of faces limiting the extrusion
143 /// \param[out] theMakeShapes list of according algos.
144 /// \return false in case one of algo failed.
145 bool makeExtrusions(ListOfShape& theBaseShapes,
146 ListOfShape& theBoundaryShapes,
147 ListOfMakeShape& theMakeShapes);
149 /// Stores result of generation.
150 void storeResultWithBoundaries(const GeomShapePtr theBaseShape,
151 const ListOfShape& theBoundaryShapes,
152 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
153 const int theIndex = 0);
155 /// Retrieve direction argument.
156 void getDirection(std::shared_ptr<GeomAPI_Dir>& theDir);
158 /// Retrieve or calculate prism sizes.
159 virtual void getSizes(double& theToSize, double& theFromSize);