Salome HOME
updated copyright message
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Tools.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_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_
21 #define SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_
22
23 //--------------------------------------------------------------------------------------
24 #include "ModelHighAPI.h"
25 #include <ModelAPI_AttributeTables.h>
26
27 #include <GeomAPI_Shape.h>
28
29 #include <list>
30 #include <memory>
31 #include <string>
32 //--------------------------------------------------------------------------------------
33 class GeomAPI_Dir;
34 class GeomAPI_Pnt;
35 class GeomAPI_Pnt2d;
36 //--------------------------------------------------------------------------------------
37 class GeomDataAPI_Dir;
38 class GeomDataAPI_Point;
39 class GeomDataAPI_Point2D;
40 class GeomDataAPI_Point2DArray;
41 //--------------------------------------------------------------------------------------
42 class ModelAPI_AttributeBoolean;
43 class ModelAPI_AttributeDouble;
44 class ModelAPI_AttributeDoubleArray;
45 class ModelAPI_AttributeIntArray;
46 class ModelAPI_AttributeInteger;
47 class ModelAPI_AttributeRefAttr;
48 class ModelAPI_AttributeRefAttrList;
49 class ModelAPI_AttributeReference;
50 class ModelAPI_AttributeRefList;
51 class ModelAPI_AttributeSelection;
52 class ModelAPI_AttributeSelectionList;
53 class ModelAPI_AttributeString;
54 class ModelAPI_AttributeStringArray;
55 class ModelAPI_Object;
56 //--------------------------------------------------------------------------------------
57 class ModelHighAPI_Double;
58 class ModelHighAPI_Integer;
59 class ModelHighAPI_RefAttr;
60 class ModelHighAPI_Reference;
61 class ModelHighAPI_Selection;
62 //--------------------------------------------------------------------------------------
63 MODELHIGHAPI_EXPORT
64 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
65                    const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute);
66
67 MODELHIGHAPI_EXPORT
68 void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
69                    double theX, double theY);
70
71 MODELHIGHAPI_EXPORT
72 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
73                    const std::shared_ptr<GeomDataAPI_Dir> & theAttribute);
74
75 MODELHIGHAPI_EXPORT
76 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt> & theValue,
77                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute);
78
79 //--------------------------------------------------------------------------------------
80 MODELHIGHAPI_EXPORT
81 void fillAttribute(bool theValue,
82                    const std::shared_ptr<ModelAPI_AttributeBoolean> & theAttribute);
83
84 MODELHIGHAPI_EXPORT
85 void fillAttribute(const ModelHighAPI_Double & theValue,
86                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute);
87
88 MODELHIGHAPI_EXPORT
89 void fillAttribute(double theValue,
90                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute);
91
92 MODELHIGHAPI_EXPORT
93 void fillAttribute(const ModelHighAPI_Integer & theValue,
94                    const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute);
95
96 MODELHIGHAPI_EXPORT
97 void fillAttribute(int theValue,
98                    const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute);
99
100 MODELHIGHAPI_EXPORT
101 void fillAttribute(const ModelHighAPI_RefAttr & theValue,
102                    const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute);
103
104 MODELHIGHAPI_EXPORT
105 void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
106                    const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute);
107
108 MODELHIGHAPI_EXPORT
109 void fillAttribute(const ModelHighAPI_Reference & theValue,
110                    const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute);
111
112 MODELHIGHAPI_EXPORT
113 void fillAttribute(const std::list<ModelHighAPI_Reference> & theValue,
114                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute);
115
116 MODELHIGHAPI_EXPORT
117 void fillAttribute(const std::shared_ptr<ModelAPI_Object> & theValue,
118                    const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute);
119
120 MODELHIGHAPI_EXPORT
121 void fillAttribute(const std::list<std::shared_ptr<ModelAPI_Object> > & theValue,
122                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute);
123
124 MODELHIGHAPI_EXPORT
125 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
126                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute);
127
128 MODELHIGHAPI_EXPORT
129 void fillAttribute(const ModelHighAPI_Selection & theValue,
130                    const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute);
131
132 MODELHIGHAPI_EXPORT
133 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
134                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute);
135
136 MODELHIGHAPI_EXPORT
137 void fillAttribute(const std::string & theValue,
138                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
139
140 MODELHIGHAPI_EXPORT
141 void fillAttribute(const std::wstring & theValue,
142   const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
143
144 MODELHIGHAPI_EXPORT
145 void fillAttribute(const char * theValue,
146                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
147
148 MODELHIGHAPI_EXPORT
149 void fillAttribute(const std::list<std::string> & theValue,
150                    const std::shared_ptr<ModelAPI_AttributeStringArray> & theAttribute);
151
152 MODELHIGHAPI_EXPORT
153 void fillAttribute(const std::list<ModelHighAPI_Integer> & theValue,
154                    const std::shared_ptr<ModelAPI_AttributeIntArray> & theAttribute);
155
156 MODELHIGHAPI_EXPORT
157 void fillAttribute(const std::list<ModelHighAPI_Double> & theValue,
158                    const std::shared_ptr<ModelAPI_AttributeDoubleArray> & theAttribute);
159
160 MODELHIGHAPI_EXPORT
161 void fillAttribute(const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & theValue,
162                    const std::shared_ptr<GeomDataAPI_Point2DArray> & theAttribute);
163
164 MODELHIGHAPI_EXPORT
165 void fillAttribute(const ModelHighAPI_Double & theX,
166                    const ModelHighAPI_Double & theY,
167                    const ModelHighAPI_Double & theZ,
168                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute);
169
170 MODELHIGHAPI_EXPORT
171 GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr);
172
173 MODELHIGHAPI_EXPORT
174 std::string strByShapeType(GeomAPI_Shape::ShapeType theShapeType);
175
176 MODELHIGHAPI_EXPORT
177 GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
178
179 MODELHIGHAPI_EXPORT
180 ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr);
181
182 MODELHIGHAPI_EXPORT
183 std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType);
184
185 /// Enumeration to manage the check python dump modes.
186 enum checkDumpType {
187   CHECK_NAMING = 1, ///< check topological naming only
188   CHECK_GEOMETRICAL = 2, ///< check geometrical naming only
189   CHECK_NAMING_AND_GEOMETRICAL = 3, ///< default option, check topological and geometrical dumps
190   CHECK_WEAK = 4, ///< check weak naming only
191 };
192
193 /// Performs the high level API dump, then closes all and executes the script:
194 /// model must be recreated fully, with all attributes
195 /// \returns true if check is well done
196 MODELHIGHAPI_EXPORT
197 bool checkPyDump(const std::string& theFilenameNaming,
198                  const std::string& theFilenameGeo,
199                  const std::string& theFilenameWeak,
200                  const checkDumpType theCheckType = CHECK_NAMING_AND_GEOMETRICAL);
201
202 //--------------------------------------------------------------------------------------
203 //--------------------------------------------------------------------------------------
204 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ */