1 #include <HYDROData_Iterator.h>
3 #include <HYDROData_Image.h>
4 #include <HYDROData_Polyline.h>
5 #include <HYDROData_VisualState.h>
7 #include <TDataStd_Name.hxx>
8 #include <NCollection_DataMap.hxx>
10 //! Returns label by root objects kind and the kind of the object
11 static TDF_Label GetLabelByKind(TDF_Label theRoot, ObjectKind theKind)
13 if (theKind == KIND_UNKNOWN) return theRoot;
14 return theRoot.FindChild(theKind);
17 HYDROData_Iterator::HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind)
18 : myIter(GetLabelByKind(theDoc->LabelOfObjects(), theKind),
19 TDataStd_Name::GetID(), theKind == KIND_UNKNOWN) // iterate all sub-objects for unknown kind
23 void HYDROData_Iterator::Next()
26 // omit the properties iteration in case of UNKNOWN kind filtering
27 while(myIter.More() && myIter.Value()->Label().Depth() != 4)
31 bool HYDROData_Iterator::More() const
36 Handle(HYDROData_Object) HYDROData_Iterator::Current()
38 return Object(myIter.Value()->Label());
41 Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
42 Handle(HYDROData_Document) theDoc, ObjectKind theKind)
44 TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
45 FindChild(theDoc->NewID());
46 // object exists if there is name attribute
47 TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
48 return Object(aNewLab);
51 Handle_HYDROData_Object HYDROData_Iterator::Object(const TDF_Label theLabel)
53 ObjectKind aKind = theLabel.Father().Tag();
54 Handle(HYDROData_Object) aResult;
57 aResult = new HYDROData_Image();
60 aResult = new HYDROData_Polyline();
62 case KIND_VISUAL_STATE:
63 aResult = new HYDROData_VisualState();
66 if (!aResult.IsNull())
67 aResult->SetLabel(theLabel);