summaryrefslogtreecommitdiff
path: root/src/BRepPrim/BRepPrim_Cylinder.cxx
blob: c2be9ef98798e84ee7b0ad8e1d0ab150c3dc8aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// File:	BRepPrim_Cylinder.cxx
// Created:	Fri Nov  6 10:46:02 1992
// Author:	Remi LEQUETTE
//		<rle@phylox>


#include <BRepPrim_Cylinder.ixx>

#include <gp.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_Line.hxx>
#include <Geom2d_Line.hxx>

//=======================================================================
//function : BRepPrim_Cylinder
//purpose  : 
//=======================================================================

BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Ax2& Position, 
				     const Standard_Real Radius,
				     const Standard_Real Height) : 
       BRepPrim_Revolution(Position,0,Height),
       myRadius(Radius)
{
  SetMeridian();
}

//=======================================================================
//function : BRepPrim_Cylinder
//purpose  : 
//=======================================================================

BRepPrim_Cylinder::BRepPrim_Cylinder(const Standard_Real Radius) :
       BRepPrim_Revolution(gp::XOY(),RealFirst(),RealLast()),
       myRadius(Radius)
{
  SetMeridian();
}

//=======================================================================
//function : BRepPrim_Cylinder
//purpose  : 
//=======================================================================

BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Pnt& Center, 
				     const Standard_Real Radius) :
       BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
			   RealFirst(),RealLast()),
       myRadius(Radius)
{
  SetMeridian();
}

//=======================================================================
//function : BRepPrim_Cylinder
//purpose  : 
//=======================================================================

BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Ax2& Axes,
				     const Standard_Real Radius) :
       BRepPrim_Revolution(Axes, RealFirst(),RealLast()),
       myRadius(Radius)
{
  SetMeridian();
}

//=======================================================================
//function : BRepPrim_Cylinder
//purpose  : 
//=======================================================================

BRepPrim_Cylinder::BRepPrim_Cylinder(const Standard_Real R,
				     const Standard_Real H) :
       BRepPrim_Revolution(gp::XOY(), 0, H),
       myRadius(R)
{
  SetMeridian();
}

//=======================================================================
//function : BRepPrim_Cylinder
//purpose  : 
//=======================================================================

BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Pnt& Center, 
				     const Standard_Real R, 
				     const Standard_Real H) :
       BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
			   0,H),
       myRadius(R)
{
  SetMeridian();
}

//=======================================================================
//function : MakeEmptyLateralFace
//purpose  : 
//=======================================================================

TopoDS_Face  BRepPrim_Cylinder::MakeEmptyLateralFace() const 
{
  Handle(Geom_CylindricalSurface) C =
    new Geom_CylindricalSurface(Axes(),myRadius);
  TopoDS_Face F;
  myBuilder.Builder().MakeFace(F,C,Precision::Confusion());
  return F;
}

//=======================================================================
//function : SetMeridian
//purpose  : 
//=======================================================================

void BRepPrim_Cylinder::SetMeridian()
{
  gp_Vec V = Axes().XDirection();
  V.Multiply(myRadius);
  gp_Ax1 A = Axes().Axis();
  A.Translate(V);
  Handle(Geom_Line) L = new Geom_Line(A);
  Handle(Geom2d_Line) L2d = new Geom2d_Line(gp_Pnt2d(myRadius,0),gp_Dir2d(0,1));
  Meridian(L,L2d);
}