AtilaCalculatorSoftware  2.3.4
C++ Interface for Atila fem resources files
binary_data_wrapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Project: AtilaCalculatorSoftware
4  File: binary_data_wrapper.h
5 
6  Copyright (c) 2020
7  All rights reserved.
8 
9 =========================================================================*/
10 #ifndef ATILACALCULATORSOFTWARE_BINARY_DATA_WRAPPER_H
11 #define ATILACALCULATORSOFTWARE_BINARY_DATA_WRAPPER_H
12 
13 #include "core/binary_data.h"
14 #include "logger/logger.h"
15 
16 #include <QString>
17 #include <QStringList>
18 #include <fstream>
19 #include <string>
20 #include <vtkCell.h>
21 #include <vtkCellArray.h>
22 #include <vtkFloatArray.h>
23 #include <vtkHexahedron.h>
24 #include <vtkLine.h>
25 #include <vtkPointData.h>
26 #include <vtkPoints.h>
27 #include <vtkPolygon.h>
28 #include <vtkPolyhedron.h>
29 #include <vtkPyramid.h>
30 #include <vtkQuad.h>
31 #include <vtkQuadraticPyramid.h>
32 #include <vtkQuadraticTriangle.h>
33 #include <vtkSmartPointer.h>
34 #include <vtkUnstructuredGrid.h>
35 
40 class BinaryDataWrapper : public BinaryData {
41  public:
45  explicit BinaryDataWrapper(const std::string& file);
46 
51 
57  void loadResult(Result& result, const int& component);
58 
62  void reload();
63 
68  void hideElement(const std::string& element);
69 
74  void showElement(const std::string& element);
75 
80  void toggleElement(const std::string& element);
81 
85  void showAllElements();
86 
90  vtkSmartPointer<vtkUnstructuredGrid> getUnstructuredGrid() const;
91 
95  vtkSmartPointer<vtkFloatArray> getScalars() const;
96 
100  std::set<std::string> getElements() const;
101 
105  std::set<std::string> getHiddenElements() const;
106 
110  bool isElementHidden(const std::string& element) const;
111 
115  QStringList getInformationList() const;
116 
117  private:
121  void loadMeshInformation(Mesh& mesh);
122 
126  void convertFromGiD();
127 
134  static vtkSmartPointer<vtkCell> getPolygonVTKCell(const std::string& meshElement,
135  const unsigned int& dimCount);
136 
140  vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid;
141 
145  vtkSmartPointer<vtkPoints> points;
146 
150  vtkSmartPointer<vtkFloatArray> scalars;
151 
155  std::set<std::string> elements;
156 
160  std::set<std::string> hiddenElements;
161 
165  QStringList informationList;
166 };
167 
168 #endif // ATILACALCULATORSOFTWARE_BINARY_DATA_WRAPPER_H
void hideElement(const std::string &element)
Prevent an element from being plot.
Definition: binary_data_wrapper.cpp:28
void toggleElement(const std::string &element)
Set hidden element to non hidden and non hidden element to shown.
Definition: binary_data_wrapper.cpp:36
QStringList getInformationList() const
Definition: binary_data_wrapper.cpp:64
vtkSmartPointer< vtkFloatArray > getScalars() const
Definition: binary_data_wrapper.cpp:54
std::set< std::string > elements
All elements loaded by the mesh.
Definition: binary_data_wrapper.h:155
~BinaryDataWrapper()
Empty but needed for unstructuredGrid destruction.
Representation of a mesh, all of its nodes and elements.
Definition: mesh.h:99
vtkSmartPointer< vtkFloatArray > scalars
Observed values.
Definition: binary_data_wrapper.h:150
Wrapper around the BinaryData class that allows to interact with VTK.
Definition: binary_data_wrapper.h:40
void reload()
Re-read points, use to update hidden/shown elements.
Definition: binary_data_wrapper.cpp:98
void showElement(const std::string &element)
Set a hidden element to non hidden.
Definition: binary_data_wrapper.cpp:32
BinaryDataWrapper(const std::string &file)
Definition: binary_data_wrapper.cpp:16
Representation of all the results and their components read from a res file.
Definition: result.h:28
std::set< std::string > getHiddenElements() const
Definition: binary_data_wrapper.cpp:58
std::set< std::string > hiddenElements
GiD elements of the mesh that won&#39;t be shown.
Definition: binary_data_wrapper.h:160
std::set< std::string > getElements() const
Definition: binary_data_wrapper.cpp:56
vtkSmartPointer< vtkPoints > points
Mesh nodes as vtkPoints object.
Definition: binary_data_wrapper.h:145
void showAllElements()
Set all elements to non hidden.
Definition: binary_data_wrapper.cpp:44
QStringList informationList
Information about the current results.
Definition: binary_data_wrapper.h:165
vtkSmartPointer< vtkUnstructuredGrid > unstructuredGrid
DataSet of all the points converted from GiD representation.
Definition: binary_data_wrapper.h:140
void loadMeshInformation(Mesh &mesh)
Read information from the mesh and write it to the informationList.
Definition: binary_data_wrapper.cpp:108
void loadResult(Result &result, const int &component)
Load the given component of the given result, set inner values.
Definition: binary_data_wrapper.cpp:70
static vtkSmartPointer< vtkCell > getPolygonVTKCell(const std::string &meshElement, const unsigned int &dimCount)
Find and return the good polygon fitting the mesh elements and dimensions.
Definition: binary_data_wrapper.cpp:170
void convertFromGiD()
Read points from BinaryData values loaded with GiD (meshes)
Definition: binary_data_wrapper.cpp:119
vtkSmartPointer< vtkUnstructuredGrid > getUnstructuredGrid() const
Definition: binary_data_wrapper.cpp:50
Load the resources file and allow to read meshes and results from it.
Definition: binary_data.h:31
gzFile file
Opened res gzFile.
Definition: binary_data.h:80
bool isElementHidden(const std::string &element) const
Definition: binary_data_wrapper.cpp:60