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>
42 #include "HYDRO_trace.hxx"
44 HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects()
45 : NCollection_Sequence<Handle_HYDROData_Entity>()
49 HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects( const HYDROData_SequenceOfObjects& theSequence )
50 : NCollection_Sequence<Handle_HYDROData_Entity>( theSequence )
54 HYDROData_SequenceOfObjects::HYDROData_SequenceOfObjects( const NCollection_Sequence<Handle_HYDROData_Entity>& theSequence )
55 : NCollection_Sequence<Handle_HYDROData_Entity>( theSequence )
59 IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared)
60 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Entity,MMgt_TShared)
62 // is equal function for unique object mapping
63 bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2)
65 if ( !theObj1.IsNull() && !theObj2.IsNull() )
66 return theObj1->Label() == theObj2->Label();
70 QString HYDROData_Entity::GetName() const
72 Handle(TDataStd_Name) aName;
73 if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
74 TCollection_AsciiString aStr(aName->Get());
75 return QString(aStr.ToCString());
80 QString HYDROData_Entity::GetObjPyName() const
82 QString aName = GetName();
83 aName.replace(QRegExp("[\\W]"), "_");
88 void HYDROData_Entity::SetName(const QString& theName)
90 TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
93 QStringList HYDROData_Entity::DumpToPython( const QString& thePyScriptPath,
94 MapOfTreatedObjects& theTreatedObjects ) const
96 QStringList anEmptyList;
100 void HYDROData_Entity::Update()
105 void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy )
107 //On the base level no actions are necessary
110 bool HYDROData_Entity::IsHas2dPrs() const
115 void HYDROData_Entity::Show()
120 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
121 if ( aDocument.IsNull() )
124 aDocument->Show( this );
127 QVariant HYDROData_Entity::GetDataVariant()
132 void HYDROData_Entity::ClearChanged()
134 TDataStd_Integer::Set( myLab.FindChild( DataTag_GeomChange ), 0 );
137 int HYDROData_Entity::GetGeomChangeFlag() const
139 int aGeomChangeFlag = 0;
140 Handle(TDataStd_Integer) aGeomChangeAttr;
141 TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange );
142 aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr );
143 if ( !aGeomChangeAttr.IsNull() )
144 aGeomChangeFlag = aGeomChangeAttr->Get();
145 return aGeomChangeFlag;
148 void HYDROData_Entity::Changed( Geometry theChangedGeometry )
150 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
151 if( aDocument.IsNull() )
154 int aGeomChangeFlag = 0;
155 Handle(TDataStd_Integer) aGeomChangeAttr;
156 TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange );
157 aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr );
158 if ( !aGeomChangeAttr.IsNull() )
159 aGeomChangeFlag = aGeomChangeAttr->Get();
161 int aBitsToChange = ( myGeom & theChangedGeometry );
162 if( aBitsToChange == 0 )
165 aGeomChangeFlag = ( aGeomChangeFlag | aBitsToChange );
166 TDataStd_Integer::Set( aGeomChangeLab, aGeomChangeFlag );
168 HYDROData_Iterator anIter( aDocument );
169 for ( ; anIter.More(); anIter.Next() )
171 Handle(HYDROData_Entity) anObject = anIter.Current();
172 if( anObject.IsNull() )
174 HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects();
175 for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i )
177 Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i );
178 if( aRefObject->Label()==myLab )
179 anObject->Changed( theChangedGeometry );
184 bool HYDROData_Entity::IsMustBeUpdated( Geometry theGeom ) const
186 return ( ( GetGeomChangeFlag() & theGeom ) != 0 );
189 bool HYDROData_Entity::CanBeUpdated() const
194 bool HYDROData_Entity::IsRemoved() const
196 return !myLab.HasAttribute();
199 void HYDROData_Entity::Remove()
201 return myLab.ForgetAllAttributes( true );
204 bool HYDROData_Entity::CanRemove()
209 HYDROData_Entity::HYDROData_Entity( Geometry theGeom )
214 HYDROData_Entity::~HYDROData_Entity()
218 void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination,
219 bool isGenerateNewName ) const
221 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
222 if ( aDocument.IsNull() ) {
226 TDF_CopyLabel aCopy(myLab, theDestination->Label());
229 if( isGenerateNewName )
231 // generate a new unique name for the clone object:
232 // case 1: Image_1 -> Image_2
233 // case 2: ImageObj -> ImageObj_1
234 QString aName = theDestination->GetName();
235 QString aPrefix = aName;
236 if( aName.contains( '_' ) ) { // case 1
237 QString aSuffix = aName.section( '_', -1 );
238 bool anIsInteger = false;
239 aSuffix.toInt( &anIsInteger );
241 aPrefix = aName.section( '_', 0, -2 );
246 aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix );
247 theDestination->SetName( aName );
251 Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const
253 Handle(HYDROData_Entity) aFather;
255 if ( !myLab.IsNull() )
257 TDF_Label aFatherLabel = myLab.Father();
259 while ( aFather.IsNull() && !aFatherLabel.IsNull() && !aFatherLabel.IsRoot() )
261 aFather = HYDROData_Iterator::Object( aFatherLabel );
262 aFatherLabel = aFatherLabel.Father();
269 HYDROData_SequenceOfObjects HYDROData_Entity::GetAllReferenceObjects() const
271 return HYDROData_SequenceOfObjects();
274 Standard_Boolean HYDROData_Entity::GetZLevel( Standard_Integer& theLevel ) const
278 TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false );
279 if ( !aLabel.IsNull() )
281 Handle(TDataStd_Integer) anIntVal;
282 if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) )
284 theLevel = anIntVal->Get();
285 return Standard_True;
289 return Standard_False;
292 void HYDROData_Entity::SetZLevel( const Standard_Integer& theLevel )
294 TDataStd_Integer::Set( myLab.FindChild( DataTag_ZLevel ), theLevel );
297 void HYDROData_Entity::RemoveZLevel()
299 TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false );
300 if ( !aLabel.IsNull() )
301 aLabel.ForgetAllAttributes();
304 void HYDROData_Entity::SetLabel( const TDF_Label& theLabel )
309 void HYDROData_Entity::SaveByteArray( const int theTag,
313 TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
314 // array is empty, remove the attribute
316 aLab.ForgetAttribute(TDataStd_ByteArray::GetID());
319 // store data of image in byte array
320 Handle(TDataStd_ByteArray) aData;
321 if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData)) {
322 aData = TDataStd_ByteArray::Set(aLab, 1, theLen);
324 // copy bytes one by one
325 if (aData->Length() != theLen) {
326 Handle(TColStd_HArray1OfByte) aNewData = new TColStd_HArray1OfByte(1, theLen);
327 for(int a = 0; a < theLen; a++)
328 aNewData->SetValue(a + 1, theData[a]);
329 aData->ChangeArray(aNewData);
331 for(int a = 0; a < theLen; a++)
332 aData->SetValue(a + 1, theData[a]);
336 const char* HYDROData_Entity::ByteArray(const int theTag, int& theLen) const
338 TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
339 Handle(TDataStd_ByteArray) aData;
340 if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData))
341 return NULL; // return empty image if there is no array
342 theLen = aData->Length();
344 return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
348 int HYDROData_Entity::NbReferenceObjects( const int theTag ) const
350 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
351 return aRefs.IsNull() ? 0 : aRefs->Extent();
354 bool HYDROData_Entity::HasReference( const Handle_HYDROData_Entity& theObj,
355 const int theTag ) const
357 if ( theObj.IsNull() )
360 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
361 if ( aRefs.IsNull() || aRefs->IsEmpty() )
364 TDF_ListIteratorOfLabelList aListIt( aRefs->List() );
365 for ( ; aListIt.More(); aListIt.Next() )
367 const TDF_Label& aRefLabel = aListIt.Value();
368 if ( theObj->Label() == aRefLabel )
375 void HYDROData_Entity::AddReferenceObject( const Handle_HYDROData_Entity& theObj,
378 if ( theObj.IsNull() )
381 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
382 aRefs->Append( theObj->Label() );
385 void HYDROData_Entity::SetReferenceObject( const Handle_HYDROData_Entity& theObj,
389 if ( theObj.IsNull() )
391 RemoveReferenceObject( theTag, theIndex );
395 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
397 if ( theIndex >= aRefs->Extent() )
399 aRefs->Append( theObj->Label() );
401 else if ( theIndex < 0 )
403 aRefs->Prepend( theObj->Label() );
407 RemoveReferenceObject( theTag, theIndex );
409 Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theIndex );
411 aRefs = getReferenceList( theTag, true ); // because reference list can be removed
412 if ( !aBeforeObj.IsNull() )
413 aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
415 aRefs->Append( theObj->Label() );
419 void HYDROData_Entity::InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
421 const int theBeforeIndex )
423 if ( theObj.IsNull() )
426 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
428 if ( theBeforeIndex >= aRefs->Extent() )
430 aRefs->Append( theObj->Label() );
432 else if ( theBeforeIndex < 0 )
434 aRefs->Prepend( theObj->Label() );
438 Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theBeforeIndex );
439 if ( !aBeforeObj.IsNull() )
440 aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
442 aRefs->Append( theObj->Label() );
446 void HYDROData_Entity::SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
449 ClearReferenceObjects( theTag );
450 if ( theObjects.IsEmpty() )
453 HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
454 for ( ; anIter.More(); anIter.Next() )
455 AddReferenceObject( anIter.Value(), theTag );
458 Handle(HYDROData_Entity) HYDROData_Entity::GetReferenceObject( const int theTag,
459 const int theIndex ) const
461 Handle(HYDROData_Entity) aRes;
463 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
464 if ( aRefs.IsNull() || theIndex < 0 || theIndex >= aRefs->Extent() )
467 TDF_ListIteratorOfLabelList anIter( aRefs->List() );
468 for ( int anIndex = 0; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
470 const TDF_Label& aRefLabel = anIter.Value();
471 aRes = HYDROData_Iterator::Object( aRefLabel );
476 HYDROData_SequenceOfObjects HYDROData_Entity::GetReferenceObjects( const int theTag ) const
478 HYDROData_SequenceOfObjects aRes;
480 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
481 if ( aRefs.IsNull() )
484 TDF_ListIteratorOfLabelList anIter( aRefs->List() );
485 for ( ; anIter.More(); anIter.Next() )
487 const TDF_Label& aRefLabel = anIter.Value();
489 Handle(HYDROData_Entity) aRefObject = HYDROData_Iterator::Object( aRefLabel );
490 if ( aRefObject.IsNull() )
493 aRes.Append( aRefObject );
499 void HYDROData_Entity::RemoveReferenceObject( const TDF_Label& theRefLabel,
502 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
503 if ( aRefs.IsNull() )
506 if ( aRefs->Extent() == 1 )
508 // remove all if only one
509 ClearReferenceObjects( theTag );
513 aRefs->Remove( theRefLabel );
516 void HYDROData_Entity::RemoveReferenceObject( const int theTag,
519 Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
520 if ( aRefs.IsNull() )
523 if ( aRefs->Extent() == 1 && theIndex == 0 )
525 // remove all if only one
526 ClearReferenceObjects( theTag );
531 TDF_ListIteratorOfLabelList anIter( aRefs->List() );
532 for ( ; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
534 if ( anIndex != theIndex || !anIter.More() )
537 const TDF_Label& aRefLabel = anIter.Value();
538 aRefs->Remove( aRefLabel );
541 void HYDROData_Entity::ClearReferenceObjects( const int theTag )
543 TDF_Label aSetLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
544 aSetLabel.ForgetAttribute( TDataStd_ReferenceList::GetID() );
547 Handle(TDataStd_ReferenceList) HYDROData_Entity::getReferenceList( const int theTag,
548 const bool theIsCreate ) const
550 TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
552 Handle(TDataStd_ReferenceList) aRefs;
553 if ( !aLabel.FindAttribute( TDataStd_ReferenceList::GetID(), aRefs ) && theIsCreate )
554 aRefs = TDataStd_ReferenceList::Set( aLabel );
559 void HYDROData_Entity::SetColor( const QColor& theColor,
562 TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
564 Handle(TDataStd_IntegerArray) aColorArray;
565 if ( !aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
566 aColorArray = TDataStd_IntegerArray::Set( aLabel, 1, 4 );
568 aColorArray->SetValue( 1, theColor.red() );
569 aColorArray->SetValue( 2, theColor.green() );
570 aColorArray->SetValue( 3, theColor.blue() );
571 aColorArray->SetValue( 4, theColor.alpha() );
574 QColor HYDROData_Entity::GetColor( const QColor& theDefColor,
575 const int theTag ) const
577 QColor aResColor = theDefColor;
579 TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
581 Handle(TDataStd_IntegerArray) aColorArray;
582 if ( aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
584 aResColor.setRed( aColorArray->Value( 1 ) );
585 aResColor.setGreen( aColorArray->Value( 2 ) );
586 aResColor.setBlue( aColorArray->Value( 3 ) );
587 aResColor.setAlpha( aColorArray->Value( 4 ) );
593 QStringList HYDROData_Entity::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const
595 QStringList aResList;
597 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
598 if ( aDocument.IsNull() )
601 QString aDocName = aDocument->GetDocPyName();
602 QString aName = GetObjPyName();
604 aResList << QString( "%1 = %2.CreateObject( %3 )" )
605 .arg( aName ).arg( aDocName ).arg( getPyTypeID() );
606 aResList << QString( "%1.SetName( \"%2\" )" )
607 .arg( aName ).arg( GetName() );
608 aResList << QString( "" );
612 // Dump object z-level in viewer
613 Standard_Integer anObjZLevel = -1;
614 if ( GetZLevel( anObjZLevel ) )
616 aResList << QString( "%1.SetZLevel( %2 )" )
617 .arg( aName ).arg( anObjZLevel );
618 aResList << QString( "" );
625 QString HYDROData_Entity::getPyTypeID() const
627 DEBTRACE("HYDROData_Entity::getPyTypeID " << GetKind());
630 case KIND_IMAGE: return "KIND_IMAGE";
631 case KIND_POLYLINE: return "KIND_POLYLINE";
632 case KIND_BATHYMETRY: return "KIND_BATHYMETRY";
633 case KIND_ALTITUDE: return "KIND_ALTITUDE";
634 case KIND_IMMERSIBLE_ZONE: return "KIND_IMMERSIBLE_ZONE";
635 case KIND_RIVER: return "KIND_RIVER";
636 case KIND_STREAM: return "KIND_STREAM";
637 case KIND_CONFLUENCE: return "KIND_CONFLUENCE";
638 case KIND_CHANNEL: return "KIND_CHANNEL";
639 case KIND_OBSTACLE: return "KIND_OBSTACLE";
640 case KIND_DIGUE: return "KIND_DIGUE";
641 case KIND_PROFILE: return "KIND_PROFILE";
642 case KIND_PROFILEUZ: return "KIND_PROFILEUZ";
643 case KIND_POLYLINEXY: return "KIND_POLYLINEXY";
644 case KIND_CALCULATION: return "KIND_CALCULATION";
645 case KIND_ZONE: return "KIND_ZONE";
646 case KIND_REGION: return "KIND_REGION";
647 case KIND_VISUAL_STATE: return "KIND_VISUAL_STATE";
648 case KIND_ARTIFICIAL_OBJECT: return "KIND_ARTIFICIAL_OBJECT";
649 case KIND_NATURAL_OBJECT: return "KIND_NATURAL_OBJECT";
650 case KIND_DUMMY_3D: return "KIND_DUMMY_3D";
651 case KIND_SHAPES_GROUP: return "KIND_SHAPES_GROUP";
652 case KIND_SPLIT_GROUP: return "KIND_SPLIT_GROUP";
653 case KIND_STREAM_ALTITUDE: return "KIND_STREAM_ALTITUDE";
654 case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE";
655 case KIND_STRICKLER_TABLE: return "KIND_STRICKLER_TABLE";
656 case KIND_LAND_COVER_OBSOLETE: return "";
657 case KIND_CHANNEL_ALTITUDE: return "KIND_CHANNEL_ALTITUDE";
658 case KIND_LAND_COVER_MAP: return "KIND_LAND_COVER_MAP";
659 default: return "KIND_UNKNOWN"; ///! Unrecognized object
663 void HYDROData_Entity::setPythonReferenceObject( const QString& thePyScriptPath,
664 MapOfTreatedObjects& theTreatedObjects,
665 QStringList& theScript,
666 const Handle(HYDROData_Entity)& theRefObject,
667 const QString& theMethod ) const
669 if ( !checkObjectPythonDefinition( thePyScriptPath, theTreatedObjects, theScript, theRefObject ) )
672 QString aRefObjName = theRefObject->GetObjPyName();
674 QString anObjName = GetObjPyName();
675 theScript << QString( "%1.%2( %3 )" )
676 .arg( anObjName ).arg( theMethod ).arg( aRefObjName );
679 bool HYDROData_Entity::checkObjectPythonDefinition( const QString& thePyScriptPath,
680 MapOfTreatedObjects& theTreatedObjects,
681 QStringList& theScript,
682 const Handle(HYDROData_Entity)& theRefObject ) const
684 if ( theRefObject.IsNull() )
687 QString aRefObjName = theRefObject->GetName();
688 if ( aRefObjName.isEmpty() )
691 if ( theTreatedObjects.contains( aRefObjName ) )
694 // The definition of reference object must be dumped before this
695 QStringList aRefObjDump = theRefObject->DumpToPython( thePyScriptPath, theTreatedObjects );
696 if ( aRefObjDump.isEmpty() )
699 QStringList aTmpList = theScript;
700 theScript = aRefObjDump;
702 theScript << QString( "" );
703 theScript << aTmpList;
705 theTreatedObjects.insert( aRefObjName, theRefObject );
710 void HYDROData_Entity::setPythonObjectColor( QStringList& theScript,
711 const QColor& theColor,
712 const QColor& theDefaultColor,
713 const QString& theMethod ) const
715 if ( theColor == theDefaultColor )
716 return; //Do not set the color for object if it like default
718 QString anObjName = GetObjPyName();
719 theScript << QString( "%1.%2( QColor( %3, %4, %5, %6 ) )" )
720 .arg( anObjName ).arg( theMethod )
721 .arg( theColor.red() ).arg( theColor.green() )
722 .arg( theColor.blue() ).arg( theColor.alpha() );
725 void HYDROData_Entity::findPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
726 QStringList& theScript ) const
728 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
729 if ( aDocument.IsNull() )
732 theScript << QString( "%1 = %2.FindObjectByName( \"%3\" )" ).arg( GetObjPyName() )
733 .arg( aDocument->GetDocPyName() )
737 void HYDROData_Entity::SetShape( int theTag, const TopoDS_Shape& theShape )
739 TNaming_Builder aBuilder( myLab.FindChild( theTag ) );
740 aBuilder.Generated( theShape );
743 TopoDS_Shape HYDROData_Entity::GetShape( int theTag ) const
745 TDF_Label aShapeLabel = myLab.FindChild( theTag, false );
746 if ( !aShapeLabel.IsNull() )
748 Handle(TNaming_NamedShape) aNamedShape;
749 if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
750 return aNamedShape->Get();
752 return TopoDS_Shape();
755 void HYDROData_Entity::SetDouble( int theTag, double theValue )
757 Handle(TDataStd_Real) anAttr;
758 TDF_Label aLabel = myLab.FindChild( theTag );
759 if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
760 aLabel.AddAttribute( anAttr = new TDataStd_Real() );
761 anAttr->Set( theValue );
764 double HYDROData_Entity::GetDouble( int theTag, double theDefValue ) const
766 Handle(TDataStd_Real) anAttr;
767 TDF_Label aLabel = myLab.FindChild( theTag );
768 if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
771 return anAttr->Get();