Salome HOME
Merge remote-tracking branch 'remotes/origin/HigherLevelObjectsHistory'
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ImportFeature.h
1 // Copyright (C) 2014-2019  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 #ifndef EXCHANGEPLUGIN_IMPORTFEATURE_H_
21 #define EXCHANGEPLUGIN_IMPORTFEATURE_H_
22
23 #include "ExchangePlugin.h"
24
25 #include <ModelAPI_CompositeFeature.h>
26 #include <ModelAPI_Result.h>
27
28 #include <map>
29
30 /**
31  * \class ExchangePlugin_ImportFeature
32  * \ingroup Plugins
33  * \brief Feature for import shapes from the external files in CAD formats.
34  *
35  * The list of supported formats is defined in the configuration file.
36  */
37 class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature
38 {
39  public:
40   /// Feature kind
41   inline static const std::string& ID()
42   {
43     static const std::string MY_IMPORT_ID("Import");
44     return MY_IMPORT_ID;
45   }
46   /// attribute name of file path
47   inline static const std::string& FILE_PATH_ID()
48   {
49     static const std::string MY_FILE_PATH_ID("file_path");
50     return MY_FILE_PATH_ID;
51   }
52   /// All features (list of references)
53   inline static const std::string& FEATURES_ID()
54   {
55     static const std::string MY_FEATURES_ID("Features");
56     return MY_FEATURES_ID;
57   }
58   /// Default constructor
59   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature();
60   /// Default destructor
61   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportFeature();
62
63   /// Returns the unique kind of a feature
64   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
65   {
66     return ExchangePlugin_ImportFeature::ID();
67   }
68
69   /// Request for initialization of data model of the feature: adding all attributes
70   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
71
72   /// Computes or recomputes the results
73   EXCHANGEPLUGIN_EXPORT virtual void execute();
74
75   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
76   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
77
78   /// Reimplemented from ModelAPI_CompositeFeature::addFeature()
79   virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
80
81   /// Reimplemented from ModelAPI_CompositeFeature::numberOfSubs()
82   virtual int numberOfSubs(bool forTree = false) const;
83
84   /// Reimplemented from ModelAPI_CompositeFeature::subFeature()
85   virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
86
87   /// Reimplemented from ModelAPI_CompositeFeature::subFeatureId()
88   virtual int subFeatureId(const int theIndex) const;
89
90   /// Reimplemented from ModelAPI_CompositeFeature::isSub()
91   virtual bool isSub(ObjectPtr theObject) const;
92
93   /// Reimplemented from ModelAPI_CompositeFeature::removeFeature()
94   virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
95
96  protected:
97   /// Performs the import of the file
98   EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName);
99
100   /// Performs the import of XAO file
101   EXCHANGEPLUGIN_EXPORT void importXAO(const std::string& theFileName);
102
103   /// Creates and prepares a result body from the shape
104   std::shared_ptr<ModelAPI_ResultBody> createResultBody(
105       std::shared_ptr<GeomAPI_Shape> aGeomShape);
106
107 private:
108   /// Loads Naming data structure to the document
109   void loadNamingDS(std::shared_ptr<GeomAPI_Shape> theGeomShape,
110                     std::shared_ptr<ModelAPI_ResultBody> theResultBody);
111 };
112
113 #endif /* IMPORT_IMPORTFEATURE_H_ */