1 // Created on: 2005-10-14
2 // Created by: Mikhail KLOKOV
3 // Copyright (c) 2005-2012 OPEN CASCADE SAS
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.
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.
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.
22 #include <IntTools_SurfaceRangeLocalizeData.ixx>
23 #include <IntTools_ListIteratorOfListOfSurfaceRangeSample.hxx>
24 #include <IntTools_ListIteratorOfListOfBox.hxx>
25 #include <IntTools_MapIteratorOfMapOfSurfaceSample.hxx>
26 #include <Precision.hxx>
28 IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData()
34 // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin
40 // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End
44 IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const Standard_Integer theNbSampleU,
45 const Standard_Integer theNbSampleV,
46 const Standard_Real theMinRangeU,
47 const Standard_Real theMinRangeV)
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
59 // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End
62 IntTools_SurfaceRangeLocalizeData::IntTools_SurfaceRangeLocalizeData(const IntTools_SurfaceRangeLocalizeData& Other)
67 IntTools_SurfaceRangeLocalizeData& IntTools_SurfaceRangeLocalizeData::Assign(const IntTools_SurfaceRangeLocalizeData& Other)
69 myNbSampleU = Other.myNbSampleU;
70 myNbSampleV = Other.myNbSampleV;
71 myMinRangeU = Other.myMinRangeU;
72 myMinRangeV = Other.myMinRangeV;
73 myMapRangeOut.Clear();
74 myMapRangeOut = Other.myMapRangeOut;
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;
84 if (!Other.myUParams.IsNull())
85 myUParams = Other.myUParams;
87 if (!Other.myVParams.IsNull())
88 myVParams = Other.myVParams;
90 if (!Other.myGridPoints.IsNull())
91 myGridPoints = Other.myGridPoints;
92 // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End
97 void IntTools_SurfaceRangeLocalizeData::AddOutRange(const IntTools_SurfaceRangeSample& theRange)
99 myMapRangeOut.Add(theRange);
100 // myMapBox.UnBind(theRange);
103 void IntTools_SurfaceRangeLocalizeData::AddBox(const IntTools_SurfaceRangeSample& theRange,
104 const Bnd_Box& theBox)
106 myMapBox.Bind(theRange, theBox);
109 Standard_Boolean IntTools_SurfaceRangeLocalizeData::FindBox(const IntTools_SurfaceRangeSample& theRange,
110 Bnd_Box& theBox) const
112 if(myMapBox.IsBound(theRange)) {
113 theBox = myMapBox(theRange);
114 return Standard_True;
116 return Standard_False;
119 Standard_Boolean IntTools_SurfaceRangeLocalizeData::IsRangeOut(const IntTools_SurfaceRangeSample& theRange) const
121 return myMapRangeOut.Contains(theRange);
124 void IntTools_SurfaceRangeLocalizeData::ListRangeOut(IntTools_ListOfSurfaceRangeSample& theList) const
126 IntTools_MapIteratorOfMapOfSurfaceSample anIt( myMapRangeOut);
128 for(; anIt.More(); anIt.Next())
129 theList.Append(anIt.Key());
132 void IntTools_SurfaceRangeLocalizeData::RemoveRangeOutAll()
134 myMapRangeOut.Clear();
137 // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization Begin
138 void IntTools_SurfaceRangeLocalizeData::SetRangeUGrid
139 (const Standard_Integer theNbUGrid)
146 if (myUParams.IsNull() || theNbUGrid != myUParams->Length()) {
147 myUParams = new TColStd_HArray1OfReal(1, theNbUGrid);
149 if (!myVParams.IsNull()) {
150 myGridPoints = new TColgp_HArray2OfPnt(1, theNbUGrid,
151 1, myVParams->Length());
156 void IntTools_SurfaceRangeLocalizeData::SetRangeVGrid
157 (const Standard_Integer theNbVGrid)
164 if (myVParams.IsNull() || theNbVGrid != myVParams->Length()) {
165 myVParams = new TColStd_HArray1OfReal(1, theNbVGrid);
167 if (!myUParams.IsNull()) {
168 myGridPoints = new TColgp_HArray2OfPnt(1, myUParams->Length(),
174 void IntTools_SurfaceRangeLocalizeData::SetFrame(const Standard_Real theUMin,
175 const Standard_Real theUMax,
176 const Standard_Real theVMin,
177 const Standard_Real theVMax)
184 if (myUParams.IsNull() || myVParams.IsNull()) {
189 Standard_Integer aLmI;
190 Standard_Integer aLen = myUParams->Length();
192 // Compute frame along U.
193 for (i = 1; i <= aLen; i++) {
194 if (myUIndMin == 0 && theUMin < myUParams->Value(i))
199 if (myUIndMax == 0 && theUMax > myUParams->Value(aLmI))
204 myUIndMin = aLen + 1;
206 // Compute frame along V.
207 aLen = myVParams->Length();
209 for (i = 1; i <= aLen; i++) {
210 if (myVIndMin == 0 && theVMin < myVParams->Value(i))
215 if (myVIndMax == 0 && theVMax > myVParams->Value(aLmI))
220 myVIndMin = aLen + 1;
224 const gp_Pnt &IntTools_SurfaceRangeLocalizeData::GetPointInFrame
225 (const Standard_Integer theUIndex,
226 const Standard_Integer theVIndex) const
228 Standard_Integer aFrmUInd = theUIndex + myUIndMin - 1;
229 Standard_Integer aFrmVInd = theVIndex + myVIndMin - 1;
231 if (aFrmUInd > myUIndMax || aFrmVInd > myVIndMax)
234 return myGridPoints->Value(aFrmUInd, aFrmVInd);
237 Standard_Real IntTools_SurfaceRangeLocalizeData::GetUParamInFrame
238 (const Standard_Integer theIndex) const
240 Standard_Integer aFrmInd = theIndex + myUIndMin - 1;
242 if (aFrmInd > myUIndMax)
243 return Precision::Infinite();
245 return myUParams->Value(aFrmInd);
248 Standard_Real IntTools_SurfaceRangeLocalizeData::GetVParamInFrame
249 (const Standard_Integer theIndex) const
251 Standard_Integer aFrmInd = theIndex + myVIndMin - 1;
253 if (aFrmInd > myVIndMax)
254 return Precision::Infinite();
256 return myVParams->Value(aFrmInd);
259 void IntTools_SurfaceRangeLocalizeData::ClearGrid()
267 if (!myUParams.IsNull())
270 if (!myVParams.IsNull())
273 if (!myGridPoints.IsNull())
274 myGridPoints.Nullify();
276 // Modified by skv - Thu Nov 3 11:58:24 2005 Optimization End