Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:15:39

0001 // Created on: 1996-02-26
0002 // Created by: Philippe MANGIN
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 _FairCurve_MinimalVariation_HeaderFile
0018 #define _FairCurve_MinimalVariation_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <FairCurve_Batten.hxx>
0024 #include <FairCurve_AnalysisCode.hxx>
0025 #include <Standard_OStream.hxx>
0026 class gp_Pnt2d;
0027 class gp_Vec2d;
0028 
0029 //! Computes a 2D curve using an algorithm which
0030 //! minimizes tension, sagging, and jerk energy. As in
0031 //! FairCurve_Batten, two reference points are used.
0032 //! Unlike that class, FairCurve_MinimalVariation
0033 //! requires curvature settings at the first and second
0034 //! reference points. These are defined by the rays of
0035 //! curvature desired at each point.
0036 class FairCurve_MinimalVariation : public FairCurve_Batten
0037 {
0038 public:
0039   DEFINE_STANDARD_ALLOC
0040 
0041   //! Constructs the two contact points P1 and P2 and the geometrical
0042   //! characteristics of the batten (elastic beam)
0043   //! These include the real number values for height of
0044   //! deformation Height, slope value Slope, and kind of
0045   //! energy PhysicalRatio. The kinds of energy include:
0046   //! -   Jerk (0)
0047   //! -   Sagging (1).
0048   //! Note that the default setting for Physical Ration is in FairCurve_Batten
0049   //! Other parameters are initialized as follow :
0050   //! - FreeSliding = False
0051   //! - ConstraintOrder1 = 1
0052   //! - ConstraintOrder2 = 1
0053   //! - Angle1 = 0
0054   //! - Angle2 = 0
0055   //! - Curvature1 = 0
0056   //! - Curvature2 = 0
0057   //! - SlidingFactor = 1
0058   //! Warning
0059   //! If PhysicalRatio equals 1, you cannot impose constraints on curvature.
0060   //! Exceptions
0061   //! NegativeValue if Height is less than or equal to 0.
0062   //! NullValue if the distance between P1 and P2 is less
0063   //! than or equal to the tolerance value for distance in
0064   //! Precision::Confusion: P1.IsEqual(P2,
0065   //! Precision::Confusion()). The function
0066   //! gp_Pnt2d::IsEqual tests to see if this is the case.
0067   //! Definition of the geometricals constraints
0068   Standard_EXPORT FairCurve_MinimalVariation(const gp_Pnt2d& P1,
0069                                              const gp_Pnt2d& P2,
0070                                              const double    Heigth,
0071                                              const double    Slope         = 0,
0072                                              const double    PhysicalRatio = 0);
0073 
0074   //! Allows you to set a new constraint on curvature at the first point.
0075   void SetCurvature1(const double Curvature);
0076 
0077   //! Allows you to set a new constraint on curvature at the second point.
0078   void SetCurvature2(const double Curvature);
0079 
0080   //! Allows you to set the physical ratio Ratio.
0081   //! The kinds of energy which you can specify include:
0082   //! 0 is only "Jerk" Energy
0083   //! 1 is only "Sagging" Energy like batten
0084   //! Warning: if Ratio is 1 it is impossible to impose curvature constraints.
0085   //! Raises DomainError if Ratio < 0 or Ratio > 1
0086   void SetPhysicalRatio(const double Ratio);
0087 
0088   //! Computes the curve with respect to the constraints,
0089   //! NbIterations and Tolerance. The tolerance setting
0090   //! allows you to control the precision of computation, and
0091   //! the maximum number of iterations allows you to set a limit on computation time.
0092   Standard_EXPORT bool Compute(FairCurve_AnalysisCode& ACode,
0093                                const int               NbIterations = 50,
0094                                const double            Tolerance    = 1.0e-3) override;
0095 
0096   //! Returns the first established curvature.
0097   double GetCurvature1() const;
0098 
0099   //! Returns the second established curvature.
0100   double GetCurvature2() const;
0101 
0102   //! Returns the physical ratio, or kind of energy.
0103   double GetPhysicalRatio() const;
0104 
0105   //! Prints on the stream o information on the current state
0106   //! of the object.
0107   //! Is used to redefine the operator <<.
0108   Standard_EXPORT void Dump(Standard_OStream& o) const override;
0109 
0110 private:
0111   //! compute the curve with respect of the delta-constraints.
0112   Standard_EXPORT bool Compute(const gp_Vec2d&         DeltaP1,
0113                                const gp_Vec2d&         DeltaP2,
0114                                const double            DeltaAngle1,
0115                                const double            DeltaAngle2,
0116                                const double            DeltaCurvature1,
0117                                const double            DeltaCurvature2,
0118                                FairCurve_AnalysisCode& ACode,
0119                                const int               NbIterations,
0120                                const double            Tolerance);
0121 
0122   double OldCurvature1;
0123   double OldCurvature2;
0124   double OldPhysicalRatio;
0125   double NewCurvature1;
0126   double NewCurvature2;
0127   double NewPhysicalRatio;
0128 };
0129 
0130 #include <FairCurve_MinimalVariation.lxx>
0131 
0132 #endif // _FairCurve_MinimalVariation_HeaderFile