Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-22 08:29:16

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