Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:07

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