1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROData_Zone.h"
25 #include "HYDROData_ArtificialObject.h"
26 #include "HYDROData_IAltitudeObject.h"
27 #include "HYDROData_Document.h"
28 #include "HYDROData_NaturalObject.h"
30 #include <TNaming_Builder.hxx>
31 #include <TNaming_NamedShape.hxx>
33 #include <TopoDS_Shape.hxx>
35 #include <QStringList>
37 #include <TDataStd_Integer.hxx>
39 IMPLEMENT_STANDARD_HANDLE(HYDROData_Zone, HYDROData_Entity)
40 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity)
43 HYDROData_Zone::HYDROData_Zone()
46 myInterpolator = NULL;
49 HYDROData_Zone::~HYDROData_Zone()
53 bool HYDROData_Zone::CanBeUpdated() const
58 bool HYDROData_Zone::IsHas2dPrs() const
63 bool HYDROData_Zone::CanRemove()
68 HYDROData_SequenceOfObjects HYDROData_Zone::GetAllReferenceObjects() const
70 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
72 HYDROData_SequenceOfObjects aSeqOfGeomObjects = GetGeometryObjects();
73 aResSeq.Append( aSeqOfGeomObjects );
78 void HYDROData_Zone::SetShape( const TopoDS_Shape& theShape )
80 TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
81 aBuilder.Generated( theShape );
84 TopoDS_Shape HYDROData_Zone::GetShape() const
86 TDF_Label aLabel = myLab.FindChild( DataTag_Shape, false );
87 if ( !aLabel.IsNull() )
89 Handle(TNaming_NamedShape) aNamedShape;
90 if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
91 return aNamedShape->Get();
94 return TopoDS_Shape();
97 bool HYDROData_Zone::IsMergingNeed() const
99 Handle(HYDROData_IAltitudeObject) aRefAltitude;
101 HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
102 HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects );
103 for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() )
105 Handle(HYDROData_Object) aRefGeomObj =
106 Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() );
107 if ( aRefGeomObj.IsNull() )
110 Handle(HYDROData_IAltitudeObject) anObjAltitude = aRefGeomObj->GetAltitudeObject();
111 if ( anObjAltitude.IsNull() )
114 if ( aRefAltitude.IsNull() )
116 aRefAltitude = anObjAltitude;
120 if ( !IsEqual( aRefAltitude, anObjAltitude ) )
127 void HYDROData_Zone::SetInterpolator( HYDROData_IInterpolator* theInter )
129 myInterpolator = theInter;
132 HYDROData_IInterpolator* HYDROData_Zone::GetInterpolator() const
134 return myInterpolator;
137 void HYDROData_Zone::SetMergeType( const MergeAltitudesType& theType )
139 TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType );
142 HYDROData_Zone::MergeAltitudesType HYDROData_Zone::GetMergeType() const
144 MergeAltitudesType aMergeType = Merge_UNKNOWN;
146 TDF_Label aLabel = myLab.FindChild( DataTag_MergeType, false );
147 if ( !aLabel.IsNull() )
149 Handle(TDataStd_Integer) anInt;
150 if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anInt ) )
151 aMergeType = (MergeAltitudesType)anInt->Get();
157 void HYDROData_Zone::SetMergeAltitude( const Handle(HYDROData_IAltitudeObject)& theAltitude )
159 SetReferenceObject( theAltitude, DataTag_MergeAltitude );
162 Handle(HYDROData_IAltitudeObject) HYDROData_Zone::GetMergeAltitude() const
164 return Handle(HYDROData_IAltitudeObject)::DownCast(
165 GetReferenceObject( DataTag_MergeAltitude ) );
168 void HYDROData_Zone::RemoveMergeAltitude()
170 ClearReferenceObjects( DataTag_MergeAltitude );
173 bool HYDROData_Zone::AddGeometryObject( const Handle(HYDROData_Object)& theObject )
175 if ( theObject.IsNull() )
178 if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) &&
179 !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) )
180 return false; // Wrong type of object
182 if ( HasReference( theObject, DataTag_GeometryObject ) )
183 return false; // Object is already in reference list
185 AddReferenceObject( theObject, DataTag_GeometryObject );
190 HYDROData_SequenceOfObjects HYDROData_Zone::GetGeometryObjects() const
192 return GetReferenceObjects( DataTag_GeometryObject );
195 void HYDROData_Zone::RemoveGeometryObjects()
197 ClearReferenceObjects( DataTag_GeometryObject );