Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1992-10-02 |
2 | // Created by: Remi GILET | |
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 | |
42cf5bc1 | 17 | |
18 | #include <GC_MakeCylindricalSurface.hxx> | |
7fd59977 | 19 | #include <gce_MakeCylinder.hxx> |
42cf5bc1 | 20 | #include <Geom_CylindricalSurface.hxx> |
21 | #include <gp_Ax1.hxx> | |
22 | #include <gp_Ax2.hxx> | |
23 | #include <gp_Circ.hxx> | |
24 | #include <gp_Cylinder.hxx> | |
7fd59977 | 25 | #include <gp_Lin.hxx> |
42cf5bc1 | 26 | #include <gp_Pnt.hxx> |
7fd59977 | 27 | #include <StdFail_NotDone.hxx> |
28 | ||
29 | GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& C) | |
30 | { | |
31 | TheError = gce_Done; | |
32 | TheCylinder = new Geom_CylindricalSurface(C); | |
33 | } | |
34 | ||
35 | GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Ax2& A2 , | |
36 | const Standard_Real Radius) | |
37 | { | |
38 | if (Radius < 0.0) { TheError = gce_NegativeRadius; } | |
39 | else { | |
40 | TheError = gce_Done; | |
41 | TheCylinder = new Geom_CylindricalSurface(A2,Radius); | |
42 | } | |
43 | } | |
44 | ||
45 | //========================================================================= | |
0d969553 | 46 | // Construction of a cylinder by axis <A1> et radius <Radius>. + |
7fd59977 | 47 | //========================================================================= |
48 | ||
49 | GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Ax1& A1 , | |
50 | const Standard_Real Radius ) | |
51 | { | |
52 | gce_MakeCylinder Cyl = gce_MakeCylinder(A1,Radius); | |
53 | TheError = Cyl.Status(); | |
54 | if (TheError == gce_Done) { | |
55 | TheCylinder=new Geom_CylindricalSurface(Cyl.Value()); | |
56 | } | |
57 | } | |
58 | ||
59 | //========================================================================= | |
0d969553 | 60 | // Construction of a cylinder by a circle <Cir>. + |
7fd59977 | 61 | //========================================================================= |
62 | ||
63 | GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Circ& Circ ) { | |
64 | gp_Cylinder Cyl = gce_MakeCylinder(Circ); | |
65 | TheCylinder=new Geom_CylindricalSurface(Cyl); | |
66 | TheError = gce_Done; | |
67 | } | |
68 | ||
69 | //========================================================================= | |
0d969553 Y |
70 | // Construction of a cylinder by tree points <P1>, <P2>, <P3>. + |
71 | // Two first points define the axis. + | |
72 | // The third gives the radius. + | |
7fd59977 | 73 | //========================================================================= |
74 | ||
75 | GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Pnt& P1 , | |
76 | const gp_Pnt& P2 , | |
77 | const gp_Pnt& P3 ) { | |
78 | gce_MakeCylinder Cyl = gce_MakeCylinder(P1,P2,P3); | |
79 | TheError = Cyl.Status(); | |
80 | if (TheError == gce_Done) { | |
81 | TheCylinder=new Geom_CylindricalSurface(Cyl.Value()); | |
82 | } | |
83 | } | |
84 | ||
85 | GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& Cyl , | |
86 | const Standard_Real Dist) | |
87 | { | |
88 | TheError = gce_Done; | |
89 | Standard_Real R = Abs(Cyl.Radius()-Dist); | |
90 | TheCylinder = new Geom_CylindricalSurface(Cyl); | |
91 | TheCylinder->SetRadius(R); | |
92 | } | |
93 | ||
94 | GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& Cyl , | |
95 | const gp_Pnt& Point) | |
96 | { | |
97 | TheError = gce_Done; | |
98 | gp_Cylinder C(Cyl); | |
99 | gp_Lin L(C.Axis()); | |
100 | Standard_Real R = L.Distance(Point); | |
101 | C.SetRadius(R); | |
102 | TheCylinder = new Geom_CylindricalSurface(C); | |
103 | } | |
104 | ||
105 | const Handle(Geom_CylindricalSurface)& | |
106 | GC_MakeCylindricalSurface::Value() const | |
107 | { | |
82fc327c | 108 | StdFail_NotDone_Raise_if(TheError != gce_Done,""); |
7fd59977 | 109 | return TheCylinder; |
110 | } |