- TDF_Label aNewLab = myLab.FindChild( ChildTag_Zone ).NewChild();
-
- return Handle(HYDROData_Zone)::DownCast(
- HYDROData_Iterator::CreateObject( aNewLab, KIND_ZONE ) );
-}
-
-void HYDROData_Region::RemoveChildZones()
-{
- myLab.FindChild( ChildTag_Zone ).ForgetAllAttributes( true );
-}
-
-int HYDROData_Region::NbZones() const
-{
- return NbReferenceObjects( DataTag_Zone );
-}
-
-void HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone )
-{
- AddReferenceObject( theZone, DataTag_Zone );
-}
+ if ( theZone.IsNull() )
+ return false;
+
+ if ( HasReference( theZone, DataTag_Zone ) )
+ return false; // Object is already in reference list
+
+ // Move the zone from other region
+ Handle(HYDROData_Region) aFatherRegion =
+ Handle(HYDROData_Region)::DownCast( theZone->GetFatherObject() );
+ if ( !aFatherRegion.IsNull() && aFatherRegion->Label() != myLab )
+ {
+ Handle(HYDROData_Zone) aNewZone = addNewZone();
+ theZone->CopyTo( aNewZone );