Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:11:17

0001 // Created on: 1991-12-02
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1991-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 _AppDef_Compute_HeaderFile
0018 #define _AppDef_Compute_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <AppParCurves_MultiCurve.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <AppParCurves_MultiBSpCurve.hxx>
0027 #include <Approx_ParametrizationType.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <NCollection_HArray1.hxx>
0030 #include <AppParCurves_ConstraintCouple.hxx>
0031 #include <Standard_Integer.hxx>
0032 #include <AppParCurves_Constraint.hxx>
0033 #include <math_Vector.hxx>
0034 class AppDef_MultiLine;
0035 class AppDef_MyLineTool;
0036 class AppDef_MyGradientOfCompute;
0037 class AppDef_ParLeastSquareOfMyGradientOfCompute;
0038 class AppDef_ResConstraintOfMyGradientOfCompute;
0039 class AppDef_ParFunctionOfMyGradientOfCompute;
0040 class AppDef_Gradient_BFGSOfMyGradientOfCompute;
0041 class AppParCurves_MultiCurve;
0042 class AppParCurves_MultiBSpCurve;
0043 
0044 class AppDef_Compute
0045 {
0046 public:
0047   DEFINE_STANDARD_ALLOC
0048 
0049   //! The MultiLine <Line> will be approximated until tolerances
0050   //! will be reached.
0051   //! The approximation will be done from degreemin to degreemax
0052   //! with a cutting if the corresponding boolean is True.
0053   //! If <Squares> is True, the computation will be done with
0054   //! no iteration at all.
0055   Standard_EXPORT AppDef_Compute(
0056     const AppDef_MultiLine&          Line,
0057     const int                        degreemin       = 4,
0058     const int                        degreemax       = 8,
0059     const double                     Tolerance3d     = 1.0e-3,
0060     const double                     Tolerance2d     = 1.0e-6,
0061     const int                        NbIterations    = 5,
0062     const bool                       cutting         = true,
0063     const Approx_ParametrizationType parametrization = Approx_ChordLength,
0064     const bool                       Squares         = false);
0065 
0066   //! The MultiLine <Line> will be approximated until tolerances
0067   //! will be reached.
0068   //! The approximation will be done from degreemin to degreemax
0069   //! with a cutting if the corresponding boolean is True.
0070   //! If <Squares> is True, the computation will be done with
0071   //! no iteration at all.
0072   Standard_EXPORT AppDef_Compute(const AppDef_MultiLine& Line,
0073                                  const math_Vector&      Parameters,
0074                                  const int               degreemin    = 4,
0075                                  const int               degreemax    = 8,
0076                                  const double            Tolerance3d  = 1.0e-03,
0077                                  const double            Tolerance2d  = 1.0e-06,
0078                                  const int               NbIterations = 5,
0079                                  const bool              cutting      = true,
0080                                  const bool              Squares      = false);
0081 
0082   //! Initializes the fields of the algorithm.
0083   Standard_EXPORT AppDef_Compute(const math_Vector& Parameters,
0084                                  const int          degreemin    = 4,
0085                                  const int          degreemax    = 8,
0086                                  const double       Tolerance3d  = 1.0e-03,
0087                                  const double       Tolerance2d  = 1.0e-06,
0088                                  const int          NbIterations = 5,
0089                                  const bool         cutting      = true,
0090                                  const bool         Squares      = false);
0091 
0092   //! Initializes the fields of the algorithm.
0093   Standard_EXPORT AppDef_Compute(
0094     const int                        degreemin       = 4,
0095     const int                        degreemax       = 8,
0096     const double                     Tolerance3d     = 1.0e-03,
0097     const double                     Tolerance2d     = 1.0e-06,
0098     const int                        NbIterations    = 5,
0099     const bool                       cutting         = true,
0100     const Approx_ParametrizationType parametrization = Approx_ChordLength,
0101     const bool                       Squares         = false);
0102 
0103   //! Initializes the fields of the algorithm.
0104   Standard_EXPORT void Init(const int                        degreemin       = 4,
0105                             const int                        degreemax       = 8,
0106                             const double                     Tolerance3d     = 1.0e-03,
0107                             const double                     Tolerance2d     = 1.0e-06,
0108                             const int                        NbIterations    = 5,
0109                             const bool                       cutting         = true,
0110                             const Approx_ParametrizationType parametrization = Approx_ChordLength,
0111                             const bool                       Squares         = false);
0112 
0113   //! runs the algorithm after having initialized the fields.
0114   Standard_EXPORT void Perform(const AppDef_MultiLine& Line);
0115 
0116   //! changes the degrees of the approximation.
0117   Standard_EXPORT void SetDegrees(const int degreemin, const int degreemax);
0118 
0119   //! Changes the tolerances of the approximation.
0120   Standard_EXPORT void SetTolerances(const double Tolerance3d, const double Tolerance2d);
0121 
0122   //! changes the first and the last constraint points.
0123   Standard_EXPORT void SetConstraints(const AppParCurves_Constraint firstC,
0124                                       const AppParCurves_Constraint lastC);
0125 
0126   //! returns False if at a moment of the approximation,
0127   //! the status NoApproximation has been sent by the user
0128   //! when more points were needed.
0129   Standard_EXPORT bool IsAllApproximated() const;
0130 
0131   //! returns False if the status NoPointsAdded has been sent.
0132   Standard_EXPORT bool IsToleranceReached() const;
0133 
0134   //! returns the tolerances 2d and 3d of the <Index> MultiCurve.
0135   Standard_EXPORT void Error(const int Index, double& tol3d, double& tol2d) const;
0136 
0137   //! Returns the number of MultiCurve doing the approximation
0138   //! of the MultiLine.
0139   Standard_EXPORT int NbMultiCurves() const;
0140 
0141   //! returns the result of the approximation.
0142   Standard_EXPORT const AppParCurves_MultiCurve& Value(const int Index = 1) const;
0143 
0144   //! returns the result of the approximation.
0145   Standard_EXPORT AppParCurves_MultiCurve& ChangeValue(const int Index = 1);
0146 
0147   //! returns the result of the approximation.
0148   Standard_EXPORT const AppParCurves_MultiBSpCurve& SplineValue();
0149 
0150   //! returns the type of parametrization
0151   Standard_EXPORT Approx_ParametrizationType Parametrization() const;
0152 
0153   //! returns the new parameters of the approximation
0154   //! corresponding to the points of the multicurve <Index>.
0155   Standard_EXPORT const NCollection_Array1<double>& Parameters(const int Index = 1) const;
0156 
0157 private:
0158   //! is internally used in the algorithm.
0159   Standard_EXPORT bool Compute(const AppDef_MultiLine& Line,
0160                                const int               fpt,
0161                                const int               lpt,
0162                                math_Vector&            Para,
0163                                double&                 TheTol3d,
0164                                double&                 TheTol2d,
0165                                int&                    indbad);
0166 
0167   //! is internally used in the algorithm.
0168   Standard_EXPORT bool ComputeCurve(const AppDef_MultiLine& Line,
0169                                     const int               firspt,
0170                                     const int               lastpt);
0171 
0172   //! computes new parameters between firstP and lastP.
0173   Standard_EXPORT void Parameters(const AppDef_MultiLine& Line,
0174                                   const int               firstP,
0175                                   const int               LastP,
0176                                   math_Vector&            TheParameters) const;
0177 
0178   Standard_EXPORT double SearchFirstLambda(const AppDef_MultiLine& Line,
0179                                            const math_Vector&      Para,
0180                                            const math_Vector&      V,
0181                                            const int               index) const;
0182 
0183   Standard_EXPORT double SearchLastLambda(const AppDef_MultiLine& Line,
0184                                           const math_Vector&      Para,
0185                                           const math_Vector&      V,
0186                                           const int               index) const;
0187 
0188   Standard_EXPORT void FirstTangencyVector(const AppDef_MultiLine& Line,
0189                                            const int               index,
0190                                            math_Vector&            V) const;
0191 
0192   Standard_EXPORT void LastTangencyVector(const AppDef_MultiLine& Line,
0193                                           const int               index,
0194                                           math_Vector&            V) const;
0195 
0196   NCollection_Sequence<AppParCurves_MultiCurve>                   myMultiCurves;
0197   AppParCurves_MultiCurve                                         TheMultiCurve;
0198   AppParCurves_MultiBSpCurve                                      myspline;
0199   bool                                                            alldone;
0200   bool                                                            tolreached;
0201   Approx_ParametrizationType                                      Par;
0202   occ::handle<NCollection_HArray1<double>>                        myParameters;
0203   occ::handle<NCollection_HArray1<double>>                        myfirstParam;
0204   NCollection_Sequence<occ::handle<NCollection_HArray1<double>>>  myPar;
0205   NCollection_Sequence<double>                                    Tolers3d;
0206   NCollection_Sequence<double>                                    Tolers2d;
0207   occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>> myConstraints;
0208   int                                                             mydegremin;
0209   int                                                             mydegremax;
0210   double                                                          mytol3d;
0211   double                                                          mytol2d;
0212   double                                                          currenttol3d;
0213   double                                                          currenttol2d;
0214   bool                                                            mycut;
0215   bool                                                            mysquares;
0216   int                                                             myitermax;
0217   AppParCurves_Constraint                                         myfirstC;
0218   AppParCurves_Constraint                                         mylastC;
0219   int                                                             myMultiLineNb;
0220   bool                                                            myIsClear;
0221 };
0222 
0223 #endif // _AppDef_Compute_HeaderFile