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