*/
bool HYDROData_LandCoverMap::LocalPartition( const TopoDS_Shape& theNewShape, const QString& theNewType )
{
- //TODO
+ BOPCol_ListOfShape aShapesList;
+ BOPAlgo_PaveFiller aPaveFiller;
+
+ // add faces to shapes list
+ Iterator anIt( *this );
+ for( ; anIt.More(); anIt.Next() )
+ aShapesList.Append( anIt.Face() );
+ aShapesList.Append( theNewShape );
+
+ // prepare pave filler
+ aPaveFiller.SetArguments( aShapesList );
+ aPaveFiller.Perform();
+ Standard_Integer anError = aPaveFiller.ErrorStatus();
+ if( anError )
+ return false;
+
+ // add faces to builder
+ BOPAlgo_Builder aBuilder;
+ anIt.Init( *this );
+ for( ; anIt.More(); anIt.Next() )
+ aBuilder.AddArgument( anIt.Face() );
+ aBuilder.AddArgument( theNewShape );
+
+ // perform the partition with the pave filler
+ aBuilder.PerformWithFiller( aPaveFiller );
+ anError = aBuilder.ErrorStatus();
+ if( anError )
+ return false;
+
+ // analysis of the history
+ BOPCol_DataMapOfShapeListOfShape aSplits = aBuilder.Splits();
+
+ // a. fill map of shape => type for initial faces
+ HYDROData_MapOfShapeToStricklerType anOldFaces;
+ anIt.Init( *this );
+ for( ; anIt.More(); anIt.Next() )
+ anOldFaces.Add( anIt.Face(), anIt.StricklerType() );
+
+ // b. fill map of shape => type for split faces without the new face
+ HYDROData_MapOfShapeToStricklerType aNewFaces;
+ BOPCol_DataMapOfShapeListOfShape::Iterator aSplitIt( aSplits );
+ for( ; aSplitIt.More(); aSplitIt.Next() )
+ {
+ TopoDS_Shape anInitial = aSplitIt.Key();
+ if( anInitial==theNewShape )
+ continue;
+ QString aType = anOldFaces.FindFromKey( anInitial );
+ BOPCol_ListOfShape aSplitFaces = aSplitIt.Value();
+ BOPCol_ListOfShape::Iterator aSFIt( aSplitFaces );
+ for( ; aSFIt.More(); aSFIt.Next() )
+ aNewFaces.Add( aSFIt.Value(), aType );
+ }
+
+ // c. add the new shape if it is face with its type
+ if( theNewShape.ShapeType()==TopAbs_FACE )
+ aNewFaces.Add( theNewShape, theNewType );
+
+ // convert map of shape to type to compound and list of types
+ StoreLandCovers( aNewFaces );
+ return true;
}
/**