1 #include <HYDROData_Iterator.h>
3 #include <HYDROData_Image.h>
4 #include <HYDROData_Polyline.h>
6 #include <TDataStd_Name.hxx>
7 #include <NCollection_DataMap.hxx>
9 //! Returns label by root objects kind and the kind of the object
10 static TDF_Label GetLabelByKind(TDF_Label theRoot, ObjectKind theKind)
12 if (theKind == KIND_UNKNOWN) return theRoot;
13 return theRoot.FindChild(theKind);
16 HYDROData_Iterator::HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind)
17 : myIter(GetLabelByKind(theDoc->LabelOfObjects(), theKind),
18 TDataStd_Name::GetID(), theKind == KIND_UNKNOWN) // iterate all sub-objects for unknown kind
22 void HYDROData_Iterator::Next()
25 // omit the properties iteration in case of UNKNOWN kind filtering
26 while(myIter.More() && myIter.Value()->Label().Depth() != 4)
30 bool HYDROData_Iterator::More() const
35 Handle(HYDROData_Object) HYDROData_Iterator::Current()
37 return Object(myIter.Value()->Label());
40 Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
41 Handle(HYDROData_Document) theDoc, ObjectKind theKind)
43 TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
44 FindChild(theDoc->NewID());
45 // object exists if there is name attribute
46 TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
47 return Object(aNewLab);
50 Handle_HYDROData_Object HYDROData_Iterator::Object(const TDF_Label theLabel)
52 ObjectKind aKind = theLabel.Father().Tag();
53 Handle(HYDROData_Object) aResult;
56 aResult = new HYDROData_Image();
59 aResult = new HYDROData_Polyline();
62 if (!aResult.IsNull())
63 aResult->SetLabel(theLabel);