Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1996-02-05
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_Batten_HeaderFile
0018 #define _FairCurve_Batten_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <FairCurve_AnalysisCode.hxx>
0025 #include <gp_Pnt2d.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <TColgp_HArray1OfPnt2d.hxx>
0028 #include <TColStd_HArray1OfReal.hxx>
0029 #include <TColStd_HArray1OfInteger.hxx>
0030 #include <Standard_OStream.hxx>
0031 class gp_Vec2d;
0032 class Geom2d_BSplineCurve;
0033 
0034 
0035 //! Constructs curves with a constant or linearly increasing
0036 //! section to be used in the design of wooden or plastic
0037 //! battens. These curves are two-dimensional, and
0038 //! simulate physical splines or battens.
0039 class FairCurve_Batten 
0040 {
0041 public:
0042 
0043   DEFINE_STANDARD_ALLOC
0044 
0045   
0046   //! Constructor  with the two points and the geometrical
0047   //! characteristics of the batten (elastic beam)
0048   //! Height is the height of the deformation, and Slope is the
0049   //! slope value, initialized at 0. The user can then supply the
0050   //! desired slope value by the method, SetSlope.
0051   //! Other parameters are initialized as follow :
0052   //! - FreeSliding = False
0053   //! - ConstraintOrder1 = 1
0054   //! - ConstraintOrder2 = 1
0055   //! - Angle1 = 0
0056   //! - Angle2 = 0
0057   //! - SlidingFactor = 1
0058   //! Exceptions
0059   //! NegativeValue if Height is less than or equal to 0.
0060   //! NullValue if the distance between P1 and P2 is less
0061   //! than or equal to the tolerance value for distance in
0062   //! Precision::Confusion: P1.IsEqual(P2,
0063   //! Precision::Confusion()). The function
0064   //! gp_Pnt2d::IsEqual tests to see if this is the case.
0065   Standard_EXPORT FairCurve_Batten(const gp_Pnt2d& P1, const gp_Pnt2d& P2, const Standard_Real Height, const Standard_Real Slope = 0);
0066   
0067   Standard_EXPORT virtual ~FairCurve_Batten();
0068   
0069   //! Freesliding is initialized with the default setting false.
0070   //! When Freesliding is set to true and, as a result, sliding
0071   //! is free, the sliding factor is automatically computed to
0072   //! satisfy the equilibrium of the batten.
0073     void SetFreeSliding (const Standard_Boolean FreeSliding);
0074   
0075   //! Allows you to change the order of the constraint on the
0076   //! first point. ConstraintOrder has the default setting of 1.
0077   //! The following settings are available:
0078   //! -   0-the curve must pass through a point
0079   //! -   1-the curve must pass through a point and have a given tangent
0080   //! -   2-the curve must pass through a point, have a given tangent and a given curvature.
0081   //! The third setting is only valid for
0082   //! FairCurve_MinimalVariation curves.
0083   //! These constraints, though geometric, represent the
0084   //! mechanical constraints due, for example, to the
0085   //! resistance of the material the actual physical batten is made of.
0086     void SetConstraintOrder1 (const Standard_Integer ConstraintOrder);
0087   
0088   //! Allows you to change the order of the constraint on the
0089   //! second point. ConstraintOrder is initialized with the default setting of 1.
0090   //! The following settings are available:
0091   //! -   0-the curve must pass through a point
0092   //! -   1-the curve must pass through a point and have a given tangent
0093   //! -   2-the curve must pass through a point, have a given
0094   //! tangent and a given curvature.
0095   //! The third setting is only valid for
0096   //! FairCurve_MinimalVariation curves.
0097   //! These constraints, though geometric, represent the
0098   //! mechanical constraints due, for example, to the
0099   //! resistance of the material the actual physical batten is made of.
0100     void SetConstraintOrder2 (const Standard_Integer ConstraintOrder);
0101   
0102   //! Allows you to change the location of the point, P1, and in
0103   //! doing so, modify the curve.
0104   //! Warning
0105   //! This method changes the angle as well as the point.
0106   //! Exceptions
0107   //! NullValue if the distance between P1 and P2 is less
0108   //! than or equal to the tolerance value for distance in
0109   //! Precision::Confusion: P1.IsEqual(P2,
0110   //! Precision::Confusion()). The function
0111   //! gp_Pnt2d::IsEqual tests to see if this is the case.
0112   Standard_EXPORT void SetP1 (const gp_Pnt2d& P1);
0113   
0114   //! Allows you to change the location of the point, P1, and in
0115   //! doing so, modify the curve.
0116   //! Warning
0117   //! This method changes the angle as well as the point.
0118   //! Exceptions
0119   //! NullValue if the distance between P1 and P2 is less
0120   //! than or equal to the tolerance value for distance in
0121   //! Precision::Confusion: P1.IsEqual(P2,
0122   //! Precision::Confusion()). The function
0123   //! gp_Pnt2d::IsEqual tests to see if this is the case.
0124   Standard_EXPORT void SetP2 (const gp_Pnt2d& P2);
0125   
0126   //! Allows you to change the angle Angle1 at the first point,
0127   //! P1. The default setting is 0.
0128     void SetAngle1 (const Standard_Real Angle1);
0129   
0130   //! Allows you to change the angle Angle2 at the second
0131   //! point, P2. The default setting is 0.
0132     void SetAngle2 (const Standard_Real Angle2);
0133   
0134   //! Allows you to change the height of the deformation.
0135   //! Raises  NegativeValue; -- if  Height <= 0
0136   //! if  Height <= 0
0137     void SetHeight (const Standard_Real Height);
0138   
0139   //! Allows you to set the slope value, Slope.
0140     void SetSlope (const Standard_Real Slope);
0141   
0142   //! Allows you to change the ratio SlidingFactor. This
0143   //! compares the length of the batten and the reference
0144   //! length, which is, in turn, a function of the constraints.
0145   //! This modification has one of the following two effects:
0146   //! -   if you increase the value, it inflates the batten
0147   //! -   if you decrease the value, it flattens the batten.
0148   //! When sliding is free, the sliding factor is automatically
0149   //! computed to satisfy the equilibrium of the batten. When
0150   //! sliding is imposed, a value is required for the sliding factor.
0151   //! SlidingFactor is initialized with the default setting of 1.
0152     void SetSlidingFactor (const Standard_Real SlidingFactor);
0153   
0154   //! Performs the algorithm, using the arguments Code,
0155   //! NbIterations and Tolerance and computes the curve
0156   //! with respect to the constraints.
0157   //! Code will have one of the following values:
0158   //! -   OK
0159   //! -   NotConverged
0160   //! -   InfiniteSliding
0161   //! -   NullHeight
0162   //! The parameters Tolerance and NbIterations control
0163   //! how precise the computation is, and how long it will take.
0164   Standard_EXPORT virtual Standard_Boolean Compute (FairCurve_AnalysisCode& Code, const Standard_Integer NbIterations = 50, const Standard_Real Tolerance = 1.0e-3);
0165   
0166   //! Computes the real number value for length Sliding of
0167   //! Reference for new constraints. If you want to give a
0168   //! specific length to a batten curve, use the following
0169   //! syntax: b.SetSlidingFactor(L /
0170   //! b.SlidingOfReference()) where b is the
0171   //! name of the batten curve object.
0172   Standard_EXPORT Standard_Real SlidingOfReference() const;
0173   
0174   //! Returns the initial free sliding value, false by default.
0175   //! Free sliding is generally more aesthetically pleasing
0176   //! than constrained sliding. However, the computation can
0177   //! fail with values such as angles greater than PI/2. This is
0178   //! because the resulting batten length is theoretically infinite.
0179     Standard_Boolean GetFreeSliding() const;
0180   
0181   //! Returns the established first constraint order.
0182     Standard_Integer GetConstraintOrder1() const;
0183   
0184   //! Returns the established second constraint order.
0185     Standard_Integer GetConstraintOrder2() const;
0186   
0187   //! Returns the established location of the point P1.
0188     const gp_Pnt2d& GetP1() const;
0189   
0190   //! Returns the established location of the point P2.
0191     const gp_Pnt2d& GetP2() const;
0192   
0193   //! Returns the established first angle.
0194     Standard_Real GetAngle1() const;
0195   
0196   //! Returns the established second angle.
0197     Standard_Real GetAngle2() const;
0198   
0199   //! Returns the thickness of the lathe.
0200     Standard_Real GetHeight() const;
0201   
0202   //! Returns the established slope value.
0203     Standard_Real GetSlope() const;
0204   
0205   //! Returns the initial sliding factor.
0206     Standard_Real GetSlidingFactor() const;
0207   
0208   //! Returns the computed curve a 2d BSpline.
0209   Standard_EXPORT Handle(Geom2d_BSplineCurve) Curve() const;
0210   
0211   //! Prints on the stream o information on the current state
0212   //! of the object.
0213   //!
0214   //! Private methodes  --------------------------------------
0215   Standard_EXPORT virtual void Dump (Standard_OStream& o) const;
0216 
0217 
0218 
0219 
0220 protected:
0221 
0222   
0223   Standard_EXPORT Standard_Real SlidingOfReference (const Standard_Real D, const Standard_Real A1, const Standard_Real A2) const;
0224   
0225   Standard_EXPORT Standard_Real Compute (const Standard_Real D, const Standard_Real A1, const Standard_Real A2) const;
0226   
0227   //! Returns the effective geometrical constraints at  the
0228   //! last batten  computation.  This effectives values may
0229   //! be not equal with the wanted values if
0230   //! - if the value is "free"
0231   //! - in the case of incomplete computation : collapse,
0232   //! infinite sliding, height of batten will be negative at end points
0233   Standard_EXPORT Standard_Real Compute (const Standard_Real D, const Standard_Real A) const;
0234 
0235 
0236   FairCurve_AnalysisCode myCode;
0237   gp_Pnt2d OldP1;
0238   gp_Pnt2d OldP2;
0239   Standard_Real OldAngle1;
0240   Standard_Real OldAngle2;
0241   Standard_Real OldHeight;
0242   Standard_Real OldSlope;
0243   Standard_Real OldSlidingFactor;
0244   Standard_Boolean OldFreeSliding;
0245   Standard_Integer OldConstraintOrder1;
0246   Standard_Integer OldConstraintOrder2;
0247   gp_Pnt2d NewP1;
0248   gp_Pnt2d NewP2;
0249   Standard_Real NewAngle1;
0250   Standard_Real NewAngle2;
0251   Standard_Real NewHeight;
0252   Standard_Real NewSlope;
0253   Standard_Real NewSlidingFactor;
0254   Standard_Boolean NewFreeSliding;
0255   Standard_Integer NewConstraintOrder1;
0256   Standard_Integer NewConstraintOrder2;
0257   Standard_Integer Degree;
0258   Handle(TColgp_HArray1OfPnt2d) Poles;
0259   Handle(TColStd_HArray1OfReal) Flatknots;
0260   Handle(TColStd_HArray1OfReal) Knots;
0261   Handle(TColStd_HArray1OfInteger) Mults;
0262 
0263 
0264 private:
0265 
0266   
0267   //! compute the curve with respect of the delta-constraints.
0268   Standard_EXPORT Standard_Boolean Compute (const gp_Vec2d& DeltaP1, const gp_Vec2d& DeltaP2, const Standard_Real DeltaAngle1, const Standard_Real DeltaAngle2, FairCurve_AnalysisCode& ACode, const Standard_Integer NbIterations, const Standard_Real Tolerance);
0269   
0270   Standard_EXPORT void Angles (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
0271 
0272 
0273 
0274 
0275 };
0276 
0277 
0278 #include <FairCurve_Batten.lxx>
0279 
0280 
0281 
0282 
0283 
0284 #endif // _FairCurve_Batten_HeaderFile