1 // Copyright (C) 2018-20xx 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include <GeomAPI_Cylinder.h>
22 #include <GeomAPI_Pnt.h>
23 #include <GeomAPI_Dir.h>
25 #include <gp_Cylinder.hxx>
26 #include <Precision.hxx>
28 #define MY_CYL implPtr<gp_Cylinder>()
30 static gp_Cylinder* newCyl(const gp_Pnt& theLocation, const gp_Dir& theAxis, const double theRadius)
32 return new gp_Cylinder(gp_Ax3(theLocation, theAxis), theRadius);
35 //=================================================================================================
36 GeomAPI_Cylinder::GeomAPI_Cylinder(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
37 const std::shared_ptr<GeomAPI_Dir>& theAxis,
38 const double theRadius)
39 : GeomAPI_Interface(newCyl(theLocation->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theRadius)),
40 myHeight(Precision::Infinite())
44 //=================================================================================================
45 GeomAPI_Cylinder::GeomAPI_Cylinder(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
46 const std::shared_ptr<GeomAPI_Dir>& theAxis,
47 const double theRadius,
48 const double theHeight)
49 : GeomAPI_Interface(newCyl(theLocation->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theRadius)),
54 //=================================================================================================
55 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Cylinder::location() const
57 const gp_Pnt& aCenter = MY_CYL->Location();
58 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
61 //=================================================================================================
62 std::shared_ptr<GeomAPI_Dir> GeomAPI_Cylinder::axis() const
64 const gp_Dir& anAxis = MY_CYL->Position().Direction();
65 return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(anAxis.X(), anAxis.Y(), anAxis.Z()));
68 //=================================================================================================
69 double GeomAPI_Cylinder::radius() const
71 return MY_CYL->Radius();
74 //=================================================================================================
75 double GeomAPI_Cylinder::height() const
80 //=================================================================================================
81 bool GeomAPI_Cylinder::isInfinite() const
83 return Precision::IsInfinite(myHeight);