Salome HOME
37ab3cca8932a415b6966ffe6fb0ac117b9c5589
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Plugin.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 <FeaturesPlugin_Plugin.h>
21
22 #include <FeaturesPlugin_BooleanCut.h>
23 #include <FeaturesPlugin_BooleanFuse.h>
24 #include <FeaturesPlugin_BooleanCommon.h>
25 #include <FeaturesPlugin_BooleanSmash.h>
26 #include <FeaturesPlugin_BooleanFill.h>
27 #include <FeaturesPlugin_BoundingBox.h>
28 #include <FeaturesPlugin_Chamfer.h>
29 #include <FeaturesPlugin_Defeaturing.h>
30 #include <FeaturesPlugin_Extrusion.h>
31 #include <FeaturesPlugin_ExtrusionCut.h>
32 #include <FeaturesPlugin_ExtrusionFuse.h>
33 #include <FeaturesPlugin_Fillet.h>
34 #include <FeaturesPlugin_Fillet1D.h>
35 #include <FeaturesPlugin_GeometryCalculation.h>
36 #include <FeaturesPlugin_GlueFaces.h>
37 #include <FeaturesPlugin_GroupSharedFaces.h>
38 #include <FeaturesPlugin_InspectBoundingBox.h>
39 #include <FeaturesPlugin_InspectNormalToFace.h>
40 #include <FeaturesPlugin_Intersection.h>
41 #include <FeaturesPlugin_LimitTolerance.h>
42 #include <FeaturesPlugin_Measurement.h>
43 #include <FeaturesPlugin_PointCoordinates.h>
44 #include <FeaturesPlugin_MultiRotation.h>
45 #include <FeaturesPlugin_MultiTranslation.h>
46 #include <FeaturesPlugin_NormalToFace.h>
47 #include <FeaturesPlugin_Partition.h>
48 #include <FeaturesPlugin_Pipe.h>
49 #include <FeaturesPlugin_Loft.h>
50 #include <FeaturesPlugin_Placement.h>
51 #include <FeaturesPlugin_PointCloudOnFace.h>
52 #include <FeaturesPlugin_Recover.h>
53 #include <FeaturesPlugin_RemoveSubShapes.h>
54 #include <FeaturesPlugin_Revolution.h>
55 #include <FeaturesPlugin_RevolutionCut.h>
56 #include <FeaturesPlugin_RevolutionFuse.h>
57 #include <FeaturesPlugin_Rotation.h>
58 #include <FeaturesPlugin_Scale.h>
59 #include <FeaturesPlugin_Sewing.h>
60 #include <FeaturesPlugin_SharedFaces.h>
61 #include <FeaturesPlugin_Symmetry.h>
62 #include <FeaturesPlugin_Translation.h>
63 #include <FeaturesPlugin_Union.h>
64 #include <FeaturesPlugin_FusionFaces.h>
65 #include <FeaturesPlugin_RemoveResults.h>
66 #include <FeaturesPlugin_Copy.h>
67 #include <FeaturesPlugin_ImportResult.h>
68 #include <FeaturesPlugin_ValidatorTransform.h>
69 #include <FeaturesPlugin_Validators.h>
70
71 #include <ModelAPI_Session.h>
72
73 #include <string>
74
75 #include <memory>
76
77 // the only created instance of this plugin
78 static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin();
79
80 FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
81 {
82   SessionPtr aMgr = ModelAPI_Session::get();
83   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
84   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
85                               new FeaturesPlugin_ValidatorTransform);
86   aFactory->registerValidator("FeaturesPlugin_ValidatorCompositeLauncher",
87                               new FeaturesPlugin_ValidatorCompositeLauncher);
88   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGeneration",
89                               new FeaturesPlugin_ValidatorBaseForGeneration);
90   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects",
91                               new FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects);
92   aFactory->registerValidator("FeaturesPlugin_ValidatorPipeLocations",
93                               new FeaturesPlugin_ValidatorPipeLocations);
94   aFactory->registerValidator("FeaturesPlugin_ValidatorPipeLocationsNumber",
95                               new FeaturesPlugin_ValidatorPipeLocationsNumber);
96   aFactory->registerValidator("FeaturesPlugin_ValidatorLoftSameTypeShape",
97                               new FeaturesPlugin_ValidatorLoftSameTypeShape);
98   aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionDir",
99                               new FeaturesPlugin_ValidatorExtrusionDir);
100   aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionBoundary",
101                               new FeaturesPlugin_ValidatorExtrusionBoundaryFace);
102   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanSelection",
103                               new FeaturesPlugin_ValidatorBooleanSelection);
104   aFactory->registerValidator("FeaturesPlugin_ValidatorPartitionSelection",
105                               new FeaturesPlugin_ValidatorPartitionSelection);
106   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesSelection",
107                               new FeaturesPlugin_ValidatorRemoveSubShapesSelection);
108   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesResult",
109                               new FeaturesPlugin_ValidatorRemoveSubShapesResult);
110   aFactory->registerValidator("FeaturesPlugin_ValidatorPipePath",
111                               new FeaturesPlugin_ValidatorPipePath);
112   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionSelection",
113                               new FeaturesPlugin_ValidatorUnionSelection);
114   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionArguments",
115                               new FeaturesPlugin_ValidatorUnionArguments);
116   aFactory->registerValidator("FeaturesPlugin_ValidatorConcealedResult",
117                               new FeaturesPlugin_ValidatorConcealedResult);
118   aFactory->registerValidator("FeaturesPlugin_ValidatorFilletSelection",
119                               new FeaturesPlugin_ValidatorFilletSelection);
120   aFactory->registerValidator("FeaturesPlugin_ValidatorFillet1DSelection",
121                               new FeaturesPlugin_ValidatorFillet1DSelection);
122   aFactory->registerValidator("FeaturesPlugin_ValidatorCircular",
123                               new FeaturesPlugin_ValidatorCircular);
124   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanArguments",
125                               new FeaturesPlugin_ValidatorBooleanArguments);
126   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanSmashSelection",
127                               new FeaturesPlugin_ValidatorBooleanSmashSelection);
128   aFactory->registerValidator("FeaturesPlugin_IntersectionSelection",
129                               new FeaturesPlugin_IntersectionSelection);
130   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanFuseSelection",
131                               new FeaturesPlugin_ValidatorBooleanFuseSelection);
132   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanFuseArguments",
133                               new FeaturesPlugin_ValidatorBooleanFuseArguments);
134   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanCommonSelection",
135                               new FeaturesPlugin_ValidatorBooleanCommonSelection);
136   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanCommonArguments",
137                               new FeaturesPlugin_ValidatorBooleanCommonArguments);
138   aFactory->registerValidator("FeaturesPlugin_ValidatorImportResults",
139                               new FeaturesPlugin_ValidatorImportResults);
140   aFactory->registerValidator("FeaturesPlugin_ValidatorDefeaturingSelection",
141                               new FeaturesPlugin_ValidatorDefeaturingSelection);
142   aFactory->registerValidator("FeaturesPlugin_ValidatorSewingSelection",
143                               new FeaturesPlugin_ValidatorSewingSelection);
144   aFactory->registerValidator("FeaturesPlugin_ValidatorGlueFacesSelection",
145                               new FeaturesPlugin_ValidatorGlueFacesSelection);
146
147   // register this plugin
148   ModelAPI_Session::get()->registerPlugin(this);
149 }
150
151 FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
152 {
153   if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
154     return FeaturePtr(new FeaturesPlugin_Extrusion);
155   } else if (theFeatureID == FeaturesPlugin_Revolution::ID()) {
156    return FeaturePtr(new FeaturesPlugin_Revolution);
157   } else if (theFeatureID == FeaturesPlugin_Rotation::ID()) {
158     return FeaturePtr(new FeaturesPlugin_Rotation);
159   } else if (theFeatureID == FeaturesPlugin_Translation::ID()) {
160     return FeaturePtr(new FeaturesPlugin_Translation);
161   } else if (theFeatureID == FeaturesPlugin_BooleanCut::ID()) {
162     return FeaturePtr(new FeaturesPlugin_BooleanCut);
163   } else if (theFeatureID == FeaturesPlugin_BooleanFuse::ID()) {
164     return FeaturePtr(new FeaturesPlugin_BooleanFuse);
165   } else if (theFeatureID == FeaturesPlugin_BooleanCommon::ID()) {
166     return FeaturePtr(new FeaturesPlugin_BooleanCommon);
167   } else if (theFeatureID == FeaturesPlugin_BooleanSmash::ID()) {
168     return FeaturePtr(new FeaturesPlugin_BooleanSmash);
169   } else if (theFeatureID == FeaturesPlugin_BooleanFill::ID() || theFeatureID == "Fill") {
170     return FeaturePtr(new FeaturesPlugin_BooleanFill);
171   } else if (theFeatureID == FeaturesPlugin_Intersection::ID()) {
172     return FeaturePtr(new FeaturesPlugin_Intersection);
173   } else if (theFeatureID == FeaturesPlugin_Partition::ID()) {
174     return FeaturePtr(new FeaturesPlugin_Partition);
175   } else if (theFeatureID == FeaturesPlugin_Pipe::ID()) {
176     return FeaturePtr(new FeaturesPlugin_Pipe);
177   } else if (theFeatureID == FeaturesPlugin_Loft::ID()) {
178     return FeaturePtr(new FeaturesPlugin_Loft);
179   } else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
180     return FeaturePtr(new FeaturesPlugin_Placement);
181   } else if (theFeatureID == FeaturesPlugin_Recover::ID()) {
182     return FeaturePtr(new FeaturesPlugin_Recover);
183   } else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) {
184     return FeaturePtr(new FeaturesPlugin_ExtrusionCut);
185   } else if (theFeatureID == FeaturesPlugin_ExtrusionFuse::ID()) {
186     return FeaturePtr(new FeaturesPlugin_ExtrusionFuse);
187   } else if (theFeatureID == FeaturesPlugin_RevolutionCut::ID()) {
188     return FeaturePtr(new FeaturesPlugin_RevolutionCut);
189   } else if (theFeatureID == FeaturesPlugin_RevolutionFuse::ID()) {
190     return FeaturePtr(new FeaturesPlugin_RevolutionFuse);
191   } else if (theFeatureID == FeaturesPlugin_RemoveSubShapes::ID()) {
192     return FeaturePtr(new FeaturesPlugin_RemoveSubShapes);
193   } else if (theFeatureID == FeaturesPlugin_Union::ID()) {
194     return FeaturePtr(new FeaturesPlugin_Union);
195   } else if (theFeatureID == FeaturesPlugin_FusionFaces::ID()) {
196     return FeaturePtr(new FeaturesPlugin_FusionFaces);
197   } else if (theFeatureID == FeaturesPlugin_Symmetry::ID()) {
198     return FeaturePtr(new FeaturesPlugin_Symmetry);
199   } else if (theFeatureID == FeaturesPlugin_Scale::ID()) {
200     return FeaturePtr(new FeaturesPlugin_Scale);
201   } else if (theFeatureID == FeaturesPlugin_Sewing::ID()) {
202     return FeaturePtr(new FeaturesPlugin_Sewing);
203   } else if (theFeatureID == FeaturesPlugin_MultiTranslation::ID()) {
204     return FeaturePtr(new FeaturesPlugin_MultiTranslation);
205   } else if (theFeatureID == FeaturesPlugin_MultiRotation::ID()) {
206     return FeaturePtr(new FeaturesPlugin_MultiRotation);
207   } else if (theFeatureID == FeaturesPlugin_Fillet::ID()) {
208     return FeaturePtr(new FeaturesPlugin_Fillet);
209   } else if (theFeatureID == FeaturesPlugin_Fillet1D::ID()) {
210     return FeaturePtr(new FeaturesPlugin_Fillet1D);
211   } else if (theFeatureID == FeaturesPlugin_Measurement::ID()) {
212     return FeaturePtr(new FeaturesPlugin_Measurement);
213   } else if (theFeatureID == FeaturesPlugin_RemoveResults::ID()) {
214     return FeaturePtr(new FeaturesPlugin_RemoveResults);
215   } else if (theFeatureID == FeaturesPlugin_Chamfer::ID()) {
216     return FeaturePtr(new FeaturesPlugin_Chamfer);
217   } else if (theFeatureID == FeaturesPlugin_Copy::ID()) {
218     return FeaturePtr(new FeaturesPlugin_Copy);
219   } else if (theFeatureID == FeaturesPlugin_GlueFaces::ID()) {
220     return FeaturePtr(new FeaturesPlugin_GlueFaces);
221   } else if (theFeatureID == FeaturesPlugin_ImportResult::ID()) {
222     return FeaturePtr(new FeaturesPlugin_ImportResult);
223   } else if (theFeatureID == FeaturesPlugin_Defeaturing::ID()) {
224     return FeaturePtr(new FeaturesPlugin_Defeaturing);
225   } else if (theFeatureID == FeaturesPlugin_PointCoordinates::ID()) {
226     return FeaturePtr(new FeaturesPlugin_PointCoordinates);
227   } else if (theFeatureID == FeaturesPlugin_GeometryCalculation::ID()) {
228     return FeaturePtr(new FeaturesPlugin_GeometryCalculation);
229   } else if (theFeatureID == FeaturesPlugin_InspectBoundingBox::ID()) {
230     return FeaturePtr(new FeaturesPlugin_InspectBoundingBox);
231   } else if (theFeatureID == FeaturesPlugin_BoundingBox::ID()) {
232     return FeaturePtr(new FeaturesPlugin_BoundingBox);
233   } else if (theFeatureID == FeaturesPlugin_InspectNormalToFace::ID()) {
234     return FeaturePtr(new FeaturesPlugin_InspectNormalToFace);
235   } else if (theFeatureID == FeaturesPlugin_NormalToFace::ID()) {
236     return FeaturePtr(new FeaturesPlugin_NormalToFace);
237   } else if (theFeatureID == FeaturesPlugin_PointCloudOnFace::ID()) {
238     return FeaturePtr(new FeaturesPlugin_PointCloudOnFace);
239   } else if (theFeatureID == FeaturesPlugin_LimitTolerance::ID()) {
240     return FeaturePtr(new FeaturesPlugin_LimitTolerance);
241   } else if (theFeatureID == FeaturesPlugin_SharedFaces::ID()) {
242     return FeaturePtr(new FeaturesPlugin_SharedFaces);
243   } else if (theFeatureID == FeaturesPlugin_GroupSharedFaces::ID()) {
244     return FeaturePtr(new FeaturesPlugin_GroupSharedFaces);
245   }
246
247
248   // feature of such kind is not found
249   return FeaturePtr();
250 }