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.
15 #include <BOPDS_PaveBlock.ixx>
16 #include <BOPDS_ListOfPave.hxx>
17 #include <BOPDS_VectorOfPave.hxx>
19 #include <Standard.hxx>
20 #include <NCollection_BaseAllocator.hxx>
25 #pragma warning ( disable : 4291 )
28 //=======================================================================
31 //=======================================================================
32 BOPDS_PaveBlock::BOPDS_PaveBlock()
34 myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
35 myExtPaves(myAllocator)
42 //=======================================================================
45 //=======================================================================
46 BOPDS_PaveBlock::BOPDS_PaveBlock(const Handle(NCollection_BaseAllocator)& theAllocator)
48 myAllocator(theAllocator),
49 myExtPaves(theAllocator),
50 myMFence(100, theAllocator)
58 //=======================================================================
61 //=======================================================================
62 void BOPDS_PaveBlock::SetEdge(const Standard_Integer theEdge)
66 //=======================================================================
69 //=======================================================================
70 Standard_Integer BOPDS_PaveBlock::Edge()const
74 //=======================================================================
77 //=======================================================================
78 Standard_Boolean BOPDS_PaveBlock::HasEdge()const
82 //=======================================================================
85 //=======================================================================
86 Standard_Boolean BOPDS_PaveBlock::HasEdge(Standard_Integer& theEdge)const
92 //=======================================================================
93 //function : SetOriginalEdge
95 //=======================================================================
96 void BOPDS_PaveBlock::SetOriginalEdge(const Standard_Integer theEdge)
98 myOriginalEdge=theEdge;
100 //=======================================================================
101 //function : OriginalEdge
103 //=======================================================================
104 Standard_Integer BOPDS_PaveBlock::OriginalEdge()const
106 return myOriginalEdge;
108 //=======================================================================
109 //function : IsSplitEdge
111 //=======================================================================
112 Standard_Boolean BOPDS_PaveBlock::IsSplitEdge()const
114 return (myEdge!=myOriginalEdge);
116 //=======================================================================
117 //function : SetPave1
119 //=======================================================================
120 void BOPDS_PaveBlock::SetPave1(const BOPDS_Pave& thePave)
124 //=======================================================================
127 //=======================================================================
128 const BOPDS_Pave& BOPDS_PaveBlock::Pave1()const
132 //=======================================================================
133 //function : SetPave2
135 //=======================================================================
136 void BOPDS_PaveBlock::SetPave2(const BOPDS_Pave& thePave)
140 //=======================================================================
143 //=======================================================================
144 const BOPDS_Pave& BOPDS_PaveBlock::Pave2()const
148 //=======================================================================
151 //=======================================================================
152 void BOPDS_PaveBlock::Range(Standard_Real& theT1,
153 Standard_Real& theT2)const
155 theT1=myPave1.Parameter();
156 theT2=myPave2.Parameter();
158 //=======================================================================
161 //=======================================================================
162 void BOPDS_PaveBlock::Indices(Standard_Integer& theIndex1,
163 Standard_Integer& theIndex2)const
165 theIndex1=myPave1.Index();
166 theIndex2=myPave2.Index();
168 //=======================================================================
169 //function : HasSameBounds
171 //=======================================================================
172 Standard_Boolean BOPDS_PaveBlock::HasSameBounds(const Handle(BOPDS_PaveBlock)& theOther)const
174 Standard_Boolean bFlag1, bFlag2;
175 Standard_Integer n11, n12, n21, n22;
178 theOther->Indices(n21, n22);
180 bFlag1=(n11==n21) && (n12==n22);
181 bFlag2=(n11==n22) && (n12==n21);
183 return (bFlag1 || bFlag2);
190 //=======================================================================
191 //function : AppendExtPave
193 //=======================================================================
194 void BOPDS_PaveBlock::AppendExtPave(const BOPDS_Pave& thePave)
196 if (myMFence.Add(thePave.Index())) {
197 myExtPaves.Append(thePave);
200 //=======================================================================
201 //function : AppendExtPave1
203 //=======================================================================
204 void BOPDS_PaveBlock::AppendExtPave1(const BOPDS_Pave& thePave)
206 myExtPaves.Append(thePave);
208 //=======================================================================
209 //function : ExtPaves
211 //=======================================================================
212 const BOPDS_ListOfPave& BOPDS_PaveBlock::ExtPaves()const
216 //=======================================================================
217 //function : ChangeExtPaves
219 //=======================================================================
220 BOPDS_ListOfPave& BOPDS_PaveBlock::ChangeExtPaves()
224 //=======================================================================
225 //function : IsToUpdate
227 //=======================================================================
228 Standard_Boolean BOPDS_PaveBlock::IsToUpdate()const
230 return !myExtPaves.IsEmpty();
232 //=======================================================================
233 //function : ContainsParameter
235 //=======================================================================
236 Standard_Boolean BOPDS_PaveBlock::ContainsParameter(const Standard_Real theT,
237 const Standard_Real theTol)const
239 Standard_Boolean bRet;
241 BOPDS_ListIteratorOfListOfPave aIt;
244 aIt.Initialize(myExtPaves);
245 for (; aIt.More(); aIt.Next()) {
246 dT=aIt.Value().Parameter()-theT;
257 //=======================================================================
260 //=======================================================================
261 void BOPDS_PaveBlock::Update(BOPDS_ListOfPaveBlock& theLPB,
262 const Standard_Boolean theFlag)
264 Standard_Integer i, aNb;
265 BOPDS_Pave aPave1, aPave2;
266 Handle(BOPDS_PaveBlock) aPB;
267 BOPDS_ListIteratorOfListOfPave aIt;
269 aNb=myExtPaves.Extent();
280 BOPDS_VectorOfPave pPaves(1, aNb);
290 aIt.Initialize(myExtPaves);
291 for (; aIt.More(); aIt.Next()) {
292 const BOPDS_Pave& aPave=aIt.Value();
299 std::sort(pPaves.begin(), pPaves.end());
301 for (i = 1; i <= aNb; ++i) {
302 const BOPDS_Pave& aPave = pPaves(i);
309 aPB = new BOPDS_PaveBlock;
310 aPB->SetOriginalEdge(myOriginalEdge);
311 aPB->SetPave1(aPave1);
312 aPB->SetPave2(aPave2);
320 //=======================================================================
321 //function : HasShrunkData
323 //=======================================================================
324 Standard_Boolean BOPDS_PaveBlock::HasShrunkData()const
326 return (!myShrunkBox.IsVoid());
328 //=======================================================================
329 //function : SetShrunkData
331 //=======================================================================
332 void BOPDS_PaveBlock::SetShrunkData(const Standard_Real theT1,
333 const Standard_Real theT2,
334 const Bnd_Box& theBox)
340 //=======================================================================
341 //function : ShrunkData
343 //=======================================================================
344 void BOPDS_PaveBlock::ShrunkData(Standard_Real& theT1,
345 Standard_Real& theT2,
346 Bnd_Box& theBox)const
352 //=======================================================================
355 //=======================================================================
356 void BOPDS_PaveBlock::Dump()const
358 printf(" PB:{ E:%d orE:%d", myEdge, myOriginalEdge);