Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:16:59

0001 // Created on: 1993-07-12
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _BRepBuilderAPI_MakeFace_HeaderFile
0018 #define _BRepBuilderAPI_MakeFace_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <BRepLib_MakeFace.hxx>
0025 #include <BRepBuilderAPI_MakeShape.hxx>
0026 #include <Standard_Real.hxx>
0027 #include <BRepBuilderAPI_FaceError.hxx>
0028 class TopoDS_Face;
0029 class gp_Pln;
0030 class gp_Cylinder;
0031 class gp_Cone;
0032 class gp_Sphere;
0033 class gp_Torus;
0034 class Geom_Surface;
0035 class TopoDS_Wire;
0036 
0037 //! Provides methods to build faces.
0038 //!
0039 //! A face may be built:
0040 //!
0041 //! * From a surface.
0042 //!
0043 //! - Elementary surface from gp.
0044 //!
0045 //! - Surface from Geom.
0046 //!
0047 //! * From a surface and U,V values.
0048 //!
0049 //! * From a wire.
0050 //!
0051 //! - Find the surface automatically if possible.
0052 //!
0053 //! * From a surface and a wire.
0054 //!
0055 //! - A flag Inside is given, when this flag is True
0056 //! the wire is oriented to bound a finite area on
0057 //! the surface.
0058 //!
0059 //! * From a face and a wire.
0060 //!
0061 //! - The new wire is a perforation.
0062 class BRepBuilderAPI_MakeFace : public BRepBuilderAPI_MakeShape
0063 {
0064 public:
0065   DEFINE_STANDARD_ALLOC
0066 
0067   //! Not done.
0068   Standard_EXPORT BRepBuilderAPI_MakeFace();
0069 
0070   //! Load a face. useful to add wires.
0071   Standard_EXPORT BRepBuilderAPI_MakeFace(const TopoDS_Face& F);
0072 
0073   //! Make a face from a plane.
0074   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Pln& P);
0075 
0076   //! Make a face from a cylinder.
0077   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cylinder& C);
0078 
0079   //! Make a face from a cone.
0080   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cone& C);
0081 
0082   //! Make a face from a sphere.
0083   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Sphere& S);
0084 
0085   //! Make a face from a torus.
0086   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Torus& C);
0087 
0088   //! Make a face from a Surface. Accepts tolerance value (TolDegen)
0089   //! for resolution of degenerated edges.
0090   Standard_EXPORT BRepBuilderAPI_MakeFace(const occ::handle<Geom_Surface>& S,
0091                                           const double                     TolDegen);
0092 
0093   //! Make a face from a plane.
0094   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Pln& P,
0095                                           const double  UMin,
0096                                           const double  UMax,
0097                                           const double  VMin,
0098                                           const double  VMax);
0099 
0100   //! Make a face from a cylinder.
0101   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cylinder& C,
0102                                           const double       UMin,
0103                                           const double       UMax,
0104                                           const double       VMin,
0105                                           const double       VMax);
0106 
0107   //! Make a face from a cone.
0108   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cone& C,
0109                                           const double   UMin,
0110                                           const double   UMax,
0111                                           const double   VMin,
0112                                           const double   VMax);
0113 
0114   //! Make a face from a sphere.
0115   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Sphere& S,
0116                                           const double     UMin,
0117                                           const double     UMax,
0118                                           const double     VMin,
0119                                           const double     VMax);
0120 
0121   //! Make a face from a torus.
0122   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Torus& C,
0123                                           const double    UMin,
0124                                           const double    UMax,
0125                                           const double    VMin,
0126                                           const double    VMax);
0127 
0128   //! Make a face from a Surface. Accepts tolerance value (TolDegen)
0129   //! for resolution of degenerated edges.
0130   Standard_EXPORT BRepBuilderAPI_MakeFace(const occ::handle<Geom_Surface>& S,
0131                                           const double                     UMin,
0132                                           const double                     UMax,
0133                                           const double                     VMin,
0134                                           const double                     VMax,
0135                                           const double                     TolDegen);
0136 
0137   //! Find a surface from the wire and make a face.
0138   //! if <OnlyPlane> is true, the computed surface will be
0139   //! a plane. If it is not possible to find a plane, the
0140   //! flag NotDone will be set.
0141   Standard_EXPORT BRepBuilderAPI_MakeFace(const TopoDS_Wire& W, const bool OnlyPlane = false);
0142 
0143   //! Make a face from a plane and a wire.
0144   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Pln&      P,
0145                                           const TopoDS_Wire& W,
0146                                           const bool         Inside = true);
0147 
0148   //! Make a face from a cylinder and a wire.
0149   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cylinder& C,
0150                                           const TopoDS_Wire& W,
0151                                           const bool         Inside = true);
0152 
0153   //! Make a face from a cone and a wire.
0154   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Cone&     C,
0155                                           const TopoDS_Wire& W,
0156                                           const bool         Inside = true);
0157 
0158   //! Make a face from a sphere and a wire.
0159   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Sphere&   S,
0160                                           const TopoDS_Wire& W,
0161                                           const bool         Inside = true);
0162 
0163   //! Make a face from a torus and a wire.
0164   Standard_EXPORT BRepBuilderAPI_MakeFace(const gp_Torus&    C,
0165                                           const TopoDS_Wire& W,
0166                                           const bool         Inside = true);
0167 
0168   //! Make a face from a Surface and a wire.
0169   //! If the surface S is not plane,
0170   //! it must contain pcurves for all edges in W,
0171   //! otherwise the wrong shape will be created.
0172   Standard_EXPORT BRepBuilderAPI_MakeFace(const occ::handle<Geom_Surface>& S,
0173                                           const TopoDS_Wire&               W,
0174                                           const bool                       Inside = true);
0175 
0176   //! Adds the wire <W> in the face <F>
0177   //! A general method to create a face is to give
0178   //! -      a surface S as the support (the geometric domain) of the face,
0179   //! -      and a wire W to bound it.
0180   //! The bounds of the face can also be defined by four parameter values
0181   //! umin, umax, vmin, vmax which determine isoparametric limitations on
0182   //! the parametric space of the surface. In this way, a patch is
0183   //! defined. The parameter values are optional. If they are omitted, the
0184   //! natural bounds of the surface are used. A wire is automatically
0185   //! built using the defined bounds. Up to four edges and four vertices
0186   //! are created with this wire (no edge is created when the
0187   //! corresponding parameter value is infinite).
0188   //! Wires can then be added using the function Add to define other
0189   //! restrictions on the face. These restrictions represent holes. More
0190   //! than one wire may be added by this way, provided that the wires do
0191   //! not cross each other and that they define only one area on the
0192   //! surface. (Be careful, however, as this is not checked).
0193   //! Forbidden addition of wires
0194   //! Note that in this schema, the third case is valid if edges of the
0195   //! wire W are declared internal to the face. As a result, these edges
0196   //! are no longer bounds of the face.
0197   //! A default tolerance (Precision::Confusion()) is given to the face,
0198   //! this tolerance may be increased during construction of the face
0199   //! using various algorithms.
0200   //! Rules applied to the arguments
0201   //! For the surface:
0202   //! -      The surface must not be a 'null handle'.
0203   //! -      If the surface is a trimmed surface, the basis surface is used.
0204   //! -      For the wire: the wire is composed of connected edges, each
0205   //! edge having a parametric curve description in the parametric
0206   //! domain of the surface; in other words, as a pcurve.
0207   //! For the parameters:
0208   //! -      The parameter values must be in the parametric range of the
0209   //! surface (or the basis surface, if the surface is trimmed). If this
0210   //! condition is not satisfied, the face is not built, and the Error
0211   //! function will return BRepBuilderAPI_ParametersOutOfRange.
0212   //! -      The bounding parameters p1 and p2 are adjusted on a periodic
0213   //! surface in a given parametric direction by adding or subtracting
0214   //! the period to obtain p1 in the parametric range of the surface and
0215   //! such p2, that p2 - p1 <= Period, where Period is the period of the
0216   //! surface in this parametric direction.
0217   //! -      A parameter value may be infinite. There will be no edge and
0218   //! no vertex in the corresponding direction.
0219   Standard_EXPORT BRepBuilderAPI_MakeFace(const TopoDS_Face& F, const TopoDS_Wire& W);
0220 
0221   //! Initializes (or reinitializes) the
0222   //! construction of a face by creating a new object which is a copy of
0223   //! the face F, in order to add wires to it, using the function Add.
0224   //! Note: this complete copy of the geometry is only required if you
0225   //! want to work on the geometries of the two faces independently.
0226   Standard_EXPORT void Init(const TopoDS_Face& F);
0227 
0228   //! Initializes (or reinitializes) the construction of a face on
0229   //! the surface S. If Bound is true, a wire is
0230   //! automatically created from the natural bounds of the
0231   //! surface S and added to the face in order to bound it. If
0232   //! Bound is false, no wire is added. This option is used
0233   //! when real bounds are known. These will be added to
0234   //! the face after this initialization, using the function Add.
0235   //! TolDegen parameter is used for resolution of degenerated edges
0236   //! if calculation of natural bounds is turned on.
0237   Standard_EXPORT void Init(const occ::handle<Geom_Surface>& S,
0238                             const bool                       Bound,
0239                             const double                     TolDegen);
0240 
0241   //! Initializes (or reinitializes) the construction of a face on
0242   //! the surface S, limited in the u parametric direction by
0243   //! the two parameter values UMin and UMax and in the
0244   //! v parametric direction by the two parameter values VMin and VMax.
0245   //! Warning
0246   //! Error returns:
0247   //! -      BRepBuilderAPI_ParametersOutOfRange
0248   //! when the parameters given are outside the bounds of the
0249   //! surface or the basis surface of a trimmed surface.
0250   //! TolDegen parameter is used for resolution of degenerated edges.
0251   Standard_EXPORT void Init(const occ::handle<Geom_Surface>& S,
0252                             const double                     UMin,
0253                             const double                     UMax,
0254                             const double                     VMin,
0255                             const double                     VMax,
0256                             const double                     TolDegen);
0257 
0258   //! Adds the wire W to the constructed face as a hole.
0259   //! Warning
0260   //! W must not cross the other bounds of the face, and all
0261   //! the bounds must define only one area on the surface.
0262   //! (Be careful, however, as this is not checked.)
0263   //! Example
0264   //! // a cylinder
0265   //! gp_Cylinder C = ..;
0266   //! // a wire
0267   //! TopoDS_Wire W = ...;
0268   //! BRepBuilderAPI_MakeFace MF(C);
0269   //! MF.Add(W);
0270   //! TopoDS_Face F = MF;
0271   Standard_EXPORT void Add(const TopoDS_Wire& W);
0272 
0273   //! Returns true if this algorithm has a valid face.
0274   Standard_EXPORT bool IsDone() const override;
0275 
0276   //! Returns the construction status
0277   //! BRepBuilderAPI_FaceDone if the face is built, or
0278   //! -   another value of the BRepBuilderAPI_FaceError
0279   //! enumeration indicating why the construction failed, in
0280   //! particular when the given parameters are outside the
0281   //! bounds of the surface.
0282   Standard_EXPORT BRepBuilderAPI_FaceError Error() const;
0283 
0284   //! Returns the constructed face.
0285   //! Exceptions
0286   //! StdFail_NotDone if no face is built.
0287   Standard_EXPORT const TopoDS_Face& Face() const;
0288   Standard_EXPORT                    operator TopoDS_Face() const;
0289 
0290 private:
0291   BRepLib_MakeFace myMakeFace;
0292 };
0293 
0294 #endif // _BRepBuilderAPI_MakeFace_HeaderFile