Salome HOME
Issue #1649: Added options to create plane by three points;
[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("PlaneByFaceAndDistance", mycreationMethod);
52   fillAttribute(theFace, myplane);
53   fillAttribute(theDistance, 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   fillAttribute("PlaneByGeneralEquation", mycreationMethod);
65   fillAttribute(theA, myA);
66   fillAttribute(theB, myB);
67   fillAttribute(theC, myC);
68   fillAttribute(theD, myD);
69
70   execute();
71 }
72
73 //--------------------------------------------------------------------------------------
74 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
75                   const ModelHighAPI_Selection & theFace,
76                   const ModelHighAPI_Double & theDistance)
77 {
78   // TODO(spo): check that thePart is not empty
79   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
80   return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance));
81 }
82
83 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
84                   const ModelHighAPI_Double & theA,
85                   const ModelHighAPI_Double & theB,
86                   const ModelHighAPI_Double & theC,
87                   const ModelHighAPI_Double & theD)
88 {
89   // TODO(spo): check that thePart is not empty
90   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
91   return PlanePtr(new ConstructionAPI_Plane(aFeature, theA, theB, theC, theD));
92 }