Salome HOME
3f1da2fd109dace09749365e58ae9b5a09ddaa00
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Plugin.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_Plugin.h>
22
23 #include <FeaturesPlugin_BooleanCut.h>
24 #include <FeaturesPlugin_BooleanFuse.h>
25 #include <FeaturesPlugin_BooleanCommon.h>
26 #include <FeaturesPlugin_BooleanSmash.h>
27 #include <FeaturesPlugin_BooleanFill.h>
28 #include <FeaturesPlugin_Extrusion.h>
29 #include <FeaturesPlugin_ExtrusionCut.h>
30 #include <FeaturesPlugin_ExtrusionFuse.h>
31 #include <FeaturesPlugin_Fillet.h>
32 #include <FeaturesPlugin_Intersection.h>
33 #include <FeaturesPlugin_Measurement.h>
34 #include <FeaturesPlugin_MultiRotation.h>
35 #include <FeaturesPlugin_MultiTranslation.h>
36 #include <FeaturesPlugin_Partition.h>
37 #include <FeaturesPlugin_Pipe.h>
38 #include <FeaturesPlugin_Placement.h>
39 #include <FeaturesPlugin_Recover.h>
40 #include <FeaturesPlugin_RemoveSubShapes.h>
41 #include <FeaturesPlugin_Revolution.h>
42 #include <FeaturesPlugin_RevolutionCut.h>
43 #include <FeaturesPlugin_RevolutionFuse.h>
44 #include <FeaturesPlugin_Rotation.h>
45 #include <FeaturesPlugin_Scale.h>
46 #include <FeaturesPlugin_Symmetry.h>
47 #include <FeaturesPlugin_Translation.h>
48 #include <FeaturesPlugin_Union.h>
49 #include <FeaturesPlugin_FusionFaces.h>
50 #include <FeaturesPlugin_ValidatorTransform.h>
51 #include <FeaturesPlugin_Validators.h>
52
53 #include <ModelAPI_Session.h>
54
55 #include <string>
56
57 #include <memory>
58
59 // the only created instance of this plugin
60 static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin();
61
62 FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
63 {
64   SessionPtr aMgr = ModelAPI_Session::get();
65   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
66   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
67                               new FeaturesPlugin_ValidatorTransform);
68   aFactory->registerValidator("FeaturesPlugin_ValidatorCompositeLauncher",
69                               new FeaturesPlugin_ValidatorCompositeLauncher);
70   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGeneration",
71                               new FeaturesPlugin_ValidatorBaseForGeneration);
72   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects",
73                               new FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects);
74   aFactory->registerValidator("FeaturesPlugin_ValidatorPipeLocations",
75                               new FeaturesPlugin_ValidatorPipeLocations);
76   aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionDir",
77                               new FeaturesPlugin_ValidatorExtrusionDir);
78   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanSelection",
79                               new FeaturesPlugin_ValidatorBooleanSelection);
80   aFactory->registerValidator("FeaturesPlugin_ValidatorPartitionSelection",
81                               new FeaturesPlugin_ValidatorPartitionSelection);
82   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesSelection",
83                               new FeaturesPlugin_ValidatorRemoveSubShapesSelection);
84   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesResult",
85                               new FeaturesPlugin_ValidatorRemoveSubShapesResult);
86   aFactory->registerValidator("FeaturesPlugin_ValidatorPipePath",
87                               new FeaturesPlugin_ValidatorPipePath);
88   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionSelection",
89                               new FeaturesPlugin_ValidatorUnionSelection);
90   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionArguments",
91                               new FeaturesPlugin_ValidatorUnionArguments);
92   aFactory->registerValidator("FeaturesPlugin_ValidatorConcealedResult",
93                               new FeaturesPlugin_ValidatorConcealedResult);
94   aFactory->registerValidator("FeaturesPlugin_ValidatorFilletSelection",
95                               new FeaturesPlugin_ValidatorFilletSelection);
96   aFactory->registerValidator("FeaturesPlugin_ValidatorCircular",
97                               new FeaturesPlugin_ValidatorCircular);
98   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanArguments",
99                               new FeaturesPlugin_ValidatorBooleanArguments);
100   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanSmashSelection",
101                               new FeaturesPlugin_ValidatorBooleanSmashSelection);
102   aFactory->registerValidator("FeaturesPlugin_IntersectionSelection",
103                               new FeaturesPlugin_IntersectionSelection);
104   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanFuseSelection",
105                               new FeaturesPlugin_ValidatorBooleanFuseSelection);
106   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanFuseArguments",
107                               new FeaturesPlugin_ValidatorBooleanFuseArguments);
108
109   // register this plugin
110   ModelAPI_Session::get()->registerPlugin(this);
111 }
112
113 FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
114 {
115   if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
116     return FeaturePtr(new FeaturesPlugin_Extrusion);
117   } else if (theFeatureID == FeaturesPlugin_Revolution::ID()) {
118    return FeaturePtr(new FeaturesPlugin_Revolution);
119   } else if (theFeatureID == FeaturesPlugin_Rotation::ID()) {
120     return FeaturePtr(new FeaturesPlugin_Rotation);
121   } else if (theFeatureID == FeaturesPlugin_Translation::ID()) {
122     return FeaturePtr(new FeaturesPlugin_Translation);
123   } else if (theFeatureID == FeaturesPlugin_BooleanCut::ID()) {
124     return FeaturePtr(new FeaturesPlugin_BooleanCut);
125   } else if (theFeatureID == FeaturesPlugin_BooleanFuse::ID()) {
126     return FeaturePtr(new FeaturesPlugin_BooleanFuse);
127   } else if (theFeatureID == FeaturesPlugin_BooleanCommon::ID()) {
128     return FeaturePtr(new FeaturesPlugin_BooleanCommon);
129   } else if (theFeatureID == FeaturesPlugin_BooleanSmash::ID()) {
130     return FeaturePtr(new FeaturesPlugin_BooleanSmash);
131   } else if (theFeatureID == FeaturesPlugin_BooleanFill::ID()) {
132     return FeaturePtr(new FeaturesPlugin_BooleanFill);
133   } else if (theFeatureID == FeaturesPlugin_Intersection::ID()) {
134     return FeaturePtr(new FeaturesPlugin_Intersection);
135   } else if (theFeatureID == FeaturesPlugin_Partition::ID()) {
136     return FeaturePtr(new FeaturesPlugin_Partition);
137   } else if (theFeatureID == FeaturesPlugin_Pipe::ID()) {
138     return FeaturePtr(new FeaturesPlugin_Pipe);
139   } else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
140     return FeaturePtr(new FeaturesPlugin_Placement);
141   } else if (theFeatureID == FeaturesPlugin_Recover::ID()) {
142     return FeaturePtr(new FeaturesPlugin_Recover);
143   } else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) {
144     return FeaturePtr(new FeaturesPlugin_ExtrusionCut);
145   } else if (theFeatureID == FeaturesPlugin_ExtrusionFuse::ID()) {
146     return FeaturePtr(new FeaturesPlugin_ExtrusionFuse);
147   } else if (theFeatureID == FeaturesPlugin_RevolutionCut::ID()) {
148     return FeaturePtr(new FeaturesPlugin_RevolutionCut);
149   } else if (theFeatureID == FeaturesPlugin_RevolutionFuse::ID()) {
150     return FeaturePtr(new FeaturesPlugin_RevolutionFuse);
151   } else if (theFeatureID == FeaturesPlugin_RemoveSubShapes::ID()) {
152     return FeaturePtr(new FeaturesPlugin_RemoveSubShapes);
153   } else if (theFeatureID == FeaturesPlugin_Union::ID()) {
154     return FeaturePtr(new FeaturesPlugin_Union);
155   } else if (theFeatureID == FeaturesPlugin_FusionFaces::ID()) {
156     return FeaturePtr(new FeaturesPlugin_FusionFaces);
157   } else if (theFeatureID == FeaturesPlugin_Symmetry::ID()) {
158     return FeaturePtr(new FeaturesPlugin_Symmetry);
159   } else if (theFeatureID == FeaturesPlugin_Scale::ID()) {
160     return FeaturePtr(new FeaturesPlugin_Scale);
161   } else if (theFeatureID == FeaturesPlugin_MultiTranslation::ID()) {
162     return FeaturePtr(new FeaturesPlugin_MultiTranslation);
163   } else if (theFeatureID == FeaturesPlugin_MultiRotation::ID()) {
164     return FeaturePtr(new FeaturesPlugin_MultiRotation);
165   } else if (theFeatureID == FeaturesPlugin_Fillet::ID()) {
166     return FeaturePtr(new FeaturesPlugin_Fillet);
167   } else if (theFeatureID == FeaturesPlugin_Measurement::ID()) {
168     return FeaturePtr(new FeaturesPlugin_Measurement);
169   }
170
171   // feature of such kind is not found
172   return FeaturePtr();
173 }