0024428: Implementation of LGPL license
[occt.git] / src / GC / GC_MakeCylindricalSurface.cxx
CommitLineData
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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
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
17#include <GC_MakeCylindricalSurface.ixx>
18#include <gce_MakeCylinder.hxx>
19#include <gp_Lin.hxx>
20#include <StdFail_NotDone.hxx>
21
22GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& C)
23{
24 TheError = gce_Done;
25 TheCylinder = new Geom_CylindricalSurface(C);
26}
27
28GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Ax2& A2 ,
29 const Standard_Real Radius)
30{
31 if (Radius < 0.0) { TheError = gce_NegativeRadius; }
32 else {
33 TheError = gce_Done;
34 TheCylinder = new Geom_CylindricalSurface(A2,Radius);
35 }
36}
37
38//=========================================================================
0d969553 39// Construction of a cylinder by axis <A1> et radius <Radius>. +
7fd59977 40//=========================================================================
41
42GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Ax1& A1 ,
43 const Standard_Real Radius )
44{
45 gce_MakeCylinder Cyl = gce_MakeCylinder(A1,Radius);
46 TheError = Cyl.Status();
47 if (TheError == gce_Done) {
48 TheCylinder=new Geom_CylindricalSurface(Cyl.Value());
49 }
50}
51
52//=========================================================================
0d969553 53// Construction of a cylinder by a circle <Cir>. +
7fd59977 54//=========================================================================
55
56GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Circ& Circ ) {
57 gp_Cylinder Cyl = gce_MakeCylinder(Circ);
58 TheCylinder=new Geom_CylindricalSurface(Cyl);
59 TheError = gce_Done;
60}
61
62//=========================================================================
0d969553
Y
63// Construction of a cylinder by tree points <P1>, <P2>, <P3>. +
64// Two first points define the axis. +
65// The third gives the radius. +
7fd59977 66//=========================================================================
67
68GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Pnt& P1 ,
69 const gp_Pnt& P2 ,
70 const gp_Pnt& P3 ) {
71 gce_MakeCylinder Cyl = gce_MakeCylinder(P1,P2,P3);
72 TheError = Cyl.Status();
73 if (TheError == gce_Done) {
74 TheCylinder=new Geom_CylindricalSurface(Cyl.Value());
75 }
76}
77
78GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& Cyl ,
79 const Standard_Real Dist)
80{
81 TheError = gce_Done;
82 Standard_Real R = Abs(Cyl.Radius()-Dist);
83 TheCylinder = new Geom_CylindricalSurface(Cyl);
84 TheCylinder->SetRadius(R);
85}
86
87GC_MakeCylindricalSurface::GC_MakeCylindricalSurface(const gp_Cylinder& Cyl ,
88 const gp_Pnt& Point)
89{
90 TheError = gce_Done;
91 gp_Cylinder C(Cyl);
92 gp_Lin L(C.Axis());
93 Standard_Real R = L.Distance(Point);
94 C.SetRadius(R);
95 TheCylinder = new Geom_CylindricalSurface(C);
96}
97
98const Handle(Geom_CylindricalSurface)&
99 GC_MakeCylindricalSurface::Value() const
100{
101 StdFail_NotDone_Raise_if(!TheError == gce_Done,"");
102 return TheCylinder;
103}
104
105const Handle(Geom_CylindricalSurface)& GC_MakeCylindricalSurface::Operator() const
106{
107 return Value();
108}
109
110GC_MakeCylindricalSurface::operator Handle(Geom_CylindricalSurface) () const
111{
112 return Value();
113}