1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <IGESData_HArray1OfIGESEntity.hxx>
20 #include <IGESData_IGESEntity.hxx>
21 #include <IGESDefs_AttributeDef.hxx>
22 #include <IGESDefs_HArray1OfHArray1OfTextDisplayTemplate.hxx>
23 #include <IGESGraph_HArray1OfTextDisplayTemplate.hxx>
24 #include <IGESGraph_TextDisplayTemplate.hxx>
25 #include <Interface_HArray1OfHAsciiString.hxx>
26 #include <Interface_Macros.hxx>
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>
36 IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_AttributeDef,IGESData_IGESEntity)
38 // For each Attribute Value, according to Attribute Type :
39 // 0 -> Void, 1 -> Integer, 2 -> Real, 3 -> String, 4 -> Entity 6 -> Logical
40 IGESDefs_AttributeDef::IGESDefs_AttributeDef () { }
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)&
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)
57 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
59 if (FormNumber() >= 1)
60 if (attrValues->Lower() != 1 || attrValues->Length() != nb)
61 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
63 if (FormNumber() == 2)
64 if (attrValuePointers->Lower() != 1 || attrValuePointers->Length() != nb)
65 throw Standard_DimensionMismatch("IGESDefs_AttributeDef : Init");
66 // Form 1 : attrValues defined Form = 2 : attrValuePointers defined
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);
80 Standard_Boolean IGESDefs_AttributeDef::HasTableName () const
82 return (!theName.IsNull());
85 Handle(TCollection_HAsciiString) IGESDefs_AttributeDef::TableName () const
90 Standard_Integer IGESDefs_AttributeDef::ListType () const
95 Standard_Integer IGESDefs_AttributeDef::NbAttributes () const
97 return theAttrTypes->Length();
100 Standard_Integer IGESDefs_AttributeDef::AttributeType
101 (const Standard_Integer num) const
103 return theAttrTypes->Value(num);
106 Standard_Integer IGESDefs_AttributeDef::AttributeValueDataType
107 (const Standard_Integer num) const
109 return theAttrValueDataTypes->Value(num);
112 Standard_Integer IGESDefs_AttributeDef::AttributeValueCount
113 (const Standard_Integer num) const
115 return theAttrValueCounts->Value(num);
118 Standard_Boolean IGESDefs_AttributeDef::HasValues () const
120 return (!theAttrValues.IsNull());
123 Standard_Boolean IGESDefs_AttributeDef::HasTextDisplay () const
125 return (!theAttrValuePointers.IsNull());
128 Handle(IGESGraph_TextDisplayTemplate)
129 IGESDefs_AttributeDef::AttributeTextDisplay
130 (const Standard_Integer AttrNum, const Standard_Integer PointerNum) const
132 Handle(IGESGraph_TextDisplayTemplate) res;
133 if (HasTextDisplay()) res =
134 theAttrValuePointers->Value(AttrNum)->Value(PointerNum);
138 Handle(Standard_Transient) IGESDefs_AttributeDef::AttributeList
139 (const Standard_Integer AttrNum) const
141 Handle(Standard_Transient) nulres;
142 if (!HasValues()) return nulres;
143 return theAttrValues->Value(AttrNum);
146 Standard_Integer IGESDefs_AttributeDef::AttributeAsInteger
147 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
149 return GetCasted(TColStd_HArray1OfInteger,theAttrValues->Value(AttrNum))
153 Standard_Real IGESDefs_AttributeDef::AttributeAsReal
154 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
156 return GetCasted(TColStd_HArray1OfReal,theAttrValues->Value(AttrNum))
160 Handle(TCollection_HAsciiString) IGESDefs_AttributeDef::AttributeAsString
161 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
163 return GetCasted(Interface_HArray1OfHAsciiString,theAttrValues->Value(AttrNum))
167 Handle(IGESData_IGESEntity) IGESDefs_AttributeDef::AttributeAsEntity
168 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
170 return GetCasted(IGESData_HArray1OfIGESEntity,theAttrValues->Value(AttrNum))
174 Standard_Boolean IGESDefs_AttributeDef::AttributeAsLogical
175 (const Standard_Integer AttrNum, const Standard_Integer ValueNum) const
177 return (GetCasted(TColStd_HArray1OfInteger,theAttrValues->Value(AttrNum))
178 ->Value(ValueNum) != 0);