Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox_HeaderFile
0018 #define _GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <AppParCurves_Constraint.hxx>
0025 #include <AppParCurves_MultiBSpCurve.hxx>
0026 #include <NCollection_Array1.hxx>
0027 #include <NCollection_HArray1.hxx>
0028 #include <Standard_Integer.hxx>
0029 #include <math_Matrix.hxx>
0030 #include <math_Vector.hxx>
0031 #include <math_IntegerVector.hxx>
0032 #include <Standard_Real.hxx>
0033 class StdFail_NotDone;
0034 class Standard_OutOfRange;
0035 class Standard_DimensionError;
0036 class Standard_NoSuchObject;
0037 class GeomInt_TheMultiLineOfWLApprox;
0038 class GeomInt_TheMultiLineToolOfWLApprox;
0039 class AppParCurves_MultiCurve;
0040 class AppParCurves_MultiBSpCurve;
0041 class math_Matrix;
0042 
0043 class GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox
0044 {
0045 public:
0046   DEFINE_STANDARD_ALLOC
0047 
0048   //! given a MultiLine, this algorithm computes the least
0049   //! square resolution using the Householder-QR method.
0050   //! If the first and/or the last point is a constraint
0051   //! point, the value of the tangency or curvature is
0052   //! computed in the resolution.
0053   //! NbPol is the number of control points wanted
0054   //! for the approximating curves.
0055   //! The system to solve is the following:
0056   //! A X = B.
0057   //! Where A is the Bernstein matrix computed with the
0058   //! parameters, B the points coordinates and X the poles
0059   //! solutions.
0060   //! The matrix A is the same for each coordinate x, y and z
0061   //! and is also the same for each MultiLine point because
0062   //! they are approximated in parallel(so with the same
0063   //! parameter, only the vector B changes).
0064   Standard_EXPORT GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox(
0065     const GeomInt_TheMultiLineOfWLApprox& SSP,
0066     const int                             FirstPoint,
0067     const int                             LastPoint,
0068     const AppParCurves_Constraint         FirstCons,
0069     const AppParCurves_Constraint         LastCons,
0070     const math_Vector&                    Parameters,
0071     const int                             NbPol);
0072 
0073   //! Initializes the fields of the object.
0074   Standard_EXPORT GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox(
0075     const GeomInt_TheMultiLineOfWLApprox& SSP,
0076     const int                             FirstPoint,
0077     const int                             LastPoint,
0078     const AppParCurves_Constraint         FirstCons,
0079     const AppParCurves_Constraint         LastCons,
0080     const int                             NbPol);
0081 
0082   //! given a MultiLine, this algorithm computes the least
0083   //! square resolution using the Householder-QR method.
0084   //! If the first and/or the last point is a constraint
0085   //! point, the value of the tangency or curvature is
0086   //! computed in the resolution.
0087   //! Deg is the degree wanted for the approximating curves.
0088   //! The system to solve is the following:
0089   //! A X = B.
0090   //! Where A is the BSpline functions matrix computed with
0091   //! <parameters>, B the points coordinates and X the poles
0092   //! solutions.
0093   //! The matrix A is the same for each coordinate x, y and z
0094   //! and is also the same for each MultiLine point because
0095   //! they are approximated in parallel(so with the same
0096   //! parameter, only the vector B changes).
0097   Standard_EXPORT GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox(
0098     const GeomInt_TheMultiLineOfWLApprox& SSP,
0099     const NCollection_Array1<double>&     Knots,
0100     const NCollection_Array1<int>&        Mults,
0101     const int                             FirstPoint,
0102     const int                             LastPoint,
0103     const AppParCurves_Constraint         FirstCons,
0104     const AppParCurves_Constraint         LastCons,
0105     const math_Vector&                    Parameters,
0106     const int                             NbPol);
0107 
0108   //! Initializes the fields of the object.
0109   Standard_EXPORT GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox(
0110     const GeomInt_TheMultiLineOfWLApprox& SSP,
0111     const NCollection_Array1<double>&     Knots,
0112     const NCollection_Array1<int>&        Mults,
0113     const int                             FirstPoint,
0114     const int                             LastPoint,
0115     const AppParCurves_Constraint         FirstCons,
0116     const AppParCurves_Constraint         LastCons,
0117     const int                             NbPol);
0118 
0119   //! Is used after having initialized the fields.
0120   //! The case "CurvaturePoint" is not treated in this method.
0121   Standard_EXPORT void Perform(const math_Vector& Parameters);
0122 
0123   //! Is used after having initialized the fields.
0124   Standard_EXPORT void Perform(const math_Vector& Parameters, const double l1, const double l2);
0125 
0126   //! Is used after having initialized the fields.
0127   //! <V1t> is the tangent vector at the first point.
0128   //! <V2t> is the tangent vector at the last point.
0129   Standard_EXPORT void Perform(const math_Vector& Parameters,
0130                                const math_Vector& V1t,
0131                                const math_Vector& V2t,
0132                                const double       l1,
0133                                const double       l2);
0134 
0135   //! Is used after having initialized the fields.
0136   //! <V1t> is the tangent vector at the first point.
0137   //! <V2t> is the tangent vector at the last point.
0138   //! <V1c> is the tangent vector at the first point.
0139   //! <V2c> is the tangent vector at the last point.
0140   Standard_EXPORT void Perform(const math_Vector& Parameters,
0141                                const math_Vector& V1t,
0142                                const math_Vector& V2t,
0143                                const math_Vector& V1c,
0144                                const math_Vector& V2c,
0145                                const double       l1,
0146                                const double       l2);
0147 
0148   //! returns True if all has been correctly done.
0149   Standard_EXPORT bool IsDone() const;
0150 
0151   //! returns the result of the approximation, i.e. all the
0152   //! Curves.
0153   //! An exception is raised if NotDone.
0154   Standard_EXPORT AppParCurves_MultiCurve BezierValue();
0155 
0156   //! returns the result of the approximation, i.e. all the
0157   //! Curves.
0158   //! An exception is raised if NotDone.
0159   Standard_EXPORT const AppParCurves_MultiBSpCurve& BSplineValue();
0160 
0161   //! returns the function matrix used to approximate the
0162   //! set.
0163   Standard_EXPORT const math_Matrix& FunctionMatrix() const;
0164 
0165   //! returns the derivative function matrix used
0166   //! to approximate the set.
0167   Standard_EXPORT const math_Matrix& DerivativeFunctionMatrix() const;
0168 
0169   //! returns the maximum errors between the MultiLine
0170   //! and the approximation curves. F is the sum of the square
0171   //! distances. Grad is the derivative vector of the
0172   //! function F.
0173   Standard_EXPORT void ErrorGradient(math_Vector& Grad, double& F, double& MaxE3d, double& MaxE2d);
0174 
0175   //! returns the distances between the points of the
0176   //! multiline and the approximation curves.
0177   Standard_EXPORT const math_Matrix& Distance();
0178 
0179   //! returns the maximum errors between the MultiLine
0180   //! and the approximation curves. F is the sum of the square
0181   //! distances.
0182   Standard_EXPORT void Error(double& F, double& MaxE3d, double& MaxE2d);
0183 
0184   //! returns the value (P2 - P1)/ V1 if the first point
0185   //! was a tangency point.
0186   Standard_EXPORT double FirstLambda() const;
0187 
0188   //! returns the value (PN - PN-1)/ VN if the last point
0189   //! was a tangency point.
0190   Standard_EXPORT double LastLambda() const;
0191 
0192   //! returns the matrix of points value.
0193   Standard_EXPORT const math_Matrix& Points() const;
0194 
0195   //! returns the matrix of resulting control points value.
0196   Standard_EXPORT const math_Matrix& Poles() const;
0197 
0198   //! Returns the indexes of the first non null values of
0199   //! A and DA.
0200   //! The values are non null from Index(ieme point) +1
0201   //! to Index(ieme point) + degree +1.
0202   Standard_EXPORT const math_IntegerVector& KIndex() const;
0203 
0204 protected:
0205   //! is used by the constructors above.
0206   Standard_EXPORT void Init(const GeomInt_TheMultiLineOfWLApprox& SSP,
0207                             const int                             FirstPoint,
0208                             const int                             LastPoint);
0209 
0210   //! returns the number of second member columns.
0211   //! Is used internally to initialize the fields.
0212   Standard_EXPORT int NbBColumns(const GeomInt_TheMultiLineOfWLApprox& SSP) const;
0213 
0214   //! returns the first point being fitted.
0215   Standard_EXPORT int TheFirstPoint(const AppParCurves_Constraint FirstCons,
0216                                     const int                     FirstPoint) const;
0217 
0218   //! returns the last point being fitted.
0219   Standard_EXPORT int TheLastPoint(const AppParCurves_Constraint LastCons,
0220                                    const int                     LastPoint) const;
0221 
0222   //! Affects the fields in the case of a constraint point.
0223   Standard_EXPORT void Affect(const GeomInt_TheMultiLineOfWLApprox& SSP,
0224                               const int                             Index,
0225                               AppParCurves_Constraint&              Cons,
0226                               math_Vector&                          Vt,
0227                               math_Vector&                          Vc);
0228 
0229   Standard_EXPORT void ComputeFunction(const math_Vector& Parameters);
0230 
0231   Standard_EXPORT void SearchIndex(math_IntegerVector& Index);
0232 
0233   //! computes internal matrixes for the resolution
0234   Standard_EXPORT void MakeTAA(math_Vector& TheA, math_Vector& TheB);
0235 
0236   //! computes internal matrixes for the resolution
0237   Standard_EXPORT void MakeTAA(math_Vector& TheA);
0238 
0239   //! computes internal matrixes for the resolution
0240   Standard_EXPORT void MakeTAA(math_Vector& TheA, math_Matrix& TheB);
0241 
0242 private:
0243   AppParCurves_Constraint                  FirstConstraint;
0244   AppParCurves_Constraint                  LastConstraint;
0245   AppParCurves_MultiBSpCurve               SCU;
0246   occ::handle<NCollection_HArray1<double>> myknots;
0247   occ::handle<NCollection_HArray1<int>>    mymults;
0248   math_Matrix                              mypoles;
0249   math_Matrix                              A;
0250   math_Matrix                              DA;
0251   math_Matrix                              B2;
0252   math_Matrix                              mypoints;
0253   math_Vector                              Vflatknots;
0254   math_Vector                              Vec1t;
0255   math_Vector                              Vec1c;
0256   math_Vector                              Vec2t;
0257   math_Vector                              Vec2c;
0258   math_Matrix                              theError;
0259   math_IntegerVector                       myindex;
0260   double                                   lambda1;
0261   double                                   lambda2;
0262   int                                      FirstP;
0263   int                                      LastP;
0264   int                                      Nlignes;
0265   int                                      Ninc;
0266   int                                      NA;
0267   int                                      myfirstp;
0268   int                                      mylastp;
0269   int                                      resinit;
0270   int                                      resfin;
0271   int                                      nbP2d;
0272   int                                      nbP;
0273   int                                      nbpoles;
0274   int                                      deg;
0275   bool                                     done;
0276   bool                                     iscalculated;
0277   bool                                     isready;
0278 };
0279 
0280 #endif // _GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox_HeaderFile