42cf5bc1 |
1 | // Created on: 1996-02-26 |
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_MinimalVariation_HeaderFile |
18 | #define _FairCurve_MinimalVariation_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Real.hxx> |
25 | #include <FairCurve_Batten.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <FairCurve_AnalysisCode.hxx> |
28 | #include <Standard_Integer.hxx> |
29 | #include <Standard_OStream.hxx> |
30 | class Standard_NegativeValue; |
31 | class Standard_NullValue; |
32 | class Standard_DomainError; |
33 | class gp_Pnt2d; |
34 | class gp_Vec2d; |
35 | |
36 | |
37 | //! Computes a 2D curve using an algorithm which |
38 | //! minimizes tension, sagging, and jerk energy. As in |
39 | //! FairCurve_Batten, two reference points are used. |
40 | //! Unlike that class, FairCurve_MinimalVariation |
41 | //! requires curvature settings at the first and second |
42 | //! reference points. These are defined by the rays of |
43 | //! curvature desired at each point. |
44 | class FairCurve_MinimalVariation : public FairCurve_Batten |
45 | { |
46 | public: |
47 | |
48 | DEFINE_STANDARD_ALLOC |
49 | |
50 | |
51 | //! Constructs the two contact points P1 and P2 and the geometrical |
52 | //! characteristics of the batten (elastic beam) |
53 | //! These include the real number values for height of |
54 | //! deformation Height, slope value Slope, and kind of |
55 | //! energy PhysicalRatio. The kinds of energy include: |
56 | //! - Jerk (0) |
57 | //! - Sagging (1). |
58 | //! Note that the default setting for Physical Ration is in FairCurve_Batten |
59 | //! Other parameters are initialized as follow : |
60 | //! - FreeSliding = False |
61 | //! - ConstraintOrder1 = 1 |
62 | //! - ConstraintOrder2 = 1 |
63 | //! - Angle1 = 0 |
64 | //! - Angle2 = 0 |
65 | //! - Curvature1 = 0 |
66 | //! - Curvature2 = 0 |
67 | //! - SlidingFactor = 1 |
68 | //! Warning |
69 | //! If PhysicalRatio equals 1, you cannot impose constraints on curvature. |
70 | //! Exceptions |
71 | //! NegativeValue if Height is less than or equal to 0. |
72 | //! NullValue if the distance between P1 and P2 is less |
73 | //! than or equal to the tolerance value for distance in |
74 | //! Precision::Confusion: P1.IsEqual(P2, |
75 | //! Precision::Confusion()). The function |
76 | //! gp_Pnt2d::IsEqual tests to see if this is the case. |
77 | //! Definition of the geometricals constraints |
78 | Standard_EXPORT FairCurve_MinimalVariation(const gp_Pnt2d& P1, const gp_Pnt2d& P2, const Standard_Real Heigth, const Standard_Real Slope = 0, const Standard_Real PhysicalRatio = 0); |
79 | |
80 | //! Allows you to set a new constraint on curvature at the first point. |
81 | void SetCurvature1 (const Standard_Real Curvature); |
82 | |
83 | //! Allows you to set a new constraint on curvature at the second point. |
84 | void SetCurvature2 (const Standard_Real Curvature); |
85 | |
86 | //! Allows you to set the physical ratio Ratio. |
87 | //! The kinds of energy which you can specify include: |
88 | //! 0 is only "Jerk" Energy |
89 | //! 1 is only "Sagging" Energy like batten |
90 | //! Warning: if Ratio is 1 it is impossible to impose curvature constraints. |
91 | //! Raises DomainError if Ratio < 0 or Ratio > 1 |
92 | void SetPhysicalRatio (const Standard_Real Ratio); |
93 | |
94 | //! Computes the curve with respect to the constraints, |
95 | //! NbIterations and Tolerance. The tolerance setting |
96 | //! allows you to control the precision of computation, and |
97 | //! the maximum number of iterations allows you to set a limit on computation time. |
98 | Standard_EXPORT virtual Standard_Boolean Compute (FairCurve_AnalysisCode& ACode, const Standard_Integer NbIterations = 50, const Standard_Real Tolerance = 1.0e-3) Standard_OVERRIDE; |
99 | |
100 | //! Returns the first established curvature. |
101 | Standard_Real GetCurvature1() const; |
102 | |
103 | //! Returns the second established curvature. |
104 | Standard_Real GetCurvature2() const; |
105 | |
106 | //! Returns the physical ratio, or kind of energy. |
107 | Standard_Real GetPhysicalRatio() const; |
108 | |
109 | //! Prints on the stream o information on the current state |
110 | //! of the object. |
111 | //! Is used to redefine the operator <<. |
112 | Standard_EXPORT virtual void Dump (Standard_OStream& o) const Standard_OVERRIDE; |
113 | |
114 | |
115 | |
116 | |
117 | protected: |
118 | |
119 | |
120 | |
121 | |
122 | |
123 | private: |
124 | |
125 | |
126 | //! compute the curve with respect of the delta-constraints. |
127 | Standard_EXPORT Standard_Boolean Compute (const gp_Vec2d& DeltaP1, const gp_Vec2d& DeltaP2, const Standard_Real DeltaAngle1, const Standard_Real DeltaAngle2, const Standard_Real DeltaCurvature1, const Standard_Real DeltaCurvature2, FairCurve_AnalysisCode& ACode, const Standard_Integer NbIterations, const Standard_Real Tolerance); |
128 | |
129 | |
130 | Standard_Real OldCurvature1; |
131 | Standard_Real OldCurvature2; |
132 | Standard_Real OldPhysicalRatio; |
133 | Standard_Real NewCurvature1; |
134 | Standard_Real NewCurvature2; |
135 | Standard_Real NewPhysicalRatio; |
136 | |
137 | |
138 | }; |
139 | |
140 | |
141 | #include <FairCurve_MinimalVariation.lxx> |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | #endif // _FairCurve_MinimalVariation_HeaderFile |