Loading...
Searching...
No Matches
VTKTypes.cpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#include "VTK.hpp"
26
27namespace bitpit{
28
29
30// Initialize static variables
31std::unordered_map<std::type_index, VTKDataType> VTKTypes::m_types = std::unordered_map<std::type_index, VTKDataType>();
32
33// Register standadd types
34static VTKDataType VTKTypeIndex_sint = VTKTypes::registerType<short int>();
35static VTKDataType VTKTypeIndex_int = VTKTypes::registerType<int>();
36static VTKDataType VTKTypeIndex_long = VTKTypes::registerType<long>();
37static VTKDataType VTKTypeIndex_llong = VTKTypes::registerType<long long>();
38static VTKDataType VTKTypeIndex_usint = VTKTypes::registerType<unsigned short int>();
39static VTKDataType VTKTypeIndex_uint = VTKTypes::registerType<unsigned int>();
40static VTKDataType VTKTypeIndex_ulong = VTKTypes::registerType<unsigned long>();
41static VTKDataType VTKTypeIndex_ullong = VTKTypes::registerType<unsigned long long>();
42static VTKDataType VTKTypeIndex_uint8 = VTKTypes::registerType<uint8_t>();
43static VTKDataType VTKTypeIndex_uint16 = VTKTypes::registerType<uint16_t>();
44static VTKDataType VTKTypeIndex_uint32 = VTKTypes::registerType<uint32_t>();
45static VTKDataType VTKTypeIndex_uint64 = VTKTypes::registerType<uint64_t>();
46static VTKDataType VTKTypeIndex_int8 = VTKTypes::registerType<int8_t>();
47static VTKDataType VTKTypeIndex_int16 = VTKTypes::registerType<int16_t>();
48static VTKDataType VTKTypeIndex_int32 = VTKTypes::registerType<int32_t>();
49static VTKDataType VTKTypeIndex_int64 = VTKTypes::registerType<int64_t>();
50static VTKDataType VTKTypeIndex_float = VTKTypes::registerType<float>();
51static VTKDataType VTKTypeIndex_double = VTKTypes::registerType<double>();
52
53// Register VTK types
54static VTKDataType VTKTypeIndex_VTKElement = VTKTypes::registerType<VTKElementType>();
55
68
69 switch( type){
70 case VTKDataType::Int8 : case VTKDataType::UInt8:
71 return( sizeof(int8_t) );
72
73 case VTKDataType::Int16 : case VTKDataType::UInt16 :
74 return( sizeof(int16_t) ) ;
75
76 case VTKDataType::Int32 : case VTKDataType::UInt32 :
77 return( sizeof(int32_t) ) ;
78
79 case VTKDataType::Int64 : case VTKDataType::UInt64 :
80 return( sizeof(int64_t) ) ;
81
82 case VTKDataType::Float32 :
83 return( sizeof(float) ) ;
84
85 case VTKDataType::Float64 :
86 return( sizeof(double) ) ;
87
88 case VTKDataType::UNDEFINED :
89 return( 0 ) ;
90
91 default:
92 return(0);
93 }
94
95}
96
102VTKDataType VTKTypes::whichType( const std::type_info & typeInfo ){
103
104 std::type_index index = std::type_index(typeInfo);
105 if (m_types.count(index) == 0) {
106 return VTKDataType::UNDEFINED;
107 }
108
109 return m_types.at(typeInfo);
110
111}
112
113}
static VTKDataType whichType()
Definition VTKTypes.tpp:117
static uint8_t sizeOfType(VTKDataType type)
Definition VTKTypes.cpp:67
VTKDataType
Definition VTK.hpp:74
--- layout: doxygen_footer ---