+ // 3. to add the face into the map
+ return LocalPartition( TopoDS::Face( aMergedFace ), theType );
+ }
+ return false;
+}
+
+/**
+ Merge the given faces into the shell/face
+ @param theFaces the faces to merge
+ @param IsToUnify if the common edges should be removed (fused)
+ @param theTolerance the operation's tolerance
+ @return result shape (face or shell)
+*/
+TopoDS_Shape HYDROData_LandCoverMap::MergeFaces( const TopTools_ListOfShape& theFaces,
+ bool IsToUnify, double theTolerance )
+{
+ int anError;
+ TopTools_ListIteratorOfListOfShape anIt;
+ BOPCol_ListOfShape aLC;
+ anIt.Initialize(theFaces);
+ for( ; anIt.More(); anIt.Next() )
+ {
+ if (anIt.Value().ShapeType() != TopAbs_FACE)
+ return TopoDS_Shape();
+ aLC.Append( anIt.Value() );
+ }
+
+ BOPAlgo_PaveFiller aPF;
+ aPF.SetArguments( aLC );
+ aPF.SetRunParallel( Standard_False );
+ aPF.SetFuzzyValue( theTolerance );
+
+ aPF.Perform();
+ anError = aPF.ErrorStatus();
+ if( anError )
+ return TopoDS_Shape();
+
+ BOPAlgo_Builder anAlgo;
+ anIt.Initialize( theFaces );
+ for( ; anIt.More(); anIt.Next() )
+ anAlgo.AddArgument( anIt.Value() );
+
+ anAlgo.PerformWithFiller( aPF );
+ anError = anAlgo.ErrorStatus();
+ if( anError )
+ return TopoDS_Shape();
+
+ const TopoDS_Shape& aMergedShape = anAlgo.Shape();
+
+ BRep_Builder aBuilder;
+ TopoDS_Shell aShell;
+ aBuilder.MakeShell( aShell );
+ aShell.Closed( Standard_False );
+ TopExp_Explorer anExplorer( aMergedShape, TopAbs_FACE );
+ for( ; anExplorer.More(); anExplorer.Next() )
+ {
+ const TopoDS_Face& aFace = TopoDS::Face(anExplorer.Current());
+ if( aFace.IsNull() )
+ continue;
+ if( aFace.ShapeType() == TopAbs_FACE )
+ {
+ aBuilder.Add( aShell, aFace );
+ aShell.Closed( Standard_False );
+ }
+ }
+
+ TopoDS_Shape aResult;
+ if( IsToUnify )
+ {
+ ShapeUpgrade_UnifySameDomain aUSD;
+ aUSD.Initialize( aShell );
+ aUSD.Build();
+ aResult = aUSD.Shape();
+ }
+ else
+ aResult = aShell;
+
+ anExplorer.Init( aResult, 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)
+ {
+ BRepCheck_Shell aBCS(TopoDS::Shell(aResult));
+ if (aBCS.Status().First() != BRepCheck_NoError)
+ {
+ ShapeFix_Shell aFixer;
+ aFixer.FixFaceOrientation(TopoDS::Shell(aResult), 1);
+ aResult = aFixer.Shape();
+ }
+ }
+
+ return aResult;
+}
+
+/**
+ Change Strickler type for the list of faces to the given one
+ @param theFaces the faces to change type
+ @param theType the Strickler type for the given land cover(s)
+ @return if the change type operation is successful
+*/
+bool HYDROData_LandCoverMap::ChangeType( const TopTools_ListOfShape& theFaces, const QString& theType )
+{
+ HYDROData_MapOfFaceToStricklerType aFacesToChangeType;
+ TopTools_ListIteratorOfListOfShape aFIt( theFaces );
+ for( ; aFIt.More(); aFIt.Next() )
+ {
+ TopoDS_Shape aShape = aFIt.Value();
+ if( aShape.ShapeType()==TopAbs_FACE )
+ aFacesToChangeType.Add( TopoDS::Face( aShape ), "" );
+ }