Salome HOME
Use ID() static functions of ConstructionAPI_Plane & ConstructionAPI_Point in add...
[modules/shaper.git] / src / ConstructionAPI / ConstructionAPI_Plane.cpp
1 // Name   : ConstructionAPI_Plane.cpp
2 // Purpose: 
3 //
4 // History:
5 // 27/05/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ConstructionAPI_Plane.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Double.h>
11 #include <ModelHighAPI_Selection.h>
12 //--------------------------------------------------------------------------------------
13 ConstructionAPI_Plane::ConstructionAPI_Plane(
14     const std::shared_ptr<ModelAPI_Feature> & theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 ConstructionAPI_Plane::ConstructionAPI_Plane(
21     const std::shared_ptr<ModelAPI_Feature> & theFeature,
22     const ModelHighAPI_Selection & theFace,
23     const ModelHighAPI_Double & theDistance)
24 : ModelHighAPI_Interface(theFeature)
25 {
26   if (initialize())
27     setFaceAndDistance(theFace, theDistance);
28 }
29
30 ConstructionAPI_Plane::ConstructionAPI_Plane(
31     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)
37 {
38   if (initialize())
39     setGeneralEquation(theA, theB, theC, theD);
40 }
41
42 ConstructionAPI_Plane::~ConstructionAPI_Plane()
43 {
44
45 }
46
47 //--------------------------------------------------------------------------------------
48 void ConstructionAPI_Plane::setFaceAndDistance(
49     const ModelHighAPI_Selection & theFace,
50     const ModelHighAPI_Double & theDistance)
51 {
52   theFace.fillAttribute(myface);
53   theDistance.fillAttribute(mydistance);
54
55   execute();
56 }
57
58 void ConstructionAPI_Plane::setGeneralEquation(
59     const ModelHighAPI_Double & theA,
60     const ModelHighAPI_Double & theB,
61     const ModelHighAPI_Double & theC,
62     const ModelHighAPI_Double & theD)
63 {
64   theA.fillAttribute(myA);
65   theB.fillAttribute(myB);
66   theC.fillAttribute(myC);
67   theD.fillAttribute(myD);
68
69   execute();
70 }
71
72 //--------------------------------------------------------------------------------------
73 // TODO(spo): make add* as static functions of the class
74
75 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
76                   const ModelHighAPI_Selection & theFace,
77                   const ModelHighAPI_Double & theDistance)
78 {
79   // TODO(spo): check that thePart is not empty
80   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
81   return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance));
82 }
83
84 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
85                   const ModelHighAPI_Double & theA,
86                   const ModelHighAPI_Double & theB,
87                   const ModelHighAPI_Double & theC,
88                   const ModelHighAPI_Double & theD)
89 {
90   // TODO(spo): check that thePart is not empty
91   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
92   return PlanePtr(new ConstructionAPI_Plane(aFeature, theA, theB, theC, theD));
93 }