0027104: DownCast() cannot return null for mismatched handle
[occt.git] / src / IGESAppli / IGESAppli_ElementResults.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//--------------------------------------------------------------------
7fd59977 18// UNFINISHED & UNSTARTED
7fd59977 19
42cf5bc1 20#include <IGESAppli_ElementResults.hxx>
21#include <IGESAppli_FiniteElement.hxx>
22#include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
23#include <IGESBasic_HArray1OfHArray1OfReal.hxx>
24#include <IGESDimen_GeneralNote.hxx>
25#include <Standard_DimensionMismatch.hxx>
26#include <Standard_OutOfRange.hxx>
27#include <Standard_Type.hxx>
7fd59977 28
92efcf78 29IMPLEMENT_STANDARD_RTTIEXT(IGESAppli_ElementResults,IGESData_IGESEntity)
30
b311480e 31IGESAppli_ElementResults::IGESAppli_ElementResults () { }
7fd59977 32
33 void IGESAppli_ElementResults::Init
34 (const Handle(IGESDimen_GeneralNote)& aNote,
35 const Standard_Integer aSubCase, const Standard_Real aTime,
36 const Standard_Integer nbResults, const Standard_Integer aResRepFlag,
37 const Handle(TColStd_HArray1OfInteger)& allElementIdents,
38 const Handle(IGESAppli_HArray1OfFiniteElement)& allFiniteElems,
39 const Handle(TColStd_HArray1OfInteger)& allTopTypes,
40 const Handle(TColStd_HArray1OfInteger)& nbLayers,
41 const Handle(TColStd_HArray1OfInteger)& allDataLayerFlags,
42 const Handle(TColStd_HArray1OfInteger)& allnbResDataLocs,
43 const Handle(IGESBasic_HArray1OfHArray1OfInteger)& allResDataLocs,
44 const Handle(IGESBasic_HArray1OfHArray1OfReal)& allResults) // UNFINISHED
45{
46 // raises exception if sizes are not consistent, (lower = 1 too)
47 // but how to check is not clear ??
48 Standard_Integer num = allElementIdents->Length();
49 if (allElementIdents->Lower() != 1 ||
50 allFiniteElems->Lower() != 1 || allFiniteElems->Upper() != num ||
51 allTopTypes->Lower() != 1 || allTopTypes->Upper() != num ||
52 nbLayers->Lower() != 1 || nbLayers->Upper() != num ||
53 allDataLayerFlags->Lower() != 1 || allDataLayerFlags->Upper() != num ||
54 allnbResDataLocs->Lower() != 1 || allnbResDataLocs->Upper() != num ||
55 allResDataLocs->Lower() != 1 || allResDataLocs->Upper() != num ||
56 allResults->Lower() != 1 || allResults->Upper() != num )
57 Standard_DimensionMismatch::Raise("IGESAppli_ElementsResults : Init");
58 for (Standard_Integer i = 1; i <= num; i ++) {
59 Standard_Integer nl = nbLayers->Value(i);
60 Standard_Integer nrl = allnbResDataLocs->Value(i);
61 if (allResDataLocs->Value(i)->Lower() != 1 ||
62 allResDataLocs->Value(i)->Upper() != nrl)
63 Standard_DimensionMismatch::Raise("IGESAppli_ElementsResults : DataLoc");
64 if (allResults->Value(i)->Lower() != 1 ||
65 allResults->Value(i)->Upper() != nl*nrl*nbResults)
66 Standard_DimensionMismatch::Raise("IGESAppli_ElementsResults : Results");
67 }
68
69 theNote = aNote;
70 theSubcaseNumber = aSubCase;
71 theTime = aTime;
72 theNbResultValues = nbResults;
73 theResultReportFlag = aResRepFlag;
74 theElementIdentifiers = allElementIdents;
75 theElements = allFiniteElems;
76 theElementTopologyTypes = allTopTypes;
77 theNbLayers = nbLayers;
78 theDataLayerFlags = allDataLayerFlags;
79 theNbResultDataLocs = allnbResDataLocs;
80 theResultDataLocs = allResDataLocs;
81 theResultData = allResults;
82 InitTypeAndForm(148,FormNumber());
83// FormNumber -> Type of the Results
84}
85
86 void IGESAppli_ElementResults::SetFormNumber (const Standard_Integer form)
87{
88 if (form < 0 || form > 34) Standard_OutOfRange::Raise
89 ("IGESAppli_ElementResults : SetFormNumber");
90 InitTypeAndForm(148,form);
91}
92
93
94 Handle(IGESDimen_GeneralNote) IGESAppli_ElementResults::Note () const
95{
96 return theNote;
97}
98
99 Standard_Integer IGESAppli_ElementResults::SubCaseNumber () const
100{
101 return theSubcaseNumber;
102}
103
104 Standard_Real IGESAppli_ElementResults::Time () const
105{
106 return theTime;
107}
108
109 Standard_Integer IGESAppli_ElementResults::NbResultValues () const
110{
111 return theNbResultValues;
112}
113
114 Standard_Integer IGESAppli_ElementResults::ResultReportFlag () const
115{
116 return theResultReportFlag;
117}
118
119 Standard_Integer IGESAppli_ElementResults::NbElements () const
120{
121 return theElements->Length();
122}
123
124 Standard_Integer IGESAppli_ElementResults::ElementIdentifier
125 (const Standard_Integer Index) const
126{
127 return theElementIdentifiers->Value(Index);
128}
129
130 Handle(IGESAppli_FiniteElement) IGESAppli_ElementResults::Element
131 (const Standard_Integer Index) const
132{
133 return theElements->Value(Index);
134}
135
136 Standard_Integer IGESAppli_ElementResults::ElementTopologyType
137 (const Standard_Integer Index) const
138{
139 return theElementTopologyTypes->Value(Index);
140}
141
142 Standard_Integer IGESAppli_ElementResults::NbLayers
143 (const Standard_Integer Index) const
144{
145 return theNbLayers->Value(Index);
146}
147
148 Standard_Integer IGESAppli_ElementResults::DataLayerFlag
149 (const Standard_Integer Index) const
150{
151 return theDataLayerFlags->Value(Index);
152}
153
154 Standard_Integer IGESAppli_ElementResults::NbResultDataLocs
155 (const Standard_Integer Index) const
156{
157 return theNbResultDataLocs->Value(Index);
158}
159
160// ?? VERIFIER
161
162 Standard_Integer IGESAppli_ElementResults::ResultDataLoc
163 (const Standard_Integer NElem, const Standard_Integer NLoc) const
164{
165 return theResultDataLocs->Value(NElem)->Value(NLoc);
166}
167
168 Standard_Integer IGESAppli_ElementResults::NbResults
169 (const Standard_Integer Index) const
170{
171 return theResultData->Value(Index)->Length();
172}
173
174 Standard_Real IGESAppli_ElementResults::ResultData
175 (const Standard_Integer NElem, const Standard_Integer num) const
176{
177 return theResultData->Value(NElem)->Value(num);
178}
179
180 Standard_Integer IGESAppli_ElementResults::ResultRank
181 (const Standard_Integer NElem, const Standard_Integer NVal,
182 const Standard_Integer NLay, const Standard_Integer NLoc) const
183{
184 Standard_Integer num = NVal + theNbResultValues *
185 (NLay + theNbLayers->Value(NElem) * NLoc);
186 return num;
187}
188
189 Standard_Real IGESAppli_ElementResults::ResultData
190 (const Standard_Integer NElem, const Standard_Integer NVal,
191 const Standard_Integer NLay, const Standard_Integer NLoc) const
192{
193 return theResultData->Value(NElem)->Value(ResultRank(NElem,NVal,NLay,NLoc));
194}
195
196 Handle(TColStd_HArray1OfReal) IGESAppli_ElementResults::ResultList
197 (const Standard_Integer NElem) const
198{
199 return theResultData->Value(NElem);
200}