0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepPrim / BRepPrim_Cylinder.cxx
CommitLineData
b311480e 1// Created on: 1992-11-06
2// Created by: Remi LEQUETTE
3// Copyright (c) 1992-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <BRepPrim_Cylinder.hxx>
19#include <Geom2d_Line.hxx>
20#include <Geom_CylindricalSurface.hxx>
21#include <Geom_Line.hxx>
7fd59977 22#include <gp.hxx>
42cf5bc1 23#include <gp_Ax2.hxx>
24#include <gp_Pnt.hxx>
7fd59977 25#include <gp_Vec.hxx>
26#include <Precision.hxx>
42cf5bc1 27#include <Standard_DomainError.hxx>
28#include <TopoDS_Face.hxx>
7fd59977 29
30//=======================================================================
31//function : BRepPrim_Cylinder
32//purpose :
33//=======================================================================
7fd59977 34BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Ax2& Position,
35 const Standard_Real Radius,
36 const Standard_Real Height) :
37 BRepPrim_Revolution(Position,0,Height),
38 myRadius(Radius)
39{
40 SetMeridian();
41}
42
43//=======================================================================
44//function : BRepPrim_Cylinder
45//purpose :
46//=======================================================================
47
48BRepPrim_Cylinder::BRepPrim_Cylinder(const Standard_Real Radius) :
49 BRepPrim_Revolution(gp::XOY(),RealFirst(),RealLast()),
50 myRadius(Radius)
51{
52 SetMeridian();
53}
54
55//=======================================================================
56//function : BRepPrim_Cylinder
57//purpose :
58//=======================================================================
59
60BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Pnt& Center,
61 const Standard_Real Radius) :
62 BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
63 RealFirst(),RealLast()),
64 myRadius(Radius)
65{
66 SetMeridian();
67}
68
69//=======================================================================
70//function : BRepPrim_Cylinder
71//purpose :
72//=======================================================================
73
74BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Ax2& Axes,
75 const Standard_Real Radius) :
76 BRepPrim_Revolution(Axes, RealFirst(),RealLast()),
77 myRadius(Radius)
78{
79 SetMeridian();
80}
81
82//=======================================================================
83//function : BRepPrim_Cylinder
84//purpose :
85//=======================================================================
86
87BRepPrim_Cylinder::BRepPrim_Cylinder(const Standard_Real R,
88 const Standard_Real H) :
89 BRepPrim_Revolution(gp::XOY(), 0, H),
90 myRadius(R)
91{
92 SetMeridian();
93}
94
95//=======================================================================
96//function : BRepPrim_Cylinder
97//purpose :
98//=======================================================================
99
100BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Pnt& Center,
101 const Standard_Real R,
102 const Standard_Real H) :
103 BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
104 0,H),
105 myRadius(R)
106{
107 SetMeridian();
108}
109
110//=======================================================================
111//function : MakeEmptyLateralFace
112//purpose :
113//=======================================================================
114
115TopoDS_Face BRepPrim_Cylinder::MakeEmptyLateralFace() const
116{
117 Handle(Geom_CylindricalSurface) C =
118 new Geom_CylindricalSurface(Axes(),myRadius);
119 TopoDS_Face F;
120 myBuilder.Builder().MakeFace(F,C,Precision::Confusion());
121 return F;
122}
123
124//=======================================================================
125//function : SetMeridian
126//purpose :
127//=======================================================================
128
129void BRepPrim_Cylinder::SetMeridian()
130{
131 gp_Vec V = Axes().XDirection();
132 V.Multiply(myRadius);
133 gp_Ax1 A = Axes().Axis();
134 A.Translate(V);
135 Handle(Geom_Line) L = new Geom_Line(A);
136 Handle(Geom2d_Line) L2d = new Geom2d_Line(gp_Pnt2d(myRadius,0),gp_Dir2d(0,1));
137 Meridian(L,L2d);
138}