1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D -->
3 // File: PrimitivesAPI_Box.cpp
4 // Created: 28 June 2016
5 // Author: Clarisse Genrault
7 #include "PrimitivesAPI_Box.h"
9 #include <ModelHighAPI_Tools.h>
11 //==================================================================================================
12 PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
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)
26 setDimensions(theDx, theDy, theDz);
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)
36 setPoints(theFirstPoint, theSecondPoint);
39 //==================================================================================================
40 PrimitivesAPI_Box::~PrimitivesAPI_Box()
45 //==================================================================================================
46 void PrimitivesAPI_Box::setDimensions(const ModelHighAPI_Double& theDx,
47 const ModelHighAPI_Double& theDy,
48 const ModelHighAPI_Double& theDz)
50 fillAttribute(PrimitivesPlugin_Box::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
51 fillAttribute(theDx, dx());
52 fillAttribute(theDy, dy());
53 fillAttribute(theDz, dz());
58 //==================================================================================================
59 void PrimitivesAPI_Box::setPoints(const ModelHighAPI_Selection& theFirstPoint,
60 const ModelHighAPI_Selection& theSecondPoint)
62 fillAttribute(PrimitivesPlugin_Box::CREATION_METHOD_BY_TWO_POINTS(), creationMethod());
63 fillAttribute(theFirstPoint, firstPoint());
64 fillAttribute(theSecondPoint, secondPoint());
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)
75 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
76 return BoxPtr(new PrimitivesAPI_Box(aFeature, theDx, theDy, theDz));
79 //==================================================================================================
80 BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
81 const ModelHighAPI_Selection& theFirstPoint,
82 const ModelHighAPI_Selection& theSecondPoint)
84 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
85 return BoxPtr(new PrimitivesAPI_Box(aFeature, theFirstPoint, theSecondPoint));