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>
9 #include <TDataStd_Name.hxx>
10 #include <NCollection_DataMap.hxx>
12 //! Returns label by root objects kind and the kind of the object
13 static TDF_Label GetLabelByKind(TDF_Label theRoot, ObjectKind theKind)
15 if (theKind == KIND_UNKNOWN) return theRoot;
16 return theRoot.FindChild(theKind);
19 HYDROData_Iterator::HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind)
20 : myIter(GetLabelByKind(theDoc->LabelOfObjects(), theKind),
21 TDataStd_Name::GetID(), theKind == KIND_UNKNOWN) // iterate all sub-objects for unknown kind
25 void HYDROData_Iterator::Next()
28 // omit the properties iteration in case of UNKNOWN kind filtering
29 while(myIter.More() && myIter.Value()->Label().Depth() != 4)
33 bool HYDROData_Iterator::More() const
38 Handle(HYDROData_Object) HYDROData_Iterator::Current()
40 return Object(myIter.Value()->Label());
43 Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
44 Handle(HYDROData_Document) theDoc, ObjectKind theKind)
46 TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
47 FindChild(theDoc->NewID());
48 // object exists if there is name attribute
49 TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
50 return Object(aNewLab);
53 Handle_HYDROData_Object HYDROData_Iterator::Object( const TDF_Label theLabel )
55 ObjectKind aKind = theLabel.Father().Tag();
57 Handle(HYDROData_Object) aResult;
61 aResult = new HYDROData_Image();
64 aResult = new HYDROData_Polyline();
66 case KIND_VISUAL_STATE:
67 aResult = new HYDROData_VisualState();
70 aResult = new HYDROData_Bathymetry();
72 case KIND_CALCULATION:
73 aResult = new HYDROData_Calculation();
77 if ( !aResult.IsNull() )
78 aResult->SetLabel( theLabel );