1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15 
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18 // UNFINISHED
19 // The last field (theDependentValues) not resolved. Queried to mdtv
20 
21 #include <IGESBasic_HArray1OfHArray1OfReal.hxx>
22 #include <IGESDefs_TabularData.hxx>
23 #include <Standard_DimensionMismatch.hxx>
24 #include <Standard_OutOfRange.hxx>
25 #include <Standard_Type.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
27 
IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_TabularData,IGESData_IGESEntity)28 IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_TabularData,IGESData_IGESEntity)
29 
30 IGESDefs_TabularData::IGESDefs_TabularData ()    {  }
31 
32 
Init(const Standard_Integer nbProps,const Standard_Integer propType,const Handle (TColStd_HArray1OfInteger)& typesInd,const Handle (TColStd_HArray1OfInteger)& nbValuesInd,const Handle (IGESBasic_HArray1OfHArray1OfReal)& valuesInd,const Handle (IGESBasic_HArray1OfHArray1OfReal)& valuesDep)33     void IGESDefs_TabularData::Init
34   (const Standard_Integer nbProps,
35    const Standard_Integer propType,
36 /*     const Standard_Integer nbDeps, */
37 /*     const Standard_Integer nbIndeps, */
38    const Handle(TColStd_HArray1OfInteger)& typesInd,
39    const Handle(TColStd_HArray1OfInteger)& nbValuesInd,
40    const Handle(IGESBasic_HArray1OfHArray1OfReal)& valuesInd,
41    const Handle(IGESBasic_HArray1OfHArray1OfReal)& valuesDep)
42 {
43   Standard_Integer num = typesInd->Length();
44   if (typesInd->Lower() != 1 ||
45       nbValuesInd->Lower() != 1 || nbValuesInd->Length() != num ||
46       valuesInd->Lower()   != 1 || valuesInd->Length()   != num ||
47       valuesDep->Lower()   != 1 )
48     throw Standard_DimensionMismatch("IGESDefs_TabularData : Init");
49   theNbPropertyValues = nbProps;
50   thePropertyType               = propType;
51 /*     theNbDependents = nbDeps; */
52 /*     theNbIndependents = nbIndeps; */
53   theTypeOfIndependentVariables = typesInd;
54   theNbValues                   = nbValuesInd;
55   theIndependentValues          = valuesInd;
56   theDependentValues            = valuesDep;
57   InitTypeAndForm(406,11);
58 }
59 
NbPropertyValues() const60     Standard_Integer IGESDefs_TabularData::NbPropertyValues () const
61 {
62   return theNbPropertyValues;
63 }
64 
ComputedNbPropertyValues() const65     Standard_Integer IGESDefs_TabularData::ComputedNbPropertyValues () const
66 {
67   return theNbPropertyValues;  // pas malin ... a ameliorer
68 }
69 
OwnCorrect()70     Standard_Boolean IGESDefs_TabularData::OwnCorrect ()
71 {
72   Standard_Integer newnb = ComputedNbPropertyValues();
73   if (newnb == theNbPropertyValues) return Standard_False;
74   theNbPropertyValues = newnb;
75   return Standard_True;
76 }
77 
78 
PropertyType() const79     Standard_Integer IGESDefs_TabularData::PropertyType () const
80 {
81   return thePropertyType;
82 }
83 
NbDependents() const84     Standard_Integer IGESDefs_TabularData::NbDependents () const
85 {
86   return theDependentValues->Length();
87 }
88 
NbIndependents() const89     Standard_Integer IGESDefs_TabularData::NbIndependents () const
90 {
91   return theTypeOfIndependentVariables->Length();
92 }
93 
TypeOfIndependents(const Standard_Integer num) const94     Standard_Integer IGESDefs_TabularData::TypeOfIndependents
95   (const Standard_Integer num) const
96 {
97   return theTypeOfIndependentVariables->Value(num);
98 }
99 
NbValues(const Standard_Integer num) const100     Standard_Integer IGESDefs_TabularData::NbValues (const Standard_Integer num) const
101 {
102   return theNbValues->Value(num);
103 }
104 
IndependentValue(const Standard_Integer variablenum,const Standard_Integer valuenum) const105     Standard_Real IGESDefs_TabularData::IndependentValue
106   (const Standard_Integer variablenum, const Standard_Integer valuenum) const
107 {
108   return (theIndependentValues->Value(variablenum))->Value(valuenum);
109 }
110 
Handle(TColStd_HArray1OfReal)111     Handle(TColStd_HArray1OfReal)  IGESDefs_TabularData::DependentValues
112   (const Standard_Integer num) const
113 {
114   return theDependentValues->Value(num);
115 }
116 
117 // UNFINISHED
118 // Array limits not sure.
DependentValue(const Standard_Integer,const Standard_Integer) const119 Standard_Real IGESDefs_TabularData::DependentValue (const Standard_Integer /*variablenum*/,
120                                                     const Standard_Integer /*valuenum*/) const
121 {
122   Standard_Real val = 0.;
123 #if 0
124   Standard_Integer sum = 0;
125   for (Standard_Integer i = 1; i < variablenum; i++)
126     {
127       sum += theNbValues->Value(i);
128     }
129   sum += valuenum;
130   val = theDependentValues->Value(sum);
131 #endif
132   return val;
133 }
134