1 #include <HYDROData_Iterator.h>
3 #include <HYDROData_Image.h>
5 #include <TDataStd_Name.hxx>
6 #include <NCollection_DataMap.hxx>
8 //! Returns label by root objects kind and the kind of the object
9 static TDF_Label GetLabelByKind(TDF_Label theRoot, ObjectKind theKind)
11 if (theKind == KIND_UNKNOWN) return theRoot;
12 return theRoot.FindChild(theKind);
15 HYDROData_Iterator::HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind)
16 : myIter(GetLabelByKind(theDoc->LabelOfObjects(), theKind),
17 TDataStd_Name::GetID(), theKind == KIND_UNKNOWN) // iterate all sub-objects for unknown kind
21 void HYDROData_Iterator::Next()
24 // omit the properties iteration in case of UNKNOWN kind filtering
25 while(myIter.More() && myIter.Value()->Label().Depth() != 4)
29 bool HYDROData_Iterator::More() const
34 Handle(HYDROData_Object) HYDROData_Iterator::Current()
36 return Object(myIter.Value()->Label());
39 Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
40 Handle(HYDROData_Document) theDoc, ObjectKind theKind)
42 TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
43 FindChild(theDoc->NewID());
44 // object exists if there is name attribute
45 TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
46 return Object(aNewLab);
49 Handle_HYDROData_Object HYDROData_Iterator::Object(const TDF_Label theLabel)
51 ObjectKind aKind = theLabel.Father().Tag();
52 Handle(HYDROData_Object) aResult;
55 aResult = new HYDROData_Image();
58 if (!aResult.IsNull())
59 aResult->SetLabel(theLabel);