Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:57

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