Salome HOME
Add SketchAPI and Line feature. Also fix tests.
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Tools.cpp
1 // Name   : ModelHighAPI_Tools.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Tools.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Dir.h>
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Pnt2d.h>
13 //--------------------------------------------------------------------------------------
14 #include <GeomDataAPI_Dir.h>
15 #include <GeomDataAPI_Point.h>
16 #include <GeomDataAPI_Point2D.h>
17 //--------------------------------------------------------------------------------------
18 #include <ModelAPI_AttributeBoolean.h>
19 #include <ModelAPI_AttributeDocRef.h>
20 #include <ModelAPI_AttributeDouble.h>
21 #include <ModelAPI_AttributeIntArray.h>
22 #include <ModelAPI_AttributeInteger.h>
23 #include <ModelAPI_AttributeRefAttr.h>
24 #include <ModelAPI_AttributeRefAttrList.h>
25 #include <ModelAPI_AttributeReference.h>
26 #include <ModelAPI_AttributeRefList.h>
27 #include <ModelAPI_AttributeSelection.h>
28 #include <ModelAPI_AttributeSelectionList.h>
29 #include <ModelAPI_AttributeString.h>
30 //--------------------------------------------------------------------------------------
31 #include "ModelHighAPI_Double.h"
32 #include "ModelHighAPI_Selection.h"
33
34 //--------------------------------------------------------------------------------------
35 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
36                    const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute)
37 {
38   theAttribute->setValue(theValue);
39 }
40
41 void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
42                    double theX, double theY)
43 {
44   theAttribute->setValue(theX, theY);
45 }
46
47 //--------------------------------------------------------------------------------------
48 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
49                    const std::shared_ptr<GeomDataAPI_Dir> & theAttribute)
50 {
51   theAttribute->setValue(theValue);
52 }
53
54 //--------------------------------------------------------------------------------------
55 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt> & theValue,
56                    const std::shared_ptr<GeomDataAPI_Point> & theAttribute)
57 {
58   theAttribute->setValue(theValue);
59 }
60
61 //--------------------------------------------------------------------------------------
62 void fillAttribute(bool theValue,
63                    const std::shared_ptr<ModelAPI_AttributeBoolean> & theAttribute)
64 {
65   theAttribute->setValue(theValue);
66 }
67
68 //--------------------------------------------------------------------------------------
69 void fillAttribute(const ModelHighAPI_Double & theValue,
70                    const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
71 {
72   theValue.fillAttribute(theAttribute);
73 }
74
75 //--------------------------------------------------------------------------------------
76 void fillAttribute(const ModelHighAPI_Selection & theValue,
77                    const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
78 {
79   theValue.fillAttribute(theAttribute);
80 }
81
82 //--------------------------------------------------------------------------------------
83 void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
84                    const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
85 {
86   theAttribute->clear();
87   for (auto it = theValue.begin(); it != theValue.end(); ++it)
88     it->appendToList(theAttribute);
89 }
90
91 //--------------------------------------------------------------------------------------
92 void fillAttribute(const std::string & theValue,
93                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
94 {
95   theAttribute->setValue(theValue);
96 }
97 //--------------------------------------------------------------------------------------