#include <BOPAlgo_PaveFiller.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BRep_Builder.hxx>
+#include <BRepAlgoAPI_Fuse.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
#include <NCollection_IndexedMap.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
*/
bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_PolylineXY )& thePolyline, const QString& theType )
{
- //TODO
- return false;
+ if( thePolyline.IsNull() )
+ return false;
+
+ TopoDS_Shape aShape = thePolyline->GetShape();
+ if( aShape.ShapeType()!=TopAbs_WIRE )
+ return false;
+
+ TopoDS_Wire aWire = TopoDS::Wire( aShape );
+ if( !aWire.Closed() )
+ return false;
+
+ TopoDS_Face aFace = BRepBuilderAPI_MakeFace( aWire, Standard_True ).Face();
+ return LocalPartition( aFace, theType );
}
/**
/**
Remove the given faces from land cover map
- @param theFacesList the face list to be removed
+ @param theFacesToRemove the face list to be removed
@return if the removing is successful
*/
-bool HYDROData_LandCoverMap::Remove( const TopTools_ListOfShape& theFacesList )
+bool HYDROData_LandCoverMap::Remove( const TopTools_ListOfShape& theFacesToRemove )
{
- TopoDS_Compound aCompound = TopoDS::Compound( GetShape() );
- BRep_Builder aCompoundBuilder;
- //TODO: aCompoundBuilder.Remove( aCompound, theFace );
- //TODO: update types
- SetShape( aCompound );
+ HYDROData_MapOfFaceToStricklerType aFacesToRemove, aNewFaces;
+ TopTools_ListIteratorOfListOfShape aFIt( theFacesToRemove );
+ for( ; aFIt.More(); aFIt.Next() )
+ {
+ TopoDS_Shape aShape = aFIt.Value();
+ if( aShape.ShapeType()==TopAbs_FACE )
+ aFacesToRemove.Add( TopoDS::Face( aShape ), "" );
+ }
+
+ Iterator anIt( *this );
+ for( ; anIt.More(); anIt.Next() )
+ if( !aFacesToRemove.Contains( anIt.Face() ) )
+ aNewFaces.Add( anIt.Face(), anIt.StricklerType() );
+
+ StoreLandCovers( aNewFaces );
return true;
}
Remove( theFaces );
// 2. to fuse the faces into the new face
- // TODO
- TopoDS_Face aMergedFace;
+ BRepAlgoAPI_Fuse aFuse;
+ aFuse.SetArguments( theFaces );
+ aFuse.Build();
+ if( !aFuse.IsDone() )
+ return false;
+
+ TopoDS_Shape aMergedShape = aFuse.Shape();
+ if( aMergedShape.ShapeType()!=TopAbs_FACE )
+ return false;
// 3. to add the face into the map
- return LocalPartition( aMergedFace, theType );
+ return LocalPartition( TopoDS::Face( aMergedShape ), theType );
}
/**