1 // Copyright (C) 2018-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <GeomAPI_Box.h>
21 #include <GeomAPI_Ax3.h>
23 #include <Precision.hxx>
27 std::shared_ptr<GeomAPI_Ax3> myCoordSystem;
32 Box(const std::shared_ptr<GeomAPI_Ax3>& theCoordSystem,
33 const double theWidth,
34 const double theDepth,
35 const double theHeight)
36 : myCoordSystem(theCoordSystem),
43 #define MY_BOX implPtr<Box>()
45 //=================================================================================================
46 GeomAPI_Box::GeomAPI_Box(const std::shared_ptr<GeomAPI_Ax3>& theCorner,
47 const double theWidth,
48 const double theDepth,
49 const double theHeight)
50 : GeomAPI_Interface(new Box(theCorner, theWidth, theDepth, theHeight))
54 //=================================================================================================
55 std::shared_ptr<GeomAPI_Ax3> GeomAPI_Box::axes() const
57 return MY_BOX->myCoordSystem;
60 //=================================================================================================
61 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Box::corner() const
63 return axes()->origin();
66 //=================================================================================================
67 double GeomAPI_Box::width() const
69 return MY_BOX->myWidth;
72 //=================================================================================================
73 double GeomAPI_Box::depth() const
75 return MY_BOX->myDepth;
78 //=================================================================================================
79 double GeomAPI_Box::height() const
81 return MY_BOX->myHeight;
84 //=================================================================================================
85 bool GeomAPI_Box::isAxesAligned() const
87 return Abs(MY_BOX->myCoordSystem->dirX()->x() - 1.0) < Precision::Angular() &&
88 Abs(MY_BOX->myCoordSystem->normal()->z() - 1.0) < Precision::Angular();