From: asl Date: Tue, 13 Oct 2015 14:27:44 +0000 (+0300) Subject: refs #650: local partition algorithm X-Git-Tag: v1.5~135 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=190f2bc2f5142292b2d578f104e63dc8b81de315;p=modules%2Fhydro.git refs #650: local partition algorithm --- diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 5c1f9e39..ee6119e5 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -245,7 +245,66 @@ void HYDROData_LandCoverMap::SetShape( const TopoDS_Shape& theShape ) */ 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; } /**