1 // Name : ConstructionAPI_Plane.cpp
5 // 27/05/16 - Sergey POKHODENKO - Creation of the file
7 #include "ConstructionAPI_Plane.h"
9 #include <ModelHighAPI_Tools.h>
11 //==================================================================================================
12 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
18 //==================================================================================================
19 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
20 const ModelHighAPI_Selection& theFace,
21 const ModelHighAPI_Double& theDistance,
22 const bool theIsReverse)
23 : ModelHighAPI_Interface(theFeature)
26 setByFaceAndDistance(theFace, theDistance, theIsReverse);
30 //==================================================================================================
31 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
32 const ModelHighAPI_Double& theA,
33 const ModelHighAPI_Double& theB,
34 const ModelHighAPI_Double& theC,
35 const ModelHighAPI_Double& theD)
36 : ModelHighAPI_Interface(theFeature)
39 setByGeneralEquation(theA, theB, theC, theD);
43 //==================================================================================================
44 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45 const ModelHighAPI_Selection& thePoint1,
46 const ModelHighAPI_Selection& thePoint2,
47 const ModelHighAPI_Selection& thePoint3)
48 : ModelHighAPI_Interface(theFeature)
51 setByThreePoints(thePoint1, thePoint2, thePoint3);
55 //==================================================================================================
56 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
57 const ModelHighAPI_Selection& theLine,
58 const ModelHighAPI_Selection& thePoint,
59 const bool theIsPerpendicular)
60 : ModelHighAPI_Interface(theFeature)
63 setByLineAndPoint(theLine, thePoint, theIsPerpendicular);
67 //==================================================================================================
68 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
69 const ModelHighAPI_Selection& theObject1,
70 const ModelHighAPI_Selection& theObject2)
71 : ModelHighAPI_Interface(theFeature)
74 GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1);
75 GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2);
76 if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::VERTEX) {
77 setByCoincidentToPoint(theObject1, theObject2);
78 } else if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::FACE) {
79 setByTwoParallelPlanes(theObject1, theObject2);
84 //==================================================================================================
85 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
86 const ModelHighAPI_Selection& thePlane,
87 const ModelHighAPI_Selection& theAxis,
88 const ModelHighAPI_Double& theAngle)
89 : ModelHighAPI_Interface(theFeature)
92 setByRotation(thePlane, theAxis, theAngle);
96 //==================================================================================================
97 ConstructionAPI_Plane::~ConstructionAPI_Plane()
101 //==================================================================================================
102 void ConstructionAPI_Plane::setByFaceAndDistance(const ModelHighAPI_Selection& theFace,
103 const ModelHighAPI_Double& theDistance,
104 const bool theIsReverse)
106 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
107 fillAttribute(theFace, myplane);
108 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_DISTANCE_FROM_OTHER(), mycreationMethodByOtherPlane);
109 fillAttribute(theDistance, mydistance);
110 fillAttribute(theIsReverse, myreverse);
115 //==================================================================================================
116 void ConstructionAPI_Plane::setByGeneralEquation(const ModelHighAPI_Double& theA,
117 const ModelHighAPI_Double& theB,
118 const ModelHighAPI_Double& theC,
119 const ModelHighAPI_Double& theD)
121 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_GENERAL_EQUATION(), mycreationMethod);
122 fillAttribute(theA, myA);
123 fillAttribute(theB, myB);
124 fillAttribute(theC, myC);
125 fillAttribute(theD, myD);
130 //==================================================================================================
131 void ConstructionAPI_Plane::setByThreePoints(const ModelHighAPI_Selection& thePoint1,
132 const ModelHighAPI_Selection& thePoint2,
133 const ModelHighAPI_Selection& thePoint3)
135 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_THREE_POINTS(), mycreationMethod);
136 fillAttribute(thePoint1, mypoint1);
137 fillAttribute(thePoint2, mypoint2);
138 fillAttribute(thePoint3, mypoint3);
143 //==================================================================================================
144 void ConstructionAPI_Plane::setByLineAndPoint(const ModelHighAPI_Selection& theLine,
145 const ModelHighAPI_Selection& thePoint,
146 const bool theIsPerpendicular)
148 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_LINE_AND_POINT(), mycreationMethod);
149 fillAttribute(theLine, myline);
150 fillAttribute(thePoint, mypoint);
151 fillAttribute(theIsPerpendicular, myperpendicular);
156 //==================================================================================================
157 void ConstructionAPI_Plane::setByTwoParallelPlanes(const ModelHighAPI_Selection& thePlane1,
158 const ModelHighAPI_Selection& thePlane2)
160 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_TWO_PARALLEL_PLANES(), mycreationMethod);
161 fillAttribute(thePlane1, myplane1);
162 fillAttribute(thePlane2, myplane2);
167 //==================================================================================================
168 void ConstructionAPI_Plane::setByCoincidentToPoint(const ModelHighAPI_Selection& thePlane,
169 const ModelHighAPI_Selection& thePoint)
171 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
172 fillAttribute(thePlane, myplane);
173 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_COINCIDENT_TO_POINT(), mycreationMethodByOtherPlane);
174 fillAttribute(thePoint, mycoincidentPoint);
179 //==================================================================================================
180 void ConstructionAPI_Plane::setByRotation(const ModelHighAPI_Selection& thePlane,
181 const ModelHighAPI_Selection& theAxis,
182 const ModelHighAPI_Double& theAngle)
184 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
185 fillAttribute(thePlane, myplane);
186 fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_ROTATION(), mycreationMethodByOtherPlane);
187 fillAttribute(theAxis, myaxis);
188 fillAttribute(theAngle, myangle);
193 //==================================================================================================
194 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
195 const ModelHighAPI_Selection& theFace,
196 const ModelHighAPI_Double& theDistance,
197 const bool theIsReverse)
199 // TODO(spo): check that thePart is not empty
200 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
201 return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance, theIsReverse));
204 //==================================================================================================
205 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
206 const ModelHighAPI_Double& theA,
207 const ModelHighAPI_Double& theB,
208 const ModelHighAPI_Double& theC,
209 const ModelHighAPI_Double& theD)
211 // TODO(spo): check that thePart is not empty
212 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
213 return PlanePtr(new ConstructionAPI_Plane(aFeature, theA, theB, theC, theD));
216 //==================================================================================================
217 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
218 const ModelHighAPI_Selection& thePoint1,
219 const ModelHighAPI_Selection& thePoint2,
220 const ModelHighAPI_Selection& thePoint3)
222 // TODO(spo): check that thePart is not empty
223 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
224 return PlanePtr(new ConstructionAPI_Plane(aFeature, thePoint1, thePoint2, thePoint3));
227 //==================================================================================================
228 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
229 const ModelHighAPI_Selection& theLine,
230 const ModelHighAPI_Selection& thePoint,
231 const bool theIsPerpendicular)
233 // TODO(spo): check that thePart is not empty
234 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
235 return PlanePtr(new ConstructionAPI_Plane(aFeature, theLine, thePoint, theIsPerpendicular));
238 //==================================================================================================
239 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
240 const ModelHighAPI_Selection& theObject1,
241 const ModelHighAPI_Selection& theObject2)
243 // TODO(spo): check that thePart is not empty
244 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
245 return PlanePtr(new ConstructionAPI_Plane(aFeature, theObject1, theObject2));
248 //==================================================================================================
249 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
250 const ModelHighAPI_Selection& thePlane,
251 const ModelHighAPI_Selection& theAxis,
252 const ModelHighAPI_Double& theAngle)
254 // TODO(spo): check that thePart is not empty
255 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
256 return PlanePtr(new ConstructionAPI_Plane(aFeature, thePlane, theAxis, theAngle));