Back to home page

EIC code displayed by LXR

 
 

    


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

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