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 <BOPDS_CommonBlock.hxx>
17 #include <BOPDS_PaveBlock.hxx>
18 #include <Standard_Type.hxx>
20 IMPLEMENT_STANDARD_RTTIEXT(BOPDS_CommonBlock,Standard_Transient)
22 //=======================================================================
25 //=======================================================================
26 BOPDS_CommonBlock::BOPDS_CommonBlock()
31 //=======================================================================
34 //=======================================================================
35 BOPDS_CommonBlock::BOPDS_CommonBlock(const Handle(NCollection_BaseAllocator)& theAllocator)
37 myPaveBlocks(theAllocator),
38 myFaces(theAllocator),
42 //=======================================================================
43 // function: AddPaveBlock
45 //=======================================================================
46 void BOPDS_CommonBlock::AddPaveBlock(const Handle(BOPDS_PaveBlock)& aPB)
48 if (myPaveBlocks.IsEmpty()) {
49 myPaveBlocks.Append(aPB);
53 // Put the pave block with the minimal index of the original edge in the first place
54 if (aPB->OriginalEdge() < myPaveBlocks.First()->OriginalEdge()) {
55 myPaveBlocks.Prepend(aPB);
58 myPaveBlocks.Append(aPB);
61 //=======================================================================
62 // function: SetPaveBlocks
64 //=======================================================================
65 void BOPDS_CommonBlock::SetPaveBlocks(const BOPDS_ListOfPaveBlock& aLPB)
68 BOPDS_ListIteratorOfListOfPaveBlock aIt(aLPB);
69 for (; aIt.More(); aIt.Next()) {
70 AddPaveBlock(aIt.Value());
73 //=======================================================================
74 // function: PaveBlocks
76 //=======================================================================
77 const BOPDS_ListOfPaveBlock& BOPDS_CommonBlock::PaveBlocks()const
81 //=======================================================================
84 //=======================================================================
85 void BOPDS_CommonBlock::AddFace(const Standard_Integer aF)
89 //=======================================================================
92 //=======================================================================
93 void BOPDS_CommonBlock::SetFaces(const TColStd_ListOfInteger& aLF)
97 //=======================================================================
98 // function: AppendFaces
100 //=======================================================================
101 void BOPDS_CommonBlock::AppendFaces(TColStd_ListOfInteger& aLF)
105 //=======================================================================
108 //=======================================================================
109 const TColStd_ListOfInteger& BOPDS_CommonBlock::Faces()const
113 //=======================================================================
114 // function: PaveBlock1
116 //=======================================================================
117 const Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlock1()const
119 return myPaveBlocks.First();
121 //=======================================================================
122 // function: SetRealPaveBlock
124 //=======================================================================
125 void BOPDS_CommonBlock::SetRealPaveBlock(const Handle(BOPDS_PaveBlock)& thePB)
127 BOPDS_ListIteratorOfListOfPaveBlock it(myPaveBlocks);
128 for (; it.More(); it.Next())
130 if (it.Value() == thePB)
132 myPaveBlocks.Prepend(thePB);
133 myPaveBlocks.Remove(it);
138 //=======================================================================
139 // function: PaveBlockOnEdge
141 //=======================================================================
142 Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx)
144 static Handle(BOPDS_PaveBlock) aPBs;
146 Standard_Integer aIOr;
147 BOPDS_ListIteratorOfListOfPaveBlock anIt;
149 anIt.Initialize(myPaveBlocks);
150 for (; anIt.More(); anIt.Next()) {
151 Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue();
152 aIOr=aPB->OriginalEdge();
159 //=======================================================================
160 // function: IsPaveBlockOnFace
162 //=======================================================================
163 Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const
165 Standard_Boolean bFound;
167 TColStd_ListIteratorOfListOfInteger anIt;
169 bFound=Standard_False;
170 anIt.Initialize(myFaces);
171 for (; anIt.More(); anIt.Next()) {
179 //=======================================================================
180 // function: IsPaveBlockOnEdge
182 //=======================================================================
183 Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const
185 Standard_Boolean bFound;
186 Standard_Integer aIOr;
187 BOPDS_ListIteratorOfListOfPaveBlock anIt;
189 bFound=Standard_False;
190 anIt.Initialize(myPaveBlocks);
191 for (; anIt.More(); anIt.Next()) {
192 const Handle(BOPDS_PaveBlock)& aPB=anIt.Value();
193 aIOr=aPB->OriginalEdge();
200 //=======================================================================
203 //=======================================================================
204 void BOPDS_CommonBlock::SetEdge(const Standard_Integer theEdge)
206 BOPDS_ListIteratorOfListOfPaveBlock anIt;
208 anIt.Initialize(myPaveBlocks);
209 for (; anIt.More(); anIt.Next()) {
210 Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue();
211 aPB->SetEdge(theEdge);
214 //=======================================================================
217 //=======================================================================
218 Standard_Integer BOPDS_CommonBlock::Edge()const
220 const Handle(BOPDS_PaveBlock)& aPB1=myPaveBlocks.First();
226 //=======================================================================
227 // function: Contains
229 //=======================================================================
230 Standard_Boolean BOPDS_CommonBlock::Contains(const Handle(BOPDS_PaveBlock)& aPBx)const
232 Standard_Boolean bFound;
233 Standard_Integer aNb1;
234 BOPDS_ListIteratorOfListOfPaveBlock anIt;
236 bFound=Standard_False;
237 aNb1=myPaveBlocks.Extent();
243 anIt.Initialize(myPaveBlocks);
244 for (; anIt.More(); anIt.Next()) {
245 const Handle(BOPDS_PaveBlock)& aPB=anIt.Value();
252 //=======================================================================
253 // function: Contains
255 //=======================================================================
256 Standard_Boolean BOPDS_CommonBlock::Contains(const Standard_Integer theF)const
258 Standard_Boolean bFound;
259 TColStd_ListIteratorOfListOfInteger aIt;
261 bFound=Standard_False;
262 aIt.Initialize(myFaces);
263 for (; aIt.More(); aIt.Next()) {
264 if (aIt.Value()==theF) {
270 //=======================================================================
273 //=======================================================================
274 void BOPDS_CommonBlock::Dump()const
277 TColStd_ListIteratorOfListOfInteger aIt;
278 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
281 aItPB.Initialize(myPaveBlocks);
282 for (; aItPB.More(); aItPB.Next()) {
283 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
288 if (myFaces.Extent()) {
290 aIt.Initialize(myFaces);
291 for (; aIt.More(); aIt.Next()) {