Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1996-05-14
0002 // Created by: Philippe MANGIN / Jeannine PANCIATICI
0003 // Copyright (c) 1996-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_Variational_HeaderFile
0018 #define _AppDef_Variational_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <AppDef_MultiLine.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <AppParCurves_HArray1OfConstraintCouple.hxx>
0027 #include <GeomAbs_Shape.hxx>
0028 #include <AppParCurves_MultiBSpCurve.hxx>
0029 #include <Standard_OStream.hxx>
0030 #include <TColStd_Array1OfReal.hxx>
0031 #include <math_Vector.hxx>
0032 #include <AppParCurves_Constraint.hxx>
0033 class AppDef_SmoothCriterion;
0034 class math_Matrix;
0035 class FEmTool_Curve;
0036 class FEmTool_Assembly;
0037 class PLib_Base;
0038 
0039 
0040 //! This class is used to smooth N points with constraints
0041 //! by   minimization  of quadratic  criterium   but  also
0042 //! variational criterium in order to obtain " fair Curve "
0043 //! Computes the approximation of a Multiline by
0044 //! Variational optimization.
0045 class AppDef_Variational 
0046 {
0047 public:
0048 
0049   DEFINE_STANDARD_ALLOC
0050 
0051   
0052   //! Constructor.
0053   //! Initialization of   the   fields.
0054   //! warning :  Nc0 : number of PassagePoint consraints
0055   //! Nc2 : number  of  TangencyPoint constraints
0056   //! Nc3 : number of    CurvaturePoint   constraints
0057   //! if
0058   //! ((MaxDegree-Continuity)*MaxSegment -Nc0  - 2*Nc1
0059   //! -3*Nc2)
0060   //! is  negative
0061   //! The problem is over-constrained.
0062   //!
0063   //! Limitation : The MultiLine from AppDef has to be composed by
0064   //! only one Line ( Dimension 2 or 3).
0065   Standard_EXPORT AppDef_Variational(const AppDef_MultiLine& SSP, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer MaxDegree = 14, const Standard_Integer MaxSegment = 100, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Boolean WithMinMax = Standard_False, const Standard_Boolean WithCutting = Standard_True, const Standard_Real Tolerance = 1.0, const Standard_Integer NbIterations = 2);
0066   
0067   //! Makes the approximation with the current fields.
0068   Standard_EXPORT void Approximate();
0069   
0070   //! returns True if the creation is done
0071   //! and correspond  to the current fields.
0072   Standard_EXPORT Standard_Boolean IsCreated() const;
0073   
0074   //! returns True if the  approximation is ok
0075   //! and correspond  to the current fields.
0076   Standard_EXPORT Standard_Boolean IsDone() const;
0077   
0078   //! returns True if the problem is overconstrained
0079   //! in this case, approximation cannot be done.
0080   Standard_EXPORT Standard_Boolean IsOverConstrained() const;
0081   
0082   //! returns all the BSpline curves approximating the
0083   //! MultiLine from AppDef SSP after minimization of the parameter.
0084   Standard_EXPORT AppParCurves_MultiBSpCurve Value() const;
0085   
0086   //! returns the maximum of the distances between
0087   //! the points of the multiline and the approximation
0088   //! curves.
0089   Standard_EXPORT Standard_Real MaxError() const;
0090   
0091   //! returns the index of the MultiPoint of ErrorMax
0092   Standard_EXPORT Standard_Integer MaxErrorIndex() const;
0093   
0094   //! returns the quadratic average of the distances between
0095   //! the points of the multiline and the approximation
0096   //! curves.
0097   Standard_EXPORT Standard_Real QuadraticError() const;
0098   
0099   //! returns the distances between the points of the
0100   //! multiline and the approximation curves.
0101   Standard_EXPORT void Distance (math_Matrix& mat);
0102   
0103   //! returns the average error between
0104   //! the MultiLine from AppDef and the approximation.
0105   Standard_EXPORT Standard_Real AverageError() const;
0106   
0107   //! returns the parameters uses to the approximations
0108   Standard_EXPORT const Handle(TColStd_HArray1OfReal)& Parameters() const;
0109   
0110   //! returns the knots uses to the approximations
0111   Standard_EXPORT const Handle(TColStd_HArray1OfReal)& Knots() const;
0112   
0113   //! returns the values of the quality criterium.
0114   Standard_EXPORT void Criterium (Standard_Real& VFirstOrder, Standard_Real& VSecondOrder, Standard_Real& VThirdOrder) const;
0115   
0116   //! returns the Weights (as percent) associed  to the criterium used in
0117   //! the  optimization.
0118   Standard_EXPORT void CriteriumWeight (Standard_Real& Percent1, Standard_Real& Percent2, Standard_Real& Percent3) const;
0119   
0120   //! returns the Maximum Degree used in the approximation
0121   Standard_EXPORT Standard_Integer MaxDegree() const;
0122   
0123   //! returns the Maximum of segment used in the approximation
0124   Standard_EXPORT Standard_Integer MaxSegment() const;
0125   
0126   //! returns the Continuity used in the approximation
0127   Standard_EXPORT GeomAbs_Shape Continuity() const;
0128   
0129   //! returns if the  approximation  search to  minimize the
0130   //! maximum Error or not.
0131   Standard_EXPORT Standard_Boolean WithMinMax() const;
0132   
0133   //! returns if the  approximation can insert new Knots or not.
0134   Standard_EXPORT Standard_Boolean WithCutting() const;
0135   
0136   //! returns the tolerance used in the approximation.
0137   Standard_EXPORT Standard_Real Tolerance() const;
0138   
0139   //! returns the number of iterations used in the approximation.
0140   Standard_EXPORT Standard_Integer NbIterations() const;
0141   
0142   //! Prints on the stream o information on the current state
0143   //! of the object.
0144   //! MaxError,MaxErrorIndex,AverageError,QuadraticError,Criterium
0145   //! Distances,Degre,Nombre de poles, parametres, noeuds
0146   Standard_EXPORT void Dump (Standard_OStream& o) const;
0147   
0148   //! Define the constraints to approximate
0149   //! If this value is incompatible with the others fields
0150   //! this method modify nothing and returns false
0151   Standard_EXPORT Standard_Boolean SetConstraints (const Handle(AppParCurves_HArray1OfConstraintCouple)& aConstrainst);
0152   
0153   //! Defines the parameters used by the approximations.
0154   Standard_EXPORT void SetParameters (const Handle(TColStd_HArray1OfReal)& param);
0155   
0156   //! Defines the knots used by the approximations
0157   //! If this value is incompatible with the others fields
0158   //! this method modify nothing and returns false
0159   Standard_EXPORT Standard_Boolean SetKnots (const Handle(TColStd_HArray1OfReal)& knots);
0160   
0161   //! Define the Maximum Degree used in the approximation
0162   //! If this value is incompatible with the others fields
0163   //! this method modify nothing and returns false
0164   Standard_EXPORT Standard_Boolean SetMaxDegree (const Standard_Integer Degree);
0165   
0166   //! Define the maximum number of segments used in the approximation
0167   //! If this value is incompatible with the others fields
0168   //! this method modify nothing and returns false
0169   Standard_EXPORT Standard_Boolean SetMaxSegment (const Standard_Integer NbSegment);
0170   
0171   //! Define the Continuity used in the approximation
0172   //! If this value is incompatible with the others fields
0173   //! this method modify nothing and returns false
0174   Standard_EXPORT Standard_Boolean SetContinuity (const GeomAbs_Shape C);
0175   
0176   //! Define if the  approximation  search to  minimize the
0177   //! maximum Error or not.
0178   Standard_EXPORT void SetWithMinMax (const Standard_Boolean MinMax);
0179   
0180   //! Define if the  approximation can insert new Knots or not.
0181   //! If this value is incompatible with the others fields
0182   //! this method modify nothing and returns false
0183   Standard_EXPORT Standard_Boolean SetWithCutting (const Standard_Boolean Cutting);
0184   
0185   //! define the Weights (as percent) associed to the criterium used in
0186   //! the  optimization.
0187   //!
0188   //! if Percent <= 0
0189   Standard_EXPORT void SetCriteriumWeight (const Standard_Real Percent1, const Standard_Real Percent2, const Standard_Real Percent3);
0190   
0191   //! define the  Weight   (as  percent)  associed  to   the
0192   //! criterium   Order used in   the optimization  : Others
0193   //! weights are updated.
0194   //! if Percent < 0
0195   //! if Order < 1 or Order > 3
0196   Standard_EXPORT void SetCriteriumWeight (const Standard_Integer Order, const Standard_Real Percent);
0197   
0198   //! define the tolerance used in the approximation.
0199   Standard_EXPORT void SetTolerance (const Standard_Real Tol);
0200   
0201   //! define the number of iterations used in the approximation.
0202   //! if Iter < 1
0203   Standard_EXPORT void SetNbIterations (const Standard_Integer Iter);
0204 
0205 
0206 
0207 
0208 protected:
0209 
0210 
0211 
0212 
0213 
0214 private:
0215 
0216   
0217   Standard_EXPORT void TheMotor (Handle(AppDef_SmoothCriterion)& J, const Standard_Real WQuadratic, const Standard_Real WQuality, Handle(FEmTool_Curve)& TheCurve, TColStd_Array1OfReal& Ecarts);
0218   
0219   Standard_EXPORT void Adjusting (Handle(AppDef_SmoothCriterion)& J, Standard_Real& WQuadratic, Standard_Real& WQuality, Handle(FEmTool_Curve)& TheCurve, TColStd_Array1OfReal& Ecarts);
0220   
0221   Standard_EXPORT void Optimization (Handle(AppDef_SmoothCriterion)& J, FEmTool_Assembly& A, const Standard_Boolean ToAssemble, const Standard_Real EpsDeg, Handle(FEmTool_Curve)& Curve, const TColStd_Array1OfReal& Parameters) const;
0222   
0223   Standard_EXPORT void Project (const Handle(FEmTool_Curve)& C, const TColStd_Array1OfReal& Ti, TColStd_Array1OfReal& ProjTi, TColStd_Array1OfReal& Distance, Standard_Integer& NumPoints, Standard_Real& MaxErr, Standard_Real& QuaErr, Standard_Real& AveErr, const Standard_Integer NbIterations = 2) const;
0224   
0225   Standard_EXPORT void ACR (Handle(FEmTool_Curve)& Curve, TColStd_Array1OfReal& Ti, const Standard_Integer Decima) const;
0226   
0227   Standard_EXPORT void SplitCurve (const Handle(FEmTool_Curve)& InCurve, const TColStd_Array1OfReal& Ti, const Standard_Real CurveTol, Handle(FEmTool_Curve)& OutCurve, Standard_Boolean& iscut) const;
0228   
0229   Standard_EXPORT void Init();
0230   
0231   Standard_EXPORT void InitSmoothCriterion();
0232   
0233   Standard_EXPORT void InitParameters (Standard_Real& Length);
0234   
0235   Standard_EXPORT void InitCriterionEstimations (const Standard_Real Length, Standard_Real& J1, Standard_Real& J2, Standard_Real& J3) const;
0236   
0237   Standard_EXPORT void EstTangent (const Standard_Integer ipnt, math_Vector& VTang) const;
0238   
0239   Standard_EXPORT void EstSecnd (const Standard_Integer ipnt, const math_Vector& VTang1, const math_Vector& VTang2, const Standard_Real Length, math_Vector& VScnd) const;
0240   
0241   Standard_EXPORT void InitCutting (const Handle(PLib_Base)& aBase, const Standard_Real CurvTol, Handle(FEmTool_Curve)& aCurve) const;
0242   
0243   Standard_EXPORT void AssemblingConstraints (const Handle(FEmTool_Curve)& Curve, const TColStd_Array1OfReal& Parameters, const Standard_Real CBLONG, FEmTool_Assembly& A) const;
0244   
0245   Standard_EXPORT Standard_Boolean InitTthetaF (const Standard_Integer ndimen, const AppParCurves_Constraint typcon, const Standard_Integer begin, const Standard_Integer jndex);
0246 
0247 
0248   AppDef_MultiLine mySSP;
0249   Standard_Integer myNbP3d;
0250   Standard_Integer myNbP2d;
0251   Standard_Integer myDimension;
0252   Standard_Integer myFirstPoint;
0253   Standard_Integer myLastPoint;
0254   Standard_Integer myNbPoints;
0255   Handle(TColStd_HArray1OfReal) myTabPoints;
0256   Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints;
0257   Standard_Integer myNbConstraints;
0258   Handle(TColStd_HArray1OfReal) myTabConstraints;
0259   Standard_Integer myNbPassPoints;
0260   Standard_Integer myNbTangPoints;
0261   Standard_Integer myNbCurvPoints;
0262   Handle(TColStd_HArray1OfInteger) myTypConstraints;
0263   Handle(TColStd_HArray1OfReal) myTtheta;
0264   Handle(TColStd_HArray1OfReal) myTfthet;
0265   Standard_Integer myMaxDegree;
0266   Standard_Integer myMaxSegment;
0267   Standard_Integer myNbIterations;
0268   Standard_Real myTolerance;
0269   GeomAbs_Shape myContinuity;
0270   Standard_Integer myNivCont;
0271   Standard_Boolean myWithMinMax;
0272   Standard_Boolean myWithCutting;
0273   Standard_Real myPercent[3];
0274   Standard_Real myCriterium[4];
0275   Handle(AppDef_SmoothCriterion) mySmoothCriterion;
0276   Handle(TColStd_HArray1OfReal) myParameters;
0277   Handle(TColStd_HArray1OfReal) myKnots;
0278   AppParCurves_MultiBSpCurve myMBSpCurve;
0279   Standard_Real myMaxError;
0280   Standard_Integer myMaxErrorIndex;
0281   Standard_Real myAverageError;
0282   Standard_Boolean myIsCreated;
0283   Standard_Boolean myIsDone;
0284   Standard_Boolean myIsOverConstr;
0285 
0286 
0287 };
0288 
0289 
0290 
0291 
0292 
0293 
0294 
0295 #endif // _AppDef_Variational_HeaderFile