4e57c75e |
1 | // Created by: Peter KURNEV |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
4e57c75e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
4e57c75e |
5 | // |
973c2be1 |
6 | // This library is free software; you can redistribute it and / or modify it |
7 | // under the terms of the GNU Lesser General Public 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. |
4e57c75e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
4e57c75e |
14 | |
15 | #include <BOPDS_CommonBlock.ixx> |
16 | |
17 | //======================================================================= |
18 | // function: |
19 | // purpose: |
20 | //======================================================================= |
21 | BOPDS_CommonBlock::BOPDS_CommonBlock() |
22 | { |
23 | } |
24 | //======================================================================= |
25 | // function: |
26 | // purpose: |
27 | //======================================================================= |
28 | BOPDS_CommonBlock::BOPDS_CommonBlock(const Handle(NCollection_BaseAllocator)& theAllocator) |
29 | : |
30 | myPaveBlocks(theAllocator), |
31 | myFaces(theAllocator) |
32 | { |
33 | } |
34 | //======================================================================= |
35 | // function: AddPaveBlock |
36 | // purpose: |
37 | //======================================================================= |
38 | void BOPDS_CommonBlock::AddPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) |
39 | { |
40 | myPaveBlocks.Append(aPB); |
41 | } |
42 | //======================================================================= |
43 | // function: AddPaveBlocks |
44 | // purpose: |
45 | //======================================================================= |
46 | void BOPDS_CommonBlock::AddPaveBlocks(const BOPDS_ListOfPaveBlock& aLPB) |
47 | { |
48 | myPaveBlocks=aLPB; |
49 | } |
50 | //======================================================================= |
51 | // function: PaveBlocks |
52 | // purpose: |
53 | //======================================================================= |
54 | const BOPDS_ListOfPaveBlock& BOPDS_CommonBlock::PaveBlocks()const |
55 | { |
56 | return myPaveBlocks; |
57 | } |
58 | //======================================================================= |
59 | // function: AddFace |
60 | // purpose: |
61 | //======================================================================= |
62 | void BOPDS_CommonBlock::AddFace(const Standard_Integer aF) |
63 | { |
64 | myFaces.Append(aF); |
65 | } |
66 | //======================================================================= |
67 | // function: AddFaces |
68 | // purpose: |
69 | //======================================================================= |
70 | void BOPDS_CommonBlock::AddFaces(const BOPCol_ListOfInteger& aLF) |
71 | { |
72 | myFaces=aLF; |
73 | } |
74 | //======================================================================= |
75 | // function: Faces |
76 | // purpose: |
77 | //======================================================================= |
78 | const BOPCol_ListOfInteger& BOPDS_CommonBlock::Faces()const |
79 | { |
80 | return myFaces; |
81 | } |
82 | //======================================================================= |
83 | // function: PaveBlock1 |
84 | // purpose: |
85 | //======================================================================= |
86 | const Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlock1()const |
87 | { |
88 | return myPaveBlocks.First(); |
89 | } |
90 | //======================================================================= |
91 | // function: PaveBlockOnEdge |
92 | // purpose: |
93 | //======================================================================= |
94 | Handle(BOPDS_PaveBlock)& BOPDS_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx) |
95 | { |
96 | static Handle(BOPDS_PaveBlock) aPBs; |
97 | // |
98 | Standard_Integer aIOr; |
99 | BOPDS_ListIteratorOfListOfPaveBlock anIt; |
100 | // |
101 | anIt.Initialize(myPaveBlocks); |
102 | for (; anIt.More(); anIt.Next()) { |
103 | Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue(); |
104 | aIOr=aPB->OriginalEdge(); |
105 | if (aIOr==aIx){ |
106 | return aPB; |
107 | } |
108 | } |
109 | return aPBs; |
110 | } |
111 | //======================================================================= |
112 | // function: IsPaveBlockOnFace |
113 | // purpose: |
114 | //======================================================================= |
115 | Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const |
116 | { |
117 | Standard_Boolean bFound; |
118 | Standard_Integer nF; |
119 | BOPCol_ListIteratorOfListOfInteger anIt; |
120 | // |
121 | bFound=Standard_False; |
122 | anIt.Initialize(myFaces); |
123 | for (; anIt.More(); anIt.Next()) { |
124 | nF=anIt.Value(); |
125 | if (nF==aIx){ |
126 | return !bFound; |
127 | } |
128 | } |
129 | return bFound; |
130 | } |
131 | //======================================================================= |
132 | // function: IsPaveBlockOnEdge |
133 | // purpose: |
134 | //======================================================================= |
135 | Standard_Boolean BOPDS_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const |
136 | { |
137 | Standard_Boolean bFound; |
138 | Standard_Integer aIOr; |
139 | BOPDS_ListIteratorOfListOfPaveBlock anIt; |
140 | // |
141 | bFound=Standard_False; |
142 | anIt.Initialize(myPaveBlocks); |
143 | for (; anIt.More(); anIt.Next()) { |
144 | const Handle(BOPDS_PaveBlock)& aPB=anIt.Value(); |
145 | aIOr=aPB->OriginalEdge(); |
146 | if (aIOr==aIx){ |
147 | return !bFound; |
148 | } |
149 | } |
150 | return bFound; |
151 | } |
152 | //======================================================================= |
153 | //function : SetEdge |
154 | //purpose : |
155 | //======================================================================= |
156 | void BOPDS_CommonBlock::SetEdge(const Standard_Integer theEdge) |
157 | { |
158 | BOPDS_ListIteratorOfListOfPaveBlock anIt; |
159 | // |
160 | anIt.Initialize(myPaveBlocks); |
161 | for (; anIt.More(); anIt.Next()) { |
162 | Handle(BOPDS_PaveBlock)& aPB=anIt.ChangeValue(); |
163 | aPB->SetEdge(theEdge); |
164 | } |
165 | } |
166 | //======================================================================= |
167 | //function : Edge |
168 | //purpose : |
169 | //======================================================================= |
170 | Standard_Integer BOPDS_CommonBlock::Edge()const |
171 | { |
172 | const Handle(BOPDS_PaveBlock)& aPB1=myPaveBlocks.First(); |
173 | if(!aPB1.IsNull()) { |
174 | return aPB1->Edge(); |
175 | } |
176 | return -1; |
177 | } |
178 | //======================================================================= |
179 | // function: Contains |
180 | // purpose: |
181 | //======================================================================= |
182 | Standard_Boolean BOPDS_CommonBlock::Contains(const Handle(BOPDS_PaveBlock)& aPBx)const |
183 | { |
184 | Standard_Boolean bFound; |
185 | Standard_Integer aNb1; |
186 | BOPDS_ListIteratorOfListOfPaveBlock anIt; |
187 | // |
188 | bFound=Standard_False; |
189 | aNb1=myPaveBlocks.Extent(); |
190 | // |
191 | if (!aNb1) { |
192 | return bFound; |
193 | } |
194 | // |
195 | anIt.Initialize(myPaveBlocks); |
196 | for (; anIt.More(); anIt.Next()) { |
197 | const Handle(BOPDS_PaveBlock)& aPB=anIt.Value(); |
198 | if (aPB==aPBx) { |
199 | return !bFound; |
200 | } |
201 | } |
202 | return bFound; |
203 | } |
204 | //======================================================================= |
205 | // function: Contains |
206 | // purpose: |
207 | //======================================================================= |
208 | Standard_Boolean BOPDS_CommonBlock::Contains(const Standard_Integer theF)const |
209 | { |
210 | Standard_Boolean bFound; |
211 | BOPCol_ListIteratorOfListOfInteger aIt; |
212 | // |
213 | bFound=Standard_False; |
214 | aIt.Initialize(myFaces); |
215 | for (; aIt.More(); aIt.Next()) { |
216 | if (aIt.Value()==theF) { |
217 | return !bFound; |
218 | } |
219 | } |
220 | return bFound; |
221 | } |
222 | //======================================================================= |
223 | // function: Dump |
224 | // purpose: |
225 | //======================================================================= |
226 | void BOPDS_CommonBlock::Dump()const |
227 | { |
228 | Standard_Integer nF; |
229 | BOPCol_ListIteratorOfListOfInteger aIt; |
230 | BOPDS_ListIteratorOfListOfPaveBlock aItPB; |
231 | // |
232 | printf(" -- CB:\n"); |
233 | aItPB.Initialize(myPaveBlocks); |
234 | for (; aItPB.More(); aItPB.Next()) { |
235 | const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); |
236 | aPB->Dump(); |
237 | printf("\n"); |
238 | } |
239 | // |
240 | if (myFaces.Extent()) { |
241 | printf(" Faces:"); |
242 | aIt.Initialize(myFaces); |
243 | for (; aIt.More(); aIt.Next()) { |
244 | nF=aIt.Value(); |
245 | printf(" %d", nF); |
246 | } |
247 | printf("\n"); |
248 | } |
249 | } |