Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-05 09:21:30

0001 // Created on: 1994-06-17
0002 // Created by: Modeling
0003 // Copyright (c) 1994-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_MakeFillet_HeaderFile
0018 #define _BRepFilletAPI_MakeFillet_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <ChFi3d_FilBuilder.hxx>
0025 #include <TopoDS_Shape.hxx>
0026 #include <TopTools_ShapeMapHasher.hxx>
0027 #include <NCollection_Map.hxx>
0028 #include <BRepFilletAPI_LocalOperation.hxx>
0029 #include <ChFi3d_FilletShape.hxx>
0030 #include <Standard_Real.hxx>
0031 #include <GeomAbs_Shape.hxx>
0032 #include <gp_Pnt2d.hxx>
0033 #include <NCollection_Array1.hxx>
0034 #include <Standard_Integer.hxx>
0035 #include <NCollection_List.hxx>
0036 #include <ChFiDS_CircSection.hxx>
0037 #include <NCollection_HArray1.hxx>
0038 #include <ChFiDS_ErrorStatus.hxx>
0039 class TopoDS_Shape;
0040 class TopoDS_Edge;
0041 class Law_Function;
0042 class TopoDS_Vertex;
0043 class TopOpeBRepBuild_HBuilder;
0044 class Geom_Surface;
0045 
0046 //! Describes functions to build fillets on the broken edges of a shell or solid.
0047 //! A MakeFillet object provides a framework for:
0048 //! -   initializing the construction algorithm with a given shape,
0049 //! -   acquiring the data characterizing the fillets,
0050 //! -   building the fillets and constructing the resulting shape, and
0051 //! -   consulting the result.
0052 class BRepFilletAPI_MakeFillet : public BRepFilletAPI_LocalOperation
0053 {
0054 public:
0055   DEFINE_STANDARD_ALLOC
0056 
0057   //! Initializes the computation of the fillets.
0058   //! <FShape> sets the type of fillet surface. The
0059   //! default value is ChFi3d_Rational (classical nurbs
0060   //! representation of circles). ChFi3d_QuasiAngular
0061   //! corresponds to a nurbs representation of circles
0062   //! which parameterisation matches the circle one.
0063   //! ChFi3d_Polynomial corresponds to a polynomial
0064   //! representation of circles.
0065   Standard_EXPORT BRepFilletAPI_MakeFillet(const TopoDS_Shape&      S,
0066                                            const ChFi3d_FilletShape FShape = ChFi3d_Rational);
0067 
0068   Standard_EXPORT void SetParams(const double Tang,
0069                                  const double Tesp,
0070                                  const double T2d,
0071                                  const double TApp3d,
0072                                  const double TolApp2d,
0073                                  const double Fleche);
0074 
0075   //! Changes the parameters of continiuity
0076   //! InternalContinuity to produce fillet'surfaces with
0077   //! an continuity Ci (i=0,1 or 2).
0078   //! By defaultInternalContinuity = GeomAbs_C1.
0079   //! AngularTolerance is the G1 tolerance between fillet
0080   //! and support'faces.
0081   Standard_EXPORT void SetContinuity(const GeomAbs_Shape InternalContinuity,
0082                                      const double        AngularTolerance);
0083 
0084   //! Adds a fillet contour in the builder (builds a
0085   //! contour of tangent edges).
0086   //! The Radius must be set after.
0087   Standard_EXPORT void Add(const TopoDS_Edge& E) override;
0088 
0089   //! Adds a fillet description in the builder
0090   //! - builds a contour of tangent edges,
0091   //! - sets the radius.
0092   Standard_EXPORT void Add(const double Radius, const TopoDS_Edge& E);
0093 
0094   //! Adds a fillet description in the builder
0095   //! - builds a contour of tangent edges,
0096   //! - sets a linear radius evolution law between
0097   //! the first and last vertex of the spine.
0098   Standard_EXPORT void Add(const double R1, const double R2, const TopoDS_Edge& E);
0099 
0100   //! Adds a fillet description in the builder
0101   //! - builds a contour of tangent edges,
0102   //! - sest the radius evolution law.
0103   Standard_EXPORT void Add(const occ::handle<Law_Function>& L, const TopoDS_Edge& E);
0104 
0105   //! Adds a fillet description in the builder
0106   //! - builds a contour of tangent edges,
0107   //! - sets the radius evolution law interpolating the values
0108   //! given in the array UandR :
0109   //!
0110   //! p2d.X() = relative parameter on the spine [0,1]
0111   //! p2d.Y() = value of the radius.
0112   Standard_EXPORT void Add(const NCollection_Array1<gp_Pnt2d>& UandR, const TopoDS_Edge& E);
0113 
0114   //! Sets the parameters of the fillet
0115   //! along the contour of index IC generated using the Add function
0116   //! in the internal data structure of
0117   //! this algorithm, where Radius is the radius of the fillet.
0118   Standard_EXPORT void SetRadius(const double Radius, const int IC, const int IinC);
0119 
0120   //! Sets the parameters of the fillet
0121   //! along the contour of index IC generated using the Add function
0122   //! in the internal data structure of this algorithm, where the radius of the
0123   //! fillet evolves according to a linear evolution law defined
0124   //! from R1 to R2, between the first and last vertices of the contour of index IC.
0125   Standard_EXPORT void SetRadius(const double R1, const double R2, const int IC, const int IinC);
0126 
0127   //! Sets the parameters of the fillet
0128   //! along the contour of index IC generated using the Add function
0129   //! in the internal data structure of this algorithm, where the radius of the
0130   //! fillet evolves according to the evolution law L, between the
0131   //! first and last vertices of the contour of index IC.
0132   Standard_EXPORT void SetRadius(const occ::handle<Law_Function>& L, const int IC, const int IinC);
0133 
0134   //! Sets the parameters of the fillet
0135   //! along the contour of index IC generated using the Add function
0136   //! in the internal data structure of this algorithm,
0137   //! where the radius of the fillet evolves according to the evolution law
0138   //! which interpolates the set of parameter and radius pairs given
0139   //! in the array UandR as follows:
0140   //! -   the X coordinate of a point in UandR defines a
0141   //! relative parameter on the contour (i.e. a parameter between 0 and 1),
0142   //! -   the Y coordinate of a point in UandR gives the
0143   //! corresponding value of the radius, and the radius evolves
0144   //! between the first and last vertices of the contour of index IC.
0145   Standard_EXPORT void SetRadius(const NCollection_Array1<gp_Pnt2d>& UandR,
0146                                  const int                           IC,
0147                                  const int                           IinC);
0148 
0149   //! Erases the radius information on the contour of index
0150   //! IC in the internal data structure of this algorithm.
0151   //! Use the SetRadius function to reset this data.
0152   //! Warning
0153   //! Nothing is done if IC is outside the bounds of the table of contours.
0154   Standard_EXPORT void ResetContour(const int IC) override;
0155 
0156   //! Returns true if the radius of the fillet along the contour of index IC
0157   //! in the internal data structure of this algorithm is constant,
0158   //! Warning
0159   //! False is returned if IC is outside the bounds of the table
0160   //! of contours or if E does not belong to the contour of index IC.
0161   Standard_EXPORT bool IsConstant(const int IC);
0162 
0163   //! Returns the radius of the fillet along the contour of index IC in the
0164   //! internal data structure of this algorithm
0165   //! Warning
0166   //! -   Use this function only if the radius is constant.
0167   //! -   -1. is returned if IC is outside the bounds of the
0168   //! table of contours or if E does not belong to the contour of index IC.
0169   Standard_EXPORT double Radius(const int IC);
0170 
0171   //! Returns true if the radius of the fillet along the edge E of the
0172   //! contour of index IC in the internal data structure of
0173   //! this algorithm is constant.
0174   //! Warning
0175   //! False is returned if IC is outside the bounds of the table
0176   //! of contours or if E does not belong to the contour of index IC.
0177   Standard_EXPORT bool IsConstant(const int IC, const TopoDS_Edge& E);
0178 
0179   //! Returns the radius of the fillet along the edge E of the contour of index
0180   //! IC in the internal data structure of this algorithm.
0181   //! Warning
0182   //! -   Use this function only if the radius is constant.
0183   //! -   -1 is returned if IC is outside the bounds of the
0184   //! table of contours or if E does not belong to the contour of index IC.
0185   Standard_EXPORT double Radius(const int IC, const TopoDS_Edge& E);
0186 
0187   //! Assigns Radius as the radius of the fillet on the edge E
0188   Standard_EXPORT void SetRadius(const double Radius, const int IC, const TopoDS_Edge& E);
0189 
0190   Standard_EXPORT void SetRadius(const double Radius, const int IC, const TopoDS_Vertex& V);
0191 
0192   Standard_EXPORT bool GetBounds(const int IC, const TopoDS_Edge& E, double& F, double& L);
0193 
0194   Standard_EXPORT occ::handle<Law_Function> GetLaw(const int IC, const TopoDS_Edge& E);
0195 
0196   Standard_EXPORT void SetLaw(const int                        IC,
0197                               const TopoDS_Edge&               E,
0198                               const occ::handle<Law_Function>& L);
0199 
0200   //! Assigns FShape as the type of fillet shape built by this algorithm.
0201   Standard_EXPORT void SetFilletShape(const ChFi3d_FilletShape FShape);
0202 
0203   //! Returns the type of fillet shape built by this algorithm.
0204   Standard_EXPORT ChFi3d_FilletShape GetFilletShape() const;
0205 
0206   //! Returns the number of contours generated using the
0207   //! Add function in the internal data structure of this algorithm.
0208   Standard_EXPORT int NbContours() const override;
0209 
0210   //! Returns the index of the contour in the internal data
0211   //! structure of this algorithm which contains the edge E of the shape.
0212   //! This function returns 0 if the edge E does not belong to any contour.
0213   //! Warning
0214   //! This index can change if a contour is removed from the
0215   //! internal data structure of this algorithm using the function Remove.
0216   Standard_EXPORT int Contour(const TopoDS_Edge& E) const override;
0217 
0218   //! Returns the number of edges in the contour of index I in
0219   //! the internal data structure of this algorithm.
0220   //! Warning
0221   //! Returns 0 if I is outside the bounds of the table of contours.
0222   Standard_EXPORT int NbEdges(const int I) const override;
0223 
0224   //! Returns the edge of index J in the contour of index I in
0225   //! the internal data structure of this algorithm.
0226   //! Warning
0227   //! Returns a null shape if:
0228   //! -   I is outside the bounds of the table of contours, or
0229   //! -   J is outside the bounds of the table of edges of the index I contour.
0230   Standard_EXPORT const TopoDS_Edge& Edge(const int I, const int J) const override;
0231 
0232   //! Removes the contour in the internal data structure of
0233   //! this algorithm which contains the edge E of the shape.
0234   //! Warning
0235   //! Nothing is done if the edge E does not belong to the
0236   //! contour in the internal data structure of this algorithm.
0237   Standard_EXPORT void Remove(const TopoDS_Edge& E) override;
0238 
0239   //! Returns the length of the contour of index IC in the
0240   //! internal data structure of this algorithm.
0241   //! Warning
0242   //! Returns -1. if IC is outside the bounds of the table of contours.
0243   Standard_EXPORT double Length(const int IC) const override;
0244 
0245   //! Returns the first vertex of the contour of index IC
0246   //! in the internal data structure of this algorithm.
0247   //! Warning
0248   //! Returns a null shape if IC is outside the bounds of the table of contours.
0249   Standard_EXPORT TopoDS_Vertex FirstVertex(const int IC) const override;
0250 
0251   //! Returns the last vertex of the contour of index IC
0252   //! in the internal data structure of this algorithm.
0253   //! Warning
0254   //! Returns a null shape if IC is outside the bounds of the table of contours.
0255   Standard_EXPORT TopoDS_Vertex LastVertex(const int IC) const override;
0256 
0257   //! Returns the curvilinear abscissa of the vertex V on the
0258   //! contour of index IC in the internal data structure of this algorithm.
0259   //! Warning
0260   //! Returns -1. if:
0261   //! -   IC is outside the bounds of the table of contours, or
0262   //! -   V is not on the contour of index IC.
0263   Standard_EXPORT double Abscissa(const int IC, const TopoDS_Vertex& V) const override;
0264 
0265   //! Returns the relative curvilinear abscissa (i.e. between 0
0266   //! and 1) of the vertex V on the contour of index IC in the
0267   //! internal data structure of this algorithm.
0268   //! Warning
0269   //! Returns -1. if:
0270   //! -   IC is outside the bounds of the table of contours, or
0271   //! -   V is not on the contour of index IC.
0272   Standard_EXPORT double RelativeAbscissa(const int IC, const TopoDS_Vertex& V) const override;
0273 
0274   //! Returns true if the contour of index IC in the internal
0275   //! data structure of this algorithm is closed and tangential
0276   //! at the point of closure.
0277   //! Warning
0278   //! Returns false if IC is outside the bounds of the table of contours.
0279   Standard_EXPORT bool ClosedAndTangent(const int IC) const override;
0280 
0281   //! Returns true if the contour of index IC in the internal
0282   //! data structure of this algorithm is closed.
0283   //! Warning
0284   //! Returns false if IC is outside the bounds of the table of contours.
0285   Standard_EXPORT bool Closed(const int IC) const override;
0286 
0287   //! Builds the fillets on all the contours in the internal data
0288   //! structure of this algorithm and constructs the resulting shape.
0289   //! Use the function IsDone to verify that the filleted shape
0290   //! is built. Use the function Shape to retrieve the filleted shape.
0291   //! Warning
0292   //! The construction of fillets implements highly complex
0293   //! construction algorithms. Consequently, there may be
0294   //! instances where the algorithm fails, for example if the
0295   //! data defining the radius of the fillet is not compatible
0296   //! with the geometry of the initial shape. There is no initial
0297   //! analysis of errors and they only become evident at the
0298   //! construction stage.
0299   //! Additionally, in the current software release, the
0300   //! following cases are not handled:
0301   //! -   the end point of the contour is the point of
0302   //! intersection of 4 or more edges of the shape, or
0303   //! -   the intersection of the fillet with a face which limits
0304   //! the contour is not fully contained in this face.
0305   Standard_EXPORT void Build(
0306     const Message_ProgressRange& theRange = Message_ProgressRange()) override;
0307 
0308   //! Reinitializes this algorithm, thus canceling the effects of the Build function.
0309   //! This function allows modifications to be made to the
0310   //! contours and fillet parameters in order to rebuild the shape.
0311   Standard_EXPORT void Reset() override;
0312 
0313   //! Returns the internal topology building algorithm.
0314   Standard_EXPORT occ::handle<TopOpeBRepBuild_HBuilder> Builder() const;
0315 
0316   //! Returns the list of shapes generated from the
0317   //! shape <EorV>.
0318   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Generated(
0319     const TopoDS_Shape& EorV) override;
0320 
0321   //! Returns the list of shapes modified from the shape
0322   //! <F>.
0323   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Modified(const TopoDS_Shape& F) override;
0324 
0325   Standard_EXPORT bool IsDeleted(const TopoDS_Shape& F) override;
0326 
0327   //! returns the number of surfaces
0328   //! after the shape creation.
0329   Standard_EXPORT int NbSurfaces() const;
0330 
0331   //! Return the faces created for surface <I>.
0332   Standard_EXPORT const NCollection_List<TopoDS_Shape>& NewFaces(const int I);
0333 
0334   Standard_EXPORT void Simulate(const int IC) override;
0335 
0336   Standard_EXPORT int NbSurf(const int IC) const override;
0337 
0338   Standard_EXPORT occ::handle<NCollection_HArray1<ChFiDS_CircSection>> Sect(
0339     const int IC,
0340     const int IS) const override;
0341 
0342   //! Returns the number of contours where the computation
0343   //! of the fillet failed
0344   Standard_EXPORT int NbFaultyContours() const;
0345 
0346   //! for each I in [1.. NbFaultyContours] returns the index IC of
0347   //! the contour where the computation of the fillet failed.
0348   //! the method NbEdges(IC) gives the number of edges in the contour IC
0349   //! the method Edge(IC,ie) gives the edge number ie of the contour IC
0350   Standard_EXPORT int FaultyContour(const int I) const;
0351 
0352   //! returns the number of surfaces which have been
0353   //! computed on the contour IC
0354   Standard_EXPORT int NbComputedSurfaces(const int IC) const;
0355 
0356   //! returns the surface number IS concerning the contour IC
0357   Standard_EXPORT occ::handle<Geom_Surface> ComputedSurface(const int IC, const int IS) const;
0358 
0359   //! returns the number of vertices where the computation failed
0360   Standard_EXPORT int NbFaultyVertices() const;
0361 
0362   //! returns the vertex where the computation failed
0363   Standard_EXPORT TopoDS_Vertex FaultyVertex(const int IV) const;
0364 
0365   //! returns true if a part of the result has been computed
0366   //! if the filling in a corner failed a shape with a hole is returned
0367   Standard_EXPORT bool HasResult() const;
0368 
0369   //! if (HasResult()) returns the partial result
0370   Standard_EXPORT TopoDS_Shape BadShape() const;
0371 
0372   //! returns the status concerning the contour IC in case of error
0373   //! ChFiDS_Ok : the computation is Ok
0374   //! ChFiDS_StartsolFailure : the computation can't start, perhaps the
0375   //! the radius is too big
0376   //! ChFiDS_TwistedSurface : the computation failed because of a twisted
0377   //! surface
0378   //! ChFiDS_WalkingFailure : there is a problem in the walking
0379   //! ChFiDS_Error: other error different from above
0380   Standard_EXPORT ChFiDS_ErrorStatus StripeStatus(const int IC) const;
0381 
0382 private:
0383   ChFi3d_FilBuilder                                      myBuilder;
0384   NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> myMap;
0385 };
0386 
0387 #endif // _BRepFilletAPI_MakeFillet_HeaderFile