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