Salome HOME
Fix incorrect orientation of external arc (issue #1687)
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_ImportFeature.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    ExchangePlugin_ImportFeature.h
4 // Created: Aug 28, 2014
5 // Authors:  Sergey BELASH, Sergey POKHODENKO
6
7 #ifndef EXCHANGEPLUGIN_IMPORTFEATURE_H_
8 #define EXCHANGEPLUGIN_IMPORTFEATURE_H_
9
10 #include "ExchangePlugin.h"
11
12 #include <ModelAPI_CompositeFeature.h>
13 #include <ModelAPI_Result.h>
14
15 #include <map>
16
17 /**
18  * \class ExchangePlugin_ImportFeature
19  * \ingroup Plugins
20  * \brief Feature for import shapes from the external files in CAD formats.
21  *
22  * The list of supported formats is defined in the configuration file.
23  */
24 class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature
25 {
26  public:
27   /// Feature kind
28   inline static const std::string& ID()
29   {
30     static const std::string MY_IMPORT_ID("Import");
31     return MY_IMPORT_ID;
32   }
33   /// attribute name of file path
34   inline static const std::string& FILE_PATH_ID()
35   {
36     static const std::string MY_FILE_PATH_ID("file_path");
37     return MY_FILE_PATH_ID;
38   }
39   /// All features (list of references)
40   inline static const std::string& FEATURES_ID()
41   {
42     static const std::string MY_FEATURES_ID("Features");
43     return MY_FEATURES_ID;
44   }
45   /// Default constructor
46   EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature();
47   /// Default destructor
48   EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportFeature();
49
50   /// Returns the unique kind of a feature
51   EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
52   {
53     return ExchangePlugin_ImportFeature::ID();
54   }
55
56   /// Request for initialization of data model of the feature: adding all attributes
57   EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
58
59   /// Computes or recomputes the results
60   EXCHANGEPLUGIN_EXPORT virtual void execute();
61
62   /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
63   EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
64
65   /// Reimplemented from ModelAPI_CompositeFeature::addFeature()
66   virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
67
68   /// Reimplemented from ModelAPI_CompositeFeature::numberOfSubs()
69   virtual int numberOfSubs(bool forTree = false) const;
70
71   /// Reimplemented from ModelAPI_CompositeFeature::subFeature()
72   virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
73
74   /// Reimplemented from ModelAPI_CompositeFeature::subFeatureId()
75   virtual int subFeatureId(const int theIndex) const;
76
77   /// Reimplemented from ModelAPI_CompositeFeature::isSub()
78   virtual bool isSub(ObjectPtr theObject) const;
79
80   /// Reimplemented from ModelAPI_CompositeFeature::removeFeature()
81   virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
82
83  protected:
84   /// Performs the import of the file
85   EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName);
86
87   /// Performs the import of XAO file
88   EXCHANGEPLUGIN_EXPORT void importXAO(const std::string& theFileName);
89
90   /// Creates and prepares a result body from the shape
91   std::shared_ptr<ModelAPI_ResultBody> createResultBody(
92       std::shared_ptr<GeomAPI_Shape> aGeomShape);
93
94 private:
95   /// Loads Naming data structure to the document
96   void loadNamingDS(std::shared_ptr<GeomAPI_Shape> theGeomShape, 
97                     std::shared_ptr<ModelAPI_ResultBody> theResultBody);
98 };
99
100 #endif /* IMPORT_IMPORTFEATURE_H_ */