0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / IGESData / IGESData_FreeFormatEntity.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
42cf5bc1 14
15#include <IGESData_FreeFormatEntity.hxx>
7fd59977 16#include <IGESData_IGESEntity.hxx>
42cf5bc1 17#include <IGESData_IGESWriter.hxx>
18#include <Interface_InterfaceError.hxx>
7fd59977 19#include <Interface_Macros.hxx>
42cf5bc1 20#include <Interface_UndefinedContent.hxx>
21#include <Standard_OutOfRange.hxx>
22#include <Standard_Type.hxx>
23#include <TCollection_HAsciiString.hxx>
7fd59977 24
92efcf78 25IMPLEMENT_STANDARD_RTTIEXT(IGESData_FreeFormatEntity,IGESData_UndefinedEntity)
26
7fd59977 27// Donne un acces simple a la constitution d une UndefinedEntity :
28// Methodes de UndefinedContent, + Type & Form, + AddEntities (little gadget)
b311480e 29IGESData_FreeFormatEntity::IGESData_FreeFormatEntity () { }
7fd59977 30
31 void IGESData_FreeFormatEntity::SetTypeNumber
32 (const Standard_Integer typenum)
33{ InitTypeAndForm (typenum,0); }
34
35 void IGESData_FreeFormatEntity::SetFormNumber
36 (const Standard_Integer formnum)
37{ InitTypeAndForm (TypeNumber(), formnum); }
38
39
40 Standard_Integer IGESData_FreeFormatEntity::NbParams () const
41{ return UndefinedContent()->NbParams(); }
42
43 Standard_Boolean IGESData_FreeFormatEntity::ParamData
44 (const Standard_Integer num, Interface_ParamType& ptype,
45 Handle(IGESData_IGESEntity)& ent, Handle(TCollection_HAsciiString)& val) const
aa00364d 46{
47 Handle(Standard_Transient) anEnt = ent;
48 return UndefinedContent()->ParamData (num, ptype, anEnt, val) &&
49 ! (ent = Handle(IGESData_IGESEntity)::DownCast (anEnt)).IsNull();
50}
7fd59977 51
52
53 Interface_ParamType IGESData_FreeFormatEntity::ParamType
54 (const Standard_Integer num) const
55{ return UndefinedContent()->ParamType(num); }
56
57 Standard_Boolean IGESData_FreeFormatEntity::IsParamEntity
58 (const Standard_Integer num) const
59{ return UndefinedContent()->IsParamEntity(num); }
60
61 Handle(IGESData_IGESEntity) IGESData_FreeFormatEntity::ParamEntity
62 (const Standard_Integer num) const
63{
64 return Handle(IGESData_IGESEntity)::DownCast
65 (UndefinedContent()->ParamEntity(num));
66}
67
68 Standard_Boolean IGESData_FreeFormatEntity::IsNegativePointer
69 (const Standard_Integer num) const
70{
71 if (thenegptrs.IsNull()) return Standard_False;
72 Standard_Integer nb = thenegptrs->Length();
73 for (Standard_Integer i = 1; i <= nb; i ++)
74 if (thenegptrs->Value(i) == num) return Standard_True;
75 return Standard_False;
76}
77
78 Handle(TCollection_HAsciiString) IGESData_FreeFormatEntity::ParamValue
79 (const Standard_Integer num) const
80{ return UndefinedContent()->ParamValue(num); }
81
82 Handle(TColStd_HSequenceOfInteger) IGESData_FreeFormatEntity::NegativePointers () const
83 { return thenegptrs; }
84
85
86 void IGESData_FreeFormatEntity::AddLiteral
87 (const Interface_ParamType ptype, const Handle(TCollection_HAsciiString)& val)
88{ UndefinedContent()->AddLiteral (ptype,val); }
89
90 void IGESData_FreeFormatEntity::AddLiteral
91 (const Interface_ParamType ptype, const Standard_CString val)
92{ UndefinedContent()->AddLiteral (ptype,new TCollection_HAsciiString(val)); }
93
94 void IGESData_FreeFormatEntity::AddEntity
95 (const Interface_ParamType ptype,
96 const Handle(IGESData_IGESEntity)& ent, const Standard_Boolean negative)
97{
98 UndefinedContent()->AddEntity (ptype,ent);
99 if (!negative) return;
100 if (thenegptrs.IsNull()) thenegptrs = new TColStd_HSequenceOfInteger();
101 thenegptrs->Append(NbParams());
102}
103
104 void IGESData_FreeFormatEntity::AddEntities
105 (const Handle(IGESData_HArray1OfIGESEntity)& ents)
106{
107 if (ents.IsNull()) {
108 AddLiteral ( Interface_ParamInteger, new TCollection_HAsciiString("0") );
109 return;
110 }
111 AddLiteral ( Interface_ParamInteger, new TCollection_HAsciiString(ents->Length()) );
112 Standard_Integer iup = ents->Upper();
113 for (Standard_Integer i = ents->Lower(); i <= iup; i ++) {
114 AddEntity (Interface_ParamIdent,ents->Value(i));
115 }
116}
117
118
119 void IGESData_FreeFormatEntity::AddNegativePointers
120 (const Handle(TColStd_HSequenceOfInteger)& list)
121{
122 if (thenegptrs.IsNull()) thenegptrs = new TColStd_HSequenceOfInteger();
123 thenegptrs->Append(list);
124}
125
126 void IGESData_FreeFormatEntity::ClearNegativePointers ()
127 { thenegptrs.Nullify(); }
128
129
130 void IGESData_FreeFormatEntity::WriteOwnParams
131 (IGESData_IGESWriter& IW) const
132{
133// Redefini de UndefinedEntity pour : NegativePointers
134 Standard_Integer neg = 0;
135 Standard_Integer fneg = 0;
136 if (!thenegptrs.IsNull())
137 if (!thenegptrs->IsEmpty()) { neg = thenegptrs->Value(1); fneg = 1; }
138
139 Standard_Integer nb = UndefinedContent()->NbParams();
140 for (Standard_Integer i = 1; i <= nb; i ++) {
141 Interface_ParamType ptyp = UndefinedContent()->ParamType(i);
142 if (ptyp == Interface_ParamVoid) IW.SendVoid();
143 else if (UndefinedContent()->IsParamEntity(i)) {
144 DeclareAndCast(IGESData_IGESEntity,anent,UndefinedContent()->ParamEntity(i));
145// Send Entity : Redefini
146 if (i == neg) {
147 IW.Send(anent,Standard_True);
148 if (fneg >= thenegptrs->Length()) neg = 0;
149 else { fneg ++; neg = thenegptrs->Value(fneg); }
150 }
151 else IW.Send(anent,Standard_False);
152 }
153 else IW.SendString (UndefinedContent()->ParamValue(i));
154 }
155}