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