Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1996-09-05 |
2 | // Created by: Yves FRICAUD | |
3 | // Copyright (c) 1996-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
7fd59977 | 17 | |
18 | #include <BRep_Builder.hxx> | |
19 | #include <BRep_Tool.hxx> | |
42cf5bc1 | 20 | #include <BRep_TVertex.hxx> |
21 | #include <BRepAlgo_AsDes.hxx> | |
42cf5bc1 | 22 | #include <BRepAlgo_Loop.hxx> |
23 | #include <BRepOffset_Analyse.hxx> | |
24 | #include <BRepOffset_MakeLoops.hxx> | |
7fd59977 | 25 | #include <TopExp.hxx> |
26 | #include <TopExp_Explorer.hxx> | |
7fd59977 | 27 | #include <TopoDS.hxx> |
7fd59977 | 28 | #include <TopoDS_Edge.hxx> |
42cf5bc1 | 29 | #include <TopoDS_Face.hxx> |
30 | #include <TopoDS_Iterator.hxx> | |
7fd59977 | 31 | #include <TopoDS_Vertex.hxx> |
32 | #include <TopTools_MapOfShape.hxx> | |
7fd59977 | 33 | |
42cf5bc1 | 34 | #include <stdio.h> |
7fd59977 | 35 | #ifdef DRAW |
36 | #include <DBRep.hxx> | |
7fd59977 | 37 | Standard_Integer NbF = 1; |
38 | static Standard_Boolean Affich = Standard_False; | |
7fd59977 | 39 | #endif |
40 | ||
7fd59977 | 41 | BRepOffset_MakeLoops::BRepOffset_MakeLoops() |
42 | { | |
43 | } | |
44 | ||
45 | //======================================================================= | |
46 | //function : Build | |
47 | //purpose : | |
48 | //======================================================================= | |
49 | ||
50 | void BRepOffset_MakeLoops::Build(const TopTools_ListOfShape& LF, | |
51 | const Handle(BRepAlgo_AsDes)& AsDes, | |
8948e18d | 52 | BRepAlgo_Image& Image, |
7c6fecf9 | 53 | BRepAlgo_Image& theImageVV, |
54 | const Message_ProgressRange& theRange) | |
7fd59977 | 55 | { |
56 | TopTools_ListIteratorOfListOfShape it(LF); | |
57 | TopTools_ListIteratorOfListOfShape itl,itLCE; | |
58 | BRepAlgo_Loop Loops; | |
59 | Loops.VerticesForSubstitute( myVerVerMap ); | |
8948e18d | 60 | Loops.SetImageVV (theImageVV); |
7c6fecf9 | 61 | Message_ProgressScope aPSOuter(theRange, NULL, 2); |
62 | Message_ProgressScope aPS1(aPSOuter.Next(), "Init loops", LF.Size()); | |
63 | for (; it.More(); it.Next(), aPS1.Next()) { | |
64 | if (!aPS1.More()) | |
65 | { | |
66 | return; | |
67 | } | |
7fd59977 | 68 | const TopoDS_Face& F = TopoDS::Face(it.Value()); |
69 | //--------------------------- | |
0d969553 | 70 | // Initialization of Loops. |
7fd59977 | 71 | //--------------------------- |
72 | Loops.Init(F); | |
73 | //----------------------------- | |
0d969553 | 74 | // return edges of F. |
7fd59977 | 75 | //----------------------------- |
76 | const TopTools_ListOfShape& LE = AsDes->Descendant(F); | |
77 | TopTools_ListOfShape AddedEdges; | |
78 | ||
79 | for (itl.Initialize(LE); itl.More(); itl.Next()) { | |
80 | TopoDS_Edge E = TopoDS::Edge(itl.Value()); | |
81 | if (Image.HasImage(E)) { | |
82 | //------------------------------------------- | |
0d969553 Y |
83 | // E was already cut in another face. |
84 | // Return the cut edges reorientate them as E. | |
85 | // See pb for the edges that have disappeared? | |
7fd59977 | 86 | //------------------------------------------- |
87 | const TopTools_ListOfShape& LCE = Image.Image(E); | |
88 | for (itLCE.Initialize(LCE); itLCE.More(); itLCE.Next()) { | |
89 | TopoDS_Shape CE = itLCE.Value().Oriented(E.Orientation()); | |
90 | Loops.AddConstEdge(TopoDS::Edge(CE)); | |
91 | } | |
92 | } | |
93 | else { | |
94 | Loops .AddEdge(E, AsDes->Descendant(E)); | |
95 | AddedEdges.Append (E); | |
96 | } | |
97 | } | |
98 | //------------------------ | |
0d969553 | 99 | // Unwind. |
7fd59977 | 100 | //------------------------ |
101 | Loops.Perform(); | |
102 | Loops.WiresToFaces(); | |
103 | //------------------------ | |
104 | // MAJ SD. | |
105 | //------------------------ | |
106 | const TopTools_ListOfShape& NF = Loops.NewFaces(); | |
107 | //----------------------- | |
0d969553 | 108 | // F => New faces; |
7fd59977 | 109 | //----------------------- |
110 | Image.Bind(F,NF); | |
111 | ||
112 | TopTools_ListIteratorOfListOfShape itAdded; | |
113 | for (itAdded.Initialize(AddedEdges); itAdded.More(); itAdded.Next()) { | |
114 | const TopoDS_Edge& E = TopoDS::Edge(itAdded.Value()); | |
115 | //----------------------- | |
0d969553 | 116 | // E => New edges; |
7fd59977 | 117 | //----------------------- |
118 | const TopTools_ListOfShape& LoopNE = Loops.NewEdges(E); | |
119 | if (Image.HasImage(E)) { | |
120 | Image.Add(E,LoopNE); | |
121 | } | |
122 | else { | |
123 | Image.Bind(E,LoopNE); | |
124 | } | |
125 | } | |
126 | } | |
127 | Loops.GetVerticesForSubstitute( myVerVerMap ); | |
128 | if (myVerVerMap.IsEmpty()) | |
129 | return; | |
130 | BRep_Builder BB; | |
7c6fecf9 | 131 | Message_ProgressScope aPS2(aPSOuter.Next(), "Building loops", LF.Size()); |
132 | for (it.Initialize(LF); it.More(); it.Next(), aPS2.Next()) | |
133 | { | |
134 | if (!aPS2.More()) | |
7fd59977 | 135 | { |
7c6fecf9 | 136 | return; |
137 | } | |
138 | TopoDS_Shape F = it.Value(); | |
139 | TopTools_ListOfShape LIF; | |
140 | Image.LastImage(F, LIF); | |
141 | for (itl.Initialize(LIF); itl.More(); itl.Next()) | |
142 | { | |
143 | const TopoDS_Shape& IF = itl.Value(); | |
144 | TopExp_Explorer EdExp(IF, TopAbs_EDGE); | |
145 | for (; EdExp.More(); EdExp.Next()) | |
146 | { | |
147 | TopoDS_Shape E = EdExp.Current(); | |
148 | TopTools_ListOfShape VList; | |
149 | TopoDS_Iterator VerExp(E); | |
150 | for (; VerExp.More(); VerExp.Next()) | |
151 | VList.Append(VerExp.Value()); | |
152 | TopTools_ListIteratorOfListOfShape itlv(VList); | |
153 | for (; itlv.More(); itlv.Next()) | |
154 | { | |
155 | const TopoDS_Shape& V = itlv.Value(); | |
156 | if (myVerVerMap.IsBound(V)) | |
157 | { | |
158 | TopoDS_Shape NewV = myVerVerMap(V); | |
159 | E.Free(Standard_True); | |
160 | NewV.Orientation(V.Orientation()); | |
161 | Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); | |
162 | Handle(BRep_TVertex)& NewTV = *((Handle(BRep_TVertex)*) &NewV.TShape()); | |
163 | if (TV->Tolerance() > NewTV->Tolerance()) | |
164 | NewTV->Tolerance(TV->Tolerance()); | |
165 | NewTV->ChangePoints().Append(TV->ChangePoints()); | |
166 | AsDes->Replace(V, NewV); | |
167 | BB.Remove(E, V); | |
168 | BB.Add(E, NewV); | |
169 | } | |
170 | } | |
171 | } | |
7fd59977 | 172 | } |
7c6fecf9 | 173 | } |
7fd59977 | 174 | } |
175 | ||
176 | //======================================================================= | |
177 | //function : IsBetweenCorks | |
178 | //purpose : | |
179 | //======================================================================= | |
180 | ||
181 | static Standard_Boolean IsBetweenCorks(const TopoDS_Shape& E, | |
182 | const Handle(BRepAlgo_AsDes)& AsDes, | |
183 | const TopTools_ListOfShape& LContext) | |
184 | { | |
185 | if (!AsDes->HasAscendant(E)) return 1; | |
186 | const TopTools_ListOfShape& LF = AsDes->Ascendant(E); | |
187 | TopTools_ListIteratorOfListOfShape it; | |
188 | for (it.Initialize(LF); it.More(); it.Next()) { | |
189 | const TopoDS_Shape& S = it.Value(); | |
190 | Standard_Boolean found = 0; | |
191 | TopTools_ListIteratorOfListOfShape it2; | |
192 | for (it2.Initialize(LContext); it2.More(); it2.Next()) { | |
193 | if(S.IsSame(it2.Value())) { | |
194 | found = 1; | |
195 | break; | |
196 | } | |
197 | } | |
198 | if (!found) return 0; | |
199 | } | |
200 | return 1; | |
201 | } | |
202 | //======================================================================= | |
203 | //function : BuildOnContext | |
204 | //purpose : | |
205 | //======================================================================= | |
206 | ||
207 | void BRepOffset_MakeLoops::BuildOnContext(const TopTools_ListOfShape& LContext, | |
7c6fecf9 | 208 | const BRepOffset_Analyse& Analyse, |
209 | const Handle(BRepAlgo_AsDes)& AsDes, | |
210 | BRepAlgo_Image& Image, | |
211 | const Standard_Boolean InSide, | |
212 | const Message_ProgressRange& theRange) | |
7fd59977 | 213 | { |
214 | //----------------------------------------- | |
0d969553 | 215 | // unwinding of caps. |
7fd59977 | 216 | //----------------------------------------- |
217 | TopTools_ListIteratorOfListOfShape it(LContext); | |
218 | TopTools_ListIteratorOfListOfShape itl,itLCE; | |
219 | BRepAlgo_Loop Loops; | |
220 | Loops.VerticesForSubstitute( myVerVerMap ); | |
221 | TopExp_Explorer exp; | |
222 | TopTools_MapOfShape MapExtent; | |
223 | ||
7c6fecf9 | 224 | Message_ProgressScope aPS(theRange, "Building deepening faces", LContext.Extent()); |
225 | for (; it.More(); it.Next(), aPS.Next()) { | |
226 | if (!aPS.More()) | |
227 | { | |
228 | return; | |
229 | } | |
7fd59977 | 230 | const TopoDS_Face& F = TopoDS::Face(it.Value()); |
231 | TopTools_MapOfShape MBound; | |
232 | //----------------------------------------------- | |
0d969553 Y |
233 | // Initialisation of Loops. |
234 | // F is reversed it will be added in myOffC. | |
235 | // and myOffC will be reversed in the final result. | |
7fd59977 | 236 | //----------------------------------------------- |
51740958 | 237 | TopoDS_Shape aReversedF = F.Reversed(); |
238 | if (InSide) Loops.Init(TopoDS::Face(aReversedF)); | |
7fd59977 | 239 | // if (InSide) Loops.Init(TopoDS::Face(F.Reversed())); |
240 | else Loops.Init(F); | |
241 | //-------------------------------------------------------- | |
0d969553 | 242 | // return edges of F not modified by definition. |
7fd59977 | 243 | //-------------------------------------------------------- |
244 | for (exp.Init(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE); | |
245 | exp.More(); | |
246 | exp.Next()) { | |
247 | TopoDS_Edge CE = TopoDS::Edge(exp.Current()); | |
248 | MBound.Add(CE); | |
249 | if (Analyse.HasAncestor(CE)) { | |
0d969553 | 250 | // the stop of cups except for the connectivity stops between caps. |
7fd59977 | 251 | // if (!AsDes->HasAscendant(CE)) { |
51740958 | 252 | TopoDS_Shape aReversedE = CE.Reversed(); |
7fd59977 | 253 | if (InSide) Loops.AddConstEdge(CE); |
51740958 | 254 | else Loops.AddConstEdge(TopoDS::Edge(aReversedE)); |
7fd59977 | 255 | // else Loops.AddConstEdge(TopoDS::Edge(CE.Reversed())); |
256 | } | |
257 | } | |
258 | //------------------------------------------------------ | |
0d969553 | 259 | // Trace of offsets + connectivity edge between caps. |
7fd59977 | 260 | //------------------------------------------------------ |
261 | const TopTools_ListOfShape& LE = AsDes->Descendant(F); | |
262 | TopTools_ListOfShape AddedEdges; | |
263 | ||
264 | for (itl.Initialize(LE); itl.More(); itl.Next()) { | |
265 | TopoDS_Edge E = TopoDS::Edge(itl.Value()); | |
266 | if (Image.HasImage(E)) { | |
267 | //------------------------------------------- | |
0d969553 Y |
268 | // E was already cut in another face. |
269 | // Return cut edges and orientate them as E. | |
270 | // See pb for the edges that have disappeared? | |
7fd59977 | 271 | //------------------------------------------- |
272 | const TopTools_ListOfShape& LCE = Image.Image(E); | |
273 | for (itLCE.Initialize(LCE); itLCE.More(); itLCE.Next()) { | |
274 | TopoDS_Shape CE = itLCE.Value().Oriented(E.Orientation()); | |
275 | if (MapExtent.Contains(E)) { | |
276 | Loops.AddConstEdge(TopoDS::Edge(CE)); | |
277 | continue; | |
278 | } | |
279 | if (!MBound.Contains(E)) CE.Reverse(); | |
280 | if (InSide) Loops.AddConstEdge(TopoDS::Edge(CE)); | |
281 | else | |
282 | { | |
51740958 | 283 | TopoDS_Shape aReversedE = CE.Reversed(); |
284 | Loops.AddConstEdge(TopoDS::Edge(aReversedE)); | |
7fd59977 | 285 | } |
286 | // else Loops.AddConstEdge(TopoDS::Edge(CE.Reversed())); | |
287 | } | |
288 | } | |
289 | else { | |
290 | if (IsBetweenCorks(E,AsDes,LContext) && AsDes->HasDescendant(E)) { | |
0d969553 | 291 | //connection between 2 caps |
7fd59977 | 292 | MapExtent.Add(E); |
293 | TopTools_ListOfShape LV; | |
294 | if (InSide) { | |
295 | for (itLCE.Initialize(AsDes->Descendant(E)); itLCE.More(); itLCE.Next()) { | |
296 | LV.Append(itLCE.Value().Reversed()); | |
297 | } | |
298 | Loops.AddEdge(E,LV); | |
299 | } | |
300 | else { | |
301 | Loops.AddEdge(E,AsDes->Descendant(E)); | |
302 | } | |
303 | AddedEdges.Append (E); | |
304 | } | |
305 | else if (IsBetweenCorks(E,AsDes,LContext)) { | |
306 | TopoDS_Shape aLocalShape = E.Reversed(); | |
307 | if (InSide) Loops.AddConstEdge(E); | |
308 | else Loops.AddConstEdge(TopoDS::Edge(aLocalShape)); | |
309 | // if (InSide) Loops.AddConstEdge(TopoDS::Edge(E)); | |
310 | // else Loops.AddConstEdge(TopoDS::Edge(E.Reversed())); | |
311 | } | |
312 | else { | |
313 | TopoDS_Shape aLocalShape = E.Reversed(); | |
314 | if (InSide) Loops.AddConstEdge(TopoDS::Edge(aLocalShape)); | |
315 | else Loops.AddConstEdge(E); | |
316 | // if (InSide) Loops.AddConstEdge(TopoDS::Edge(E.Reversed())); | |
317 | // else Loops.AddConstEdge(TopoDS::Edge(E)); | |
318 | } | |
319 | } | |
320 | } | |
321 | //------------------------ | |
0d969553 | 322 | // Unwind. |
7fd59977 | 323 | //------------------------ |
324 | Loops.Perform(); | |
325 | Loops.WiresToFaces(); | |
326 | //------------------------ | |
327 | // MAJ SD. | |
328 | //------------------------ | |
329 | const TopTools_ListOfShape& NF = Loops.NewFaces(); | |
330 | //----------------------- | |
0d969553 | 331 | // F => New faces; |
7fd59977 | 332 | //----------------------- |
333 | Image.Bind(F,NF); | |
334 | ||
335 | TopTools_ListIteratorOfListOfShape itAdded; | |
336 | for (itAdded.Initialize(AddedEdges); itAdded.More(); itAdded.Next()) { | |
337 | const TopoDS_Edge& E = TopoDS::Edge(itAdded.Value()); | |
338 | //----------------------- | |
0d969553 | 339 | // E => New edges; |
7fd59977 | 340 | //----------------------- |
341 | if (Image.HasImage(E)) { | |
342 | Image.Add(E,Loops.NewEdges(E)); | |
343 | } | |
344 | else { | |
345 | Image.Bind(E,Loops.NewEdges(E)); | |
346 | } | |
347 | } | |
348 | } | |
349 | Loops.GetVerticesForSubstitute( myVerVerMap ); | |
350 | if (myVerVerMap.IsEmpty()) | |
351 | return; | |
352 | BRep_Builder BB; | |
353 | for (it.Initialize( LContext ); it.More(); it.Next()) | |
354 | { | |
355 | TopoDS_Shape F = it.Value(); | |
356 | TopTools_ListOfShape LIF; | |
357 | Image.LastImage( F, LIF ); | |
358 | for (itl.Initialize(LIF); itl.More(); itl.Next()) | |
359 | { | |
360 | const TopoDS_Shape& IF = itl.Value(); | |
361 | TopExp_Explorer EdExp( IF, TopAbs_EDGE ); | |
362 | for (; EdExp.More(); EdExp.Next()) | |
363 | { | |
364 | TopoDS_Shape E = EdExp.Current(); | |
365 | TopTools_ListOfShape VList; | |
366 | TopoDS_Iterator VerExp( E ); | |
367 | for (; VerExp.More(); VerExp.Next()) | |
368 | VList.Append( VerExp.Value() ); | |
369 | TopTools_ListIteratorOfListOfShape itlv( VList ); | |
370 | for (; itlv.More(); itlv.Next()) | |
371 | { | |
372 | const TopoDS_Shape& V = itlv.Value(); | |
373 | if (myVerVerMap.IsBound( V )) | |
374 | { | |
375 | TopoDS_Shape NewV = myVerVerMap( V ); | |
376 | E.Free( Standard_True ); | |
377 | NewV.Orientation( V.Orientation() ); | |
378 | Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); | |
379 | Handle(BRep_TVertex)& NewTV = *((Handle(BRep_TVertex)*) &NewV.TShape()); | |
380 | if (TV->Tolerance() > NewTV->Tolerance()) | |
381 | NewTV->Tolerance( TV->Tolerance() ); | |
382 | NewTV->ChangePoints().Append( TV->ChangePoints() ); | |
383 | AsDes->Replace( V, NewV ); | |
384 | BB.Remove( E, V ); | |
385 | BB.Add( E, NewV ); | |
386 | } | |
387 | } | |
388 | } | |
389 | } | |
390 | } | |
391 | } | |
392 | ||
393 | ||
394 | //======================================================================= | |
395 | //function : BuildFaces | |
396 | //purpose : | |
397 | //======================================================================= | |
398 | ||
399 | void BRepOffset_MakeLoops::BuildFaces(const TopTools_ListOfShape& LF, | |
400 | const Handle(BRepAlgo_AsDes)& AsDes, | |
7c6fecf9 | 401 | BRepAlgo_Image& Image, |
402 | const Message_ProgressRange& theRange) | |
7fd59977 | 403 | { |
404 | TopTools_ListIteratorOfListOfShape itr,itl,itLCE; | |
405 | Standard_Boolean ToRebuild; | |
406 | BRepAlgo_Loop Loops; | |
407 | Loops.VerticesForSubstitute( myVerVerMap ); | |
408 | BRep_Builder B; | |
409 | ||
410 | //---------------------------------- | |
0d969553 | 411 | // Loop on all faces //. |
7fd59977 | 412 | //---------------------------------- |
7c6fecf9 | 413 | Message_ProgressScope aPS(theRange, "Building faces", LF.Size()); |
414 | for (itr.Initialize(LF); itr.More(); itr.Next(), aPS.Next()) { | |
415 | if (!aPS.More()) | |
416 | { | |
417 | return; | |
418 | } | |
7fd59977 | 419 | TopoDS_Face F = TopoDS::Face(itr.Value()); |
420 | Loops.Init(F); | |
421 | ToRebuild = Standard_False; | |
422 | TopTools_ListOfShape AddedEdges; | |
423 | ||
424 | if (!Image.HasImage(F)) { | |
425 | //---------------------------------- | |
0d969553 | 426 | // Face F not yet reconstructed. |
7fd59977 | 427 | //---------------------------------- |
428 | const TopTools_ListOfShape& LE = AsDes->Descendant(F); | |
429 | //---------------------------------------------------------------- | |
0d969553 Y |
430 | // first loop to find if the edges of the face were reconstructed. |
431 | // - maj on map MONV. Some vertices on reconstructed edges | |
432 | // coincide geometrically with old but are not IsSame. | |
7fd59977 | 433 | //---------------------------------------------------------------- |
434 | TopTools_DataMapOfShapeShape MONV; | |
435 | TopoDS_Vertex OV1,OV2,NV1,NV2; | |
436 | ||
437 | for (itl.Initialize(LE); itl.More(); itl.Next()) { | |
438 | TopoDS_Edge E = TopoDS::Edge(itl.Value()); | |
439 | if (Image.HasImage(E)) { | |
440 | const TopTools_ListOfShape& LCE = Image.Image(E); | |
441 | if (LCE.Extent() == 1 && LCE.First().IsSame(E)) { | |
442 | TopoDS_Shape aLocalShape = LCE.First().Oriented(E.Orientation()); | |
443 | TopoDS_Edge CE = TopoDS::Edge(aLocalShape); | |
444 | // TopoDS_Edge CE = TopoDS::Edge(LCE.First().Oriented(E.Orientation())); | |
445 | Loops.AddConstEdge(CE); | |
446 | continue; | |
447 | } | |
448 | //---------------------------------- | |
0d969553 | 449 | // F should be reconstructed. |
7fd59977 | 450 | //---------------------------------- |
451 | ToRebuild = Standard_True; | |
452 | for (itLCE.Initialize(LCE); itLCE.More(); itLCE.Next()) { | |
453 | TopoDS_Shape aLocalShape = itLCE.Value().Oriented(E.Orientation()); | |
454 | TopoDS_Edge CE = TopoDS::Edge(aLocalShape); | |
455 | // TopoDS_Edge CE = TopoDS::Edge(itLCE.Value().Oriented(E.Orientation())); | |
456 | TopExp::Vertices (E ,OV1,OV2); | |
457 | TopExp::Vertices (CE,NV1,NV2); | |
458 | if (!OV1.IsSame(NV1)) MONV.Bind(OV1,NV1); | |
459 | if (!OV2.IsSame(NV2)) MONV.Bind(OV2,NV2); | |
460 | Loops.AddConstEdge(CE); | |
461 | } | |
462 | } | |
463 | } | |
464 | if (ToRebuild) { | |
465 | #ifdef DRAW | |
7fd59977 | 466 | if ( Affich) { |
1896126e | 467 | char name[256]; |
7fd59977 | 468 | sprintf(name,"CF_%d",NbF++); |
469 | DBRep::Set(name,F); | |
470 | } | |
471 | #endif | |
472 | ||
473 | //----------------------------------------------------------- | |
0d969553 Y |
474 | // Non-reconstructed edges on other faces are added. |
475 | // If their vertices were reconstructed they are reconstructed. | |
7fd59977 | 476 | //----------------------------------------------------------- |
477 | for (itl.Initialize(LE); itl.More(); itl.Next()) { | |
478 | Standard_Real f,l; | |
479 | TopoDS_Edge E = TopoDS::Edge(itl.Value()); | |
480 | BRep_Tool::Range(E,f,l); | |
481 | if (!Image.HasImage(E)) { | |
482 | TopExp::Vertices (E,OV1,OV2); | |
483 | TopTools_ListOfShape LV; | |
484 | if (MONV.IsBound(OV1)) { | |
485 | TopoDS_Vertex VV = TopoDS::Vertex(MONV(OV1)); | |
486 | VV.Orientation(TopAbs_FORWARD); | |
487 | LV.Append(VV); | |
488 | TopoDS_Shape aLocalShape = VV.Oriented(TopAbs_INTERNAL); | |
489 | B.UpdateVertex(TopoDS::Vertex(aLocalShape), | |
490 | f,E,BRep_Tool::Tolerance(VV)); | |
491 | } | |
492 | if (MONV.IsBound(OV2)) { | |
493 | TopoDS_Vertex VV = TopoDS::Vertex(MONV(OV2)); | |
494 | VV.Orientation(TopAbs_REVERSED); | |
495 | LV.Append(VV); | |
496 | TopoDS_Shape aLocalShape = VV.Oriented(TopAbs_INTERNAL); | |
497 | B.UpdateVertex(TopoDS::Vertex(aLocalShape), | |
498 | l,E,BRep_Tool::Tolerance(VV)); | |
499 | // B.UpdateVertex(TopoDS::Vertex(VV.Oriented(TopAbs_INTERNAL)), | |
500 | // l,E,BRep_Tool::Tolerance(VV)); | |
501 | } | |
502 | if (LV.IsEmpty()) Loops.AddConstEdge(E); | |
503 | else { | |
504 | Loops.AddEdge (E,LV); | |
505 | AddedEdges.Append(E); | |
506 | } | |
507 | } | |
508 | } | |
509 | } | |
510 | } | |
511 | if (ToRebuild) { | |
512 | //------------------------ | |
513 | // Reconstruction. | |
514 | //------------------------ | |
515 | Loops.Perform(); | |
516 | Loops.WiresToFaces(); | |
517 | //------------------------ | |
518 | // MAJ SD. | |
519 | //------------------------ | |
520 | const TopTools_ListOfShape& NF = Loops.NewFaces(); | |
521 | //----------------------- | |
0d969553 | 522 | // F => New faces; |
7fd59977 | 523 | //----------------------- |
524 | Image.Bind(F,NF); | |
525 | ||
526 | TopTools_ListIteratorOfListOfShape itAdded; | |
527 | for (itAdded.Initialize(AddedEdges); itAdded.More(); itAdded.Next()) { | |
528 | const TopoDS_Edge& E = TopoDS::Edge(itAdded.Value()); | |
529 | //----------------------- | |
0d969553 | 530 | // E => New edges; |
7fd59977 | 531 | //----------------------- |
532 | if (Image.HasImage(E)) { | |
533 | Image.Add(E,Loops.NewEdges(E)); | |
534 | } | |
535 | else { | |
536 | Image.Bind(E,Loops.NewEdges(E)); | |
537 | } | |
538 | } | |
539 | } | |
540 | } | |
541 | Loops.GetVerticesForSubstitute( myVerVerMap ); | |
542 | if (myVerVerMap.IsEmpty()) | |
543 | return; | |
544 | BRep_Builder BB; | |
545 | for (itr.Initialize( LF ); itr.More(); itr.Next()) | |
546 | { | |
547 | TopoDS_Shape F = itr.Value(); | |
548 | TopTools_ListOfShape LIF; | |
549 | Image.LastImage( F, LIF ); | |
550 | for (itl.Initialize(LIF); itl.More(); itl.Next()) | |
551 | { | |
552 | const TopoDS_Shape& IF = itl.Value(); | |
553 | TopExp_Explorer EdExp( IF, TopAbs_EDGE ); | |
554 | for (; EdExp.More(); EdExp.Next()) | |
555 | { | |
556 | TopoDS_Shape E = EdExp.Current(); | |
557 | TopTools_ListOfShape VList; | |
558 | TopoDS_Iterator VerExp( E ); | |
559 | for (; VerExp.More(); VerExp.Next()) | |
560 | VList.Append( VerExp.Value() ); | |
561 | TopTools_ListIteratorOfListOfShape itlv( VList ); | |
562 | for (; itlv.More(); itlv.Next()) | |
563 | { | |
564 | const TopoDS_Shape& V = itlv.Value(); | |
565 | if (myVerVerMap.IsBound( V )) | |
566 | { | |
567 | TopoDS_Shape NewV = myVerVerMap( V ); | |
568 | E.Free( Standard_True ); | |
569 | NewV.Orientation( V.Orientation() ); | |
570 | Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape()); | |
571 | Handle(BRep_TVertex)& NewTV = *((Handle(BRep_TVertex)*) &NewV.TShape()); | |
572 | if (TV->Tolerance() > NewTV->Tolerance()) | |
573 | NewTV->Tolerance( TV->Tolerance() ); | |
574 | NewTV->ChangePoints().Append( TV->ChangePoints() ); | |
575 | AsDes->Replace( V, NewV ); | |
576 | BB.Remove( E, V ); | |
577 | BB.Add( E, NewV ); | |
578 | } | |
579 | } | |
580 | } | |
581 | } | |
582 | } | |
583 | } |