Salome HOME
Implementation of 3D Fillet operation
[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_Boolean.h>
24 #include <FeaturesPlugin_Extrusion.h>
25 #include <FeaturesPlugin_ExtrusionCut.h>
26 #include <FeaturesPlugin_ExtrusionFuse.h>
27 #include <FeaturesPlugin_Fillet.h>
28 #include <FeaturesPlugin_Intersection.h>
29 #include <FeaturesPlugin_MultiRotation.h>
30 #include <FeaturesPlugin_MultiTranslation.h>
31 #include <FeaturesPlugin_Partition.h>
32 #include <FeaturesPlugin_Pipe.h>
33 #include <FeaturesPlugin_Placement.h>
34 #include <FeaturesPlugin_Recover.h>
35 #include <FeaturesPlugin_RemoveSubShapes.h>
36 #include <FeaturesPlugin_Revolution.h>
37 #include <FeaturesPlugin_RevolutionCut.h>
38 #include <FeaturesPlugin_RevolutionFuse.h>
39 #include <FeaturesPlugin_Rotation.h>
40 #include <FeaturesPlugin_Scale.h>
41 #include <FeaturesPlugin_Symmetry.h>
42 #include <FeaturesPlugin_Translation.h>
43 #include <FeaturesPlugin_Union.h>
44 #include <FeaturesPlugin_ValidatorTransform.h>
45 #include <FeaturesPlugin_Validators.h>
46
47 #include <ModelAPI_Session.h>
48
49 #include <string>
50
51 #include <memory>
52
53 // the only created instance of this plugin
54 static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin();
55
56 FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
57 {
58   SessionPtr aMgr = ModelAPI_Session::get();
59   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
60   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
61                               new FeaturesPlugin_ValidatorTransform);
62   aFactory->registerValidator("FeaturesPlugin_ValidatorCompositeLauncher",
63                               new FeaturesPlugin_ValidatorCompositeLauncher);
64   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGeneration",
65                               new FeaturesPlugin_ValidatorBaseForGeneration);
66   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects",
67                               new FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects);
68   aFactory->registerValidator("FeaturesPlugin_ValidatorPipeLocations",
69                               new FeaturesPlugin_ValidatorPipeLocations);
70   aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionDir",
71                               new FeaturesPlugin_ValidatorExtrusionDir);
72   aFactory->registerValidator("FeaturesPlugin_ValidatorBooleanSelection",
73                               new FeaturesPlugin_ValidatorBooleanSelection);
74   aFactory->registerValidator("FeaturesPlugin_ValidatorPartitionSelection",
75                               new FeaturesPlugin_ValidatorPartitionSelection);
76   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesSelection",
77                               new FeaturesPlugin_ValidatorRemoveSubShapesSelection);
78   aFactory->registerValidator("FeaturesPlugin_ValidatorRemoveSubShapesResult",
79                               new FeaturesPlugin_ValidatorRemoveSubShapesResult);
80   aFactory->registerValidator("FeaturesPlugin_ValidatorPipePath",
81                               new FeaturesPlugin_ValidatorPipePath);
82   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionSelection",
83                               new FeaturesPlugin_ValidatorUnionSelection);
84   aFactory->registerValidator("FeaturesPlugin_ValidatorUnionArguments",
85                               new FeaturesPlugin_ValidatorUnionArguments);
86   aFactory->registerValidator("FeaturesPlugin_ValidatorConcealedResult",
87                               new FeaturesPlugin_ValidatorConcealedResult);
88   aFactory->registerValidator("FeaturesPlugin_ValidatorFilletSelection",
89                               new FeaturesPlugin_ValidatorFilletSelection);
90
91   // register this plugin
92   ModelAPI_Session::get()->registerPlugin(this);
93 }
94
95 FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
96 {
97   if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
98     return FeaturePtr(new FeaturesPlugin_Extrusion);
99   } else if (theFeatureID == FeaturesPlugin_Revolution::ID()) {
100    return FeaturePtr(new FeaturesPlugin_Revolution);
101   } else if (theFeatureID == FeaturesPlugin_Rotation::ID()) {
102     return FeaturePtr(new FeaturesPlugin_Rotation);
103   } else if (theFeatureID == FeaturesPlugin_Translation::ID()) {
104     return FeaturePtr(new FeaturesPlugin_Translation);
105   } else if (theFeatureID == FeaturesPlugin_Boolean::ID()) {
106     return FeaturePtr(new FeaturesPlugin_Boolean);
107   } else if (theFeatureID == FeaturesPlugin_Intersection::ID()) {
108     return FeaturePtr(new FeaturesPlugin_Intersection);
109   } else if (theFeatureID == FeaturesPlugin_Partition::ID()) {
110     return FeaturePtr(new FeaturesPlugin_Partition);
111   } else if (theFeatureID == FeaturesPlugin_Pipe::ID()) {
112     return FeaturePtr(new FeaturesPlugin_Pipe);
113   } else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
114     return FeaturePtr(new FeaturesPlugin_Placement);
115   } else if (theFeatureID == FeaturesPlugin_Recover::ID()) {
116     return FeaturePtr(new FeaturesPlugin_Recover);
117   } else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) {
118     return FeaturePtr(new FeaturesPlugin_ExtrusionCut);
119   } else if (theFeatureID == FeaturesPlugin_ExtrusionFuse::ID()) {
120     return FeaturePtr(new FeaturesPlugin_ExtrusionFuse);
121   } else if (theFeatureID == FeaturesPlugin_RevolutionCut::ID()) {
122     return FeaturePtr(new FeaturesPlugin_RevolutionCut);
123   } else if (theFeatureID == FeaturesPlugin_RevolutionFuse::ID()) {
124     return FeaturePtr(new FeaturesPlugin_RevolutionFuse);
125   } else if (theFeatureID == FeaturesPlugin_RemoveSubShapes::ID()) {
126     return FeaturePtr(new FeaturesPlugin_RemoveSubShapes);
127   } else if (theFeatureID == FeaturesPlugin_Union::ID()) {
128     return FeaturePtr(new FeaturesPlugin_Union);
129   } else if (theFeatureID == FeaturesPlugin_Symmetry::ID()) {
130     return FeaturePtr(new FeaturesPlugin_Symmetry);
131   } else if (theFeatureID == FeaturesPlugin_Scale::ID()) {
132     return FeaturePtr(new FeaturesPlugin_Scale);
133   } else if (theFeatureID == FeaturesPlugin_MultiTranslation::ID()) {
134     return FeaturePtr(new FeaturesPlugin_MultiTranslation);
135   } else if (theFeatureID == FeaturesPlugin_MultiRotation::ID()) {
136     return FeaturePtr(new FeaturesPlugin_MultiRotation);
137   } else if (theFeatureID == FeaturesPlugin_Fillet::ID()) {
138     return FeaturePtr(new FeaturesPlugin_Fillet);
139   }
140
141   // feature of such kind is not found
142   return FeaturePtr();
143 }