#include "HYDROData_Calculation.h"
+#include "HYDROData_ArtificialObject.h"
#include "HYDROData_Document.h"
#include "HYDROData_Iterator.h"
-#include "HYDROData_Object.h"
+#include "HYDROData_NaturalObject.h"
#include "HYDROData_SplitToZonesTool.h"
#include "HYDROData_Region.h"
#include "HYDROData_Tool.h"
#include "HYDROData_Zone.h"
-#include <QStringList>
-
#define PYTHON_CALCULATION_ID "KIND_CALCULATION"
IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Entity)
{
// At first we remove previously created regions
RemoveRegions();
- RemoveChildRegions();
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
if ( aDocument.IsNull() )
// Create new region
Handle(HYDROData_Region) aRegion = AddNewRegion();
- AddRegion( aRegion );
QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, "Region" );
aRegion->SetName( aRegionName );
// Add the zone for region
Handle(HYDROData_Zone) aRegionZone = aRegion->AddNewZone();
- aRegion->AddZone( aRegionZone );
QString aZoneName = HYDROData_Tool::GenerateObjectName( aDocument, "Zone" );
aRegionZone->SetName( aZoneName );
}
}
-int HYDROData_Calculation::NbGeometryObjects() const
+bool HYDROData_Calculation::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
{
- return NbReferenceObjects( DataTag_GeometryObject );
-}
+ if ( theObject.IsNull() )
+ return false;
+
+ if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) &&
+ !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) )
+ return false; // Wrong type of object
-void HYDROData_Calculation::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
-{
- AddReferenceObject( theObject, DataTag_GeometryObject );
-}
+ if ( HasReference( theObject, DataTag_GeometryObject ) )
+ return false; // Object is already in reference list
-void HYDROData_Calculation::SetGeometryObject( const int theIndex,
- const Handle(HYDROData_Object)& theObject )
-{
- SetReferenceObject( theObject, DataTag_GeometryObject, theIndex );
+ AddReferenceObject( theObject, DataTag_GeometryObject );
+ return true;
}
-void HYDROData_Calculation::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects )
+HYDROData_SequenceOfObjects HYDROData_Calculation::GetGeometryObjects() const
{
- SetReferenceObjects( theObjects, DataTag_GeometryObject );
+ return GetReferenceObjects( DataTag_GeometryObject );
}
-Handle(HYDROData_Object) HYDROData_Calculation::GetGeometryObject( const int theIndex ) const
+void HYDROData_Calculation::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject )
{
- return Handle(HYDROData_Object)::DownCast(
- GetReferenceObject( DataTag_GeometryObject, theIndex ) );
-}
+ if ( theObject.IsNull() )
+ return;
-HYDROData_SequenceOfObjects HYDROData_Calculation::GetGeometryObjects() const
-{
- return GetReferenceObjects( DataTag_GeometryObject );
+ RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject );
}
void HYDROData_Calculation::RemoveGeometryObjects()
{
TDF_Label aNewLab = myLab.FindChild( ChildTag_Region ).NewChild();
- return Handle(HYDROData_Region)::DownCast(
- HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
-}
-
-void HYDROData_Calculation::RemoveChildRegions()
-{
- myLab.FindChild( ChildTag_Region ).ForgetAllAttributes( true );
-}
-
-int HYDROData_Calculation::NbRegions() const
-{
- return NbReferenceObjects( DataTag_Region );
-}
+ Handle(HYDROData_Region) aNewRegion =
+ Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
+ AddRegion( aNewRegion );
-void HYDROData_Calculation::AddRegion( const Handle(HYDROData_Region)& theRegion )
-{
- AddReferenceObject( theRegion, DataTag_Region );
+ return aNewRegion;
}
-void HYDROData_Calculation::SetRegion( const int theIndex,
- const Handle(HYDROData_Region)& theRegion )
+bool HYDROData_Calculation::AddRegion( Handle(HYDROData_Region)& theRegion )
{
- SetReferenceObject( theRegion, DataTag_Region, theIndex );
-}
+ if ( theRegion.IsNull() )
+ return false;
+
+ if ( HasReference( theRegion, DataTag_Region ) )
+ return false; // Object is already in reference list
+
+ // Move the region from other calculation
+ Handle(HYDROData_Calculation) aFatherCalc =
+ Handle(HYDROData_Calculation)::DownCast( theRegion->GetFatherObject() );
+ if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
+ {
+ Handle(HYDROData_Region) aNewRegion = AddNewRegion();
+ theRegion->CopyTo( aNewRegion );
-void HYDROData_Calculation::InsertRegion( const int theBeforeIndex,
- const Handle(HYDROData_Region)& theRegion )
-{
- InsertReferenceObject( theRegion, DataTag_Region, theBeforeIndex );
-}
+ aFatherCalc->RemoveRegion( theRegion );
-void HYDROData_Calculation::SetRegions( const HYDROData_SequenceOfObjects& theRegions )
-{
- SetReferenceObjects( theRegions, DataTag_Region );
-}
+ theRegion = aNewRegion;
+ }
-Handle(HYDROData_Region) HYDROData_Calculation::GetRegion( const int theIndex ) const
-{
- return Handle(HYDROData_Region)::DownCast(
- GetReferenceObject( DataTag_Region, theIndex ) );
+ AddReferenceObject( theRegion, DataTag_Region );
+ return true;
}
HYDROData_SequenceOfObjects HYDROData_Calculation::GetRegions() const
void HYDROData_Calculation::RemoveRegion( const Handle(HYDROData_Region)& theRegion )
{
- if ( theRegion.IsNull() )
+ if ( theRegion.IsNull() || !HasReference( theRegion, DataTag_Region ) )
return;
RemoveReferenceObject( theRegion->Label(), DataTag_Region );
-}
-void HYDROData_Calculation::RemoveRegion( const int theIndex )
-{
- RemoveReferenceObject( DataTag_Region, theIndex );
+ // Remove region from data model
+ theRegion->Remove();
}
void HYDROData_Calculation::RemoveRegions()
{
ClearReferenceObjects( DataTag_Region );
+ myLab.FindChild( ChildTag_Region ).ForgetAllAttributes( true );
}
/**
- * Returns number of geometry objects for calculation case.
+ * Add new one reference geometry object for calculation case.
*/
- HYDRODATA_EXPORT virtual int NbGeometryObjects() const;
+ HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
/**
- * Add new one geometry object for calculation case.
+ * Returns all reference geometry objects of calculation case.
*/
- HYDRODATA_EXPORT virtual void AddGeometryObject( const Handle(HYDROData_Object)& theObject );
-
- /**
- * Replace the geometry object for calculation case.
- */
- HYDRODATA_EXPORT virtual void SetGeometryObject( const int theIndex,
- const Handle(HYDROData_Object)& theObject );
-
- /**
- * Sets the geometry object for calculation case.
- */
- HYDRODATA_EXPORT virtual void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
-
- /**
- * Returns geometry object of calculation case by index.
- */
- HYDRODATA_EXPORT virtual Handle(HYDROData_Object) GetGeometryObject( const int theIndex ) const;
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
/**
- * Returns all geometry objects of calculation case.
+ * Removes reference geometry object from calculation case.
*/
- HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
+ HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
/**
- * Removes all geometry objects from calculation case.
+ * Removes all reference geometry objects from calculation case.
*/
HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
/**
* Add new one region for calculation case.
- * The new region is not added into the list of reference regions.
+ * The new region is added into the list of reference regions.
*/
HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion();
- /**
- * Removes all child regions from calculation case.
- */
- HYDRODATA_EXPORT virtual void RemoveChildRegions();
-
-
- /**
- * Returns number of reference regions of calculation case.
- */
- int NbRegions() const;
/**
* Add new one reference region for calculation case.
*/
- HYDRODATA_EXPORT virtual void AddRegion( const Handle(HYDROData_Region)& theRegion );
-
- /**
- * Replace the reference region for calculation case.
- */
- HYDRODATA_EXPORT virtual void SetRegion( const int theIndex,
- const Handle(HYDROData_Region)& theRegion );
-
- /**
- * Inserts the reference region for calculation case before given index.
- */
- HYDRODATA_EXPORT virtual void InsertRegion( const int theBeforeIndex,
- const Handle(HYDROData_Region)& theRegion );
-
- /**
- * Sets reference regions for calculation case.
- */
- HYDRODATA_EXPORT virtual void SetRegions( const HYDROData_SequenceOfObjects& theRegions );
-
- /**
- * Returns reference region of calculation case by index.
- */
- HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegion( const int theIndex ) const;
+ HYDRODATA_EXPORT virtual bool AddRegion( Handle(HYDROData_Region)& theRegion );
/**
* Returns all reference regions of calculation case.
*/
HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
- /**
- * Removes reference region from calculation case by it index.
- */
- HYDRODATA_EXPORT virtual void RemoveRegion( const int theIndex );
-
/**
* Removes all reference regions from calculation case.
*/
aCopy.Perform();
}
+Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const
+{
+ Handle(HYDROData_Entity) aFather;
+
+ if ( !myLab.IsNull() )
+ {
+ TDF_Label aFatherLabel = myLab.Father();
+
+ while ( aFather.IsNull() && !aFatherLabel.IsNull() && !aFatherLabel.IsRoot() )
+ {
+ aFather = HYDROData_Iterator::Object( aFatherLabel );
+ aFatherLabel = aFatherLabel.Father();
+ }
+ }
+
+ return aFather;
+}
+
void HYDROData_Entity::SetLabel(TDF_Label theLabel)
{
myLab = theLabel;
return aRefs.IsNull() ? 0 : aRefs->Extent();
}
+bool HYDROData_Entity::HasReference( const Handle_HYDROData_Entity& theObj,
+ const int theTag ) const
+{
+ if ( theObj.IsNull() )
+ return false;
+
+ Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
+ if ( aRefs.IsNull() || aRefs->IsEmpty() )
+ return false;
+
+ TDF_ListIteratorOfLabelList aListIt( aRefs->List() );
+ for ( ; aListIt.More(); aListIt.Next() )
+ {
+ const TDF_Label& aRefLabel = aListIt.Value();
+ if ( theObj->Label() == aRefLabel )
+ return true;
+ }
+
+ return false;
+}
+
void HYDROData_Entity::AddReferenceObject( const Handle_HYDROData_Entity& theObj,
const int theTag )
{
*/
HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
+ /**
+ * Returns father object. For object created under root document label
+ * this method always return NULL object.
+ */
+ HYDRODATA_EXPORT virtual Handle(HYDROData_Entity) GetFatherObject() const;
+
protected:
friend class HYDROData_Iterator;
*/
int NbReferenceObjects( const int theTag = 0 ) const;
+ /**
+ * Internal method that used to check object for entry into the reference list
+ * \param theObj pointer to reference object
+ * \param theTag tag of a label to store attribute (for 0 this is myLab)
+ */
+ bool HasReference( const Handle_HYDROData_Entity& theObj,
+ const int theTag = 0 ) const;
+
/**
* Internal method that used to store the reference object label attribute
* \param theObj pointer to reference object
return Object( theNewLabel );
}
-Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label theLabel )
+Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel )
{
+ Handle(HYDROData_Entity) aResult;
+
+ // If label has no name attribute it mean that this is not object or
+ // this object has been removed from document
+ Handle(TDataStd_Name) aNameAtt;
+ if ( !theLabel.FindAttribute( TDataStd_Name::GetID(), aNameAtt ) )
+ return aResult;
+
ObjectKind aKind = KIND_UNKNOWN;
// Retrieve the type of object from label
if ( aKind == KIND_UNKNOWN )
aKind = theLabel.Father().Tag(); // Try to get type from father label
- Handle(HYDROData_Entity) aResult;
switch( aKind )
{
case KIND_IMAGE:
/**
* Returns object associated to the given label.
*/
- static Handle(HYDROData_Entity) Object(const TDF_Label theLabel);
+ static Handle(HYDROData_Entity) Object( const TDF_Label& theLabel );
TDF_ChildIDIterator myIter; ///< iterator by the objects in the document
};
#include <QStringList>
-#include <TDataStd_Integer.hxx>
-
#define PYTHON_REGION_ID "KIND_REGION"
IMPLEMENT_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
HYDROData_Region::HYDROData_Region()
: HYDROData_Entity()
{
- SetMergeType( Merge_ZMIN );
}
HYDROData_Region::~HYDROData_Region()
return aResList;
}
-Handle(HYDROData_Zone) HYDROData_Region::AddNewZone()
-{
- 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 );
-}
-
-void HYDROData_Region::SetMergeType( const MergeBathymetriesType& theType )
+bool HYDROData_Region::AddZone( Handle(HYDROData_Zone)& theZone )
{
- Handle(TDataStd_Integer) anInt;
- if ( !myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
- anInt = TDataStd_Integer::Set( myLab, 0 );
- anInt->Set( (int)theType );
-}
-
-HYDROData_Region::MergeBathymetriesType HYDROData_Region::GetMergeType() const
-{
- MergeBathymetriesType aMergeType = Merge_ZMIN;
+ if ( theZone.IsNull() )
+ return false;
- Handle(TDataStd_Integer) anInt;
- if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
- aMergeType = (MergeBathymetriesType)anInt->Get();
-
- return aMergeType;
-}
-
-int HYDROData_Region::NbZones() const
-{
- return NbReferenceObjects( DataTag_Zone );
-}
-
-void HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone )
-{
- AddReferenceObject( theZone, DataTag_Zone );
-}
+ if ( HasReference( theZone, DataTag_Zone ) )
+ return false; // Object is already in reference list
-void HYDROData_Region::SetZone( const int theIndex,
- const Handle(HYDROData_Zone)& theZone )
-{
- SetReferenceObject( theZone, DataTag_Zone, theIndex );
-}
+ // 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 );
-void HYDROData_Region::InsertZone( const int theBeforeIndex,
- const Handle(HYDROData_Zone)& theZone )
-{
- InsertReferenceObject( theZone, DataTag_Zone, theBeforeIndex );
-}
+ aFatherRegion->RemoveZone( theZone );
-void HYDROData_Region::SetZones( const HYDROData_SequenceOfObjects& theZones )
-{
- SetReferenceObjects( theZones, DataTag_Zone );
-}
+ theZone = aNewZone;
+ }
-Handle(HYDROData_Zone) HYDROData_Region::GetZone( const int theIndex ) const
-{
- return Handle(HYDROData_Zone)::DownCast(
- GetReferenceObject( DataTag_Zone, theIndex ) );
+ AddReferenceObject( theZone, DataTag_Zone );
+ return true;
}
HYDROData_SequenceOfObjects HYDROData_Region::GetZones() const
void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone )
{
- if ( theZone.IsNull() )
+ if ( theZone.IsNull() || !HasReference( theZone, DataTag_Zone ) )
return;
RemoveReferenceObject( theZone->Label(), DataTag_Zone );
-}
-void HYDROData_Region::RemoveZone( const int theIndex )
-{
- RemoveReferenceObject( DataTag_Zone, theIndex );
+ // Remove zone from data model
+ theZone->Remove();
}
void HYDROData_Region::RemoveZones()
{
ClearReferenceObjects( DataTag_Zone );
+ myLab.FindChild( ChildTag_Zone ).ForgetAllAttributes( true );
}
+Handle(HYDROData_Zone) HYDROData_Region::AddNewZone()
+{
+ TDF_Label aNewLab = myLab.FindChild( ChildTag_Zone ).NewChild();
+
+ Handle(HYDROData_Zone) aNewZone =
+ Handle(HYDROData_Zone)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_ZONE ) );
+ AddZone( aNewZone );
+
+ return aNewZone;
+}
class HYDROData_Region : public HYDROData_Entity
{
-public:
-
- // Enumeration of mergin types for conflict bathymetries
- enum MergeBathymetriesType
- {
- Merge_ZMIN,
- Merge_ZMAX
- };
-
protected:
/**
{
DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
DataTag_Zone, ///< reference zones
- DataTag_MergeType, ///< mergin type of conflict bathymetries
};
/**
HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
- /**
- * Create new one reference zone for region on child label.
- * The new zone is not added into the list of reference zones.
- */
- HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) AddNewZone();
-
- /**
- * Removes all child zones from region.
- */
- HYDRODATA_EXPORT virtual void RemoveChildZones();
-
-
- /**
- * Sets the merging type for conflict bathymetries.
- * By default it is set to Merge_ZMIN.
- */
- HYDRODATA_EXPORT virtual void SetMergeType( const MergeBathymetriesType& theType );
-
- /**
- * Returns the merging type for conflict bathymetries.
- */
- HYDRODATA_EXPORT virtual MergeBathymetriesType GetMergeType() const;
-
-
-
- /**
- * Returns number of reference zones of region.
- */
- int NbZones() const;
-
/**
* Add new one reference zone for region.
*/
- HYDRODATA_EXPORT virtual void AddZone( const Handle(HYDROData_Zone)& theZone );
-
- /**
- * Replace the reference zone for region.
- */
- HYDRODATA_EXPORT virtual void SetZone( const int theIndex,
- const Handle(HYDROData_Zone)& theZone );
-
- /**
- * Inserts the reference zone for region before given index.
- */
- HYDRODATA_EXPORT virtual void InsertZone( const int theBeforeIndex,
- const Handle(HYDROData_Zone)& theZone );
-
- /**
- * Sets reference zones for calculation region.
- */
- HYDRODATA_EXPORT virtual void SetZones( const HYDROData_SequenceOfObjects& theZones );
-
- /**
- * Returns reference zone of region by index.
- */
- HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZone( const int theIndex ) const;
+ HYDRODATA_EXPORT virtual bool AddZone( Handle(HYDROData_Zone)& theZone );
/**
* Returns all reference zone of region.
*/
HYDRODATA_EXPORT virtual void RemoveZone( const Handle(HYDROData_Zone)& theZone );
- /**
- * Removes reference zone from region by it index.
- */
- HYDRODATA_EXPORT virtual void RemoveZone( const int theIndex );
-
/**
* Removes all reference zones from region.
*/
HYDRODATA_EXPORT virtual void RemoveZones();
+protected:
+
+ /**
+ * Create new one reference zone for region on child label.
+ * The new zone is added into the list of reference zones.
+ */
+ HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) AddNewZone();
+
protected:
friend class HYDROData_Calculation;
#include "HYDROData_Zone.h"
+#include "HYDROData_ArtificialObject.h"
+#include "HYDROData_Bathymetry.h"
#include "HYDROData_Document.h"
-#include "HYDROData_Object.h"
+#include "HYDROData_NaturalObject.h"
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <QStringList>
+#include <TDataStd_Integer.hxx>
+
#define PYTHON_ZONE_ID "KIND_ZONE"
IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
HYDROData_Zone::HYDROData_Zone()
: HYDROData_Entity()
{
+ SetMergeType( Merge_ZMIN );
}
HYDROData_Zone::~HYDROData_Zone()
return TopoDS_Shape();
}
-int HYDROData_Zone::NbGeometryObjects() const
+void HYDROData_Zone::SetMergeType( const MergeBathymetriesType& theType )
{
- return NbReferenceObjects( DataTag_GeometryObject );
+ Handle(TDataStd_Integer) anInt;
+ if ( !myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
+ anInt = TDataStd_Integer::Set( myLab, 0 );
+ anInt->Set( (int)theType );
}
-void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
+HYDROData_Zone::MergeBathymetriesType HYDROData_Zone::GetMergeType() const
{
- AddReferenceObject( theObject, DataTag_GeometryObject );
+ MergeBathymetriesType aMergeType = Merge_ZMIN;
+
+ Handle(TDataStd_Integer) anInt;
+ if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
+ aMergeType = (MergeBathymetriesType)anInt->Get();
+
+ return aMergeType;
+}
+
+void HYDROData_Zone::SetMergeBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+{
+ SetReferenceObject( theBathymetry, DataTag_Bathymetry );
}
-void HYDROData_Zone::SetGeometryObject( const int theIndex,
- const Handle(HYDROData_Object)& theObject )
+Handle(HYDROData_Bathymetry) HYDROData_Zone::GetMergeBathymetry() const
{
- SetReferenceObject( theObject, DataTag_GeometryObject, theIndex );
+ return Handle(HYDROData_Bathymetry)::DownCast(
+ GetReferenceObject( DataTag_Bathymetry ) );
}
-void HYDROData_Zone::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects )
+void HYDROData_Zone::RemoveMergeBathymetry()
{
- SetReferenceObjects( theObjects, DataTag_GeometryObject );
+ ClearReferenceObjects( DataTag_Bathymetry );
}
-Handle(HYDROData_Object) HYDROData_Zone::GetGeometryObject( const int theIndex ) const
+bool HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
{
- return Handle(HYDROData_Object)::DownCast(
- GetReferenceObject( DataTag_GeometryObject, theIndex ) );
+ if ( theObject.IsNull() )
+ return false;
+
+ if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) &&
+ !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) )
+ return false; // Wrong type of object
+
+ if ( HasReference( theObject, DataTag_GeometryObject ) )
+ return false; // Object is already in reference list
+
+ AddReferenceObject( theObject, DataTag_GeometryObject );
+ return true;
}
HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const
-
#include <HYDROData_Entity.h>
class Handle(HYDROData_Object);
+class Handle(HYDROData_Bathymetry);
class TopoDS_Shape;
DEFINE_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
class HYDROData_Zone : public HYDROData_Entity
{
+public:
+
+ // Enumeration of mergin types for conflict bathymetries
+ enum MergeBathymetriesType
+ {
+ Merge_ZMIN, // The minimum values
+ Merge_ZMAX, // The maximum values
+ Merge_Object // Only one bathymetry will be taken into account
+ };
+
protected:
/**
* Enumeration of tags corresponding to the persistent object parameters.
enum DataTag
{
DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
- DataTag_Shape, ///< reference shape
- DataTag_GeometryObject, ///< reference geometry objects
+ DataTag_Shape, ///< reference shape
+ DataTag_GeometryObject, ///< reference geometry objects
+ DataTag_MergeType, ///< mergin type of conflict bathymetries
+ DataTag_Bathymetry, ///< reference bathymetry
};
public:
/**
- * Returns number of geometry objects for zone.
+ * Sets the merging type for conflict bathymetries.
+ * By default it is set to Merge_ZMIN.
*/
- HYDRODATA_EXPORT virtual int NbGeometryObjects() const;
+ HYDRODATA_EXPORT virtual void SetMergeType( const MergeBathymetriesType& theType );
/**
- * Add new one geometry object for zone.
+ * Returns the merging type for conflict bathymetries.
*/
- HYDRODATA_EXPORT virtual void AddGeometryObject( const Handle(HYDROData_Object)& theObject );
+ HYDRODATA_EXPORT virtual MergeBathymetriesType GetMergeType() const;
+
/**
- * Replace the geometry object for zone.
+ * Sets the reference bathymetry to resolve the conflict.
+ * This object is used only in case of "Merge_Object" merge type.
*/
- HYDRODATA_EXPORT virtual void SetGeometryObject( const int theIndex,
- const Handle(HYDROData_Object)& theObject );
+ HYDRODATA_EXPORT virtual void SetMergeBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry );
/**
- * Sets the geometry object for zone.
+ * Returns the reference bathymetry to resolve the conflict.
*/
- HYDRODATA_EXPORT virtual void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
+ HYDRODATA_EXPORT virtual Handle(HYDROData_Bathymetry) GetMergeBathymetry() const;
/**
- * Returns geometry object of zone by index.
+ * Removes the reference bathymetry for resolving the conflict.
+ */
+ HYDRODATA_EXPORT virtual void RemoveMergeBathymetry();
+
+
+ /**
+ * Add new one geometry object for zone.
*/
- HYDRODATA_EXPORT virtual Handle(HYDROData_Object) GetGeometryObject( const int theIndex ) const;
+ HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
/**
* Returns all geometry objects of zone.
HYDROData_SequenceOfObjects aGeomObjects =
HYDROGUI_Tool::FindObjectsByNames( module(), aRefObjectNames );
- aCalculObj->SetGeometryObjects( aGeomObjects );
-
theUpdateFlags = UF_Model;
return true;
#include <HYDROData_Calculation.h>
%End
-class HYDROData_Calculation : HYDROData_Object
+class HYDROData_Calculation : HYDROData_Entity
{
%TypeHeaderCode
%End
- /**
- * Replace the geometry object for calculation case.
- */
- void SetGeometryObject( const int theIndex,
- HYDROData_Object theObject ) [void (const int, const Handle_HYDROData_Object&)];
- %MethodCode
-
- Handle(HYDROData_Object) aGeomObj =
- Handle(HYDROData_Object)::DownCast( createHandle( a1 ) );
- if ( !aGeomObj.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Calculation::SetGeometryObject( a0, aGeomObj ) :
- sipCpp->SetGeometryObject( a0, aGeomObj );
- Py_END_ALLOW_THREADS
- }
-
- %End
-
- /**
- * Sets the geometry object for calculation case.
- */
- //void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
-
- /**
- * Returns geometry object of calculation case by index.
- */
- HYDROData_Object GetGeometryObject( const int theIndex ) const [Handle_HYDROData_Object (const int)];
- %MethodCode
-
- Handle(HYDROData_Object) aGeomObj;
-
- Py_BEGIN_ALLOW_THREADS
- aGeomObj = sipSelfWasArg ? sipCpp->HYDROData_Calculation::GetGeometryObject( a0 ) :
- sipCpp->GetGeometryObject( a0 );
- Py_END_ALLOW_THREADS
-
- sipRes = (HYDROData_Object*)createPointer( aGeomObj );
-
- %End
-
/**
* Returns all geometry objects of calculation case.
*/
/**
* Add new one region for calculation case.
- * The new region is not added into the list of reference regions.
+ * The new region is added into the list of reference regions.
*/
HYDROData_Region AddNewRegion() [Handle_HYDROData_Region ()];
%MethodCode
%End
- /**
- * Removes all child regions from calculation case.
- */
- void RemoveChildRegions();
-
-
- /**
- * Returns number of reference regions for calculation case.
- */
- int NbRegions() const;
/**
* Add new one reference region for calculation case.
%End
- /**
- * Replace the reference region for calculation case.
- */
- void SetRegion( const int theIndex,
- HYDROData_Region theRegion ) [void (const int, const Handle_HYDROData_Region&)];
- %MethodCode
-
- Handle(HYDROData_Region) aRegion =
- Handle(HYDROData_Region)::DownCast( createHandle( a1 ) );
- if ( !aRegion.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Calculation::SetRegion( a0, aRegion ) :
- sipCpp->SetRegion( a0, aRegion );
- Py_END_ALLOW_THREADS
- }
-
- %End
-
- /**
- * Inserts the reference region for calculation case before given index.
- */
- void InsertRegion( const int theBeforeIndex,
- HYDROData_Region theRegion ) [void (const int, const Handle_HYDROData_Region&)];
- %MethodCode
-
- Handle(HYDROData_Region) aRegion =
- Handle(HYDROData_Region)::DownCast( createHandle( a1 ) );
- if ( !aRegion.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Calculation::InsertRegion( a0, aRegion ) :
- sipCpp->InsertRegion( a0, aRegion );
- Py_END_ALLOW_THREADS
- }
-
- %End
-
- /**
- * Sets reference regions for calculation case.
- */
- //void SetRegions( const HYDROData_SequenceOfObjects& theRegions );
-
- /**
- * Returns reference region of calculation case by index.
- */
- HYDROData_Region GetRegion( const int theIndex ) const [Handle_HYDROData_Region (const int)];
- %MethodCode
-
- Handle(HYDROData_Region) aRefRegion;
-
- Py_BEGIN_ALLOW_THREADS
- aRefRegion = sipSelfWasArg ? sipCpp->HYDROData_Calculation::GetRegion( a0 ) :
- sipCpp->GetRegion( a0 );
- Py_END_ALLOW_THREADS
-
- sipRes = (HYDROData_Region*)createPointer( aRefRegion );
-
- %End
-
/**
* Returns all reference regions of calculation case.
*/
%End
- /**
- * Removes region from calculation case by it index.
- */
- void RemoveRegion( const int theIndex );
-
/**
* Removes all reference regions from calculation case.
*/
}
%End
-public:
-
- // Enumeration of mergin types for conflict bathymetries
- enum MergeBathymetriesType
- {
- Merge_ZMIN,
- Merge_ZMAX
- };
-
public:
- /**
- * Create new one reference zone for region on child label.
- * The new zone is not added into the list of reference zones.
- */
- HYDROData_Zone AddNewZone() [Handle_HYDROData_Zone ()];
- %MethodCode
-
- Handle(HYDROData_Zone) aNewZone;
-
- Py_BEGIN_ALLOW_THREADS
- aNewZone = sipSelfWasArg ? sipCpp->HYDROData_Region::AddNewZone() :
- sipCpp->AddNewZone();
- Py_END_ALLOW_THREADS
-
- sipRes = (HYDROData_Zone*)createPointer( aNewZone );
-
- %End
-
- /**
- * Removes all child zones from region.
- */
- void RemoveChildZones();
-
-
- /**
- * Sets the merging type for conflict bathymetries.
- * By default it is set to Merge_ZMIN.
- */
- void SetMergeType( const MergeBathymetriesType& theType );
-
- /**
- * Returns the merging type for conflict bathymetries.
- */
- MergeBathymetriesType GetMergeType() const;
-
-
- /**
- * Returns number of reference zones of region.
- */
- int NbZones() const;
-
/**
* Add new one reference zone for region.
*/
%End
- /**
- * Replace the reference zone for region.
- */
- void SetZone( const int theIndex,
- HYDROData_Zone theZone ) [void (const int, const Handle_HYDROData_Zone&)];
- %MethodCode
-
- Handle(HYDROData_Zone) aZone =
- Handle(HYDROData_Zone)::DownCast( createHandle( a1 ) );
- if ( !aZone.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Region::SetZone( a0, aZone ) :
- sipCpp->SetZone( a0, aZone );
- Py_END_ALLOW_THREADS
- }
-
- %End
-
- /**
- * Inserts the reference zone for region before given index.
- */
- void InsertZone( const int theBeforeIndex,
- HYDROData_Zone theZone ) [void (const int, const Handle_HYDROData_Zone&)];
- %MethodCode
-
- Handle(HYDROData_Zone) aZone =
- Handle(HYDROData_Zone)::DownCast( createHandle( a1 ) );
- if ( !aZone.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Region::InsertZone( a0, aZone ) :
- sipCpp->InsertZone( a0, aZone );
- Py_END_ALLOW_THREADS
- }
-
- %End
-
- /**
- * Sets reference zones for calculation region.
- */
- //void SetZones( const HYDROData_SequenceOfObjects& theZones );
-
- /**
- * Returns reference zone of region by index.
- */
- HYDROData_Zone GetZone( const int theIndex ) const [Handle_HYDROData_Zone (const int)];
- %MethodCode
-
- Handle(HYDROData_Zone) aRefZone;
-
- Py_BEGIN_ALLOW_THREADS
- aRefZone = sipSelfWasArg ? sipCpp->HYDROData_Region::GetZone( a0 ) :
- sipCpp->GetZone( a0 );
- Py_END_ALLOW_THREADS
-
- sipRes = (HYDROData_Zone*)createPointer( aRefZone );
-
- %End
-
/**
* Returns all reference zone of region.
*/
%End
- /**
- * Removes reference zone from region by it index.
- */
- void RemoveZone( const int theIndex );
-
/**
* Removes all reference zones from region.
*/
}
%End
+public:
+
+ // Enumeration of mergin types for conflict bathymetries
+ enum MergeBathymetriesType
+ {
+ Merge_ZMIN, // The minimum values
+ Merge_ZMAX, // The maximum values
+ Merge_Object // Only one bathymetry will be taken into account
+ };
+
public:
/**
- * Returns number of geometry objects for zone.
+ * Sets the merging type for conflict bathymetries.
+ * By default it is set to Merge_ZMIN.
*/
- int NbGeometryObjects() const;
+ void SetMergeType( const MergeBathymetriesType& theType );
/**
- * dd new one geometry object for zone.
+ * Returns the merging type for conflict bathymetries.
*/
- void AddGeometryObject( HYDROData_Object theRegion ) [void (const Handle_HYDROData_Object&)];
- %MethodCode
-
- Handle(HYDROData_Object) aGeomObj =
- Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
- if ( !aGeomObj.IsNull() )
- {
- Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Zone::AddGeometryObject( aGeomObj ) :
- sipCpp->AddGeometryObject( aGeomObj );
- Py_END_ALLOW_THREADS
- }
+ MergeBathymetriesType GetMergeType() const;
- %End
/**
- * Replace the geometry object for zone.
+ * Sets the reference bathymetry to resolve the conflict.
+ * This object is used only in case of "Merge_Object" merge type.
*/
- void SetGeometryObject( const int theIndex,
- HYDROData_Object theObject ) [void (const int, const Handle_HYDROData_Object&)];
+ void SetMergeBathymetry( HYDROData_Bathymetry theBathymetry ) [void (const Handle_HYDROData_Bathymetry&)];
%MethodCode
- Handle(HYDROData_Object) aGeomObj =
- Handle(HYDROData_Object)::DownCast( createHandle( a1 ) );
- if ( !aGeomObj.IsNull() )
+ Handle(HYDROData_Bathymetry) aRefBath =
+ Handle(HYDROData_Bathymetry)::DownCast( createHandle( a0 ) );
+ if ( !aRefBath.IsNull() )
{
Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_Zone::SetGeometryObject( a0, aGeomObj ) :
- sipCpp->SetGeometryObject( a0, aGeomObj );
+ sipSelfWasArg ? sipCpp->HYDROData_Zone::SetMergeBathymetry( aRefBath ) :
+ sipCpp->SetMergeBathymetry( aRefBath );
Py_END_ALLOW_THREADS
}
%End
/**
- * Sets the geometry object for zone.
+ * Returns the reference bathymetry to resolve the conflict.
*/
- //void SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects );
-
- /**
- * Returns geometry object of zone by index.
- */
- HYDROData_Object GetGeometryObject( const int theIndex ) const [Handle_HYDROData_Object (const int)];
+ HYDROData_Bathymetry GetMergeBathymetry() const [Handle_HYDROData_Bathymetry ()];
%MethodCode
- Handle(HYDROData_Object) aGeomObj;
+ Handle(HYDROData_Bathymetry) aRefBath;
Py_BEGIN_ALLOW_THREADS
- aGeomObj = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetGeometryObject( a0 ) :
- sipCpp->GetGeometryObject( a0 );
+ aRefBath = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetMergeBathymetry() :
+ sipCpp->GetMergeBathymetry();
Py_END_ALLOW_THREADS
- sipRes = (HYDROData_Object*)createPointer( aGeomObj );
+ sipRes = (HYDROData_Bathymetry*)createPointer( aRefBath );
%End
+ /**
+ * Removes the reference bathymetry for resolving the conflict.
+ */
+ void RemoveMergeBathymetry();
+
+
+ /**
+ * dd new one geometry object for zone.
+ */
+ void AddGeometryObject( HYDROData_Object theRegion ) [void (const Handle_HYDROData_Object&)];
+ %MethodCode
+
+ Handle(HYDROData_Object) aGeomObj =
+ Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
+ if ( !aGeomObj.IsNull() )
+ {
+ Py_BEGIN_ALLOW_THREADS
+ sipSelfWasArg ? sipCpp->HYDROData_Zone::AddGeometryObject( aGeomObj ) :
+ sipCpp->AddGeometryObject( aGeomObj );
+ Py_END_ALLOW_THREADS
+ }
+
+ %End
+
/**
* Returns all geometry objects of zone.
*/