0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / BRepSweep / BRepSweep_Revol.cxx
1 // Created on: 1993-06-25
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <BRepSweep_Revol.ixx>
18 #include <BRepSweep_Rotation.hxx>
19 #include <Sweep_NumShape.hxx>
20
21 #include <gp_Trsf.hxx>
22 #include <Precision.hxx>
23 //=======================================================================
24 //function : BRepSweep_Revol
25 //purpose  : 
26 //=======================================================================
27
28 BRepSweep_Revol::BRepSweep_Revol
29   (const TopoDS_Shape& S, 
30    const gp_Ax1& Ax, 
31    const Standard_Real D,
32    const Standard_Boolean C):
33   myRotation(S.Oriented(TopAbs_FORWARD),
34              NumShape(D),
35              Location(Ax,D),
36              Axe(Ax,D),
37              Angle(D),
38              C)
39 {
40   Standard_ConstructionError_Raise_if
41     (Angle(D)<=Precision::Angular(),"BRepSweep_Revol::Constructor");
42 }
43
44 //=======================================================================
45 //function : BRepSweep_Revol
46 //purpose  : 
47 //=======================================================================
48
49 BRepSweep_Revol::BRepSweep_Revol
50   (const TopoDS_Shape& S, 
51    const gp_Ax1& Ax, 
52    const Standard_Boolean C):
53   myRotation(S.Oriented(TopAbs_FORWARD),
54              NumShape(2*M_PI),
55              Location(Ax,2*M_PI),
56              Axe(Ax,2*M_PI),
57              Angle(2*M_PI),
58              C)
59
60 {
61 }
62
63
64 //=======================================================================
65 //function : Shape
66 //purpose  : 
67 //=======================================================================
68
69 TopoDS_Shape  BRepSweep_Revol::Shape()
70 {
71   return myRotation.Shape();
72 }
73
74
75 //=======================================================================
76 //function : Shape
77 //purpose  : 
78 //=======================================================================
79
80 TopoDS_Shape  BRepSweep_Revol::Shape(const TopoDS_Shape& aGenS)
81 {
82   return myRotation.Shape(aGenS);
83 }
84
85
86 //=======================================================================
87 //function : FirstShape
88 //purpose  : 
89 //=======================================================================
90
91 TopoDS_Shape  BRepSweep_Revol::FirstShape()
92 {
93   return myRotation.FirstShape();
94 }
95
96
97 //=======================================================================
98 //function : FirstShape
99 //purpose  : 
100 //=======================================================================
101
102 TopoDS_Shape  BRepSweep_Revol::FirstShape(const TopoDS_Shape& aGenS)
103 {
104   return myRotation.FirstShape(aGenS);
105 }
106
107
108 //=======================================================================
109 //function : LastShape
110 //purpose  : 
111 //=======================================================================
112
113 TopoDS_Shape  BRepSweep_Revol::LastShape()
114 {
115   return myRotation.LastShape();
116 }
117
118
119 //=======================================================================
120 //function : LastShape
121 //purpose  : 
122 //=======================================================================
123
124 TopoDS_Shape  BRepSweep_Revol::LastShape(const TopoDS_Shape& aGenS)
125 {
126   return myRotation.LastShape(aGenS);
127 }
128
129
130 //=======================================================================
131 //function : NumShape
132 //purpose  : 
133 //=======================================================================
134
135 Sweep_NumShape  BRepSweep_Revol::NumShape(const Standard_Real D)const 
136 {
137   Sweep_NumShape N;
138   if (Abs(Angle(D) - 2*M_PI)<=Precision::Angular()){
139     N.Init(2,TopAbs_EDGE,Standard_True,
140            Standard_False,Standard_False);
141   }
142   else{
143     N.Init(2,TopAbs_EDGE);
144   }
145   return N;
146 }
147
148
149 //=======================================================================
150 //function : Location
151 //purpose  : 
152 //=======================================================================
153
154 TopLoc_Location  BRepSweep_Revol::Location(const gp_Ax1& Ax, 
155                                            const Standard_Real D)const 
156 {
157   gp_Trsf gpt;
158   gpt.SetRotation(Axe(Ax,D),Angle(D));
159   TopLoc_Location L(gpt);
160   return L;
161 }
162
163
164 //=======================================================================
165 //function : Axe
166 //purpose  : 
167 //=======================================================================
168
169 gp_Ax1  BRepSweep_Revol::Axe(const gp_Ax1& Ax, const Standard_Real D)const 
170 {
171   gp_Ax1 A = Ax;
172   if ( D < 0. ) A.Reverse();
173   return A;
174 }
175
176
177 //=======================================================================
178 //function : Angle
179 //purpose  : 
180 //=======================================================================
181
182 Standard_Real  BRepSweep_Revol::Angle(const Standard_Real D)const 
183 {
184   Standard_Real d = Abs(D);
185   while(d>(2*M_PI + Precision::Angular())){
186     d = d - 2*M_PI;
187   }
188   return d;
189 }
190
191
192 //=======================================================================
193 //function : Angle
194 //purpose  : 
195 //=======================================================================
196
197 Standard_Real  BRepSweep_Revol::Angle()const 
198 {
199   return myRotation.Angle();
200 }
201
202
203 //=======================================================================
204 //function : Axe
205 //purpose  : 
206 //=======================================================================
207
208 gp_Ax1  BRepSweep_Revol::Axe()const 
209 {
210   return myRotation.Axe();
211 }
212
213