0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IGESDefs / IGESDefs_AttributeDef.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
7fd59977 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
7fd59977 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//--------------------------------------------------------------------
7fd59977 17//--------------------------------------------------------------------
18
7fd59977 19#include <IGESData_HArray1OfIGESEntity.hxx>
42cf5bc1 20#include <IGESData_IGESEntity.hxx>
21#include <IGESDefs_AttributeDef.hxx>
22#include <IGESDefs_HArray1OfHArray1OfTextDisplayTemplate.hxx>
7fd59977 23#include <IGESGraph_HArray1OfTextDisplayTemplate.hxx>
42cf5bc1 24#include <IGESGraph_TextDisplayTemplate.hxx>
7fd59977 25#include <Interface_HArray1OfHAsciiString.hxx>
26#include <Interface_Macros.hxx>
42cf5bc1 27#include <Standard_DimensionMismatch.hxx>
28#include <Standard_NullObject.hxx>
29#include <Standard_OutOfRange.hxx>
30#include <Standard_Transient.hxx>
31#include <Standard_Type.hxx>
32#include <TCollection_HAsciiString.hxx>
33#include <TColStd_HArray1OfInteger.hxx>
34#include <TColStd_HArray1OfReal.hxx>
7fd59977 35
92efcf78 36IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_AttributeDef,IGESData_IGESEntity)
37
7fd59977 38// For each Attribute Value, according to Attribute Type :
39// 0 -> Void, 1 -> Integer, 2 -> Real, 3 -> String, 4 -> Entity 6 -> Logical
b311480e 40IGESDefs_AttributeDef::IGESDefs_AttributeDef () { }
7fd59977 41
42
43 void IGESDefs_AttributeDef::Init
44 (const Handle(TCollection_HAsciiString)& aName,
45 const Standard_Integer aListType,
46 const Handle(TColStd_HArray1OfInteger)& attrTypes,
47 const Handle(TColStd_HArray1OfInteger)& attrValueDataTypes,
48 const Handle(TColStd_HArray1OfInteger)& attrValueCounts,
49 const Handle(TColStd_HArray1OfTransient)& attrValues,
50 const Handle(IGESDefs_HArray1OfHArray1OfTextDisplayTemplate)&
51 attrValuePointers)
52{
53 Standard_Integer nb = attrTypes->Length();
54 if (attrTypes->Lower() != 1 || attrValueDataTypes->Lower() != 1 ||
55 attrValueDataTypes->Length() != nb ||
56 attrValueCounts->Lower() != 1 || attrValueCounts->Length() != nb)
9775fa61 57 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
7fd59977 58
59 if (FormNumber() >= 1)
60 if (attrValues->Lower() != 1 || attrValues->Length() != nb)
9775fa61 61 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
7fd59977 62
63 if (FormNumber() == 2)
64 if (attrValuePointers->Lower() != 1 || attrValuePointers->Length() != nb)
9775fa61 65 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
7fd59977 66// Form 1 : attrValues defined Form = 2 : attrValuePointers defined
67
68 theName = aName;
69 theListType = aListType;
70 theAttrTypes = attrTypes;
71 theAttrValueDataTypes = attrValueDataTypes;
72 theAttrValueCounts = attrValueCounts;
73 theAttrValues = attrValues;
74 theAttrValuePointers = attrValuePointers;
75 if (attrValues.IsNull()) InitTypeAndForm(322,0);
76 else if (attrValuePointers.IsNull()) InitTypeAndForm(322,1);
77 else InitTypeAndForm(322,2);
78}
79
80 Standard_Boolean IGESDefs_AttributeDef::HasTableName () const
81{
82 return (!theName.IsNull());
83}
84
85 Handle(TCollection_HAsciiString) IGESDefs_AttributeDef::TableName () const
86{
87 return theName;
88}
89
90 Standard_Integer IGESDefs_AttributeDef::ListType () const
91{
92 return theListType;
93}
94
95 Standard_Integer IGESDefs_AttributeDef::NbAttributes () const
96{
97 return theAttrTypes->Length();
98}
99
100 Standard_Integer IGESDefs_AttributeDef::AttributeType
101 (const Standard_Integer num) const
102{
103 return theAttrTypes->Value(num);
104}
105
106 Standard_Integer IGESDefs_AttributeDef::AttributeValueDataType
107 (const Standard_Integer num) const
108{
109 return theAttrValueDataTypes->Value(num);
110}
111
112 Standard_Integer IGESDefs_AttributeDef::AttributeValueCount
113 (const Standard_Integer num) const
114{
115 return theAttrValueCounts->Value(num);
116}
117
118 Standard_Boolean IGESDefs_AttributeDef::HasValues () const
119{
120 return (!theAttrValues.IsNull());
121}
122
123 Standard_Boolean IGESDefs_AttributeDef::HasTextDisplay () const
124{
125 return (!theAttrValuePointers.IsNull());
126}
127
128 Handle(IGESGraph_TextDisplayTemplate)
129 IGESDefs_AttributeDef::AttributeTextDisplay
130 (const Standard_Integer AttrNum, const Standard_Integer PointerNum) const
131{
132 Handle(IGESGraph_TextDisplayTemplate) res;
133 if (HasTextDisplay()) res =
134 theAttrValuePointers->Value(AttrNum)->Value(PointerNum);
135 return res;
136}
137
138 Handle(Standard_Transient) IGESDefs_AttributeDef::AttributeList
139 (const Standard_Integer AttrNum) const
140{
141 Handle(Standard_Transient) nulres;
142 if (!HasValues()) return nulres;
143 return theAttrValues->Value(AttrNum);
144}
145
146 Standard_Integer IGESDefs_AttributeDef::AttributeAsInteger
147 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
148{
149 return GetCasted(TColStd_HArray1OfInteger,theAttrValues->Value(AttrNum))
150 ->Value(ValueNum);
151}
152
153 Standard_Real IGESDefs_AttributeDef::AttributeAsReal
154 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
155{
156 return GetCasted(TColStd_HArray1OfReal,theAttrValues->Value(AttrNum))
157 ->Value(ValueNum);
158}
159
160 Handle(TCollection_HAsciiString) IGESDefs_AttributeDef::AttributeAsString
161 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
162{
163 return GetCasted(Interface_HArray1OfHAsciiString,theAttrValues->Value(AttrNum))
164 ->Value(ValueNum);
165}
166
167 Handle(IGESData_IGESEntity) IGESDefs_AttributeDef::AttributeAsEntity
168 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
169{
170 return GetCasted(IGESData_HArray1OfIGESEntity,theAttrValues->Value(AttrNum))
171 ->Value(ValueNum);
172}
173
174 Standard_Boolean IGESDefs_AttributeDef::AttributeAsLogical
175 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
176{
177 return (GetCasted(TColStd_HArray1OfInteger,theAttrValues->Value(AttrNum))
178 ->Value(ValueNum) != 0);
179}