0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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>
42cf5bc1 28#include <Standard_Transient.hxx>
29#include <Standard_Type.hxx>
30#include <TCollection_HAsciiString.hxx>
31#include <TColStd_HArray1OfInteger.hxx>
32#include <TColStd_HArray1OfReal.hxx>
7fd59977 33
92efcf78 34IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_AttributeDef,IGESData_IGESEntity)
35
7fd59977 36// For each Attribute Value, according to Attribute Type :
37// 0 -> Void, 1 -> Integer, 2 -> Real, 3 -> String, 4 -> Entity 6 -> Logical
b311480e 38IGESDefs_AttributeDef::IGESDefs_AttributeDef () { }
7fd59977 39
40
41 void IGESDefs_AttributeDef::Init
42 (const Handle(TCollection_HAsciiString)& aName,
43 const Standard_Integer aListType,
44 const Handle(TColStd_HArray1OfInteger)& attrTypes,
45 const Handle(TColStd_HArray1OfInteger)& attrValueDataTypes,
46 const Handle(TColStd_HArray1OfInteger)& attrValueCounts,
47 const Handle(TColStd_HArray1OfTransient)& attrValues,
48 const Handle(IGESDefs_HArray1OfHArray1OfTextDisplayTemplate)&
49 attrValuePointers)
50{
51 Standard_Integer nb = attrTypes->Length();
52 if (attrTypes->Lower() != 1 || attrValueDataTypes->Lower() != 1 ||
53 attrValueDataTypes->Length() != nb ||
54 attrValueCounts->Lower() != 1 || attrValueCounts->Length() != nb)
9775fa61 55 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
7fd59977 56
57 if (FormNumber() >= 1)
58 if (attrValues->Lower() != 1 || attrValues->Length() != nb)
9775fa61 59 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
7fd59977 60
61 if (FormNumber() == 2)
62 if (attrValuePointers->Lower() != 1 || attrValuePointers->Length() != nb)
9775fa61 63 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
7fd59977 64// Form 1 : attrValues defined Form = 2 : attrValuePointers defined
65
66 theName = aName;
67 theListType = aListType;
68 theAttrTypes = attrTypes;
69 theAttrValueDataTypes = attrValueDataTypes;
70 theAttrValueCounts = attrValueCounts;
71 theAttrValues = attrValues;
72 theAttrValuePointers = attrValuePointers;
73 if (attrValues.IsNull()) InitTypeAndForm(322,0);
74 else if (attrValuePointers.IsNull()) InitTypeAndForm(322,1);
75 else InitTypeAndForm(322,2);
76}
77
78 Standard_Boolean IGESDefs_AttributeDef::HasTableName () const
79{
80 return (!theName.IsNull());
81}
82
83 Handle(TCollection_HAsciiString) IGESDefs_AttributeDef::TableName () const
84{
85 return theName;
86}
87
88 Standard_Integer IGESDefs_AttributeDef::ListType () const
89{
90 return theListType;
91}
92
93 Standard_Integer IGESDefs_AttributeDef::NbAttributes () const
94{
95 return theAttrTypes->Length();
96}
97
98 Standard_Integer IGESDefs_AttributeDef::AttributeType
99 (const Standard_Integer num) const
100{
101 return theAttrTypes->Value(num);
102}
103
104 Standard_Integer IGESDefs_AttributeDef::AttributeValueDataType
105 (const Standard_Integer num) const
106{
107 return theAttrValueDataTypes->Value(num);
108}
109
110 Standard_Integer IGESDefs_AttributeDef::AttributeValueCount
111 (const Standard_Integer num) const
112{
113 return theAttrValueCounts->Value(num);
114}
115
116 Standard_Boolean IGESDefs_AttributeDef::HasValues () const
117{
118 return (!theAttrValues.IsNull());
119}
120
121 Standard_Boolean IGESDefs_AttributeDef::HasTextDisplay () const
122{
123 return (!theAttrValuePointers.IsNull());
124}
125
126 Handle(IGESGraph_TextDisplayTemplate)
127 IGESDefs_AttributeDef::AttributeTextDisplay
128 (const Standard_Integer AttrNum, const Standard_Integer PointerNum) const
129{
130 Handle(IGESGraph_TextDisplayTemplate) res;
131 if (HasTextDisplay()) res =
132 theAttrValuePointers->Value(AttrNum)->Value(PointerNum);
133 return res;
134}
135
136 Handle(Standard_Transient) IGESDefs_AttributeDef::AttributeList
137 (const Standard_Integer AttrNum) const
138{
139 Handle(Standard_Transient) nulres;
140 if (!HasValues()) return nulres;
141 return theAttrValues->Value(AttrNum);
142}
143
144 Standard_Integer IGESDefs_AttributeDef::AttributeAsInteger
145 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
146{
147 return GetCasted(TColStd_HArray1OfInteger,theAttrValues->Value(AttrNum))
148 ->Value(ValueNum);
149}
150
151 Standard_Real IGESDefs_AttributeDef::AttributeAsReal
152 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
153{
154 return GetCasted(TColStd_HArray1OfReal,theAttrValues->Value(AttrNum))
155 ->Value(ValueNum);
156}
157
158 Handle(TCollection_HAsciiString) IGESDefs_AttributeDef::AttributeAsString
159 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
160{
161 return GetCasted(Interface_HArray1OfHAsciiString,theAttrValues->Value(AttrNum))
162 ->Value(ValueNum);
163}
164
165 Handle(IGESData_IGESEntity) IGESDefs_AttributeDef::AttributeAsEntity
166 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
167{
168 return GetCasted(IGESData_HArray1OfIGESEntity,theAttrValues->Value(AttrNum))
169 ->Value(ValueNum);
170}
171
172 Standard_Boolean IGESDefs_AttributeDef::AttributeAsLogical
173 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
174{
175 return (GetCasted(TColStd_HArray1OfInteger,theAttrValues->Value(AttrNum))
176 ->Value(ValueNum) != 0);
177}