]> SALOME platform Git repositories - modules/shaper.git/blob - src/ConstructionAPI/ConstructionAPI_Plane.cpp
Salome HOME
Tests fix.
[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 #include "ConstructionAPI_Plane.h"
8
9 #include <ModelHighAPI_Tools.h>
10
11 ConstructionAPI_Plane::ConstructionAPI_Plane(
12     const std::shared_ptr<ModelAPI_Feature> & theFeature)
13 : ModelHighAPI_Interface(theFeature)
14 {
15   initialize();
16 }
17
18 ConstructionAPI_Plane::ConstructionAPI_Plane(
19     const std::shared_ptr<ModelAPI_Feature> & theFeature,
20     const ModelHighAPI_Selection & theFace,
21     const ModelHighAPI_Double & theDistance)
22 : ModelHighAPI_Interface(theFeature)
23 {
24   if (initialize())
25     setFaceAndDistance(theFace, theDistance);
26 }
27
28 ConstructionAPI_Plane::ConstructionAPI_Plane(
29     const std::shared_ptr<ModelAPI_Feature> & theFeature,
30     const ModelHighAPI_Double & theA,
31     const ModelHighAPI_Double & theB,
32     const ModelHighAPI_Double & theC,
33     const ModelHighAPI_Double & theD)
34 : ModelHighAPI_Interface(theFeature)
35 {
36   if (initialize())
37     setGeneralEquation(theA, theB, theC, theD);
38 }
39
40 ConstructionAPI_Plane::~ConstructionAPI_Plane()
41 {
42
43 }
44
45 //--------------------------------------------------------------------------------------
46 void ConstructionAPI_Plane::setFaceAndDistance(
47     const ModelHighAPI_Selection & theFace,
48     const ModelHighAPI_Double & theDistance)
49 {
50   fillAttribute("PlaneByFaceAndDistance", mycreationMethod);
51   fillAttribute(theFace, myplane);
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(ConstructionPlugin_Plane::CREATION_METHOD_BY_GENERAL_EQUATION(), mycreationMethod);
64   fillAttribute(theA, myA);
65   fillAttribute(theB, myB);
66   fillAttribute(theC, myC);
67   fillAttribute(theD, myD);
68
69   execute();
70 }
71
72 //--------------------------------------------------------------------------------------
73 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
74                   const ModelHighAPI_Selection & theFace,
75                   const ModelHighAPI_Double & theDistance)
76 {
77   // TODO(spo): check that thePart is not empty
78   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
79   return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance));
80 }
81
82 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
83                   const ModelHighAPI_Double & theA,
84                   const ModelHighAPI_Double & theB,
85                   const ModelHighAPI_Double & theC,
86                   const ModelHighAPI_Double & theD)
87 {
88   // TODO(spo): check that thePart is not empty
89   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
90   return PlanePtr(new ConstructionAPI_Plane(aFeature, theA, theB, theC, theD));
91 }