0027067: Avoid use of virtual methods for implementation of destructors in legacy...
[occt.git] / src / FairCurve / FairCurve_Batten.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _FairCurve_Batten_HeaderFile
18#define _FairCurve_Batten_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <FairCurve_AnalysisCode.hxx>
25#include <gp_Pnt2d.hxx>
26#include <Standard_Real.hxx>
27#include <Standard_Boolean.hxx>
28#include <Standard_Integer.hxx>
29#include <TColgp_HArray1OfPnt2d.hxx>
30#include <TColStd_HArray1OfReal.hxx>
31#include <TColStd_HArray1OfInteger.hxx>
32#include <Standard_OStream.hxx>
33class Standard_NegativeValue;
34class Standard_NullValue;
35class gp_Pnt2d;
36class gp_Vec2d;
37class Geom2d_BSplineCurve;
38
39
40//! Constructs curves with a constant or linearly increasing
41//! section to be used in the design of wooden or plastic
42//! battens. These curves are two-dimensional, and
43//! simulate physical splines or battens.
44class FairCurve_Batten
45{
46public:
47
48 DEFINE_STANDARD_ALLOC
49
50
51 //! Constructor with the two points and the geometrical
52 //! characteristics of the batten (elastic beam)
53 //! Height is the height of the deformation, and Slope is the
54 //! slope value, initialized at 0. The user can then supply the
55 //! desired slope value by the method, SetSlope.
56 //! Other parameters are initialized as follow :
57 //! - FreeSliding = False
58 //! - ConstraintOrder1 = 1
59 //! - ConstraintOrder2 = 1
60 //! - Angle1 = 0
61 //! - Angle2 = 0
62 //! - SlidingFactor = 1
63 //! Exceptions
64 //! NegativeValue if Height is less than or equal to 0.
65 //! NullValue if the distance between P1 and P2 is less
66 //! than or equal to the tolerance value for distance in
67 //! Precision::Confusion: P1.IsEqual(P2,
68 //! Precision::Confusion()). The function
69 //! gp_Pnt2d::IsEqual tests to see if this is the case.
70 Standard_EXPORT FairCurve_Batten(const gp_Pnt2d& P1, const gp_Pnt2d& P2, const Standard_Real Height, const Standard_Real Slope = 0);
71
e6f550da 72 Standard_EXPORT virtual ~FairCurve_Batten();
42cf5bc1 73
74 //! Freesliding is initialized with the default setting false.
75 //! When Freesliding is set to true and, as a result, sliding
76 //! is free, the sliding factor is automatically computed to
77 //! satisfy the equilibrium of the batten.
78 void SetFreeSliding (const Standard_Boolean FreeSliding);
79
80 //! Allows you to change the order of the constraint on the
81 //! first point. ConstraintOrder has the default setting of 1.
82 //! The following settings are available:
83 //! - 0-the curve must pass through a point
84 //! - 1-the curve must pass through a point and have a given tangent
85 //! - 2-the curve must pass through a point, have a given tangent and a given curvature.
86 //! The third setting is only valid for
87 //! FairCurve_MinimalVariation curves.
88 //! These constraints, though geometric, represent the
89 //! mechanical constraints due, for example, to the
90 //! resistance of the material the actual physical batten is made of.
91 void SetConstraintOrder1 (const Standard_Integer ConstraintOrder);
92
93 //! Allows you to change the order of the constraint on the
94 //! second point. ConstraintOrder is initialized with the default setting of 1.
95 //! The following settings are available:
96 //! - 0-the curve must pass through a point
97 //! - 1-the curve must pass through a point and have a given tangent
98 //! - 2-the curve must pass through a point, have a given
99 //! tangent and a given curvature.
100 //! The third setting is only valid for
101 //! FairCurve_MinimalVariation curves.
102 //! These constraints, though geometric, represent the
103 //! mechanical constraints due, for example, to the
104 //! resistance of the material the actual physical batten is made of.
105 void SetConstraintOrder2 (const Standard_Integer ConstraintOrder);
106
107 //! Allows you to change the location of the point, P1, and in
108 //! doing so, modify the curve.
109 //! Warning
110 //! This method changes the angle as well as the point.
111 //! Exceptions
112 //! NullValue if the distance between P1 and P2 is less
113 //! than or equal to the tolerance value for distance in
114 //! Precision::Confusion: P1.IsEqual(P2,
115 //! Precision::Confusion()). The function
116 //! gp_Pnt2d::IsEqual tests to see if this is the case.
117 Standard_EXPORT void SetP1 (const gp_Pnt2d& P1);
118
119 //! Allows you to change the location of the point, P1, and in
120 //! doing so, modify the curve.
121 //! Warning
122 //! This method changes the angle as well as the point.
123 //! Exceptions
124 //! NullValue if the distance between P1 and P2 is less
125 //! than or equal to the tolerance value for distance in
126 //! Precision::Confusion: P1.IsEqual(P2,
127 //! Precision::Confusion()). The function
128 //! gp_Pnt2d::IsEqual tests to see if this is the case.
129 Standard_EXPORT void SetP2 (const gp_Pnt2d& P2);
130
131 //! Allows you to change the angle Angle1 at the first point,
132 //! P1. The default setting is 0.
133 void SetAngle1 (const Standard_Real Angle1);
134
135 //! Allows you to change the angle Angle2 at the second
136 //! point, P2. The default setting is 0.
137 void SetAngle2 (const Standard_Real Angle2);
138
139 //! Allows you to change the height of the deformation.
140 //! Raises NegativeValue; -- if Height <= 0
141 //! if Height <= 0
142 void SetHeight (const Standard_Real Height);
143
144 //! Allows you to set the slope value, Slope.
145 void SetSlope (const Standard_Real Slope);
146
147 //! Allows you to change the ratio SlidingFactor. This
148 //! compares the length of the batten and the reference
149 //! length, which is, in turn, a function of the constraints.
150 //! This modification has one of the following two effects:
151 //! - if you increase the value, it inflates the batten
152 //! - if you decrease the value, it flattens the batten.
153 //! When sliding is free, the sliding factor is automatically
154 //! computed to satisfy the equilibrium of the batten. When
155 //! sliding is imposed, a value is required for the sliding factor.
156 //! SlidingFactor is initialized with the default setting of 1.
157 void SetSlidingFactor (const Standard_Real SlidingFactor);
158
159 //! Performs the algorithm, using the arguments Code,
160 //! NbIterations and Tolerance and computes the curve
161 //! with respect to the constraints.
162 //! Code will have one of the following values:
163 //! - OK
164 //! - NotConverged
165 //! - InfiniteSliding
166 //! - NullHeight
167 //! The parameters Tolerance and NbIterations control
168 //! how precise the computation is, and how long it will take.
169 Standard_EXPORT virtual Standard_Boolean Compute (FairCurve_AnalysisCode& Code, const Standard_Integer NbIterations = 50, const Standard_Real Tolerance = 1.0e-3);
170
171 //! Computes the real number value for length Sliding of
172 //! Reference for new constraints. If you want to give a
173 //! specific length to a batten curve, use the following
174 //! syntax: b.SetSlidingFactor(L /
175 //! b.SlidingOfReference()) where b is the
176 //! name of the batten curve object.
177 Standard_EXPORT Standard_Real SlidingOfReference() const;
178
179 //! Returns the initial free sliding value, false by default.
180 //! Free sliding is generally more aesthetically pleasing
181 //! than constrained sliding. However, the computation can
182 //! fail with values such as angles greater than PI/2. This is
183 //! because the resulting batten length is theoretically infinite.
184 Standard_Boolean GetFreeSliding() const;
185
186 //! Returns the established first constraint order.
187 Standard_Integer GetConstraintOrder1() const;
188
189 //! Returns the established second constraint order.
190 Standard_Integer GetConstraintOrder2() const;
191
192 //! Returns the established location of the point P1.
193 const gp_Pnt2d& GetP1() const;
194
195 //! Returns the established location of the point P2.
196 const gp_Pnt2d& GetP2() const;
197
198 //! Returns the established first angle.
199 Standard_Real GetAngle1() const;
200
201 //! Returns the established second angle.
202 Standard_Real GetAngle2() const;
203
204 //! Returns the thickness of the lathe.
205 Standard_Real GetHeight() const;
206
207 //! Returns the established slope value.
208 Standard_Real GetSlope() const;
209
210 //! Returns the initial sliding factor.
211 Standard_Real GetSlidingFactor() const;
212
213 //! Returns the computed curve a 2d BSpline.
214 Standard_EXPORT Handle(Geom2d_BSplineCurve) Curve() const;
215
216 //! Prints on the stream o information on the current state
217 //! of the object.
218 //!
219 //! Private methodes --------------------------------------
220 Standard_EXPORT virtual void Dump (Standard_OStream& o) const;
221
222
223
224
225protected:
226
227
228 Standard_EXPORT Standard_Real SlidingOfReference (const Standard_Real D, const Standard_Real A1, const Standard_Real A2) const;
229
230 Standard_EXPORT Standard_Real Compute (const Standard_Real D, const Standard_Real A1, const Standard_Real A2) const;
231
232 //! Returns the effective geometrical constraints at the
233 //! last batten computation. This effectives values may
234 //! be not equal with the wanted values if
235 //! - if the value is "free"
236 //! - in the case of incomplete computation : collapse,
237 //! infinite sliding, height of batten will be negative at end points
238 Standard_EXPORT Standard_Real Compute (const Standard_Real D, const Standard_Real A) const;
239
240
241 FairCurve_AnalysisCode myCode;
242 gp_Pnt2d OldP1;
243 gp_Pnt2d OldP2;
244 Standard_Real OldAngle1;
245 Standard_Real OldAngle2;
246 Standard_Real OldHeight;
247 Standard_Real OldSlope;
248 Standard_Real OldSlidingFactor;
249 Standard_Boolean OldFreeSliding;
250 Standard_Integer OldConstraintOrder1;
251 Standard_Integer OldConstraintOrder2;
252 gp_Pnt2d NewP1;
253 gp_Pnt2d NewP2;
254 Standard_Real NewAngle1;
255 Standard_Real NewAngle2;
256 Standard_Real NewHeight;
257 Standard_Real NewSlope;
258 Standard_Real NewSlidingFactor;
259 Standard_Boolean NewFreeSliding;
260 Standard_Integer NewConstraintOrder1;
261 Standard_Integer NewConstraintOrder2;
262 Standard_Integer Degree;
263 Handle(TColgp_HArray1OfPnt2d) Poles;
264 Handle(TColStd_HArray1OfReal) Flatknots;
265 Handle(TColStd_HArray1OfReal) Knots;
266 Handle(TColStd_HArray1OfInteger) Mults;
267
268
269private:
270
271
272 //! compute the curve with respect of the delta-constraints.
273 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);
274
275 Standard_EXPORT void Angles (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
276
277
278
279
280};
281
282
283#include <FairCurve_Batten.lxx>
284
285
286
287
288
289#endif // _FairCurve_Batten_HeaderFile