1 // File: Model_Iterator.hxx
3 // Author: Mikhail PONIKAROV
5 #include "Model_Iterator.h"
6 #include "Model_Document.h"
7 #include "ModelAPI_Feature.h"
8 #include "Model_Object.h"
9 #include <TDataStd_Comment.hxx>
10 #include <TDataStd_Name.hxx>
14 void Model_Iterator::next()
19 bool Model_Iterator::more()
24 shared_ptr<ModelAPI_Feature> Model_Iterator::current()
26 TDF_Label aLab = myIter.Value()->Label();
27 return myDoc->feature(aLab);
30 string Model_Iterator::currentKind()
32 return string(TCollection_AsciiString(
33 Handle(TDataStd_Comment)::DownCast(myIter.Value())->Get()).ToCString());
36 string Model_Iterator::currentName()
38 TDF_Label aLab = myIter.Value()->Label();
39 Handle(TDataStd_Name) aName;
40 if (aLab.FindAttribute(TDataStd_Name::GetID(), aName))
41 return string(TCollection_AsciiString(aName->Get()).ToCString());
42 return ""; // name is not found
45 int Model_Iterator::numIterationsLeft()
48 TDF_ChildIDIterator aTempIter(myIter);
49 for(; aTempIter.More(); aTempIter.Next())
54 bool Model_Iterator::is(std::shared_ptr<ModelAPI_Feature> theFeature)
56 return myIter.Value()->Label() ==
57 dynamic_pointer_cast<Model_Object>(theFeature->data())->label();
62 Model_Iterator::Model_Iterator(std::shared_ptr<Model_Document> theDoc, TDF_Label theLab)
63 : myDoc(theDoc), myIter(theLab, TDataStd_Comment::GetID(), Standard_False)