summaryrefslogtreecommitdiff
path: root/src/GC/GC_MakeCylindricalSurface.cxx
blob: 90b80d813fd73c9fb805322fcdfca91e20dd5178 (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
// File:	GC_MakeCylindricalSurface.cxx
// Created:	Fri Oct  2 16:35:54 1992
// Author:	Remi GILET
//		<reg@topsn3>

#include <GC_MakeCylindricalSurface.ixx>
#include <gce_MakeCylinder.hxx>
#include <gp_Lin.hxx>
#include <StdFail_NotDone.hxx>

GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& C)
{
  TheError = gce_Done;
  TheCylinder = new Geom_CylindricalSurface(C);
}

GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Ax2& A2    ,
						const Standard_Real  Radius)
{
  if (Radius < 0.0) { TheError = gce_NegativeRadius; }
  else {
    TheError = gce_Done;
    TheCylinder = new Geom_CylindricalSurface(A2,Radius);
  }
}

//=========================================================================
//   Construction d un cylindre par axe <A1> et rayon <Radius>.           +
//=========================================================================

GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Ax1& A1     ,
						 const Standard_Real Radius ) 
{
  gce_MakeCylinder Cyl = gce_MakeCylinder(A1,Radius);
  TheError = Cyl.Status();
  if (TheError == gce_Done) {
    TheCylinder=new Geom_CylindricalSurface(Cyl.Value());
  }
}

//=========================================================================
//   Construction d un cylindre par un cercle <Cir>.                      +
//=========================================================================

GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Circ& Circ ) {
  gp_Cylinder Cyl = gce_MakeCylinder(Circ);
  TheCylinder=new Geom_CylindricalSurface(Cyl);
  TheError = gce_Done;
}

//=========================================================================
//   Construction d un cylindre par trois points <P1>, <P2>, <P3>.        +
//   Les deux premiers points definissent l axe.                          +
//   Le troisieme donne le rayon.                                         +
//=========================================================================

GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Pnt& P1 ,
						       const gp_Pnt& P2 ,
						       const gp_Pnt& P3 ) {
  gce_MakeCylinder Cyl = gce_MakeCylinder(P1,P2,P3);
  TheError = Cyl.Status();
  if (TheError == gce_Done) {
    TheCylinder=new Geom_CylindricalSurface(Cyl.Value());
  }
}

GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& Cyl ,
						     const Standard_Real  Dist)
{
  TheError = gce_Done;
  Standard_Real R = Abs(Cyl.Radius()-Dist);
  TheCylinder = new Geom_CylindricalSurface(Cyl);
  TheCylinder->SetRadius(R);
}

GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& Cyl ,
						       const gp_Pnt&     Point)
{
  TheError = gce_Done;
  gp_Cylinder C(Cyl);
  gp_Lin L(C.Axis());
  Standard_Real R = L.Distance(Point);
  C.SetRadius(R);
  TheCylinder = new Geom_CylindricalSurface(C);
}

const Handle(Geom_CylindricalSurface)& 
       GC_MakeCylindricalSurface::Value() const
{ 
  StdFail_NotDone_Raise_if(!TheError == gce_Done,"");
  return TheCylinder;
}

const Handle(Geom_CylindricalSurface)& GC_MakeCylindricalSurface::Operator() const 
{
  return Value();
}

GC_MakeCylindricalSurface::operator Handle(Geom_CylindricalSurface) () const
{
  return Value();
}