42cf5bc1 |
1 | // Created on: 1991-07-23 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1991-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 under |
9 | // the terms of the GNU Lesser General Public License 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 | #ifndef _BRepPrim_OneAxis_HeaderFile |
18 | #define _BRepPrim_OneAxis_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
42cf5bc1 |
22 | |
23 | #include <BRepPrim_Builder.hxx> |
24 | #include <gp_Ax2.hxx> |
42cf5bc1 |
25 | #include <TopoDS_Shell.hxx> |
42cf5bc1 |
26 | #include <TopoDS_Vertex.hxx> |
27 | #include <TopoDS_Edge.hxx> |
28 | #include <TopoDS_Wire.hxx> |
29 | #include <TopoDS_Face.hxx> |
42cf5bc1 |
30 | class gp_Pnt2d; |
42cf5bc1 |
31 | |
32 | |
33 | //! Algorithm to build primitives with one axis of |
34 | //! revolution. |
35 | //! |
36 | //! The revolution body is described by : |
37 | //! |
38 | //! A coordinate system (Ax2 from gp). The Z axis is |
39 | //! the rotational axis. |
40 | //! |
41 | //! An Angle around the Axis, When the Angle is 2*PI |
42 | //! the primitive is not limited by planar faces. The |
43 | //! U parameter range from 0 to Angle. |
44 | //! |
45 | //! A parameter range VMin, VMax on the meridian. |
46 | //! |
47 | //! A meridian : The meridian is a curve described by |
48 | //! a set of deferred methods. |
49 | //! |
50 | //! The topology consists of A shell, Faces, Wires, |
51 | //! Edges and Vertices. Methods are provided to build |
52 | //! all the elements. Building an element implies the |
53 | //! automatic building of all its sub-elements. |
54 | //! |
55 | //! So building the shell builds everything. |
56 | //! |
57 | //! There are at most 5 faces : |
58 | //! |
59 | //! - The LateralFace. |
60 | //! |
61 | //! - The TopFace and the BottomFace. |
62 | //! |
63 | //! - The StartFace and the EndFace. |
64 | class BRepPrim_OneAxis |
65 | { |
66 | public: |
67 | |
68 | DEFINE_STANDARD_ALLOC |
69 | |
70 | |
71 | //! The MeridianOffset is added to the parameters on |
72 | //! the meridian curve and to the V values of the |
73 | //! pcurves. This is used for the sphere for example, |
74 | //! to give a range on the meridian edge which is not |
75 | //! VMin, VMax. |
76 | Standard_EXPORT void SetMeridianOffset (const Standard_Real MeridianOffset = 0); |
77 | |
78 | //! Returns the Ax2 from <me>. |
79 | Standard_EXPORT const gp_Ax2& Axes() const; |
80 | |
81 | Standard_EXPORT void Axes (const gp_Ax2& A); |
82 | |
83 | Standard_EXPORT Standard_Real Angle() const; |
84 | |
85 | Standard_EXPORT void Angle (const Standard_Real A); |
86 | |
87 | Standard_EXPORT Standard_Real VMin() const; |
88 | |
89 | Standard_EXPORT void VMin (const Standard_Real V); |
90 | |
91 | Standard_EXPORT Standard_Real VMax() const; |
92 | |
93 | Standard_EXPORT void VMax (const Standard_Real V); |
94 | |
95 | //! Returns a face with no edges. The surface is the |
96 | //! lateral surface with normals pointing outward. The |
97 | //! U parameter is the angle with the origin on the X |
98 | //! axis. The V parameter is the parameter of the |
99 | //! meridian. |
100 | Standard_EXPORT virtual TopoDS_Face MakeEmptyLateralFace() const = 0; |
101 | |
102 | //! Returns an edge with a 3D curve made from the |
103 | //! meridian in the XZ plane rotated by <Ang> around |
104 | //! the Z-axis. Ang may be 0 or myAngle. |
105 | Standard_EXPORT virtual TopoDS_Edge MakeEmptyMeridianEdge (const Standard_Real Ang) const = 0; |
106 | |
107 | //! Sets the parametric curve of the edge <E> in the |
108 | //! face <F> to be the 2d representation of the |
109 | //! meridian. |
110 | Standard_EXPORT virtual void SetMeridianPCurve (TopoDS_Edge& E, const TopoDS_Face& F) const = 0; |
111 | |
112 | //! Returns the meridian point at parameter <V> in the |
113 | //! plane XZ. |
114 | Standard_EXPORT virtual gp_Pnt2d MeridianValue (const Standard_Real V) const = 0; |
115 | |
116 | //! Returns True if the point of parameter <V> on the |
117 | //! meridian is on the Axis. Default implementation is |
118 | //! Abs(MeridianValue(V).X()) < Precision::Confusion() |
119 | Standard_EXPORT virtual Standard_Boolean MeridianOnAxis (const Standard_Real V) const; |
120 | |
121 | //! Returns True if the meridian is closed. Default |
122 | //! implementation is |
123 | //! MeridianValue(VMin).IsEqual(MeridianValue(VMax), |
124 | //! Precision::Confusion()) |
125 | Standard_EXPORT virtual Standard_Boolean MeridianClosed() const; |
126 | |
127 | //! Returns True if VMax is infinite. Default |
128 | //! Precision::IsPositiveInfinite(VMax); |
129 | Standard_EXPORT virtual Standard_Boolean VMaxInfinite() const; |
130 | |
131 | //! Returns True if VMin is infinite. Default |
132 | //! Precision::IsNegativeInfinite(VMax); |
133 | Standard_EXPORT virtual Standard_Boolean VMinInfinite() const; |
134 | |
135 | //! Returns True if there is a top face. |
136 | //! |
137 | //! That is neither : VMaxInfinite() |
138 | //! MeridianClosed() |
139 | //! MeridianOnAxis(VMax) |
140 | Standard_EXPORT virtual Standard_Boolean HasTop() const; |
141 | |
142 | //! Returns True if there is a bottom face. |
143 | //! |
144 | //! That is neither : VMinInfinite() |
145 | //! MeridianClosed() |
146 | //! MeridianOnAxis(VMin) |
147 | Standard_EXPORT virtual Standard_Boolean HasBottom() const; |
148 | |
149 | //! Returns True if there are Start and End faces. |
150 | //! |
151 | //! That is : 2*PI - Angle > Precision::Angular() |
152 | Standard_EXPORT virtual Standard_Boolean HasSides() const; |
153 | |
154 | //! Returns the Shell containing all the Faces of the |
155 | //! primitive. |
156 | Standard_EXPORT const TopoDS_Shell& Shell(); |
157 | |
158 | //! Returns the lateral Face. It is oriented toward |
159 | //! the outside of the primitive. |
160 | Standard_EXPORT const TopoDS_Face& LateralFace(); |
161 | |
162 | //! Returns the top planar Face. It is Oriented |
163 | //! toward the +Z axis (outside). |
164 | Standard_EXPORT const TopoDS_Face& TopFace(); |
165 | |
166 | //! Returns the Bottom planar Face. It is Oriented |
167 | //! toward the -Z axis (outside). |
168 | Standard_EXPORT const TopoDS_Face& BottomFace(); |
169 | |
170 | //! Returns the Face starting the slice, it is |
171 | //! oriented toward the exterior of the primitive. |
172 | Standard_EXPORT const TopoDS_Face& StartFace(); |
173 | |
174 | //! Returns the Face ending the slice, it is oriented |
175 | //! toward the exterior of the primitive. |
176 | Standard_EXPORT const TopoDS_Face& EndFace(); |
177 | |
178 | //! Returns the wire in the lateral face. |
179 | Standard_EXPORT const TopoDS_Wire& LateralWire(); |
180 | |
181 | //! Returns the wire in the lateral face with the |
182 | //! start edge. |
183 | Standard_EXPORT const TopoDS_Wire& LateralStartWire(); |
184 | |
185 | //! Returns the wire with in lateral face with the end |
186 | //! edge. |
187 | Standard_EXPORT const TopoDS_Wire& LateralEndWire(); |
188 | |
189 | //! Returns the wire in the top face. |
190 | Standard_EXPORT const TopoDS_Wire& TopWire(); |
191 | |
192 | //! Returns the wire in the bottom face. |
193 | Standard_EXPORT const TopoDS_Wire& BottomWire(); |
194 | |
195 | //! Returns the wire in the start face. |
196 | Standard_EXPORT const TopoDS_Wire& StartWire(); |
197 | |
198 | //! Returns the wire in the start face with the |
199 | //! AxisEdge. |
200 | Standard_EXPORT const TopoDS_Wire& AxisStartWire(); |
201 | |
202 | //! Returns the Wire in the end face. |
203 | Standard_EXPORT const TopoDS_Wire& EndWire(); |
204 | |
205 | //! Returns the Wire in the end face with the |
206 | //! AxisEdge. |
207 | Standard_EXPORT const TopoDS_Wire& AxisEndWire(); |
208 | |
209 | //! Returns the Edge built along the Axis and oriented |
210 | //! on +Z of the Axis. |
211 | Standard_EXPORT const TopoDS_Edge& AxisEdge(); |
212 | |
213 | //! Returns the Edge at angle 0. |
214 | Standard_EXPORT const TopoDS_Edge& StartEdge(); |
215 | |
216 | //! Returns the Edge at angle Angle. If !HasSides() |
217 | //! the StartEdge and the EndEdge are the same edge. |
218 | Standard_EXPORT const TopoDS_Edge& EndEdge(); |
219 | |
220 | //! Returns the linear Edge between start Face and top |
221 | //! Face. |
222 | Standard_EXPORT const TopoDS_Edge& StartTopEdge(); |
223 | |
224 | //! Returns the linear Edge between start Face and |
225 | //! bottom Face. |
226 | Standard_EXPORT const TopoDS_Edge& StartBottomEdge(); |
227 | |
228 | //! Returns the linear Edge between end Face and top |
229 | //! Face. |
230 | Standard_EXPORT const TopoDS_Edge& EndTopEdge(); |
231 | |
232 | //! Returns the linear Edge between end Face and |
233 | //! bottom Face. |
234 | Standard_EXPORT const TopoDS_Edge& EndBottomEdge(); |
235 | |
236 | //! Returns the edge at VMax. If MeridianClosed() the |
237 | //! TopEdge and the BottomEdge are the same edge. |
238 | Standard_EXPORT const TopoDS_Edge& TopEdge(); |
239 | |
240 | //! Returns the edge at VMin. If MeridianClosed() the |
241 | //! TopEdge and the BottomEdge are the same edge. |
242 | Standard_EXPORT const TopoDS_Edge& BottomEdge(); |
243 | |
244 | //! Returns the Vertex at the Top altitude on the axis. |
245 | Standard_EXPORT const TopoDS_Vertex& AxisTopVertex(); |
246 | |
247 | //! Returns the Vertex at the Bottom altitude on the |
248 | //! axis. |
249 | Standard_EXPORT const TopoDS_Vertex& AxisBottomVertex(); |
250 | |
251 | //! Returns the vertex (0,VMax) |
252 | Standard_EXPORT const TopoDS_Vertex& TopStartVertex(); |
253 | |
254 | //! Returns the vertex (angle,VMax) |
255 | Standard_EXPORT const TopoDS_Vertex& TopEndVertex(); |
256 | |
257 | //! Returns the vertex (0,VMin) |
258 | Standard_EXPORT const TopoDS_Vertex& BottomStartVertex(); |
259 | |
260 | //! Returns the vertex (angle,VMax) |
261 | Standard_EXPORT const TopoDS_Vertex& BottomEndVertex(); |
262 | Standard_EXPORT virtual ~BRepPrim_OneAxis(); |
263 | |
264 | |
265 | |
266 | |
267 | protected: |
268 | |
269 | |
270 | //! Creates a OneAxis algorithm. <B> is used to build |
271 | //! the Topology. The angle defaults to 2*PI. |
272 | Standard_EXPORT BRepPrim_OneAxis(const BRepPrim_Builder& B, const gp_Ax2& A, const Standard_Real VMin, const Standard_Real VMax); |
273 | |
274 | |
275 | BRepPrim_Builder myBuilder; |
276 | |
277 | |
278 | private: |
279 | |
280 | |
281 | |
282 | gp_Ax2 myAxes; |
283 | Standard_Real myAngle; |
284 | Standard_Real myVMin; |
285 | Standard_Real myVMax; |
286 | Standard_Real myMeridianOffset; |
287 | TopoDS_Shell myShell; |
288 | Standard_Boolean ShellBuilt; |
289 | TopoDS_Vertex myVertices[6]; |
290 | Standard_Boolean VerticesBuilt[6]; |
291 | TopoDS_Edge myEdges[9]; |
292 | Standard_Boolean EdgesBuilt[9]; |
293 | TopoDS_Wire myWires[9]; |
294 | Standard_Boolean WiresBuilt[9]; |
295 | TopoDS_Face myFaces[5]; |
296 | Standard_Boolean FacesBuilt[5]; |
297 | |
298 | |
299 | }; |
300 | |
301 | |
302 | |
303 | |
304 | |
305 | |
306 | |
307 | #endif // _BRepPrim_OneAxis_HeaderFile |