Salome HOME
76262f8e346af7a8b5ae18abfeaa2f1160b754fb
[modules/shaper.git] / src / ExchangeAPI / ExchangeAPI_Import.h
1 // Copyright (C) 2014-2023  CEA, EDF
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 SRC_EXCHANGEAPI_EXCHANGEAPI_IMPORT_H_
21 #define SRC_EXCHANGEAPI_EXCHANGEAPI_IMPORT_H_
22
23 //--------------------------------------------------------------------------------------
24 #include "ExchangeAPI.h"
25
26 #include <string>
27
28 #include <ExchangePlugin_ImportFeature.h>
29
30 #include <ModelHighAPI_Interface.h>
31 #include <ModelHighAPI_Macro.h>
32 #include <ModelHighAPI_Reference.h>
33 #include <ModelHighAPI_Selection.h>
34
35 #include <Python.h>
36 //--------------------------------------------------------------------------------------
37
38 /**\class ExchangeAPI_Import
39  * \ingroup CPPHighAPI
40  * \brief Interface for Import feature
41  */
42 class ExchangeAPI_Import : public ModelHighAPI_Interface
43 {
44 public:
45   /// Constructor without values
46   EXCHANGEAPI_EXPORT
47   explicit ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature);
48
49   /// Constructor with values
50   EXCHANGEAPI_EXPORT
51   ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature,
52                      const std::string & theFilePath);
53
54   /// Constructor with values for XAO import from memory buffer
55   EXCHANGEAPI_EXPORT
56   ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature,
57                      const std::string & theFilePath,
58                      const std::string & theBuffer);
59
60   /// Constructor with values for Step file
61   EXCHANGEAPI_EXPORT
62   ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & theFeature,
63                      const std::string & theFilePath,
64                      const bool  theScalInterUnits,
65                      const bool  theMaterials,
66                      const bool  theColor);
67   /// Destructor
68   EXCHANGEAPI_EXPORT
69   virtual ~ExchangeAPI_Import();
70
71   INTERFACE_7(ExchangePlugin_ImportFeature::ID(),
72               filePath, ExchangePlugin_ImportFeature::FILE_PATH_ID(),
73               ModelAPI_AttributeString, /** File path */,
74               importType, ExchangePlugin_ImportFeature::IMPORT_TYPE_ID(),
75               ModelAPI_AttributeString, /**import type */,
76               stepFilePath, ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID(),
77               ModelAPI_AttributeString, /**step File path */,
78               scalInterUnits, ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID(),
79               ModelAPI_AttributeBoolean, /** Scale internationals units */,
80               materials, ExchangePlugin_ImportFeature::STEP_MATERIALS_ID(),
81               ModelAPI_AttributeBoolean, /** Materials */,
82               colors, ExchangePlugin_ImportFeature::STEP_COLORS_ID(),
83               ModelAPI_AttributeBoolean, /** Colors */,
84               memoryBuffer, ExchangePlugin_ImportFeature::MEMORY_BUFFER_ID(),
85               ModelAPI_AttributeString, /** Bytes */
86   )
87
88   /// Set point values
89   EXCHANGEAPI_EXPORT
90   void setFilePath(const std::string & theFilePath);
91
92   EXCHANGEAPI_EXPORT
93   void setParameters(const std::string & theFilePath,
94                      const bool theScalInterUnits,
95                      const bool theMaterials,
96                      const bool theColor);
97
98   /// Dump wrapped feature
99   EXCHANGEAPI_EXPORT
100   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
101 };
102
103 //! Pointer on Import object
104 typedef std::shared_ptr<ExchangeAPI_Import> ImportPtr;
105
106 /**\ingroup CPPHighAPI
107  * \brief Create Import feature
108  */
109 EXCHANGEAPI_EXPORT
110 ImportPtr addImport(const std::shared_ptr<ModelAPI_Document> & thePart,
111                     const std::string & theFilePath);
112
113 /**\ingroup CPPHighAPI
114  * \brief Create Import feature to import XAO data from bytes buffer
115  */
116 EXCHANGEAPI_EXPORT
117 ImportPtr addImportXAOMem(const std::shared_ptr<ModelAPI_Document> & thePart,
118                           PyObject* theBuffer);
119
120 /**\ingroup CPPHighAPI
121  * \brief Create Import Step feature
122  */
123 EXCHANGEAPI_EXPORT
124 ImportPtr addImportSTEP(const std::shared_ptr<ModelAPI_Document> & thePart,
125                         const std::string & theFilePath,
126                         const bool theScalInterUnits,
127                         const bool theMaterials,
128                         const bool theColor);
129
130
131 /** \ingroup CPPHighAPI
132  *  \brief Import features from the file to the document after the current feature (or to the end).
133  */
134 EXCHANGEAPI_EXPORT void importPart(
135     const std::shared_ptr<ModelAPI_Document> & thePart,
136     const std::string & theFilePath,
137     const ModelHighAPI_Reference & theAfterThis = ModelHighAPI_Reference());
138
139 //--------------------------------------------------------------------------------------
140 //--------------------------------------------------------------------------------------
141 /**\class ExchangeAPI_Import_Image
142  * \ingroup CPPHighAPI
143  * \brief Interface for Import feature
144  */
145 class ExchangeAPI_Import_Image : public ModelHighAPI_Interface
146 {
147 public:
148   /// Constructor without values
149   EXCHANGEAPI_EXPORT
150   explicit ExchangeAPI_Import_Image(const std::shared_ptr<ModelAPI_Feature> & theFeature);
151   /// Constructor with values
152   EXCHANGEAPI_EXPORT
153   ExchangeAPI_Import_Image(const std::shared_ptr<ModelAPI_Feature> & theFeature,
154                      const std::string & theFilePath);
155
156   /// Destructor
157   EXCHANGEAPI_EXPORT
158   virtual ~ExchangeAPI_Import_Image() = default;
159
160   INTERFACE_1(ExchangePlugin_Import_ImageFeature::ID(),
161               filePath, ExchangePlugin_Import_ImageFeature::FILE_PATH_ID(),
162               ModelAPI_AttributeString, /** File path */
163   )
164
165   /// Set point values
166   EXCHANGEAPI_EXPORT
167   void setFilePath(const std::string & theFilePath);
168
169   /// Dump wrapped feature
170   EXCHANGEAPI_EXPORT
171   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
172
173 };
174
175 //! Pointer on Import object
176 typedef std::shared_ptr<ExchangeAPI_Import_Image> ImportImagePtr;
177
178
179 EXCHANGEAPI_EXPORT
180 ImportImagePtr addImportImage(const std::shared_ptr<ModelAPI_Document> & thePart,
181                     const std::string & theFilePath);
182
183 //--------------------------------------------------------------------------------------
184 #endif /* SRC_EXCHANGEAPI_EXCHANGEAPI_IMPORT_H_ */