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