summaryrefslogtreecommitdiff
path: root/src/IntTools/IntTools_SurfaceRangeLocalizeData.cxx
blob: 87d8e83d2e45ccc769552d81a3348935b8717428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// File:	IntTools_SurfaceRangeLocalizeData.cxx
// Created:	Fri Oct 14 19:53:14 2005
// Author:	Mikhail KLOKOV
//		<mkk@kurox>


#include <IntTools_SurfaceRangeLocalizeData.ixx>
#include <IntTools_ListIteratorOfListOfSurfaceRangeSample.hxx>
#include <IntTools_ListIteratorOfListOfBox.hxx>
#include <IntTools_MapIteratorOfMapOfSurfaceSample.hxx>
#include <Precision.hxx>

IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData()
{
  myNbSampleU = 1;
  myNbSampleV = 1;
  myMinRangeU = 0.;
  myMinRangeV = 0.;
//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization Begin
  myDeflection = 0.;
  myUIndMin    = 0;
  myUIndMax    = 0;
  myVIndMin    = 0;
  myVIndMax    = 0;
//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization End
}


IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const Standard_Integer theNbSampleU,
								     const Standard_Integer theNbSampleV,
								     const Standard_Real theMinRangeU,
								     const Standard_Real theMinRangeV)
{
  myNbSampleU = theNbSampleU;
  myNbSampleV = theNbSampleV;
  myMinRangeU = theMinRangeU;
  myMinRangeV = theMinRangeV;
//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization Begin
  myDeflection = 0.;
  myUIndMin    = 0;
  myUIndMax    = 0;
  myVIndMin    = 0;
  myVIndMax    = 0;
//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization End
}

IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const IntTools_SurfaceRangeLocalizeData& Other)
{
  Assign(Other);
}

IntTools_SurfaceRangeLocalizeData& IntTools_SurfaceRangeLocalizeData::Assign(const IntTools_SurfaceRangeLocalizeData& Other) 
{
  myNbSampleU = Other.myNbSampleU;
  myNbSampleV = Other.myNbSampleV;
  myMinRangeU = Other.myMinRangeU;
  myMinRangeV = Other.myMinRangeV;
  myMapRangeOut.Clear();
  myMapRangeOut = Other.myMapRangeOut;
  myMapBox.Clear();
  myMapBox   =  Other.myMapBox;
//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization Begin
  myDeflection = Other.myDeflection;
  myUIndMin    = Other.myUIndMin;
  myUIndMax    = Other.myUIndMax;
  myVIndMin    = Other.myVIndMin;
  myVIndMax    = Other.myVIndMax;

  if (!Other.myUParams.IsNull())
    myUParams = Other.myUParams;

  if (!Other.myVParams.IsNull())
    myVParams = Other.myVParams;

  if (!Other.myGridPoints.IsNull())
    myGridPoints = Other.myGridPoints;
//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization End
  return *(this);
}


void IntTools_SurfaceRangeLocalizeData::AddOutRange(const IntTools_SurfaceRangeSample& theRange) 
{
  myMapRangeOut.Add(theRange);
//   myMapBox.UnBind(theRange);
}

void IntTools_SurfaceRangeLocalizeData::AddBox(const IntTools_SurfaceRangeSample& theRange,
					       const Bnd_Box& theBox) 
{
  myMapBox.Bind(theRange, theBox);
}

Standard_Boolean IntTools_SurfaceRangeLocalizeData::FindBox(const IntTools_SurfaceRangeSample& theRange,
							    Bnd_Box& theBox) const
{
  if(myMapBox.IsBound(theRange)) {
    theBox = myMapBox(theRange);
    return Standard_True;
  }
  return Standard_False;
}

Standard_Boolean IntTools_SurfaceRangeLocalizeData::IsRangeOut(const IntTools_SurfaceRangeSample& theRange) const
{
  return myMapRangeOut.Contains(theRange);
}

void IntTools_SurfaceRangeLocalizeData::ListRangeOut(IntTools_ListOfSurfaceRangeSample& theList) const
{
  IntTools_MapIteratorOfMapOfSurfaceSample anIt( myMapRangeOut);

  for(; anIt.More(); anIt.Next())
    theList.Append(anIt.Key());
}

void IntTools_SurfaceRangeLocalizeData::RemoveRangeOutAll() 
{
  myMapRangeOut.Clear();
}

//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization Begin
void IntTools_SurfaceRangeLocalizeData::SetRangeUGrid
                            (const Standard_Integer theNbUGrid)
{
  myUIndMin   = 0;
  myUIndMax   = 0;
  myVIndMin   = 0;
  myVIndMax   = 0;

  if (myUParams.IsNull() || theNbUGrid != myUParams->Length()) {
    myUParams = new TColStd_HArray1OfReal(1, theNbUGrid);

    if (!myVParams.IsNull()) {
      myGridPoints = new TColgp_HArray2OfPnt(1, theNbUGrid,
					     1, myVParams->Length());
    }
  }
}

void IntTools_SurfaceRangeLocalizeData::SetRangeVGrid
                            (const Standard_Integer theNbVGrid)
{
  myUIndMin   = 0;
  myUIndMax   = 0;
  myVIndMin   = 0;
  myVIndMax   = 0;

  if (myVParams.IsNull() || theNbVGrid != myVParams->Length()) {
    myVParams = new TColStd_HArray1OfReal(1, theNbVGrid);

    if (!myUParams.IsNull()) {
      myGridPoints = new TColgp_HArray2OfPnt(1, myUParams->Length(),
					    1, theNbVGrid);
    }
  }
}

void IntTools_SurfaceRangeLocalizeData::SetFrame(const Standard_Real theUMin,
						 const Standard_Real theUMax,
						 const Standard_Real theVMin,
						 const Standard_Real theVMax)
{
  myUIndMin   = 0;
  myUIndMax   = 0;
  myVIndMin   = 0;
  myVIndMax   = 0;

  if (myUParams.IsNull() || myVParams.IsNull()) {
    return;
  }

  Standard_Integer i;
  Standard_Integer aLmI;
  Standard_Integer aLen = myUParams->Length();

  // Compute frame along U.
  for (i = 1; i <= aLen; i++) {
    if (myUIndMin == 0 && theUMin < myUParams->Value(i))
      myUIndMin = i;

    aLmI = aLen - i + 1;

    if (myUIndMax == 0 && theUMax > myUParams->Value(aLmI))
      myUIndMax = aLmI;
  }

  if (myUIndMin == 0)
    myUIndMin = aLen + 1;

  // Compute frame along V.
  aLen = myVParams->Length();

  for (i = 1; i <= aLen; i++) {
    if (myVIndMin == 0 && theVMin < myVParams->Value(i))
      myVIndMin = i;

    aLmI = aLen - i + 1;

    if (myVIndMax == 0 && theVMax > myVParams->Value(aLmI))
      myVIndMax = aLmI;
  }

  if (myVIndMin == 0)
    myVIndMin = aLen + 1;

}

const gp_Pnt &IntTools_SurfaceRangeLocalizeData::GetPointInFrame
                       (const Standard_Integer theUIndex,
			const Standard_Integer theVIndex) const
{
  static gp_Pnt aNullPnt(0., 0., 0.);

  Standard_Integer aFrmUInd = theUIndex + myUIndMin - 1;
  Standard_Integer aFrmVInd = theVIndex + myVIndMin - 1;

  if (aFrmUInd > myUIndMax || aFrmVInd > myVIndMax)
    return aNullPnt;

  return myGridPoints->Value(aFrmUInd, aFrmVInd);
}

Standard_Real IntTools_SurfaceRangeLocalizeData::GetUParamInFrame
                       (const Standard_Integer theIndex) const
{
  Standard_Integer aFrmInd = theIndex + myUIndMin - 1;

  if (aFrmInd > myUIndMax)
    return Precision::Infinite();

  return myUParams->Value(aFrmInd);
}

Standard_Real IntTools_SurfaceRangeLocalizeData::GetVParamInFrame
                       (const Standard_Integer theIndex) const
{
  Standard_Integer aFrmInd = theIndex + myVIndMin - 1;

  if (aFrmInd > myVIndMax)
    return Precision::Infinite();

  return myVParams->Value(aFrmInd);
}

void IntTools_SurfaceRangeLocalizeData::ClearGrid()
{
  myDeflection = 0.;
  myUIndMin    = 0;
  myUIndMax    = 0;
  myVIndMin    = 0;
  myVIndMax    = 0;

  if (!myUParams.IsNull())
    myUParams.Nullify();

  if (!myVParams.IsNull())
    myVParams.Nullify();

  if (!myGridPoints.IsNull())
    myGridPoints.Nullify();
}
//  Modified by skv - Thu Nov  3 11:58:24 2005 Optimization End