+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#include "HYDROData_Zone.h"
#include "HYDROData_ArtificialObject.h"
-#include "HYDROData_Bathymetry.h"
+#include "HYDROData_IAltitudeObject.h"
#include "HYDROData_Document.h"
#include "HYDROData_NaturalObject.h"
-
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
-
-#include <TopoDS_Shape.hxx>
-
#include <QStringList>
-
#include <TDataStd_Integer.hxx>
+#include <TopoDS_Shape.hxx>
-#define PYTHON_ZONE_ID "KIND_ZONE"
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity)
HYDROData_Zone::HYDROData_Zone()
-: HYDROData_Entity()
+: HYDROData_Entity( Geom_2d )
{
+ myInterpolator = NULL;
}
HYDROData_Zone::~HYDROData_Zone()
{
}
-QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+bool HYDROData_Zone::CanBeUpdated() const
{
- 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( "" );
-
- 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 false;
+}
- return aResList;
+bool HYDROData_Zone::IsHas2dPrs() const
+{
+ return true;
}
bool HYDROData_Zone::CanRemove()
HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const
{
HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
- aResSeq.Append( GetGeometryObjects() );
+
+ HYDROData_SequenceOfObjects aSeqOfObjects = GetObjects();
+ aResSeq.Append( aSeqOfObjects );
+
return aResSeq;
}
void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape )
{
- TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
- aBuilder.Generated( theShape );
+ HYDROData_Entity::SetShape( DataTag_Shape, theShape );
}
TopoDS_Shape HYDROData_Zone::GetShape() const
{
- Handle(TNaming_NamedShape) aNamedShape;
- if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
- return aNamedShape->Get();
- return TopoDS_Shape();
+ return HYDROData_Entity::GetShape( DataTag_Shape );
}
bool HYDROData_Zone::IsMergingNeed() const
{
- Handle(HYDROData_Bathymetry) aRefBathymetry;
+ // Zones based on geometry objects (compare altitudes)
+ Handle(HYDROData_IAltitudeObject) aRefAltitude;
- HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
- HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects );
- for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() )
+ HYDROData_SequenceOfObjects anObjects = GetObjects();
+ HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects );
+ for ( ; anObjsIter.More(); anObjsIter.Next() )
{
Handle(HYDROData_Object) aRefGeomObj =
- Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() );
+ Handle(HYDROData_Object)::DownCast( anObjsIter.Value() );
if ( aRefGeomObj.IsNull() )
continue;
- Handle(HYDROData_Bathymetry) anObjBathymetry = aRefGeomObj->GetBathymetry();
- if ( anObjBathymetry.IsNull() )
+ Handle(HYDROData_IAltitudeObject) anObjAltitude = aRefGeomObj->GetAltitudeObject();
+ if ( anObjAltitude.IsNull() )
continue;
- if ( aRefBathymetry.IsNull() )
+ if ( aRefAltitude.IsNull() )
{
- aRefBathymetry = anObjBathymetry;
+ aRefAltitude = anObjAltitude;
continue;
}
- if ( !IsEqual( aRefBathymetry, anObjBathymetry ) )
+ if ( !IsEqual( aRefAltitude, anObjAltitude ) )
return true;
}
return false;
}
-void HYDROData_Zone::SetMergeType( const MergeBathymetriesType& theType )
+void HYDROData_Zone::SetInterpolator( HYDROData_IInterpolator* theInter )
{
- 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 );
- }
+ myInterpolator = theInter;
+}
+
+HYDROData_IInterpolator* HYDROData_Zone::GetInterpolator() const
+{
+ return myInterpolator;
}
-HYDROData_Zone::MergeBathymetriesType HYDROData_Zone::GetMergeType() const
+void HYDROData_Zone::SetMergeType( const MergeType& theType )
{
- MergeBathymetriesType aMergeType = Merge_UNKNOWN;
+ TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType );
+}
+
+HYDROData_Zone::MergeType HYDROData_Zone::GetMergeType() const
+{
+ MergeType aMergeType = Merge_UNKNOWN;
- Handle(TDataStd_Integer) anInt;
- if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
- aMergeType = (MergeBathymetriesType)anInt->Get();
+ TDF_Label aLabel = myLab.FindChild( DataTag_MergeType, false );
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Integer) anInt;
+ if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anInt ) )
+ aMergeType = (MergeType)anInt->Get();
+ }
return aMergeType;
}
-void HYDROData_Zone::SetMergeBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+void HYDROData_Zone::SetMergeObject( const Handle(HYDROData_Entity)& theObject )
{
- SetReferenceObject( theBathymetry, DataTag_Bathymetry );
+ //DEBTRACE("HYDROData_Zone::SetMergeObject");
+ SetReferenceObject( theObject, DataTag_MergeObject );
}
-Handle(HYDROData_Bathymetry) HYDROData_Zone::GetMergeBathymetry() const
+Handle(HYDROData_Entity) HYDROData_Zone::GetMergeObject() const
{
- return Handle(HYDROData_Bathymetry)::DownCast(
- GetReferenceObject( DataTag_Bathymetry ) );
+ return GetReferenceObject( DataTag_MergeObject );
}
-void HYDROData_Zone::RemoveMergeBathymetry()
+void HYDROData_Zone::RemoveMergeObject()
{
- ClearReferenceObjects( DataTag_Bathymetry );
+ ClearReferenceObjects( DataTag_MergeObject );
}
-bool HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
+bool HYDROData_Zone::AddObject( const Handle(HYDROData_Entity)& theObject )
{
if ( theObject.IsNull() )
return false;
!theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) )
return false; // Wrong type of object
- if ( HasReference( theObject, DataTag_GeometryObject ) )
+ if ( HasReference( theObject, DataTag_Object ) )
return false; // Object is already in reference list
- AddReferenceObject( theObject, DataTag_GeometryObject );
+ AddReferenceObject( theObject, DataTag_Object );
+
return true;
}
-HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const
+HYDROData_SequenceOfObjects HYDROData_Zone::GetObjects() const
{
- return GetReferenceObjects( DataTag_GeometryObject );
+ return GetReferenceObjects( DataTag_Object );
}
-void HYDROData_Zone::RemoveGeometryObjects()
+void HYDROData_Zone::RemoveObjects()
{
- ClearReferenceObjects( DataTag_GeometryObject );
+ ClearReferenceObjects( DataTag_Object );
}
+bool HYDROData_Zone::IsSubmersible() const
+{
+ HYDROData_SequenceOfObjects anObjects = GetObjects();
+ HYDROData_SequenceOfObjects::Iterator anObjsIter( anObjects );
+ for ( ; anObjsIter.More(); anObjsIter.Next() )
+ {
+ Handle(HYDROData_Object) aRefGeomObj =
+ Handle(HYDROData_Object)::DownCast( anObjsIter.Value() );
+ if ( aRefGeomObj.IsNull() )
+ continue;
+ if( !aRefGeomObj->IsSubmersible() )
+ return false; //if one of geometry objects is not submersible the zone is considered as not submersible
+ }
+ return true;
+}