1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <HYDROData_Entity.h>
20 #include <HYDROData_Document.h>
21 #include <HYDROData_Iterator.h>
22 #include <HYDROData_Tool.h>
23 #include <Standard_GUID.hxx>
24 #include <TDataStd_Name.hxx>
25 #include <TDataStd_ByteArray.hxx>
26 #include <TDataStd_UAttribute.hxx>
27 #include <TDataStd_Integer.hxx>
28 #include <TDataStd_IntegerArray.hxx>
29 #include <TDataStd_ReferenceList.hxx>
30 #include <TDataStd_Real.hxx>
31 #include <TDF_CopyLabel.hxx>
32 #include <TDF_ListIteratorOfLabelList.hxx>
33 #include <TNaming_Builder.hxx>
34 #include <TNaming_NamedShape.hxx>
35 #include <TopoDS_Shape.hxx>
38 #include <QStringList>
41 HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects()
42 : NCollection_Sequence<Handle_HYDROData_Entity>()
46 HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects( const HYDROData_SequenceOfObjects& theSequence )
47 : NCollection_Sequence<Handle_HYDROData_Entity>( theSequence )
51 HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects( const NCollection_Sequence<Handle_HYDROData_Entity>& theSequence )
52 : NCollection_Sequence<Handle_HYDROData_Entity>( theSequence )
57 IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared)
58 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Entity,MMgt_TShared)
60 // is equal function for unique object mapping
61 bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2)
63 if ( !theObj1.IsNull() && !theObj2.IsNull() )
64 return theObj1->Label() == theObj2->Label();
68 QString HYDROData_Entity::GetName() const
70 Handle(TDataStd_Name) aName;
71 if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
72 TCollection_AsciiString aStr(aName->Get());
73 return QString(aStr.ToCString());
78 QString HYDROData_Entity::GetObjPyName() const
80 QString aName = GetName();
81 aName.replace(QRegExp("[\\W]"), "_");
86 void HYDROData_Entity::SetName(const QString& theName)
88 TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
91 QStringList HYDROData_Entity::DumpToPython( const QString& thePyScriptPath,
92 MapOfTreatedObjects& theTreatedObjects ) const
94 QStringList anEmptyList;
98 void HYDROData_Entity::Update()
103 void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy )
105 //On the base level no actions are necessary
108 bool HYDROData_Entity::IsHas2dPrs() const
113 void HYDROData_Entity::Show()
118 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
119 if ( aDocument.IsNull() )
122 aDocument->Show( this );
125 QVariant HYDROData_Entity::GetDataVariant()
130 void HYDROData_Entity::ClearChanged()
132 TDataStd_Integer::Set( myLab.FindChild( DataTag_GeomChange ), 0 );
135 int HYDROData_Entity::GetGeomChangeFlag() const
137 int aGeomChangeFlag = 0;
138 Handle(TDataStd_Integer) aGeomChangeAttr;
139 TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange );
140 aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr );
141 if ( !aGeomChangeAttr.IsNull() )
142 aGeomChangeFlag = aGeomChangeAttr->Get();
143 return aGeomChangeFlag;
146 void HYDROData_Entity::Changed( Geometry theChangedGeometry )
148 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
149 if( aDocument.IsNull() )
152 int aGeomChangeFlag = 0;
153 Handle(TDataStd_Integer) aGeomChangeAttr;
154 TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange );
155 aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr );
156 if ( !aGeomChangeAttr.IsNull() )
157 aGeomChangeFlag = aGeomChangeAttr->Get();
159 int aBitsToChange = ( myGeom & theChangedGeometry );
160 if( aBitsToChange == 0 )
163 aGeomChangeFlag = ( aGeomChangeFlag | aBitsToChange );
164 TDataStd_Integer::Set( aGeomChangeLab, aGeomChangeFlag );
166 HYDROData_Iterator anIter( aDocument );
167 for ( ; anIter.More(); anIter.Next() )
169 Handle(HYDROData_Entity) anObject = anIter.Current();
170 if( anObject.IsNull() )
172 HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects();
173 for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i )
175 Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i );
176 if( aRefObject->Label()==myLab )
177 anObject->Changed( theChangedGeometry );
182 bool HYDROData_Entity::IsMustBeUpdated( Geometry theGeom ) const
184 return ( ( GetGeomChangeFlag() & theGeom ) != 0 );
187 bool HYDROData_Entity::CanBeUpdated() const
192 bool HYDROData_Entity::IsRemoved() const
194 return !myLab.HasAttribute();
197 void HYDROData_Entity::Remove()
199 return myLab.ForgetAllAttributes( true );
202 bool HYDROData_Entity::CanRemove()
207 HYDROData_Entity::HYDROData_Entity( Geometry theGeom )
212 HYDROData_Entity::~HYDROData_Entity()
216 void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination,
217 bool isGenerateNewName ) const
219 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
220 if ( aDocument.IsNull() ) {
224 TDF_CopyLabel aCopy(myLab, theDestination->Label());
227 if( isGenerateNewName )
229 // generate a new unique name for the clone object:
230 // case 1: Image_1 -> Image_2
231 // case 2: ImageObj -> ImageObj_1
232 QString aName = theDestination->GetName();
233 QString aPrefix = aName;
234 if( aName.contains( '_' ) ) { // case 1
235 QString aSuffix = aName.section( '_', -1 );
236 bool anIsInteger = false;
237 aSuffix.toInt( &anIsInteger );
239 aPrefix = aName.section( '_', 0, -2 );
244 aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix );
245 theDestination->SetName( aName );
249 Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const
251 Handle(HYDROData_Entity) aFather;
253 if ( !myLab.IsNull() )
255 TDF_Label aFatherLabel = myLab.Father();
257 while ( aFather.IsNull() && !aFatherLabel.IsNull() && !aFatherLabel.IsRoot() )
259 aFather = HYDROData_Iterator::Object( aFatherLabel );
260 aFatherLabel = aFatherLabel.Father();
267 HYDROData_SequenceOfObjects HYDROData_Entity::GetAllReferenceObjects() const
269 return HYDROData_SequenceOfObjects();
272 Standard_Boolean HYDROData_Entity::GetZLevel( Standard_Integer& theLevel ) const
276 TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false );
277 if ( !aLabel.IsNull() )
279 Handle(TDataStd_Integer) anIntVal;
280 if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) )
282 theLevel = anIntVal->Get();
283 return Standard_True;
287 return Standard_False;
290 void HYDROData_Entity::SetZLevel( const Standard_Integer& theLevel )
292 TDataStd_Integer::Set( myLab.FindChild( DataTag_ZLevel ), theLevel );
295 void HYDROData_Entity::RemoveZLevel()
297 TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false );
298 if ( !aLabel.IsNull() )
299 aLabel.ForgetAllAttributes();
302 void HYDROData_Entity::SetLabel( const TDF_Label& theLabel )
307 void HYDROData_Entity::SaveByteArray( const int theTag,
311 TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
312 // array is empty, remove the attribute
314 aLab.ForgetAttribute(TDataStd_ByteArray::GetID());
317 // store data of image in byte array
318 Handle(TDataStd_ByteArray) aData;
319 if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData)) {
320 aData = TDataStd_ByteArray::Set(aLab, 1, theLen);
322 // copy bytes one by one
323 if (aData->Length() != theLen) {
324 Handle(TColStd_HArray1OfByte) aNewData = new TColStd_HArray1OfByte(1, theLen);
325 for(int a = 0; a < theLen; a++)
326 aNewData->SetValue(a + 1, theData[a]);
327 aData->ChangeArray(aNewData);
329 for(int a = 0; a < theLen; a++)
330 aData->SetValue(a + 1, theData[a]);
334 const char* HYDROData_Entity::ByteArray(const int theTag, int& theLen) const
336 TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
337 Handle(TDataStd_ByteArray) aData;
338 if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData))
339 return NULL; // return empty image if there is no array
340 theLen = aData->Length();
342 return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
346 int HYDROData_Entity::NbReferenceObjects( const int theTag ) const
348 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
349 return aRefs.IsNull() ? 0 : aRefs->Extent();
352 bool HYDROData_Entity::HasReference( const Handle_HYDROData_Entity& theObj,
353 const int theTag ) const
355 if ( theObj.IsNull() )
358 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
359 if ( aRefs.IsNull() || aRefs->IsEmpty() )
362 TDF_ListIteratorOfLabelList aListIt( aRefs->List() );
363 for ( ; aListIt.More(); aListIt.Next() )
365 const TDF_Label& aRefLabel = aListIt.Value();
366 if ( theObj->Label() == aRefLabel )
373 void HYDROData_Entity::AddReferenceObject( const Handle_HYDROData_Entity& theObj,
376 if ( theObj.IsNull() )
379 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
380 aRefs->Append( theObj->Label() );
383 void HYDROData_Entity::SetReferenceObject( const Handle_HYDROData_Entity& theObj,
387 if ( theObj.IsNull() )
389 RemoveReferenceObject( theTag, theIndex );
393 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
395 if ( theIndex >= aRefs->Extent() )
397 aRefs->Append( theObj->Label() );
399 else if ( theIndex < 0 )
401 aRefs->Prepend( theObj->Label() );
405 RemoveReferenceObject( theTag, theIndex );
407 Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theIndex );
409 aRefs = getReferenceList( theTag, true ); // because reference list can be removed
410 if ( !aBeforeObj.IsNull() )
411 aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
413 aRefs->Append( theObj->Label() );
417 void HYDROData_Entity::InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
419 const int theBeforeIndex )
421 if ( theObj.IsNull() )
424 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
426 if ( theBeforeIndex >= aRefs->Extent() )
428 aRefs->Append( theObj->Label() );
430 else if ( theBeforeIndex < 0 )
432 aRefs->Prepend( theObj->Label() );
436 Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theBeforeIndex );
437 if ( !aBeforeObj.IsNull() )
438 aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
440 aRefs->Append( theObj->Label() );
444 void HYDROData_Entity::SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
447 ClearReferenceObjects( theTag );
448 if ( theObjects.IsEmpty() )
451 HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
452 for ( ; anIter.More(); anIter.Next() )
453 AddReferenceObject( anIter.Value(), theTag );
456 Handle(HYDROData_Entity) HYDROData_Entity::GetReferenceObject( const int theTag,
457 const int theIndex ) const
459 Handle(HYDROData_Entity) aRes;
461 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
462 if ( aRefs.IsNull() || theIndex < 0 || theIndex >= aRefs->Extent() )
465 TDF_ListIteratorOfLabelList anIter( aRefs->List() );
466 for ( int anIndex = 0; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
468 const TDF_Label& aRefLabel = anIter.Value();
469 aRes = HYDROData_Iterator::Object( aRefLabel );
474 HYDROData_SequenceOfObjects HYDROData_Entity::GetReferenceObjects( const int theTag ) const
476 HYDROData_SequenceOfObjects aRes;
478 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
479 if ( aRefs.IsNull() )
482 TDF_ListIteratorOfLabelList anIter( aRefs->List() );
483 for ( ; anIter.More(); anIter.Next() )
485 const TDF_Label& aRefLabel = anIter.Value();
487 Handle(HYDROData_Entity) aRefObject = HYDROData_Iterator::Object( aRefLabel );
488 if ( aRefObject.IsNull() )
491 aRes.Append( aRefObject );
497 void HYDROData_Entity::RemoveReferenceObject( const TDF_Label& theRefLabel,
500 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
501 if ( aRefs.IsNull() )
504 if ( aRefs->Extent() == 1 )
506 // remove all if only one
507 ClearReferenceObjects( theTag );
511 aRefs->Remove( theRefLabel );
514 void HYDROData_Entity::RemoveReferenceObject( const int theTag,
517 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
518 if ( aRefs.IsNull() )
521 if ( aRefs->Extent() == 1 && theIndex == 0 )
523 // remove all if only one
524 ClearReferenceObjects( theTag );
529 TDF_ListIteratorOfLabelList anIter( aRefs->List() );
530 for ( ; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
532 if ( anIndex != theIndex || !anIter.More() )
535 const TDF_Label& aRefLabel = anIter.Value();
536 aRefs->Remove( aRefLabel );
539 void HYDROData_Entity::ClearReferenceObjects( const int theTag )
541 TDF_Label aSetLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
542 aSetLabel.ForgetAttribute( TDataStd_ReferenceList::GetID() );
545 Handle(TDataStd_ReferenceList) HYDROData_Entity::getReferenceList( const int theTag,
546 const bool theIsCreate ) const
548 TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
550 Handle(TDataStd_ReferenceList) aRefs;
551 if ( !aLabel.FindAttribute( TDataStd_ReferenceList::GetID(), aRefs ) && theIsCreate )
552 aRefs = TDataStd_ReferenceList::Set( aLabel );
557 void HYDROData_Entity::SetColor( const QColor& theColor,
560 TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
562 Handle(TDataStd_IntegerArray) aColorArray;
563 if ( !aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
564 aColorArray = TDataStd_IntegerArray::Set( aLabel, 1, 4 );
566 aColorArray->SetValue( 1, theColor.red() );
567 aColorArray->SetValue( 2, theColor.green() );
568 aColorArray->SetValue( 3, theColor.blue() );
569 aColorArray->SetValue( 4, theColor.alpha() );
572 QColor HYDROData_Entity::GetColor( const QColor& theDefColor,
573 const int theTag ) const
575 QColor aResColor = theDefColor;
577 TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
579 Handle(TDataStd_IntegerArray) aColorArray;
580 if ( aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
582 aResColor.setRed( aColorArray->Value( 1 ) );
583 aResColor.setGreen( aColorArray->Value( 2 ) );
584 aResColor.setBlue( aColorArray->Value( 3 ) );
585 aResColor.setAlpha( aColorArray->Value( 4 ) );
591 QStringList HYDROData_Entity::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const
593 QStringList aResList;
595 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
596 if ( aDocument.IsNull() )
599 QString aDocName = aDocument->GetDocPyName();
600 QString aName = GetObjPyName();
602 aResList << QString( "%1 = %2.CreateObject( %3 );" )
603 .arg( aName ).arg( aDocName ).arg( getPyTypeID() );
604 aResList << QString( "%1.SetName( \"%2\" );" )
605 .arg( aName ).arg( GetName() );
606 aResList << QString( "" );
610 // Dump object z-level in viewer
611 Standard_Integer anObjZLevel = -1;
612 if ( GetZLevel( anObjZLevel ) )
614 aResList << QString( "%1.SetZLevel( %2 );" )
615 .arg( aName ).arg( anObjZLevel );
616 aResList << QString( "" );
623 QString HYDROData_Entity::getPyTypeID() const
627 case KIND_IMAGE: return "KIND_IMAGE";
628 case KIND_POLYLINE: return "KIND_POLYLINE";
629 case KIND_BATHYMETRY: return "KIND_BATHYMETRY";
630 case KIND_ALTITUDE: return "KIND_ALTITUDE";
631 case KIND_IMMERSIBLE_ZONE: return "KIND_IMMERSIBLE_ZONE";
632 case KIND_RIVER: return "KIND_RIVER";
633 case KIND_STREAM: return "KIND_STREAM";
634 case KIND_CONFLUENCE: return "KIND_CONFLUENCE";
635 case KIND_CHANNEL: return "KIND_CHANNEL";
636 case KIND_OBSTACLE: return "KIND_OBSTACLE";
637 case KIND_DIGUE: return "KIND_DIGUE";
638 case KIND_PROFILE: return "KIND_PROFILE";
639 case KIND_PROFILEUZ: return "KIND_PROFILEUZ";
640 case KIND_POLYLINEXY: return "KIND_POLYLINEXY";
641 case KIND_CALCULATION: return "KIND_CALCULATION";
642 case KIND_ZONE: return "KIND_ZONE";
643 case KIND_REGION: return "KIND_REGION";
644 case KIND_VISUAL_STATE: return "KIND_VISUAL_STATE";
645 case KIND_ARTIFICIAL_OBJECT: return "KIND_ARTIFICIAL_OBJECT";
646 case KIND_NATURAL_OBJECT: return "KIND_NATURAL_OBJECT";
647 case KIND_DUMMY_3D: return "KIND_DUMMY_3D";
648 case KIND_SHAPES_GROUP: return "KIND_SHAPES_GROUP";
649 case KIND_SPLIT_GROUP: return "KIND_SPLIT_GROUP";
650 case KIND_STREAM_ALTITUDE: return "KIND_STREAM_ALTITUDE";
651 case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE";
652 case KIND_STRICKLER_TABLE: return "KIND_STRICKLER_TABLE";
653 case KIND_LAND_COVER_OBSOLETE: return "";
654 case KIND_LAND_COVER_MAP: return "KIND_LAND_COVER_MAP";
655 default: return "KIND_UNKNOWN"; ///! Unrecognized object
659 void HYDROData_Entity::setPythonReferenceObject( const QString& thePyScriptPath,
660 MapOfTreatedObjects& theTreatedObjects,
661 QStringList& theScript,
662 const Handle(HYDROData_Entity)& theRefObject,
663 const QString& theMethod ) const
665 if ( !checkObjectPythonDefinition( thePyScriptPath, theTreatedObjects, theScript, theRefObject ) )
668 QString aRefObjName = theRefObject->GetObjPyName();
670 QString anObjName = GetObjPyName();
671 theScript << QString( "%1.%2( %3 );" )
672 .arg( anObjName ).arg( theMethod ).arg( aRefObjName );
675 bool HYDROData_Entity::checkObjectPythonDefinition( const QString& thePyScriptPath,
676 MapOfTreatedObjects& theTreatedObjects,
677 QStringList& theScript,
678 const Handle(HYDROData_Entity)& theRefObject ) const
680 if ( theRefObject.IsNull() )
683 QString aRefObjName = theRefObject->GetName();
684 if ( aRefObjName.isEmpty() )
687 if ( theTreatedObjects.contains( aRefObjName ) )
690 // The definition of reference object must be dumped before this
691 QStringList aRefObjDump = theRefObject->DumpToPython( thePyScriptPath, theTreatedObjects );
692 if ( aRefObjDump.isEmpty() )
695 QStringList aTmpList = theScript;
696 theScript = aRefObjDump;
698 theScript << QString( "" );
699 theScript << aTmpList;
701 theTreatedObjects.insert( aRefObjName, theRefObject );
706 void HYDROData_Entity::setPythonObjectColor( QStringList& theScript,
707 const QColor& theColor,
708 const QColor& theDefaultColor,
709 const QString& theMethod ) const
711 if ( theColor == theDefaultColor )
712 return; //Do not set the color for object if it like default
714 QString anObjName = GetObjPyName();
715 theScript << QString( "%1.%2( QColor( %3, %4, %5, %6 ) );" )
716 .arg( anObjName ).arg( theMethod )
717 .arg( theColor.red() ).arg( theColor.green() )
718 .arg( theColor.blue() ).arg( theColor.alpha() );
721 void HYDROData_Entity::findPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
722 QStringList& theScript ) const
724 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
725 if ( aDocument.IsNull() )
728 theScript << QString( "%1 = %2.FindObjectByName( \"%3\" );" ).arg( GetObjPyName() )
729 .arg( aDocument->GetDocPyName() )
733 void HYDROData_Entity::SetShape( int theTag, const TopoDS_Shape& theShape )
735 TNaming_Builder aBuilder( myLab.FindChild( theTag ) );
736 aBuilder.Generated( theShape );
739 TopoDS_Shape HYDROData_Entity::GetShape( int theTag ) const
741 TDF_Label aShapeLabel = myLab.FindChild( theTag, false );
742 if ( !aShapeLabel.IsNull() )
744 Handle(TNaming_NamedShape) aNamedShape;
745 if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
746 return aNamedShape->Get();
748 return TopoDS_Shape();
751 void HYDROData_Entity::SetDouble( int theTag, double theValue )
753 Handle(TDataStd_Real) anAttr;
754 TDF_Label aLabel = myLab.FindChild( theTag );
755 if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
756 aLabel.AddAttribute( anAttr = new TDataStd_Real() );
757 anAttr->Set( theValue );
760 double HYDROData_Entity::GetDouble( int theTag, double theDefValue ) const
762 Handle(TDataStd_Real) anAttr;
763 TDF_Label aLabel = myLab.FindChild( theTag );
764 if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
767 return anAttr->Get();