1 #include <HYDROData_Iterator.h>
3 #include <HYDROData_Image.h>
4 #include <HYDROData_Polyline.h>
5 #include <HYDROData_VisualState.h>
6 #include <HYDROData_Bathymetry.h>
7 #include <HYDROData_Calculation.h>
8 #include <HYDROData_Zone.h>
10 #include <TDataStd_Name.hxx>
11 #include <NCollection_DataMap.hxx>
13 //! Returns label by root objects kind and the kind of the object
14 static TDF_Label GetLabelByKind(TDF_Label theRoot, ObjectKind theKind)
16 if (theKind == KIND_UNKNOWN) return theRoot;
17 return theRoot.FindChild(theKind);
20 HYDROData_Iterator::HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind)
21 : myIter(GetLabelByKind(theDoc->LabelOfObjects(), theKind),
22 TDataStd_Name::GetID(), theKind == KIND_UNKNOWN) // iterate all sub-objects for unknown kind
26 void HYDROData_Iterator::Next()
29 // omit the properties iteration in case of UNKNOWN kind filtering
30 while(myIter.More() && myIter.Value()->Label().Depth() != 4)
34 bool HYDROData_Iterator::More() const
39 Handle(HYDROData_Object) HYDROData_Iterator::Current()
41 return Object(myIter.Value()->Label());
44 Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
45 Handle(HYDROData_Document) theDoc, ObjectKind theKind)
47 TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
48 FindChild(theDoc->NewID());
49 // object exists if there is name attribute
50 TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
51 return Object(aNewLab);
54 Handle_HYDROData_Object HYDROData_Iterator::Object( const TDF_Label theLabel )
56 ObjectKind aKind = theLabel.Father().Tag();
58 Handle(HYDROData_Object) aResult;
62 aResult = new HYDROData_Image();
65 aResult = new HYDROData_Polyline();
67 case KIND_VISUAL_STATE:
68 aResult = new HYDROData_VisualState();
71 aResult = new HYDROData_Bathymetry();
73 case KIND_CALCULATION:
74 aResult = new HYDROData_Calculation();
77 aResult = new HYDROData_Zone();
81 if ( !aResult.IsNull() )
82 aResult->SetLabel( theLabel );