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