X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Zone.cxx;h=edd4169040c90629a63026d2e6e8bf284bdbd97a;hb=f7c005b67e48ec7bac99c566fb4f34215ec1a4b1;hp=36b13d65629b20eb2edd5293622947deb8edf647;hpb=84f8b4a57d3cdad820bc1333a5066699cd1c8ae3;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 36b13d65..edd41690 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -1,8 +1,31 @@ +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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_IAltitudeObject.h" #include "HYDROData_Document.h" -#include "HYDROData_Object.h" +#include "HYDROData_NaturalObject.h" #include #include @@ -11,7 +34,7 @@ #include -#define PYTHON_ZONE_ID "KIND_ZONE" +#include IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) @@ -20,28 +43,60 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) HYDROData_Zone::HYDROData_Zone() : HYDROData_Entity() { + myInterpolator = NULL; } HYDROData_Zone::~HYDROData_Zone() { } -QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +bool HYDROData_Zone::CanBeUpdated() const { - QStringList aResList; + return false; +} + +bool HYDROData_Zone::IsHas2dPrs() const +{ + return true; +} + +bool HYDROData_Zone::CanRemove() +{ + return false; +} + +HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const +{ + HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects(); + + HYDROData_SequenceOfObjects aSeqOfGeomObjects = GetGeometryObjects(); + aResSeq.Append( aSeqOfGeomObjects ); + + return aResSeq; +} - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); - if ( aDocument.IsNull() ) - return aResList; +void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape ) +{ + TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) ); + aBuilder.Generated( 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(); + } - QString aDocName = aDocument->GetDocPyName(); - QString aZoneName = GetName(); + return TopoDS_Shape(); +} - 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( "" ); +bool HYDROData_Zone::IsMergingNeed() const +{ + Handle(HYDROData_IAltitudeObject) aRefAltitude; HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects ); @@ -49,55 +104,87 @@ QStringList HYDROData_Zone::DumpToPython( MapOfTreatedObjects& theTreatedObjects { Handle(HYDROData_Object) aRefGeomObj = Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() ); - if ( !aRefGeomObj.IsNull() ) - setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); + if ( aRefGeomObj.IsNull() ) + continue; + + Handle(HYDROData_IAltitudeObject) anObjAltitude = aRefGeomObj->GetAltitudeObject(); + if ( anObjAltitude.IsNull() ) + continue; + + if ( aRefAltitude.IsNull() ) + { + aRefAltitude = anObjAltitude; + continue; + } + + if ( !IsEqual( aRefAltitude, anObjAltitude ) ) + return true; } - // 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; +void HYDROData_Zone::SetInterpolator( HYDROData_IInterpolator* theInter ) +{ + myInterpolator = theInter; } -void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape ) +HYDROData_IInterpolator* HYDROData_Zone::GetInterpolator() const { - TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) ); - aBuilder.Generated( theShape ); + return myInterpolator; } -TopoDS_Shape HYDROData_Zone::GetShape() const +void HYDROData_Zone::SetMergeType( const MergeAltitudesType& theType ) { - Handle(TNaming_NamedShape) aNamedShape; - if( myLab.FindChild( DataTag_Shape ).FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) ) - return aNamedShape->Get(); - return TopoDS_Shape(); + TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType ); } -int HYDROData_Zone::NbGeometryObjects() const +HYDROData_Zone::MergeAltitudesType HYDROData_Zone::GetMergeType() const { - return NbReferenceObjects( DataTag_GeometryObject ); + MergeAltitudesType 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(); + } + + return aMergeType; } -void HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) +void HYDROData_Zone::SetMergeAltitude( const Handle(HYDROData_IAltitudeObject)& theAltitude ) { - AddReferenceObject( theObject, DataTag_GeometryObject ); + SetReferenceObject( theAltitude, DataTag_MergeAltitude ); } -void HYDROData_Zone::SetGeometryObject( const int theIndex, - const Handle(HYDROData_Object)& theObject ) +Handle(HYDROData_IAltitudeObject) HYDROData_Zone::GetMergeAltitude() const { - SetReferenceObject( theObject, DataTag_GeometryObject, theIndex ); + return Handle(HYDROData_IAltitudeObject)::DownCast( + GetReferenceObject( DataTag_MergeAltitude ) ); } -void HYDROData_Zone::SetGeometryObjects( const HYDROData_SequenceOfObjects& theObjects ) +void HYDROData_Zone::RemoveMergeAltitude() { - SetReferenceObjects( theObjects, DataTag_GeometryObject ); + ClearReferenceObjects( DataTag_MergeAltitude ); } -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 @@ -112,4 +199,3 @@ void HYDROData_Zone::RemoveGeometryObjects() -