summaryrefslogtreecommitdiff
path: root/src/BOPTools/BOPTools_PaveFiller_1.cxx
blob: b9d5530bb377a3d268b687e760b7d0fe347d3f02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
// File:	BOPTools_PaveFiller_1.cxx
// Created:	Tue Mar 13 16:12:16 2001
// Author:	Peter KURNEV
//		<pkv@irinox>


#include <BOPTools_PaveFiller.ixx>

#include <Precision.hxx>
#include <SortTools_QuickSortOfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TCollection_CompareOfReal.hxx>
#include <BRep_Tool.hxx>

#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>

#include <IntTools_Tools.hxx>
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_ShrunkRange.hxx>
#include <IntTools_EdgeFace.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_CommonPrt.hxx>
#include <IntTools_SequenceOfRanges.hxx>

#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
#include <BooleanOperations_OnceExplorer.hxx>

#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_IteratorOfCoupleOfShape.hxx>
#include <BOPTools_VVInterference.hxx>
#include <BOPTools_VEInterference.hxx>
#include <BOPTools_EEInterference.hxx>
#include <BOPTools_CArray1OfVEInterference.hxx>
#include <BOPTools_CArray1OfVVInterference.hxx>
#include <BOPTools_CArray1OfEEInterference.hxx>
#include <BOPTools_Tools.hxx>
#include <BOPTools_Pave.hxx>
#include <BOPTools_PaveSet.hxx>
#include <BOPTools_PaveBlockIterator.hxx>
#include <BOPTools_ListOfPave.hxx>
#include <BOPTools_ListIteratorOfListOfPave.hxx>
#include <BOPTools_ListOfPaveBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_CommonBlock.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_ESInterference.hxx>
#include <BOPTools_CommonBlockAPI.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_ListIteratorOfListOfInterference.hxx>
#include <BOPTools_Interference.hxx>
#include <BOPTools_InterferenceLine.hxx>
#include <BOPTools_CArray1OfInterferenceLine.hxx>

#include <BOPTColStd_Failure.hxx>

#include <stdio.h>

//=======================================================================
// function: PerformEF
// purpose: 
//=======================================================================
  void BOPTools_PaveFiller::PerformEF() 
{
  myIsDone=Standard_False;
  
  Standard_Integer n1, n2, anIndexIn=0, nE, nF, aNbEFs, aBlockLength;

  BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences();
  //
  // E/F Interferences  [BooleanOperations_EdgeFace]
  myDSIt.Initialize(TopAbs_EDGE, TopAbs_FACE);
  //
  // BlockLength correction
  aNbEFs=ExpectedPoolLength();
  aBlockLength=aEFs.BlockLength();
  if (aNbEFs > aBlockLength) {
    aEFs.SetBlockLength(aNbEFs);
  }
  //
  for (; myDSIt.More(); myDSIt.Next()) {
    Standard_Boolean justaddinterference = Standard_True;
    myDSIt.Current(n1, n2, justaddinterference);
    
    if(justaddinterference) {
      if (!myIntrPool->IsComputed(n1, n2)) {
	anIndexIn = 0;
	nE=n1; 
	nF=n2; 
	SortTypes(nE, nF);
	myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
      }
      continue;
    }
    //
    if (myIntrPool->IsComputed(n1, n2)) {
      continue;
    }
    //
    nE=n1; 
    nF=n2; 
    SortTypes(nE, nF);
    //
    // ListOfCommonBlock for nE and CommonBlockAPI object to avoid
    // CommonBlocks processing
    BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
    BOPTools_CommonBlockAPI aCBAPI(aLCB);
    //
    Standard_Real aTolE, aTolF, aDeflection=0.01;
    Standard_Integer aDiscretize=35;

    // modified by NIZHNY-MKK  Thu Oct 27 12:31:45 2005
//     const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE));
    TopoDS_Edge aE=TopoDS::Edge(myDS->GetShape(nE));
    //
    if (BRep_Tool::Degenerated(aE)){
      continue;
    }
    //
    aTolE=BRep_Tool::Tolerance(aE);

    // modified by NIZHNY-MKK  Thu Oct 27 12:31:52 2005
//     const TopoDS_Face& aF=TopoDS::Face(myDS->GetShape(nF));
    TopoDS_Face aF=TopoDS::Face(myDS->GetShape(nF));
    aTolF=BRep_Tool::Tolerance(aF);
// modified by NIZHNY-MKK  Thu Oct 27 12:32:02 2005
//     const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); 
    Bnd_Box aBBF=myDS->GetBoundingBox(nF); 
    //
    BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
    BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);

    for (; anIt.More(); anIt.Next()) {

      BOPTools_PaveBlock& aPB=anIt.Value();

      if (aCBAPI.IsCommonBlock(aPB)) {
	// avoid CommonBlocks processing
	continue;
      }
      
      const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange();
      const IntTools_Range& aSR =aShrunkRange.ShrunkRange();
      const Bnd_Box&        aBBE=aShrunkRange.BndBox();

      //////////////////////////////////////////////
      if (aBBF.IsOut (aBBE)) {
	continue;
      }
      // 
      // EF
      IntTools_EdgeFace aEF;
      aEF.SetEdge (aE);
      aEF.SetFace (aF);
      aEF.SetTolE (aTolE);
      aEF.SetTolF (aTolF);
      aEF.SetDiscretize (aDiscretize);
      aEF.SetDeflection (aDeflection);
      // 
      aEF.SetContext((IntTools_PContext)&myContext);
      // 

      BRepAdaptor_Curve aCurve(aE);
      IntTools_Range anewSR = aSR;
      // 
      // Correction of the Shrunk Range 
      //
      BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR);
      //
      aEF.SetRange (anewSR);
      //
      aEF.Perform();
      //
      anIndexIn=0;
      //
      if (aEF.IsDone()) {
	//
	const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts();
	Standard_Integer i, aNbCPrts;
	aNbCPrts=aCPrts.Length();

	// modified by NIZHNY-MKK  Thu Aug 26 17:37:07 2004.BEGIN
	if(aNbCPrts != 0) {
	  char buf[512];

	  if(!aShrunkRange.IsDone()) {
	    sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE);
	    throw BOPTColStd_Failure(buf) ;
	  }
	}
	// modified by NIZHNY-MKK  Thu Aug 26 17:37:09 2004.END

	for (i=1; i<=aNbCPrts; i++) {
	  const IntTools_CommonPrt& aCPart=aCPrts.Value(i);
	  //
	  anIndexIn=0;
	  //
	  TopAbs_ShapeEnum aType=aCPart.Type();
	  switch (aType) {
	      
	    case TopAbs_VERTEX:  {
		
	      Standard_Real aT; 
	      Standard_Integer aNewShape;
	      
	      const IntTools_Range& aR=aCPart.Range1();

	      Standard_Real aRFirst, aRLast;

	      aR.Range(aRFirst, aRLast);
	      aT=0.5*(aRFirst+aRLast);

	      if((aCPart.VertexParameter1() >= aRFirst) &&
		 (aCPart.VertexParameter1() <= aRLast)) {
		aT = aCPart.VertexParameter1();
	      }
	      
	      TopoDS_Vertex aNewVertex;
	      BOPTools_Tools::MakeNewVertex(aE, aT, aF,aNewVertex);
	      //
	      Standard_Boolean isonpave1, isonpave2;
	      Standard_Real aTolToDecide;
	      aTolToDecide=5.e-8;

	      // modified by NIZHNY-IFV  Feb 15   2007
	      // for occ11565
	      //Check that whole edge belongs face
	      isonpave1 = (Abs(anewSR.First() - aRFirst) < aTolToDecide);
	      isonpave2 = (Abs(anewSR.Last()  - aRLast)  < aTolToDecide);
	      //++
	      if(isonpave1 && isonpave2) {
		//Seems whole edge belongs face
		
		Standard_Boolean aCoinsideFlag = 
		  BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
		if (aCoinsideFlag) {
		//
		  // Add Interference to the Pool
		  
		  IntTools_CommonPrt aCP = aCPart;
		  aCP.SetType(TopAbs_EDGE);
		  BOPTools_ESInterference anInterf (nE, nF, aCP);
		  anIndexIn=aEFs.Append(anInterf);
		  myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
		  //
		  BOPTools_CommonBlock aCB(aPB, nF);
	      
		  aLCB.Append(aCB);
		  break;
		}
	      }
	      // modified by NIZHNY-IFV  Feb 15   2007. end
	      //
	      //decide to add pave or not.begin
	      isonpave1  = (Abs(anewSR.First() - aT) < aTolToDecide);
	      isonpave2  = (Abs(anewSR.Last()  - aT) < aTolToDecide);

	      // modified by NIZHNY-MKK  Wed Nov  6 14:43:07 2002.BEGIN
	      if(!isonpave1 && !isonpave2) {
		isonpave1 = (Abs(anewSR.First() - aR.First()) < aTolToDecide);
		isonpave2 = (Abs(anewSR.Last()  - aR.Last())  < aTolToDecide);
	      }
	      // modified by NIZHNY-MKK  Wed Nov  6 14:43:11 2002.END
	      //++
	      {
		Standard_Integer nVP1, nVP2;
		Standard_Boolean bIsComputed;
		
		// Pave 1
		const BOPTools_Pave& aPave1=aPB.Pave1();
		nVP1=aPave1.Index();

		bIsComputed=Standard_True;
		if (nVP1 <= myNbSources) {

		  if(((nVP1 <= myDS->NumberOfShapesOfTheObject()) &&
		      (nF <= myDS->NumberOfShapesOfTheObject())) ||
		     ((nVP1 > myDS->NumberOfShapesOfTheObject()) &&
		      (nF > myDS->NumberOfShapesOfTheObject()))) {
		    bIsComputed=myIntrPool->IsComputed(nVP1, nE);

		    if (!bIsComputed) {
		      bIsComputed=IsSuccesstorsComputed(nVP1, nE);
		    }
		  }
		  else {
		    bIsComputed=myIntrPool->IsComputed(nVP1, nF);
		    if (!bIsComputed) {
		      bIsComputed=IsSuccesstorsComputed(nVP1, nF);
		    }
		  }
		}

		if (bIsComputed && isonpave1) {
		  //
		  myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
		  const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP1));
		  BOPTools_Tools::UpdateVertex(aE, aT, aVF);
		  continue;
		}
		// Pave 2
		const BOPTools_Pave& aPave2=aPB.Pave2();
		nVP2=aPave2.Index();

		bIsComputed=Standard_True;
		if (nVP2 <= myNbSources) {

		  if((nVP2 <= myDS->NumberOfShapesOfTheObject() &&
		     nF <= myDS->NumberOfShapesOfTheObject()) ||
		     (nVP2 > myDS->NumberOfShapesOfTheObject() &&
		      nF > myDS->NumberOfShapesOfTheObject())) {
		    bIsComputed=myIntrPool->IsComputed(nVP2, nE);

		    if (!bIsComputed) {
		      bIsComputed=IsSuccesstorsComputed(nVP2, nE);
		    }
		  }
		  else {
		    bIsComputed=myIntrPool->IsComputed(nVP2, nF);
		    if (!bIsComputed) {
		      bIsComputed=IsSuccesstorsComputed(nVP2, nF);
		    }
		  }
		}
		
		if (bIsComputed && isonpave2) {
		  //
		  myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
		  const TopoDS_Vertex& aVF = TopoDS::Vertex(myDS->Shape(nVP2));
		  BOPTools_Tools::UpdateVertex(aE, aT, aVF);
		  continue;
		}
	      }	      
	      //decide to add pave or not.end
	      //
	      // Insert New Vertex in DS;
	      // aNewShape is # of DS-line, where aNewVertex is kept
	      //
	      BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; 
	      //
	      Standard_Integer nVF;
	      nVF=CheckFacePaves(aNewVertex, nF);
	      if (nVF) {
		const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
		
		Standard_Real aTNew;
		//
		myContext.ComputeVE(aVF, aE, aTNew);
		//
		aT=aTNew;
		aNewShape=nVF;
		BOPTools_Tools::UpdateVertex(aVF, aNewVertex);
	      }
	      //
	      else {
		myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
		aNewShape=myDS->NumberOfInsertedShapes();
	      }
	      //
	      // Add Interference to the Pool
	      BOPTools_ESInterference anInterf (nE, nF, aCPart);
	      anIndexIn=aEFs.Append(anInterf);
	      myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
	      //
	      // State of the new Vertex is ON
	      myDS->SetState (aNewShape, BooleanOperations_ON);
	      //
	      // Insert New Vertex in EE Interference
	      BOPTools_ESInterference& aESInterf= aEFs(anIndexIn);
	      aESInterf.SetNewShape(aNewShape);
	      //
	      // Add Pave to the myPavePoolNew
	      BOPTools_Pave aPave;
	      aPave.SetInterference(anIndexIn);
	      aPave.SetType (BooleanOperations_EdgeSurface);
	      aPave.SetIndex(aNewShape);
	      
	      aPave.SetParam(aT);
	      BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
	      aPaveSet.Append(aPave);
	      
	    }// case TopAbs_VERTEX:
	      break;

	    case TopAbs_EDGE: {
	      
	      Standard_Boolean aCoinsideFlag;
	      aCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
	      if (!aCoinsideFlag) {
		//
		myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
		break;
	      }
	      // Add Interference to the Pool
	      BOPTools_ESInterference anInterf (nE, nF, aCPart);
	      anIndexIn=aEFs.Append(anInterf);
	      myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn);
	      //
	      BOPTools_CommonBlock aCB(aPB, nF);
	      
	      aLCB.Append(aCB);
	      
	    }// case TopAbs_EDGE:
	      break;

	    default:
	      break;
	  } // switch (aType) 
	} // for (i=1; i<=aNbCPrts; i++) 
      } //if (aEF.IsDone())
    } // for (; anIt.More(); anIt.Next()) 
  }// for (; myDSIt.More(); myDSIt.Next()) 
  myIsDone=Standard_True;
}


//=======================================================================
// function: DoSDEdges
// purpose: 
//=======================================================================
  void BOPTools_PaveFiller::DoSDEdges() 
{
  myIsDone=Standard_False;

  Standard_Integer aNbObj, nEObj, nETool, aSplitIndexObj, aSplitIndexTool;
  TopAbs_ShapeEnum aType;

  aNbObj=myDS->NumberOfShapesOfTheObject();
  
  for (nEObj=1; nEObj<=aNbObj; nEObj++) {
    // modified by NIZHNY-MKK  Thu Oct 27 12:32:37 2005
//     const TopoDS_Shape& aS=myDS->GetShape(nEObj);
    TopoDS_Shape aS=myDS->GetShape(nEObj);
    aType=aS.ShapeType();
    if (aType==TopAbs_EDGE) {
      //ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nEObj));
      
      BOPTools_ListOfCommonBlock& aLCBObj=myCommonBlockPool(myDS->RefEdge(nEObj));
      BOPTools_ListIteratorOfListOfCommonBlock anItCBObj(aLCBObj);
      for (; anItCBObj.More(); anItCBObj.Next()) {
	BOPTools_CommonBlock& aCBObj=anItCBObj.Value();
	
	if (aCBObj.Face()) {
	  continue;
	}
	
	BOPTools_PaveBlock& aPBObj1=aCBObj.PaveBlock1(nEObj);
	BOPTools_PaveBlock& aPBObj2=aCBObj.PaveBlock2(nEObj);
	//
	// Tool
	nETool=aPBObj2.OriginalEdge();

	BOPTools_ListOfCommonBlock& aLCBTool=myCommonBlockPool(myDS->RefEdge(nETool));
	BOPTools_ListIteratorOfListOfCommonBlock anItCBTool(aLCBTool);
	for (; anItCBTool.More(); anItCBTool.Next()) {
	  BOPTools_CommonBlock& aCBTool=anItCBTool.Value();
	  
	  BOPTools_PaveBlock& aPBTool1=aCBTool.PaveBlock1(nETool);
	  BOPTools_PaveBlock& aPBTool2=aCBTool.PaveBlock2(nETool);
	  
	  if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1)) {
	    //
	    // That is aCBObj==aCBTool
	    // Find SplitIndices in DS for aPBObj1 and aPBTool1
	    aSplitIndexObj =SplitIndex(aPBObj1);
	    aSplitIndexTool=SplitIndex(aPBTool1);
	    if (aSplitIndexObj && aSplitIndexTool) {
	      
	      aPBObj1. SetEdge(aSplitIndexObj);
	      aPBObj2. SetEdge(aSplitIndexTool);
	      aPBTool1.SetEdge(aSplitIndexTool);
	      aPBTool2.SetEdge(aSplitIndexObj);
	      break;
	    }
	    else {
	      //error: can not find SplitIndex
	      throw 
		BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex");
#ifndef _MSC_VER
	      myIsDone=Standard_False;
	      return;
#endif
	    }
	    
	  } // if (aPBTool1.IsEqual(aPBObj2) && aPBTool2.IsEqual(aPBObj1)) 
	} // for (; anItCBTool.More(); anItCBTool.Next()) 
      } // for (; anItCBObj.More(); anItCBObj.Next())
    } // if (aType==TopAbs_EDGE)
  } // for (nEObj=1; nEObj<=aNbObj; nEObj++)

  //
  // 2. EF CommonBlocks
  //
  Standard_Integer nE, aSplitIndex;
  for (nE=1; nE<=myNbSources; nE++) {
    // modified by NIZHNY-MKK  Thu Oct 27 12:32:57 2005
//     const TopoDS_Shape& aS=myDS->GetShape(nE);
    TopoDS_Shape aS=myDS->GetShape(nE);
    aType=aS.ShapeType();
    if (aType==TopAbs_EDGE) {
      //ZZ const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE));

      BOPTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
      BOPTools_ListIteratorOfListOfCommonBlock anItCB(aLCB);
      
      for (; anItCB.More(); anItCB.Next()) {
	BOPTools_CommonBlock& aCB=anItCB.Value();
	if (aCB.Face()) {
	  BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE);
	  aSplitIndex =SplitIndex(aPB);
	  if (aSplitIndex) {
	    aPB.SetEdge(aSplitIndex);
	    //break;
	  }
	  else {
	    //error: can not find SplitIndex
	    throw 
		BOPTColStd_Failure(" BOPTools_PaveFiller::DoSDEdges()=> can not find SplitIndex");
#ifndef _MSC_VER
	    myIsDone=Standard_False;
	    return;
#endif
	  }
	}
      }
    }
  }
  myIsDone=Standard_True;
}

//=======================================================================
// function: SplitIndex
// purpose: 
//=======================================================================
  Standard_Integer BOPTools_PaveFiller::SplitIndex(const BOPTools_PaveBlock& aPBx) 
{
  Standard_Integer anOriginalEdge, anEdgeIndex=0;

  anOriginalEdge=aPBx.OriginalEdge();

  BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge));
  BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);

  for (; anIt.More(); anIt.Next()) {
    BOPTools_PaveBlock& aPB=anIt.Value();
    if (aPB.IsEqual(aPBx)) {
      anEdgeIndex=aPB.Edge();
      return anEdgeIndex;
    }
  }
  return anEdgeIndex;
} 
//=======================================================================
// function: CheckFacePaves
// purpose: 
//=======================================================================
  Standard_Integer BOPTools_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aNewVertex,
							const Standard_Integer nF)
{
  Standard_Integer nEF, nVF, iFlag;
  BOPTools_ListIteratorOfListOfPave anIt;
  // 1.
  BooleanOperations_OnceExplorer aExp(*myDS);
  aExp.Init(nF, TopAbs_EDGE);
  for (; aExp.More(); aExp.Next()) {
    nEF=aExp.Current();
    BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nEF));
    const BOPTools_ListOfPave& aLP=aPaveSet.Set();
    anIt.Initialize(aLP);
    for (; anIt.More(); anIt.Next()) {
      const BOPTools_Pave& aPave=anIt.Value();
      nVF=aPave.Index();
      const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
      iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
      if (!iFlag) {
	return nVF;
      }
    }
  }
  //
  // 2.
  aExp.Init(nF, TopAbs_EDGE);
  for (; aExp.More(); aExp.Next()) {
    nEF=aExp.Current();
    BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF));
    const BOPTools_ListOfPave& aLP=aPaveSet.Set();
    anIt.Initialize(aLP);
    for (; anIt.More(); anIt.Next()) {
      const BOPTools_Pave& aPave=anIt.Value();
      nVF=aPave.Index();
      const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
      iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
      if (!iFlag) {
	return nVF;
      }
    }
  }
  
  return 0;
} 
//