b311480e |
1 | // Created on: 2005-10-14 |
2 | // Created by: Mikhail KLOKOV |
973c2be1 |
3 | // Copyright (c) 2005-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
973c2be1 |
7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #include <IntTools_SurfaceRangeLocalizeData.ixx> |
17 | #include <IntTools_ListIteratorOfListOfSurfaceRangeSample.hxx> |
18 | #include <IntTools_ListIteratorOfListOfBox.hxx> |
19 | #include <IntTools_MapIteratorOfMapOfSurfaceSample.hxx> |
20 | #include <Precision.hxx> |
21 | |
22 | IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData() |
23 | { |
24 | myNbSampleU = 1; |
25 | myNbSampleV = 1; |
26 | myMinRangeU = 0.; |
27 | myMinRangeV = 0.; |
28 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
29 | myDeflection = 0.; |
30 | myUIndMin = 0; |
31 | myUIndMax = 0; |
32 | myVIndMin = 0; |
33 | myVIndMax = 0; |
34 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |
35 | } |
36 | |
37 | |
38 | IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const Standard_Integer theNbSampleU, |
39 | const Standard_Integer theNbSampleV, |
40 | const Standard_Real theMinRangeU, |
41 | const Standard_Real theMinRangeV) |
42 | { |
43 | myNbSampleU = theNbSampleU; |
44 | myNbSampleV = theNbSampleV; |
45 | myMinRangeU = theMinRangeU; |
46 | myMinRangeV = theMinRangeV; |
47 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
48 | myDeflection = 0.; |
49 | myUIndMin = 0; |
50 | myUIndMax = 0; |
51 | myVIndMin = 0; |
52 | myVIndMax = 0; |
53 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |
54 | } |
55 | |
56 | IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const IntTools_SurfaceRangeLocalizeData& Other) |
57 | { |
58 | Assign(Other); |
59 | } |
60 | |
61 | IntTools_SurfaceRangeLocalizeData& IntTools_SurfaceRangeLocalizeData::Assign(const IntTools_SurfaceRangeLocalizeData& Other) |
62 | { |
63 | myNbSampleU = Other.myNbSampleU; |
64 | myNbSampleV = Other.myNbSampleV; |
65 | myMinRangeU = Other.myMinRangeU; |
66 | myMinRangeV = Other.myMinRangeV; |
67 | myMapRangeOut.Clear(); |
68 | myMapRangeOut = Other.myMapRangeOut; |
69 | myMapBox.Clear(); |
70 | myMapBox = Other.myMapBox; |
71 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
72 | myDeflection = Other.myDeflection; |
73 | myUIndMin = Other.myUIndMin; |
74 | myUIndMax = Other.myUIndMax; |
75 | myVIndMin = Other.myVIndMin; |
76 | myVIndMax = Other.myVIndMax; |
77 | |
78 | if (!Other.myUParams.IsNull()) |
79 | myUParams = Other.myUParams; |
80 | |
81 | if (!Other.myVParams.IsNull()) |
82 | myVParams = Other.myVParams; |
83 | |
84 | if (!Other.myGridPoints.IsNull()) |
85 | myGridPoints = Other.myGridPoints; |
86 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |
87 | return *(this); |
88 | } |
89 | |
90 | |
91 | void IntTools_SurfaceRangeLocalizeData::AddOutRange(const IntTools_SurfaceRangeSample& theRange) |
92 | { |
93 | myMapRangeOut.Add(theRange); |
94 | // myMapBox.UnBind(theRange); |
95 | } |
96 | |
97 | void IntTools_SurfaceRangeLocalizeData::AddBox(const IntTools_SurfaceRangeSample& theRange, |
98 | const Bnd_Box& theBox) |
99 | { |
100 | myMapBox.Bind(theRange, theBox); |
101 | } |
102 | |
103 | Standard_Boolean IntTools_SurfaceRangeLocalizeData::FindBox(const IntTools_SurfaceRangeSample& theRange, |
104 | Bnd_Box& theBox) const |
105 | { |
106 | if(myMapBox.IsBound(theRange)) { |
107 | theBox = myMapBox(theRange); |
108 | return Standard_True; |
109 | } |
110 | return Standard_False; |
111 | } |
112 | |
113 | Standard_Boolean IntTools_SurfaceRangeLocalizeData::IsRangeOut(const IntTools_SurfaceRangeSample& theRange) const |
114 | { |
115 | return myMapRangeOut.Contains(theRange); |
116 | } |
117 | |
118 | void IntTools_SurfaceRangeLocalizeData::ListRangeOut(IntTools_ListOfSurfaceRangeSample& theList) const |
119 | { |
120 | IntTools_MapIteratorOfMapOfSurfaceSample anIt( myMapRangeOut); |
121 | |
122 | for(; anIt.More(); anIt.Next()) |
123 | theList.Append(anIt.Key()); |
124 | } |
125 | |
126 | void IntTools_SurfaceRangeLocalizeData::RemoveRangeOutAll() |
127 | { |
128 | myMapRangeOut.Clear(); |
129 | } |
130 | |
131 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
132 | void IntTools_SurfaceRangeLocalizeData::SetRangeUGrid |
133 | (const Standard_Integer theNbUGrid) |
134 | { |
135 | myUIndMin = 0; |
136 | myUIndMax = 0; |
137 | myVIndMin = 0; |
138 | myVIndMax = 0; |
139 | |
140 | if (myUParams.IsNull() || theNbUGrid != myUParams->Length()) { |
141 | myUParams = new TColStd_HArray1OfReal(1, theNbUGrid); |
142 | |
143 | if (!myVParams.IsNull()) { |
144 | myGridPoints = new TColgp_HArray2OfPnt(1, theNbUGrid, |
145 | 1, myVParams->Length()); |
146 | } |
147 | } |
148 | } |
149 | |
150 | void IntTools_SurfaceRangeLocalizeData::SetRangeVGrid |
151 | (const Standard_Integer theNbVGrid) |
152 | { |
153 | myUIndMin = 0; |
154 | myUIndMax = 0; |
155 | myVIndMin = 0; |
156 | myVIndMax = 0; |
157 | |
158 | if (myVParams.IsNull() || theNbVGrid != myVParams->Length()) { |
159 | myVParams = new TColStd_HArray1OfReal(1, theNbVGrid); |
160 | |
161 | if (!myUParams.IsNull()) { |
162 | myGridPoints = new TColgp_HArray2OfPnt(1, myUParams->Length(), |
163 | 1, theNbVGrid); |
164 | } |
165 | } |
166 | } |
167 | |
168 | void IntTools_SurfaceRangeLocalizeData::SetFrame(const Standard_Real theUMin, |
169 | const Standard_Real theUMax, |
170 | const Standard_Real theVMin, |
171 | const Standard_Real theVMax) |
172 | { |
173 | myUIndMin = 0; |
174 | myUIndMax = 0; |
175 | myVIndMin = 0; |
176 | myVIndMax = 0; |
177 | |
178 | if (myUParams.IsNull() || myVParams.IsNull()) { |
179 | return; |
180 | } |
181 | |
182 | Standard_Integer i; |
183 | Standard_Integer aLmI; |
184 | Standard_Integer aLen = myUParams->Length(); |
185 | |
186 | // Compute frame along U. |
187 | for (i = 1; i <= aLen; i++) { |
188 | if (myUIndMin == 0 && theUMin < myUParams->Value(i)) |
189 | myUIndMin = i; |
190 | |
191 | aLmI = aLen - i + 1; |
192 | |
193 | if (myUIndMax == 0 && theUMax > myUParams->Value(aLmI)) |
194 | myUIndMax = aLmI; |
195 | } |
196 | |
197 | if (myUIndMin == 0) |
198 | myUIndMin = aLen + 1; |
199 | |
200 | // Compute frame along V. |
201 | aLen = myVParams->Length(); |
202 | |
203 | for (i = 1; i <= aLen; i++) { |
204 | if (myVIndMin == 0 && theVMin < myVParams->Value(i)) |
205 | myVIndMin = i; |
206 | |
207 | aLmI = aLen - i + 1; |
208 | |
209 | if (myVIndMax == 0 && theVMax > myVParams->Value(aLmI)) |
210 | myVIndMax = aLmI; |
211 | } |
212 | |
213 | if (myVIndMin == 0) |
214 | myVIndMin = aLen + 1; |
215 | |
216 | } |
217 | |
218 | const gp_Pnt &IntTools_SurfaceRangeLocalizeData::GetPointInFrame |
219 | (const Standard_Integer theUIndex, |
220 | const Standard_Integer theVIndex) const |
221 | { |
7fd59977 |
222 | Standard_Integer aFrmUInd = theUIndex + myUIndMin - 1; |
223 | Standard_Integer aFrmVInd = theVIndex + myVIndMin - 1; |
224 | |
225 | if (aFrmUInd > myUIndMax || aFrmVInd > myVIndMax) |
1ef32e96 |
226 | return gp::Origin(); |
7fd59977 |
227 | |
228 | return myGridPoints->Value(aFrmUInd, aFrmVInd); |
229 | } |
230 | |
231 | Standard_Real IntTools_SurfaceRangeLocalizeData::GetUParamInFrame |
232 | (const Standard_Integer theIndex) const |
233 | { |
234 | Standard_Integer aFrmInd = theIndex + myUIndMin - 1; |
235 | |
236 | if (aFrmInd > myUIndMax) |
237 | return Precision::Infinite(); |
238 | |
239 | return myUParams->Value(aFrmInd); |
240 | } |
241 | |
242 | Standard_Real IntTools_SurfaceRangeLocalizeData::GetVParamInFrame |
243 | (const Standard_Integer theIndex) const |
244 | { |
245 | Standard_Integer aFrmInd = theIndex + myVIndMin - 1; |
246 | |
247 | if (aFrmInd > myVIndMax) |
248 | return Precision::Infinite(); |
249 | |
250 | return myVParams->Value(aFrmInd); |
251 | } |
252 | |
253 | void IntTools_SurfaceRangeLocalizeData::ClearGrid() |
254 | { |
255 | myDeflection = 0.; |
256 | myUIndMin = 0; |
257 | myUIndMax = 0; |
258 | myVIndMin = 0; |
259 | myVIndMax = 0; |
260 | |
261 | if (!myUParams.IsNull()) |
262 | myUParams.Nullify(); |
263 | |
264 | if (!myVParams.IsNull()) |
265 | myVParams.Nullify(); |
266 | |
267 | if (!myGridPoints.IsNull()) |
268 | myGridPoints.Nullify(); |
269 | } |
270 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |