Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:12:20

0001 // Created on: 1995-01-27
0002 // Created by: Jacques GOUSSARD
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 _GeomInt_TheComputeLineOfWLApprox_HeaderFile
0018 #define _GeomInt_TheComputeLineOfWLApprox_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <AppParCurves_MultiBSpCurve.hxx>
0025 #include <Approx_ParametrizationType.hxx>
0026 #include <NCollection_Array1.hxx>
0027 #include <NCollection_HArray1.hxx>
0028 #include <Standard_Integer.hxx>
0029 #include <AppParCurves_ConstraintCouple.hxx>
0030 #include <AppParCurves_Constraint.hxx>
0031 #include <math_Vector.hxx>
0032 class GeomInt_TheMultiLineOfWLApprox;
0033 class GeomInt_TheMultiLineToolOfWLApprox;
0034 class GeomInt_MyBSplGradientOfTheComputeLineOfWLApprox;
0035 class GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox;
0036 class GeomInt_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfWLApprox;
0037 class GeomInt_BSpGradient_BFGSOfMyBSplGradientOfTheComputeLineOfWLApprox;
0038 class GeomInt_MyGradientbisOfTheComputeLineOfWLApprox;
0039 class GeomInt_ParLeastSquareOfMyGradientbisOfTheComputeLineOfWLApprox;
0040 class GeomInt_ResConstraintOfMyGradientbisOfTheComputeLineOfWLApprox;
0041 class GeomInt_ParFunctionOfMyGradientbisOfTheComputeLineOfWLApprox;
0042 class GeomInt_Gradient_BFGSOfMyGradientbisOfTheComputeLineOfWLApprox;
0043 class AppParCurves_MultiBSpCurve;
0044 class AppParCurves_MultiCurve;
0045 
0046 class GeomInt_TheComputeLineOfWLApprox
0047 {
0048 public:
0049   DEFINE_STANDARD_ALLOC
0050 
0051   //! The MultiLine <Line> will be approximated until tolerances
0052   //! will be reached.
0053   //! The approximation will be done from degreemin to degreemax
0054   //! with a cutting if the corresponding boolean is True.
0055   //! If <Squares> is True, the computation will be done with
0056   //! no iteration at all.
0057   //!
0058   //! The multiplicities of the internal knots is set by
0059   //! default.
0060   Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(
0061     const GeomInt_TheMultiLineOfWLApprox& Line,
0062     const int                             degreemin       = 4,
0063     const int                             degreemax       = 8,
0064     const double                          Tolerance3d     = 1.0e-3,
0065     const double                          Tolerance2d     = 1.0e-6,
0066     const int                             NbIterations    = 5,
0067     const bool                            cutting         = true,
0068     const Approx_ParametrizationType      parametrization = Approx_ChordLength,
0069     const bool                            Squares         = false);
0070 
0071   //! The MultiLine <Line> will be approximated until tolerances
0072   //! will be reached.
0073   //! The approximation will be done from degreemin to degreemax
0074   //! with a cutting if the corresponding boolean is True.
0075   //! If <Squares> is True, the computation will be done with
0076   //! no iteration at all.
0077   Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& Line,
0078                                                    const math_Vector&                    Parameters,
0079                                                    const int    degreemin    = 4,
0080                                                    const int    degreemax    = 8,
0081                                                    const double Tolerance3d  = 1.0e-03,
0082                                                    const double Tolerance2d  = 1.0e-06,
0083                                                    const int    NbIterations = 5,
0084                                                    const bool   cutting      = true,
0085                                                    const bool   Squares      = false);
0086 
0087   //! Initializes the fields of the algorithm.
0088   Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(const math_Vector& Parameters,
0089                                                    const int          degreemin    = 4,
0090                                                    const int          degreemax    = 8,
0091                                                    const double       Tolerance3d  = 1.0e-03,
0092                                                    const double       Tolerance2d  = 1.0e-06,
0093                                                    const int          NbIterations = 5,
0094                                                    const bool         cutting      = true,
0095                                                    const bool         Squares      = false);
0096 
0097   //! Initializes the fields of the algorithm.
0098   Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(
0099     const int                        degreemin       = 4,
0100     const int                        degreemax       = 8,
0101     const double                     Tolerance3d     = 1.0e-03,
0102     const double                     Tolerance2d     = 1.0e-06,
0103     const int                        NbIterations    = 5,
0104     const bool                       cutting         = true,
0105     const Approx_ParametrizationType parametrization = Approx_ChordLength,
0106     const bool                       Squares         = false);
0107 
0108   //! Constructs an interpolation of the MultiLine <Line>
0109   //! The result will be a C2 curve of degree 3.
0110   Standard_EXPORT void Interpol(const GeomInt_TheMultiLineOfWLApprox& Line);
0111 
0112   //! Initializes the fields of the algorithm.
0113   Standard_EXPORT void Init(const int                        degreemin       = 4,
0114                             const int                        degreemax       = 8,
0115                             const double                     Tolerance3d     = 1.0e-03,
0116                             const double                     Tolerance2d     = 1.0e-06,
0117                             const int                        NbIterations    = 5,
0118                             const bool                       cutting         = true,
0119                             const Approx_ParametrizationType parametrization = Approx_ChordLength,
0120                             const bool                       Squares         = false);
0121 
0122   //! runs the algorithm after having initialized the fields.
0123   Standard_EXPORT void Perform(const GeomInt_TheMultiLineOfWLApprox& Line);
0124 
0125   //! The approximation will begin with the
0126   //! set of parameters <ThePar>.
0127   Standard_EXPORT void SetParameters(const math_Vector& ThePar);
0128 
0129   //! The approximation will be done with the
0130   //! set of knots <Knots>. The multiplicities will be set
0131   //! with the degree and the desired continuity.
0132   Standard_EXPORT void SetKnots(const NCollection_Array1<double>& Knots);
0133 
0134   //! The approximation will be done with the
0135   //! set of knots <Knots> and the multiplicities <Mults>.
0136   Standard_EXPORT void SetKnotsAndMultiplicities(const NCollection_Array1<double>& Knots,
0137                                                  const NCollection_Array1<int>&    Mults);
0138 
0139   //! changes the degrees of the approximation.
0140   Standard_EXPORT void SetDegrees(const int degreemin, const int degreemax);
0141 
0142   //! Changes the tolerances of the approximation.
0143   Standard_EXPORT void SetTolerances(const double Tolerance3d, const double Tolerance2d);
0144 
0145   //! sets the continuity of the spline.
0146   //! if C = 2, the spline will be C2.
0147   Standard_EXPORT void SetContinuity(const int C);
0148 
0149   //! changes the first and the last constraint points.
0150   Standard_EXPORT void SetConstraints(const AppParCurves_Constraint firstC,
0151                                       const AppParCurves_Constraint lastC);
0152 
0153   //! Sets periodic flag.
0154   //! If thePeriodic = true, algorithm tries to build periodic
0155   //! multicurve using corresponding C1 boundary condition for first and last multipoints.
0156   //! Multiline must be closed.
0157   Standard_EXPORT void SetPeriodic(const bool thePeriodic);
0158 
0159   //! returns False if at a moment of the approximation,
0160   //! the status NoApproximation has been sent by the user
0161   //! when more points were needed.
0162   Standard_EXPORT bool IsAllApproximated() const;
0163 
0164   //! returns False if the status NoPointsAdded has been sent.
0165   Standard_EXPORT bool IsToleranceReached() const;
0166 
0167   //! returns the tolerances 2d and 3d of the MultiBSpCurve.
0168   Standard_EXPORT void Error(double& tol3d, double& tol2d) const;
0169 
0170   //! returns the result of the approximation.
0171   Standard_EXPORT const AppParCurves_MultiBSpCurve& Value() const;
0172 
0173   //! returns the result of the approximation.
0174   Standard_EXPORT AppParCurves_MultiBSpCurve& ChangeValue();
0175 
0176   //! returns the new parameters of the approximation
0177   //! corresponding to the points of the MultiBSpCurve.
0178   Standard_EXPORT const NCollection_Array1<double>& Parameters() const;
0179 
0180 private:
0181   //! is internally used in the algorithm.
0182   Standard_EXPORT bool Compute(const GeomInt_TheMultiLineOfWLApprox& Line,
0183                                const int                             fpt,
0184                                const int                             lpt,
0185                                math_Vector&                          Para,
0186                                const NCollection_Array1<double>&     Knots,
0187                                NCollection_Array1<int>&              Mults);
0188 
0189   //! is internally used in the algorithm.
0190   Standard_EXPORT bool ComputeCurve(const GeomInt_TheMultiLineOfWLApprox& Line,
0191                                     const int                             firspt,
0192                                     const int                             lastpt);
0193 
0194   //! computes new parameters between firstP and lastP.
0195   Standard_EXPORT void Parameters(const GeomInt_TheMultiLineOfWLApprox& Line,
0196                                   const int                             firstP,
0197                                   const int                             LastP,
0198                                   math_Vector&                          TheParameters) const;
0199 
0200   Standard_EXPORT double SearchFirstLambda(const GeomInt_TheMultiLineOfWLApprox& Line,
0201                                            const math_Vector&                    Para,
0202                                            const NCollection_Array1<double>&     Knots,
0203                                            const math_Vector&                    V,
0204                                            const int                             index) const;
0205 
0206   Standard_EXPORT double SearchLastLambda(const GeomInt_TheMultiLineOfWLApprox& Line,
0207                                           const math_Vector&                    Para,
0208                                           const NCollection_Array1<double>&     Knots,
0209                                           const math_Vector&                    V,
0210                                           const int                             index) const;
0211 
0212   Standard_EXPORT void TangencyVector(const GeomInt_TheMultiLineOfWLApprox& Line,
0213                                       const AppParCurves_MultiCurve&        C,
0214                                       const double                          U,
0215                                       math_Vector&                          V) const;
0216 
0217   Standard_EXPORT void FirstTangencyVector(const GeomInt_TheMultiLineOfWLApprox& Line,
0218                                            const int                             index,
0219                                            math_Vector&                          V) const;
0220 
0221   Standard_EXPORT void LastTangencyVector(const GeomInt_TheMultiLineOfWLApprox& Line,
0222                                           const int                             index,
0223                                           math_Vector&                          V) const;
0224 
0225   Standard_EXPORT void FindRealConstraints(const GeomInt_TheMultiLineOfWLApprox& Line);
0226 
0227   AppParCurves_MultiBSpCurve                                      TheMultiBSpCurve;
0228   bool                                                            alldone;
0229   bool                                                            tolreached;
0230   Approx_ParametrizationType                                      Par;
0231   occ::handle<NCollection_HArray1<double>>                        myParameters;
0232   occ::handle<NCollection_HArray1<double>>                        myfirstParam;
0233   occ::handle<NCollection_HArray1<double>>                        myknots;
0234   occ::handle<NCollection_HArray1<int>>                           mymults;
0235   bool                                                            myhasknots;
0236   bool                                                            myhasmults;
0237   occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>> myConstraints;
0238   int                                                             mydegremin;
0239   int                                                             mydegremax;
0240   double                                                          mytol3d;
0241   double                                                          mytol2d;
0242   double                                                          currenttol3d;
0243   double                                                          currenttol2d;
0244   bool                                                            mycut;
0245   bool                                                            mysquares;
0246   int                                                             myitermax;
0247   AppParCurves_Constraint                                         myfirstC;
0248   AppParCurves_Constraint                                         mylastC;
0249   AppParCurves_Constraint                                         realfirstC;
0250   AppParCurves_Constraint                                         reallastC;
0251   int                                                             mycont;
0252   double                                                          mylambda1;
0253   double                                                          mylambda2;
0254   bool                                                            myPeriodic;
0255 };
0256 
0257 #endif // _GeomInt_TheComputeLineOfWLApprox_HeaderFile