Salome HOME
refs #744 (draft)
authorisn <isn@opencascade.com>
Tue, 24 Nov 2015 14:29:31 +0000 (17:29 +0300)
committerisn <isn@opencascade.com>
Tue, 24 Nov 2015 14:53:53 +0000 (17:53 +0300)
src/HYDROData/HYDROData_LandCoverMap.cxx

index 367f60488338e8b37d2fa308fc4373b5a70119d2..677cd6770779aa9b870041fe980f4ce262af063d 100644 (file)
@@ -59,6 +59,7 @@
 #include <Handle_Geom_Line.hxx>
 #include <Handle_Geom_TrimmedCurve.hxx>
 #include <Geom_TrimmedCurve.hxx>
+#include <NCollection_Sequence.hxx>
 
 
 #include <QFile>
@@ -670,53 +671,78 @@ TopoDS_Shape HYDROData_LandCoverMap::MergeFaces( const TopTools_ListOfShape& the
 
   const TopoDS_Shape& aMergedShape = anAlgo.Shape();
 
-  BRep_Builder aBuilder;
+  BRep_Builder BB;
   TopoDS_Shell aShell; 
-  aBuilder.MakeShell( aShell ); 
+  BB.MakeShell( aShell ); 
   aShell.Closed( Standard_False );
-  TopExp_Explorer anExplorer( aMergedShape, TopAbs_FACE );
-  for( ; anExplorer.More(); anExplorer.Next() ) 
+
+  NCollection_Sequence<TopoDS_Shape> aSeqSh;
+
+  anIt.Initialize(theFaces);
+  bool EmptySh = true;
+  for( ; anIt.More(); anIt.Next() )
   {
-    const TopoDS_Face& aFace = TopoDS::Face(anExplorer.Current());
-    if( aFace.IsNull() ) 
-      continue;
-    if( aFace.ShapeType() == TopAbs_FACE )
+    TopoDS_Face F = TopoDS::Face(anIt.Value());
+    TopTools_ListOfShape aLSG = anAlgo.Modified(F);
+    if (aLSG.IsEmpty())
+      aSeqSh.Append (F);
+    else
     {
-      aBuilder.Add( aShell, aFace );
-      aShell.Closed( Standard_False );
+      EmptySh = false;
+      TopTools_ListIteratorOfListOfShape It(aLSG);
+      for (;It.More(); It.Next())
+        BB.Add(aShell, It.Value());
     }
   }
 
-  TopoDS_Shape aResult;
+  TopoDS_Shape ShellR; 
   if( IsToUnify )
   {
     ShapeUpgrade_UnifySameDomain aUSD;
     aUSD.Initialize( aShell );
     aUSD.Build();
-    aResult = aUSD.Shape();
+    ShellR = aUSD.Shape();
   }
   else
-    aResult = aShell;
+    ShellR = aShell;
 
-  anExplorer.Init( aResult, TopAbs_FACE );
+  TopExp_Explorer anExplorer;
+  anExplorer.Init( ShellR, TopAbs_FACE );
   int n = 0;
   TopoDS_Face anOneFace;
   for( ; anExplorer.More(); anExplorer.Next(), n++ ) 
     anOneFace = TopoDS::Face( anExplorer.Current() );
 
   if (n == 1)
-    aResult = anOneFace;
-  else if (aResult.ShapeType() == TopAbs_SHELL)
+    ShellR = anOneFace;
+  else if (ShellR.ShapeType() == TopAbs_SHELL)
   {
-    BRepCheck_Shell aBCS(TopoDS::Shell(aResult));
+    BRepCheck_Shell aBCS(TopoDS::Shell(ShellR));
     if (aBCS.Status().First() != BRepCheck_NoError)
     {
       ShapeFix_Shell aFixer;
-      aFixer.FixFaceOrientation(TopoDS::Shell(aResult), 1);
-      aResult = aFixer.Shape();
+      aFixer.FixFaceOrientation(TopoDS::Shell(ShellR), 1);
+      ShellR = aFixer.Shape();
     }
   }
 
+  if (!EmptySh)
+    aSeqSh.Append (ShellR);
+  
+  TopoDS_Compound cmp; 
+  BB.MakeCompound( cmp ); 
+  
+  TopoDS_Shape aResult;
+
+  if (aSeqSh.Length() == 1)
+    aResult = aSeqSh.First();
+  else
+  {
+    for (int i = 1; i <= aSeqSh.Size(); i++)
+      BB.Add(cmp, aSeqSh(i));
+    aResult = cmp;
+  }
+
   return aResult;
 }