Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1998-05-12
0002 // Created by: Philippe NOUAILLE
0003 // Copyright (c) 1998-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 _BRepBlend_AppFuncRoot_HeaderFile
0018 #define _BRepBlend_AppFuncRoot_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <math_Vector.hxx>
0024 #include <Blend_Point.hxx>
0025 #include <gp_Pnt.hxx>
0026 #include <Approx_SweepFunction.hxx>
0027 #include <NCollection_Array1.hxx>
0028 #include <gp_Pnt2d.hxx>
0029 #include <gp_Vec.hxx>
0030 #include <gp_Vec2d.hxx>
0031 #include <Standard_Integer.hxx>
0032 #include <GeomAbs_Shape.hxx>
0033 
0034 #include <memory>
0035 
0036 class BRepBlend_Line;
0037 class Blend_AppFunction;
0038 class math_FunctionSetRoot;
0039 
0040 //! Function to approximate by AppSurface
0041 class BRepBlend_AppFuncRoot : public Approx_SweepFunction
0042 {
0043 
0044 public:
0045   //! compute the section for v = param
0046   Standard_EXPORT bool D0(const double                  Param,
0047                           const double                  First,
0048                           const double                  Last,
0049                           NCollection_Array1<gp_Pnt>&   Poles,
0050                           NCollection_Array1<gp_Pnt2d>& Poles2d,
0051                           NCollection_Array1<double>&   Weigths) override;
0052 
0053   //! compute the first derivative in v direction of the
0054   //! section for v = param
0055   Standard_EXPORT bool D1(const double                  Param,
0056                           const double                  First,
0057                           const double                  Last,
0058                           NCollection_Array1<gp_Pnt>&   Poles,
0059                           NCollection_Array1<gp_Vec>&   DPoles,
0060                           NCollection_Array1<gp_Pnt2d>& Poles2d,
0061                           NCollection_Array1<gp_Vec2d>& DPoles2d,
0062                           NCollection_Array1<double>&   Weigths,
0063                           NCollection_Array1<double>&   DWeigths) override;
0064 
0065   //! compute the second derivative in v direction of the
0066   //! section for v = param
0067   Standard_EXPORT bool D2(const double                  Param,
0068                           const double                  First,
0069                           const double                  Last,
0070                           NCollection_Array1<gp_Pnt>&   Poles,
0071                           NCollection_Array1<gp_Vec>&   DPoles,
0072                           NCollection_Array1<gp_Vec>&   D2Poles,
0073                           NCollection_Array1<gp_Pnt2d>& Poles2d,
0074                           NCollection_Array1<gp_Vec2d>& DPoles2d,
0075                           NCollection_Array1<gp_Vec2d>& D2Poles2d,
0076                           NCollection_Array1<double>&   Weigths,
0077                           NCollection_Array1<double>&   DWeigths,
0078                           NCollection_Array1<double>&   D2Weigths) override;
0079 
0080   //! get the number of 2d curves to approximate.
0081   Standard_EXPORT int Nb2dCurves() const override;
0082 
0083   //! get the format of an section
0084   Standard_EXPORT void SectionShape(int& NbPoles, int& NbKnots, int& Degree) const override;
0085 
0086   //! get the Knots of the section
0087   Standard_EXPORT void Knots(NCollection_Array1<double>& TKnots) const override;
0088 
0089   //! get the Multplicities of the section
0090   Standard_EXPORT void Mults(NCollection_Array1<int>& TMults) const override;
0091 
0092   //! Returns if the section is rational or not
0093   Standard_EXPORT bool IsRational() const override;
0094 
0095   //! Returns the number of intervals for continuity
0096   //! <S>. May be one if Continuity(me) >= <S>
0097   Standard_EXPORT int NbIntervals(const GeomAbs_Shape S) const override;
0098 
0099   //! Stores in <T> the parameters bounding the intervals
0100   //! of continuity <S>.
0101   //!
0102   //! The array must provide enough room to accommodate
0103   //! for the parameters. i.e. T.Length() > NbIntervals()
0104   Standard_EXPORT void Intervals(NCollection_Array1<double>& T,
0105                                  const GeomAbs_Shape         S) const override;
0106 
0107   //! Sets the bounds of the parametric interval on
0108   //! the fonction
0109   //! This determines the derivatives in these values if the
0110   //! function is not Cn.
0111   Standard_EXPORT void SetInterval(const double First, const double Last) override;
0112 
0113   //! Returns the resolutions in the sub-space 2d <Index> --
0114   //! This information is useful to find a good tolerance in
0115   //! 2d approximation
0116   Standard_EXPORT void Resolution(const int    Index,
0117                                   const double Tol,
0118                                   double&      TolU,
0119                                   double&      TolV) const override;
0120 
0121   //! Returns the tolerance to reach in approximation
0122   //! to respect
0123   //! BoundTol error at the Boundary
0124   //! AngleTol tangent error at the Boundary (in radian)
0125   //! SurfTol error inside the surface.
0126   Standard_EXPORT void GetTolerance(const double                BoundTol,
0127                                     const double                SurfTol,
0128                                     const double                AngleTol,
0129                                     NCollection_Array1<double>& Tol3d) const override;
0130 
0131   //! Is useful, if (me) has to be run numerical
0132   //! algorithm to perform D0, D1 or D2
0133   Standard_EXPORT void SetTolerance(const double Tol3d, const double Tol2d) override;
0134 
0135   //! Get the barycentre of Surface. An very poor
0136   //! estimation is sufficient. This information is useful
0137   //! to perform well conditioned rational approximation.
0138   Standard_EXPORT gp_Pnt BarycentreOfSurf() const override;
0139 
0140   //! Returns the length of the maximum section. This
0141   //! information is useful to perform well conditioned rational
0142   //! approximation.
0143   Standard_EXPORT double MaximalSection() const override;
0144 
0145   //! Compute the minimal value of weight for each poles
0146   //! of all sections. This information is useful to
0147   //! perform well conditioned rational approximation.
0148   Standard_EXPORT void GetMinimalWeight(NCollection_Array1<double>& Weigths) const override;
0149 
0150   Standard_EXPORT virtual void Point(const Blend_AppFunction& Func,
0151                                      const double             Param,
0152                                      const math_Vector&       Sol,
0153                                      Blend_Point&             Pnt) const = 0;
0154 
0155   Standard_EXPORT virtual void Vec(math_Vector& Sol, const Blend_Point& Pnt) const = 0;
0156 
0157   DEFINE_STANDARD_RTTIEXT(BRepBlend_AppFuncRoot, Approx_SweepFunction)
0158 
0159   Standard_EXPORT ~BRepBlend_AppFuncRoot();
0160 
0161 protected:
0162   Standard_EXPORT BRepBlend_AppFuncRoot(occ::handle<BRepBlend_Line>& Line,
0163                                         Blend_AppFunction&           Func,
0164                                         const double                 Tol3d,
0165                                         const double                 Tol2d);
0166 
0167 private:
0168   Standard_EXPORT bool SearchPoint(Blend_AppFunction& Func, const double Param, Blend_Point& Pnt);
0169 
0170   Standard_EXPORT bool SearchLocation(const double Param,
0171                                       const int    FirstIndex,
0172                                       const int    LastIndex,
0173                                       int&         ParamIndex) const;
0174 
0175   occ::handle<BRepBlend_Line>           myLine;
0176   void*                                 myFunc;
0177   math_Vector                           myTolerance;
0178   Blend_Point                           myPnt;
0179   gp_Pnt                                myBary;
0180   math_Vector                           X1;
0181   math_Vector                           X2;
0182   math_Vector                           XInit;
0183   math_Vector                           Sol;
0184   std::unique_ptr<math_FunctionSetRoot> mySolver;
0185 };
0186 
0187 #endif // _BRepBlend_AppFuncRoot_HeaderFile