0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BRepBuilderAPI / BRepBuilderAPI_MakeFace.hxx
1 // Created on: 1993-07-12
2 // Created by: Remi LEQUETTE
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 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 _BRepBuilderAPI_MakeFace_HeaderFile
18 #define _BRepBuilderAPI_MakeFace_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <BRepLib_MakeFace.hxx>
25 #include <BRepBuilderAPI_MakeShape.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <BRepBuilderAPI_FaceError.hxx>
29 class StdFail_NotDone;
30 class TopoDS_Face;
31 class gp_Pln;
32 class gp_Cylinder;
33 class gp_Cone;
34 class gp_Sphere;
35 class gp_Torus;
36 class Geom_Surface;
37 class TopoDS_Wire;
38
39
40 //! Provides methods to build faces.
41 //!
42 //! A face may be built :
43 //!
44 //! * From a surface.
45 //!
46 //! - Elementary surface from gp.
47 //!
48 //! - Surface from Geom.
49 //!
50 //! * From a surface and U,V values.
51 //!
52 //! * From a wire.
53 //!
54 //! - Find the surface automatically if possible.
55 //!
56 //! * From a surface and a wire.
57 //!
58 //! - A flag Inside is given, when this flag is True
59 //! the  wire is  oriented to bound a finite area on
60 //! the surface.
61 //!
62 //! * From a face and a wire.
63 //!
64 //! - The new wire is a perforation.
65 class BRepBuilderAPI_MakeFace  : public BRepBuilderAPI_MakeShape
66 {
67 public:
68
69   DEFINE_STANDARD_ALLOC
70
71   
72   //! Not done.
73   Standard_EXPORT BRepBuilderAPI_MakeFace();
74   
75   //! Load a face. Usefull to add wires.
76   Standard_EXPORT BRepBuilderAPI_MakeFace(const TopoDS_Face& F);
77   
78   //! Make a face from a plane.
79   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Pln& P);
80   
81   //! Make a face from a cylinder.
82   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cylinder& C);
83   
84   //! Make a face from a cone.
85   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cone& C);
86   
87   //! Make a face from a sphere.
88   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Sphere& S);
89   
90   //! Make a face from a torus.
91   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Torus& C);
92   
93   //! Make a face from a Surface. Accepts tolerance value (TolDegen)
94   //! for resolution of degenerated edges.
95   Standard_EXPORT BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S, const Standard_Real TolDegen);
96   
97   //! Make a face from a plane.
98   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Pln& P, const Standard_Real UMin, const Standard_Real UMax, const Standard_Real VMin, const Standard_Real VMax);
99   
100   //! Make a face from a cylinder.
101   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cylinder& C, const Standard_Real UMin, const Standard_Real UMax, const Standard_Real VMin, const Standard_Real VMax);
102   
103   //! Make a face from a cone.
104   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cone& C, const Standard_Real UMin, const Standard_Real UMax, const Standard_Real VMin, const Standard_Real VMax);
105   
106   //! Make a face from a sphere.
107   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Sphere& S, const Standard_Real UMin, const Standard_Real UMax, const Standard_Real VMin, const Standard_Real VMax);
108   
109   //! Make a face from a torus.
110   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Torus& C, const Standard_Real UMin, const Standard_Real UMax, const Standard_Real VMin, const Standard_Real VMax);
111   
112   //! Make a face from a Surface. Accepts tolerance value (TolDegen)
113   //! for resolution of degenerated edges.
114   Standard_EXPORT BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S, const Standard_Real UMin, const Standard_Real UMax, const Standard_Real VMin, const Standard_Real VMax, const Standard_Real TolDegen);
115   
116   //! Find a surface from the wire and make a face.
117   //! if <OnlyPlane> is true, the computed surface will be
118   //! a plane. If it is not possible to find a plane, the
119   //! flag NotDone will be set.
120   Standard_EXPORT BRepBuilderAPI_MakeFace(const TopoDS_Wire& W, const Standard_Boolean OnlyPlane = Standard_False);
121   
122   //! Make a face from a plane and a wire.
123   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Pln& P, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
124   
125   //! Make a face from a cylinder and a wire.
126   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cylinder& C, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
127   
128   //! Make a face from a cone and a wire.
129   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cone& C, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
130   
131   //! Make a face from a sphere and a wire.
132   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Sphere& S, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
133   
134   //! Make a face from a torus and a wire.
135   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Torus& C, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
136   
137   //! Make a face from a Surface and a wire.
138   Standard_EXPORT BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S, const TopoDS_Wire& W, const Standard_Boolean Inside = Standard_True);
139   
140   //! Adds the wire <W> in the face <F>
141   //! A general method to create a face is to give
142   //! -      a surface S as the support (the geometric domain) of the face,
143   //! -      and a wire W to bound it.
144   //! The bounds of the face can also be defined by four parameter values
145   //! umin, umax, vmin, vmax which determine isoparametric limitations on
146   //! the parametric space of the surface. In this way, a patch is
147   //! defined. The parameter values are optional. If they are omitted, the
148   //! natural bounds of the surface are used. A wire is automatically
149   //! built using the defined bounds. Up to four edges and four vertices
150   //! are created with this wire (no edge is created when the
151   //! corresponding parameter value is infinite).
152   //! Wires can then be added using the function Add to define other
153   //! restrictions on the face. These restrictions represent holes. More
154   //! than one wire may be added by this way, provided that the wires do
155   //! not cross each other and that they define only one area on the
156   //! surface. (Be careful, however, as this is not checked).
157   //! Forbidden addition of wires
158   //! Note that in this schema, the third case is valid if edges of the
159   //! wire W are declared internal to the face. As a result, these edges
160   //! are no longer bounds of the face.
161   //! A default tolerance (Precision::Confusion()) is given to the face,
162   //! this tolerance may be increased during construction of the face
163   //! using various algorithms.
164   //! Rules applied to the arguments
165   //! For the surface:
166   //! -      The surface must not be a 'null handle'.
167   //! -      If the surface is a trimmed surface, the basis surface is used.
168   //! -      For the wire: the wire is composed of connected edges, each
169   //! edge having a parametric curve description in the parametric
170   //! domain of the surface; in other words, as a pcurve.
171   //! For the parameters:
172   //! -      The parameter values must be in the parametric range of the
173   //! surface (or the basis surface, if the surface is trimmed). If this
174   //! condition is not satisfied, the face is not built, and the Error
175   //! function will return BRepBuilderAPI_ParametersOutOfRange.
176   //! -      The bounding parameters p1 and p2 are adjusted on a periodic
177   //! surface in a given parametric direction by adding or subtracting
178   //! the period to obtain p1 in the parametric range of the surface and
179   //! such p2, that p2 - p1 <= Period, where Period is the period of the
180   //! surface in this parametric direction.
181   //! -      A parameter value may be infinite. There will be no edge and
182   //! no vertex in the corresponding direction.
183   Standard_EXPORT BRepBuilderAPI_MakeFace(const TopoDS_Face& F, const TopoDS_Wire& W);
184   
185   //! Initializes (or reinitializes) the
186   //! construction of a face by creating a new object which is a copy of
187   //! the face F, in order to add wires to it, using the function Add.
188   //! Note: this complete copy of the geometry is only required if you
189   //! want to work on the geometries of the two faces independently.
190   Standard_EXPORT void Init (const TopoDS_Face& F);
191   
192   //! Initializes (or reinitializes) the construction of a face on
193   //! the surface S. If Bound is true, a wire is
194   //! automatically created from the natural bounds of the
195   //! surface S and added to the face in order to bound it. If
196   //! Bound is false, no wire is added. This option is used
197   //! when real bounds are known. These will be added to
198   //! the face after this initialization, using the function Add.
199   //! TolDegen parameter is used for resolution of degenerated edges
200   //! if calculation of natural bounds is turned on.
201   Standard_EXPORT void Init (const Handle(Geom_Surface)& S, const Standard_Boolean Bound, const Standard_Real TolDegen);
202   
203   //! Initializes (or reinitializes) the construction of a face on
204   //! the surface S, limited in the u parametric direction by
205   //! the two parameter values UMin and UMax and in the
206   //! v parametric direction by the two parameter values VMin and VMax.
207   //! Warning
208   //! Error returns:
209   //! -      BRepBuilderAPI_ParametersOutOfRange
210   //! when the parameters given are outside the bounds of the
211   //! surface or the basis surface of a trimmed surface.
212   //! TolDegen parameter is used for resolution of degenerated edges.
213   Standard_EXPORT void Init (const Handle(Geom_Surface)& S, const Standard_Real UMin, const Standard_Real UMax, const Standard_Real VMin, const Standard_Real VMax, const Standard_Real TolDegen);
214   
215   //! Adds the wire W to the constructed face as a hole.
216   //! Warning
217   //! W must not cross the other bounds of the face, and all
218   //! the bounds must define only one area on the surface.
219   //! (Be careful, however, as this is not checked.)
220   //! Example
221   //! // a cylinder
222   //! gp_Cylinder C = ..;
223   //! // a wire
224   //! TopoDS_Wire W = ...;
225   //! BRepBuilderAPI_MakeFace MF(C);
226   //! MF.Add(W);
227   //! TopoDS_Face F = MF;
228   Standard_EXPORT void Add (const TopoDS_Wire& W);
229   
230   //! Returns true if this algorithm has a valid face.
231   Standard_EXPORT virtual Standard_Boolean IsDone() const Standard_OVERRIDE;
232   
233   //! Returns the construction status
234   //! BRepBuilderAPI_FaceDone if the face is built, or
235   //! -   another value of the BRepBuilderAPI_FaceError
236   //! enumeration indicating why the construction failed, in
237   //! particular when the given parameters are outside the
238   //! bounds of the surface.
239   Standard_EXPORT BRepBuilderAPI_FaceError Error() const;
240   
241   //! Returns the constructed face.
242   //! Exceptions
243   //! StdFail_NotDone if no face is built.
244   Standard_EXPORT const TopoDS_Face& Face() const;
245 Standard_EXPORT operator TopoDS_Face() const;
246
247
248
249
250 protected:
251
252
253
254
255
256 private:
257
258
259
260   BRepLib_MakeFace myMakeFace;
261
262
263 };
264
265
266
267
268
269
270
271 #endif // _BRepBuilderAPI_MakeFace_HeaderFile