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,
240 Standard_Integer& theInd) const
242 Standard_Boolean bRet;
243 BOPDS_ListIteratorOfListOfPave aIt;
245 bRet = Standard_False;
246 aIt.Initialize(myExtPaves);
247 for (; aIt.More(); aIt.Next()) {
248 const BOPDS_Pave& aPave = aIt.Value();
249 bRet = (Abs(aPave.Parameter() - theT) < theTol);
251 theInd = aPave.Index();
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);