Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-01 09:17:44

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