1 // Created on: 1996-02-05
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _FairCurve_Batten_HeaderFile
18 #define _FairCurve_Batten_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <FairCurve_AnalysisCode.hxx>
25 #include <gp_Pnt2d.hxx>
26 #include <Standard_Integer.hxx>
27 #include <TColgp_HArray1OfPnt2d.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
29 #include <TColStd_HArray1OfInteger.hxx>
30 #include <Standard_OStream.hxx>
32 class Geom2d_BSplineCurve;
35 //! Constructs curves with a constant or linearly increasing
36 //! section to be used in the design of wooden or plastic
37 //! battens. These curves are two-dimensional, and
38 //! simulate physical splines or battens.
39 class FairCurve_Batten
46 //! Constructor with the two points and the geometrical
47 //! characteristics of the batten (elastic beam)
48 //! Height is the height of the deformation, and Slope is the
49 //! slope value, initialized at 0. The user can then supply the
50 //! desired slope value by the method, SetSlope.
51 //! Other parameters are initialized as follow :
52 //! - FreeSliding = False
53 //! - ConstraintOrder1 = 1
54 //! - ConstraintOrder2 = 1
57 //! - SlidingFactor = 1
59 //! NegativeValue if Height is less than or equal to 0.
60 //! NullValue if the distance between P1 and P2 is less
61 //! than or equal to the tolerance value for distance in
62 //! Precision::Confusion: P1.IsEqual(P2,
63 //! Precision::Confusion()). The function
64 //! gp_Pnt2d::IsEqual tests to see if this is the case.
65 Standard_EXPORT FairCurve_Batten(const gp_Pnt2d& P1, const gp_Pnt2d& P2, const Standard_Real Height, const Standard_Real Slope = 0);
67 Standard_EXPORT virtual ~FairCurve_Batten();
69 //! Freesliding is initialized with the default setting false.
70 //! When Freesliding is set to true and, as a result, sliding
71 //! is free, the sliding factor is automatically computed to
72 //! satisfy the equilibrium of the batten.
73 void SetFreeSliding (const Standard_Boolean FreeSliding);
75 //! Allows you to change the order of the constraint on the
76 //! first point. ConstraintOrder has the default setting of 1.
77 //! The following settings are available:
78 //! - 0-the curve must pass through a point
79 //! - 1-the curve must pass through a point and have a given tangent
80 //! - 2-the curve must pass through a point, have a given tangent and a given curvature.
81 //! The third setting is only valid for
82 //! FairCurve_MinimalVariation curves.
83 //! These constraints, though geometric, represent the
84 //! mechanical constraints due, for example, to the
85 //! resistance of the material the actual physical batten is made of.
86 void SetConstraintOrder1 (const Standard_Integer ConstraintOrder);
88 //! Allows you to change the order of the constraint on the
89 //! second point. ConstraintOrder is initialized with the default setting of 1.
90 //! The following settings are available:
91 //! - 0-the curve must pass through a point
92 //! - 1-the curve must pass through a point and have a given tangent
93 //! - 2-the curve must pass through a point, have a given
94 //! tangent and a given curvature.
95 //! The third setting is only valid for
96 //! FairCurve_MinimalVariation curves.
97 //! These constraints, though geometric, represent the
98 //! mechanical constraints due, for example, to the
99 //! resistance of the material the actual physical batten is made of.
100 void SetConstraintOrder2 (const Standard_Integer ConstraintOrder);
102 //! Allows you to change the location of the point, P1, and in
103 //! doing so, modify the curve.
105 //! This method changes the angle as well as the point.
107 //! NullValue if the distance between P1 and P2 is less
108 //! than or equal to the tolerance value for distance in
109 //! Precision::Confusion: P1.IsEqual(P2,
110 //! Precision::Confusion()). The function
111 //! gp_Pnt2d::IsEqual tests to see if this is the case.
112 Standard_EXPORT void SetP1 (const gp_Pnt2d& P1);
114 //! Allows you to change the location of the point, P1, and in
115 //! doing so, modify the curve.
117 //! This method changes the angle as well as the point.
119 //! NullValue if the distance between P1 and P2 is less
120 //! than or equal to the tolerance value for distance in
121 //! Precision::Confusion: P1.IsEqual(P2,
122 //! Precision::Confusion()). The function
123 //! gp_Pnt2d::IsEqual tests to see if this is the case.
124 Standard_EXPORT void SetP2 (const gp_Pnt2d& P2);
126 //! Allows you to change the angle Angle1 at the first point,
127 //! P1. The default setting is 0.
128 void SetAngle1 (const Standard_Real Angle1);
130 //! Allows you to change the angle Angle2 at the second
131 //! point, P2. The default setting is 0.
132 void SetAngle2 (const Standard_Real Angle2);
134 //! Allows you to change the height of the deformation.
135 //! Raises NegativeValue; -- if Height <= 0
137 void SetHeight (const Standard_Real Height);
139 //! Allows you to set the slope value, Slope.
140 void SetSlope (const Standard_Real Slope);
142 //! Allows you to change the ratio SlidingFactor. This
143 //! compares the length of the batten and the reference
144 //! length, which is, in turn, a function of the constraints.
145 //! This modification has one of the following two effects:
146 //! - if you increase the value, it inflates the batten
147 //! - if you decrease the value, it flattens the batten.
148 //! When sliding is free, the sliding factor is automatically
149 //! computed to satisfy the equilibrium of the batten. When
150 //! sliding is imposed, a value is required for the sliding factor.
151 //! SlidingFactor is initialized with the default setting of 1.
152 void SetSlidingFactor (const Standard_Real SlidingFactor);
154 //! Performs the algorithm, using the arguments Code,
155 //! NbIterations and Tolerance and computes the curve
156 //! with respect to the constraints.
157 //! Code will have one of the following values:
160 //! - InfiniteSliding
162 //! The parameters Tolerance and NbIterations control
163 //! how precise the computation is, and how long it will take.
164 Standard_EXPORT virtual Standard_Boolean Compute (FairCurve_AnalysisCode& Code, const Standard_Integer NbIterations = 50, const Standard_Real Tolerance = 1.0e-3);
166 //! Computes the real number value for length Sliding of
167 //! Reference for new constraints. If you want to give a
168 //! specific length to a batten curve, use the following
169 //! syntax: b.SetSlidingFactor(L /
170 //! b.SlidingOfReference()) where b is the
171 //! name of the batten curve object.
172 Standard_EXPORT Standard_Real SlidingOfReference() const;
174 //! Returns the initial free sliding value, false by default.
175 //! Free sliding is generally more aesthetically pleasing
176 //! than constrained sliding. However, the computation can
177 //! fail with values such as angles greater than PI/2. This is
178 //! because the resulting batten length is theoretically infinite.
179 Standard_Boolean GetFreeSliding() const;
181 //! Returns the established first constraint order.
182 Standard_Integer GetConstraintOrder1() const;
184 //! Returns the established second constraint order.
185 Standard_Integer GetConstraintOrder2() const;
187 //! Returns the established location of the point P1.
188 const gp_Pnt2d& GetP1() const;
190 //! Returns the established location of the point P2.
191 const gp_Pnt2d& GetP2() const;
193 //! Returns the established first angle.
194 Standard_Real GetAngle1() const;
196 //! Returns the established second angle.
197 Standard_Real GetAngle2() const;
199 //! Returns the thickness of the lathe.
200 Standard_Real GetHeight() const;
202 //! Returns the established slope value.
203 Standard_Real GetSlope() const;
205 //! Returns the initial sliding factor.
206 Standard_Real GetSlidingFactor() const;
208 //! Returns the computed curve a 2d BSpline.
209 Standard_EXPORT Handle(Geom2d_BSplineCurve) Curve() const;
211 //! Prints on the stream o information on the current state
214 //! Private methodes --------------------------------------
215 Standard_EXPORT virtual void Dump (Standard_OStream& o) const;
223 Standard_EXPORT Standard_Real SlidingOfReference (const Standard_Real D, const Standard_Real A1, const Standard_Real A2) const;
225 Standard_EXPORT Standard_Real Compute (const Standard_Real D, const Standard_Real A1, const Standard_Real A2) const;
227 //! Returns the effective geometrical constraints at the
228 //! last batten computation. This effectives values may
229 //! be not equal with the wanted values if
230 //! - if the value is "free"
231 //! - in the case of incomplete computation : collapse,
232 //! infinite sliding, height of batten will be negative at end points
233 Standard_EXPORT Standard_Real Compute (const Standard_Real D, const Standard_Real A) const;
236 FairCurve_AnalysisCode myCode;
239 Standard_Real OldAngle1;
240 Standard_Real OldAngle2;
241 Standard_Real OldHeight;
242 Standard_Real OldSlope;
243 Standard_Real OldSlidingFactor;
244 Standard_Boolean OldFreeSliding;
245 Standard_Integer OldConstraintOrder1;
246 Standard_Integer OldConstraintOrder2;
249 Standard_Real NewAngle1;
250 Standard_Real NewAngle2;
251 Standard_Real NewHeight;
252 Standard_Real NewSlope;
253 Standard_Real NewSlidingFactor;
254 Standard_Boolean NewFreeSliding;
255 Standard_Integer NewConstraintOrder1;
256 Standard_Integer NewConstraintOrder2;
257 Standard_Integer Degree;
258 Handle(TColgp_HArray1OfPnt2d) Poles;
259 Handle(TColStd_HArray1OfReal) Flatknots;
260 Handle(TColStd_HArray1OfReal) Knots;
261 Handle(TColStd_HArray1OfInteger) Mults;
267 //! compute the curve with respect of the delta-constraints.
268 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);
270 Standard_EXPORT void Angles (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
278 #include <FairCurve_Batten.lxx>
284 #endif // _FairCurve_Batten_HeaderFile