1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <Bnd_Box.hxx>
17 #include <BOPDS_ListOfPave.hxx>
18 #include <BOPDS_Pave.hxx>
19 #include <BOPDS_PaveBlock.hxx>
20 #include <BOPDS_VectorOfPave.hxx>
21 #include <NCollection_BaseAllocator.hxx>
22 #include <Standard.hxx>
23 #include <Standard_Type.hxx>
27 #pragma warning ( disable : 4291 )
30 //=======================================================================
33 //=======================================================================
34 BOPDS_PaveBlock::BOPDS_PaveBlock()
36 myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
37 myExtPaves(myAllocator)
44 //=======================================================================
47 //=======================================================================
48 BOPDS_PaveBlock::BOPDS_PaveBlock(const Handle(NCollection_BaseAllocator)& theAllocator)
50 myAllocator(theAllocator),
51 myExtPaves(theAllocator),
52 myMFence(100, theAllocator)
60 //=======================================================================
63 //=======================================================================
64 void BOPDS_PaveBlock::SetEdge(const Standard_Integer theEdge)
68 //=======================================================================
71 //=======================================================================
72 Standard_Integer BOPDS_PaveBlock::Edge()const
76 //=======================================================================
79 //=======================================================================
80 Standard_Boolean BOPDS_PaveBlock::HasEdge()const
84 //=======================================================================
87 //=======================================================================
88 Standard_Boolean BOPDS_PaveBlock::HasEdge(Standard_Integer& theEdge)const
94 //=======================================================================
95 //function : SetOriginalEdge
97 //=======================================================================
98 void BOPDS_PaveBlock::SetOriginalEdge(const Standard_Integer theEdge)
100 myOriginalEdge=theEdge;
102 //=======================================================================
103 //function : OriginalEdge
105 //=======================================================================
106 Standard_Integer BOPDS_PaveBlock::OriginalEdge()const
108 return myOriginalEdge;
110 //=======================================================================
111 //function : IsSplitEdge
113 //=======================================================================
114 Standard_Boolean BOPDS_PaveBlock::IsSplitEdge()const
116 return (myEdge!=myOriginalEdge);
118 //=======================================================================
119 //function : SetPave1
121 //=======================================================================
122 void BOPDS_PaveBlock::SetPave1(const BOPDS_Pave& thePave)
126 //=======================================================================
129 //=======================================================================
130 const BOPDS_Pave& BOPDS_PaveBlock::Pave1()const
134 //=======================================================================
135 //function : SetPave2
137 //=======================================================================
138 void BOPDS_PaveBlock::SetPave2(const BOPDS_Pave& thePave)
142 //=======================================================================
145 //=======================================================================
146 const BOPDS_Pave& BOPDS_PaveBlock::Pave2()const
150 //=======================================================================
153 //=======================================================================
154 void BOPDS_PaveBlock::Range(Standard_Real& theT1,
155 Standard_Real& theT2)const
157 theT1=myPave1.Parameter();
158 theT2=myPave2.Parameter();
160 //=======================================================================
163 //=======================================================================
164 void BOPDS_PaveBlock::Indices(Standard_Integer& theIndex1,
165 Standard_Integer& theIndex2)const
167 theIndex1=myPave1.Index();
168 theIndex2=myPave2.Index();
170 //=======================================================================
171 //function : HasSameBounds
173 //=======================================================================
174 Standard_Boolean BOPDS_PaveBlock::HasSameBounds(const Handle(BOPDS_PaveBlock)& theOther)const
176 Standard_Boolean bFlag1, bFlag2;
177 Standard_Integer n11, n12, n21, n22;
180 theOther->Indices(n21, n22);
182 bFlag1=(n11==n21) && (n12==n22);
183 bFlag2=(n11==n22) && (n12==n21);
185 return (bFlag1 || bFlag2);
192 //=======================================================================
193 //function : AppendExtPave
195 //=======================================================================
196 void BOPDS_PaveBlock::AppendExtPave(const BOPDS_Pave& thePave)
198 if (myMFence.Add(thePave.Index())) {
199 myExtPaves.Append(thePave);
202 //=======================================================================
203 //function : AppendExtPave1
205 //=======================================================================
206 void BOPDS_PaveBlock::AppendExtPave1(const BOPDS_Pave& thePave)
208 myExtPaves.Append(thePave);
210 //=======================================================================
211 //function : ExtPaves
213 //=======================================================================
214 const BOPDS_ListOfPave& BOPDS_PaveBlock::ExtPaves()const
218 //=======================================================================
219 //function : ChangeExtPaves
221 //=======================================================================
222 BOPDS_ListOfPave& BOPDS_PaveBlock::ChangeExtPaves()
226 //=======================================================================
227 //function : IsToUpdate
229 //=======================================================================
230 Standard_Boolean BOPDS_PaveBlock::IsToUpdate()const
232 return !myExtPaves.IsEmpty();
234 //=======================================================================
235 //function : ContainsParameter
237 //=======================================================================
238 Standard_Boolean BOPDS_PaveBlock::ContainsParameter(const Standard_Real theT,
239 const Standard_Real theTol)const
241 Standard_Boolean bRet;
243 BOPDS_ListIteratorOfListOfPave aIt;
246 aIt.Initialize(myExtPaves);
247 for (; aIt.More(); aIt.Next()) {
248 dT=aIt.Value().Parameter()-theT;
259 //=======================================================================
262 //=======================================================================
263 void BOPDS_PaveBlock::Update(BOPDS_ListOfPaveBlock& theLPB,
264 const Standard_Boolean theFlag)
266 Standard_Integer i, aNb;
267 BOPDS_Pave aPave1, aPave2;
268 Handle(BOPDS_PaveBlock) aPB;
269 BOPDS_ListIteratorOfListOfPave aIt;
271 aNb=myExtPaves.Extent();
282 BOPDS_VectorOfPave pPaves(1, aNb);
292 aIt.Initialize(myExtPaves);
293 for (; aIt.More(); aIt.Next()) {
294 const BOPDS_Pave& aPave=aIt.Value();
301 std::sort(pPaves.begin(), pPaves.end());
303 for (i = 1; i <= aNb; ++i) {
304 const BOPDS_Pave& aPave = pPaves(i);
311 aPB = new BOPDS_PaveBlock;
312 aPB->SetOriginalEdge(myOriginalEdge);
313 aPB->SetPave1(aPave1);
314 aPB->SetPave2(aPave2);
322 //=======================================================================
323 //function : HasShrunkData
325 //=======================================================================
326 Standard_Boolean BOPDS_PaveBlock::HasShrunkData()const
328 return (!myShrunkBox.IsVoid());
330 //=======================================================================
331 //function : SetShrunkData
333 //=======================================================================
334 void BOPDS_PaveBlock::SetShrunkData(const Standard_Real theT1,
335 const Standard_Real theT2,
336 const Bnd_Box& theBox)
342 //=======================================================================
343 //function : ShrunkData
345 //=======================================================================
346 void BOPDS_PaveBlock::ShrunkData(Standard_Real& theT1,
347 Standard_Real& theT2,
348 Bnd_Box& theBox)const
354 //=======================================================================
357 //=======================================================================
358 void BOPDS_PaveBlock::Dump()const
360 printf(" PB:{ E:%d orE:%d", myEdge, myOriginalEdge);