1 #include <StepData_FreeFormEntity.ixx>
2 #include <Dico_DictionaryOfTransient.hxx>
3 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
4 #include <Interface_Macros.hxx>
8 void StepData_FreeFormEntity::SetStepType (const Standard_CString typenam)
9 { thetype.Clear(); thetype.AssignCat (typenam); }
11 Standard_CString StepData_FreeFormEntity::StepType () const
12 { return thetype.ToCString(); }
14 void StepData_FreeFormEntity::SetNext
15 (const Handle(StepData_FreeFormEntity)& next, const Standard_Boolean last)
17 if (next.IsNull()) thenext.Nullify();
18 else if (thenext.IsNull()) thenext = next;
19 else if (last) thenext->SetNext(next);
21 next->SetNext(thenext,last);
26 Handle(StepData_FreeFormEntity) StepData_FreeFormEntity::Next () const
29 Standard_Boolean StepData_FreeFormEntity::IsComplex () const
30 { return (!thenext.IsNull()); }
32 Handle(StepData_FreeFormEntity) StepData_FreeFormEntity::Typed
33 (const Standard_CString typenam) const
35 Handle(StepData_FreeFormEntity) res;
36 if (thetype.IsEqual (typenam)) return this;
37 if (thenext.IsNull()) return res;
38 return thenext->Typed (typenam);
41 Handle(TColStd_HSequenceOfAsciiString) StepData_FreeFormEntity::TypeList
44 Handle(TColStd_HSequenceOfAsciiString) li = new TColStd_HSequenceOfAsciiString();
46 Handle(StepData_FreeFormEntity) next = thenext;
47 while (!next.IsNull()) {
48 li->Append (TCollection_AsciiString (next->StepType()) );
54 Standard_Boolean StepData_FreeFormEntity::Reorder
55 (Handle(StepData_FreeFormEntity)& ent)
57 if (ent.IsNull()) return Standard_False;
58 if (!ent->IsComplex()) return Standard_False;
59 Standard_Boolean afr = Standard_False;
60 Handle(StepData_FreeFormEntity) e1 = ent; Handle(StepData_FreeFormEntity) e2 = ent->Next();
61 while (!e2.IsNull()) {
62 if (strcmp (e1->StepType(), e2->StepType()) > 0) { afr = Standard_True; break; }
63 e1 = e2; e2 = e1->Next();
66 // remise en ordre avec un dictionnaire
67 e1 = ent; e2.Nullify();
68 Handle(Dico_DictionaryOfTransient) dic = new Dico_DictionaryOfTransient;
69 while (!e1.IsNull()) {
70 dic->SetItem (e1->StepType(), e1);
73 // d abord effacer les next en cours ...
74 Dico_IteratorOfDictionaryOfTransient iter(dic);
75 for (iter.Start(); iter.More(); iter.Next()) {
76 e1 = GetCasted(StepData_FreeFormEntity,iter.Value());
77 if (!e1.IsNull()) e1->SetNext(e2);
79 // ... puis les remettre dans l ordre
81 for (iter.Start(); iter.More(); iter.Next()) {
82 e2 = GetCasted(StepData_FreeFormEntity,iter.Value());
83 if (!e1.IsNull()) e1->SetNext(e2);
92 void StepData_FreeFormEntity::SetNbFields (const Standard_Integer nb)
94 if (nb <= 0) thefields.Nullify();
95 else thefields = new StepData_HArray1OfField (1,nb);
98 Standard_Integer StepData_FreeFormEntity::NbFields () const
99 { return (thefields.IsNull() ? 0 : thefields->Length()); }
101 const StepData_Field& StepData_FreeFormEntity::Field
102 (const Standard_Integer num) const
103 { return thefields->Value(num); }
105 StepData_Field& StepData_FreeFormEntity::CField
106 (const Standard_Integer num)
107 { return thefields->ChangeValue(num); }