1 // File: gce_MakeCylinder.cxx
2 // Created: Wed Sep 2 10:34:28 1992
6 #include <gce_MakeCylinder.ixx>
7 #include <StdFail_NotDone.hxx>
11 //=========================================================================
12 // Constructions d un cylindre de gp par son Ax2 A2 et son rayon +
14 //=========================================================================
16 gce_MakeCylinder::gce_MakeCylinder(const gp_Ax2& A2 ,
17 const Standard_Real Radius )
19 if (Radius < 0.0) { TheError = gce_NegativeRadius; }
21 TheCylinder = gp_Cylinder(A2,Radius);
26 //=========================================================================
27 // Constructions d un cylindre de gp par son axe Axis et son rayon +
29 //=========================================================================
31 gce_MakeCylinder::gce_MakeCylinder(const gp_Ax1& Axis ,
32 const Standard_Real Radius )
34 if (Radius < 0.0) { TheError = gce_NegativeRadius; }
36 gp_Dir D(Axis.Direction());
38 Standard_Real x = D.X();
39 Standard_Real y = D.Y();
40 Standard_Real z = D.Z();
41 if (Abs(x) > gp::Resolution()) { Direc = gp_Dir(-y,x,0.0); }
42 else if (Abs(y) > gp::Resolution()) { Direc = gp_Dir(-y,x,0.0); }
43 else if (Abs(z) > gp::Resolution()) { Direc = gp_Dir(0.0,-z,y); }
44 TheCylinder = gp_Cylinder(gp_Ax2(Axis.Location(),D,Direc),Radius);
49 //=========================================================================
50 // Constructions d un cylindre de gp par un cercle. +
51 //=========================================================================
53 gce_MakeCylinder::gce_MakeCylinder(const gp_Circ& Circ )
55 TheCylinder = gp_Cylinder(Circ.Position(),Circ.Radius());
59 //=========================================================================
60 // Constructions d un cylindre de gp par trois points P1, P2, P3. +
61 // P1 et P2 donnent l axe du cylindre, la distance de P3 a l axe donne +
62 // le rayon du cylindre. +
63 //=========================================================================
65 gce_MakeCylinder::gce_MakeCylinder(const gp_Pnt& P1 ,
69 if (P1.Distance(P2) < gp::Resolution()) { TheError = gce_ConfusedPoints; }
71 gp_Dir D1(P2.XYZ()-P1.XYZ());
73 Standard_Real x = D1.X();
74 Standard_Real y = D1.Y();
75 Standard_Real z = D1.Z();
76 if (Abs(x) > gp::Resolution()) { D2 = gp_Dir(-y,x,0.0); }
77 else if (Abs(y) > gp::Resolution()) { D2 = gp_Dir(-y,x,0.0); }
78 else if (Abs(z) > gp::Resolution()) { D2 = gp_Dir(0.0,-z,y); }
79 TheCylinder = gp_Cylinder(gp_Ax2(P1,D1,D2 ),gp_Lin(P1,D1).Distance(P3));
84 //=========================================================================
85 // Constructions d un cylindre de gp concentrique a un autre cylindre de +
86 // gp a une distance Dist. +
87 //=========================================================================
89 gce_MakeCylinder::gce_MakeCylinder(const gp_Cylinder& Cyl ,
90 const Standard_Real Dist )
92 Standard_Real Rad = Cyl.Radius()+Dist;
93 if (Rad < 0.) { TheError = gce_NegativeRadius; }
95 TheCylinder = gp_Cylinder(Cyl);
96 TheCylinder.SetRadius(Rad);
101 //=========================================================================
102 // Constructions d un cylindre de gp concentrique a un autre cylindre de +
103 // gp passant par le point P. +
104 //=========================================================================
106 gce_MakeCylinder::gce_MakeCylinder(const gp_Cylinder& Cyl ,
109 gp_Lin L(Cyl.Axis());
110 Standard_Real Rad = L.Distance(P);
111 TheCylinder = gp_Cylinder(Cyl);
112 TheCylinder.SetRadius(Rad);
116 const gp_Cylinder& gce_MakeCylinder::Value() const
118 StdFail_NotDone_Raise_if(!TheError == gce_Done,"");
122 const gp_Cylinder& gce_MakeCylinder::Operator() const
127 gce_MakeCylinder::operator gp_Cylinder() const