0026937: Eliminate NO_CXX_EXCEPTION macro support
[occt.git] / src / IGESDefs / IGESDefs_AttributeTable.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>
7fd59977 21#include <IGESDefs_AttributeDef.hxx>
42cf5bc1 22#include <IGESDefs_AttributeTable.hxx>
23#include <Interface_HArray1OfHAsciiString.hxx>
7fd59977 24#include <Interface_Macros.hxx>
42cf5bc1 25#include <Standard_DimensionMismatch.hxx>
26#include <Standard_NullObject.hxx>
27#include <Standard_OutOfRange.hxx>
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_AttributeTable,IGESData_IGESEntity)
35
7fd59977 36// ATTENTION ATTENTION : L Appellation "ROW" n est pas reconduite en l etat
37// Le Numero d Attribut est donne en 1er (donc, en colonne du HArray2 et non
38// en ligne), le numero de Colonne en 2e (donc, comme un numero de Ligne)
b311480e 39IGESDefs_AttributeTable::IGESDefs_AttributeTable () { }
7fd59977 40
41
42 void IGESDefs_AttributeTable::Init
43 (const Handle(TColStd_HArray2OfTransient)& attributes)
44{
45 if (attributes->LowerCol() != 1 || attributes->LowerRow() != 1)
9775fa61 46 throw Standard_DimensionMismatch("IGESDefs_AttributeTable : Init");
7fd59977 47 theAttributes = attributes;
48
49 Standard_Integer fn = FormNumber();
50 if (attributes->UpperCol() > 1) fn = 1;
51 else if (fn < 0 || fn > 1) fn = 0;
52 InitTypeAndForm(422,fn);
53// FormNumber : 0 SingleRow, 1 MultipleRows (can be reduced to one ...)
54}
55
56 void IGESDefs_AttributeTable::SetDefinition
57 (const Handle(IGESDefs_AttributeDef)& def)
58{
59 InitMisc (def,LabelDisplay(),LineWeightNumber());
60}
61
62 Handle(IGESDefs_AttributeDef) IGESDefs_AttributeTable::Definition () const
63{
64 return GetCasted(IGESDefs_AttributeDef,Structure());
65}
66
67
68 Standard_Integer IGESDefs_AttributeTable::NbRows () const
69{
70 return theAttributes->UpperCol();
71}
72
73 Standard_Integer IGESDefs_AttributeTable::NbAttributes () const
74{
75 return theAttributes->UpperRow();
76}
77
78 Standard_Integer IGESDefs_AttributeTable::DataType
79 (const Standard_Integer Atnum) const
80{
81 return Definition()->AttributeType(Atnum);
82}
83
84 Standard_Integer IGESDefs_AttributeTable::ValueCount
85 (const Standard_Integer Atnum) const
86{
87 return Definition()->AttributeValueCount(Atnum);
88}
89
90 Handle(Standard_Transient) IGESDefs_AttributeTable::AttributeList
91 (const Standard_Integer Atnum, const Standard_Integer Rownum) const
92{
93 return theAttributes->Value(Atnum,Rownum);
94}
95
96 Standard_Integer IGESDefs_AttributeTable::AttributeAsInteger
97 (const Standard_Integer Atnum, const Standard_Integer Rownum,
98 const Standard_Integer Valuenum) const
99{
100 return GetCasted(TColStd_HArray1OfInteger,theAttributes->Value(Atnum,Rownum))
101 ->Value(Valuenum);
102}
103
104 Standard_Real IGESDefs_AttributeTable::AttributeAsReal
105 (const Standard_Integer Atnum, const Standard_Integer Rownum,
106 const Standard_Integer Valuenum) const
107{
108 return GetCasted(TColStd_HArray1OfReal,theAttributes->Value(Atnum,Rownum))
109 ->Value(Valuenum);
110}
111
112 Handle(TCollection_HAsciiString) IGESDefs_AttributeTable::AttributeAsString
113 (const Standard_Integer Atnum, const Standard_Integer Rownum,
114 const Standard_Integer Valuenum) const
115{
116 return GetCasted(Interface_HArray1OfHAsciiString,theAttributes->Value(Atnum,Rownum))
117 ->Value(Valuenum);
118}
119
120 Handle(IGESData_IGESEntity) IGESDefs_AttributeTable::AttributeAsEntity
121 (const Standard_Integer Atnum, const Standard_Integer Rownum,
122 const Standard_Integer Valuenum) const
123{
124 return GetCasted(IGESData_HArray1OfIGESEntity,theAttributes->Value(Atnum,Rownum))
125 ->Value(Valuenum);
126}
127
128 Standard_Boolean IGESDefs_AttributeTable::AttributeAsLogical
129 (const Standard_Integer Atnum, const Standard_Integer Rownum,
130 const Standard_Integer Valuenum) const
131{
132 return (AttributeAsInteger(Atnum,Rownum,Valuenum) != 0); // raccourci
133}