1 // Copyright (C) 2010-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay
21 #include "pqMEDReaderGraphUtils.h"
26 #include "vtkStringArray.h"
27 #include "vtkDataSetAttributes.h"
29 namespace pqMedReaderGraphUtils
31 void getCurrentTS(vtkGraph* graph, vtkIdType id, QStringList& dts, QStringList& its,
35 tree->CheckedShallowCopy(graph);
36 vtkStringArray* names = vtkStringArray::SafeDownCast(
37 tree->GetVertexData()->GetAbstractArray("Names"));
38 vtkIdType root = tree->GetRoot();
39 vtkIdType fst = tree->GetChild(root, 0); // FieldsStatusTree
40 vtkIdType tsr = tree->GetChild(tree->GetChild(fst, id*2), 0); //Time Step root node
42 for (int i = 0; i < tree->GetNumberOfChildren(tsr); i++)
46 tmp = tree->GetChild(tsr, i);
47 dts << QString(names->GetValue(tmp));
50 tmp = tree->GetChild(tmp, 0);
51 its << QString(names->GetValue(tmp));
54 tmp = tree->GetChild(tmp, 0);
55 tts << QString(names->GetValue(tmp));
59 int getMaxNumberOfTS(vtkGraph* graph)
62 tree->CheckedShallowCopy(graph);
63 vtkStringArray* names = vtkStringArray::SafeDownCast(
64 tree->GetVertexData()->GetAbstractArray("Names"));
65 vtkIdType root = tree->GetRoot();
66 vtkIdType fst = tree->GetChild(root, 0); // FieldsStatusTree
69 for (int i = 0; i < tree->GetNumberOfChildren(fst); i += 2)
71 // Look for max time steps
72 tmp = tree->GetChild(tree->GetChild(fst, i), 0);
73 nbTS = std::max(nbTS, names->GetVariantValue(tmp).ToInt());