1 // Name : ConstructionAPI_Axis.cpp
5 // 15/06/16 - Sergey POKHODENKO - Creation of the file
7 #include "ConstructionAPI_Axis.h"
9 #include <ModelHighAPI_Tools.h>
11 //==================================================================================================
12 ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
18 //==================================================================================================
19 ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
20 const ModelHighAPI_Selection& theObject1,
21 const ModelHighAPI_Selection& theObject2)
22 : ModelHighAPI_Interface(theFeature)
25 GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1);
26 GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2);
27 if(aType1 == GeomAPI_Shape::VERTEX && aType2 == GeomAPI_Shape::VERTEX) {
28 setByPoints(theObject1, theObject2);
29 } else if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::VERTEX) {
30 setByPlaneAndPoint(theObject1, theObject2);
31 } else if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::FACE) {
32 setByTwoPlanes(theObject1, theObject2);
37 //==================================================================================================
38 ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
39 const ModelHighAPI_Selection& theObject)
40 : ModelHighAPI_Interface(theFeature)
43 GeomAPI_Shape::ShapeType aType = getShapeType(theObject);
44 if(aType == GeomAPI_Shape::EDGE) {
46 } else if(aType == GeomAPI_Shape::FACE) {
47 setByCylindricalFace(theObject);
52 //==================================================================================================
53 ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
54 const ModelHighAPI_Selection& thePoint,
55 const ModelHighAPI_Double& theX,
56 const ModelHighAPI_Double& theY,
57 const ModelHighAPI_Double& theZ)
58 : ModelHighAPI_Interface(theFeature)
61 setByPointAndDirection(thePoint, theX, theY, theZ);
65 //==================================================================================================
66 ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
67 const ModelHighAPI_Double& theDX,
68 const ModelHighAPI_Double& theDY,
69 const ModelHighAPI_Double& theDZ)
70 : ModelHighAPI_Interface(theFeature)
73 setByDimensions(theDX, theDY, theDZ);
77 //==================================================================================================
78 ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
79 const ModelHighAPI_Selection& thePlane1,
80 const ModelHighAPI_Double& theOffset1,
81 const bool theReverseOffset1,
82 const ModelHighAPI_Selection& thePlane2,
83 const ModelHighAPI_Double& theOffset2,
84 const bool theReverseOffset2)
85 : ModelHighAPI_Interface(theFeature)
88 setByTwoPlanes(thePlane1, theOffset1, theReverseOffset1, thePlane2, theOffset2, theReverseOffset2);
92 //==================================================================================================
93 ConstructionAPI_Axis::~ConstructionAPI_Axis()
97 //==================================================================================================
98 void ConstructionAPI_Axis::setByPoints(const ModelHighAPI_Selection& thePoint1,
99 const ModelHighAPI_Selection& thePoint2)
101 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_POINTS(), creationMethod());
102 fillAttribute(thePoint1, firstPoint());
103 fillAttribute(thePoint2, secondPoint());
108 //==================================================================================================
109 void ConstructionAPI_Axis::setByCylindricalFace(const ModelHighAPI_Selection& theCylindricalFace)
111 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_CYLINDRICAL_FACE(), creationMethod());
112 fillAttribute(theCylindricalFace, cylindricalFace());
117 //==================================================================================================
118 void ConstructionAPI_Axis::setByPointAndDirection(const ModelHighAPI_Selection& thePoint,
119 const ModelHighAPI_Double& theX,
120 const ModelHighAPI_Double& theY,
121 const ModelHighAPI_Double& theZ)
123 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_POINT_AND_DIRECTION(), creationMethod());
124 fillAttribute(thePoint, firstPoint());
125 fillAttribute(theX, xDirection());
126 fillAttribute(theY, yDirection());
127 fillAttribute(theZ, zDirection());
132 //==================================================================================================
133 void ConstructionAPI_Axis::setByDimensions(const ModelHighAPI_Double& theDX,
134 const ModelHighAPI_Double& theDY,
135 const ModelHighAPI_Double& theDZ)
137 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
138 fillAttribute(theDX, xDimension());
139 fillAttribute(theDY, yDimension());
140 fillAttribute(theDZ, zDimension());
145 //==================================================================================================
146 void ConstructionAPI_Axis::setByLine(const ModelHighAPI_Selection& theLine)
148 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_LINE(), creationMethod());
149 fillAttribute(theLine, line());
154 //==================================================================================================
155 void ConstructionAPI_Axis::setByPlaneAndPoint(const ModelHighAPI_Selection& thePlane,
156 const ModelHighAPI_Selection& thePoint)
158 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_PLANE_AND_POINT(), creationMethod());
159 fillAttribute(thePlane, plane());
160 fillAttribute(thePoint, point());
165 //==================================================================================================
166 void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
167 const ModelHighAPI_Selection& thePlane2)
169 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
170 fillAttribute(thePlane1, plane1());
171 fillAttribute("", useOffset1());
172 fillAttribute(thePlane2, plane2());
173 fillAttribute("", useOffset2());
178 //==================================================================================================
179 void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
180 const ModelHighAPI_Double& theOffset1,
181 const bool theReverseOffset1,
182 const ModelHighAPI_Selection& thePlane2,
183 const ModelHighAPI_Double& theOffset2,
184 const bool theReverseOffset2)
186 fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
187 fillAttribute(thePlane1, plane1());
188 fillAttribute(ConstructionPlugin_Axis::USE_OFFSET1(), useOffset1());
189 fillAttribute(theOffset1, offset1());
190 fillAttribute(theReverseOffset1, reverseOffset1());
191 fillAttribute(thePlane2, plane2());
192 fillAttribute(ConstructionPlugin_Axis::USE_OFFSET2(), useOffset2());
193 fillAttribute(theOffset2, offset2());
194 fillAttribute(theReverseOffset2, reverseOffset2());
199 //==================================================================================================
200 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
201 const ModelHighAPI_Selection& thePoint1,
202 const ModelHighAPI_Selection& thePoint2)
204 // TODO(spo): check that thePart is not empty
205 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
206 return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint1, thePoint2));
209 //==================================================================================================
210 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
211 const ModelHighAPI_Selection& theObject)
213 // TODO(spo): check that thePart is not empty
214 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
215 return AxisPtr(new ConstructionAPI_Axis(aFeature, theObject));
218 //==================================================================================================
219 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
220 const ModelHighAPI_Selection& thePoint,
221 const ModelHighAPI_Double& theX,
222 const ModelHighAPI_Double& theY,
223 const ModelHighAPI_Double& theZ)
225 // TODO(spo): check that thePart is not empty
226 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
227 return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint, theX, theY, theZ));
230 //==================================================================================================
231 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
232 const ModelHighAPI_Double& theDX,
233 const ModelHighAPI_Double& theDY,
234 const ModelHighAPI_Double& theDZ)
236 // TODO(spo): check that thePart is not empty
237 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
238 return AxisPtr(new ConstructionAPI_Axis(aFeature, theDX, theDY, theDZ));
241 //==================================================================================================
242 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
243 const ModelHighAPI_Selection& thePlane1,
244 const ModelHighAPI_Double& theOffset1,
245 const bool theReverseOffset1,
246 const ModelHighAPI_Selection& thePlane2,
247 const ModelHighAPI_Double& theOffset2,
248 const bool theReverseOffset2)
250 // TODO(spo): check that thePart is not empty
251 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
252 return AxisPtr(new ConstructionAPI_Axis(aFeature, thePlane1, theOffset1, theReverseOffset1,
253 thePlane2, theOffset2, theReverseOffset2));