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 | |
19 | // rln 11.05.2000 BUC60660 |
20 | |
21 | #include <IGESDefs_GenericData.ixx> |
22 | #include <TColStd_HArray1OfReal.hxx> |
23 | #include <IGESData_HArray1OfIGESEntity.hxx> |
24 | #include <Interface_HArray1OfHAsciiString.hxx> |
25 | #include <Interface_Macros.hxx> |
26 | |
27 | |
b311480e |
28 | IGESDefs_GenericData::IGESDefs_GenericData () { } |
7fd59977 |
29 | |
30 | |
31 | void IGESDefs_GenericData::Init |
32 | (const Standard_Integer nbPropVal, |
33 | const Handle(TCollection_HAsciiString)& aName, |
34 | const Handle(TColStd_HArray1OfInteger)& allTypes, |
35 | const Handle(TColStd_HArray1OfTransient)& allValues) |
36 | { |
37 | // rln May 11, 2000 BUC60660 |
38 | // Number of TYPE/VALUE pairs is 0 and arrays are null handles, |
39 | // this caused exception |
40 | if ( !allTypes.IsNull() && !allValues.IsNull() && |
41 | (allValues->Lower() != 1 || allTypes->Lower() != 1 || |
42 | allTypes->Length() != allValues->Length() ) ) |
43 | Standard_DimensionMismatch::Raise("IGESDefs_GenericData: Init"); |
44 | theNbPropertyValues = nbPropVal; |
45 | theName = aName; |
46 | theTypes = allTypes; |
47 | theValues = allValues; |
48 | InitTypeAndForm(406,27); |
49 | } |
50 | |
51 | Standard_Integer IGESDefs_GenericData::NbPropertyValues () const |
52 | { |
53 | // return 2 * theTypes->Length() + 2; |
54 | return theNbPropertyValues; |
55 | } |
56 | |
57 | Handle(TCollection_HAsciiString) IGESDefs_GenericData::Name () const |
58 | { |
59 | return theName; |
60 | } |
61 | |
62 | Standard_Integer IGESDefs_GenericData::NbTypeValuePairs () const |
63 | { |
64 | return theTypes->Length(); |
65 | } |
66 | |
67 | Standard_Integer IGESDefs_GenericData::Type (const Standard_Integer Index) const |
68 | { |
69 | return theTypes->Value(Index); |
70 | } |
71 | |
72 | Handle(Standard_Transient) IGESDefs_GenericData::Value |
73 | (const Standard_Integer Index) const |
74 | { |
75 | return theValues->Value(Index); |
76 | } |
77 | |
78 | Standard_Integer IGESDefs_GenericData::ValueAsInteger |
79 | (const Standard_Integer Index) const |
80 | { |
81 | return GetCasted(TColStd_HArray1OfInteger,theValues->Value(Index))->Value(1); |
82 | } |
83 | |
84 | Standard_Real IGESDefs_GenericData::ValueAsReal |
85 | (const Standard_Integer Index) const |
86 | { |
87 | return GetCasted(TColStd_HArray1OfReal,theValues->Value(Index))->Value(1); |
88 | } |
89 | |
90 | Handle(TCollection_HAsciiString) IGESDefs_GenericData::ValueAsString |
91 | (const Standard_Integer Index) const |
92 | { |
93 | return GetCasted(TCollection_HAsciiString,theValues->Value(Index)); |
94 | } |
95 | |
96 | Handle(IGESData_IGESEntity) IGESDefs_GenericData::ValueAsEntity |
97 | (const Standard_Integer Index) const |
98 | { |
99 | return GetCasted(IGESData_IGESEntity,theValues->Value(Index)); |
100 | } |
101 | |
102 | Standard_Boolean IGESDefs_GenericData::ValueAsLogical |
103 | (const Standard_Integer Index) const |
104 | { |
105 | return (GetCasted(TColStd_HArray1OfInteger,theValues->Value(Index))->Value(1) |
106 | != 0); |
107 | } |