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()
29 //=======================================================================
32 //=======================================================================
33 BOPDS_CommonBlock::BOPDS_CommonBlock(const Handle(NCollection_BaseAllocator)& theAllocator)
35 myPaveBlocks(theAllocator),
39 //=======================================================================
40 // function: AddPaveBlock
42 //=======================================================================
43 void BOPDS_CommonBlock::AddPaveBlock(const Handle(BOPDS_PaveBlock)& aPB)
45 if (myPaveBlocks.IsEmpty()) {
46 myPaveBlocks.Append(aPB);
50 // Put the pave block with the minimal index of the original edge in the first place
51 if (aPB->OriginalEdge() < myPaveBlocks.First()->OriginalEdge()) {
52 myPaveBlocks.Prepend(aPB);
55 myPaveBlocks.Append(aPB);
58 //=======================================================================
59 // function: SetPaveBlocks
61 //=======================================================================
62 void BOPDS_CommonBlock::SetPaveBlocks(const BOPDS_ListOfPaveBlock& aLPB)
65 BOPDS_ListIteratorOfListOfPaveBlock aIt(aLPB);
66 for (; aIt.More(); aIt.Next()) {
67 AddPaveBlock(aIt.Value());
70 //=======================================================================
71 // function: PaveBlocks
73 //=======================================================================
74 const BOPDS_ListOfPaveBlock& BOPDS_CommonBlock::PaveBlocks()const
78 //=======================================================================
81 //=======================================================================
82 void BOPDS_CommonBlock::AddFace(const Standard_Integer aF)
86 //=======================================================================
89 //=======================================================================
90 void BOPDS_CommonBlock::SetFaces(const BOPCol_ListOfInteger& aLF)
94 //=======================================================================
95 // function: AppendFaces
97 //=======================================================================
98 void BOPDS_CommonBlock::AppendFaces(BOPCol_ListOfInteger& aLF)
102 //=======================================================================
105 //=======================================================================
106 const BOPCol_ListOfInteger& BOPDS_CommonBlock::Faces()const
110 //=======================================================================
111 // function: PaveBlock1
113 //=======================================================================
114 const Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlock1()const
116 return myPaveBlocks.First();
118 //=======================================================================
119 // function: PaveBlockOnEdge
121 //=======================================================================
122 Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx)
124 static Handle(BOPDS_PaveBlock) aPBs;
126 Standard_Integer aIOr;
127 BOPDS_ListIteratorOfListOfPaveBlock anIt;
129 anIt.Initialize(myPaveBlocks);
130 for (; anIt.More(); anIt.Next()) {
131 Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue();
132 aIOr=aPB->OriginalEdge();
139 //=======================================================================
140 // function: IsPaveBlockOnFace
142 //=======================================================================
143 Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const
145 Standard_Boolean bFound;
147 BOPCol_ListIteratorOfListOfInteger anIt;
149 bFound=Standard_False;
150 anIt.Initialize(myFaces);
151 for (; anIt.More(); anIt.Next()) {
159 //=======================================================================
160 // function: IsPaveBlockOnEdge
162 //=======================================================================
163 Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const
165 Standard_Boolean bFound;
166 Standard_Integer aIOr;
167 BOPDS_ListIteratorOfListOfPaveBlock anIt;
169 bFound=Standard_False;
170 anIt.Initialize(myPaveBlocks);
171 for (; anIt.More(); anIt.Next()) {
172 const Handle(BOPDS_PaveBlock)& aPB=anIt.Value();
173 aIOr=aPB->OriginalEdge();
180 //=======================================================================
183 //=======================================================================
184 void BOPDS_CommonBlock::SetEdge(const Standard_Integer theEdge)
186 BOPDS_ListIteratorOfListOfPaveBlock anIt;
188 anIt.Initialize(myPaveBlocks);
189 for (; anIt.More(); anIt.Next()) {
190 Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue();
191 aPB->SetEdge(theEdge);
194 //=======================================================================
197 //=======================================================================
198 Standard_Integer BOPDS_CommonBlock::Edge()const
200 const Handle(BOPDS_PaveBlock)& aPB1=myPaveBlocks.First();
206 //=======================================================================
207 // function: Contains
209 //=======================================================================
210 Standard_Boolean BOPDS_CommonBlock::Contains(const Handle(BOPDS_PaveBlock)& aPBx)const
212 Standard_Boolean bFound;
213 Standard_Integer aNb1;
214 BOPDS_ListIteratorOfListOfPaveBlock anIt;
216 bFound=Standard_False;
217 aNb1=myPaveBlocks.Extent();
223 anIt.Initialize(myPaveBlocks);
224 for (; anIt.More(); anIt.Next()) {
225 const Handle(BOPDS_PaveBlock)& aPB=anIt.Value();
232 //=======================================================================
233 // function: Contains
235 //=======================================================================
236 Standard_Boolean BOPDS_CommonBlock::Contains(const Standard_Integer theF)const
238 Standard_Boolean bFound;
239 BOPCol_ListIteratorOfListOfInteger aIt;
241 bFound=Standard_False;
242 aIt.Initialize(myFaces);
243 for (; aIt.More(); aIt.Next()) {
244 if (aIt.Value()==theF) {
250 //=======================================================================
253 //=======================================================================
254 void BOPDS_CommonBlock::Dump()const
257 BOPCol_ListIteratorOfListOfInteger aIt;
258 BOPDS_ListIteratorOfListOfPaveBlock aItPB;
261 aItPB.Initialize(myPaveBlocks);
262 for (; aItPB.More(); aItPB.Next()) {
263 const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value();
268 if (myFaces.Extent()) {
270 aIt.Initialize(myFaces);
271 for (; aIt.More(); aIt.Next()) {