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>
8 #include <HYDROData_Zone.h>
9 #include <HYDROData_Region.h>
11 #include <TDataStd_Name.hxx>
12 #include <NCollection_DataMap.hxx>
14 //! Returns label by root objects kind and the kind of the object
15 static TDF_Label GetLabelByKind(TDF_Label theRoot, ObjectKind theKind)
17 if (theKind == KIND_UNKNOWN) return theRoot;
18 return theRoot.FindChild(theKind);
21 HYDROData_Iterator::HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind)
22 : myIter(GetLabelByKind(theDoc->LabelOfObjects(), theKind),
23 TDataStd_Name::GetID(), theKind == KIND_UNKNOWN) // iterate all sub-objects for unknown kind
27 void HYDROData_Iterator::Next()
30 // omit the properties iteration in case of UNKNOWN kind filtering
31 while(myIter.More() && myIter.Value()->Label().Depth() != 4)
35 bool HYDROData_Iterator::More() const
40 Handle(HYDROData_Object) HYDROData_Iterator::Current()
42 return Object(myIter.Value()->Label());
45 Handle_HYDROData_Object HYDROData_Iterator::CreateObject(
46 Handle(HYDROData_Document) theDoc, ObjectKind theKind)
48 TDF_Label aNewLab = GetLabelByKind(theDoc->LabelOfObjects(), theKind).
49 FindChild(theDoc->NewID());
50 // object exists if there is name attribute
51 TDataStd_Name::Set(aNewLab, TCollection_ExtendedString(""));
52 return Object(aNewLab);
55 Handle_HYDROData_Object HYDROData_Iterator::Object( const TDF_Label theLabel )
57 ObjectKind aKind = theLabel.Father().Tag();
59 Handle(HYDROData_Object) aResult;
63 aResult = new HYDROData_Image();
66 aResult = new HYDROData_Polyline();
68 case KIND_VISUAL_STATE:
69 aResult = new HYDROData_VisualState();
72 aResult = new HYDROData_Bathymetry();
74 case KIND_CALCULATION:
75 aResult = new HYDROData_Calculation();
78 aResult = new HYDROData_Zone();
81 aResult = new HYDROData_Region();
85 if ( !aResult.IsNull() )
86 aResult->SetLabel( theLabel );