b311480e |
1 | // Created on: 1994-09-05 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <ElCLib.hxx> |
42cf5bc1 |
19 | #include <LProp_CurAndInf.hxx> |
20 | #include <Standard_OutOfRange.hxx> |
7fd59977 |
21 | |
22 | //======================================================================= |
23 | //function : LProp_CurAndInf |
24 | //purpose : |
25 | //======================================================================= |
7fd59977 |
26 | LProp_CurAndInf::LProp_CurAndInf() |
27 | { |
28 | } |
29 | |
30 | |
31 | //======================================================================= |
32 | //function : AddInflection |
33 | //purpose : |
34 | //======================================================================= |
35 | |
36 | void LProp_CurAndInf::AddInflection(const Standard_Real Param) |
37 | { |
38 | if (theParams.IsEmpty()) { |
39 | theParams.Append(Param); |
40 | theTypes .Append(LProp_Inflection); |
41 | return; |
42 | } |
43 | if (Param > theParams.Last()) { |
44 | theParams.Append(Param); |
45 | theTypes .Append(LProp_Inflection); |
46 | return; |
47 | } |
48 | for (Standard_Integer i = 1; i <= theParams.Length(); i++) { |
49 | if (theParams.Value(i) > Param) { |
50 | theParams.InsertBefore(i, Param); |
51 | theTypes .InsertBefore(i, LProp_Inflection); |
52 | break; |
53 | } |
54 | } |
55 | } |
56 | |
57 | |
58 | //======================================================================= |
59 | //function : AddExtCur |
60 | //purpose : |
61 | //======================================================================= |
62 | |
63 | void LProp_CurAndInf::AddExtCur(const Standard_Real Param, |
64 | const Standard_Boolean IsMin) |
65 | { |
66 | LProp_CIType TypePoint; |
67 | if (IsMin ) TypePoint = LProp_MinCur; else TypePoint = LProp_MaxCur; |
68 | |
69 | if (theParams.IsEmpty()) { |
70 | theParams.Append(Param); |
71 | theTypes .Append(TypePoint); |
72 | return; |
73 | } |
74 | if (Param > theParams.Last()) { |
75 | theParams.Append(Param); |
76 | theTypes .Append(TypePoint); |
77 | return; |
78 | } |
79 | for (Standard_Integer i = 1; i <= theParams.Length(); i++) { |
80 | if (theParams.Value(i) > Param) { |
81 | theParams.InsertBefore(i, Param); |
82 | theTypes .InsertBefore(i, TypePoint); |
83 | break; |
84 | } |
85 | } |
86 | } |
87 | |
88 | //======================================================================= |
89 | //function : Clear |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | void LProp_CurAndInf::Clear() |
94 | { |
95 | theParams.Clear(); |
96 | theTypes .Clear(); |
97 | } |
98 | |
99 | |
100 | //======================================================================= |
101 | //function : IsEmpty |
102 | //purpose : |
103 | //======================================================================= |
104 | |
105 | Standard_Boolean LProp_CurAndInf::IsEmpty() const |
106 | { |
107 | return theParams.IsEmpty(); |
108 | } |
109 | |
110 | |
111 | //======================================================================= |
112 | //function : NbPoints |
113 | //purpose : |
114 | //======================================================================= |
115 | |
116 | Standard_Integer LProp_CurAndInf::NbPoints() const |
117 | { |
118 | return theParams.Length(); |
119 | } |
120 | |
121 | |
122 | //======================================================================= |
123 | //function : Parameter |
124 | //purpose : |
125 | //======================================================================= |
126 | |
127 | Standard_Real LProp_CurAndInf::Parameter(const Standard_Integer N) const |
128 | { |
9775fa61 |
129 | if (N <1 || N > NbPoints ()) {throw Standard_OutOfRange();} |
7fd59977 |
130 | return theParams.Value(N); |
131 | } |
132 | |
133 | |
134 | //======================================================================= |
135 | //function : Type |
136 | //purpose : |
137 | //======================================================================= |
138 | |
139 | LProp_CIType LProp_CurAndInf::Type(const Standard_Integer N) const |
140 | { |
9775fa61 |
141 | if (N <1 || N > NbPoints()) {throw Standard_OutOfRange();} |
7fd59977 |
142 | return theTypes.Value(N); |
143 | } |
144 | |
145 | |
146 | |