Salome HOME
7f0e1c8962d7bbcc248a7e8a4092a0135525162c
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Tools.h
1 // Copyright (C) 2014-2021  CEA/DEN, EDF R&D
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 MODELHIGHAPI_EXPORT
140 void fillAttribute(const char * theValue,
141                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
142
143 MODELHIGHAPI_EXPORT
144 void fillAttribute(const std::list<std::string> & theValue,
145                    const std::shared_ptr<ModelAPI_AttributeStringArray> & theAttribute);
146
147 MODELHIGHAPI_EXPORT
148 void fillAttribute(const std::list<ModelHighAPI_Integer> & theValue,
149                    const std::shared_ptr<ModelAPI_AttributeIntArray> & theAttribute);
150
151 MODELHIGHAPI_EXPORT
152 void fillAttribute(const std::list<ModelHighAPI_Double> & theValue,
153                    const std::shared_ptr<ModelAPI_AttributeDoubleArray> & theAttribute);
154
155 MODELHIGHAPI_EXPORT
156 void fillAttribute(const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & theValue,
157                    const std::shared_ptr<GeomDataAPI_Point2DArray> & theAttribute);
158
159 MODELHIGHAPI_EXPORT
160 void fillAttribute(const ModelHighAPI_Double & theX,
161                    const ModelHighAPI_Double & theY,
162                    const ModelHighAPI_Double & theZ,
163                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute);
164
165 MODELHIGHAPI_EXPORT
166 GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr);
167
168 MODELHIGHAPI_EXPORT
169 std::string strByShapeType(GeomAPI_Shape::ShapeType theShapeType);
170
171 MODELHIGHAPI_EXPORT
172 GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
173
174 MODELHIGHAPI_EXPORT
175 ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr);
176
177 MODELHIGHAPI_EXPORT
178 std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType);
179
180 /// Enumeration to manage the check python dump modes.
181 enum checkDumpType {
182   CHECK_NAMING = 1, ///< check topological naming only
183   CHECK_GEOMETRICAL = 2, ///< check geometrical naming only
184   CHECK_NAMING_AND_GEOMETRICAL = 3, ///< default option, check topological and geometrical dumps
185   CHECK_WEAK = 4, ///< check weak naming only
186 };
187
188 /// Performs the high level API dump, then closes all and executes the script:
189 /// model must be recreated fully, with all attributes
190 /// \returns true if check is well done
191 MODELHIGHAPI_EXPORT
192 bool checkPyDump(const std::string& theFilenameNaming,
193                  const std::string& theFilenameGeo,
194                  const std::string& theFilenameWeak,
195                  const checkDumpType theCheckType = CHECK_NAMING_AND_GEOMETRICAL);
196
197 //--------------------------------------------------------------------------------------
198 //--------------------------------------------------------------------------------------
199 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ */