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