b311480e |
1 | // Created on: 2005-10-14 |
2 | // Created by: Mikhail KLOKOV |
3 | // Copyright (c) 2005-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | |
22 | #include <IntTools_SurfaceRangeLocalizeData.ixx> |
23 | #include <IntTools_ListIteratorOfListOfSurfaceRangeSample.hxx> |
24 | #include <IntTools_ListIteratorOfListOfBox.hxx> |
25 | #include <IntTools_MapIteratorOfMapOfSurfaceSample.hxx> |
26 | #include <Precision.hxx> |
27 | |
28 | IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData() |
29 | { |
30 | myNbSampleU = 1; |
31 | myNbSampleV = 1; |
32 | myMinRangeU = 0.; |
33 | myMinRangeV = 0.; |
34 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
35 | myDeflection = 0.; |
36 | myUIndMin = 0; |
37 | myUIndMax = 0; |
38 | myVIndMin = 0; |
39 | myVIndMax = 0; |
40 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |
41 | } |
42 | |
43 | |
44 | IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const Standard_Integer theNbSampleU, |
45 | const Standard_Integer theNbSampleV, |
46 | const Standard_Real theMinRangeU, |
47 | const Standard_Real theMinRangeV) |
48 | { |
49 | myNbSampleU = theNbSampleU; |
50 | myNbSampleV = theNbSampleV; |
51 | myMinRangeU = theMinRangeU; |
52 | myMinRangeV = theMinRangeV; |
53 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
54 | myDeflection = 0.; |
55 | myUIndMin = 0; |
56 | myUIndMax = 0; |
57 | myVIndMin = 0; |
58 | myVIndMax = 0; |
59 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |
60 | } |
61 | |
62 | IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const IntTools_SurfaceRangeLocalizeData& Other) |
63 | { |
64 | Assign(Other); |
65 | } |
66 | |
67 | IntTools_SurfaceRangeLocalizeData& IntTools_SurfaceRangeLocalizeData::Assign(const IntTools_SurfaceRangeLocalizeData& Other) |
68 | { |
69 | myNbSampleU = Other.myNbSampleU; |
70 | myNbSampleV = Other.myNbSampleV; |
71 | myMinRangeU = Other.myMinRangeU; |
72 | myMinRangeV = Other.myMinRangeV; |
73 | myMapRangeOut.Clear(); |
74 | myMapRangeOut = Other.myMapRangeOut; |
75 | myMapBox.Clear(); |
76 | myMapBox = Other.myMapBox; |
77 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
78 | myDeflection = Other.myDeflection; |
79 | myUIndMin = Other.myUIndMin; |
80 | myUIndMax = Other.myUIndMax; |
81 | myVIndMin = Other.myVIndMin; |
82 | myVIndMax = Other.myVIndMax; |
83 | |
84 | if (!Other.myUParams.IsNull()) |
85 | myUParams = Other.myUParams; |
86 | |
87 | if (!Other.myVParams.IsNull()) |
88 | myVParams = Other.myVParams; |
89 | |
90 | if (!Other.myGridPoints.IsNull()) |
91 | myGridPoints = Other.myGridPoints; |
92 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |
93 | return *(this); |
94 | } |
95 | |
96 | |
97 | void IntTools_SurfaceRangeLocalizeData::AddOutRange(const IntTools_SurfaceRangeSample& theRange) |
98 | { |
99 | myMapRangeOut.Add(theRange); |
100 | // myMapBox.UnBind(theRange); |
101 | } |
102 | |
103 | void IntTools_SurfaceRangeLocalizeData::AddBox(const IntTools_SurfaceRangeSample& theRange, |
104 | const Bnd_Box& theBox) |
105 | { |
106 | myMapBox.Bind(theRange, theBox); |
107 | } |
108 | |
109 | Standard_Boolean IntTools_SurfaceRangeLocalizeData::FindBox(const IntTools_SurfaceRangeSample& theRange, |
110 | Bnd_Box& theBox) const |
111 | { |
112 | if(myMapBox.IsBound(theRange)) { |
113 | theBox = myMapBox(theRange); |
114 | return Standard_True; |
115 | } |
116 | return Standard_False; |
117 | } |
118 | |
119 | Standard_Boolean IntTools_SurfaceRangeLocalizeData::IsRangeOut(const IntTools_SurfaceRangeSample& theRange) const |
120 | { |
121 | return myMapRangeOut.Contains(theRange); |
122 | } |
123 | |
124 | void IntTools_SurfaceRangeLocalizeData::ListRangeOut(IntTools_ListOfSurfaceRangeSample& theList) const |
125 | { |
126 | IntTools_MapIteratorOfMapOfSurfaceSample anIt( myMapRangeOut); |
127 | |
128 | for(; anIt.More(); anIt.Next()) |
129 | theList.Append(anIt.Key()); |
130 | } |
131 | |
132 | void IntTools_SurfaceRangeLocalizeData::RemoveRangeOutAll() |
133 | { |
134 | myMapRangeOut.Clear(); |
135 | } |
136 | |
137 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin |
138 | void IntTools_SurfaceRangeLocalizeData::SetRangeUGrid |
139 | (const Standard_Integer theNbUGrid) |
140 | { |
141 | myUIndMin = 0; |
142 | myUIndMax = 0; |
143 | myVIndMin = 0; |
144 | myVIndMax = 0; |
145 | |
146 | if (myUParams.IsNull() || theNbUGrid != myUParams->Length()) { |
147 | myUParams = new TColStd_HArray1OfReal(1, theNbUGrid); |
148 | |
149 | if (!myVParams.IsNull()) { |
150 | myGridPoints = new TColgp_HArray2OfPnt(1, theNbUGrid, |
151 | 1, myVParams->Length()); |
152 | } |
153 | } |
154 | } |
155 | |
156 | void IntTools_SurfaceRangeLocalizeData::SetRangeVGrid |
157 | (const Standard_Integer theNbVGrid) |
158 | { |
159 | myUIndMin = 0; |
160 | myUIndMax = 0; |
161 | myVIndMin = 0; |
162 | myVIndMax = 0; |
163 | |
164 | if (myVParams.IsNull() || theNbVGrid != myVParams->Length()) { |
165 | myVParams = new TColStd_HArray1OfReal(1, theNbVGrid); |
166 | |
167 | if (!myUParams.IsNull()) { |
168 | myGridPoints = new TColgp_HArray2OfPnt(1, myUParams->Length(), |
169 | 1, theNbVGrid); |
170 | } |
171 | } |
172 | } |
173 | |
174 | void IntTools_SurfaceRangeLocalizeData::SetFrame(const Standard_Real theUMin, |
175 | const Standard_Real theUMax, |
176 | const Standard_Real theVMin, |
177 | const Standard_Real theVMax) |
178 | { |
179 | myUIndMin = 0; |
180 | myUIndMax = 0; |
181 | myVIndMin = 0; |
182 | myVIndMax = 0; |
183 | |
184 | if (myUParams.IsNull() || myVParams.IsNull()) { |
185 | return; |
186 | } |
187 | |
188 | Standard_Integer i; |
189 | Standard_Integer aLmI; |
190 | Standard_Integer aLen = myUParams->Length(); |
191 | |
192 | // Compute frame along U. |
193 | for (i = 1; i <= aLen; i++) { |
194 | if (myUIndMin == 0 && theUMin < myUParams->Value(i)) |
195 | myUIndMin = i; |
196 | |
197 | aLmI = aLen - i + 1; |
198 | |
199 | if (myUIndMax == 0 && theUMax > myUParams->Value(aLmI)) |
200 | myUIndMax = aLmI; |
201 | } |
202 | |
203 | if (myUIndMin == 0) |
204 | myUIndMin = aLen + 1; |
205 | |
206 | // Compute frame along V. |
207 | aLen = myVParams->Length(); |
208 | |
209 | for (i = 1; i <= aLen; i++) { |
210 | if (myVIndMin == 0 && theVMin < myVParams->Value(i)) |
211 | myVIndMin = i; |
212 | |
213 | aLmI = aLen - i + 1; |
214 | |
215 | if (myVIndMax == 0 && theVMax > myVParams->Value(aLmI)) |
216 | myVIndMax = aLmI; |
217 | } |
218 | |
219 | if (myVIndMin == 0) |
220 | myVIndMin = aLen + 1; |
221 | |
222 | } |
223 | |
224 | const gp_Pnt &IntTools_SurfaceRangeLocalizeData::GetPointInFrame |
225 | (const Standard_Integer theUIndex, |
226 | const Standard_Integer theVIndex) const |
227 | { |
228 | static gp_Pnt aNullPnt(0., 0., 0.); |
229 | |
230 | Standard_Integer aFrmUInd = theUIndex + myUIndMin - 1; |
231 | Standard_Integer aFrmVInd = theVIndex + myVIndMin - 1; |
232 | |
233 | if (aFrmUInd > myUIndMax || aFrmVInd > myVIndMax) |
234 | return aNullPnt; |
235 | |
236 | return myGridPoints->Value(aFrmUInd, aFrmVInd); |
237 | } |
238 | |
239 | Standard_Real IntTools_SurfaceRangeLocalizeData::GetUParamInFrame |
240 | (const Standard_Integer theIndex) const |
241 | { |
242 | Standard_Integer aFrmInd = theIndex + myUIndMin - 1; |
243 | |
244 | if (aFrmInd > myUIndMax) |
245 | return Precision::Infinite(); |
246 | |
247 | return myUParams->Value(aFrmInd); |
248 | } |
249 | |
250 | Standard_Real IntTools_SurfaceRangeLocalizeData::GetVParamInFrame |
251 | (const Standard_Integer theIndex) const |
252 | { |
253 | Standard_Integer aFrmInd = theIndex + myVIndMin - 1; |
254 | |
255 | if (aFrmInd > myVIndMax) |
256 | return Precision::Infinite(); |
257 | |
258 | return myVParams->Value(aFrmInd); |
259 | } |
260 | |
261 | void IntTools_SurfaceRangeLocalizeData::ClearGrid() |
262 | { |
263 | myDeflection = 0.; |
264 | myUIndMin = 0; |
265 | myUIndMax = 0; |
266 | myVIndMin = 0; |
267 | myVIndMax = 0; |
268 | |
269 | if (!myUParams.IsNull()) |
270 | myUParams.Nullify(); |
271 | |
272 | if (!myVParams.IsNull()) |
273 | myVParams.Nullify(); |
274 | |
275 | if (!myGridPoints.IsNull()) |
276 | myGridPoints.Nullify(); |
277 | } |
278 | // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End |