Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/geom.git] / src / NMTAlgo / NMTAlgo_Builder.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 // File:        NMTAlgo_Inter3d.cxx
21 // Created:     Tue Jan 27 15:14:13 2004
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24
25
26 #include <NMTAlgo_Builder.ixx>
27
28 #include <TColStd_IndexedMapOfInteger.hxx>
29
30 #include <TopoDS_Face.hxx>
31 #include <TopoDS.hxx>
32 #include <TopoDS_Compound.hxx>
33 #include <TopoDS_Edge.hxx>
34 #include <TopoDS_Shape.hxx>
35
36 #include <TopExp.hxx>
37 #include <TopExp_Explorer.hxx>
38
39 #include <BRep_Builder.hxx>
40 #include <BRep_Tool.hxx>
41
42 #include <TopTools_IndexedMapOfShape.hxx>
43 #include <TopTools_ListOfShape.hxx>
44 #include <TopTools_ListIteratorOfListOfShape.hxx>
45
46 #include <BOPTColStd_Dump.hxx>
47 #include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
48
49 #include <IntTools_Context.hxx>
50
51 #include <BOPTools_Tools3D.hxx>
52 #include <BOPTools_CArray1OfSSInterference.hxx>
53 #include <BOPTools_InterferencePool.hxx>
54 #include <BOPTools_SSInterference.hxx>
55 #include <BOPTools_SequenceOfCurves.hxx>
56 #include <BOPTools_Curve.hxx>
57 #include <BOPTools_SequenceOfCurves.hxx>
58 #include <BOPTools_SplitShapesPool.hxx>
59 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
60 #include <BOPTools_ListOfPaveBlock.hxx>
61 #include <BOPTools_PaveBlock.hxx>
62
63 #include <BOP_WireEdgeSet.hxx>
64 #include <BOP_FaceBuilder.hxx>
65 #include <BOP_BuilderTools.hxx>
66
67 #include <NMTDS_ShapesDataStructure.hxx>
68
69 #include <NMTTools_PaveFiller.hxx>
70 #include <NMTTools_ListOfCoupleOfShape.hxx>
71 #include <NMTTools_Tools.hxx>
72 #include <NMTTools_CoupleOfShape.hxx>
73 #include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
74 #include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
75
76 #include <TopoDS_Shell.hxx>
77 #include <NMTAlgo_Tools.hxx>
78 #include <TColStd_IndexedMapOfInteger.hxx>
79 #include <TopExp_Explorer.hxx>
80 #include <TopoDS_Iterator.hxx>
81
82 //=======================================================================
83 // function: NMTAlgo_Inter3d::NMTAlgo_Inter3d()
84 // purpose: 
85 //=======================================================================
86   NMTAlgo_Builder::NMTAlgo_Builder()
87 :
88   NMTAlgo_Algo()
89 {
90 }
91 //=======================================================================
92 // function: ~NMTAlgo_Builder
93 // purpose: 
94 //=======================================================================
95   NMTAlgo_Builder::~NMTAlgo_Builder()
96 {
97   Clear();
98 }
99 //=======================================================================
100 // function: Clear
101 // purpose: 
102 //=======================================================================
103   void NMTAlgo_Builder::Clear()
104 {
105   NMTAlgo_Algo::Clear();
106   //
107   myImagesEdges.Clear();
108   myImagesFaces.Clear();
109   myIn2DParts.Clear();
110   mySectionParts.Clear();
111   mySDFaces.Clear();
112 }
113 //=======================================================================
114 // function: ComputeWithFiller
115 // purpose: 
116 //=======================================================================
117   void NMTAlgo_Builder::ComputeWithFiller(const NMTTools_DSFiller& aDSF)
118 {
119   myErrorStatus=0;
120   myIsDone=Standard_False;
121   //
122   SetFiller(aDSF);
123   // edges
124   FillImagesEdges();
125   // faces
126   FillIn2DParts();
127   FillImagesFaces();
128   FillSDFaces();
129 }
130
131 //=======================================================================
132 // function: FillSDFaces
133 // purpose: 
134 //=======================================================================
135   void NMTAlgo_Builder::FillSDFaces()
136 {
137   const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
138   NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
139   BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*)&myDSFiller->InterfPool();
140   BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
141   IntTools_Context& aCtx= pPF->ChangeContext();
142   //
143   Standard_Boolean bIsSDF;
144   Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC;
145   TopTools_ListIteratorOfListOfShape aItF1, aItF2;
146   NMTTools_ListOfCoupleOfShape aLCS;   
147   //
148   mySDFaces.Clear();
149   //
150   // 1. For each FF find among images of faces
151   //    all pairs of same domain faces (SDF) [=> aLCS]
152   aNbFF=aFFs.Extent();
153   for (i=1; i<=aNbFF; ++i) {
154     BOPTools_SSInterference& aFF=aFFs(i);
155     aFF.Indices(nF1, nF2);
156     //
157     const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1));
158     const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2));
159     //
160     // if there are no in/on 2D split parts the faces nF1, nF2
161     // can not be SDF
162     const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks();
163     aNbPBInOn=aLPBInOn.Extent();
164     if (!aNbPBInOn) {
165       continue;
166     }
167     //
168     // if there is at least one section edge between faces nF1, nF2
169     // they can not be SDF
170     BOPTools_SequenceOfCurves& aSC=aFF.Curves();
171     aNbC=aSC.Length();
172     if (aNbC) {
173       continue;
174     }
175     //
176     // the faces are suspected to be SDF.
177     // Try to find SDF among images of nF1, nF2
178     const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1);
179     const TopTools_ListOfShape& aLF2=myImagesFaces.Image(aF2);
180     //
181     aItF1.Initialize(aLF1);
182     for (; aItF1.More(); aItF1.Next()) {
183       const TopoDS_Face& aF1x=TopoDS::Face(aItF1.Value());
184       //
185       aItF2.Initialize(aLF2);
186       for (; aItF2.More(); aItF2.Next()) {
187         const TopoDS_Face& aF2y=TopoDS::Face(aItF2.Value());
188         bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
189         if (bIsSDF) {
190           NMTTools_CoupleOfShape aCS;
191           //
192           aCS.SetShape1(aF1x);
193           aCS.SetShape2(aF2y);
194           aLCS.Append(aCS);
195         }
196       }
197     }
198   }//for (i=1; i<=aNbFF; ++i)
199   //
200   aNbC=aLCS.Extent();
201   if (!aNbC) {
202     return;
203   }
204   //
205   // 2. Find Chains
206   NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;  
207   //
208   NMTTools_Tools::FindChains(aLCS, aMC); 
209   //
210   // 3. Fill the map of SDF mySDFaces
211   aNbC=aMC.Extent();
212   for (i=1; i<=aNbC; ++i) {
213     const TopoDS_Shape& aF=aMC.FindKey(i);
214     const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
215     //
216     aNbFF=aMSDF.Extent();
217     for (j=1; j<=aNbFF; ++j) {
218       const TopoDS_Shape& aFSD=aMSDF(j);
219       mySDFaces.Add(aFSD, aF);
220     }
221   }
222   //
223 }
224 //=======================================================================
225 // function: FillImagesFaces
226 // purpose: 
227 //=======================================================================
228   void NMTAlgo_Builder::FillImagesFaces()
229 {
230   const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
231   NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
232   IntTools_Context& aCtx= pPF->ChangeContext();
233   //
234   Standard_Integer i, j, aNb, aNbE;
235   TopTools_IndexedMapOfShape aMFence, aME;
236   TColStd_IndexedMapOfInteger aMFP;
237   //
238   // 1. Select Faces to process (MFP)
239   aNb=aDS.NumberOfShapesOfTheObject();
240   for (i=1; i<=aNb; ++i) {
241     const TopoDS_Shape& aF=aDS.Shape(i);
242     if (aF.ShapeType()!=TopAbs_FACE) {
243       continue;
244     }
245     if (aMFence.Contains(aF)) {
246       continue;
247     }
248     aMFence.Add(aF);
249     //
250     if (myIn2DParts.Contains(aF)) {
251       aMFP.Add(i);
252       continue;
253     }
254     //
255     if (mySectionParts.Contains(aF)) {
256       aMFP.Add(i);
257       continue;
258     }
259     //
260     aME.Clear();
261     TopExp::MapShapes(aF, TopAbs_EDGE, aME);
262     //
263     aNbE=aME.Extent();
264     for(j=1; j<=aNbE; ++j) {
265       const TopoDS_Shape& aE=aME(j);
266       //
267       if (myImagesEdges.HasImage(aE)) {
268         aMFP.Add(i);
269         break;
270       }
271     }
272   }// for (i=1; i<=aNb; ++i)
273   //
274   // 2. ProcessFaces
275   Standard_Boolean bToReverse, bIsClosed, bIsDegenerated;
276   Standard_Integer aNbF, nF;
277   TopoDS_Face aFF;
278   TopoDS_Edge aSp;
279   TopExp_Explorer anExp;
280   TopTools_ListIteratorOfListOfShape aIt;
281   BRepAlgo_Image aImagesFaces;
282   TopAbs_Orientation anOriF;
283   //
284   aNbF=aMFP.Extent();
285   for (i=1; i<=aNbF; ++i) {
286     nF=aMFP(i);
287     const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF));
288     anOriF=aF.Orientation();
289     aFF=aF;
290     aFF.Orientation(TopAbs_FORWARD);
291     //
292     aMFence.Clear();
293     //
294     // 2.1. Fill WES 
295     BOP_WireEdgeSet aWES;
296     aWES.Initialize(aFF);
297     //
298     //  2.1.1. Add Split parts
299     anExp.Init(aFF, TopAbs_EDGE);
300     for (; anExp.More(); anExp.Next()) {
301       const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current());
302       //
303       if (!myImagesEdges.HasImage(aE)) {
304         aWES.AddStartElement(aE);
305         continue;
306       }
307       //
308       bIsDegenerated=BRep_Tool::Degenerated(aE);
309       bIsClosed=BRep_Tool::IsClosed(aE, aF);
310       //
311       const TopTools_ListOfShape& aLIE=myImagesEdges.Image(aE);
312       aIt.Initialize(aLIE);
313       for (; aIt.More(); aIt.Next()) {
314         aSp=TopoDS::Edge(aIt.Value());
315         //
316         if (bIsDegenerated) {
317           aSp.Orientation(aE.Orientation());
318           aWES.AddStartElement(aSp);
319           continue;
320         }
321         //
322         if (bIsClosed){
323           if (!aMFence.Contains(aSp)){
324             aMFence.Add(aSp);
325             //
326             if (!BRep_Tool::IsClosed(aSp, aF)){
327               BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF);
328             }
329             //
330             aSp.Orientation(TopAbs_FORWARD);
331             aWES.AddStartElement(aSp);
332             //
333             aSp.Orientation(TopAbs_REVERSED);
334             aWES.AddStartElement(aSp);
335             continue;
336           }
337         }
338         //
339         bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx);
340         if (bToReverse) {
341           aSp.Reverse();
342         }
343         aWES.AddStartElement(aSp);
344       }
345     }
346     //
347     // 2.1.2. Add In2D Parts
348     if (myIn2DParts.Contains(aF)) {
349       const TopTools_ListOfShape& aLE=myIn2DParts.FindFromKey(aF);
350       aIt.Initialize(aLE);
351       for (; aIt.More(); aIt.Next()) {
352         aSp=TopoDS::Edge(aIt.Value());
353         //
354         aSp.Orientation(TopAbs_FORWARD);
355         aWES.AddStartElement(aSp);
356         //
357         aSp.Orientation(TopAbs_REVERSED);
358         aWES.AddStartElement(aSp);
359         }
360     }
361     //
362     // 2.1.3. Add Section Parts
363     if (mySectionParts.Contains(aF)) {
364       const TopTools_ListOfShape& aLE=mySectionParts.FindFromKey(aF);
365       aIt.Initialize(aLE);
366       for (; aIt.More(); aIt.Next()) {
367         aSp=TopoDS::Edge(aIt.Value());
368         //
369         aSp.Orientation(TopAbs_FORWARD);
370         aWES.AddStartElement(aSp);
371         //
372         aSp.Orientation(TopAbs_REVERSED);
373         aWES.AddStartElement(aSp);
374       }
375     }
376     //
377     // 2.2. Build images Faces
378     BOP_FaceBuilder aFB;
379     //
380     aFB.SetTreatment(0);  // 0-Do Internal Edges
381     aFB.SetTreatSDScales(0); // what is 0 ??
382     //
383     aFB.Do(aWES);
384     //
385     TopTools_ListOfShape aLFR;
386     //
387     const TopTools_ListOfShape& aLF=aFB.NewFaces();
388
389     aIt.Initialize(aLF);
390     for (; aIt.More(); aIt.Next()) {
391       TopoDS_Shape& aFR=aIt.Value();
392       if (anOriF==TopAbs_REVERSED) {
393         aFR.Orientation(TopAbs_REVERSED);
394       }
395       aLFR.Append(aFR);
396     }
397     
398     //
399     // 2.3. Collect images Faces
400     myImagesFaces.Bind(aF, aLFR);
401   }//for (i=1; i<=aNbF; ++i)
402 }
403 //=======================================================================
404 // function: FillIn2DParts
405 // purpose: 
406 //=======================================================================
407   void NMTAlgo_Builder::FillIn2DParts()
408 {
409   const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
410   NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
411   BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*)&myDSFiller->InterfPool();
412   BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences();
413   //
414   Standard_Integer i, j, aNb, nF1, nF2, aNbFF, iFF, nSpIn, nSpSc, aNbCurves;
415   BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap;
416   BOPTools_ListOfPaveBlock aLPBIn, aLPBSc;
417   BOPTools_ListIteratorOfListOfPaveBlock aItPBIn, aItPBSc;
418   TopTools_IndexedMapOfShape aMF, aMFence;
419   TopTools_ListOfShape aLSpIn, aLSpSc;
420   //
421   BOP_BuilderTools::DoMap(aFFs, aFFMap);
422   //
423   // 1. Collect Splits In 2D   (myIn2DParts) and 
424   //            Section Edges  (mySectionParts) 
425   //    for each source face that involved in FF
426   aNb=aFFMap.Extent();
427   for (i=1; i<=aNb; ++i) {
428     nF1=aFFMap.FindKey(i);
429     const TopoDS_Shape& aF=aDS.Shape(nF1);
430     //
431     if (aMF.Contains(aF)) {
432       continue;
433     }
434     aMF.Add(aF);
435     //
436     aLPBIn.Clear();
437     aLPBSc.Clear();
438     //
439     const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i);
440     //
441     aNbFF=aFFIndicesMap.Extent();
442     for (j=1; j<=aNbFF; ++j) {
443       iFF=aFFIndicesMap(j);
444       BOPTools_SSInterference& aFF=aFFs(iFF);
445       nF2=aFF.OppositeIndex(nF1);
446       //
447       // In 2D
448       pPF->RealSplitsInFace(0, nF2, nF1, aLPBIn);
449       //
450       // Sections
451       BOPTools_SequenceOfCurves& aSC=aFF.Curves();
452       aNbCurves=aSC.Length();
453       if (!aNbCurves) {
454         continue;
455       }
456       //
457       const BOPTools_Curve& aBC=aSC(1);
458       const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks();
459       //
460       aItPBSc.Initialize(aLPB);
461       for (; aItPBSc.More(); aItPBSc.Next()) {
462         const BOPTools_PaveBlock& aPBSc=aItPBSc.Value();
463         aLPBSc.Append(aPBSc);
464       }
465     }// for (j=1; j<=aNbFF; ++j) 
466     //
467     // In 2D Parts 
468     aMFence.Clear();
469     //
470     aLSpIn.Clear();
471     aItPBIn.Initialize(aLPBIn);
472     for (; aItPBIn.More(); aItPBIn.Next()) {
473       const BOPTools_PaveBlock& aPBR=aItPBIn.Value();
474       nSpIn=aPBR.Edge();
475       const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn);
476       if (!aMFence.Contains(aSpIn)){
477         aMFence.Add(aSpIn);
478         aLSpIn.Append(aSpIn);
479       }
480     }
481     myIn2DParts.Add(aF, aLSpIn);
482     //
483     // Section Parts
484     aLSpSc.Clear();
485     aItPBSc.Initialize(aLPBSc);
486     for (; aItPBSc.More(); aItPBSc.Next()) {
487       const BOPTools_PaveBlock& aPBSc=aItPBSc.Value();
488       nSpSc=aPBSc.Edge();
489       const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc);
490       if (!aMFence.Contains(aSpSc)){
491         aMFence.Add(aSpSc);
492         aLSpSc.Append(aSpSc);
493       }
494     }
495     mySectionParts.Add(aF, aLSpSc);
496   } //for (i=1; i<=aNb; ++i)
497 }
498
499 //=======================================================================
500 // function: FillImagesEdges
501 // purpose: 
502 //=======================================================================
503   void NMTAlgo_Builder::FillImagesEdges()
504 {
505   const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
506   NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
507   const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool();
508   //
509   Standard_Integer nE, aNb, aNbSp, nSp;
510   BOPTools_ListIteratorOfListOfPaveBlock aIt;
511   TopTools_IndexedMapOfShape aMFence;
512   TopTools_ListOfShape aLSp;
513   //
514   aNb=aDS.NumberOfShapesOfTheObject();
515   for (nE=1; nE<=aNb; ++nE) {
516     const TopoDS_Shape& aE=aDS.Shape(nE);
517     if (aE.ShapeType()!=TopAbs_EDGE) {
518       continue;
519     }
520     if (aMFence.Contains(aE)) {
521       continue;
522     }
523     aMFence.Add(aE);
524     //
525     const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(nE));
526     aNbSp=aLPB.Extent();
527     //
528     if (!aNbSp) {// no splits  
529       //myImagesEdges.Bind(aE, aE);
530       continue;
531     }
532     //
533     //modified by NIZNHY-PKV Fri Jan 21 17:01:10 2005 f
534     if (aNbSp==1) {
535       const BOPTools_PaveBlock& aPB1=aLPB.First();
536       const BOPTools_PaveBlock& aPBR1=pPF->RealPaveBlock(aPB1);
537       nSp=aPBR1.Edge();
538       const TopoDS_Shape& aSp1=aDS.Shape(nSp);
539       if (aSp1.IsSame(aE)) {
540         continue;
541       }
542     }
543     //modified by NIZNHY-PKV Fri Jan 21 17:01:14 2005 t
544     //
545     aLSp.Clear();
546     aIt.Initialize(aLPB);
547     for (; aIt.More(); aIt.Next()) {
548       const BOPTools_PaveBlock& aPB=aIt.Value();
549       const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB);
550       nSp=aPBR.Edge();
551       const TopoDS_Shape& aSp=aDS.Shape(nSp);
552       aLSp.Append(aSp);
553     }
554     myImagesEdges.Bind(aE, aLSp); 
555   }
556 }
557 //=======================================================================
558 // function: SplitVertices
559 // purpose: 
560 //=======================================================================
561   void NMTAlgo_Builder::SplitVertices()
562 {
563   const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS();
564   NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller());
565   const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool();
566   //
567   Standard_Integer nE, aNb, aNbSp, nV1, nV2;
568   BOPTools_ListIteratorOfListOfPaveBlock aIt;
569   //
570   myQueryShapes.Clear();
571   //
572   aNb=aDS.NumberOfShapesOfTheObject();
573   for (nE=1; nE<=aNb; ++nE) {
574     const TopoDS_Shape& aE=aDS.Shape(nE);
575     if (aE.ShapeType()!=TopAbs_EDGE) {
576       continue;
577     }
578     //
579     const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(nE));
580     aNbSp=aLPB.Extent();
581     //
582     if (!aNbSp) {// no splits  
583       continue;
584     }
585     //
586     aIt.Initialize(aLPB);
587     for (; aIt.More(); aIt.Next()) {
588       const BOPTools_PaveBlock& aPB=aIt.Value();
589       const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB);
590       //
591       nV1=aPBR.Pave1().Index();
592       if (aDS.IsNewShape(nV1)) {
593         const TopoDS_Shape& aV1=aDS.Shape(nV1);
594         myQueryShapes.Add(aV1);
595       }
596       //
597       nV2=aPBR.Pave2().Index();
598       if (aDS.IsNewShape(nV2)) {
599         const TopoDS_Shape& aV2=aDS.Shape(nV2);
600         myQueryShapes.Add(aV2);
601       }
602     }
603   }
604 }
605 //=======================================================================
606 // function: IsSectionEdge
607 // purpose: 
608 //=======================================================================
609   Standard_Boolean NMTAlgo_Builder::IsSectionEdge(const TopoDS_Edge& aE)const
610 {
611   return myImagesEdges.HasImage(aE);
612 }
613 //=======================================================================
614 // function: IsSameDomainF
615 // purpose: 
616 //=======================================================================
617   Standard_Boolean NMTAlgo_Builder::HasSameDomainF(const TopoDS_Face& aF1)const
618 {
619   Standard_Boolean bFlag=Standard_False;
620   TopTools_ListIteratorOfListOfShape aItF1;
621   //
622   const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1);
623   aItF1.Initialize(aLF1);
624   for (; aItF1.More(); aItF1.Next()) {
625     const TopoDS_Shape& aF1x=aItF1.Value();
626     //
627     if (mySDFaces.Contains(aF1x)){
628       return !bFlag;
629     }
630   }
631   return bFlag;
632 }
633 //=======================================================================
634 // function: IsSameDomainF
635 // purpose: 
636 //=======================================================================
637   Standard_Boolean NMTAlgo_Builder::IsSameDomainF(const TopoDS_Face& aF1,
638                                                   const TopoDS_Face& aF2)const
639 {
640   Standard_Boolean bFlag=Standard_False;
641   TopTools_ListIteratorOfListOfShape aItF1, aItF2;
642   //
643   const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1);
644   const TopTools_ListOfShape& aLF2=myImagesFaces.Image(aF2);
645   //
646   aItF1.Initialize(aLF1);
647   for (; aItF1.More(); aItF1.Next()) {
648     const TopoDS_Shape& aF1x=aItF1.Value();
649     //
650     if (!mySDFaces.Contains(aF1x)){
651       continue;
652     }
653     const TopoDS_Shape& aFSD1x=mySDFaces.FindFromKey(aF1x);
654     //
655     aItF2.Initialize(aLF2);
656     for (; aItF2.More(); aItF2.Next()) {
657       const TopoDS_Shape& aF2y=aItF2.Value();
658       if (!mySDFaces.Contains(aF2y)){
659         continue;
660       }
661       const TopoDS_Shape& aFSD2y=mySDFaces.FindFromKey(aF2y);
662       if (aFSD1x.IsSame(aFSD2y)) {
663         return !bFlag;
664       }
665     }
666   }
667   return bFlag;
668 }