+// 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_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 _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;
}
return false;
}
+bool HYDROData_Zone::IsHas2dPrs() const
+{
+ return true;
+}
+
bool HYDROData_Zone::CanRemove()
{
return false;
{
HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
- HYDROData_SequenceOfObjects aSeqOfGeomObjects = GetGeometryObjects();
- aResSeq.Append( aSeqOfGeomObjects );
+ 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
{
- TDF_Label aLabel = myLab.FindChild( DataTag_Shape, false );
- if ( !aLabel.IsNull() )
- {
- Handle(TNaming_NamedShape) aNamedShape;
- if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
- return aNamedShape->Get();
- }
-
- return TopoDS_Shape();
+ return HYDROData_Entity::GetShape( DataTag_Shape );
}
bool HYDROData_Zone::IsMergingNeed() const
{
+ // 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;
return myInterpolator;
}
-void HYDROData_Zone::SetMergeType( const MergeAltitudesType& theType )
+void HYDROData_Zone::SetMergeType( const MergeType& theType )
{
TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType );
}
-HYDROData_Zone::MergeAltitudesType HYDROData_Zone::GetMergeType() const
+HYDROData_Zone::MergeType HYDROData_Zone::GetMergeType() const
{
- MergeAltitudesType aMergeType = Merge_UNKNOWN;
+ MergeType aMergeType = Merge_UNKNOWN;
TDF_Label aLabel = myLab.FindChild( DataTag_MergeType, false );
if ( !aLabel.IsNull() )
{
Handle(TDataStd_Integer) anInt;
if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anInt ) )
- aMergeType = (MergeAltitudesType)anInt->Get();
+ aMergeType = (MergeType)anInt->Get();
}
return aMergeType;
}
-void HYDROData_Zone::SetMergeAltitude( const Handle(HYDROData_IAltitudeObject)& theAltitude )
+void HYDROData_Zone::SetMergeObject( const Handle(HYDROData_Entity)& theObject )
{
- SetReferenceObject( theAltitude, DataTag_MergeAltitude );
+ //DEBTRACE("HYDROData_Zone::SetMergeObject");
+ SetReferenceObject( theObject, DataTag_MergeObject );
}
-Handle(HYDROData_IAltitudeObject) HYDROData_Zone::GetMergeAltitude() const
+Handle(HYDROData_Entity) HYDROData_Zone::GetMergeObject() const
{
- return Handle(HYDROData_IAltitudeObject)::DownCast(
- GetReferenceObject( DataTag_MergeAltitude ) );
+ return GetReferenceObject( DataTag_MergeObject );
}
-void HYDROData_Zone::RemoveMergeAltitude()
+void HYDROData_Zone::RemoveMergeObject()
{
- ClearReferenceObjects( DataTag_MergeAltitude );
+ 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;
+}