Salome HOME
This commit was generated by cvs2git to create tag 'TRIPOLI_323'.
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_8.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        NMTTools_PaveFiller_8.cxx
24 // Created:     Fri Dec 19 11:15:53 2003
25 // Author:      Peter KURNEV
26 //              <pkv@irinox>
27 //
28 #include <NMTTools_PaveFiller.hxx>
29
30 #include <TColStd_MapOfInteger.hxx>
31 #include <TColStd_ListOfInteger.hxx>
32 #include <TColStd_ListIteratorOfListOfInteger.hxx>
33
34 #include <TopTools_ListOfShape.hxx>
35
36 #include <BooleanOperations_ShapesDataStructure.hxx>
37 #include <BooleanOperations_OnceExplorer.hxx>
38
39 #include <BOPTools_PaveBlock.hxx>
40 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
41 #include <BOPTools_ListOfPaveBlock.hxx>
42
43 #include <NMTDS_ShapesDataStructure.hxx>
44
45 #include <NMTTools_ListOfCommonBlock.hxx>
46 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
47 #include <NMTTools_CommonBlock.hxx>
48 #include <NMTTools_CommonBlockAPI.hxx>
49
50
51 // Modified  to add new method Thu Sep 14 14:35:18 2006
52 // Contribution of Samtech www.samcef.com BEGIN
53 //=======================================================================
54 // function:  SharedEdges
55 // purpose:
56 //=======================================================================
57   void NMTTools_PaveFiller::SharedEdges(const Standard_Integer nF1,
58                                         const Standard_Integer nF2,
59                                         TColStd_ListOfInteger& aLNE,
60                                         TopTools_ListOfShape& aLSE)
61 {
62   Standard_Integer nE1, nE2;
63   TColStd_MapOfInteger aM1;
64   //
65   BooleanOperations_ShapesDataStructure *pDS=myDS;
66   BooleanOperations_OnceExplorer aExp(*pDS);
67   //
68   aExp.Init(nF1, TopAbs_EDGE);
69   for (; aExp.More(); aExp.Next()) {
70     nE1=aExp.Current();
71     aM1.Add(nE1);
72   }
73
74   aExp.Init(nF2, TopAbs_EDGE);
75   for (; aExp.More(); aExp.Next()) {
76     nE2=aExp.Current();
77     if (aM1.Contains(nE2)) {
78       aLNE.Append(nE2);
79       const TopoDS_Shape& aE2=myDS->Shape(nE2);
80       aLSE.Append(aE2);
81     }
82   }
83 }
84 // Contribution of Samtech www.samcef.com END
85 //
86 //=======================================================================
87 // function: RealPaveBlock
88 // purpose:
89 //=======================================================================
90   const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock
91      (const BOPTools_PaveBlock& aPB,
92       TColStd_ListOfInteger& aLB,
93       Standard_Integer& aIsCommonBlock)
94 {
95   Standard_Integer nE, nSpx;
96   BOPTools_ListIteratorOfListOfPaveBlock aItPBx;
97   //
98   aIsCommonBlock=0;
99   aLB.Clear();
100   nE=aPB.OriginalEdge();
101   const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
102   NMTTools_CommonBlockAPI aCBAPI(aLCBE);
103   if (aCBAPI.IsCommonBlock(aPB)) {
104     NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
105     //
106     aIsCommonBlock=1;
107     //
108     const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
109     aItPBx.Initialize(aLPBx);
110     for (; aItPBx.More(); aItPBx.Next()) {
111       const BOPTools_PaveBlock& aPBx=aItPBx.Value();
112       nSpx=aPBx.Edge();
113       aLB.Append(nSpx);
114     }
115     //
116     const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
117     return aPBx;
118   }
119   return aPB;
120 }
121 //
122 //=======================================================================
123 // function: RealPaveBlock
124 // purpose:
125 //=======================================================================
126   const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB)
127 {
128   Standard_Integer nE;
129   //
130   nE=aPB.OriginalEdge();
131   const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
132   NMTTools_CommonBlockAPI aCBAPI(aLCBE);
133   if (aCBAPI.IsCommonBlock(aPB)) {
134     NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
135     const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1();
136     return aPBx;
137   }
138   return aPB;
139 }
140 //=======================================================================
141 // function: CommonBlocksFace
142 // purpose:
143 //=======================================================================
144   Standard_Integer NMTTools_PaveFiller::CommonBlocksFace(const Standard_Integer nF,
145                                                          NMTTools_ListOfCommonBlock& aLCB)
146 {
147   Standard_Integer nE;
148   TopAbs_ShapeEnum aT;
149   NMTTools_ListIteratorOfListOfCommonBlock anIt;
150   //
151   aT=myDS->GetShapeType(nF);
152   //
153   if (aT!=TopAbs_FACE) {
154     return 1; // Type mismatch
155   }
156   //
157   BooleanOperations_ShapesDataStructure *pDS=myDS;
158   BooleanOperations_OnceExplorer aExp(*pDS);
159   //
160   aExp.Init(nF, TopAbs_EDGE);
161   for (; aExp.More(); aExp.Next()) {
162     nE=aExp.Current();
163     const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE));
164     anIt.Initialize(aLCBE);
165     for (; anIt.More(); anIt.Next()) {
166       const NMTTools_CommonBlock& aCBE=anIt.Value();
167       aLCB.Append(aCBE);
168     }
169   }
170   return 0; //Ok
171 }
172 //
173 // 1 RealSplits
174 //
175 //
176 //=======================================================================
177 // function: RealSplitsFace
178 // purpose:
179 //=======================================================================
180   void NMTTools_PaveFiller::RealSplitsFace(const Standard_Integer nF,
181                                            BOPTools_ListOfPaveBlock& aLPB)
182 {
183   Standard_Integer nE;
184   BOPTools_ListIteratorOfListOfPaveBlock anIt;
185   //
186   BooleanOperations_ShapesDataStructure *pDS=myDS;
187   BooleanOperations_OnceExplorer aExp(*pDS);
188   //
189   aExp.Init(nF, TopAbs_EDGE);
190   for (; aExp.More(); aExp.Next()) {
191     nE=aExp.Current();
192     const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
193     anIt.Initialize(aLPBE);
194     for (; anIt.More(); anIt.Next()) {
195       const BOPTools_PaveBlock& aPB=anIt.Value();
196       const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
197       aLPB.Append(aPBR);
198     }
199   }
200 }
201 //=======================================================================
202 // function: HasRealSplitsInOnFace
203 // purpose:
204 //=======================================================================
205   Standard_Boolean NMTTools_PaveFiller::HasRealSplitsInOnFace(const Standard_Integer nF1,
206                                                               const Standard_Integer nF2)
207 {
208   Standard_Boolean bFlag;
209   BOPTools_ListOfPaveBlock aLPB;
210   //
211   RealSplitsInFace(0, nF1, nF2, aLPB);
212   //
213   bFlag=!aLPB.IsEmpty();
214   if (bFlag) {
215     return bFlag;
216   }
217   //
218   RealSplitsInFace(0, nF1, nF2, aLPB);
219   //
220   bFlag=!aLPB.IsEmpty();
221   return bFlag;
222 }
223 //=======================================================================
224 // function: RealSplitsInFace
225 // purpose:
226 //=======================================================================
227   void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer ,//for overriding
228                                              const Standard_Integer nF1,
229                                              const Standard_Integer nF2,
230                                              BOPTools_ListOfPaveBlock& aLPB)
231 {
232   Standard_Integer nE1;
233   //
234   BooleanOperations_ShapesDataStructure *pDS=myDS;
235   BooleanOperations_OnceExplorer aExp(*pDS);
236   aExp.Init(nF1, TopAbs_EDGE);
237   for (; aExp.More(); aExp.Next()) {
238     nE1=aExp.Current();
239     RealSplitsInFace (nE1, nF2, aLPB);
240   }
241 }
242 //=======================================================================
243 // function: RealSplitsInFace
244 // purpose:
245 //=======================================================================
246   void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nE1,
247                                              const Standard_Integer nF2,
248                                              BOPTools_ListOfPaveBlock& aLPB)
249 {
250   Standard_Integer nF1;
251   //
252   TColStd_ListIteratorOfListOfInteger anItLFCB;
253   NMTTools_ListIteratorOfListOfCommonBlock anItCB;
254   //
255   const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
256   //
257   anItCB.Initialize(aLCB);
258   for (; anItCB.More(); anItCB.Next()) {
259     NMTTools_CommonBlock& aCB=anItCB.ChangeValue();
260     const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
261     const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
262
263     const TColStd_ListOfInteger& aLFCB=aCB.Faces();
264     anItLFCB.Initialize(aLFCB);
265     for (; anItLFCB.More(); anItLFCB.Next()) {
266       nF1=anItLFCB.Value();
267       if (nF1==nF2) {
268         aLPB.Append(aPB1R);
269       }
270     }
271   }
272 }
273 //=======================================================================
274 // function: RealSplitsOnEdge
275 // purpose:
276 //=======================================================================
277   void NMTTools_PaveFiller::RealSplitsOnEdge(const Standard_Integer nE1,
278                                              const Standard_Integer nE2,
279                                              BOPTools_ListOfPaveBlock& aLPB)
280 {
281   Standard_Integer nE;
282   //
283   BOPTools_ListIteratorOfListOfPaveBlock anIt;
284   NMTTools_ListIteratorOfListOfCommonBlock anItCB;
285   //
286   const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
287
288   anItCB.Initialize(aLCB);
289   for (; anItCB.More(); anItCB.Next()) {
290     NMTTools_CommonBlock& aCB=anItCB.ChangeValue();
291     const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
292     const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1);
293     //
294     const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
295     anIt.Initialize(aLPBx);
296     for (; anIt.More(); anIt.Next()) {
297       const BOPTools_PaveBlock& aPB2=anIt.Value();
298       nE=aPB2.OriginalEdge();
299       if (nE==nE2) {
300         aLPB.Append(aPB1R);
301       }
302     }
303   }
304 }
305 //=======================================================================
306 // function: RealSplitsOnFace
307 // purpose:
308 //=======================================================================
309   void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer nE1,
310                                              const Standard_Integer nF2,
311                                              BOPTools_ListOfPaveBlock& aLPB)
312 {
313   Standard_Integer nE2;
314   //
315   BooleanOperations_ShapesDataStructure *pDS=myDS;
316   BooleanOperations_OnceExplorer aExp(*pDS);
317   aExp.Init(nF2, TopAbs_EDGE);
318   for (; aExp.More(); aExp.Next()) {
319     nE2=aExp.Current();
320     RealSplitsOnEdge(nE1, nE2, aLPB);
321   }
322 }
323 //=======================================================================
324 // function: RealSplitsOnFace
325 // purpose:
326 //=======================================================================
327   void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer ,//for overriding
328                                              const Standard_Integer nF1,
329                                              const Standard_Integer nF2,
330                                              BOPTools_ListOfPaveBlock& aLPB)
331 {
332   Standard_Integer nE1;
333   //
334 //   BooleanOperations_ShapesDataStructure *pDS=myDS;
335   BooleanOperations_OnceExplorer aExp(*myDS);
336   aExp.Init(nF1, TopAbs_EDGE);
337   for (; aExp.More(); aExp.Next()) {
338     nE1=aExp.Current();
339     RealSplitsOnFace(nE1, nF2, aLPB);
340   }
341 }
342
343 // 2 SimpleSplits
344 //=======================================================================
345 // function: SplitsFace
346 // purpose:
347 //=======================================================================
348   Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
349                                                    BOPTools_ListOfPaveBlock& aLPB)
350 {
351   Standard_Integer nE;
352   TopAbs_ShapeEnum aT;
353   BOPTools_ListIteratorOfListOfPaveBlock anIt;
354   //
355   aT=myDS->GetShapeType(nF);
356   //
357   if (aT!=TopAbs_FACE) {
358     return 1; // Type mismatch
359   }
360   //
361   BooleanOperations_ShapesDataStructure *pDS=myDS;
362   BooleanOperations_OnceExplorer aExp(*pDS);
363   //
364   aExp.Init(nF, TopAbs_EDGE);
365   for (; aExp.More(); aExp.Next()) {
366     nE=aExp.Current();
367     const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE));
368     anIt.Initialize(aLPBE);
369     for (; anIt.More(); anIt.Next()) {
370       const BOPTools_PaveBlock& aPBE=anIt.Value();
371       aLPB.Append(aPBE);
372     }
373   }
374   return 0; //Ok
375 }
376
377 //=======================================================================
378 // function: SplitsInFace
379 // purpose: splits of edges from nF1 in nF2
380 //=======================================================================
381   Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
382                                                      const Standard_Integer nF1,
383                                                      const Standard_Integer nF2,
384                                                      BOPTools_ListOfPaveBlock& aLPB)
385 {
386   Standard_Integer nE1;
387   TopAbs_ShapeEnum aT1, aT2;
388
389   aT1=myDS->GetShapeType(nF1);
390   aT2=myDS->GetShapeType(nF2);
391
392   if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
393     return 1; // Type mismatch
394   }
395   BooleanOperations_ShapesDataStructure *pDS=myDS;
396   BooleanOperations_OnceExplorer aExp(*pDS);
397   aExp.Init(nF1, TopAbs_EDGE);
398   for (; aExp.More(); aExp.Next()) {
399     nE1=aExp.Current();
400     SplitsInFace (nE1, nF2, aLPB);
401   }
402   return 0; //Ok
403 }
404 //=======================================================================
405 // function: SplitsInFace
406 // purpose: splits of edge nE1 in aFace2
407 //=======================================================================
408   Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
409                                                      const Standard_Integer nF2,
410                                                      BOPTools_ListOfPaveBlock& aLPB)
411 {
412   Standard_Integer nF1;
413   TopAbs_ShapeEnum aT1, aT2;
414
415   aT1=myDS->GetShapeType(nE1);
416   aT2=myDS->GetShapeType(nF2);
417
418   if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
419     return 1; // Type mismatch
420   }
421   //
422   TColStd_ListIteratorOfListOfInteger anItLFCB;
423   NMTTools_ListIteratorOfListOfCommonBlock anItCB;
424   //
425   const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
426   //
427   anItCB.Initialize(aLCB);
428   for (; anItCB.More(); anItCB.Next()) {
429     NMTTools_CommonBlock& aCB=anItCB.ChangeValue();
430     const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);
431
432     const TColStd_ListOfInteger& aLFCB=aCB.Faces();
433     anItLFCB.Initialize(aLFCB);
434     for (; anItLFCB.More(); anItLFCB.Next()) {
435       nF1=anItLFCB.Value();
436       if (nF1==nF2) {
437         aLPB.Append(aPB1);
438       }
439     }
440   }
441   return 0; //Ok
442 }
443 //=======================================================================
444 // function: SplitsOnEdge
445 // purpose:  splits of edge nE1 on nE2
446 //=======================================================================
447   Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
448                                                      const Standard_Integer nE2,
449                                                      BOPTools_ListOfPaveBlock& aLPB)
450 {
451   Standard_Integer nE;
452   TopAbs_ShapeEnum aT1, aT2;
453
454   aT1=myDS->GetShapeType(nE1);
455   aT2=myDS->GetShapeType(nE2);
456
457   if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) {
458     return 1; // Type mismatch
459   }
460   //
461   BOPTools_ListIteratorOfListOfPaveBlock anIt;
462   NMTTools_ListIteratorOfListOfCommonBlock anItCB;
463   //
464   const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1));
465
466   anItCB.Initialize(aLCB);
467   for (; anItCB.More(); anItCB.Next()) {
468     NMTTools_CommonBlock& aCB=anItCB.ChangeValue();
469     const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);//XXX
470     //
471     const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks();
472     anIt.Initialize(aLPBx);
473     for (; anIt.More(); anIt.Next()) {
474       const BOPTools_PaveBlock& aPB2=anIt.Value();
475       nE=aPB2.OriginalEdge();
476       if (nE==nE2) {
477         aLPB.Append(aPB1);
478       }
479     }
480   }
481   return 0; //Ok
482 }
483 //=======================================================================
484 // function: SplitsOnFace
485 // purpose:  splits of edge nE1 on face nF2
486 //=======================================================================
487   Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
488                                                      const Standard_Integer nF2,
489                                                      BOPTools_ListOfPaveBlock& aLPB)
490 {
491   Standard_Integer nE2, ip;
492   TopAbs_ShapeEnum aT1, aT2;
493
494   aT1=myDS->GetShapeType(nE1);
495   aT2=myDS->GetShapeType(nF2);
496
497   if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) {
498     return 1; // Type mismatch
499   }
500   BooleanOperations_ShapesDataStructure *pDS=myDS;
501   BooleanOperations_OnceExplorer aExp(*pDS);
502   aExp.Init(nF2, TopAbs_EDGE);
503   for (; aExp.More(); aExp.Next()) {
504     nE2=aExp.Current();
505     ip=SplitsOnEdge(nE1, nE2, aLPB);
506     if (ip) {
507       return ip;
508     }
509   }
510   return 0; //Ok
511 }
512 //=======================================================================
513 // function: SplitsOnFace
514 // purpose:  splits of edges from face nF1 on face nF2
515 //=======================================================================
516   Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
517                                                      const Standard_Integer nF1,
518                                                      const Standard_Integer nF2,
519                                                      BOPTools_ListOfPaveBlock& aLPB)
520 {
521   Standard_Integer nE1, ip;
522   TopAbs_ShapeEnum aT1, aT2;
523
524   aT1=myDS->GetShapeType(nF1);
525   aT2=myDS->GetShapeType(nF2);
526
527   if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
528     return 1; // Type mismatch
529   }
530 //   BooleanOperations_ShapesDataStructure *pDS=myDS;
531   BooleanOperations_OnceExplorer aExp(*myDS);
532   aExp.Init(nF1, TopAbs_EDGE);
533   for (; aExp.More(); aExp.Next()) {
534     nE1=aExp.Current();
535     ip=SplitsOnFace(nE1, nF2, aLPB);
536     if (ip) {
537       return ip;
538     }
539   }
540   return 0; //Ok
541 }
542
543 // 3 Simple Splits indices
544 //=======================================================================
545 // function: SplitsFace
546 // purpose:
547 //=======================================================================
548   Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF,
549                                                    TColStd_ListOfInteger& aSplits)
550 {
551   Standard_Integer nE, iErr;
552   BOPTools_ListIteratorOfListOfPaveBlock aIt;
553   BOPTools_ListOfPaveBlock aLPB;
554   //
555   iErr=SplitsFace(nF, aLPB);
556    if (iErr) {
557     return iErr;
558   }
559
560   aIt.Initialize(aLPB);
561   for (; aIt.More(); aIt.Next()) {
562     const BOPTools_PaveBlock& aPB=aIt.Value();
563     nE=aPB.Edge();
564     aSplits.Append(nE);
565   }
566   return 0; //Ok
567 }
568
569 //=======================================================================
570 // function: SplitsInFace
571 // purpose: splits of edges from nF1 in nF2
572 //=======================================================================
573   Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding
574                                                      const Standard_Integer nF1,
575                                                      const Standard_Integer nF2,
576                                                      TColStd_ListOfInteger& aSplits)
577 {
578   Standard_Integer nE, iErr;
579   BOPTools_ListIteratorOfListOfPaveBlock aIt;
580   BOPTools_ListOfPaveBlock aLPB;
581   //
582   iErr=SplitsInFace(0, nF1, nF2, aLPB);
583   if (iErr) {
584     return iErr;
585   }
586   aIt.Initialize(aLPB);
587   for (; aIt.More(); aIt.Next()) {
588     const BOPTools_PaveBlock& aPB=aIt.Value();
589     nE=aPB.Edge();
590     aSplits.Append(nE);
591   }
592   return iErr;
593 }
594 //=======================================================================
595 // function: SplitsInFace
596 // purpose: splits of edge nE1 in aFace2
597 //=======================================================================
598   Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1,
599                                                      const Standard_Integer nF2,
600                                                      TColStd_ListOfInteger& aSplits)
601 {
602   Standard_Integer nE, iErr;
603   BOPTools_ListIteratorOfListOfPaveBlock aIt;
604   BOPTools_ListOfPaveBlock aLPB;
605   //
606   iErr=SplitsInFace(nE1, nF2, aLPB);
607   if (iErr) {
608     return iErr;
609   }
610   aIt.Initialize(aLPB);
611   for (; aIt.More(); aIt.Next()) {
612     const BOPTools_PaveBlock& aPB=aIt.Value();
613     nE=aPB.Edge();
614     aSplits.Append(nE);
615   }
616   return iErr;
617 }
618 //=======================================================================
619 // function: SplitsOnEdge
620 // purpose:  splits of edge nE1 on nE2
621 //=======================================================================
622   Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1,
623                                                      const Standard_Integer nE2,
624                                                      TColStd_ListOfInteger& aSplits)
625 {
626   Standard_Integer nE, iErr;
627   BOPTools_ListIteratorOfListOfPaveBlock aIt;
628   BOPTools_ListOfPaveBlock aLPB;
629   //
630   iErr=SplitsOnEdge(nE1, nE2, aLPB);
631   if (iErr) {
632     return iErr;
633   }
634   aIt.Initialize(aLPB);
635   for (; aIt.More(); aIt.Next()) {
636     const BOPTools_PaveBlock& aPB=aIt.Value();
637     nE=aPB.Edge();
638     aSplits.Append(nE);
639   }
640   return iErr;
641 }
642 //=======================================================================
643 // function: SplitsOnFace
644 // purpose:  splits of edge nE1 on face nF2
645 //=======================================================================
646   Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1,
647                                                      const Standard_Integer nF2,
648                                                      TColStd_ListOfInteger& aSplits)
649 {
650   Standard_Integer nE, iErr;
651   BOPTools_ListIteratorOfListOfPaveBlock aIt;
652   BOPTools_ListOfPaveBlock aLPB;
653   //
654   iErr=SplitsOnEdge(nE1, nF2, aLPB);
655   if (iErr) {
656     return iErr;
657   }
658   aIt.Initialize(aLPB);
659   for (; aIt.More(); aIt.Next()) {
660     const BOPTools_PaveBlock& aPB=aIt.Value();
661     nE=aPB.Edge();
662     aSplits.Append(nE);
663   }
664   return iErr;
665 }
666 //=======================================================================
667 // function: SplitsOnFace
668 // purpose:  splits of edges from face nF1 on face nF2
669 //=======================================================================
670   Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding
671                                                      const Standard_Integer nF1,
672                                                      const Standard_Integer nF2,
673                                                      TColStd_ListOfInteger& aSplits)
674 {
675   Standard_Integer nE, iErr;
676   BOPTools_ListIteratorOfListOfPaveBlock aIt;
677   BOPTools_ListOfPaveBlock aLPB;
678   //
679   iErr=SplitsOnFace(0, nF1, nF2, aLPB);
680    if (iErr) {
681     return iErr;
682   }
683
684   aIt.Initialize(aLPB);
685   for (; aIt.More(); aIt.Next()) {
686     const BOPTools_PaveBlock& aPB=aIt.Value();
687     nE=aPB.Edge();
688     aSplits.Append(nE);
689   }
690   return 0; //Ok
691 }
692 //modified by NIZNHY-PKV Mon Oct 17 12:07:48 2011f
693 static
694   void SortPaveBlocks(BOPTools_ListOfPaveBlock &);
695 static
696   void SortShell(const Standard_Integer,
697                  BOPTools_PaveBlock *);
698 static
699   Standard_Boolean Less(const BOPTools_PaveBlock &,
700                         const BOPTools_PaveBlock &);
701
702 //=======================================================================
703 // function: RealSplitsInFace
704 // purpose:
705 //=======================================================================
706   void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nF,
707                                              BOPTools_ListOfPaveBlock& aLPBIn)
708 {
709   Standard_Integer j, aNbCBP, nSpIn;
710   TColStd_MapOfInteger aMFence;
711   BOPTools_ListOfPaveBlock aLPB;
712   BOPTools_ListIteratorOfListOfPaveBlock aItPB;
713   NMTTools_ListIteratorOfListOfCommonBlock aItCB;
714   //
715   NMTTools_CommonBlockPool& aCBP=ChangeCommonBlockPool();
716   //
717   aNbCBP=aCBP.Extent();
718   for (j=1; j<=aNbCBP; ++j) {
719     NMTTools_ListOfCommonBlock& aLCB=aCBP(j);
720     aItCB.Initialize(aLCB);
721     for (; aItCB.More(); aItCB.Next()) {
722       NMTTools_CommonBlock& aCB=aItCB.ChangeValue();
723       if (aCB.IsPaveBlockOnFace(nF)) {
724         const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
725         nSpIn=aPB1.Edge();
726         if (aMFence.Add(nSpIn)){
727           aLPB.Append(aPB1);
728         }
729       }
730     }
731   }
732   //
733   SortPaveBlocks(aLPB);
734   //
735   aItPB.Initialize(aLPB);
736   for (; aItPB.More(); aItPB.Next()) {
737     const BOPTools_PaveBlock& aPB=aItPB.Value();
738     aLPBIn.Append(aPB);
739   }
740 }
741 //=======================================================================
742 // function: SortPaveBlocks
743 // purpose:
744 //=======================================================================
745 void SortPaveBlocks(BOPTools_ListOfPaveBlock &aLPBIn)
746 {
747   Standard_Integer i, aNbPBIn;
748   BOPTools_ListIteratorOfListOfPaveBlock aItPB;
749   BOPTools_PaveBlock *pPB;
750   //
751   aNbPBIn=aLPBIn.Extent();
752   if (aNbPBIn<2) {
753     return;
754   }
755   //
756   pPB=new BOPTools_PaveBlock[aNbPBIn];
757   //
758   aItPB.Initialize(aLPBIn);
759   for (i=0; aItPB.More(); aItPB.Next(), ++i) {
760     const BOPTools_PaveBlock& aPB=aItPB.Value();
761     pPB[i]=aPB;
762   }
763   //
764   SortShell(aNbPBIn, pPB);
765   //
766   aLPBIn.Clear();
767   for (i=0; i<aNbPBIn; ++i) {
768     aLPBIn.Append(pPB[i]);
769   }
770   //
771   delete [] (BOPTools_PaveBlock*)pPB;
772 }
773 //=======================================================================
774 //function : SortShell
775 //purpose  :
776 //=======================================================================
777 void SortShell(const Standard_Integer n,
778                BOPTools_PaveBlock *a)
779 {
780   Standard_Integer nd, i, j, l, d=1;
781   BOPTools_PaveBlock x;
782   //
783   while(d<=n) {
784     d*=2;
785   }
786   //
787   while (d) {
788     d=(d-1)/2;
789     //
790     nd=n-d;
791     for (i=0; i<nd; ++i) {
792       j=i;
793     m30:;
794       l=j+d;
795       if (Less(a[l], a[j])) {
796       //if (a[l] < a[j]){
797         x=a[j];
798         a[j]=a[l];
799         a[l]=x;
800         j-=d;
801         if (j > -1) goto m30;
802       }//if (a[l] < a[j]){
803     }//for (i=0; i<nd; ++i)
804   }//while (1)
805 }
806
807 //=======================================================================
808 //function : Less
809 //purpose  :
810 //=======================================================================
811 Standard_Boolean Less(const BOPTools_PaveBlock &aPB1,
812                       const BOPTools_PaveBlock &aPB2)
813 {
814   Standard_Boolean bRet;
815   Standard_Integer iE1, iE2;
816   Standard_Real aT11, aT12, aT21, aT22;
817   //
818   iE1=aPB1.OriginalEdge();
819   iE2=aPB2.OriginalEdge();
820   if (iE1!=iE2) {
821     bRet=(iE1<iE2);
822     return bRet;
823   }
824   //
825   aPB1.Parameters(aT11, aT12);
826   aPB2.Parameters(aT21, aT22);
827   bRet=(aT11<aT21);
828   return bRet;
829 }
830 //modified by NIZNHY-PKV Mon Oct 17 11:44:45 2011t