1 // Copyright (C) 2014-2024 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef EXCHANGEPLUGIN_EXPORTFEATURE_H_
21 #define EXCHANGEPLUGIN_EXPORTFEATURE_H_
23 #include <ExchangePlugin.h>
24 #include <ModelAPI_Feature.h>
25 #include <ModelAPI_Result.h>
30 * \class ExchangePlugin_ExportFeature
32 * \brief Feature for export shapes to the external files in CAD formats.
34 * The list of supported formats is defined in the configuration file.
36 class ExchangePlugin_ExportFeature : public ModelAPI_Feature
40 inline static const std::string& ID()
42 static const std::string MY_EXPORT_ID("Export");
45 /// attribute name for file format
46 inline static const std::string& EXPORT_TYPE_ID()
48 static const std::string MY_EXPORT_TYPE_ID("ExportType");
49 return MY_EXPORT_TYPE_ID;
51 /// attribute name of file path
52 inline static const std::string& FILE_PATH_ID()
54 static const std::string MY_FILE_PATH_ID("file_path");
55 return MY_FILE_PATH_ID;
57 /// attribute name of xao file path
58 inline static const std::string& XAO_FILE_PATH_ID()
60 static const std::string MY_XAO_FILE_PATH_ID("xao_file_path");
61 return MY_XAO_FILE_PATH_ID;
63 /// attribute name of stl file path
64 inline static const std::string& STL_FILE_PATH_ID()
66 static const std::string MY_STL_FILE_PATH_ID("stl_file_path");
67 return MY_STL_FILE_PATH_ID;
69 /// Attribute name for selected object to export in stl file path.
70 inline static const std::string& STL_OBJECT_SELECTED()
72 static const std::string ATTR_ID("stl_object_selected");
75 /// Attribute name for deflection type.
76 inline static const std::string& STL_DEFLECTION_TYPE()
78 static const std::string ATTR_ID("stl_deflection_type");
81 /// Attribute name for deflection type relative.
82 inline static const std::string& STL_DEFLECTION_TYPE_RELATIVE()
84 static const std::string ATTR_ID("stl_deflection_type_relative");
87 /// Attribute name for deflection type absolute.
88 inline static const std::string& STL_DEFLECTION_TYPE_ABSOLUTE()
90 static const std::string ATTR_ID("stl_deflection_type_absolute");
93 /// Attribute name for relative.
94 inline static const std::string& STL_RELATIVE()
96 static const std::string ATTR_ID("stl_relative");
99 /// Attribute name for absolute.
100 inline static const std::string& STL_ABSOLUTE()
102 static const std::string ATTR_ID("stl_absolute");
105 /// Attribute name for stl file type.
106 inline static const std::string& STL_FILE_TYPE()
108 static const std::string ATTR_ID("stl_file_type");
111 /// Attribute name for stl file type ascii.
112 inline static const std::string& STL_FILE_TYPE_ASCII()
114 static const std::string ATTR_ID("stl_file_type_acii");
117 /// Attribute name for stl file type binary.
118 inline static const std::string& STL_FILE_TYPE_BINARY()
120 static const std::string ATTR_ID("stl_file_type_binary");
123 /// attribute name of file format
124 inline static const std::string& FILE_FORMAT_ID()
126 static const std::string MY_FILE_FORMAT_ID("file_format");
127 return MY_FILE_FORMAT_ID;
129 /// attribute name of selection list
130 inline static const std::string& SELECTION_LIST_ID()
132 static const std::string MY_SELECTION_LIST_ID("selection_list");
133 return MY_SELECTION_LIST_ID;
135 /// attribute name of xao selection list
136 inline static const std::string& XAO_SELECTION_LIST_ID()
138 static const std::string MY_SELECTION_LIST_ID("xao_selection_list");
139 return MY_SELECTION_LIST_ID;
141 /// attribute name of author for XAO format
142 inline static const std::string& XAO_AUTHOR_ID()
144 static const std::string MY_XAO_AUTHOR_ID("xao_author");
145 return MY_XAO_AUTHOR_ID;
147 /// attribute name of geometry name for XAO format
148 inline static const std::string& XAO_GEOMETRY_NAME_ID()
150 static const std::string MY_XAO_GEOMETRY_NAME_ID("xao_geometry_name");
151 return MY_XAO_GEOMETRY_NAME_ID;
153 /// attribute name of xao shape file path
154 inline static const std::string& XAO_SHAPE_FILE_PATH_ID()
156 static const std::string MY_XAO_SHAPE_FILE_PATH_ID("xao_shape_file_path");
157 return MY_XAO_SHAPE_FILE_PATH_ID;
159 /// attribute flag to export shape in a separate file during xao export,
160 /// name of shape file will be xao_file_path + .brep
161 inline static const std::string& XAO_SHAPE_FILE_SEPARATE_ID()
163 static const std::string MY_XAO_SHAPE_FILE_SEPARATE_ID("xao_shape_file_separate");
164 return MY_XAO_SHAPE_FILE_SEPARATE_ID;
166 /// attribute string memory buffer
167 inline static const std::string& MEMORY_BUFFER_ID()
169 static const std::string MY_MEMORY_BUFFER_ID("memory_buffer");
170 return MY_MEMORY_BUFFER_ID;
173 /// Default constructor
174 EXCHANGEPLUGIN_EXPORT ExchangePlugin_ExportFeature();
175 /// Default destructor
176 EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ExportFeature();
178 /// Returns the unique kind of a feature
179 EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind()
181 return ExchangePlugin_ExportFeature::ID();
184 /// Request for initialization of data model of the feature: adding all attributes
185 EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
187 /// Reimplemented from ModelAPI_Feature::attributeChanged()
188 EXCHANGEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
190 /// Computes or recomputes the results
191 EXCHANGEPLUGIN_EXPORT virtual void execute();
193 /// Reimplemented from ModelAPI_Feature::isMacro(). Returns false.
194 // It is macro for not-XAO export. For XAO the feature is kept invisible in the tree
195 // for the export to GEOM functionality correct working.
196 EXCHANGEPLUGIN_EXPORT virtual bool isMacro() const;
198 /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
199 EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
201 /// Do not put in history.
202 /// Since it is not a macro, it is not deleted, but we don't want to see it.
203 bool isInHistory() { return false; }
206 /// Performs export of the file
207 EXCHANGEPLUGIN_EXPORT void exportFile(const std::string& theFileName,
208 const std::string& theFormat,
209 const bool isMemoryExport);
211 /// Performs export to XAO file
212 EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string& theFileName,
213 const bool isMemoryExport);
215 /// Performs export to STL file
216 EXCHANGEPLUGIN_EXPORT void exportSTL(const std::string& theFileName);
219 #endif /* EXPORT_EXPORTFEATURE_H_ */