From 1dfc93fdcf865dcea7d8c1ad53542caec7992934 Mon Sep 17 00:00:00 2001 From: isn Date: Tue, 24 Nov 2015 17:29:31 +0300 Subject: [PATCH] refs #744 (draft) --- src/HYDROData/HYDROData_LandCoverMap.cxx | 64 +++++++++++++++++------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 367f6048..677cd677 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -59,6 +59,7 @@ #include #include #include +#include #include @@ -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 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; } -- 2.39.2