Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-08-13 |
2 | // Created by: Prestataire Mary FABIEN | |
3 | // Copyright (c) 1997-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 | |
42cf5bc1 | 18 | #include <BRepAlgo_BooleanOperations.hxx> |
19 | #include <BRepAlgo_DSAccess.hxx> | |
20 | #include <BRepAlgo_EdgeConnector.hxx> | |
7fd59977 | 21 | #include <TColStd_IndexedMapOfInteger.hxx> |
42cf5bc1 | 22 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
23 | #include <TColStd_ListOfInteger.hxx> | |
7fd59977 | 24 | #include <TColStd_MapIteratorOfMapOfInteger.hxx> |
54f7544d | 25 | #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx> |
42cf5bc1 | 26 | #include <TColStd_MapOfInteger.hxx> |
7fd59977 | 27 | #include <TopoDS.hxx> |
28 | #include <TopoDS_Compound.hxx> | |
42cf5bc1 | 29 | #include <TopoDS_Shape.hxx> |
30 | #include <TopoDS_Vertex.hxx> | |
7fd59977 | 31 | #include <TopoDS_Wire.hxx> |
42cf5bc1 | 32 | #include <TopOpeBRep_DSFiller.hxx> |
33 | #include <TopOpeBRepBuild_FaceBuilder.hxx> | |
34 | #include <TopOpeBRepBuild_HBuilder.hxx> | |
35 | #include <TopOpeBRepBuild_WireEdgeSet.hxx> | |
7fd59977 | 36 | #include <TopOpeBRepDS_BuildTool.hxx> |
7fd59977 | 37 | #include <TopOpeBRepDS_Check.hxx> |
42cf5bc1 | 38 | #include <TopOpeBRepDS_CheckStatus.hxx> |
7fd59977 | 39 | #include <TopOpeBRepDS_CurveExplorer.hxx> |
40 | #include <TopOpeBRepDS_CurveIterator.hxx> | |
41 | #include <TopOpeBRepDS_Filter.hxx> | |
42cf5bc1 | 42 | #include <TopOpeBRepDS_HDataStructure.hxx> |
43 | #include <TopOpeBRepDS_Interference.hxx> | |
44 | #include <TopOpeBRepDS_InterferenceIterator.hxx> | |
45 | #include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx> | |
46 | #include <TopOpeBRepDS_ListOfInterference.hxx> | |
47 | #include <TopOpeBRepDS_PointIterator.hxx> | |
7fd59977 | 48 | #include <TopOpeBRepDS_Reducer.hxx> |
42cf5bc1 | 49 | #include <TopOpeBRepDS_ShapeShapeInterference.hxx> |
7fd59977 | 50 | #include <TopOpeBRepTool_GeomTool.hxx> |
42cf5bc1 | 51 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
52 | #include <TopTools_ListOfShape.hxx> | |
53 | #include <TopTools_MapOfShape.hxx> | |
7fd59977 | 54 | |
7fd59977 | 55 | |
56 | //======================================================================= | |
57 | //function : Create | |
58 | //purpose : | |
59 | //======================================================================= | |
60 | ||
61 | BRepAlgo_DSAccess::BRepAlgo_DSAccess() { | |
62 | Init(); | |
63 | } | |
64 | ||
65 | //======================================================================= | |
66 | //function : Init | |
67 | //purpose : | |
68 | //======================================================================= | |
69 | ||
70 | void BRepAlgo_DSAccess::Init() | |
71 | { | |
72 | if(myHDS.IsNull()) | |
73 | myHDS = new TopOpeBRepDS_HDataStructure(); | |
74 | else | |
75 | myHDS->ChangeDS().Init(); | |
76 | myRecomputeBuilderIsDone = Standard_False; | |
77 | myGetSectionIsDone = Standard_False; | |
78 | myListOfCompoundOfEdgeConnected.Clear(); | |
79 | myEC = new BRepAlgo_EdgeConnector(); | |
80 | myHB.Nullify(); | |
81 | ||
82 | // init of the builder | |
83 | Standard_Real tol3dAPPROX = 1e-7; | |
84 | Standard_Real tol2dAPPROX = 1e-7; | |
85 | // set tolerance values used by the APPROX process | |
86 | TopOpeBRepTool_GeomTool GT; | |
87 | GT.Define(TopOpeBRepTool_APPROX); | |
88 | GT.SetTolerances(tol3dAPPROX,tol2dAPPROX); | |
89 | TopOpeBRepDS_BuildTool BT(GT); | |
90 | myHB = new TopOpeBRepBuild_HBuilder(BT); | |
91 | myHB->ChangeBuilder().ChangeClassify(Standard_False); | |
92 | ||
93 | myState1 = TopAbs_UNKNOWN; | |
94 | myState2 = TopAbs_UNKNOWN; | |
95 | ||
96 | } | |
97 | ||
98 | ||
99 | // Filling of the DS | |
100 | ||
101 | //======================================================================= | |
102 | //function : Load | |
103 | //purpose : | |
104 | //======================================================================= | |
105 | ||
106 | void BRepAlgo_DSAccess::Load(const TopoDS_Shape& S) | |
107 | { | |
108 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
109 | myS1 = S; | |
110 | DS.AddShape(S, 1); | |
111 | } | |
112 | ||
113 | //======================================================================= | |
114 | //function : Load | |
115 | //purpose : | |
116 | //======================================================================= | |
117 | ||
118 | void BRepAlgo_DSAccess::Load(TopoDS_Shape& S1, | |
119 | TopoDS_Shape& S2) | |
120 | { | |
121 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
122 | ||
123 | if ( S1.Orientation() == TopAbs_REVERSED ) { | |
124 | S1.Orientation(TopAbs_FORWARD); | |
125 | } | |
126 | if ( S2.Orientation() == TopAbs_REVERSED ) { | |
127 | S2.Orientation(TopAbs_FORWARD); | |
128 | } | |
129 | ||
130 | DS.AddShape(S1,1); | |
131 | DS.AddShape(S2,2); | |
132 | ||
133 | TopOpeBRepTool_ShapeExplorer ex1,ex2; | |
134 | for (ex1.Init(S1,TopAbs_SOLID); ex1.More(); ex1.Next()) { | |
135 | const TopoDS_Shape& so1 = ex1.Current(); | |
136 | for (ex2.Init(S2,TopAbs_SOLID); ex2.More(); ex2.Next()) { | |
137 | const TopoDS_Shape& so2 = ex2.Current(); | |
138 | DS.FillShapesSameDomain(so1,so2); | |
139 | } | |
140 | } | |
141 | ||
142 | myS1 = S1; | |
143 | myS2 = S2; | |
144 | ||
7fd59977 | 145 | } |
146 | ||
147 | //======================================================================= | |
148 | //function : Intersect | |
149 | //purpose : | |
150 | //======================================================================= | |
151 | ||
152 | void BRepAlgo_DSAccess::Intersect() | |
153 | { | |
154 | myRecomputeBuilderIsDone = Standard_False; | |
155 | ||
156 | if(!myS1.IsNull() && !myS2.IsNull()) | |
157 | myDSFiller.Insert(myS1, myS2, myHDS); | |
158 | } | |
159 | ||
160 | //======================================================================= | |
161 | //function : Intersect | |
162 | //purpose : | |
163 | //======================================================================= | |
164 | ||
165 | void BRepAlgo_DSAccess::Intersect | |
166 | (const TopoDS_Shape& S1, | |
167 | const TopoDS_Shape& S2) | |
168 | { | |
169 | myRecomputeBuilderIsDone = Standard_False; | |
170 | ||
171 | if(S1.IsNull() || S2.IsNull()) { | |
172 | return; | |
173 | } | |
174 | ||
175 | Standard_Boolean orientFORWARD = Standard_False; | |
176 | TopExp_Explorer exp; | |
177 | if(S1.ShapeType() != TopAbs_FACE) { | |
178 | exp.Init(S1, TopAbs_FACE); | |
179 | if(!exp.More()) | |
180 | return; | |
181 | } | |
182 | if(S2.ShapeType() != TopAbs_FACE) { | |
183 | exp.Init(S2, TopAbs_FACE); | |
184 | if(!exp.More()) | |
185 | return; | |
186 | } | |
187 | myDSFiller.Insert(S1, S2, myHDS, orientFORWARD); | |
188 | } | |
189 | ||
190 | //======================================================================= | |
191 | //function : SameDomain | |
192 | //purpose : | |
193 | //======================================================================= | |
194 | ||
195 | void BRepAlgo_DSAccess::SameDomain | |
196 | (const TopoDS_Shape& S1, | |
197 | const TopoDS_Shape& S2) | |
198 | { | |
199 | myRecomputeBuilderIsDone = Standard_False; | |
200 | ||
201 | if(S1.IsNull() || S2.IsNull()) | |
202 | return; | |
203 | ||
204 | TopExp_Explorer exp1, exp2; | |
205 | exp1.Init(S1, TopAbs_FACE); | |
206 | if(!exp1.More()) | |
207 | return; | |
208 | exp2.Init(S2, TopAbs_FACE); | |
209 | if(!exp2.More()) | |
210 | return; | |
211 | ||
212 | myDSFiller.Insert2d(S1, S2, myHDS); | |
213 | } | |
214 | ||
215 | ||
216 | // Construction of Sections | |
217 | ||
218 | #define FindKeep Standard_False | |
219 | ||
220 | //======================================================================= | |
221 | //function : GetSectionEdgeSet | |
222 | //purpose : | |
223 | //======================================================================= | |
224 | ||
225 | const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet | |
226 | (const TopoDS_Shape& S1, | |
227 | const TopoDS_Shape& S2) | |
228 | { | |
229 | GetSectionEdgeSet(); | |
230 | ||
231 | // Check if S1 and S2 contain faces | |
232 | TopExp_Explorer exp1, exp2; | |
233 | exp1.Init(S1, TopAbs_FACE); | |
234 | if(!exp1.More()) | |
235 | return myEmptyListOfShape; | |
236 | exp2.Init(S2, TopAbs_FACE); | |
237 | if(!exp2.More()) | |
238 | return myEmptyListOfShape; | |
239 | ||
240 | for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) { | |
241 | if(!myHDS->HasShape(exp1.Current(), FindKeep)) | |
242 | return myEmptyListOfShape; | |
243 | } | |
244 | for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next()) | |
245 | if(!myHDS->HasShape(exp2.Current(), FindKeep)) | |
246 | return myEmptyListOfShape; | |
247 | ||
248 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
249 | TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder(); | |
250 | ||
251 | // The purpose is to find interferences associated with faces, | |
252 | // edges that come from their Geometry (= Edge || Curve) | |
253 | TopTools_ListOfShape LE; | |
254 | LE.Clear(); | |
255 | TopExp_Explorer exp; | |
256 | for(exp1.Init(S1, TopAbs_FACE); exp1.More(); exp1.Next()) { | |
257 | const TopoDS_Shape& F1 = exp1.Current(); | |
258 | ||
259 | TopOpeBRepDS_ListOfInterference& lof = DS.ChangeShapeInterferences(F1); | |
260 | TopOpeBRepDS_InterferenceIterator li(lof); | |
261 | li.SupportKind(TopOpeBRepDS_FACE); | |
262 | for(exp2.Init(S2, TopAbs_FACE); exp2.More(); exp2.Next()) { | |
263 | const TopoDS_Shape& F2 = exp2.Current(); | |
264 | Standard_Integer si = DS.Shape(F2, FindKeep); | |
265 | li.Support(si); | |
266 | ||
267 | for(; li.More(); li.Next()) { | |
268 | const TopOpeBRepDS_Interference& CurrInt = li.Value(); | |
269 | TopOpeBRepDS_Kind gk = CurrInt.GeometryType(); | |
270 | Standard_Integer gi = CurrInt.Geometry(); | |
271 | const TopoDS_Shape& geosha = DS.Shape(gi, FindKeep); | |
272 | if(gk == TopOpeBRepDS_CURVE) { | |
273 | const TopTools_ListOfShape& lEdge = myHB->NewEdges(gi); | |
274 | LE.Append(lEdge.First()); | |
275 | } else { | |
276 | const TopTools_ListOfShape& lEdge = Builder.Splits(geosha, TopAbs_ON); | |
277 | TopTools_ListIteratorOfListOfShape it(lEdge); | |
278 | for(; it.More(); it.Next()) { | |
279 | const TopoDS_Shape& CurrEdge = it.Value(); | |
280 | Standard_Integer ipv1, ipv2; | |
281 | TopOpeBRepDS_Kind pvk1, pvk2; | |
282 | PntVtxOnSectEdge(CurrEdge, ipv1, pvk1, ipv2, pvk2); | |
283 | if(pvk1 != TopOpeBRepDS_VERTEX) { | |
284 | ipv1 = 0; | |
285 | if(pvk2 != TopOpeBRepDS_VERTEX) continue; | |
286 | } else { | |
287 | if(pvk2 != TopOpeBRepDS_VERTEX) | |
288 | ipv2 = 0; | |
289 | } | |
290 | for(exp.Init(F1, TopAbs_VERTEX); exp.More(); exp.Next()) { | |
291 | Standard_Integer iVert = DS.Shape(exp.Current()); | |
292 | if(iVert) { | |
293 | if((iVert == ipv1) || (iVert == ipv2)) { | |
294 | LE.Append(CurrEdge); | |
295 | break; | |
296 | } | |
297 | } | |
298 | } | |
299 | } | |
300 | } | |
301 | } | |
302 | } | |
303 | } | |
304 | ||
305 | // find all groups of connected Edges associated to LE | |
306 | TopTools_ListIteratorOfListOfShape ILE; | |
307 | myCurrentList.Clear(); | |
308 | TopTools_MapOfShape ME; | |
309 | ME.Clear(); | |
310 | TopTools_ListIteratorOfListOfShape ILC; | |
311 | TopExp_Explorer ECE; | |
312 | ILE.Initialize(LE); | |
313 | for(;ILE.More();ILE.Next()) { | |
314 | const TopoDS_Shape& E = ILE.Value(); | |
315 | ILC.Initialize(myListOfCompoundOfEdgeConnected); | |
316 | for(;ILC.More();ILC.Next()) { | |
317 | const TopoDS_Shape& Com = ILC.Value(); | |
318 | ECE.Init(Com, TopAbs_EDGE); | |
319 | for(;ECE.More();ECE.Next()) { | |
320 | if(ECE.Current().IsSame(E)) { | |
321 | if(!ME.Contains(Com)) { | |
322 | myCurrentList.Append(Com); | |
323 | ME.Add(Com); | |
324 | break; | |
325 | } | |
326 | } | |
327 | } | |
328 | } | |
329 | } | |
330 | ||
331 | return myCurrentList; | |
332 | } | |
333 | ||
334 | //======================================================================= | |
335 | //function : GetSectionEdgeSet | |
336 | //purpose : | |
337 | //======================================================================= | |
338 | ||
339 | const TopTools_ListOfShape& BRepAlgo_DSAccess::GetSectionEdgeSet() | |
340 | { | |
341 | if(!myRecomputeBuilderIsDone) { | |
342 | // it is possible to call the method many times consecutively | |
343 | myHDS->AddAncestors(myS1); | |
344 | // start of lpa modification | |
345 | if (!myS1.IsSame(myS2) && !myS2.IsNull()) { | |
346 | myHDS->AddAncestors(myS2); | |
347 | myHB->Perform(myHDS,myS1,myS2); | |
348 | } | |
349 | else { | |
350 | myHB->Perform(myHDS); | |
351 | } | |
352 | // end of modif lpa | |
353 | myRecomputeBuilderIsDone = Standard_True; | |
354 | myGetSectionIsDone = Standard_False; | |
355 | } | |
356 | if(myGetSectionIsDone) | |
357 | return myListOfCompoundOfEdgeConnected; | |
358 | myGetSectionIsDone = Standard_True; | |
359 | ||
360 | myListOfCompoundOfEdgeConnected.Clear(); | |
361 | ||
362 | // EdgeConnector | |
363 | Handle(BRepAlgo_EdgeConnector) EC = myEC; | |
364 | EC->ClearStartElement(); | |
365 | TopTools_MapOfShape ME; | |
366 | ME.Clear(); | |
367 | myHB->InitSection(); | |
368 | for(; myHB->MoreSection(); myHB->NextSection()) { | |
369 | const TopoDS_Edge& ES = TopoDS::Edge(myHB->CurrentSection()); | |
370 | if(ME.Contains(ES)) continue; | |
371 | ME.Add(ES); | |
372 | EC->AddStart(ES); | |
373 | } | |
374 | TopTools_ListOfShape& LW = EC->MakeBlock(); | |
375 | ||
376 | // the wires are tranformed into compounds. | |
377 | myCompoundWireMap.Clear(); | |
378 | BRep_Builder BB; | |
379 | TopTools_ListIteratorOfListOfShape ILW(LW); | |
380 | TopExp_Explorer Explor; | |
381 | for(;ILW.More();ILW.Next()) { | |
382 | TopoDS_Compound Compound; | |
383 | //POP | |
384 | BB.MakeCompound(Compound); | |
385 | // BB.MakeCompound(TopoDS::Compound(Compound)); | |
386 | Explor.Init(ILW.Value(), TopAbs_EDGE); | |
387 | for(;Explor.More(); Explor.Next()) { | |
388 | BB.Add(Compound, Explor.Current()); | |
389 | } | |
390 | myListOfCompoundOfEdgeConnected.Append(Compound); | |
391 | myCompoundWireMap.Bind(Compound,ILW.Value()); | |
392 | } | |
393 | return myListOfCompoundOfEdgeConnected; | |
394 | } | |
395 | ||
396 | //======================================================================= | |
397 | //function : IsWire | |
398 | //purpose : | |
399 | //======================================================================= | |
400 | ||
401 | Standard_Boolean BRepAlgo_DSAccess::IsWire(const TopoDS_Shape& S) | |
402 | { | |
403 | Standard_Boolean b = Standard_False; | |
404 | if(myEC->IsDone()) { | |
405 | if (myCompoundWireMap.IsBound(S)) | |
406 | b = myEC->IsWire(myCompoundWireMap(S)); | |
407 | } | |
408 | return b; | |
409 | } | |
410 | ||
411 | //======================================================================= | |
412 | //function : Wire | |
413 | //purpose : | |
414 | //======================================================================= | |
415 | ||
416 | const TopoDS_Shape& BRepAlgo_DSAccess::Wire(const TopoDS_Shape& S) | |
417 | { | |
418 | if(!IsWire(S)) { | |
419 | myWire.Nullify(); | |
420 | } | |
421 | else { | |
422 | BRep_Builder BB; | |
423 | BB.MakeWire(myWire); | |
424 | TopExp_Explorer Explor(S, TopAbs_EDGE); | |
425 | for(;Explor.More(); Explor.Next()) BB.Add(myWire, Explor.Current()); | |
426 | } | |
427 | return myWire; | |
428 | } | |
429 | ||
430 | //======================================================================= | |
431 | //function : SectionVertex | |
432 | //purpose : | |
433 | //======================================================================= | |
434 | ||
435 | const TopTools_ListOfShape& BRepAlgo_DSAccess::SectionVertex | |
436 | (const TopoDS_Shape& F, | |
437 | const TopoDS_Shape& E) | |
438 | { | |
04e93070 | 439 | myListOfVertex.Clear(); |
440 | if(F.ShapeType() != TopAbs_FACE || E.ShapeType() != TopAbs_EDGE) | |
441 | return myListOfVertex; | |
7fd59977 | 442 | Standard_Integer iF = myHDS->Shape(F), iE = myHDS->Shape(E); |
04e93070 | 443 | if((iF == 0) || (iE == 0)) |
444 | return myListOfVertex; | |
7fd59977 | 445 | |
446 | const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); | |
447 | const TopOpeBRepDS_ListOfInterference& LI = | |
448 | DS.ShapeInterferences(E, Standard_False); | |
449 | TopOpeBRepDS_InterferenceIterator II(LI); | |
450 | Standard_Integer goodIndex = 0; | |
451 | TopOpeBRepDS_Kind goodKind; | |
452 | for(;II.More();II.Next()) { | |
b7c077b9 | 453 | const Handle(TopOpeBRepDS_Interference)& I = II.Value(); |
7fd59977 | 454 | const TopOpeBRepDS_Transition& T = I->Transition(); |
455 | if((T.ONAfter() == TopAbs_FACE) && | |
456 | (T.IndexAfter() == iF)) { | |
457 | goodKind = I->GeometryType(); | |
458 | goodIndex = I->Geometry(); | |
459 | if(goodKind == TopOpeBRepDS_VERTEX) | |
04e93070 | 460 | myListOfVertex.Append(myHDS->Shape(goodIndex)); |
7fd59977 | 461 | else |
462 | if (goodKind == TopOpeBRepDS_POINT) | |
04e93070 | 463 | myListOfVertex.Append(myHB->NewVertex(goodIndex)); |
7fd59977 | 464 | } |
465 | } | |
7fd59977 | 466 | return myListOfVertex; |
467 | } | |
468 | ||
469 | ||
470 | // Editing of the DS | |
471 | ||
472 | //======================================================================= | |
473 | //function : SuppressEdgeSet | |
474 | //purpose : | |
475 | //======================================================================= | |
476 | ||
477 | void BRepAlgo_DSAccess::SuppressEdgeSet | |
478 | (const TopoDS_Shape& C) | |
479 | { | |
480 | // It is checked if C really is a Coumpound of connected Edges | |
481 | ||
482 | myHB->InitExtendedSectionDS(); | |
483 | // myGetSectionIsDone = Standard_False; | |
484 | ||
485 | TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected); | |
486 | for(;LLS.More(); LLS.Next()) | |
487 | if(C == LLS.Value()) | |
488 | break; | |
489 | if(!LLS.More()) | |
490 | return; | |
491 | ||
492 | // Cleaning | |
493 | TopoDS_Shape Empty; | |
494 | Empty.Nullify(); | |
495 | Suppress(C, Empty); | |
496 | myListOfCompoundOfEdgeConnected.Remove(LLS); | |
497 | } | |
498 | ||
499 | //======================================================================= | |
500 | //function : ChangeEdgeSet | |
501 | //purpose : | |
502 | //======================================================================= | |
503 | ||
504 | void BRepAlgo_DSAccess::ChangeEdgeSet | |
505 | (const TopoDS_Shape& Old, const TopoDS_Shape& New) | |
506 | { | |
507 | // It is checked if Old is a Coumpound of connected Edges | |
508 | ||
509 | myHB->InitExtendedSectionDS(); | |
510 | ||
511 | TopTools_ListIteratorOfListOfShape LLS(myListOfCompoundOfEdgeConnected); | |
512 | for(;LLS.More(); LLS.Next()) | |
513 | if(Old == LLS.Value()) | |
514 | break; | |
515 | if(!LLS.More()) | |
516 | return; | |
517 | ||
518 | // The compound of Edges to be rotated is constructed | |
519 | BRep_Builder B; | |
520 | Standard_Boolean Trouve; | |
521 | Standard_Integer iC; | |
522 | TopoDS_Compound C; | |
523 | TopoDS_Edge E; | |
524 | B.MakeCompound(C); | |
54f7544d | 525 | TColStd_PackedMapOfInteger RPoint; //The points to be controlled |
7fd59977 | 526 | |
527 | TopOpeBRepDS_ListIteratorOfListOfInterference iter; | |
528 | TopExp_Explorer exp(Old, TopAbs_EDGE); | |
529 | TopExp_Explorer exp2; | |
530 | for(; exp.More(); exp.Next()) { | |
531 | const TopoDS_Shape& Edge = exp.Current(); | |
532 | for(exp2.Init(New, TopAbs_EDGE), Trouve=Standard_False; | |
533 | exp2.More() && (!Trouve); exp2.Next()) { | |
534 | E = TopoDS::Edge(exp2.Current()); | |
535 | Trouve = E.IsSame(Edge); | |
536 | } | |
537 | ||
538 | if (!Trouve) B.Add(C, Edge); // Edge to be removed | |
539 | else if (!E.IsEqual(Edge)) { | |
540 | // It is necessary to change Interferences => take the complement | |
541 | iC = myHB->GetDSCurveFromSectEdge(Edge); | |
542 | if (!iC) { | |
0797d9d3 | 543 | #ifdef OCCT_DEBUG |
0d969553 | 544 | cout << "Warning DSAccess: Modifications of Edge are not implemented" << endl; |
7fd59977 | 545 | #endif |
546 | } | |
547 | else { | |
0d969553 | 548 | // Complete the interferences Curve/Face |
7fd59977 | 549 | Standard_Integer iF; |
550 | Handle(TopOpeBRepDS_Interference) interf; | |
551 | ||
552 | iF = myHB->GetDSFaceFromDSCurve(iC, 1); | |
553 | TopOpeBRepDS_ListOfInterference& list1 = | |
554 | myHDS->ChangeDS().ChangeShapeInterferences(iF); | |
555 | for(iter.Initialize(list1); iter.More(); iter.Next()) { | |
556 | interf = iter.Value(); | |
557 | if (interf->Geometry() == iC) | |
558 | interf->Transition(interf->Transition().Complement()); | |
559 | } | |
560 | iF = myHB->GetDSFaceFromDSCurve(iC, 2); | |
561 | TopOpeBRepDS_ListOfInterference& list2 = | |
562 | myHDS->ChangeDS().ChangeShapeInterferences(iF); | |
563 | for(iter.Initialize(list2); iter.More(); iter.Next()) { | |
564 | interf = iter.Value(); | |
565 | if (interf->Geometry() == iC) | |
566 | interf->Transition(interf->Transition().Complement()); | |
567 | } | |
568 | // The associated points are recorded | |
569 | Standard_Integer ipv1, ipv2; | |
570 | //Standard_Boolean bid; // skl | |
571 | TopOpeBRepDS_Kind k1, k2; | |
572 | PntVtxOnCurve(iC, ipv1, k1, ipv2, k2); | |
573 | if (ipv1 != 0) /*bid = */RPoint.Add(ipv1); // skl | |
574 | if (ipv2 != 0) /*bid = */RPoint.Add(ipv2); // skl | |
575 | } | |
576 | } | |
577 | } | |
578 | ||
579 | ||
0d969553 | 580 | // Cleaning |
7fd59977 | 581 | Suppress(C, New); |
582 | ||
583 | // Is it necessary to invert the Interferences "Edge on Fa" | |
584 | if (!RPoint.IsEmpty()) { | |
585 | const TopOpeBRepDS_DataStructure & DS = myHDS->DS(); | |
586 | Standard_Integer iP,iE, nbShape = DS.NbShapes(); | |
587 | Handle(TopOpeBRepDS_Interference) interf; | |
588 | for (iE=1; iE<=nbShape; iE++) { | |
589 | if (DS.Shape(iE,0).ShapeType() == TopAbs_EDGE) { | |
590 | const TopOpeBRepDS_ListOfInterference& List = | |
591 | myHDS->DS().ShapeInterferences(iE); | |
592 | for(iter.Initialize(List); iter.More(); iter.Next()) { | |
593 | interf = iter.Value(); | |
594 | if (interf->GeometryType() == TopOpeBRepDS_POINT) { | |
595 | iP = interf->Geometry(); | |
596 | if (RPoint.Contains(iP)) | |
597 | interf->Transition(interf->Transition().Complement()); | |
598 | } | |
599 | } | |
600 | } | |
601 | } | |
602 | } | |
603 | ||
604 | // The old is replaced by new | |
605 | LLS.Value() = New; | |
606 | } | |
607 | ||
608 | ||
609 | //======================================================================= | |
610 | //function : Remove | |
611 | //purpose : | |
612 | //======================================================================= | |
613 | ||
614 | void BRepAlgo_DSAccess::Suppress(const TopoDS_Shape& C, | |
615 | const TopoDS_Shape& Keep) | |
616 | { | |
617 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
618 | TopOpeBRepBuild_Builder& Builder = myHB->ChangeBuilder(); | |
619 | Standard_Integer i, iC = 0, iF1, iF2,iE1, iE2; | |
620 | // TopOpeBRepDS_ListIteratorOfListOfInterference; | |
621 | TColStd_ListIteratorOfListOfInteger it1, it2; | |
622 | ||
623 | //A group of points to be kept is constructed | |
624 | mySetOfKeepPoint.Clear(); | |
625 | if (!Keep.IsNull()) { | |
626 | //Standard_Boolean B; // skl | |
627 | Standard_Integer ipv1, ipv2; | |
628 | TopOpeBRepDS_Kind k1, k2; | |
629 | TopExp_Explorer exp(Keep, TopAbs_EDGE); | |
630 | for(; exp.More(); exp.Next()) { | |
631 | const TopoDS_Shape& SectEdge = exp.Current(); | |
632 | iC = myHB->GetDSCurveFromSectEdge(SectEdge); | |
633 | if(!iC) | |
634 | PntVtxOnSectEdge(SectEdge, ipv1, k1, ipv2, k2); | |
635 | else | |
636 | PntVtxOnCurve(iC, ipv1, k1, ipv2, k2); | |
637 | if (ipv1 != 0) /*B = */mySetOfKeepPoint.Add(ipv1); // skl | |
638 | if (ipv2 != 0) /*B = */mySetOfKeepPoint.Add(ipv2); // skl | |
639 | } | |
640 | } | |
641 | ||
642 | // The curves, which generated the the Edges, are found | |
643 | // during the parsing the Edges which come from Edge are found | |
644 | // (= MapOfInteger : ESE) | |
645 | ||
0d969553 | 646 | // First, the interferences of support 1d. |
7fd59977 | 647 | TopExp_Explorer exp(C, TopAbs_EDGE); |
648 | for(; exp.More(); exp.Next()) { | |
649 | const TopoDS_Shape& SectEdge = exp.Current(); | |
650 | iC = myHB->GetDSCurveFromSectEdge(SectEdge); | |
651 | if(!iC) { | |
652 | // the Edges that come from Edge are processed | |
653 | // the interferences connected with Edges are processed : | |
654 | iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1); | |
655 | iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2); | |
656 | ||
657 | RemoveEdgeInterferences(iE1,iE2,SectEdge); | |
658 | ||
659 | TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1); | |
660 | TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2); | |
661 | for(it1.Initialize(loi11); it1.More(); it1.Next()) { | |
662 | iF1 = it1.Value(); | |
663 | for(it2.Initialize(loi12); it2.More(); it2.Next()) { | |
664 | iF2 = it2.Value(); | |
665 | // similar to the case of SectEdges coming from curve. | |
666 | RemoveEdgeInterferences(iF1,iF2,SectEdge); | |
667 | } | |
668 | } | |
669 | TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1); | |
670 | TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2); | |
671 | for(it1.Initialize(loi21); it1.More(); it1.Next()) { | |
672 | iF1 = it1.Value(); | |
673 | for(it2.Initialize(loi22); it2.More(); it2.Next()) { | |
674 | iF2 = it2.Value(); | |
675 | // similar to the case of SectEdges coming from curve. | |
676 | RemoveEdgeInterferences(iF1,iF2,SectEdge); | |
677 | } | |
678 | } | |
679 | continue; | |
680 | } | |
681 | // The Edges that come from Curve are processed | |
682 | iF1 = myHB->GetDSFaceFromDSCurve(iC, 1); | |
683 | iF2 = myHB->GetDSFaceFromDSCurve(iC, 2); | |
684 | ||
685 | RemoveEdgeInterferences(iF1, iF2, iC); | |
686 | DS.ChangeKeepCurve(iC, FindKeep); | |
687 | } | |
688 | ||
689 | // Secondly, the interferences of 2D support. | |
690 | exp.Init(C, TopAbs_EDGE); | |
691 | for(; exp.More(); exp.Next()) { | |
692 | const TopoDS_Shape& SectEdge = exp.Current(); | |
693 | iC = myHB->GetDSCurveFromSectEdge(SectEdge); | |
694 | if(!iC) { | |
695 | iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1); | |
696 | iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2); | |
697 | TColStd_ListOfInteger& loi11 = myHB->GetDSFaceFromDSEdge(iE1, 1); | |
698 | TColStd_ListOfInteger& loi12 = myHB->GetDSFaceFromDSEdge(iE1, 2); | |
699 | for(it1.Initialize(loi11); it1.More(); it1.Next()) { | |
700 | iF1 = it1.Value(); | |
701 | for(it2.Initialize(loi12); it2.More(); it2.Next()) { | |
702 | iF2 = it2.Value(); | |
703 | if(iF1 == iF2) | |
704 | continue; | |
705 | RemoveFaceInterferences(iF1, iF2, iE1, iE2); | |
706 | } | |
707 | } | |
708 | TColStd_ListOfInteger& loi21 = myHB->GetDSFaceFromDSEdge(iE2, 1); | |
709 | TColStd_ListOfInteger& loi22 = myHB->GetDSFaceFromDSEdge(iE2, 2); | |
710 | for(it1.Initialize(loi21); it1.More(); it1.Next()) { | |
711 | iF1 = it1.Value(); | |
712 | for(it2.Initialize(loi22); it2.More(); it2.Next()) { | |
713 | iF2 = it2.Value(); | |
714 | if(iF1 == iF2) | |
715 | continue; | |
716 | RemoveFaceInterferences(iF1, iF2, iE1, iE2); | |
717 | } | |
718 | } | |
719 | } | |
720 | else { | |
721 | iF1 = myHB->GetDSFaceFromDSCurve(iC, 1); | |
722 | iF2 = myHB->GetDSFaceFromDSCurve(iC, 2); | |
723 | ||
724 | RemoveFaceInterferences(iF1, iF2, iC); | |
725 | } | |
726 | } | |
727 | ||
728 | // Thirdly, RemoveSameDomain is done for the faces that contain all Edges of C, | |
729 | // and are SameDomain and without Geometry. | |
730 | ||
731 | RemoveFaceSameDomain(C); | |
732 | ||
733 | // Fourthly, the faces, that were not concerned, are removed | |
734 | Standard_Integer NbSh = DS.NbShapes(); | |
735 | for(i = 1; i <= NbSh; i++) { | |
736 | const TopoDS_Shape& Face = DS.Shape(i); | |
737 | if(Face.IsNull()) | |
738 | continue; | |
739 | if((Face.ShapeType() != TopAbs_FACE) || DS.HasGeometry(Face) || | |
740 | (myHDS->HasSameDomain(Face))) | |
741 | continue; | |
742 | for(exp.Init(Face, TopAbs_EDGE); exp.More(); exp.Next()){ | |
743 | const TopoDS_Shape& Edge = exp.Current(); | |
744 | if(DS.HasShape(Edge)) | |
745 | break; | |
746 | } | |
747 | if(exp.More()) | |
748 | continue; | |
749 | DS.ChangeKeepShape(Face, Standard_False); | |
750 | } | |
751 | ||
752 | // Builder.myKPMAPf1f2 is reconstructed | |
753 | Builder.FindIsKPart(); | |
754 | ||
755 | // The Edges of section are removed from Builder.mySplitON | |
756 | exp.Init(C, TopAbs_EDGE); | |
757 | for(; exp.More(); exp.Next()) { | |
758 | const TopoDS_Shape& SectE= exp.Current(); | |
759 | TopTools_ListOfShape& losob = Builder.ChangeSplit(SectE, TopAbs_ON); | |
760 | losob.Clear(); | |
761 | } | |
762 | } | |
763 | ||
764 | //======================================================================= | |
765 | //function : SuppressSectionVertex | |
766 | //purpose : | |
767 | //======================================================================= | |
768 | ||
769 | void BRepAlgo_DSAccess::SuppressSectionVertex | |
770 | (const TopoDS_Vertex& /*V*/) | |
771 | { | |
772 | if(!myRecomputeBuilderIsDone) | |
773 | return; | |
774 | } | |
775 | ||
776 | ||
777 | // Reconstruction of Shapes | |
778 | ||
779 | //======================================================================= | |
780 | //function : Merge | |
781 | //purpose : | |
782 | //======================================================================= | |
783 | ||
784 | const TopoDS_Shape& BRepAlgo_DSAccess::Merge | |
785 | (const TopAbs_State state1, | |
786 | const TopAbs_State state2) | |
787 | { | |
788 | if((state1 != TopAbs_IN) && | |
789 | (state1 != TopAbs_OUT)) | |
790 | return myEmptyShape; | |
791 | if((state2 != TopAbs_IN) && | |
792 | (state2 != TopAbs_OUT)) | |
793 | return myEmptyShape; | |
794 | // if GetSectionEdgeSet has already been called, nothing is done | |
795 | // in GetSectionEdgeSet. | |
796 | if(myState1 != TopAbs_UNKNOWN) | |
797 | if(myState1 != state1 || myState2 != state2) | |
798 | myGetSectionIsDone = Standard_False; | |
799 | myState1 = state1; | |
800 | myState2 = state2; | |
801 | GetSectionEdgeSet(); | |
802 | ||
803 | myHB->Clear(); | |
804 | myHB->MergeShapes(myS1,state1,myS2,state2); | |
805 | const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1); | |
806 | ||
807 | BRep_Builder BB; | |
808 | myResultShape.Nullify(); | |
809 | BB.MakeCompound(TopoDS::Compound(myResultShape)); | |
810 | TopTools_ListIteratorOfListOfShape it(L1); | |
811 | for(;it.More(); it.Next()) { | |
812 | BB.Add(myResultShape, it.Value()); | |
813 | } | |
814 | return myResultShape; | |
815 | } | |
816 | ||
817 | //======================================================================= | |
818 | //function : Merge | |
819 | //purpose : | |
820 | //======================================================================= | |
821 | ||
822 | const TopoDS_Shape& BRepAlgo_DSAccess::Merge | |
823 | (const TopAbs_State state1) | |
824 | { | |
825 | if((state1 != TopAbs_IN) && | |
826 | (state1 != TopAbs_OUT)) | |
827 | return myEmptyShape; | |
828 | GetSectionEdgeSet(); | |
829 | ||
830 | myHB->Clear(); | |
831 | myHB->MergeSolid(myS1,state1); | |
832 | const TopTools_ListOfShape& L1 = myHB->Merged(myS1,state1); | |
833 | ||
834 | BRep_Builder BB; | |
835 | myResultShape.Nullify(); | |
836 | BB.MakeCompound(TopoDS::Compound(myResultShape)); | |
837 | TopTools_ListIteratorOfListOfShape it(L1); | |
838 | for(;it.More(); it.Next()) { | |
839 | BB.Add(myResultShape, it.Value()); | |
840 | } | |
841 | return myResultShape; | |
842 | } | |
843 | ||
844 | //======================================================================= | |
845 | //function : Propagate | |
846 | //purpose : | |
847 | //======================================================================= | |
848 | ||
849 | const TopoDS_Shape& BRepAlgo_DSAccess::Propagate | |
850 | (const TopAbs_State what, | |
851 | const TopoDS_Shape& /*fromShape*/, | |
852 | const TopoDS_Shape& /*LoadShape*/) | |
853 | { | |
854 | if((what != TopAbs_IN) && | |
855 | (what != TopAbs_OUT)) | |
856 | return myEmptyShape; | |
857 | if(!myRecomputeBuilderIsDone) | |
858 | return myEmptyShape; | |
859 | ||
860 | // myHB->MergeShapes(myS1,t1,myS2,t2); | |
861 | ||
0d969553 | 862 | //POP for NT; |
7fd59977 | 863 | static TopoDS_Shape bid; |
864 | return bid; | |
865 | } | |
866 | ||
867 | //======================================================================= | |
868 | //function : PropagateFromSection | |
869 | //purpose : | |
870 | //======================================================================= | |
871 | ||
872 | const TopoDS_Shape& BRepAlgo_DSAccess::PropagateFromSection | |
873 | (const TopoDS_Shape& SectionShape) | |
874 | { | |
875 | GetSectionEdgeSet(); | |
876 | TopTools_ListIteratorOfListOfShape ils(myListOfCompoundOfEdgeConnected); | |
877 | TopExp_Explorer exp; | |
878 | for(; ils.More(); ils.Next()) { | |
879 | const TopoDS_Shape& SetEdgSet = ils.Value(); | |
880 | exp.Init(SetEdgSet, TopAbs_EDGE); | |
881 | for(; exp.More(); exp.Next()) { | |
882 | if(SectionShape.IsSame(exp.Current())) | |
883 | return SetEdgSet; | |
884 | } | |
885 | } | |
886 | return myEmptyShape; | |
887 | } | |
888 | ||
889 | //======================================================================= | |
890 | //function : Modified | |
891 | //purpose : | |
892 | //======================================================================= | |
893 | ||
894 | const TopTools_ListOfShape& BRepAlgo_DSAccess::Modified (const TopoDS_Shape& Shape) | |
895 | { | |
896 | myModified.Clear() ; | |
897 | ||
898 | // Handle(TopOpeBRepBuild_HBuilder)& HBuilder = myDSA.myHB ; | |
899 | TopTools_ListIteratorOfListOfShape Iterator ; | |
900 | ||
901 | if (myHB->IsSplit (Shape, TopAbs_OUT)) { | |
902 | for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_OUT)) ; | |
903 | Iterator.More() ; | |
904 | Iterator.Next()) { | |
905 | myModified.Append (Iterator.Value()) ; | |
906 | } | |
907 | } | |
908 | if (myHB->IsSplit (Shape, TopAbs_IN)) { | |
909 | for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_IN)) ; | |
910 | Iterator.More() ; | |
911 | Iterator.Next()) { | |
912 | myModified.Append (Iterator.Value()) ; | |
913 | } | |
914 | } | |
915 | if (myHB->IsSplit (Shape, TopAbs_ON)) { | |
916 | for (Iterator.Initialize (myHB->Splits (Shape, TopAbs_ON)) ; | |
917 | Iterator.More() ; | |
918 | Iterator.Next()) { | |
919 | myModified.Append (Iterator.Value()) ; | |
920 | } | |
921 | } | |
922 | ||
923 | if (myHB->IsMerged (Shape, TopAbs_OUT)) { | |
924 | for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_OUT)) ; | |
925 | Iterator.More() ; | |
926 | Iterator.Next()) { | |
927 | myModified.Append (Iterator.Value()) ; | |
928 | } | |
929 | } | |
930 | if (myHB->IsMerged(Shape, TopAbs_IN)) { | |
931 | for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_IN)) ; | |
932 | Iterator.More() ; | |
933 | Iterator.Next()) { | |
934 | myModified.Append (Iterator.Value()) ; | |
935 | } | |
936 | } | |
937 | if (myHB->IsMerged(Shape, TopAbs_ON)) { | |
938 | for (Iterator.Initialize (myHB->Merged (Shape, TopAbs_ON)) ; | |
939 | Iterator.More() ; | |
940 | Iterator.Next()) { | |
941 | myModified.Append (Iterator.Value()) ; | |
942 | } | |
943 | } | |
944 | ||
945 | return myModified ; | |
946 | } | |
947 | ||
948 | ||
949 | ||
950 | //======================================================================= | |
951 | //function : Check | |
952 | //purpose : | |
953 | //======================================================================= | |
954 | ||
955 | BRepAlgo_CheckStatus BRepAlgo_DSAccess::Check() | |
956 | { | |
957 | // TopOpeBRepDS_Check Ck(HDS); | |
0d969553 Y |
958 | // to be precised : in Ck, there is a possibility to know |
959 | // exactly the n*n of shapes/points/curves/surfaces, | |
960 | // which are not correct in the DS. | |
7fd59977 | 961 | // Standard_Boolean IsOK = Ck.ChkIntgSamDom() ; |
962 | // IsOK = IsOK && Ck.OneVertexOnPnt(); | |
963 | // IsOK = IsOK && Ck.ChkIntg(); | |
964 | // if(IsOK) | |
965 | // return TopOpeBRepDS_OK; | |
966 | return BRepAlgo_NOK; | |
967 | } | |
968 | ||
969 | //======================================================================= | |
970 | //function : RemoveEdgeInterferences | |
971 | //purpose : case of SectEdge coming from Edge(s) | |
972 | // | |
973 | // if iE1 and iE2 are Edges : | |
974 | // Remove interferences of DSEdge(= iE1 or iE2) of | |
975 | // geometry a vertex of SectEdge, and if there is nothing else, | |
976 | // make unkeep on DSEdge | |
977 | // if iE1 or iE2 == 0, no interference on Edges in the DS | |
978 | // NYI : management of SameDomain | |
979 | // | |
980 | // if iE1 and iE2 are Faces : | |
981 | // for each of faces F1 and F2, explode into Edges | |
0d969553 | 982 | // for each Edge : |
7fd59977 | 983 | // remove the interferences of a SectEdge vertex |
984 | // on geometry. If there is no other interferences attached to | |
985 | // these Edges, and if these Edges are not SameDomain, | |
986 | // make unKeepShape. | |
987 | //======================================================================= | |
988 | ||
989 | void BRepAlgo_DSAccess::RemoveEdgeInterferences | |
990 | (const Standard_Integer iE1, | |
991 | const Standard_Integer iE2, | |
992 | const TopoDS_Shape& SectEdge) | |
993 | { | |
994 | if(!iE1 || !iE2) | |
995 | return; | |
996 | ||
997 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
998 | TopOpeBRepDS_Kind kind1, kind2; | |
999 | TopExp_Explorer exp(SectEdge, TopAbs_VERTEX); | |
1000 | Standard_Integer i = 1, ipv1, ipv2; | |
1001 | ||
1002 | // the Vertex/Points of SectEdge are retrieved | |
1003 | PntVtxOnSectEdge(SectEdge, ipv1, kind1, ipv2, kind2); | |
1004 | ||
1005 | const TopoDS_Shape& Shape = DS.Shape(iE1, FindKeep); | |
1006 | if(Shape.IsNull()) | |
1007 | return; | |
1008 | if(Shape.ShapeType() == TopAbs_FACE) { | |
1009 | Standard_Integer iF1 = iE1, iF2 = iE2; | |
1010 | RemoveEdgeInterferencesFromFace(iF1, iF2, ipv1, kind1, ipv2, kind2); | |
1011 | return; | |
1012 | } | |
1013 | else if(Shape.ShapeType() != TopAbs_EDGE) | |
1014 | return; | |
1015 | ||
1016 | // the interferences are taken from the DS | |
1017 | TopOpeBRepDS_ListIteratorOfListOfInterference lioloi; | |
1018 | TopOpeBRepDS_Kind gk; | |
1019 | Standard_Integer iCurrE1, iCurrE2, gi; | |
1020 | // Standard_Boolean RemInterf; | |
1021 | ||
1022 | for(i = 1; i <= 2; i++) { | |
1023 | iCurrE1 = ((i == 1) ? iE1 : iE2); | |
1024 | iCurrE2 = ((i == 1) ? iE2 : iE1); | |
1025 | const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep); | |
1026 | if(DSEdge.IsNull()) | |
1027 | continue; | |
1028 | TopOpeBRepDS_ListOfInterference& loi = | |
1029 | DS.ChangeShapeInterferences(DSEdge); | |
1030 | // RemInterf = Standard_True; | |
1031 | for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { | |
1032 | Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); | |
1033 | if (I.IsNull()) continue; | |
1034 | if((I->SupportType() != TopOpeBRepDS_EDGE) || | |
1035 | (I->Support() != iCurrE2)) { | |
1036 | // RemInterf = Standard_False;//debug ... | |
1037 | continue; | |
1038 | } | |
1039 | gk = I->GeometryType(); | |
1040 | gi = I->Geometry(); | |
1041 | if(gk == kind1) { | |
1042 | if(gi == ipv1) { | |
1043 | DS.RemoveShapeInterference(DSEdge, I); | |
1044 | if(!DS.HasGeometry(DSEdge)) { | |
1045 | // if(RemInterf || (!lioloi.More())) { | |
1046 | RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain | |
1047 | DS.ChangeKeepShape(iCurrE1, FindKeep); | |
1048 | // } | |
1049 | } | |
1050 | } | |
1051 | } | |
1052 | else if(gk == kind2) { | |
1053 | if(gi == ipv2) { | |
1054 | DS.RemoveShapeInterference(DSEdge, I); | |
1055 | if(!DS.HasGeometry(DSEdge)) { | |
1056 | // if(RemInterf || (!lioloi.More())) {//debug | |
1057 | RemoveEdgeSameDomain(iCurrE1, iCurrE2); // NYI : SameDomain | |
1058 | DS.ChangeKeepShape(iCurrE1, FindKeep); | |
1059 | // } | |
1060 | } | |
1061 | } | |
1062 | } | |
1063 | } | |
1064 | } | |
1065 | } | |
1066 | ||
1067 | //======================================================================= | |
1068 | //function : RemoveEdgeInterferences | |
1069 | //purpose : case of SectEdge coming from Curve | |
0d969553 Y |
1070 | // for each of faces F1 and F2, explode into Edges |
1071 | // for each Edge : | |
7fd59977 | 1072 | // remove the interferences that have a vertex of SectEdge |
1073 | // as a geometry. If no other interferences are attached to | |
1074 | // these Edges, and if the Edges are not SameDomain, | |
1075 | // make unKeepShape. | |
1076 | //======================================================================= | |
1077 | ||
1078 | void BRepAlgo_DSAccess::RemoveEdgeInterferences | |
1079 | (const Standard_Integer iF1, | |
1080 | const Standard_Integer iF2, | |
1081 | const Standard_Integer iCurve) | |
1082 | { | |
1083 | TopOpeBRepDS_Kind gk1, gk2; | |
1084 | Standard_Integer gi1, gi2; | |
1085 | ||
1086 | PntVtxOnCurve(iCurve, gi1, gk1, gi2, gk2); | |
1087 | ||
1088 | if (!mySetOfKeepPoint.IsEmpty()) { | |
1089 | if (mySetOfKeepPoint.Contains(gi1)) gi1 = 0; | |
1090 | if (mySetOfKeepPoint.Contains(gi2)) gi2 = 0; | |
1091 | } | |
1092 | ||
1093 | if (gi1 || gi2) | |
1094 | RemoveEdgeInterferencesFromFace(iF1, iF2, gi1, gk1, gi2, gk2); | |
1095 | } | |
1096 | ||
1097 | //======================================================================= | |
1098 | //function : RemoveFaceInterferences | |
1099 | //purpose : case of SectEdge coming from Edge(s) | |
1100 | // Remove interferences between F1 and F2 concerning | |
1101 | // DSEdge (= E1 or E2) : | |
1102 | // a) if DSEdge is not SameDomain -> the edge is Removed | |
1103 | // b) if among other interferences of DSEdge of | |
0d969553 Y |
1104 | // GeomtryType == VERTEX, there is none |
1105 | // with Edge of DSFace(= F1 or F2) | |
7fd59977 | 1106 | // if DSFace has no more interferences and is not SameDomain, |
1107 | // make unkeep DSFace. | |
1108 | //======================================================================= | |
1109 | ||
1110 | void BRepAlgo_DSAccess::RemoveFaceInterferences | |
1111 | (const Standard_Integer iF1, | |
1112 | const Standard_Integer iF2, | |
1113 | const Standard_Integer iE1, | |
1114 | const Standard_Integer iE2) | |
1115 | { | |
1116 | if(!iF1 || !iF2) | |
1117 | return; | |
1118 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1119 | TopOpeBRepDS_ListIteratorOfListOfInterference lioloi;//, lioloei, liolofi; | |
1120 | TopTools_ListIteratorOfListOfShape liolos; | |
1121 | TopOpeBRepDS_Kind gk; | |
1122 | TopExp_Explorer exp; | |
1123 | Standard_Integer i, iCurrF1, iCurrF2, j, iCurrE1, /*iCurrE2,*/ gi; // skl | |
1124 | Standard_Boolean RemInterf; | |
1125 | ||
1126 | for(i = 1; i <= 2; i++) { | |
1127 | iCurrF1 = ((i == 1) ? iF1 : iF2); | |
1128 | iCurrF2 = ((i == 1) ? iF2 : iF1); | |
1129 | const TopoDS_Shape& DSFace = DS.Shape(iCurrF1); | |
1130 | if(DSFace.IsNull()) | |
1131 | continue; | |
1132 | const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace); | |
1133 | for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { | |
1134 | Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); | |
1135 | if (I.IsNull()) continue; | |
1136 | if((I->SupportType() != TopOpeBRepDS_FACE) || | |
1137 | (I->Support() != iCurrF2)) { | |
1138 | continue; | |
1139 | } | |
1140 | gk = I->GeometryType(); | |
1141 | gi = I->Geometry(); | |
1142 | if(gk != TopOpeBRepDS_EDGE) continue; | |
1143 | for(j = 1; j <= 2; j++) { | |
1144 | iCurrE1 = ((j == 1) ? iE1 : iE2); | |
1145 | //iCurrE2 = ((j == 1) ? iE2 : iE1); // skl | |
1146 | if(gi != iCurrE1) continue; | |
1147 | // a) if DSEdge is not SameDomain -> the interference is Removed | |
1148 | // et DSEdge | |
1149 | const TopoDS_Shape& DSEdge = DS.Shape(iCurrE1, FindKeep); | |
1150 | if(DSEdge.IsNull()) | |
1151 | continue; | |
1152 | if(!myHDS->HasSameDomain(DSEdge)) { | |
1153 | if(!DS.HasGeometry(DSEdge)) { | |
1154 | DS.RemoveShapeInterference(DSFace, I); | |
1155 | DS.ChangeKeepShape(DSEdge, FindKeep); | |
1156 | } else { | |
1157 | // NYI : manage the case when the geometry of DSEdge | |
1158 | // NYI : is not connected anyhow with two faces | |
1159 | } | |
1160 | if(!DS.HasGeometry(DSFace)) { | |
1161 | DS.ChangeKeepShape(DSFace, FindKeep); | |
1162 | } | |
1163 | continue; | |
1164 | } | |
1165 | // b) if no Edges of SameDomain(DSEdge), | |
1166 | // belong to DSFace(= F1 or F2) | |
1167 | // -> the interference is removed | |
1168 | const TopoDS_Shape& Edge = DS.Shape(iCurrE1, FindKeep); | |
1169 | if(Edge.IsNull()) | |
1170 | continue; | |
1171 | const TopTools_ListOfShape& loe = DS.ShapeSameDomain(Edge); | |
1172 | RemInterf = Standard_True; | |
1173 | for(liolos.Initialize(loe); liolos.More(); liolos.Next()) { | |
1174 | const TopoDS_Shape& ESD = liolos.Value(); | |
1175 | for(exp.Init(DSFace, TopAbs_EDGE); exp.More(); exp.Next()) { | |
1176 | if(ESD.IsSame(exp.Current())) { | |
1177 | RemInterf = Standard_False; | |
1178 | break; | |
1179 | } | |
1180 | } | |
1181 | if(!RemInterf) break; | |
1182 | } | |
1183 | if(RemInterf) { | |
1184 | // RemoveSameDomain(iCurrF1, iCurrF2); | |
1185 | ||
1186 | if(!DS.HasGeometry(DSFace)) { | |
1187 | if(!myHDS->HasSameDomain(DSFace)) | |
1188 | DS.ChangeKeepShape(DSFace, FindKeep); | |
1189 | } | |
1190 | } | |
1191 | if(!DS.HasGeometry(DSFace) && !myHDS->HasSameDomain(DSFace)) | |
1192 | DS.ChangeKeepShape(DSFace, FindKeep); | |
1193 | } | |
1194 | } | |
1195 | } | |
1196 | } | |
1197 | ||
1198 | //======================================================================= | |
1199 | //function : RemoveFaceInterferences | |
1200 | //purpose : case of SectEdge from Curve | |
1201 | // remove interferences of Geometry iCurve between F1 and F2. | |
1202 | // if Face(= F1 or F2) has noother interference, and if Face | |
1203 | // is not SameDomain, make unKeepShape Face. | |
1204 | //======================================================================= | |
1205 | ||
1206 | void BRepAlgo_DSAccess::RemoveFaceInterferences | |
1207 | (const Standard_Integer iF1, | |
1208 | const Standard_Integer iF2, | |
1209 | const Standard_Integer iCurve) | |
1210 | { | |
1211 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1212 | TopOpeBRepDS_ListIteratorOfListOfInterference lioloi; | |
1213 | TopOpeBRepDS_Kind gk; | |
1214 | Standard_Integer i, iCurrF1, iCurrF2, gi; | |
1215 | ||
1216 | for(i = 1; i <= 2; i++) { | |
1217 | iCurrF1 = ((i == 1) ? iF1 : iF2); | |
1218 | iCurrF2 = ((i == 1) ? iF2 : iF1); | |
1219 | const TopoDS_Shape& DSFace = DS.Shape(iCurrF1); | |
1220 | const TopOpeBRepDS_ListOfInterference& loi = DS.ShapeInterferences(DSFace); | |
1221 | for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { | |
1222 | Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); | |
1223 | if (I.IsNull()) continue; | |
1224 | if((I->SupportType() != TopOpeBRepDS_FACE) || | |
1225 | (I->Support() != iCurrF2)) { | |
1226 | break;; | |
1227 | } | |
1228 | } | |
1229 | for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { | |
1230 | Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); | |
1231 | if (I.IsNull()) continue; | |
1232 | if((I->SupportType() != TopOpeBRepDS_FACE) || | |
1233 | (I->Support() != iCurrF2)) { | |
1234 | continue; | |
1235 | } | |
1236 | gk = I->GeometryType(); | |
1237 | gi = I->Geometry(); | |
1238 | if(gk != TopOpeBRepDS_CURVE) continue; | |
1239 | if(gi != iCurve) continue; | |
1240 | DS.RemoveShapeInterference(DSFace, I); | |
1241 | // const TopoDS_Shape& interferenceface = DS.Shape(iCurrF2); | |
1242 | // DS.RemoveShapeInterference(interferenceface, I); | |
1243 | if(!DS.HasGeometry(DSFace)) { | |
1244 | const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSFace); | |
1245 | if(los.IsEmpty()) | |
1246 | DS.ChangeKeepShape(DSFace, FindKeep); | |
1247 | } | |
1248 | // if(!DS.HasGeometry(interferenceface)) { | |
1249 | // const TopTools_ListOfShape& los = DS.ShapeSameDomain(interferenceface); | |
1250 | // if(los.IsEmpty()) | |
1251 | // DS.ChangeKeepShape(interferenceface, FindKeep); | |
1252 | // } | |
1253 | } | |
1254 | } | |
1255 | } | |
1256 | ||
1257 | //======================================================================= | |
1258 | //function : RemoveEdgeInterferencesFromFace | |
1259 | //purpose : Remove interferences of Edges from iF1 or iF2 | |
1260 | // that have GeometryType kind1/kind2 and | |
1261 | // Geometry ipv1/ipv2. | |
1262 | // if kind1/kind2 == TopAbs_VERTEX -> RemoveEdgeFromFace | |
1263 | //======================================================================= | |
1264 | ||
1265 | void BRepAlgo_DSAccess::RemoveEdgeInterferencesFromFace | |
1266 | (const Standard_Integer iF1, | |
1267 | const Standard_Integer iF2, | |
1268 | const Standard_Integer ipv1, | |
1269 | const TopOpeBRepDS_Kind kind1, | |
1270 | const Standard_Integer ipv2, | |
1271 | const TopOpeBRepDS_Kind kind2) | |
1272 | { | |
1273 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1274 | TopOpeBRepDS_ListIteratorOfListOfInterference lioloi; | |
1275 | TopExp_Explorer exp, exp2; | |
1276 | TopOpeBRepDS_Kind sk, gk; | |
1277 | Standard_Integer i, iCurrF1, iCurrF2, iE = 0, si, gi; | |
1278 | ||
1279 | for(i = 1; i <= 2; i++) { | |
1280 | iCurrF1 = ((i == 1) ? iF1 : iF2); | |
1281 | iCurrF2 = ((i == 1) ? iF2 : iF1); | |
1282 | const TopoDS_Shape& DSFace = DS.Shape(iCurrF1, FindKeep); | |
1283 | if(DSFace.IsNull()) | |
1284 | continue; | |
1285 | exp.Init(DSFace, TopAbs_EDGE); | |
1286 | for(; exp.More(); exp.Next()) { | |
1287 | const TopoDS_Shape& DSEdge = exp.Current(); | |
1288 | iE = DS.Shape(DSEdge, FindKeep); | |
1289 | if(!iE) continue; | |
1290 | const TopOpeBRepDS_ListOfInterference& loi = | |
1291 | DS.ShapeInterferences(DSEdge); | |
1292 | for(lioloi.Initialize(loi); lioloi.More(); lioloi.Next()) { | |
1293 | Handle(TopOpeBRepDS_Interference) I = lioloi.Value(); | |
1294 | if (I.IsNull()) continue; | |
1295 | sk = I->SupportType(); | |
1296 | si = I->Support(); | |
1297 | if((sk != TopOpeBRepDS_FACE) || (si != iCurrF2)) { | |
1298 | if(sk != TopOpeBRepDS_EDGE) | |
1299 | continue; | |
1300 | const TopoDS_Shape& DSFace2 = DS.Shape(iCurrF2, FindKeep); | |
1301 | exp2.Init(DSFace2, TopAbs_EDGE); | |
1302 | for(; exp2.More(); exp2.Next()) { | |
1303 | if(si == DS.Shape(exp2.Current(), FindKeep)) | |
1304 | break; | |
1305 | } | |
1306 | if(!exp2.More()) | |
1307 | continue; | |
1308 | } | |
1309 | gk = I->GeometryType(); | |
1310 | gi = I->Geometry(); | |
1311 | if(gk == kind1) { | |
1312 | if(gi == ipv1) { | |
1313 | DS.RemoveShapeInterference(DSEdge, I); | |
1314 | // if(!DS.HasGeometry(DSEdge)) { | |
1315 | // const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSEdge); | |
1316 | // if(los.IsEmpty()) { | |
1317 | // DS.ChangeKeepShape(iE, FindKeep); | |
1318 | // } | |
1319 | // } | |
1320 | } | |
1321 | else if(gk == kind2) { | |
1322 | if(gi == ipv2) { | |
1323 | DS.RemoveShapeInterference(DSEdge, I); | |
1324 | // if(!DS.HasGeometry(DSEdge)) { | |
1325 | // const TopTools_ListOfShape& los = DS.ShapeSameDomain(DSEdge); | |
1326 | // if(los.IsEmpty()) { | |
1327 | // DS.ChangeKeepShape(iE, FindKeep); | |
1328 | // } | |
1329 | // } | |
1330 | } | |
1331 | } | |
1332 | else continue; | |
1333 | } | |
1334 | } | |
1335 | } | |
1336 | if(kind1 == TopOpeBRepDS_VERTEX) | |
1337 | RemoveEdgeFromFace(iCurrF1,ipv1); | |
1338 | if(kind2 == TopOpeBRepDS_VERTEX) | |
1339 | RemoveEdgeFromFace(iCurrF1,ipv2); | |
1340 | } | |
1341 | } | |
1342 | ||
1343 | //======================================================================= | |
1344 | //function : RemoveEdgeFromFace | |
1345 | //purpose : Remove from DS the Edges, which belong to iF | |
1346 | // and have iV as vertex if they do not have Geometry and | |
1347 | // are not SameDomain. | |
1348 | //======================================================================= | |
1349 | ||
1350 | void BRepAlgo_DSAccess::RemoveEdgeFromFace | |
1351 | (const Standard_Integer iF, | |
1352 | const Standard_Integer iV) | |
1353 | { | |
1354 | if(!iF || !iV) | |
1355 | return; | |
1356 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1357 | const TopoDS_Shape& DSFace = DS.Shape(iF, FindKeep); | |
1358 | const TopoDS_Shape& Vertex = DS.Shape(iV, FindKeep); | |
1359 | if(DSFace.IsNull() || Vertex.IsNull()) | |
1360 | return; | |
1361 | TopExp_Explorer exp(DSFace, TopAbs_EDGE), exp2; | |
1362 | for(; exp.More(); exp.Next()) { | |
1363 | const TopoDS_Shape& Edge = exp.Current(); | |
0797d9d3 | 1364 | #ifdef OCCT_DEBUG |
7fd59977 | 1365 | // Standard_Integer iEdge2 = DS.Shape(Edge, FindKeep); |
1366 | // Standard_Integer iEdge3 = DS.Shape(Edge); | |
1367 | #endif | |
1368 | ||
1369 | if(!DS.HasShape(Edge)) | |
1370 | continue; | |
1371 | exp2.Init(Edge, TopAbs_VERTEX); | |
1372 | for(; exp2.More(); exp2.Next()) { | |
0797d9d3 | 1373 | #ifdef OCCT_DEBUG |
7fd59977 | 1374 | // Standard_Integer iEdge5 = DS.Shape(Vertex, FindKeep); |
1375 | // Standard_Integer iEdge4 = DS.Shape(Vertex); | |
1376 | // Standard_Integer iEdge6 = DS.Shape(exp2.Current(), FindKeep); | |
1377 | // Standard_Integer iEdge7 = DS.Shape(exp2.Current()); | |
1378 | #endif | |
1379 | ||
1380 | if(Vertex.IsSame(exp2.Current())) { | |
1381 | if(!DS.HasGeometry(Edge)) { | |
1382 | const TopTools_ListOfShape& los = DS.ShapeSameDomain(Edge); | |
1383 | if(los.IsEmpty()) { | |
0797d9d3 | 1384 | #ifdef OCCT_DEBUG |
7fd59977 | 1385 | // Standard_Integer iEdge = DS.Shape(Edge); |
1386 | #endif | |
1387 | DS.ChangeKeepShape(Edge, FindKeep); | |
1388 | } | |
1389 | } | |
1390 | } | |
1391 | } | |
1392 | } | |
1393 | } | |
1394 | ||
1395 | //======================================================================= | |
1396 | //function : PntVtxOnCurve | |
1397 | //purpose : To find the points/vertices on curves | |
1398 | //======================================================================= | |
1399 | ||
1400 | void BRepAlgo_DSAccess::PntVtxOnCurve | |
1401 | (const Standard_Integer iCurve, | |
1402 | Standard_Integer& ipv1, | |
1403 | TopOpeBRepDS_Kind& pvk1, | |
1404 | Standard_Integer& ipv2, | |
1405 | TopOpeBRepDS_Kind& pvk2) | |
1406 | { | |
1407 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1408 | ||
1409 | const TopOpeBRepDS_Curve& C = DS.Curve(iCurve); | |
1410 | TopOpeBRepDS_Kind pvk; | |
1411 | Standard_Integer ipv, iMother = C.Mother(), igoodC = iCurve, comp = 0; | |
1412 | if(iMother) igoodC = iMother; | |
0797d9d3 | 1413 | //#ifndef OCCT_DEBUG |
7fd59977 | 1414 | TopOpeBRepDS_PointIterator PII = myHDS->CurvePoints(igoodC); |
c6541a0c | 1415 | TopOpeBRepDS_PointIterator& PIt = PII; // skl : I change "M_PI" to "PIt" |
7fd59977 | 1416 | //#else |
1417 | // TopOpeBRepDS_PointIterator& PIt = myHDS->CurvePoints(igoodC); | |
1418 | //#endif | |
1419 | for(;PIt.More(); PIt.Next()) { | |
1420 | comp++; | |
1421 | if(comp > 2) | |
1422 | // Standard_Error ... | |
1423 | return; | |
1424 | ipv = PIt.Current(); | |
1425 | // a point or a vertex is removed from the DS | |
1426 | if(PIt.IsPoint()) { | |
1427 | pvk = TopOpeBRepDS_POINT; | |
1428 | DS.ChangeKeepPoint(ipv, FindKeep); | |
1429 | } | |
1430 | else if(PIt.IsVertex()) { | |
1431 | pvk = TopOpeBRepDS_VERTEX; | |
1432 | DS.ChangeKeepShape(ipv, FindKeep); | |
1433 | } | |
1434 | else continue; | |
1435 | ((comp == 1) ? ipv1 : ipv2) = ipv; | |
1436 | ((comp == 1) ? pvk1 : pvk2) = pvk; | |
1437 | } | |
1438 | } | |
1439 | ||
1440 | //======================================================================= | |
1441 | //function : PntVtxOnSectEdge | |
1442 | //purpose : Points/Vertexes on SectEdge are found | |
1443 | //======================================================================= | |
1444 | ||
1445 | void BRepAlgo_DSAccess::PntVtxOnSectEdge | |
1446 | (const TopoDS_Shape& SectEdge, | |
1447 | Standard_Integer& ipv1, | |
1448 | TopOpeBRepDS_Kind& pvk1, | |
1449 | Standard_Integer& ipv2, | |
1450 | TopOpeBRepDS_Kind& pvk2) | |
1451 | { | |
7c65581d | 1452 | ipv1 = ipv2 = 0; |
1453 | pvk1 = pvk2 = TopOpeBRepDS_UNKNOWN; | |
1454 | ||
7fd59977 | 1455 | // myHB->ChangeBuilder(); |
1456 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1457 | TopOpeBRepDS_Kind kind = TopOpeBRepDS_POINT; | |
1458 | TopExp_Explorer exp(SectEdge, TopAbs_VERTEX); | |
1459 | Standard_Integer i = 1, ipv; | |
1460 | ||
1461 | for(; exp.More(); exp.Next(), i++) { | |
1462 | const TopoDS_Shape& DSVertex = exp.Current(); | |
1463 | ipv = myHB->GetDSPointFromNewVertex(DSVertex); | |
1464 | if(!ipv) { | |
1465 | ipv = DS.Shape(DSVertex, FindKeep); | |
1466 | kind = TopOpeBRepDS_VERTEX; | |
1467 | if(!ipv) | |
1468 | // Standard_Error ... | |
1469 | return; | |
1470 | } | |
1471 | ||
1472 | if(i == 1) { | |
1473 | ipv1 = ipv; | |
1474 | pvk1 = kind; | |
1475 | } | |
1476 | else if(i == 2) { | |
1477 | ipv2 = ipv; | |
1478 | pvk2 = kind; | |
1479 | } | |
1480 | else | |
1481 | // Standard_Error ... | |
1482 | return; | |
1483 | } | |
1484 | } | |
1485 | ||
1486 | //======================================================================= | |
1487 | //function : RemoveEdgeSameDomain | |
1488 | //purpose : | |
1489 | //======================================================================= | |
1490 | ||
1491 | void BRepAlgo_DSAccess::RemoveEdgeSameDomain | |
1492 | (const Standard_Integer /*iE1*/, | |
1493 | const Standard_Integer /*iE2*/) | |
1494 | { | |
1495 | return; | |
1496 | /* TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1497 | const TopoDS_Shape& E1 = DS.Shape(iE1); | |
1498 | const TopoDS_Shape& E2 = DS.Shape(iE2); | |
1499 | TopAbs_ShapeEnum ts1, ts2; | |
1500 | ts1 = E1.ShapeType(); | |
1501 | ts2 = E2.ShapeType(); | |
1502 | if((ts1 != TopAbs_EDGE) || | |
1503 | (ts2 != TopAbs_EDGE)) | |
1504 | return; | |
1505 | TopTools_ListOfShape& lossd = DS.ChangeShapeSameDomain(E1); | |
1506 | if(lossd.IsEmpty()) | |
1507 | return; | |
1508 | Standard_Integer exte = lossd.Extent(); | |
1509 | if(exte == 1) { | |
1510 | if(lossd.First().IsSame(E2)) | |
1511 | DS.UnfillShapesSameDomain(E1,E2); | |
1512 | return; | |
1513 | }*/ | |
1514 | } | |
1515 | ||
1516 | //======================================================================= | |
1517 | //function : RemoveFaceSameDomain | |
1518 | //purpose : remove SameDomain information of glued faces | |
1519 | //======================================================================= | |
1520 | ||
1521 | void BRepAlgo_DSAccess::RemoveFaceSameDomain | |
1522 | (const TopoDS_Shape& C) | |
1523 | { | |
1524 | // myHB->ChangeBuilder(); | |
1525 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1526 | ||
1527 | //TColStd_ListIteratorOfListOfInteger it; | |
1528 | TopExp_Explorer exp(C, TopAbs_EDGE); | |
1529 | Standard_Integer iE1, iE2, iE, /*NbF,*/ iF1, iF2, iCurrF1, iCurrF2, iC =0; // skl | |
1530 | iF1 = iF2 = iCurrF1 = iCurrF2 = 0; | |
1531 | Standard_Boolean b; | |
1532 | const TopoDS_Shape& SectEdge = exp.Current(); | |
1533 | ||
1534 | for(; exp.More(); exp.Next()) { | |
1535 | iC = myHB->GetDSCurveFromSectEdge(SectEdge); | |
1536 | if(!iC && !SectEdge.IsNull()) | |
1537 | break; | |
1538 | // const TopoDS_Shape& SectEdge = exp.Current(); | |
1539 | } | |
1540 | if(!iC && !SectEdge.IsNull()) { | |
1541 | iE1 = myHB->GetDSEdgeFromSectEdge(SectEdge, 1); | |
1542 | iE2 = myHB->GetDSEdgeFromSectEdge(SectEdge, 2); | |
1543 | if(iE1 && iE2) return; | |
1544 | iE = (iE1 ? iE1 : iE2); | |
1545 | if(!iE) return; | |
1546 | ||
1547 | TColStd_ListOfInteger& loi = FindGoodFace(iE, iF1, b); | |
1548 | if(!b) return; | |
1549 | if(exp.More()) | |
1550 | exp.Next(); | |
1551 | //NbF = loi.Extent(); // skl | |
1552 | for(; exp.More(); exp.Next()) { | |
1553 | // skl : I change "SectEdge" to "SectEdg" | |
1554 | const TopoDS_Shape& SectEdg = exp.Current(); | |
1555 | iC = myHB->GetDSCurveFromSectEdge(SectEdg); | |
1556 | if(!iC) { | |
1557 | iE1 = myHB->GetDSEdgeFromSectEdge(SectEdg, 1); | |
1558 | iE2 = myHB->GetDSEdgeFromSectEdge(SectEdg, 2); | |
1559 | if(iE1 && iE2) return; | |
1560 | iE = (iE1 ? iE1 : iE2); | |
1561 | if(!iE) return; | |
1562 | ||
1563 | TColStd_ListOfInteger& loi2 = FindGoodFace(iE, iCurrF1, b); | |
1564 | if(!b) return; | |
1565 | if(!iCurrF1 || !iF1) return; | |
1566 | if(iCurrF1 != iF1) { | |
1567 | if(loi2.Extent() == 1) iCurrF2 = loi2.First(); | |
1568 | if(iCurrF2 == iF1) continue; | |
1569 | if(loi.Extent() == 1) iF2 = loi.First(); | |
1570 | ||
1571 | if(!iCurrF2 || !iF2) return; | |
1572 | if((iCurrF1 == iF2) || | |
1573 | (iCurrF2 == iF2)) { | |
1574 | iF1 = iF2; | |
1575 | continue; | |
1576 | } | |
1577 | return; | |
1578 | } | |
1579 | } | |
1580 | } | |
1581 | ||
1582 | const TopoDS_Shape& FSD = DS.Shape(iF1); | |
1583 | if(FSD.IsNull()) | |
1584 | return; | |
1585 | TopTools_ListOfShape& ssd = DS.ChangeShapeSameDomain(FSD); | |
1586 | TopTools_ListIteratorOfListOfShape itssd(ssd); | |
1587 | TopExp_Explorer exp2; | |
1588 | for(; itssd.More(); itssd.Next()) { | |
1589 | exp2.Init(itssd.Value(), TopAbs_VERTEX); | |
1590 | for(; exp2.More(); exp2.Next()) { | |
1591 | const TopoDS_Shape& exp2Curr = exp2.Current(); | |
1592 | exp.Init(C, TopAbs_VERTEX); | |
1593 | for(; exp.More(); exp.Next()) { | |
1594 | if(exp2Curr.IsSame(exp.Current())) | |
1595 | break; | |
1596 | } | |
1597 | if(exp.More()) | |
1598 | break; | |
1599 | } | |
1600 | if(exp2.More()) | |
1601 | break; | |
1602 | } | |
1603 | ||
1604 | if(exp2.More()) { | |
1605 | const TopoDS_Shape& FSD2 = itssd.Value(); | |
1606 | Standard_Integer iFSD = DS.Shape(FSD), iFSD2 = DS.Shape(FSD2); | |
1607 | RemoveFaceSameDomain(iFSD, iFSD2); | |
1608 | // DS.UnfillShapesSameDomain(FSD, FSD2); | |
1609 | } | |
1610 | } | |
1611 | } | |
1612 | ||
1613 | //======================================================================= | |
1614 | //function : FindGoodFace | |
1615 | //purpose : | |
1616 | //======================================================================= | |
1617 | ||
1618 | TColStd_ListOfInteger& BRepAlgo_DSAccess::FindGoodFace | |
1619 | (const Standard_Integer iE, | |
1620 | Standard_Integer& iF1, | |
1621 | Standard_Boolean& b) | |
1622 | { | |
1623 | // myHB->ChangeBuilder(); | |
1624 | b = Standard_False; | |
1625 | TColStd_ListOfInteger& loi = myHB->GetDSFaceFromDSEdge(iE, 1); | |
1626 | if(loi.Extent() == 1) { | |
1627 | iF1 = loi.First(); | |
1628 | b = Standard_True; | |
1629 | TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2); | |
1630 | return loi2; | |
1631 | } | |
1632 | else { | |
1633 | TColStd_ListOfInteger& loi2 = myHB->GetDSFaceFromDSEdge(iE, 2); | |
1634 | if(loi2.Extent() == 1) { | |
1635 | b = Standard_True; | |
1636 | iF1 = loi2.First(); | |
1637 | return loi; | |
1638 | } | |
1639 | } | |
1640 | b = Standard_False; | |
1641 | return myEmptyListOfInteger; | |
1642 | } | |
1643 | ||
1644 | //======================================================================= | |
1645 | //function : RemoveFaceSameDomain | |
1646 | //purpose : | |
1647 | //======================================================================= | |
1648 | ||
1649 | void BRepAlgo_DSAccess::RemoveFaceSameDomain | |
1650 | (const Standard_Integer iF1, | |
1651 | const Standard_Integer iF2) | |
1652 | { | |
1653 | TopOpeBRepDS_DataStructure& DS = myHDS->ChangeDS(); | |
1654 | const TopoDS_Shape& F1 = DS.Shape(iF1, FindKeep); | |
1655 | const TopoDS_Shape& F2 = DS.Shape(iF2, FindKeep); | |
1656 | if(F1.IsNull() || F2.IsNull()) | |
1657 | return; | |
1658 | ||
1659 | ||
1660 | Standard_Integer iref1 = DS.SameDomainRef(F1), | |
1661 | iref2 = DS.SameDomainRef(F2), istart, iend; | |
1662 | if(iref1 == iF1) | |
1663 | DS.SameDomainRef(F2,iF2); | |
1664 | if(iref2 == iF1) | |
1665 | DS.SameDomainRef(F1,iF1); | |
1666 | DS.UnfillShapesSameDomain(F1,F2); | |
1667 | ||
1668 | if(iref1 != iref2) | |
1669 | return; | |
1670 | Standard_Boolean iF1iF2IsConnected = Standard_False; | |
1671 | TColStd_IndexedMapOfInteger moi; | |
1672 | moi.Clear(); | |
1673 | if(iref2 == iF2) { | |
1674 | istart = iF2; | |
1675 | iend = iF1; | |
1676 | } | |
1677 | else { | |
1678 | istart = iF1; | |
1679 | iend = iF2; | |
1680 | } | |
1681 | moi.Add(istart); | |
1682 | Standard_Integer NbConnect = 0, icurr; | |
1683 | while(moi.Extent() > NbConnect) { | |
1684 | NbConnect++; | |
1685 | icurr = moi.FindKey(NbConnect); | |
1686 | DS.SameDomainRef(icurr, istart); | |
1687 | const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr); | |
1688 | if(los.IsEmpty()) { | |
1689 | const TopoDS_Shape& SNSD = DS.Shape(icurr); | |
1690 | DS.SameDomainRef(SNSD, 0); | |
1691 | } | |
1692 | TopTools_ListIteratorOfListOfShape li(los); | |
1693 | for(; li.More(); li.Next()) { | |
1694 | Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep); | |
1695 | if(!iCurrShap) | |
1696 | return; | |
1697 | if(iCurrShap == iend) | |
1698 | iF1iF2IsConnected = Standard_True; | |
1699 | moi.Add(iCurrShap); | |
1700 | } | |
1701 | } | |
1702 | if(!iF1iF2IsConnected) { | |
1703 | moi.Clear(); | |
1704 | moi.Add(iend); | |
1705 | NbConnect = 0; | |
1706 | while(moi.Extent() > NbConnect) { | |
1707 | NbConnect++; | |
1708 | icurr = moi.FindKey(NbConnect); | |
1709 | DS.SameDomainRef(icurr, iend); | |
1710 | const TopTools_ListOfShape& los = DS.ShapeSameDomain(icurr); | |
1711 | if(los.IsEmpty()) { | |
1712 | const TopoDS_Shape& SNSD = DS.Shape(icurr); | |
1713 | DS.SameDomainRef(SNSD, 0); | |
1714 | } | |
1715 | TopTools_ListIteratorOfListOfShape li(los); | |
1716 | for(; li.More(); li.Next()) { | |
1717 | Standard_Integer iCurrShap = DS.Shape(li.Value(), FindKeep); | |
1718 | if(!iCurrShap) | |
1719 | return; | |
1720 | moi.Add(iCurrShap); | |
1721 | } | |
1722 | } | |
1723 | } | |
1724 | } | |
1725 | ||
1726 | //======================================================================= | |
1727 | //function : DS | |
1728 | //purpose : | |
1729 | //======================================================================= | |
1730 | ||
1731 | const Handle(TopOpeBRepDS_HDataStructure)& | |
1732 | BRepAlgo_DSAccess::DS() const | |
1733 | { | |
1734 | return myHDS; | |
1735 | } | |
1736 | ||
1737 | //======================================================================= | |
1738 | //function : changeDS | |
1739 | //purpose : | |
1740 | //======================================================================= | |
1741 | Handle(TopOpeBRepDS_HDataStructure)& | |
1742 | BRepAlgo_DSAccess::ChangeDS() | |
1743 | { | |
1744 | return myHDS; | |
1745 | } | |
1746 | ||
1747 | //======================================================================= | |
1748 | //function : Builder | |
1749 | //purpose : | |
1750 | //======================================================================= | |
1751 | ||
1752 | const Handle(TopOpeBRepBuild_HBuilder)& | |
1753 | BRepAlgo_DSAccess::Builder() const | |
1754 | { | |
1755 | return myHB; | |
1756 | } | |
1757 | ||
1758 | //======================================================================= | |
1759 | //function : ChangeBuilder | |
1760 | //purpose : | |
1761 | //======================================================================= | |
1762 | ||
1763 | Handle(TopOpeBRepBuild_HBuilder)& | |
1764 | BRepAlgo_DSAccess::ChangeBuilder() | |
1765 | { | |
1766 | return myHB; | |
1767 | } |