Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[modules/shaper.git] / src / PrimitivesAPI / PrimitivesAPI_Box.cpp
1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D -->
2
3 // File:        PrimitivesAPI_Box.cpp
4 // Created:     28 June 2016
5 // Author:      Clarisse Genrault
6
7 #include "PrimitivesAPI_Box.h"
8
9 #include <ModelHighAPI_Tools.h>
10
11 //==================================================================================================
12 PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
14 {
15   initialize();
16 }
17
18 //==================================================================================================
19 PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature,
20                                      const ModelHighAPI_Double & theDx,
21                                      const ModelHighAPI_Double & theDy,
22                                      const ModelHighAPI_Double & theDz)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if (initialize())
26     setDimensions(theDx, theDy, theDz);
27 }
28
29 //==================================================================================================
30 PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature,
31                                      const ModelHighAPI_Selection& theFirstPoint,
32                                      const ModelHighAPI_Selection& theSecondPoint)
33 : ModelHighAPI_Interface(theFeature)
34 {
35   if (initialize())
36     setPoints(theFirstPoint, theSecondPoint);
37 }
38
39 //==================================================================================================
40 PrimitivesAPI_Box::~PrimitivesAPI_Box()
41 {
42
43 }
44
45 //==================================================================================================
46 void PrimitivesAPI_Box::setDimensions(const ModelHighAPI_Double& theDx,
47                                       const ModelHighAPI_Double& theDy,
48                                       const ModelHighAPI_Double& theDz)
49 {
50   fillAttribute(PrimitivesPlugin_Box::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
51   fillAttribute(theDx, dx());
52   fillAttribute(theDy, dy());
53   fillAttribute(theDz, dz());
54
55   execute();
56 }
57
58 //==================================================================================================
59 void PrimitivesAPI_Box::setPoints(const ModelHighAPI_Selection& theFirstPoint,
60                                   const ModelHighAPI_Selection& theSecondPoint)
61 {
62   fillAttribute(PrimitivesPlugin_Box::CREATION_METHOD_BY_TWO_POINTS(), creationMethod());
63   fillAttribute(theFirstPoint, firstPoint());
64   fillAttribute(theSecondPoint, secondPoint());
65
66   execute();
67 }
68
69 //==================================================================================================
70 BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
71               const ModelHighAPI_Double& theDx,
72               const ModelHighAPI_Double& theDy,
73               const ModelHighAPI_Double& theDz)
74 {
75   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
76   return BoxPtr(new PrimitivesAPI_Box(aFeature, theDx, theDy, theDz));
77 }
78
79 //==================================================================================================
80 BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
81               const ModelHighAPI_Selection& theFirstPoint,
82               const ModelHighAPI_Selection& theSecondPoint)
83 {
84   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
85   return BoxPtr(new PrimitivesAPI_Box(aFeature, theFirstPoint, theSecondPoint));
86 }