b311480e |
1 | // Created on: 2001-05-05 |
2 | // Created by: Sergey KHROMOV |
3 | // Copyright (c) 2001-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
7fd59977 |
19 | |
20 | #include <QANewModTopOpe_Glue.ixx> |
21 | #include <TopExp_Explorer.hxx> |
22 | #include <TopoDS.hxx> |
23 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
24 | #include <TopTools_ListOfShape.hxx> |
25 | #include <TopoDS_Compound.hxx> |
26 | #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> |
27 | #include <TopTools_MapOfShape.hxx> |
28 | #include <TopTools_MapIteratorOfMapOfShape.hxx> |
29 | #include <TopExp.hxx> |
30 | #include <QANewModTopOpe_Tools.hxx> |
31 | #include <BRep_Builder.hxx> |
32 | #include <BRep_Tool.hxx> |
33 | #include <Geom_TrimmedCurve.hxx> |
34 | #include <GeomProjLib.hxx> |
35 | #include <Precision.hxx> |
36 | #include <BRepAdaptor_Surface.hxx> |
37 | |
38 | static Standard_Boolean isAnalitic(const TopoDS_Shape &theShape) |
39 | { |
40 | if (theShape.ShapeType() != TopAbs_FACE) |
41 | return Standard_False; |
42 | |
43 | TopoDS_Face aFace = TopoDS::Face(theShape); |
44 | BRepAdaptor_Surface aSurf(aFace); |
45 | Standard_Boolean isAna = Standard_False; |
46 | |
47 | switch (aSurf.GetType()) { |
48 | case GeomAbs_Plane : |
49 | case GeomAbs_Cylinder : |
50 | case GeomAbs_Cone : |
51 | case GeomAbs_Sphere : |
52 | case GeomAbs_Torus : |
53 | isAna = Standard_True; |
54 | break; |
55 | default: |
56 | isAna = Standard_False; |
57 | } |
58 | |
59 | return isAna; |
60 | } |
61 | |
62 | static void DoPCurveOnF(const TopoDS_Edge &theEdge, const TopoDS_Face &theFace) |
63 | { |
64 | BRep_Builder aBuilder; |
65 | TopLoc_Location aCLoc; |
66 | TopLoc_Location aSLoc; |
67 | Standard_Real aF; |
68 | Standard_Real aL; |
69 | Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aCLoc, aF, aL); |
70 | Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, aF, aL); |
71 | Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace, aSLoc); |
72 | TopLoc_Location aCTLoc = aSLoc.Inverted().Multiplied(aCLoc); |
73 | |
74 | aTrCurve->Transform(aCTLoc.Transformation()); |
75 | |
76 | Handle(Geom2d_Curve) aCurve2d = GeomProjLib::Curve2d (aTrCurve, aSurface); |
77 | |
78 | aBuilder.UpdateEdge(theEdge, aCurve2d, aSurface, |
79 | aSLoc, Precision::Confusion()); |
80 | } |
81 | |
82 | static TopoDS_Face GetAdjacentFace |
83 | (const TopoDS_Shape &theEdge, |
84 | const TopoDS_Shape &theFace, |
85 | const TopTools_IndexedDataMapOfShapeListOfShape &theAncMap) |
86 | { |
87 | TopoDS_Face aFace; |
88 | |
89 | if (theAncMap.Contains(theEdge)) { |
90 | const TopTools_ListOfShape &aLOfFaces = |
91 | theAncMap.FindFromKey(theEdge); |
92 | TopTools_ListIteratorOfListOfShape anIter(aLOfFaces); |
93 | |
94 | for (; anIter.More(); anIter.Next()) { |
95 | const TopoDS_Shape &aLocalFace = anIter.Value(); |
96 | |
97 | if (!theFace.IsSame(aLocalFace)) { |
98 | aFace = TopoDS::Face(aLocalFace); |
99 | break; |
100 | } |
101 | } |
102 | } |
103 | |
104 | return aFace; |
105 | } |
106 | |
107 | //======================================================================= |
108 | //function : SubstitudeSDFaces |
109 | //purpose : |
110 | //======================================================================= |
111 | |
112 | Standard_Boolean QANewModTopOpe_Glue::SubstitudeSDFaces |
113 | (const TopoDS_Shape &theFirstSDFace, |
114 | const TopoDS_Shape &theSecondSDFace, |
115 | TopoDS_Shape &theNewSolid1, |
116 | TopoDS_Shape &theNewSolid2, |
117 | TopTools_DataMapOfShapeListOfShape &theMapOfChangedFaces) |
118 | { |
119 | // If the first face is already splited, we use its splits |
120 | // to recursively call this function. |
121 | if (theMapOfChangedFaces.IsBound(theFirstSDFace)) { |
122 | const TopTools_ListOfShape &aLocalList = |
123 | theMapOfChangedFaces(theFirstSDFace); |
124 | TopTools_ListIteratorOfListOfShape anIter(aLocalList); |
125 | |
126 | for (;anIter.More(); anIter.Next()) { |
127 | const TopoDS_Shape &aNewShape = anIter.Value(); |
128 | if (!SubstitudeSDFaces(aNewShape, theSecondSDFace, |
129 | theNewSolid1, theNewSolid2, |
130 | theMapOfChangedFaces)) |
131 | return Standard_False; |
132 | } |
133 | return Standard_True; |
134 | } |
135 | |
136 | // If the second face is already splited, we use its splits |
137 | // to recursively call this function. |
138 | if (theMapOfChangedFaces.IsBound(theSecondSDFace)) { |
139 | const TopTools_ListOfShape &aLocalList = |
140 | theMapOfChangedFaces(theSecondSDFace); |
141 | TopTools_ListIteratorOfListOfShape anIter(aLocalList); |
142 | |
143 | for (;anIter.More(); anIter.Next()) { |
144 | const TopoDS_Shape &aNewShape = anIter.Value(); |
145 | if (!SubstitudeSDFaces(theFirstSDFace, aNewShape, |
146 | theNewSolid1, theNewSolid2, |
147 | theMapOfChangedFaces)) |
148 | return Standard_False; |
149 | } |
150 | return Standard_True; |
151 | } |
152 | |
153 | |
154 | // If neither the first face nor the second one were |
155 | // splited before, we begin calculation: |
156 | TopTools_IndexedDataMapOfShapeListOfShape aHistory; |
157 | Standard_Boolean isCommonFound; |
158 | |
159 | if (!QANewModTopOpe_Tools::BoolOpe(theFirstSDFace.Oriented(TopAbs_FORWARD), |
160 | theSecondSDFace.Oriented(TopAbs_FORWARD), |
161 | isCommonFound, aHistory)) |
162 | return Standard_False; |
163 | |
164 | if (!isCommonFound) |
165 | return Standard_True; |
166 | |
167 | TopTools_IndexedDataMapOfShapeListOfShape anAncMap1; |
168 | TopTools_IndexedDataMapOfShapeListOfShape anAncMap2; |
169 | |
170 | TopExp::MapShapesAndAncestors(theNewSolid1, TopAbs_EDGE, |
171 | TopAbs_FACE, anAncMap1); |
172 | TopExp::MapShapesAndAncestors(theNewSolid2, TopAbs_EDGE, |
173 | TopAbs_FACE, anAncMap2); |
174 | |
175 | // Creation of a compound of old solids. |
176 | // The substitution operation will be built with this |
177 | // compound. |
178 | BRep_Builder aBuilder; |
179 | TopoDS_Compound aCompound; |
180 | |
181 | aBuilder.MakeCompound(aCompound); |
182 | aBuilder.Add(aCompound, theNewSolid1); |
183 | aBuilder.Add(aCompound, theNewSolid2); |
184 | |
185 | // Substitution of updated sub-shapes of the first solid. |
186 | BRepTools_Substitution aSubstTool; |
187 | Standard_Integer aNbModifShape = aHistory.Extent(); |
188 | Standard_Integer i; |
189 | |
190 | for (i = 1; i <= aNbModifShape; i++) { |
191 | TopTools_ListOfShape aModifShapes; |
192 | const TopoDS_Shape &anAncestor = aHistory.FindKey(i); |
193 | TopTools_ListIteratorOfListOfShape anIter(aHistory.FindFromIndex(i)); |
194 | |
195 | if (anAncestor.IsSame(theSecondSDFace)) { |
196 | for (; anIter.More(); anIter.Next()) |
197 | aModifShapes.Append(anIter.Value()); |
198 | } else { |
199 | for (; anIter.More(); anIter.Next()) |
200 | aModifShapes.Append(anIter.Value().Oriented(TopAbs_FORWARD)); |
201 | } |
202 | |
203 | if (anAncestor.ShapeType() == TopAbs_EDGE) { |
204 | // Check if the edges from common contain pcurves on both shapes. |
205 | // If they do not, create them. |
206 | TopoDS_Edge anAncEdge = TopoDS::Edge(anAncestor); |
207 | |
208 | if (anAncMap1.Contains(anAncestor)) { |
209 | TopoDS_Face aFace = GetAdjacentFace(anAncestor, theFirstSDFace, |
210 | anAncMap1); |
211 | if(!aFace.IsNull()) {//added to fix 4086 |
212 | Standard_Real aFirst; |
213 | Standard_Real aLast; |
214 | |
215 | anIter.Initialize(aHistory.FindFromIndex(i)); |
216 | for (; anIter.More(); anIter.Next()) { |
217 | TopoDS_Edge aSplit = TopoDS::Edge(anIter.Value()); |
218 | Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface |
219 | (aSplit, aFace, aFirst, aLast); |
220 | |
221 | if (aPCurve.IsNull()) |
222 | DoPCurveOnF(aSplit, aFace); |
223 | } |
224 | } |
225 | } |
226 | |
227 | if (anAncMap2.Contains(anAncestor)) { |
228 | TopoDS_Face aFace = GetAdjacentFace(anAncestor, theSecondSDFace, |
229 | anAncMap2); |
230 | if(!aFace.IsNull()) {//added to fix 4086 |
231 | Standard_Real aFirst; |
232 | Standard_Real aLast; |
233 | |
234 | anIter.Initialize(aHistory.FindFromIndex(i)); |
235 | for (; anIter.More(); anIter.Next()) { |
236 | TopoDS_Edge aSplit = TopoDS::Edge(anIter.Value()); |
237 | Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface |
238 | (aSplit, aFace, aFirst, aLast); |
239 | |
240 | if (aPCurve.IsNull()) |
241 | DoPCurveOnF(aSplit, aFace); |
242 | } |
243 | } |
244 | } |
245 | } |
246 | |
247 | //-------------------------------------------------------------- |
248 | if (!myMapModif.IsBound(anAncestor)) |
249 | myMapModif.Bind(anAncestor, aModifShapes); |
250 | //-------------------------------------------------------------- |
251 | |
252 | aSubstTool.Substitute(anAncestor, aModifShapes); |
253 | } |
254 | |
255 | aSubstTool.Build(aCompound); |
256 | |
257 | // Update the map theMapOfChangedFaces and |
258 | // obtain a new solid from the first one. |
259 | if (aSubstTool.IsCopied(theNewSolid1)) { |
260 | // Add changed faces of the first solid to theMapOfChangedFaces: |
261 | TopExp_Explorer anExp(theNewSolid1, TopAbs_FACE); |
262 | for (; anExp.More(); anExp.Next()) { |
263 | // For each face from solid |
264 | const TopoDS_Shape &aFace = anExp.Current(); |
265 | |
266 | if (aSubstTool.IsCopied(aFace)) { |
267 | const TopTools_ListOfShape &aList = aSubstTool.Copy(aFace); |
268 | |
269 | TopTools_ListOfShape aNewList; |
270 | if (!theMapOfChangedFaces.IsBound(aFace)) |
271 | theMapOfChangedFaces.Bind(aFace, aNewList); |
272 | |
273 | TopTools_ListIteratorOfListOfShape anIter(aList); |
274 | for (; anIter.More(); anIter.Next()) { |
275 | TopoDS_Shape aLocalFace = anIter.Value(); |
276 | |
277 | if (aSubstTool.IsCopied(aLocalFace)) |
278 | aLocalFace = aSubstTool.Copy(aLocalFace).First(); |
279 | |
280 | theMapOfChangedFaces(aFace).Append(aLocalFace); |
281 | } |
282 | } |
283 | } |
284 | // Obtain a new solid. |
285 | theNewSolid1 = aSubstTool.Copy(theNewSolid1).First(); |
286 | } |
287 | |
288 | // Update the map theMapOfChangedFaces and |
289 | // obtain a new solid from the second one. |
290 | if (aSubstTool.IsCopied(theNewSolid2)) { |
291 | // Add changed faces of the second solid to theMapOfChangedFaces: |
292 | TopExp_Explorer anExp(theNewSolid2, TopAbs_FACE); |
293 | for (; anExp.More(); anExp.Next()) { |
294 | // For each face from solid |
295 | const TopoDS_Shape &aFace = anExp.Current(); |
296 | |
297 | if (aSubstTool.IsCopied(aFace)) { |
298 | const TopTools_ListOfShape &aList = aSubstTool.Copy(aFace); |
299 | |
300 | TopTools_ListOfShape aNewList; |
301 | if (!theMapOfChangedFaces.IsBound(aFace)) |
302 | theMapOfChangedFaces.Bind(aFace, aNewList); |
303 | |
304 | TopTools_ListIteratorOfListOfShape anIter(aList); |
305 | for (; anIter.More(); anIter.Next()) { |
306 | TopoDS_Shape aLocalFace = anIter.Value(); |
307 | |
308 | if (aSubstTool.IsCopied(aLocalFace)) |
309 | aLocalFace = aSubstTool.Copy(aLocalFace).First(); |
310 | |
311 | theMapOfChangedFaces(aFace).Append(aLocalFace); |
312 | } |
313 | } |
314 | } |
315 | // Obtain a new solid. |
316 | theNewSolid2 = aSubstTool.Copy(theNewSolid2).First(); |
317 | } |
318 | |
319 | return Standard_True; |
320 | } |
321 | |
322 | //======================================================================= |
323 | //function : PerformSolidSolid |
324 | //purpose : |
325 | //======================================================================= |
326 | |
327 | void |
328 | QANewModTopOpe_Glue::PerformSDFaces() |
329 | { |
330 | TopExp_Explorer anExp; |
331 | TopoDS_Shape aS1, aS2; |
332 | Standard_Boolean aWire1 = Standard_False, aWire2 = Standard_False; |
333 | anExp.Init(myS1, TopAbs_WIRE, TopAbs_FACE); |
334 | if(anExp.More()) { |
335 | aS1 = myS1; |
336 | aWire1 = Standard_True; |
337 | } |
338 | else { |
339 | anExp.Init(myS1, TopAbs_EDGE, TopAbs_WIRE); |
340 | if(anExp.More()) { |
341 | aS1 = myS1; |
342 | aWire1 = Standard_True; |
343 | } |
344 | } |
345 | |
346 | anExp.Init(myS2, TopAbs_WIRE, TopAbs_FACE); |
347 | if(anExp.More()) { |
348 | aS2 = myS2; |
349 | aWire2 = Standard_True; |
350 | } |
351 | else { |
352 | anExp.Init(myS2, TopAbs_EDGE, TopAbs_WIRE); |
353 | if(anExp.More()) { |
354 | aS2 = myS2; |
355 | aWire2 = Standard_True; |
356 | } |
357 | } |
358 | |
359 | if(aWire1) { |
360 | BRep_Builder aBld; |
361 | myS1.Nullify(); |
362 | aBld.MakeCompound(TopoDS::Compound(myS1)); |
363 | anExp.Init(aS1, TopAbs_COMPSOLID); |
364 | for(; anExp.More(); anExp.Next()) { |
365 | aBld.Add(myS1, anExp.Current()); |
366 | } |
367 | |
368 | anExp.Init(aS1, TopAbs_SOLID, TopAbs_COMPSOLID); |
369 | for(; anExp.More(); anExp.Next()) { |
370 | aBld.Add(myS1, anExp.Current()); |
371 | } |
372 | |
373 | anExp.Init(aS1, TopAbs_SHELL, TopAbs_SOLID); |
374 | for(; anExp.More(); anExp.Next()) { |
375 | aBld.Add(myS1, anExp.Current()); |
376 | } |
377 | |
378 | anExp.Init(aS1, TopAbs_FACE, TopAbs_SHELL); |
379 | for(; anExp.More(); anExp.Next()) { |
380 | aBld.Add(myS1, anExp.Current()); |
381 | } |
382 | |
383 | } |
384 | |
385 | if(aWire2) { |
386 | BRep_Builder aBld; |
387 | myS2.Nullify(); |
388 | aBld.MakeCompound(TopoDS::Compound(myS2)); |
389 | anExp.Init(aS2, TopAbs_COMPSOLID); |
390 | for(; anExp.More(); anExp.Next()) { |
391 | aBld.Add(myS2, anExp.Current()); |
392 | } |
393 | |
394 | anExp.Init(aS2, TopAbs_SOLID, TopAbs_COMPSOLID); |
395 | for(; anExp.More(); anExp.Next()) { |
396 | aBld.Add(myS2, anExp.Current()); |
397 | } |
398 | |
399 | anExp.Init(aS2, TopAbs_SHELL, TopAbs_SOLID); |
400 | for(; anExp.More(); anExp.Next()) { |
401 | aBld.Add(myS2, anExp.Current()); |
402 | } |
403 | |
404 | anExp.Init(aS2, TopAbs_FACE, TopAbs_SHELL); |
405 | for(; anExp.More(); anExp.Next()) { |
406 | aBld.Add(myS2, anExp.Current()); |
407 | } |
408 | |
409 | } |
410 | |
411 | BRepAlgoAPI_BooleanOperation::Build(); |
412 | if (!BuilderCanWork()) |
413 | return; |
414 | |
415 | if(aWire1) myS1 = aS1; |
416 | if(aWire2) myS2 = aS2; |
417 | |
418 | myShape.Nullify(); |
419 | |
420 | TopoDS_Shape aNewShape1 = myS1; |
421 | TopoDS_Shape aNewShape2 = myS2; |
422 | TopTools_DataMapOfShapeListOfShape theMapOfChangedFaces; |
423 | |
424 | Standard_Boolean aHasSDF = Standard_False; |
425 | anExp.Init(myS1, TopAbs_FACE); |
426 | for (; anExp.More(); anExp.Next()) { |
427 | TopoDS_Shape aFirstFace = anExp.Current(); |
428 | |
429 | if (!isAnalitic(aFirstFace)) |
430 | continue; |
431 | |
4e57c75e |
432 | if (QANewModTopOpe_Tools::HasSameDomain(myBuilder, aFirstFace)) { |
7fd59977 |
433 | |
434 | if(!aHasSDF) aHasSDF = Standard_True; |
435 | |
436 | TopTools_ListOfShape aLOfSDFace; |
437 | TopTools_ListIteratorOfListOfShape anIter; |
438 | |
4e57c75e |
439 | QANewModTopOpe_Tools::SameDomain(myBuilder, aFirstFace, aLOfSDFace); |
7fd59977 |
440 | anIter.Initialize(aLOfSDFace); |
441 | |
442 | for(; anIter.More(); anIter.Next()) { |
443 | TopoDS_Shape aSecondFace = anIter.Value(); |
444 | |
445 | if (!isAnalitic(aSecondFace)) |
446 | continue; |
447 | |
448 | if (!SubstitudeSDFaces(aFirstFace, aSecondFace, |
449 | aNewShape1, aNewShape2, |
450 | theMapOfChangedFaces)) |
451 | return; |
452 | } |
453 | } |
454 | } |
455 | |
456 | if(myS1.IsSame(aNewShape1) && myS2.IsSame(aNewShape2)) return; |
457 | |
458 | if(aHasSDF) { |
459 | BRep_Builder aBuilder; |
460 | |
461 | // aBuilder.MakeCompSolid(TopoDS::CompSolid(myShape)); |
462 | aBuilder.MakeCompound(TopoDS::Compound(myShape)); |
463 | |
464 | aBuilder.Add(myShape, aNewShape1); |
465 | aBuilder.Add(myShape, aNewShape2); |
466 | |
467 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape anIter(theMapOfChangedFaces); |
468 | for(; anIter.More(); anIter.Next()) { |
469 | myMapModif.Bind(anIter.Key(), anIter.Value()); |
470 | } |
471 | |
472 | //--------------- creation myMapGener for common faces |
473 | |
474 | TopExp_Explorer anExp1, anExp2; |
475 | TopTools_MapOfShape aM; |
476 | anExp1.Init(aNewShape1, TopAbs_FACE); |
477 | for(; anExp1.More(); anExp1.Next()) { |
478 | const TopoDS_Shape& aF1 = anExp1.Current(); |
479 | anExp2.Init(aNewShape2, TopAbs_FACE); |
480 | for(; anExp2.More(); anExp2.Next()) { |
481 | const TopoDS_Shape& aF2 = anExp2.Current(); |
482 | if(aF1.IsSame(aF2)) { |
483 | aM.Add(aF1); |
484 | } |
485 | } |
486 | } |
487 | |
488 | anIter.Initialize(myMapModif); |
489 | TopTools_ListIteratorOfListOfShape anI1; |
490 | TopTools_MapIteratorOfMapOfShape anI2; |
491 | for(; anIter.More(); anIter.Next()) { |
492 | const TopoDS_Shape& aS = anIter.Key(); |
493 | if(aS.ShapeType() == TopAbs_FACE) { |
494 | anI1.Initialize(anIter.Value()); |
495 | for(; anI1.More(); anI1.Next()) { |
496 | const TopoDS_Shape& aSS1 = anI1.Value(); |
497 | anI2.Initialize(aM); |
498 | for(; anI2.More(); anI2.Next()) { |
499 | const TopoDS_Shape& aSS2 = anI2.Key(); |
500 | if(aSS1.IsSame(aSS2)) { |
501 | if(!myMapGener.IsBound(aS)) { |
502 | // for Mandrake-10 - mkv,02.06.06 - myMapGener.Bind(aS, TopTools_ListOfShape()); |
503 | TopTools_ListOfShape aListOfShape1; |
504 | myMapGener.Bind(aS, aListOfShape1); |
505 | } |
506 | myMapGener(aS).Append(aSS1); |
507 | myMapModif(aS).Remove(anI1); |
508 | } |
509 | } |
510 | if(!anI1.More()) break; |
511 | } |
512 | } |
513 | |
514 | // if(anIter.Value().Extent() == 0) myMapModif.UnBind(aS); |
515 | |
516 | } |
517 | |
518 | //--------------- creation myMapGener for common edges |
519 | |
520 | aM.Clear(); |
521 | anExp1.Init(aNewShape1, TopAbs_EDGE); |
522 | for(; anExp1.More(); anExp1.Next()) { |
523 | const TopoDS_Shape& anE1 = anExp1.Current(); |
524 | if(aM.Contains(anE1)) continue; |
525 | anExp2.Init(aNewShape2, TopAbs_EDGE); |
526 | for(; anExp2.More(); anExp2.Next()) { |
527 | const TopoDS_Shape& anE2 = anExp2.Current(); |
528 | if(aM.Contains(anE2)) continue; |
529 | if(anE1.IsSame(anE2)) { |
530 | aM.Add(anE1); |
531 | } |
532 | } |
533 | } |
534 | |
7fd59977 |
535 | TopTools_MapOfShape aComVerMap; |
536 | TopTools_MapOfShape aLocVerMap; |
537 | |
538 | anExp1.Init(myS1, TopAbs_VERTEX); |
539 | for(; anExp1.More(); anExp1.Next()) aComVerMap.Add(anExp1.Current()); |
540 | anExp1.Init(myS2, TopAbs_VERTEX); |
541 | for(; anExp1.More(); anExp1.Next()) aComVerMap.Add(anExp1.Current()); |
542 | |
c2f5c748 |
543 | TopTools_ListOfShape aShapesToRemove; // record items to be removed from the map (should be done after iteration) |
544 | anIter.Initialize(myMapModif); |
7fd59977 |
545 | for(; anIter.More(); anIter.Next()) { |
546 | const TopoDS_Shape& aS = anIter.Key(); |
547 | if(aS.ShapeType() == TopAbs_EDGE) { |
548 | aLocVerMap.Clear(); |
549 | anI1.Initialize(anIter.Value()); |
550 | for(; anI1.More(); anI1.Next()) { |
551 | const TopoDS_Shape& aSS1 = anI1.Value(); |
552 | anI2.Initialize(aM); |
553 | for(; anI2.More(); anI2.Next()) { |
554 | const TopoDS_Shape& aSS2 = anI2.Key(); |
555 | if(aSS1.IsSame(aSS2)) { |
556 | if(!aS.IsSame(aSS1)) { |
557 | if(!myMapGener.IsBound(aS)) { |
558 | // for Mandrake-10 - mkv,02.06.06 - myMapGener.Bind(aS, TopTools_ListOfShape()); |
559 | TopTools_ListOfShape aListOfShape2; |
560 | myMapGener.Bind(aS, aListOfShape2); |
561 | } |
562 | myMapGener(aS).Append(aSS1); |
563 | TopoDS_Vertex aV1, aV2; |
564 | TopExp::Vertices(TopoDS::Edge(aSS1), aV1, aV2); |
565 | if(!aComVerMap.Contains(aV1)) { |
566 | if(aLocVerMap.Add(aV1)) { |
567 | myMapGener(aS).Append(aV1); |
568 | } |
569 | } |
570 | if(!aComVerMap.Contains(aV2)) { |
571 | if(aLocVerMap.Add(aV2)) { |
572 | myMapGener(aS).Append(aV2); |
573 | } |
574 | } |
575 | myMapModif(aS).Remove(anI1); |
576 | } |
577 | else { |
c2f5c748 |
578 | aShapesToRemove.Append (aS); |
7fd59977 |
579 | } |
580 | } |
581 | } |
582 | if(!anI1.More()) break; |
583 | } |
584 | } |
7fd59977 |
585 | } |
4e57c75e |
586 | |
c2f5c748 |
587 | // remove items from the data map |
588 | for(TopTools_ListIteratorOfListOfShape anIt(aShapesToRemove); anIt.More(); anIt.Next()) |
589 | myMapModif.UnBind(anIt.Value()); |
590 | |
7fd59977 |
591 | // Deleted vertices |
592 | anExp1.Init(myShape, TopAbs_VERTEX); |
593 | for(; anExp1.More(); anExp1.Next()) { |
594 | const TopoDS_Shape& aV = anExp1.Current(); |
595 | aComVerMap.Remove(aV); |
596 | } |
597 | |
598 | anI2.Initialize(aComVerMap); |
599 | for(; anI2.More(); anI2.Next()) { |
600 | // for Mandrake-10 - mkv,02.06.06 - myMapModif.Bind(anI2.Key(), TopTools_ListOfShape()); |
601 | TopTools_ListOfShape aListOfShape3; |
602 | myMapModif.Bind(anI2.Key(), aListOfShape3); |
603 | } |
604 | |
605 | Done(); |
606 | } |
607 | |
608 | return; |
609 | |
610 | } |