Salome HOME
61a72e06141b9c2e591b970908b11999fe970242
[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_Tools.h>
11 //--------------------------------------------------------------------------------------
12 ConstructionAPI_Plane::ConstructionAPI_Plane(
13     const std::shared_ptr<ModelAPI_Feature> & theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 ConstructionAPI_Plane::ConstructionAPI_Plane(
20     const std::shared_ptr<ModelAPI_Feature> & theFeature,
21     const ModelHighAPI_Selection & theFace,
22     const ModelHighAPI_Double & theDistance)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if (initialize())
26     setFaceAndDistance(theFace, theDistance);
27 }
28
29 ConstructionAPI_Plane::ConstructionAPI_Plane(
30     const std::shared_ptr<ModelAPI_Feature> & theFeature,
31     const ModelHighAPI_Double & theA,
32     const ModelHighAPI_Double & theB,
33     const ModelHighAPI_Double & theC,
34     const ModelHighAPI_Double & theD)
35 : ModelHighAPI_Interface(theFeature)
36 {
37   if (initialize())
38     setGeneralEquation(theA, theB, theC, theD);
39 }
40
41 ConstructionAPI_Plane::~ConstructionAPI_Plane()
42 {
43
44 }
45
46 //--------------------------------------------------------------------------------------
47 void ConstructionAPI_Plane::setFaceAndDistance(
48     const ModelHighAPI_Selection & theFace,
49     const ModelHighAPI_Double & theDistance)
50 {
51   fillAttribute(theFace, myface);
52   fillAttribute(theDistance, mydistance);
53
54   execute();
55 }
56
57 void ConstructionAPI_Plane::setGeneralEquation(
58     const ModelHighAPI_Double & theA,
59     const ModelHighAPI_Double & theB,
60     const ModelHighAPI_Double & theC,
61     const ModelHighAPI_Double & theD)
62 {
63   fillAttribute(theA, myA);
64   fillAttribute(theB, myB);
65   fillAttribute(theC, myC);
66   fillAttribute(theD, myD);
67
68   execute();
69 }
70
71 //--------------------------------------------------------------------------------------
72 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
73                   const ModelHighAPI_Selection & theFace,
74                   const ModelHighAPI_Double & theDistance)
75 {
76   // TODO(spo): check that thePart is not empty
77   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
78   return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance));
79 }
80
81 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
82                   const ModelHighAPI_Double & theA,
83                   const ModelHighAPI_Double & theB,
84                   const ModelHighAPI_Double & theC,
85                   const ModelHighAPI_Double & theD)
86 {
87   // TODO(spo): check that thePart is not empty
88   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
89   return PlanePtr(new ConstructionAPI_Plane(aFeature, theA, theB, theC, theD));
90 }