1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <StepData_FreeFormEntity.ixx>
15 #include <Dico_DictionaryOfTransient.hxx>
16 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
17 #include <Interface_Macros.hxx>
21 void StepData_FreeFormEntity::SetStepType (const Standard_CString typenam)
22 { thetype.Clear(); thetype.AssignCat (typenam); }
24 Standard_CString StepData_FreeFormEntity::StepType () const
25 { return thetype.ToCString(); }
27 void StepData_FreeFormEntity::SetNext
28 (const Handle(StepData_FreeFormEntity)& next, const Standard_Boolean last)
30 if (next.IsNull()) thenext.Nullify();
31 else if (thenext.IsNull()) thenext = next;
32 else if (last) thenext->SetNext(next);
34 next->SetNext(thenext,last);
39 Handle(StepData_FreeFormEntity) StepData_FreeFormEntity::Next () const
42 Standard_Boolean StepData_FreeFormEntity::IsComplex () const
43 { return (!thenext.IsNull()); }
45 Handle(StepData_FreeFormEntity) StepData_FreeFormEntity::Typed
46 (const Standard_CString typenam) const
48 Handle(StepData_FreeFormEntity) res;
49 if (thetype.IsEqual (typenam)) return this;
50 if (thenext.IsNull()) return res;
51 return thenext->Typed (typenam);
54 Handle(TColStd_HSequenceOfAsciiString) StepData_FreeFormEntity::TypeList
57 Handle(TColStd_HSequenceOfAsciiString) li = new TColStd_HSequenceOfAsciiString();
59 Handle(StepData_FreeFormEntity) next = thenext;
60 while (!next.IsNull()) {
61 li->Append (TCollection_AsciiString (next->StepType()) );
67 Standard_Boolean StepData_FreeFormEntity::Reorder
68 (Handle(StepData_FreeFormEntity)& ent)
70 if (ent.IsNull()) return Standard_False;
71 if (!ent->IsComplex()) return Standard_False;
72 Standard_Boolean afr = Standard_False;
73 Handle(StepData_FreeFormEntity) e1 = ent; Handle(StepData_FreeFormEntity) e2 = ent->Next();
74 while (!e2.IsNull()) {
75 if (strcmp (e1->StepType(), e2->StepType()) > 0) { afr = Standard_True; break; }
76 e1 = e2; e2 = e1->Next();
79 // remise en ordre avec un dictionnaire
80 e1 = ent; e2.Nullify();
81 Handle(Dico_DictionaryOfTransient) dic = new Dico_DictionaryOfTransient;
82 while (!e1.IsNull()) {
83 dic->SetItem (e1->StepType(), e1);
86 // d abord effacer les next en cours ...
87 Dico_IteratorOfDictionaryOfTransient iter(dic);
88 for (iter.Start(); iter.More(); iter.Next()) {
89 e1 = GetCasted(StepData_FreeFormEntity,iter.Value());
90 if (!e1.IsNull()) e1->SetNext(e2);
92 // ... puis les remettre dans l ordre
94 for (iter.Start(); iter.More(); iter.Next()) {
95 e2 = GetCasted(StepData_FreeFormEntity,iter.Value());
96 if (!e1.IsNull()) e1->SetNext(e2);
105 void StepData_FreeFormEntity::SetNbFields (const Standard_Integer nb)
107 if (nb <= 0) thefields.Nullify();
108 else thefields = new StepData_HArray1OfField (1,nb);
111 Standard_Integer StepData_FreeFormEntity::NbFields () const
112 { return (thefields.IsNull() ? 0 : thefields->Length()); }
114 const StepData_Field& StepData_FreeFormEntity::Field
115 (const Standard_Integer num) const
116 { return thefields->Value(num); }
118 StepData_Field& StepData_FreeFormEntity::CField
119 (const Standard_Integer num)
120 { return thefields->ChangeValue(num); }