Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:16:31

0001 // Created on: 1995-08-31
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1995-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 _BRepFilletAPI_MakeFillet2d_HeaderFile
0018 #define _BRepFilletAPI_MakeFillet2d_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <ChFi2d_Builder.hxx>
0025 #include <BRepBuilderAPI_MakeShape.hxx>
0026 #include <TopoDS_Shape.hxx>
0027 #include <NCollection_Sequence.hxx>
0028 #include <NCollection_List.hxx>
0029 #include <ChFi2d_ConstructionError.hxx>
0030 class TopoDS_Face;
0031 class TopoDS_Edge;
0032 class TopoDS_Vertex;
0033 class TopoDS_Shape;
0034 
0035 // resolve name collisions with X11 headers
0036 #ifdef Status
0037   #undef Status
0038 #endif
0039 
0040 //! Describes functions to build fillets and chamfers on the
0041 //! vertices of a planar face.
0042 //! Fillets and Chamfers on the Vertices of a Planar Face
0043 //! A MakeFillet2d object provides a framework for:
0044 //! - initializing the construction algorithm with a given face,
0045 //! - acquiring the data characterizing the fillets and chamfers,
0046 //! -   building the fillets and chamfers, and constructing the
0047 //! resulting shape, and
0048 //! -   consulting the result.
0049 //! Warning
0050 //! Only segments of straight lines and arcs of circles are
0051 //! treated. BSplines are not processed.
0052 class BRepFilletAPI_MakeFillet2d : public BRepBuilderAPI_MakeShape
0053 {
0054 public:
0055   DEFINE_STANDARD_ALLOC
0056 
0057   //! Initializes an empty algorithm for computing fillets and
0058   //! chamfers. The face on which the fillets and
0059   //! chamfers are built is defined using the Init function.
0060   //! The vertices on which fillets or chamfers are built are
0061   //! defined using the AddFillet or AddChamfer function.
0062   //! Warning
0063   //! The status of the initialization, as given by the Status
0064   //! function, can be one of the following:
0065   //! -   ChFi2d_Ready if the initialization is correct,
0066   //! -   ChFi2d_NotPlanar if F is not planar,
0067   //! -   ChFi2d_NoFace if F is a null face.
0068   Standard_EXPORT BRepFilletAPI_MakeFillet2d();
0069 
0070   //! Initializes an algorithm for computing fillets and chamfers on the face F.
0071   //! The vertices on which fillets or chamfers are built are
0072   //! defined using the AddFillet or AddChamfer function.
0073   //! Warning
0074   //! The status of the initialization, as given by the Status
0075   //! function, can be one of the following:
0076   //! -   ChFi2d_Ready if the initialization is correct,
0077   //! -   ChFi2d_NotPlanar if F is not planar,
0078   //! -   ChFi2d_NoFace if F is a null face.
0079   Standard_EXPORT BRepFilletAPI_MakeFillet2d(const TopoDS_Face& F);
0080 
0081   //! Initializes this algorithm for constructing fillets or
0082   //! chamfers with the face F.
0083   //! Warning
0084   //! The status of the initialization, as given by the Status
0085   //! function, can be one of the following:
0086   //! -   ChFi2d_Ready if the initialization is correct,
0087   //! -   ChFi2d_NotPlanar if F is not planar,
0088   //! -   ChFi2d_NoFace if F is a null face.
0089   Standard_EXPORT void Init(const TopoDS_Face& F);
0090 
0091   //! This initialize method allow to init the builder
0092   //! from a face RefFace and another face ModFace which derive from RefFace.
0093   //! This is useful to modify a fillet or a chamfer already created on ModFace.
0094   Standard_EXPORT void Init(const TopoDS_Face& RefFace, const TopoDS_Face& ModFace);
0095 
0096   //! Adds a fillet of radius Radius between the two edges
0097   //! adjacent to the vertex V on the face modified by this
0098   //! algorithm. The two edges do not need to be rectilinear.
0099   //! This function returns the fillet and builds the resulting face.
0100   //! Warning
0101   //! The status of the construction, as given by the Status
0102   //! function, can be one of the following:
0103   //! - ChFi2d_IsDone if the fillet is built,
0104   //! - ChFi2d_ConnexionError if V does not belong to the initial face,
0105   //! -   ChFi2d_ComputationError if Radius is too large
0106   //! to build a fillet between the two adjacent edges,
0107   //! -   ChFi2d_NotAuthorized
0108   //! -   if one of the two edges connected to V is a fillet or chamfer, or
0109   //! -   if a curve other than a straight line or an arc of a
0110   //! circle is used as E, E1 or E2.
0111   //! Do not use the returned fillet if the status of the construction is not ChFi2d_IsDone.
0112   //! Exceptions
0113   //! Standard_NegativeValue if Radius is less than or equal to zero.
0114   Standard_EXPORT TopoDS_Edge AddFillet(const TopoDS_Vertex& V, const double Radius);
0115 
0116   //! Assigns the radius Radius to the fillet Fillet already
0117   //! built on the face modified by this algorithm.
0118   //! This function returns the new fillet and modifies the existing face.
0119   //! Warning
0120   //! The status of the construction, as given by the Status
0121   //! function, can be one of the following:
0122   //! -   ChFi2d_IsDone if the new fillet is built,
0123   //! -   ChFi2d_ConnexionError if Fillet does not
0124   //! belong to the existing face,
0125   //! -   ChFi2d_ComputationError if Radius is too
0126   //! large to build a fillet between the two adjacent edges.
0127   //! Do not use the returned fillet if the status of the
0128   //! construction is not ChFi2d_IsDone.
0129   //! Exceptions
0130   //! Standard_NegativeValue if Radius is less than or equal to zero.
0131   Standard_EXPORT TopoDS_Edge ModifyFillet(const TopoDS_Edge& Fillet, const double Radius);
0132 
0133   //! Removes the fillet Fillet already built on the face
0134   //! modified by this algorithm.
0135   //! This function returns the vertex connecting the two
0136   //! adjacent edges of Fillet and modifies the existing face.
0137   //! Warning
0138   //! -   The returned vertex is only valid if the Status
0139   //! function returns ChFi2d_IsDone.
0140   //! -   A null vertex is returned if the edge Fillet does not
0141   //! belong to the initial face.
0142   Standard_EXPORT TopoDS_Vertex RemoveFillet(const TopoDS_Edge& Fillet);
0143 
0144   //! Adds a chamfer on the face modified by this algorithm
0145   //! between the two adjacent edges E1 and E2, where
0146   //! the extremities of the chamfer are on E1 and E2 at
0147   //! distances D1 and D2 respectively
0148   //! In cases where the edges are not rectilinear, distances
0149   //! are measured using the curvilinear abscissa of the
0150   //! edges and the angle is measured with respect to the
0151   //! tangent at the corresponding point.
0152   //! The angle Ang is given in radians.
0153   //! This function returns the chamfer and builds the resulting face.
0154   Standard_EXPORT TopoDS_Edge AddChamfer(const TopoDS_Edge& E1,
0155                                          const TopoDS_Edge& E2,
0156                                          const double       D1,
0157                                          const double       D2);
0158 
0159   //! Adds a chamfer on the face modified by this algorithm
0160   //! between the two edges connected by the vertex V,
0161   //! where E is one of the two edges. The chamfer makes
0162   //! an angle Ang with E and one of its extremities is on
0163   //! E at distance D from V.
0164   //! In cases where the edges are not rectilinear, distances
0165   //! are measured using the curvilinear abscissa of the
0166   //! edges and the angle is measured with respect to the
0167   //! tangent at the corresponding point.
0168   //! The angle Ang is given in radians.
0169   //! This function returns the chamfer and builds the resulting face.
0170   //! Warning
0171   //! The status of the construction, as given by the Status function, can
0172   //! be one of the following:
0173   //! -          ChFi2d_IsDone if the chamfer is built,
0174   //! -  ChFi2d_ParametersError if D1, D2, D or Ang is less than or equal to zero,
0175   //! -          ChFi2d_ConnexionError if:
0176   //! - the edge E, E1 or E2 does not belong to the initial face, or
0177   //! -  the edges E1 and E2 are not adjacent, or
0178   //! -  the vertex V is not one of the limit points of the edge E,
0179   //! -          ChFi2d_ComputationError if the parameters of the chamfer
0180   //! are too large to build a chamfer between the two adjacent edges,
0181   //! -          ChFi2d_NotAuthorized if:
0182   //! - the edge E1, E2 or one of the two edges connected to V is a fillet or chamfer, or
0183   //! - a curve other than a straight line or an arc of a circle is used as E, E1 or E2.
0184   //! Do not use the returned chamfer if
0185   //! the status of the construction is not ChFi2d_IsDone.
0186   Standard_EXPORT TopoDS_Edge AddChamfer(const TopoDS_Edge&   E,
0187                                          const TopoDS_Vertex& V,
0188                                          const double         D,
0189                                          const double         Ang);
0190 
0191   //! Modifies the chamfer Chamfer on the face modified
0192   //! by this algorithm, where:
0193   //! E1 and E2 are the two adjacent edges on which
0194   //! Chamfer is already built; the extremities of the new
0195   //! chamfer are on E1 and E2 at distances D1 and D2 respectively.
0196   Standard_EXPORT TopoDS_Edge ModifyChamfer(const TopoDS_Edge& Chamfer,
0197                                             const TopoDS_Edge& E1,
0198                                             const TopoDS_Edge& E2,
0199                                             const double       D1,
0200                                             const double       D2);
0201 
0202   //! Modifies the chamfer Chamfer on the face modified
0203   //! by this algorithm, where:
0204   //! E is one of the two adjacent edges on which
0205   //! Chamfer is already built; the new chamfer makes
0206   //! an angle Ang with E and one of its extremities is
0207   //! on E at distance D from the vertex on which the chamfer is built.
0208   //! In cases where the edges are not rectilinear, the
0209   //! distances are measured using the curvilinear abscissa
0210   //! of the edges and the angle is measured with respect
0211   //! to the tangent at the corresponding point.
0212   //! The angle Ang is given in radians.
0213   //! This function returns the new chamfer and modifies the existing face.
0214   //! Warning
0215   //! The status of the construction, as given by the Status
0216   //! function, can be one of the following:
0217   //! -   ChFi2d_IsDone if the chamfer is built,
0218   //! -   ChFi2d_ParametersError if D1, D2, D or Ang is less than or equal to zero,
0219   //! -   ChFi2d_ConnexionError if:
0220   //! -   the edge E, E1, E2 or Chamfer does not belong
0221   //! to the existing face, or
0222   //! -   the edges E1 and E2 are not adjacent,
0223   //! -   ChFi2d_ComputationError if the parameters of
0224   //! the chamfer are too large to build a chamfer
0225   //! between the two adjacent edges,
0226   //! -   ChFi2d_NotAuthorized if E1 or E2 is a fillet or chamfer.
0227   //! Do not use the returned chamfer if the status of the
0228   //! construction is not ChFi2d_IsDone.
0229   Standard_EXPORT TopoDS_Edge ModifyChamfer(const TopoDS_Edge& Chamfer,
0230                                             const TopoDS_Edge& E,
0231                                             const double       D,
0232                                             const double       Ang);
0233 
0234   //! Removes the chamfer Chamfer already built on the face
0235   //! modified by this algorithm.
0236   //! This function returns the vertex connecting the two
0237   //! adjacent edges of Chamfer and modifies the existing face.
0238   //! Warning
0239   //! -   The returned vertex is only valid if the Status
0240   //! function returns ChFi2d_IsDone.
0241   //! -   A null vertex is returned if the edge Chamfer does
0242   //! not belong to the initial face.
0243   Standard_EXPORT TopoDS_Vertex RemoveChamfer(const TopoDS_Edge& Chamfer);
0244 
0245   //! Returns true if the edge E on the face modified by this
0246   //! algorithm is chamfered or filleted.
0247   //! Warning
0248   //! Returns false if E does not belong to the face modified by this algorithm.
0249   bool IsModified(const TopoDS_Edge& E) const;
0250 
0251   //! Returns the table of fillets on the face modified by this algorithm.
0252   const NCollection_Sequence<TopoDS_Shape>& FilletEdges() const;
0253 
0254   //! Returns the number of fillets on the face modified by this algorithm.
0255   int NbFillet() const;
0256 
0257   //! Returns the table of chamfers on the face modified by this algorithm.
0258   const NCollection_Sequence<TopoDS_Shape>& ChamferEdges() const;
0259 
0260   //! Returns the number of chamfers on the face modified by this algorithm.
0261   int NbChamfer() const;
0262 
0263   //! Returns the list of shapes modified from the shape
0264   //! <S>.
0265   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Modified(const TopoDS_Shape& S) override;
0266 
0267   //! returns the number of new curves
0268   //! after the shape creation.
0269   Standard_EXPORT int NbCurves() const;
0270 
0271   //! Return the Edges created for curve I.
0272   Standard_EXPORT const NCollection_List<TopoDS_Shape>& NewEdges(const int I);
0273 
0274   bool HasDescendant(const TopoDS_Edge& E) const;
0275 
0276   //! Returns the chamfered or filleted edge built from the
0277   //! edge E on the face modified by this algorithm. If E has
0278   //! not been modified, this function returns E.
0279   //! Exceptions
0280   //! Standard_NoSuchObject if the edge E does not
0281   //! belong to the initial face.
0282   const TopoDS_Edge& DescendantEdge(const TopoDS_Edge& E) const;
0283 
0284   //! Returns the basis edge on the face modified by this
0285   //! algorithm from which the chamfered or filleted edge E is
0286   //! built. If E has not been modified, this function returns E.
0287   //! Warning
0288   //! E is returned if it does not belong to the initial face.
0289   Standard_EXPORT const TopoDS_Edge& BasisEdge(const TopoDS_Edge& E) const;
0290 
0291   ChFi2d_ConstructionError Status() const;
0292 
0293   //! Update the result and set the Done flag
0294   Standard_EXPORT void Build(
0295     const Message_ProgressRange& theRange = Message_ProgressRange()) override;
0296 
0297 private:
0298   ChFi2d_Builder myMakeChFi2d;
0299 };
0300 
0301 #include <BRepFilletAPI_MakeFillet2d.lxx>
0302 
0303 #endif // _BRepFilletAPI_MakeFillet2d_HeaderFile