4e57c75e |
1 | // Created by: Peter KURNEV |
973c2be1 |
2 | // Copyright (c) 2010-2014 OPEN CASCADE SAS |
4e57c75e |
3 | // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE |
4 | // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, |
5 | // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS |
6 | // |
973c2be1 |
7 | // This file is part of Open CASCADE Technology software library. |
4e57c75e |
8 | // |
d5f74e42 |
9 | // This library is free software; you can redistribute it and/or modify it under |
10 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
11 | // by the Free Software Foundation, with special exception defined in the file |
12 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
13 | // distribution for complete text of the license and disclaimer of any warranty. |
4e57c75e |
14 | // |
973c2be1 |
15 | // Alternatively, this file may be used under the terms of Open CASCADE |
16 | // commercial license or contractual agreement. |
4e57c75e |
17 | |
18 | #include <BOPAlgo_PaveFiller.ixx> |
19 | |
20 | #include <NCollection_IncAllocator.hxx> |
e30616a7 |
21 | // |
22 | #include <GeomAPI_ProjectPointOnSurf.hxx> |
23 | // |
4e57c75e |
24 | #include <Bnd_Box.hxx> |
e30616a7 |
25 | // |
4e57c75e |
26 | #include <TopoDS_Vertex.hxx> |
27 | #include <TopoDS_Edge.hxx> |
28 | #include <TopoDS_Face.hxx> |
29 | #include <BRep_Tool.hxx> |
e30616a7 |
30 | #include <BRepBndLib.hxx> |
31 | #include <BRepAdaptor_Curve.hxx> |
32 | #include <BRep_Builder.hxx> |
33 | // |
4e57c75e |
34 | #include <IntTools_EdgeFace.hxx> |
35 | #include <IntTools_Range.hxx> |
36 | #include <IntTools_SequenceOfCommonPrts.hxx> |
37 | #include <IntTools_CommonPrt.hxx> |
e30616a7 |
38 | // |
4e57c75e |
39 | #include <BOPCol_MapOfInteger.hxx> |
e30616a7 |
40 | #include <BOPCol_NCVector.hxx> |
41 | #include <BOPCol_TBB.hxx> |
42 | // |
1e143abb |
43 | #include <IntTools_Context.hxx> |
44 | #include <IntTools_Tools.hxx> |
e30616a7 |
45 | // |
4e57c75e |
46 | #include <BOPDS_Interf.hxx> |
47 | #include <BOPDS_Iterator.hxx> |
48 | #include <BOPDS_PaveBlock.hxx> |
49 | #include <BOPDS_MapOfPaveBlock.hxx> |
50 | #include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx> |
51 | #include <BOPDS_CommonBlock.hxx> |
52 | #include <BOPDS_Pave.hxx> |
4e57c75e |
53 | #include <BOPDS_CoupleOfPaveBlocks.hxx> |
e30616a7 |
54 | // |
55 | #include <BOPTools_AlgoTools.hxx> |
56 | // |
4e57c75e |
57 | #include <BOPAlgo_Tools.hxx> |
4e57c75e |
58 | |
e30616a7 |
59 | //======================================================================= |
60 | //class : BOPAlgo_EdgeFace |
61 | //purpose : |
62 | //======================================================================= |
36f4947b |
63 | class BOPAlgo_EdgeFace : |
64 | public IntTools_EdgeFace, |
65 | public BOPAlgo_Algo { |
66 | |
e30616a7 |
67 | public: |
36f4947b |
68 | DEFINE_STANDARD_ALLOC |
69 | |
70 | BOPAlgo_EdgeFace() : |
71 | IntTools_EdgeFace(), |
72 | BOPAlgo_Algo(), |
73 | myIE(-1), myIF(-1) { |
e30616a7 |
74 | }; |
75 | // |
36f4947b |
76 | virtual ~BOPAlgo_EdgeFace(){ |
e30616a7 |
77 | }; |
78 | // |
79 | void SetIndices(const Standard_Integer nE, |
80 | const Standard_Integer nF) { |
81 | myIE=nE; |
82 | myIF=nF; |
83 | } |
84 | // |
85 | void Indices(Standard_Integer& nE, |
86 | Standard_Integer& nF) { |
87 | nE=myIE; |
88 | nF=myIF; |
89 | } |
90 | // |
91 | void SetNewSR(const IntTools_Range& aR){ |
92 | myNewSR=aR; |
93 | } |
94 | // |
95 | IntTools_Range& NewSR(){ |
96 | return myNewSR; |
97 | } |
98 | // |
99 | void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) { |
100 | myPB=aPB; |
101 | } |
102 | // |
103 | Handle(BOPDS_PaveBlock)& PaveBlock() { |
104 | return myPB; |
105 | } |
106 | // |
36f4947b |
107 | virtual void Perform() { |
108 | BOPAlgo_Algo::UserBreak(); |
109 | IntTools_EdgeFace::Perform(); |
110 | } |
111 | // |
e30616a7 |
112 | protected: |
113 | Standard_Integer myIE; |
114 | Standard_Integer myIF; |
115 | IntTools_Range myNewSR; |
116 | Handle(BOPDS_PaveBlock) myPB; |
117 | }; |
118 | // |
119 | //======================================================================= |
120 | typedef BOPCol_NCVector<BOPAlgo_EdgeFace> BOPAlgo_VectorOfEdgeFace; |
121 | // |
122 | typedef BOPCol_TBBContextFunctor |
123 | <BOPAlgo_EdgeFace, |
124 | BOPAlgo_VectorOfEdgeFace, |
1e143abb |
125 | Handle(IntTools_Context), |
126 | IntTools_Context> BOPAlgo_EdgeFaceFunctor; |
e30616a7 |
127 | // |
128 | typedef BOPCol_TBBContextCnt |
129 | <BOPAlgo_EdgeFaceFunctor, |
130 | BOPAlgo_VectorOfEdgeFace, |
1e143abb |
131 | Handle(IntTools_Context)> BOPAlgo_EdgeFaceCnt; |
e30616a7 |
132 | // |
4e57c75e |
133 | //======================================================================= |
134 | //function : PerformEF |
135 | //purpose : |
136 | //======================================================================= |
e30616a7 |
137 | void BOPAlgo_PaveFiller::PerformEF() |
4e57c75e |
138 | { |
139 | Standard_Integer iSize; |
140 | // |
141 | myErrorStatus=0; |
142 | // |
e30616a7 |
143 | FillShrunkData(TopAbs_EDGE, TopAbs_FACE); |
144 | // |
4e57c75e |
145 | myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE); |
146 | iSize=myIterator->ExpectedLength(); |
147 | if (!iSize) { |
148 | return; |
149 | } |
e30616a7 |
150 | // |
b4109929 |
151 | Standard_Boolean bJustAdd, bV[2]; |
152 | Standard_Integer nE, nF, aDiscretize, i, aNbCPrts, iX, nV[2]; |
e30616a7 |
153 | Standard_Integer aNbEdgeFace, k; |
b4109929 |
154 | Standard_Real aTolE, aTolF, aTS1, aTS2, aT1, aT2, aDeflection; |
4e57c75e |
155 | Handle(NCollection_IncAllocator) aAllocator; |
156 | TopAbs_ShapeEnum aType; |
157 | BOPDS_ListIteratorOfListOfPaveBlock aIt; |
e30616a7 |
158 | BOPAlgo_VectorOfEdgeFace aVEdgeFace; |
4e57c75e |
159 | BRep_Builder aBB; |
e30616a7 |
160 | //-----------------------------------------------------scope f |
4e57c75e |
161 | // |
e30616a7 |
162 | ////aAllocator=new NCollection_IncAllocator(); |
4e57c75e |
163 | |
164 | BOPCol_MapOfInteger aMIEFC(100, aAllocator); |
165 | BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator); |
166 | BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, aAllocator); |
167 | // |
168 | aDiscretize=35; |
169 | aDeflection=0.01; |
170 | // |
171 | BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); |
4e57c75e |
172 | aEFs.SetIncrement(iSize); |
4e57c75e |
173 | // |
174 | for (; myIterator->More(); myIterator->Next()) { |
175 | myIterator->Value(nE, nF, bJustAdd); |
176 | if(bJustAdd) { |
177 | continue; |
178 | } |
179 | // |
180 | const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE); |
181 | if (aSIE.HasFlag()){//degenerated |
182 | continue; |
183 | } |
184 | // |
185 | const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape())); |
186 | const TopoDS_Face& aF=(*(TopoDS_Face *)(&myDS->Shape(nF))); |
187 | const Bnd_Box& aBBF=myDS->ShapeInfo(nF).Box(); |
188 | // |
189 | BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); |
190 | const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn(); |
4e57c75e |
191 | // |
192 | aTolE=BRep_Tool::Tolerance(aE); |
193 | aTolF=BRep_Tool::Tolerance(aF); |
194 | // |
195 | BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE); |
196 | aIt.Initialize(aLPB); |
197 | for (; aIt.More(); aIt.Next()) { |
198 | Handle(BOPDS_PaveBlock)& aPB=aIt.ChangeValue(); |
199 | // |
5a77460e |
200 | const Handle(BOPDS_PaveBlock) aPBR=myDS->RealPaveBlock(aPB); |
4e57c75e |
201 | if (aMPBF.Contains(aPBR)) { |
202 | continue; |
203 | } |
204 | // |
205 | if (!aPB->HasShrunkData()) { |
e30616a7 |
206 | continue; |
4e57c75e |
207 | } |
208 | // |
209 | Bnd_Box aBBE; |
210 | aPB->ShrunkData(aTS1, aTS2, aBBE); |
211 | // |
212 | if (aBBF.IsOut (aBBE)) { |
213 | continue; |
214 | } |
215 | // |
e30616a7 |
216 | BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace.Append1(); |
217 | // |
218 | aEdgeFace.SetIndices(nE, nF); |
219 | aEdgeFace.SetPaveBlock(aPB); |
4e57c75e |
220 | // |
221 | aEdgeFace.SetEdge (aE); |
222 | aEdgeFace.SetFace (aF); |
223 | aEdgeFace.SetTolE (aTolE); |
224 | aEdgeFace.SetTolF (aTolF); |
225 | aEdgeFace.SetDiscretize (aDiscretize); |
226 | aEdgeFace.SetDeflection (aDeflection); |
4e57c75e |
227 | // |
228 | IntTools_Range aSR(aTS1, aTS2); |
229 | IntTools_Range anewSR=aSR; |
4e57c75e |
230 | BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, anewSR); |
e30616a7 |
231 | aEdgeFace.SetNewSR(anewSR); |
b4109929 |
232 | // |
233 | aPB->Range(aT1, aT2); |
234 | IntTools_Range aPBRange(aT1, aT2); |
235 | aSR = aPBRange; |
236 | BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, aPBRange); |
b4109929 |
237 | aEdgeFace.SetRange (aPBRange); |
36f4947b |
238 | aEdgeFace.SetProgressIndicator(myProgressIndicator); |
4e57c75e |
239 | // |
e30616a7 |
240 | }//for (; aIt.More(); aIt.Next()) { |
241 | }//for (; myIterator->More(); myIterator->Next()) { |
242 | // |
243 | aNbEdgeFace=aVEdgeFace.Extent(); |
244 | //================================================================= |
245 | BOPAlgo_EdgeFaceCnt::Perform(myRunParallel, aVEdgeFace, myContext); |
246 | //================================================================= |
247 | // |
248 | for (k=0; k < aNbEdgeFace; ++k) { |
249 | BOPAlgo_EdgeFace& aEdgeFace=aVEdgeFace(k); |
250 | if (!aEdgeFace.IsDone()) { |
251 | continue; |
252 | } |
253 | //~~~ |
254 | aEdgeFace.Indices(nE, nF); |
255 | // |
256 | const TopoDS_Edge& aE=aEdgeFace.Edge(); |
257 | const TopoDS_Face& aF=aEdgeFace.Face(); |
258 | // |
259 | aTolE=aEdgeFace.TolE(); |
260 | aTolF=aEdgeFace.TolF(); |
261 | const IntTools_Range& anewSR=aEdgeFace.NewSR(); |
262 | Handle(BOPDS_PaveBlock)& aPB=aEdgeFace.PaveBlock(); |
263 | // |
264 | aPB->Range(aT1, aT2); |
265 | aPB->Indices(nV[0], nV[1]); |
266 | // |
267 | BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); |
e30616a7 |
268 | const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn(); |
269 | const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn(); |
270 | //~~~ |
271 | const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts(); |
272 | aNbCPrts=aCPrts.Length(); |
273 | for (i=1; i<=aNbCPrts; ++i) { |
274 | const IntTools_CommonPrt& aCPart=aCPrts(i); |
275 | aType=aCPart.Type(); |
276 | switch (aType) { |
4e57c75e |
277 | case TopAbs_VERTEX: { |
b4109929 |
278 | Standard_Boolean bIsOnPave[2]; |
279 | Standard_Integer j; |
4e57c75e |
280 | Standard_Real aT, aTolToDecide; |
281 | TopoDS_Vertex aVnew; |
e30616a7 |
282 | // |
1e143abb |
283 | IntTools_Tools::VertexParameter(aCPart, aT); |
4e57c75e |
284 | BOPTools_AlgoTools::MakeNewVertex(aE, aT, aF, aVnew); |
285 | // |
286 | const IntTools_Range& aR=aCPart.Range1(); |
287 | aTolToDecide=5.e-8; |
4e57c75e |
288 | // |
e30616a7 |
289 | IntTools_Range aR1(aT1,anewSR.First()),aR2(anewSR.Last(), aT2); |
4e57c75e |
290 | // |
1e143abb |
291 | bIsOnPave[0]=IntTools_Tools::IsInRange(aR1, aR, aTolToDecide); |
292 | bIsOnPave[1]=IntTools_Tools::IsInRange(aR2, aR, aTolToDecide); |
b4109929 |
293 | // |
294 | if (bIsOnPave[0] && bIsOnPave[1]) { |
295 | bV[0]=CheckFacePaves(nV[0], aMIFOn, aMIFIn); |
296 | bV[1]=CheckFacePaves(nV[1], aMIFOn, aMIFIn); |
297 | if (bV[0] && bV[1]) { |
4e57c75e |
298 | IntTools_CommonPrt aCP = aCPart; |
299 | aCP.SetType(TopAbs_EDGE); |
402bfe81 |
300 | BOPDS_InterfEF& aEF=aEFs.Append1(); |
301 | iX=aEFs.Extent()-1; |
4e57c75e |
302 | aEF.SetIndices(nE, nF); |
303 | aEF.SetCommonPart(aCP); |
304 | myDS->AddInterf(nE, nF); |
ceb31c61 |
305 | // |
306 | aMIEFC.Add(nF); |
307 | // |
4e57c75e |
308 | BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator); |
309 | break; |
310 | } |
311 | } |
b4109929 |
312 | for (j=0; j<2; ++j) { |
313 | if (bIsOnPave[j]) { |
314 | bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn); |
315 | if (bV[j]) { |
e30616a7 |
316 | const TopoDS_Vertex& aV= |
317 | (*(TopoDS_Vertex *)(&myDS->Shape(nV[j]))); |
b4109929 |
318 | BOPTools_AlgoTools::UpdateVertex(aE, aT, aV); |
319 | BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV[j]); |
320 | Bnd_Box& aBoxDS=aSIDS.ChangeBox(); |
321 | BRepBndLib::Add(aV, aBoxDS); |
322 | } |
323 | else { |
324 | bIsOnPave[j] = ForceInterfVF(nV[j], nF); |
325 | } |
4e57c75e |
326 | } |
4e57c75e |
327 | } |
328 | // |
b4109929 |
329 | if (!bIsOnPave[0] && !bIsOnPave[1]) { |
330 | if (CheckFacePaves(aVnew, aMIFOn)) { |
4e57c75e |
331 | continue; |
332 | } |
b4109929 |
333 | // |
334 | const gp_Pnt& aPnew = BRep_Tool::Pnt(aVnew); |
e30616a7 |
335 | if (!myContext->IsValidPointForFace(aPnew, |
336 | aF, |
337 | aTolE+aTolF)) { |
4e57c75e |
338 | continue; |
339 | } |
b4109929 |
340 | // |
4e57c75e |
341 | aBB.UpdateVertex(aVnew, aTolE); |
342 | // |
343 | aMIEFC.Add(nF); |
344 | // 1 |
402bfe81 |
345 | BOPDS_InterfEF& aEF=aEFs.Append1(); |
346 | iX=aEFs.Extent()-1; |
4e57c75e |
347 | aEF.SetIndices(nE, nF); |
348 | aEF.SetCommonPart(aCPart); |
349 | // 2 |
350 | myDS->AddInterf(nE, nF); |
351 | // 3 |
352 | BOPDS_CoupleOfPaveBlocks aCPB; |
353 | // |
354 | aCPB.SetPaveBlocks(aPB, aPB); |
355 | aCPB.SetIndexInterf(iX); |
356 | aMVCPB.Add(aVnew, aCPB); |
357 | } |
358 | } |
359 | break; |
360 | case TopAbs_EDGE: { |
361 | aMIEFC.Add(nF); |
362 | // |
363 | // 1 |
402bfe81 |
364 | BOPDS_InterfEF& aEF=aEFs.Append1(); |
365 | iX=aEFs.Extent()-1; |
4e57c75e |
366 | aEF.SetIndices(nE, nF); |
367 | // |
b4109929 |
368 | bV[0]=CheckFacePaves(nV[0], aMIFOn, aMIFIn); |
369 | bV[1]=CheckFacePaves(nV[1], aMIFOn, aMIFIn); |
370 | if (!bV[0] || !bV[1]) { |
4e57c75e |
371 | myDS->AddInterf(nE, nF); |
372 | break; |
373 | } |
374 | //update tolerance of edge if needed |
375 | if (aTolE < aTolF) { |
376 | myDS->UpdateEdgeTolerance(nE, aTolF); |
377 | aTolE = aTolF; |
378 | } |
379 | aEF.SetCommonPart(aCPart); |
380 | // 2 |
381 | myDS->AddInterf(nE, nF); |
382 | // 3 |
383 | BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator); |
384 | |
385 | } |
386 | break; |
387 | default: |
388 | break; |
e30616a7 |
389 | }//switch (aType) { |
390 | }//for (i=1; i<=aNbCPrts; ++i) { |
391 | }// for (k=0; k < aNbEdgeEdge; ++k) { |
4e57c75e |
392 | // |
393 | //========================================= |
394 | // post treatment |
395 | //========================================= |
5a77460e |
396 | BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, aAllocator, myDS); |
4e57c75e |
397 | PerformVerticesEF(aMVCPB, aAllocator); |
398 | // |
399 | // Update FaceInfoIn for all faces having EF common parts |
400 | BOPCol_MapIteratorOfMapOfInteger aItMI; |
401 | aItMI.Initialize(aMIEFC); |
402 | for (; aItMI.More(); aItMI.Next()) { |
403 | nF=aItMI.Value(); |
404 | myDS->UpdateFaceInfoIn(nF); |
405 | } |
406 | // Refine FaceInfoOn to remove all formal pave blocks |
407 | // made during EF processing |
408 | //myDS->RefineFaceInfoOn(); |
409 | //-----------------------------------------------------scope t |
410 | aMIEFC.Clear(); |
411 | aMVCPB.Clear(); |
412 | aMPBLI.Clear(); |
e30616a7 |
413 | ////aAllocator.Nullify(); |
4e57c75e |
414 | } |
415 | //======================================================================= |
416 | //function : PerformVertices1 |
417 | //purpose : |
418 | //======================================================================= |
e30616a7 |
419 | Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF |
420 | (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB, |
421 | Handle(NCollection_BaseAllocator)& theAllocator) |
4e57c75e |
422 | { |
423 | Standard_Integer aNbV, iRet; |
424 | // |
425 | iRet=0; |
426 | aNbV=theMVCPB.Extent(); |
427 | if (!aNbV) { |
428 | return iRet; |
429 | } |
430 | // |
431 | Standard_Integer nVx, nVSD, iV, iErr, nE, iFlag, iX, i, aNbPBLI; |
432 | Standard_Real aT; |
433 | TopoDS_Shape aV; |
434 | BOPCol_ListIteratorOfListOfShape aItLS; |
435 | BOPCol_ListIteratorOfListOfInteger aItLI; |
436 | BOPDS_PDS aPDS; |
437 | BOPDS_ShapeInfo aSI; |
438 | BOPDS_Pave aPave; |
439 | // |
440 | BOPCol_ListOfShape aLS(theAllocator); |
441 | BOPCol_DataMapOfShapeInteger aMVI(100, theAllocator); |
442 | BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, theAllocator); |
443 | BOPAlgo_PaveFiller aPF(theAllocator); |
444 | // |
445 | aSI.SetShapeType(TopAbs_VERTEX); |
446 | BOPDS_VectorOfInterfEF& aEFs=myDS->InterfEF(); |
447 | // |
448 | // 1 prepare arguments |
449 | for (i=1; i<=aNbV; ++i) { |
450 | const TopoDS_Shape& aS=theMVCPB.FindKey(i); |
451 | aLS.Append(aS); |
452 | } |
453 | // |
454 | // 2 Fuse vertices |
455 | aPF.SetArguments(aLS); |
456 | aPF.Perform(); |
457 | iErr=aPF.ErrorStatus(); |
458 | if (iErr) { |
459 | iRet=1; |
460 | return iRet; |
461 | } |
462 | aPDS=aPF.PDS(); |
463 | // |
464 | // 3 Add new vertices to theDS; |
465 | // 4 Map PaveBlock/ListOfVertices to add to this PaveBlock ->aMPBLI |
466 | aItLS.Initialize(aLS); |
467 | for (; aItLS.More(); aItLS.Next()) { |
468 | const TopoDS_Shape& aVx=aItLS.Value(); |
469 | nVx=aPDS->Index(aVx); |
470 | // |
471 | if (aPDS->HasShapeSD(nVx, nVSD)) { |
472 | aV=aPDS->Shape(nVSD); |
473 | } |
474 | else { |
475 | aV=aVx; |
476 | } |
477 | // index of new vertex in theDS -> iV |
478 | if (!aMVI.IsBound(aV)) { |
479 | aSI.SetShape(aV); |
480 | iV=myDS->Append(aSI); |
481 | // |
482 | BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV); |
483 | Bnd_Box& aBox=aSIDS.ChangeBox(); |
484 | BRepBndLib::Add(aV, aBox); |
485 | // |
486 | aMVI.Bind(aV, iV); |
487 | } |
488 | else { |
489 | iV=aMVI.Find(aV); |
490 | } |
491 | // |
492 | BOPDS_CoupleOfPaveBlocks &aCPB=theMVCPB.ChangeFromKey(aVx); |
493 | aCPB.SetIndex(iV); |
494 | // update EF interference |
495 | iX=aCPB.IndexInterf(); |
496 | BOPDS_InterfEF& aEF=aEFs(iX); |
497 | aEF.SetIndexNew(iV); |
498 | // map aMPBLI |
499 | const Handle(BOPDS_PaveBlock)& aPB=aCPB.PaveBlock1(); |
500 | if (aMPBLI.Contains(aPB)) { |
501 | BOPCol_ListOfInteger& aLI=aMPBLI.ChangeFromKey(aPB); |
502 | aLI.Append(iV); |
503 | } |
504 | else { |
505 | BOPCol_ListOfInteger aLI(theAllocator); |
506 | aLI.Append(iV); |
507 | aMPBLI.Add(aPB, aLI); |
508 | } |
509 | } |
510 | // |
511 | // 5 |
512 | // 5.1 Compute Extra Paves and |
513 | // 5.2. Add Extra Paves to the PaveBlocks |
514 | aNbPBLI=aMPBLI.Extent(); |
515 | for (i=1; i<=aNbPBLI; ++i) { |
516 | Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i); |
517 | const BOPCol_ListOfInteger& aLI=aMPBLI.FindFromIndex(i); |
518 | nE=aPB->OriginalEdge(); |
519 | const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE))); |
520 | // |
521 | aItLI.Initialize(aLI); |
522 | for (; aItLI.More(); aItLI.Next()) { |
523 | nVx=aItLI.Value(); |
524 | const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx))); |
525 | // |
526 | iFlag=myContext->ComputeVE (aVx, aE, aT); |
527 | if (!iFlag) { |
528 | aPave.SetIndex(nVx); |
529 | aPave.SetParameter(aT); |
530 | aPB->AppendExtPave(aPave); |
531 | } |
532 | } |
533 | } |
534 | // 6 Split PaveBlocksa |
535 | for (i=1; i<=aNbPBLI; ++i) { |
536 | Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i); |
537 | nE=aPB->OriginalEdge(); |
538 | // 3 |
5a77460e |
539 | if (!myDS->IsCommonBlock(aPB)) { |
4e57c75e |
540 | myDS->UpdatePaveBlock(aPB); |
541 | } |
542 | else { |
5a77460e |
543 | const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB); |
4e57c75e |
544 | myDS->UpdateCommonBlock(aCB); |
545 | } |
546 | }//for (; aItMPBLI.More(); aItMPBLI.Next()) { |
547 | // |
548 | return iRet; |
549 | } |
550 | //======================================================================= |
551 | // function: CheckFacePaves |
552 | // purpose: |
553 | //======================================================================= |
e30616a7 |
554 | Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves |
555 | (const Standard_Integer nVx, |
556 | const BOPCol_MapOfInteger& aMIFOn, |
557 | const BOPCol_MapOfInteger& aMIFIn) |
4e57c75e |
558 | { |
559 | Standard_Boolean bRet; |
560 | Standard_Integer nV; |
561 | BOPCol_MapIteratorOfMapOfInteger aIt; |
562 | // |
563 | bRet=Standard_False; |
564 | // |
565 | aIt.Initialize(aMIFOn); |
566 | for (; aIt.More(); aIt.Next()) { |
567 | nV=aIt.Value(); |
568 | if (nV==nVx) { |
569 | bRet=!bRet; |
570 | return bRet; |
571 | } |
572 | } |
573 | aIt.Initialize(aMIFIn); |
574 | for (; aIt.More(); aIt.Next()) { |
575 | nV=aIt.Value(); |
576 | if (nV==nVx) { |
577 | bRet=!bRet; |
578 | return bRet; |
579 | } |
580 | } |
581 | // |
582 | return bRet; |
583 | } |
584 | //======================================================================= |
585 | // function: CheckFacePaves |
586 | // purpose: |
587 | //======================================================================= |
e30616a7 |
588 | Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves |
589 | (const TopoDS_Vertex& aVnew, |
590 | const BOPCol_MapOfInteger& aMIF) |
4e57c75e |
591 | { |
592 | Standard_Boolean bRet; |
593 | Standard_Integer nV, iFlag; |
594 | BOPCol_MapIteratorOfMapOfInteger aIt; |
595 | // |
596 | bRet=Standard_True; |
597 | // |
598 | aIt.Initialize(aMIF); |
599 | for (; aIt.More(); aIt.Next()) { |
600 | nV=aIt.Value(); |
601 | const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nV))); |
602 | iFlag=BOPTools_AlgoTools::ComputeVV(aVnew, aV); |
603 | if (!iFlag) { |
604 | return bRet; |
605 | } |
606 | } |
607 | // |
608 | return !bRet; |
609 | } |
b4109929 |
610 | //======================================================================= |
611 | //function : ForceInterfVF |
612 | //purpose : |
613 | //======================================================================= |
e30616a7 |
614 | Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF |
615 | (const Standard_Integer nV, |
616 | const Standard_Integer nF) |
b4109929 |
617 | { |
618 | Standard_Boolean bRet; |
619 | // |
620 | bRet = Standard_False; |
621 | const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV); |
622 | const TopoDS_Face& aF = *(TopoDS_Face*) &myDS->Shape(nF); |
623 | // |
624 | GeomAPI_ProjectPointOnSurf& aProj = myContext->ProjPS(aF); |
625 | const gp_Pnt& aP = BRep_Tool::Pnt(aV); |
626 | aProj.Perform(aP); |
627 | if (!aProj.IsDone()) { |
628 | return bRet; |
629 | } |
630 | Standard_Real aDist, U, V; |
631 | // |
632 | aDist=aProj.LowerDistance(); |
633 | aProj.LowerDistanceParameters(U, V); |
634 | // |
635 | gp_Pnt2d aP2d(U, V); |
636 | bRet = myContext->IsPointInFace (aF, aP2d); |
637 | if (bRet) { |
402bfe81 |
638 | //Standard_Integer i; |
b4109929 |
639 | BRep_Builder aBB; |
640 | // |
641 | BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); |
402bfe81 |
642 | BOPDS_InterfVF& aVF=aVFs.Append1(); |
b4109929 |
643 | aVF.SetIndices(nV, nF); |
644 | aVF.SetUV(U, V); |
645 | // |
646 | myDS->AddInterf(nV, nF); |
647 | // |
648 | aBB.UpdateVertex(aV, aDist); |
649 | BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV); |
650 | Bnd_Box& aBoxDS=aSIDS.ChangeBox(); |
651 | BRepBndLib::Add(aV, aBoxDS); |
652 | // |
653 | BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); |
654 | BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn(); |
655 | aMVIn.Add(nV); |
656 | } |
657 | // |
658 | return bRet; |
659 | } |
660 | |