Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-25 09:22:28

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