1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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 SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_
21 #define SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_
23 //--------------------------------------------------------------------------------------
24 #include "ModelHighAPI.h"
25 #include <ModelAPI_AttributeTables.h>
27 #include <GeomAPI_Shape.h>
32 //--------------------------------------------------------------------------------------
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 //--------------------------------------------------------------------------------------
64 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
65 const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute);
68 void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
69 double theX, double theY);
72 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
73 const std::shared_ptr<GeomDataAPI_Dir> & theAttribute);
76 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt> & theValue,
77 const std::shared_ptr<GeomDataAPI_Point> & theAttribute);
79 //--------------------------------------------------------------------------------------
81 void fillAttribute(bool theValue,
82 const std::shared_ptr<ModelAPI_AttributeBoolean> & theAttribute);
85 void fillAttribute(const ModelHighAPI_Double & theValue,
86 const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute);
89 void fillAttribute(double theValue,
90 const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute);
93 void fillAttribute(const ModelHighAPI_Integer & theValue,
94 const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute);
97 void fillAttribute(int theValue,
98 const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute);
101 void fillAttribute(const ModelHighAPI_RefAttr & theValue,
102 const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute);
105 void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
106 const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute);
109 void fillAttribute(const ModelHighAPI_Reference & theValue,
110 const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute);
113 void fillAttribute(const std::list<ModelHighAPI_Reference> & theValue,
114 const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute);
117 void fillAttribute(const std::shared_ptr<ModelAPI_Object> & theValue,
118 const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute);
121 void fillAttribute(const std::list<std::shared_ptr<ModelAPI_Object> > & theValue,
122 const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute);
125 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
126 const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute);
129 void fillAttribute(const ModelHighAPI_Selection & theValue,
130 const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute);
133 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
134 const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute);
137 void fillAttribute(const std::string & theValue,
138 const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
140 void fillAttribute(const char * theValue,
141 const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
144 void fillAttribute(const std::list<std::string> & theValue,
145 const std::shared_ptr<ModelAPI_AttributeStringArray> & theAttribute);
148 void fillAttribute(const std::list<ModelHighAPI_Integer> & theValue,
149 const std::shared_ptr<ModelAPI_AttributeIntArray> & theAttribute);
152 void fillAttribute(const std::list<ModelHighAPI_Double> & theValue,
153 const std::shared_ptr<ModelAPI_AttributeDoubleArray> & theAttribute);
156 void fillAttribute(const std::list<std::shared_ptr<GeomAPI_Pnt2d> > & theValue,
157 const std::shared_ptr<GeomDataAPI_Point2DArray> & theAttribute);
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);
166 GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr);
169 std::string strByShapeType(GeomAPI_Shape::ShapeType theShapeType);
172 GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
175 ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr);
178 std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType);
180 /// Enumeration to manage the check python dump modes.
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
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
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);
197 //--------------------------------------------------------------------------------------
198 //--------------------------------------------------------------------------------------
199 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ */