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