#include "HYDROData_Zone.h"
+#include "HYDROData_ArtificialObject.h"
#include "HYDROData_Bathymetry.h"
#include "HYDROData_Document.h"
-#include "HYDROData_Polyline.h"
-#include "HYDROData_Iterator.h"
+#include "HYDROData_NaturalObject.h"
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <TDataStd_IntegerArray.hxx>
-#include <TopoDS_Wire.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+
+#include <TopoDS_Shape.hxx>
-#include <QColor>
#include <QStringList>
+#include <TDataStd_Integer.hxx>
+
#define PYTHON_ZONE_ID "KIND_ZONE"
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Domain)
-IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Domain)
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity)
+
HYDROData_Zone::HYDROData_Zone()
+: HYDROData_Entity()
{
}
QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
{
- QStringList aResList = HYDROData_Domain::DumpToPython( theTreatedObjects );
- if ( aResList.isEmpty() )
+ QStringList aResList;
+
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( aDocument.IsNull() )
return aResList;
+ QString aDocName = aDocument->GetDocPyName();
+ QString aZoneName = GetName();
+
+ aResList << QString( "%1 = %2.CreateObject( %3 );" )
+ .arg( aZoneName ).arg( aDocName ).arg( PYTHON_ZONE_ID );
+ aResList << QString( "%1.SetName( \"%2\" );" )
+ .arg( aZoneName ).arg( aZoneName );
aResList << QString( "" );
- Handle(HYDROData_Polyline) aRefPolyline = GetPolyline();
- setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
+ HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
+ HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects );
+ for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() )
+ {
+ Handle(HYDROData_Object) aRefGeomObj =
+ Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() );
+ if ( !aRefGeomObj.IsNull() )
+ setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
+ }
+
+ // How can we get the shape? Mb Update() method to intersect the shapes of reference objects?
+ // TODO: TopoDS_Shape aRefShape = GetShape();
return aResList;
}
-void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
+bool HYDROData_Zone::CanRemove()
+{
+ return false;
+}
+
+HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const
{
- SetReferenceObject( thePolyline, DataTag_Polyline );
+ HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
+
+ HYDROData_SequenceOfObjects aSeqOfGeomObjects = GetGeometryObjects();
+ aResSeq.Append( aSeqOfGeomObjects );
+
+ return aResSeq;
}
-Handle(HYDROData_Polyline) HYDROData_Zone::GetPolyline() const
+void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape )
{
- return Handle(HYDROData_Polyline)::DownCast(
- GetReferenceObject( DataTag_Polyline ) );
+ TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
+ aBuilder.Generated( theShape );
}
-void HYDROData_Zone::RemovePolyline()
+TopoDS_Shape HYDROData_Zone::GetShape() const
{
- ClearReferenceObjects( DataTag_Polyline );
+ Handle(TNaming_NamedShape) aNamedShape;
+ if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
+ return aNamedShape->Get();
+ return TopoDS_Shape();
}
-TopoDS_Face HYDROData_Zone::Face() const
+bool HYDROData_Zone::IsMergingNeed() const
{
- Handle(HYDROData_Polyline) aPolyline = GetPolyline();
- if( !aPolyline.IsNull() )
+ Handle(HYDROData_Bathymetry) aRefBathymetry;
+
+ HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
+ HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects );
+ for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() )
{
- TopoDS_Wire aWire = aPolyline->Wire();
- if( !aWire.IsNull() )
+ Handle(HYDROData_Object) aRefGeomObj =
+ Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() );
+ if ( aRefGeomObj.IsNull() )
+ continue;
+
+ Handle(HYDROData_Bathymetry) anObjBathymetry = aRefGeomObj->GetBathymetry();
+ if ( anObjBathymetry.IsNull() )
+ continue;
+
+ if ( aRefBathymetry.IsNull() )
{
- BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
- aMakeFace.Build();
- if( aMakeFace.IsDone() )
- return aMakeFace.Face();
+ aRefBathymetry = anObjBathymetry;
+ continue;
}
+
+ if ( !IsEqual( aRefBathymetry, anObjBathymetry ) )
+ return true;
+ }
+
+ return false;
+}
+
+void HYDROData_Zone::SetMergeType( const MergeBathymetriesType& theType )
+{
+ Handle(TDataStd_Integer) anInt;
+ if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
+ {
+ anInt->Set( (int)theType );
+ }
+ else
+ {
+ anInt = TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType );
}
- return TopoDS_Face();
}
-QString HYDROData_Zone::getPythonKindId() const
+HYDROData_Zone::MergeBathymetriesType HYDROData_Zone::GetMergeType() const
+{
+ MergeBathymetriesType aMergeType = Merge_UNKNOWN;
+
+ 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 );
+}
+
+Handle(HYDROData_Bathymetry) HYDROData_Zone::GetMergeBathymetry() const
+{
+ return Handle(HYDROData_Bathymetry)::DownCast(
+ GetReferenceObject( DataTag_Bathymetry ) );
+}
+
+void HYDROData_Zone::RemoveMergeBathymetry()
+{
+ ClearReferenceObjects( DataTag_Bathymetry );
+}
+
+bool HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
+{
+ 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
+{
+ return GetReferenceObjects( DataTag_GeometryObject );
+}
+
+void HYDROData_Zone::RemoveGeometryObjects()
{
- return QString( PYTHON_ZONE_ID );
+ ClearReferenceObjects( DataTag_GeometryObject );
}