SHAPER 9.16.0
ExchangePlugin_ImportFeature.h
1// Copyright (C) 2014-2026 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 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#include <GeomAPI_Shape.h>
28
29#include <map>
30
39{
40public:
42 inline static const std::string& FILE_PATH_ID()
43 {
44 static const std::string MY_FILE_PATH_ID("file_path");
45 return MY_FILE_PATH_ID;
46 }
48 inline static const std::string& FEATURES_ID()
49 {
50 static const std::string MY_FEATURES_ID("Features");
51 return MY_FEATURES_ID;
52 }
54 inline static const std::string& TARGET_PART_ID()
55 {
56 static const std::string MY_TARGET_PART_ID("target_part");
57 return MY_TARGET_PART_ID;
58 }
60 EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeatureBase() = default;
62 EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportFeatureBase() = default;
63
65 EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind() = 0;
66
68 EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
69
71 EXCHANGEPLUGIN_EXPORT virtual void execute() = 0;
72
74 EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
75
77 virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
78
80 virtual int numberOfSubs(bool forTree = false) const;
81
83 virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
84
86 virtual int subFeatureId(const int theIndex) const;
87
89 virtual bool isSub(ObjectPtr theObject) const;
90
92 virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
93
94 protected:
96 EXCHANGEPLUGIN_EXPORT virtual void importFile(const std::string& theFileName) = 0;
97
99 std::shared_ptr<ModelAPI_ResultBody> createResultBody(
100 std::shared_ptr<GeomAPI_Shape> aGeomShape);
101
103 void loadNamingDS(std::shared_ptr<GeomAPI_Shape> theGeomShape,
104 std::shared_ptr<ModelAPI_ResultBody> theResultBody);
105};
106
108{
109public:
111 inline static const std::string& ID()
112 {
113 static const std::string MY_IMPORT_ID("Import");
114 return MY_IMPORT_ID;
115 }
117 inline static const std::string& IMPORT_TYPE_ID()
118 {
119 static const std::string MY_IMPORT_TYPE_ID("ImportType");
120 return MY_IMPORT_TYPE_ID;
121 }
123 inline static const std::string& STEP_FILE_PATH_ID()
124 {
125 static const std::string MY_STEP_FILE_PATH_ID("step_file_path");
126 return MY_STEP_FILE_PATH_ID;
127 }
128
130 EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature() = default;
132 EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_ImportFeature() = default;
133
135 inline static const std::string& STEP_SCALE_INTER_UNITS_ID()
136 {
137 static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units");
138 return MY_STEP_SCALE_INTER_UNITS_ID;
139 }
141 inline static const std::string& STEP_MATERIALS_ID()
142 {
143 static const std::string MY_STEP_MATERIALS_ID("step_materials");
144 return MY_STEP_MATERIALS_ID;
145 }
147 inline static const std::string& STEP_COLORS_ID()
148 {
149 static const std::string MY_STEP_COLORS_ID("step_colors");
150 return MY_STEP_COLORS_ID;
151 }
153 inline static const std::string& MEMORY_BUFFER_ID()
154 {
155 static const std::string MY_MEMORY_BUFFER_ID("memory_buffer");
156 return MY_MEMORY_BUFFER_ID;
157 }
159 EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind() override
160 {
162 }
163
165 EXCHANGEPLUGIN_EXPORT virtual void execute() override;
166
168 EXCHANGEPLUGIN_EXPORT virtual void initAttributes();
169
171 EXCHANGEPLUGIN_EXPORT virtual bool isEditable();
172
173protected:
175 EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName) override;
176
178 EXCHANGEPLUGIN_EXPORT void importXAO(const std::string& theFileName,
179 const std::string& theMemoryBuff = std::string(),
180 const bool isMemoryImport = false);
181
182private:
184 void setColorGroups(std::shared_ptr<ModelAPI_ResultBody> theResultBody);
185
187 void setColorGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
188 std::vector<int>& theColor,
189 const std::wstring& theName );
190
192 void setMaterielGroup(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
193 std::map< std::wstring, std::list<std::wstring>>& theMaterialShape);
194
195};
196
198{
199 public:
201 inline static const std::string& ID()
202 {
203 static const std::string MY_IMPORT_ID("ImportImage");
204 return MY_IMPORT_ID;
205 }
206
208 EXCHANGEPLUGIN_EXPORT ExchangePlugin_Import_ImageFeature() = default;
210 EXCHANGEPLUGIN_EXPORT virtual ~ExchangePlugin_Import_ImageFeature() = default;
211
213 EXCHANGEPLUGIN_EXPORT virtual const std::string& getKind() override
214 {
216 }
217
219 EXCHANGEPLUGIN_EXPORT virtual void execute() override;
220
221protected:
223 EXCHANGEPLUGIN_EXPORT void importFile(const std::string& theFileName) override;
224
225};
226#endif /* IMPORT_IMPORTFEATURE_H_ */
Definition: ExchangePlugin_ImportFeature.h:39
virtual void removeFeature(std::shared_ptr< ModelAPI_Feature > theFeature)
Reimplemented from ModelAPI_CompositeFeature::removeFeature()
Definition: ExchangePlugin_ImportFeature.cpp:616
virtual std::shared_ptr< ModelAPI_Feature > subFeature(const int theIndex, bool forTree=false)
Reimplemented from ModelAPI_CompositeFeature::subFeature()
Definition: ExchangePlugin_ImportFeature.cpp:631
void loadNamingDS(std::shared_ptr< GeomAPI_Shape > theGeomShape, std::shared_ptr< ModelAPI_ResultBody > theResultBody)
Loads Naming data structure to the document.
Definition: ExchangePlugin_ImportFeature.cpp:669
virtual std::shared_ptr< ModelAPI_Feature > addFeature(std::string theID)
Reimplemented from ModelAPI_CompositeFeature::addFeature()
Definition: ExchangePlugin_ImportFeature.cpp:604
virtual int numberOfSubs(bool forTree=false) const
Reimplemented from ModelAPI_CompositeFeature::numberOfSubs()
Definition: ExchangePlugin_ImportFeature.cpp:626
virtual void execute()=0
Computes or recomputes the results.
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: ExchangePlugin_ImportFeature.cpp:76
std::shared_ptr< ModelAPI_ResultBody > createResultBody(std::shared_ptr< GeomAPI_Shape > aGeomShape)
Creates and prepares a result body from the shape.
Definition: ExchangePlugin_ImportFeature.cpp:174
virtual int subFeatureId(const int theIndex) const
Reimplemented from ModelAPI_CompositeFeature::subFeatureId()
Definition: ExchangePlugin_ImportFeature.cpp:640
static const std::string & FILE_PATH_ID()
attribute name of file path
Definition: ExchangePlugin_ImportFeature.h:42
virtual ~ExchangePlugin_ImportFeatureBase()=default
Default destructor.
virtual bool isSub(ObjectPtr theObject) const
Reimplemented from ModelAPI_CompositeFeature::isSub()
Definition: ExchangePlugin_ImportFeature.cpp:659
static const std::string & FEATURES_ID()
All features (list of references)
Definition: ExchangePlugin_ImportFeature.h:48
virtual const std::string & getKind()=0
Returns the unique kind of a feature.
virtual bool isPreviewNeeded() const
Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
Definition: ExchangePlugin_ImportFeature.h:74
virtual void importFile(const std::string &theFileName)=0
Performs the import of the file.
ExchangePlugin_ImportFeatureBase()=default
Default constructor.
static const std::string & TARGET_PART_ID()
attribute name of target part
Definition: ExchangePlugin_ImportFeature.h:54
Feature for import shapes from the external files in CAD formats.
Definition: ExchangePlugin_ImportFeature.h:108
static const std::string & IMPORT_TYPE_ID()
Feature kind.
Definition: ExchangePlugin_ImportFeature.h:117
static const std::string & STEP_COLORS_ID()
attribute name of step colors
Definition: ExchangePlugin_ImportFeature.h:147
static const std::string & ID()
Feature kind.
Definition: ExchangePlugin_ImportFeature.h:111
virtual ~ExchangePlugin_ImportFeature()=default
Default destructor.
ExchangePlugin_ImportFeature()=default
Default constructor.
virtual const std::string & getKind() override
Returns the unique kind of a feature.
Definition: ExchangePlugin_ImportFeature.h:159
virtual bool isEditable()
Return false in case of XAOMem import.
Definition: ExchangePlugin_ImportFeature.cpp:114
static const std::string & STEP_SCALE_INTER_UNITS_ID()
attribute name of step Scale to International System Units
Definition: ExchangePlugin_ImportFeature.h:135
static const std::string & MEMORY_BUFFER_ID()
attribute memory buffer
Definition: ExchangePlugin_ImportFeature.h:153
void importXAO(const std::string &theFileName, const std::string &theMemoryBuff=std::string(), const bool isMemoryImport=false)
Performs the import of XAO file.
Definition: ExchangePlugin_ImportFeature.cpp:391
static const std::string & STEP_FILE_PATH_ID()
attribute name of file path
Definition: ExchangePlugin_ImportFeature.h:123
virtual void execute() override
Computes or recomputes the results.
Definition: ExchangePlugin_ImportFeature.cpp:129
void importFile(const std::string &theFileName) override
Performs the import of the file.
Definition: ExchangePlugin_ImportFeature.cpp:183
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: ExchangePlugin_ImportFeature.cpp:89
static const std::string & STEP_MATERIALS_ID()
attribute name of step materiels
Definition: ExchangePlugin_ImportFeature.h:141
Definition: ExchangePlugin_ImportFeature.h:198
virtual const std::string & getKind() override
Returns the unique kind of a feature.
Definition: ExchangePlugin_ImportFeature.h:213
virtual ~ExchangePlugin_Import_ImageFeature()=default
Default destructor.
virtual void execute() override
Computes or recomputes the results.
Definition: ExchangePlugin_ImportFeature.cpp:163
static const std::string & ID()
Feature kind.
Definition: ExchangePlugin_ImportFeature.h:201
ExchangePlugin_Import_ImageFeature()=default
Default constructor.
void importFile(const std::string &theFileName) override
Performs the import of the file.
Definition: ExchangePlugin_ImportFeature.cpp:695
Feature that consists of other features: like sketcher with edges inside.
Definition: ModelAPI_CompositeFeature.h:33