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>
8 #include <TDataStd_Name.hxx>
9 #include <NCollection_DataMap.hxx>
11 //! Returns label by root objects kind and the kind of the object
12 static TDF_Label GetLabelByKind(TDF_Label theRoot, ObjectKind theKind)
14 if (theKind == KIND_UNKNOWN) return theRoot;
15 return theRoot.FindChild(theKind);
18 HYDROData_Iterator::HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind)
19 : myIter(GetLabelByKind(theDoc->LabelOfObjects(), theKind),
20 TDataStd_Name::GetID(), theKind == KIND_UNKNOWN) // iterate all sub-objects for unknown kind
24 void HYDROData_Iterator::Next()
27 // omit the properties iteration in case of UNKNOWN kind filtering
28 while(myIter.More() && myIter.Value()->Label().Depth() != 4)
32 bool HYDROData_Iterator::More() const
37 Handle(HYDROData_Object) HYDROData_Iterator::Current()
39 return Object(myIter.Value()->Label());
42 Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
43 Handle(HYDROData_Document) theDoc, ObjectKind theKind)
45 TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
46 FindChild(theDoc->NewID());
47 // object exists if there is name attribute
48 TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
49 return Object(aNewLab);
52 Handle_HYDROData_Object HYDROData_Iterator::Object(const TDF_Label theLabel)
54 ObjectKind aKind = theLabel.Father().Tag();
55 Handle(HYDROData_Object) aResult;
58 aResult = new HYDROData_Image();
61 aResult = new HYDROData_Polyline();
63 case KIND_VISUAL_STATE:
64 aResult = new HYDROData_VisualState();
67 aResult = new HYDROData_Bathymetry();
70 if (!aResult.IsNull())
71 aResult->SetLabel(theLabel);