Convert unsupported cell types to supported types
This commit is contained in:
parent
b5803a5f05
commit
066e1bf3b1
@ -43,10 +43,10 @@ enum CellShapeIdEnum
|
||||
CELL_SHAPE_TRIANGLE = 5,
|
||||
//CELL_SHAPE_TRIANGLE_STRIP = 6,
|
||||
CELL_SHAPE_POLYGON = 7,
|
||||
//CELL_SHAPE_PIXEL = 8,
|
||||
//CELL_SHAPE_PIXEL = 8,
|
||||
CELL_SHAPE_QUAD = 9,
|
||||
CELL_SHAPE_TETRA = 10,
|
||||
//CELL_SHAPE_VOXEL = 11,
|
||||
//CELL_SHAPE_VOXEL = 11,
|
||||
CELL_SHAPE_HEXAHEDRON = 12,
|
||||
CELL_SHAPE_WEDGE = 13,
|
||||
CELL_SHAPE_PYRAMID = 14,
|
||||
@ -149,7 +149,7 @@ struct CellShapeTagGeneric {
|
||||
case vtkm::cellShapeId: \
|
||||
{ \
|
||||
typedef \
|
||||
typename vtkm::CellShapeIdToTag<vtkm::cellShapeId>::Tag CellShapeTag; \
|
||||
vtkm::CellShapeIdToTag<vtkm::cellShapeId>::Tag CellShapeTag; \
|
||||
call; \
|
||||
} \
|
||||
break
|
||||
|
@ -24,5 +24,6 @@ set(headers
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
||||
add_subdirectory(internal)
|
||||
add_subdirectory(reader)
|
||||
add_subdirectory(writer)
|
||||
|
@ -19,7 +19,10 @@
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
TypeInfo.h
|
||||
Endian.h
|
||||
VTKDataSetCells.h
|
||||
VTKDataSetStructures.h
|
||||
VTKDataSetTypes.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
55
vtkm/io/internal/Endian.h
Normal file
55
vtkm/io/internal/Endian.h
Normal file
@ -0,0 +1,55 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2015 Sandia Corporation.
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_io_internal_Endian_h
|
||||
#define vtk_m_io_internal_Endian_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace vtkm {
|
||||
namespace io {
|
||||
namespace internal {
|
||||
|
||||
inline bool IsLittleEndian()
|
||||
{
|
||||
static const vtkm::Int16 i16 = 0x1;
|
||||
const vtkm::Int8 *i8p = reinterpret_cast<const vtkm::Int8*>(&i16);
|
||||
return (*i8p == 1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void FlipEndianness(std::vector<T> &buffer)
|
||||
{
|
||||
vtkm::UInt8 *bytes = reinterpret_cast<vtkm::UInt8*>(&buffer[0]);
|
||||
const std::size_t tsize = sizeof(T);
|
||||
const std::size_t bsize = buffer.size();
|
||||
for (std::size_t i = 0; i < bsize; i++, bytes+=tsize)
|
||||
{
|
||||
std::reverse(bytes, bytes + tsize);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // vtkm::io::internal
|
||||
|
||||
#endif //vtk_m_io_internal_Endian_h
|
234
vtkm/io/internal/VTKDataSetCells.h
Normal file
234
vtkm/io/internal/VTKDataSetCells.h
Normal file
@ -0,0 +1,234 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2015 Sandia Corporation.
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_io_internal_VTKDataSetCells_h
|
||||
#define vtk_m_io_internal_VTKDataSetCells_h
|
||||
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
#include <vtkm/io/ErrorIO.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace vtkm {
|
||||
namespace io {
|
||||
namespace internal {
|
||||
|
||||
enum UnsupportedVTKCells
|
||||
{
|
||||
CELL_SHAPE_POLY_VERTEX = 2,
|
||||
CELL_SHAPE_POLY_LINE = 4,
|
||||
CELL_SHAPE_TRIANGLE_STRIP = 6,
|
||||
CELL_SHAPE_PIXEL = 8,
|
||||
CELL_SHAPE_VOXEL = 11
|
||||
};
|
||||
|
||||
|
||||
inline void FixupCellSet(vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> &permutation)
|
||||
{
|
||||
std::vector<vtkm::Id> newConnectivity;
|
||||
std::vector<vtkm::IdComponent> newNumIndices;
|
||||
std::vector<vtkm::UInt8> newShapes;
|
||||
std::vector<vtkm::Id> permutationVec;
|
||||
|
||||
vtkm::Id connIdx = 0;
|
||||
for (vtkm::Id i = 0; i < shapes.GetNumberOfValues(); ++i)
|
||||
{
|
||||
vtkm::UInt8 shape = shapes.GetPortalConstControl().Get(i);
|
||||
vtkm::IdComponent numInds = numIndices.GetPortalConstControl().Get(i);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>::PortalConstControl connPortal =
|
||||
connectivity.GetPortalConstControl();
|
||||
switch (shape)
|
||||
{
|
||||
case vtkm::CELL_SHAPE_VERTEX:
|
||||
case vtkm::CELL_SHAPE_LINE:
|
||||
case vtkm::CELL_SHAPE_TRIANGLE:
|
||||
case vtkm::CELL_SHAPE_QUAD:
|
||||
case vtkm::CELL_SHAPE_TETRA:
|
||||
case vtkm::CELL_SHAPE_HEXAHEDRON:
|
||||
case vtkm::CELL_SHAPE_WEDGE:
|
||||
case vtkm::CELL_SHAPE_PYRAMID:
|
||||
{
|
||||
newShapes.push_back(shape);
|
||||
newNumIndices.push_back(numInds);
|
||||
for (vtkm::IdComponent j = 0; j < numInds; ++j)
|
||||
{
|
||||
newConnectivity.push_back(connPortal.Get(connIdx++));
|
||||
}
|
||||
permutationVec.push_back(i);
|
||||
break;
|
||||
}
|
||||
case vtkm::CELL_SHAPE_POLYGON:
|
||||
{
|
||||
vtkm::IdComponent numVerts = numInds;
|
||||
vtkm::UInt8 newShape = vtkm::CELL_SHAPE_POLYGON;
|
||||
if (numVerts == 3)
|
||||
{
|
||||
newShape = vtkm::CELL_SHAPE_TRIANGLE;
|
||||
}
|
||||
else if (numVerts == 4)
|
||||
{
|
||||
newShape = vtkm::CELL_SHAPE_QUAD;
|
||||
}
|
||||
newShapes.push_back(newShape);
|
||||
newNumIndices.push_back(numVerts);
|
||||
for (vtkm::IdComponent j = 0; j < numVerts; ++j)
|
||||
{
|
||||
newConnectivity.push_back(connPortal.Get(connIdx++));
|
||||
}
|
||||
permutationVec.push_back(i);
|
||||
break;
|
||||
}
|
||||
case CELL_SHAPE_POLY_VERTEX:
|
||||
{
|
||||
vtkm::IdComponent numVerts = numInds;
|
||||
for (vtkm::IdComponent j = 0; j < numVerts; ++j)
|
||||
{
|
||||
newShapes.push_back(vtkm::CELL_SHAPE_VERTEX);
|
||||
newNumIndices.push_back(1);
|
||||
newConnectivity.push_back(connPortal.Get(connIdx));
|
||||
permutationVec.push_back(i);
|
||||
++connIdx;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CELL_SHAPE_POLY_LINE:
|
||||
{
|
||||
vtkm::IdComponent numLines = numInds - 1;
|
||||
for (vtkm::IdComponent j = 0; j < numLines; ++j)
|
||||
{
|
||||
newShapes.push_back(vtkm::CELL_SHAPE_LINE);
|
||||
newNumIndices.push_back(2);
|
||||
newConnectivity.push_back(connPortal.Get(connIdx));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx+1));
|
||||
permutationVec.push_back(i);
|
||||
++connIdx;
|
||||
}
|
||||
connIdx += 1;
|
||||
break;
|
||||
}
|
||||
case CELL_SHAPE_TRIANGLE_STRIP:
|
||||
{
|
||||
vtkm::IdComponent numTris = numInds - 2;
|
||||
for (vtkm::IdComponent j = 0; j < numTris; ++j)
|
||||
{
|
||||
newShapes.push_back(vtkm::CELL_SHAPE_TRIANGLE);
|
||||
newNumIndices.push_back(3);
|
||||
if (j % 2)
|
||||
{
|
||||
newConnectivity.push_back(connPortal.Get(connIdx));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx+1));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx+2));
|
||||
}
|
||||
else
|
||||
{
|
||||
newConnectivity.push_back(connPortal.Get(connIdx+2));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx+1));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx));
|
||||
}
|
||||
permutationVec.push_back(i);
|
||||
++connIdx;
|
||||
}
|
||||
connIdx += 2;
|
||||
break;
|
||||
}
|
||||
case CELL_SHAPE_PIXEL:
|
||||
{
|
||||
newShapes.push_back(vtkm::CELL_SHAPE_QUAD);
|
||||
newNumIndices.push_back(numInds);
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 0));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 1));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 3));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 2));
|
||||
permutationVec.push_back(i);
|
||||
connIdx += 4;
|
||||
break;
|
||||
}
|
||||
case CELL_SHAPE_VOXEL:
|
||||
{
|
||||
newShapes.push_back(vtkm::CELL_SHAPE_HEXAHEDRON);
|
||||
newNumIndices.push_back(numInds);
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 0));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 1));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 3));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 2));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 4));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 5));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 7));
|
||||
newConnectivity.push_back(connPortal.Get(connIdx + 6));
|
||||
permutationVec.push_back(i);
|
||||
connIdx += 6;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw vtkm::io::ErrorIO("Encountered unsupported cell type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newShapes.size() == static_cast<std::size_t>(shapes.GetNumberOfValues()))
|
||||
{
|
||||
permutationVec.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
permutation.Allocate(static_cast<vtkm::Id>(permutationVec.size()));
|
||||
std::copy(permutationVec.begin(), permutationVec.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(permutation.GetPortalControl()));
|
||||
}
|
||||
|
||||
shapes.Allocate(static_cast<vtkm::Id>(newShapes.size()));
|
||||
std::copy(newShapes.begin(), newShapes.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(shapes.GetPortalControl()));
|
||||
numIndices.Allocate(static_cast<vtkm::Id>(newNumIndices.size()));
|
||||
std::copy(newNumIndices.begin(), newNumIndices.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(numIndices.GetPortalControl()));
|
||||
connectivity.Allocate(static_cast<vtkm::Id>(newConnectivity.size()));
|
||||
std::copy(newConnectivity.begin(), newConnectivity.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(connectivity.GetPortalControl()));
|
||||
}
|
||||
|
||||
inline bool IsSingleShape(const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8>::PortalConstControl shapesPortal =
|
||||
shapes.GetPortalConstControl();
|
||||
|
||||
vtkm::UInt8 shape0 = shapesPortal.Get(0);
|
||||
for (vtkm::Id i = 1; i < shapes.GetNumberOfValues(); ++i)
|
||||
{
|
||||
if (shapesPortal.Get(i) != shape0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // vtkm::io::internal
|
||||
|
||||
#endif // vtk_m_io_internal_VTKDataSetCells_h
|
72
vtkm/io/internal/VTKDataSetStructures.h
Normal file
72
vtkm/io/internal/VTKDataSetStructures.h
Normal file
@ -0,0 +1,72 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2015 Sandia Corporation.
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_io_internal_VTKDataSetStructures_h
|
||||
#define vtk_m_io_internal_VTKDataSetStructures_h
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace vtkm {
|
||||
namespace io {
|
||||
namespace internal {
|
||||
|
||||
enum DataSetStructure
|
||||
{
|
||||
DATASET_UNKNOWN = 0,
|
||||
DATASET_STRUCTURED_POINTS,
|
||||
DATASET_STRUCTURED_GRID,
|
||||
DATASET_UNSTRUCTURED_GRID,
|
||||
DATASET_POLYDATA,
|
||||
DATASET_RECTILINEAR_GRID,
|
||||
DATASET_FIELD
|
||||
};
|
||||
|
||||
inline const char* DataSetStructureString(int id)
|
||||
{
|
||||
static const char *strings[] = {
|
||||
"",
|
||||
"STRUCTURED_POINTS",
|
||||
"STRUCTURED_GRID",
|
||||
"UNSTRUCTURED_GRID",
|
||||
"POLYDATA",
|
||||
"RECTILINEAR_GRID",
|
||||
"FIELD"
|
||||
};
|
||||
return strings[id];
|
||||
}
|
||||
|
||||
inline DataSetStructure DataSetStructureId(const std::string &str)
|
||||
{
|
||||
DataSetStructure structure = DATASET_UNKNOWN;
|
||||
for (int id = 1; id < 7; ++id)
|
||||
{
|
||||
if (str == DataSetStructureString(id))
|
||||
{
|
||||
structure = static_cast<DataSetStructure>(id);
|
||||
}
|
||||
}
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::io::internal
|
||||
|
||||
#endif // vtk_m_io_internal_VTKDataSetStructures_h
|
@ -17,8 +17,8 @@
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_io_readers_internal_TypeInfo_h
|
||||
#define vtk_m_io_readers_internal_TypeInfo_h
|
||||
#ifndef vtk_m_io_internal_VTKDataSetTypes_h
|
||||
#define vtk_m_io_internal_VTKDataSetTypes_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
@ -28,20 +28,8 @@
|
||||
|
||||
namespace vtkm {
|
||||
namespace io {
|
||||
namespace reader {
|
||||
namespace internal {
|
||||
|
||||
enum DataSetType
|
||||
{
|
||||
DATASET_UNKNOWN = 0,
|
||||
DATASET_STRUCTURED_POINTS,
|
||||
DATASET_STRUCTURED_GRID,
|
||||
DATASET_UNSTRUCTURED_GRID,
|
||||
DATASET_POLYDATA,
|
||||
DATASET_RECTILINEAR_GRID,
|
||||
DATASET_FIELD
|
||||
};
|
||||
|
||||
enum DataType
|
||||
{
|
||||
DTYPE_UNKNOWN = 0,
|
||||
@ -58,34 +46,6 @@ enum DataType
|
||||
DTYPE_DOUBLE
|
||||
};
|
||||
|
||||
inline const char* DataSetTypeString(int id)
|
||||
{
|
||||
static const char *strings[] = {
|
||||
"",
|
||||
"STRUCTURED_POINTS",
|
||||
"STRUCTURED_GRID",
|
||||
"UNSTRUCTURED_GRID",
|
||||
"POLYDATA",
|
||||
"RECTILINEAR_GRID",
|
||||
"FIELD"
|
||||
};
|
||||
return strings[id];
|
||||
}
|
||||
|
||||
inline DataSetType DataSetTypeId(const std::string &str)
|
||||
{
|
||||
DataSetType type = DATASET_UNKNOWN;
|
||||
for (int id = 1; id < 7; ++id)
|
||||
{
|
||||
if (str == DataSetTypeString(id))
|
||||
{
|
||||
type = static_cast<DataSetType>(id);
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
inline const char* DataTypeString(int id)
|
||||
{
|
||||
static const char *strings[] = {
|
||||
@ -166,6 +126,56 @@ inline std::istream& operator>>(std::istream& in, ColorChannel8 &val)
|
||||
}
|
||||
|
||||
|
||||
template <typename T> struct DataTypeName
|
||||
{
|
||||
static const char* Name() { return "unknown"; }
|
||||
};
|
||||
template <> struct DataTypeName<DummyBitType>
|
||||
{
|
||||
static const char* Name() { return "bit"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int8>
|
||||
{
|
||||
static const char* Name() { return "char"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt8>
|
||||
{
|
||||
static const char* Name() { return "unsigned_char"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int16>
|
||||
{
|
||||
static const char* Name() { return "short"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt16>
|
||||
{
|
||||
static const char* Name() { return "unsigned_short"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int32>
|
||||
{
|
||||
static const char* Name() { return "int"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt32>
|
||||
{
|
||||
static const char* Name() { return "unsigned_int"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int64>
|
||||
{
|
||||
static const char* Name() { return "long"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt64>
|
||||
{
|
||||
static const char* Name() { return "unsigned_long"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Float32>
|
||||
{
|
||||
static const char* Name() { return "float"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Float64>
|
||||
{
|
||||
static const char* Name() { return "double"; }
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename Functor>
|
||||
inline void SelectVecTypeAndCall(T, vtkm::IdComponent numComponents, const Functor &functor)
|
||||
{
|
||||
@ -238,7 +248,6 @@ inline void SelectTypeAndCall(DataType dtype, vtkm::IdComponent numComponents,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::io:reader::internal
|
||||
} // namespace vtkm::io::internal
|
||||
|
||||
#endif // vtk_m_io_readers_internal_TypeInfo_h
|
||||
#endif // vtk_m_io_internal_VTKDataSetTypes_h
|
@ -29,5 +29,4 @@ set(headers
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
||||
add_subdirectory(internal)
|
||||
add_subdirectory(testing)
|
||||
|
@ -70,16 +70,16 @@ private:
|
||||
{
|
||||
switch (this->DataFile->Structure)
|
||||
{
|
||||
case internal::DATASET_STRUCTURED_POINTS:
|
||||
case vtkm::io::internal::DATASET_STRUCTURED_POINTS:
|
||||
this->Reader.reset(new VTKStructuredPointsReader(""));
|
||||
break;
|
||||
case internal::DATASET_STRUCTURED_GRID:
|
||||
case vtkm::io::internal::DATASET_STRUCTURED_GRID:
|
||||
this->Reader.reset(new VTKStructuredGridReader(""));
|
||||
break;
|
||||
case internal::DATASET_POLYDATA:
|
||||
case vtkm::io::internal::DATASET_POLYDATA:
|
||||
this->Reader.reset(new VTKPolyDataReader(""));
|
||||
break;
|
||||
case internal::DATASET_UNSTRUCTURED_GRID:
|
||||
case vtkm::io::internal::DATASET_UNSTRUCTURED_GRID:
|
||||
this->Reader.reset(new VTKUnstructuredGridReader(""));
|
||||
break;
|
||||
default:
|
||||
|
@ -20,7 +20,10 @@
|
||||
#ifndef vtk_m_io_reader_VTKDataSetReaderBase_h
|
||||
#define vtk_m_io_reader_VTKDataSetReaderBase_h
|
||||
|
||||
#include <vtkm/io/reader/internal/TypeInfo.h>
|
||||
#include <vtkm/io/internal/Endian.h>
|
||||
#include <vtkm/io/internal/VTKDataSetCells.h>
|
||||
#include <vtkm/io/internal/VTKDataSetStructures.h>
|
||||
#include <vtkm/io/internal/VTKDataSetTypes.h>
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
@ -39,7 +42,6 @@ VTKM_THIRDPARTY_POST_INCLUDE
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@ -55,7 +57,7 @@ struct VTKDataSetFile
|
||||
vtkm::Id2 Version;
|
||||
std::string Title;
|
||||
bool IsBinary;
|
||||
DataSetType Structure;
|
||||
vtkm::io::internal::DataSetStructure Structure;
|
||||
std::ifstream Stream;
|
||||
};
|
||||
|
||||
@ -65,27 +67,11 @@ inline void PrintVTKDataFileSummary(const VTKDataSetFile &df, std::ostream &out)
|
||||
out << "\tVersion: " << df.Version[0] << "." << df.Version[0] << std::endl;
|
||||
out << "\tTitle: " << df.Title << std::endl;
|
||||
out << "\tFormat: " << (df.IsBinary ? "BINARY" : "ASCII") << std::endl;
|
||||
out << "\tDataSet type: " << internal::DataSetTypeString(df.Structure) << std::endl;
|
||||
out << "\tDataSet type: " << vtkm::io::internal::DataSetStructureString(df.Structure)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
inline bool isLittleEndian()
|
||||
{
|
||||
static const vtkm::Int16 i16 = 0x1;
|
||||
const vtkm::Int8 *i8p = reinterpret_cast<const vtkm::Int8*>(&i16);
|
||||
return (*i8p == 1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void flipEndianness(std::vector<T> &buffer)
|
||||
{
|
||||
for (std::size_t i = 0; i < buffer.size(); ++i)
|
||||
{
|
||||
vtkm::UInt8 *bytes = reinterpret_cast<vtkm::UInt8*>(&buffer[i]);
|
||||
std::reverse(bytes, bytes + sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
inline void parseAssert(bool condition)
|
||||
{
|
||||
if (!condition)
|
||||
@ -94,6 +80,7 @@ inline void parseAssert(bool condition)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T> struct StreamIOType { typedef T Type; };
|
||||
template <> struct StreamIOType<vtkm::Int8> { typedef vtkm::Int16 Type; };
|
||||
template <> struct StreamIOType<vtkm::UInt8> { typedef vtkm::UInt16 Type; };
|
||||
@ -130,8 +117,10 @@ vtkm::cont::DynamicArrayHandle CreateDynamicArrayHandle(const std::vector<T> &ve
|
||||
typedef typename ClosestCommonType<T>::Type CommonType;
|
||||
if (!boost::is_same<T, CommonType>::value)
|
||||
{
|
||||
std::cerr << "Type " << typeid(T).name() << " is currently unsupported. "
|
||||
<< "Converting to " << typeid(CommonType).name() << "." << std::endl;
|
||||
std::cerr << "Type " << vtkm::io::internal::DataTypeName<T>::Name()
|
||||
<< " is currently unsupported. Converting to "
|
||||
<< vtkm::io::internal::DataTypeName<CommonType>::Name() << "."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<CommonType> output;
|
||||
@ -152,10 +141,11 @@ vtkm::cont::DynamicArrayHandle CreateDynamicArrayHandle(const std::vector<T> &ve
|
||||
typedef vtkm::Vec<OutComponentType, 3> CommonType;
|
||||
if (!boost::is_same<T, CommonType>::value)
|
||||
{
|
||||
std::cerr << "Type " << typeid(InComponentType).name()
|
||||
std::cerr << "Type " << vtkm::io::internal::DataTypeName<InComponentType>::Name()
|
||||
<< "[" << vtkm::VecTraits<T>::NUM_COMPONENTS << "] "
|
||||
<< "is currently unsupported. Converting to "
|
||||
<< typeid(OutComponentType).name() << "[3]." << std::endl;
|
||||
<< vtkm::io::internal::DataTypeName<OutComponentType>::Name() << "[3]."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<CommonType> output;
|
||||
@ -245,71 +235,51 @@ protected:
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, points));
|
||||
}
|
||||
|
||||
void ReadCells(std::vector<vtkm::Id> &connectivity,
|
||||
std::vector<vtkm::IdComponent> &numIndices)
|
||||
void ReadCells(vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices)
|
||||
{
|
||||
std::size_t numCells, numInts;
|
||||
vtkm::Id numCells, numInts;
|
||||
this->DataFile->Stream >> numCells >> numInts >> std::ws;
|
||||
|
||||
connectivity.resize(numInts - numCells);
|
||||
numIndices.resize(numCells);
|
||||
connectivity.Allocate(numInts - numCells);
|
||||
numIndices.Allocate(numCells);
|
||||
|
||||
if (this->DataFile->IsBinary)
|
||||
{
|
||||
std::vector<vtkm::Int32> buffer(numInts);
|
||||
this->ReadArray(buffer);
|
||||
std::vector<vtkm::Int32> buffer(static_cast<std::size_t>(numInts));
|
||||
this->ReadArray(buffer);
|
||||
|
||||
vtkm::Int32 *buffp = &buffer[0];
|
||||
vtkm::Id *connp = &connectivity[0];
|
||||
vtkm::IdComponent *indsp = &numIndices[0];
|
||||
for (std::size_t i = 0; i < numCells; ++i)
|
||||
{
|
||||
*indsp = *buffp++;
|
||||
for (vtkm::IdComponent j = 0; j < *indsp; ++j)
|
||||
{
|
||||
*connp++ = *buffp++;
|
||||
}
|
||||
++indsp;
|
||||
}
|
||||
}
|
||||
else
|
||||
vtkm::Int32 *buffp = &buffer[0];
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>::PortalControl connectivityPortal =
|
||||
connectivity.GetPortalControl();
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent>::PortalControl numIndicesPortal =
|
||||
numIndices.GetPortalControl();
|
||||
for (vtkm::Id i = 0, connInd = 0; i < numCells; ++i)
|
||||
{
|
||||
vtkm::Id *connp = &connectivity[0];
|
||||
vtkm::IdComponent *indsp = &numIndices[0];
|
||||
for (std::size_t i = 0; i < numCells; ++i)
|
||||
vtkm::IdComponent numInds = static_cast<vtkm::IdComponent>(*buffp++);
|
||||
numIndicesPortal.Set(i, numInds);
|
||||
for (vtkm::IdComponent j = 0; j < numInds; ++j, ++connInd)
|
||||
{
|
||||
this->DataFile->Stream >> *indsp;
|
||||
for (vtkm::IdComponent j = 0; j < *indsp; ++j)
|
||||
{
|
||||
this->DataFile->Stream >> *connp++;
|
||||
}
|
||||
++indsp;
|
||||
connectivityPortal.Set(connInd, static_cast<vtkm::Id>(*buffp++));
|
||||
}
|
||||
this->DataFile->Stream >> std::ws;
|
||||
}
|
||||
}
|
||||
|
||||
void ReadShapes(std::vector<vtkm::UInt8> &shapes)
|
||||
void ReadShapes(vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes)
|
||||
{
|
||||
std::string tag;
|
||||
std::size_t numCells;
|
||||
vtkm::Id numCells;
|
||||
this->DataFile->Stream >> tag >> numCells >> std::ws;
|
||||
internal::parseAssert(tag == "CELL_TYPES");
|
||||
|
||||
shapes.resize(numCells);
|
||||
if (this->DataFile->IsBinary)
|
||||
{
|
||||
std::vector<vtkm::Int32> buffer(numCells);
|
||||
this->ReadArray(buffer);
|
||||
shapes.Allocate(numCells);
|
||||
std::vector<vtkm::Int32> buffer(static_cast<std::size_t>(numCells));
|
||||
this->ReadArray(buffer);
|
||||
|
||||
for (std::size_t i = 0; i < numCells; ++i)
|
||||
{
|
||||
shapes[i] = static_cast<vtkm::UInt8>(buffer[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
vtkm::Int32 *buffp = &buffer[0];
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8>::PortalControl shapesPortal =
|
||||
shapes.GetPortalControl();
|
||||
for (vtkm::Id i = 0; i < numCells; ++i)
|
||||
{
|
||||
this->ReadArray(shapes);
|
||||
shapesPortal.Set(i, static_cast<vtkm::UInt8>(*buffp++));
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,6 +360,7 @@ protected:
|
||||
this->DataSet.AddField(vtkm::cont::Field(name, 0, association, data));
|
||||
break;
|
||||
case vtkm::cont::Field::ASSOC_CELL_SET:
|
||||
data.CastAndCall(PermuteCellData(this->CellsPermutation, data));
|
||||
this->DataSet.AddField(
|
||||
vtkm::cont::Field(name, 0, association, "cells", data));
|
||||
break;
|
||||
@ -401,6 +372,11 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void SetCellsPermutation(const vtkm::cont::ArrayHandle<vtkm::Id> &permutation)
|
||||
{
|
||||
this->CellsPermutation = permutation;
|
||||
}
|
||||
|
||||
void TransferDataFile(VTKDataSetReaderBase &reader)
|
||||
{
|
||||
reader.DataFile.swap(this->DataFile);
|
||||
@ -459,8 +435,8 @@ private:
|
||||
this->DataFile->Stream >> tag >> structStr >> std::ws;
|
||||
internal::parseAssert(tag == "DATASET");
|
||||
|
||||
this->DataFile->Structure = internal::DataSetTypeId(structStr);
|
||||
if (this->DataFile->Structure == internal::DATASET_UNKNOWN)
|
||||
this->DataFile->Structure = vtkm::io::internal::DataSetStructureId(structStr);
|
||||
if (this->DataFile->Structure == vtkm::io::internal::DATASET_UNKNOWN)
|
||||
{
|
||||
throw vtkm::io::ErrorIO("Unsupported DataSet type.");
|
||||
}
|
||||
@ -503,7 +479,7 @@ private:
|
||||
|
||||
std::size_t numValues;
|
||||
this->DataFile->Stream >> dataName >> numValues >> std::ws;
|
||||
this->SkipArray(numElements * numValues, internal::ColorChannel8());
|
||||
this->SkipArray(numElements * numValues, vtkm::io::internal::ColorChannel8());
|
||||
}
|
||||
|
||||
void ReadLookupTable(std::string &dataName)
|
||||
@ -513,7 +489,7 @@ private:
|
||||
|
||||
std::size_t numEntries;
|
||||
this->DataFile->Stream >> dataName >> numEntries >> std::ws;
|
||||
this->SkipArray(numEntries, vtkm::Vec<internal::ColorChannel8, 4>());
|
||||
this->SkipArray(numEntries, vtkm::Vec<vtkm::io::internal::ColorChannel8, 4>());
|
||||
}
|
||||
|
||||
void ReadTextureCoordinates(std::size_t numElements, std::string &dataName,
|
||||
@ -622,18 +598,18 @@ private:
|
||||
void DoSkipDynamicArray(std::string dataType, std::size_t numElements,
|
||||
vtkm::IdComponent numComponents)
|
||||
{
|
||||
internal::DataType typeId = internal::DataTypeId(dataType);
|
||||
internal::SelectTypeAndCall(typeId, numComponents,
|
||||
SkipDynamicArray(this, numElements));
|
||||
vtkm::io::internal::DataType typeId = vtkm::io::internal::DataTypeId(dataType);
|
||||
vtkm::io::internal::SelectTypeAndCall(typeId, numComponents,
|
||||
SkipDynamicArray(this, numElements));
|
||||
}
|
||||
|
||||
void DoReadDynamicArray(std::string dataType, std::size_t numElements,
|
||||
vtkm::IdComponent numComponents,
|
||||
vtkm::cont::DynamicArrayHandle &data)
|
||||
{
|
||||
internal::DataType typeId = internal::DataTypeId(dataType);
|
||||
internal::SelectTypeAndCall(typeId, numComponents,
|
||||
ReadDynamicArray(this, numElements, data));
|
||||
vtkm::io::internal::DataType typeId = vtkm::io::internal::DataTypeId(dataType);
|
||||
vtkm::io::internal::SelectTypeAndCall(typeId, numComponents,
|
||||
ReadDynamicArray(this, numElements, data));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -644,9 +620,9 @@ private:
|
||||
{
|
||||
this->DataFile->Stream.read(reinterpret_cast<char*>(&buffer[0]),
|
||||
static_cast<std::streamsize>(numElements * sizeof(T)));
|
||||
if(internal::isLittleEndian())
|
||||
if(vtkm::io::internal::IsLittleEndian())
|
||||
{
|
||||
internal::flipEndianness(buffer);
|
||||
vtkm::io::internal::FlipEndianness(buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -669,19 +645,21 @@ private:
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent NumComponents>
|
||||
void ReadArray(std::vector<vtkm::Vec<internal::DummyBitType, NumComponents> > &buffer)
|
||||
void ReadArray(std::vector<vtkm::Vec<vtkm::io::internal::DummyBitType,
|
||||
NumComponents> > &buffer)
|
||||
{
|
||||
std::cerr << "Support for data type 'bit' is not implemented. Skipping."
|
||||
<< std::endl;
|
||||
this->SkipArray(buffer.size(), vtkm::Vec<internal::DummyBitType, NumComponents>());
|
||||
this->SkipArray(buffer.size(), vtkm::Vec<vtkm::io::internal::DummyBitType,
|
||||
NumComponents>());
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
void ReadArray(std::vector<internal::DummyBitType> &buffer)
|
||||
void ReadArray(std::vector<vtkm::io::internal::DummyBitType> &buffer)
|
||||
{
|
||||
std::cerr << "Support for data type 'bit' is not implemented. Skipping."
|
||||
<< std::endl;
|
||||
this->SkipArray(buffer.size(), internal::DummyBitType());
|
||||
this->SkipArray(buffer.size(), vtkm::io::internal::DummyBitType());
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
@ -712,18 +690,20 @@ private:
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent NumComponents>
|
||||
void SkipArray(std::size_t numElements, vtkm::Vec<internal::DummyBitType, NumComponents>)
|
||||
void SkipArray(std::size_t numElements,
|
||||
vtkm::Vec<vtkm::io::internal::DummyBitType, NumComponents>)
|
||||
{
|
||||
this->SkipArray(numElements * static_cast<std::size_t>(NumComponents),
|
||||
internal::DummyBitType());
|
||||
vtkm::io::internal::DummyBitType());
|
||||
}
|
||||
|
||||
void SkipArray(std::size_t numElements, internal::DummyBitType)
|
||||
void SkipArray(std::size_t numElements, vtkm::io::internal::DummyBitType)
|
||||
{
|
||||
if (this->DataFile->IsBinary)
|
||||
{
|
||||
numElements = (numElements + 7) / 8;
|
||||
this->DataFile->Stream.seekg(static_cast<std::streamoff>(numElements), std::ios_base::cur);
|
||||
this->DataFile->Stream.seekg(static_cast<std::streamoff>(numElements),
|
||||
std::ios_base::cur);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -736,12 +716,45 @@ private:
|
||||
this->DataFile->Stream >> std::ws;
|
||||
}
|
||||
|
||||
class PermuteCellData
|
||||
{
|
||||
public:
|
||||
PermuteCellData(const vtkm::cont::ArrayHandle<vtkm::Id> &permutation,
|
||||
vtkm::cont::DynamicArrayHandle &data)
|
||||
: Permutation(permutation), Data(&data)
|
||||
{ }
|
||||
|
||||
template <typename T>
|
||||
void operator()(const vtkm::cont::ArrayHandle<T> &handle) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> out;
|
||||
out.Allocate(this->Permutation.GetNumberOfValues());
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>::PortalConstControl permutationPortal =
|
||||
this->Permutation.GetPortalConstControl();
|
||||
typename vtkm::cont::ArrayHandle<T>::PortalConstControl inPortal =
|
||||
handle.GetPortalConstControl();
|
||||
typename vtkm::cont::ArrayHandle<T>::PortalControl outPortal =
|
||||
out.GetPortalControl();
|
||||
for (vtkm::Id i = 0; i < out.GetNumberOfValues(); ++i)
|
||||
{
|
||||
outPortal.Set(i, inPortal.Get(permutationPortal.Get(i)));
|
||||
}
|
||||
*this->Data = vtkm::cont::DynamicArrayHandle(out);
|
||||
}
|
||||
|
||||
private:
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> Permutation;
|
||||
vtkm::cont::DynamicArrayHandle *Data;
|
||||
};
|
||||
|
||||
protected:
|
||||
boost::scoped_ptr<internal::VTKDataSetFile> DataFile;
|
||||
vtkm::cont::DataSet DataSet;
|
||||
|
||||
private:
|
||||
bool Loaded;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> CellsPermutation;
|
||||
|
||||
friend class VTKDataSetReader;
|
||||
};
|
||||
@ -750,7 +763,7 @@ private:
|
||||
}
|
||||
} // vtkm::io::reader
|
||||
|
||||
VTKM_BASIC_TYPE_VECTOR(io::reader::internal::ColorChannel8)
|
||||
VTKM_BASIC_TYPE_VECTOR(io::reader::internal::DummyBitType)
|
||||
VTKM_BASIC_TYPE_VECTOR(vtkm::io::internal::ColorChannel8)
|
||||
VTKM_BASIC_TYPE_VECTOR(vtkm::io::internal::DummyBitType)
|
||||
|
||||
#endif // vtk_m_io_reader_VTKDataSetReaderBase_h
|
||||
|
@ -22,10 +22,43 @@
|
||||
|
||||
#include <vtkm/io/reader/VTKDataSetReaderBase.h>
|
||||
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace io {
|
||||
namespace reader {
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename T>
|
||||
inline vtkm::cont::ArrayHandle<T> ConcatinateArrayHandles(
|
||||
const std::vector<vtkm::cont::ArrayHandle<T> > &arrays)
|
||||
{
|
||||
vtkm::Id size = 0;
|
||||
for (std::size_t i = 0; i < arrays.size(); ++i)
|
||||
{
|
||||
size += arrays[i].GetNumberOfValues();
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<T> out;
|
||||
out.Allocate(size);
|
||||
|
||||
typename vtkm::cont::ArrayPortalToIterators<
|
||||
typename vtkm::cont::ArrayHandle<T>::PortalControl>::IteratorType outp =
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(out.GetPortalControl());
|
||||
for (std::size_t i = 0; i < arrays.size(); ++i)
|
||||
{
|
||||
std::copy(vtkm::cont::ArrayPortalToIteratorBegin(arrays[i].GetPortalConstControl()),
|
||||
vtkm::cont::ArrayPortalToIteratorEnd(arrays[i].GetPortalConstControl()),
|
||||
outp);
|
||||
outp += arrays[i].GetNumberOfValues();
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
class VTKPolyDataReader : public VTKDataSetReaderBase
|
||||
{
|
||||
public:
|
||||
@ -36,7 +69,7 @@ public:
|
||||
private:
|
||||
virtual void Read()
|
||||
{
|
||||
if (this->DataFile->Structure != internal::DATASET_POLYDATA)
|
||||
if (this->DataFile->Structure != vtkm::io::internal::DATASET_POLYDATA)
|
||||
{
|
||||
throw vtkm::io::ErrorIO("Incorrect DataSet type");
|
||||
}
|
||||
@ -47,21 +80,20 @@ private:
|
||||
this->ReadPoints();
|
||||
|
||||
// Read the cellset
|
||||
std::vector<vtkm::Id> connectivity;
|
||||
std::vector<vtkm::IdComponent> numIndices;
|
||||
std::vector<vtkm::UInt8> shapes;
|
||||
bool sameShape = true;
|
||||
std::vector<vtkm::cont::ArrayHandle<vtkm::Id> > connectivityArrays;
|
||||
std::vector<vtkm::cont::ArrayHandle<vtkm::IdComponent> > numIndicesArrays;
|
||||
std::vector<vtkm::UInt8> shapesBuffer;
|
||||
while (!this->DataFile->Stream.eof())
|
||||
{
|
||||
vtkm::CellShapeIdEnum shape = vtkm::CELL_SHAPE_EMPTY;
|
||||
vtkm::UInt8 shape = vtkm::CELL_SHAPE_EMPTY;
|
||||
this->DataFile->Stream >> tag;
|
||||
if (tag == "VERTICES")
|
||||
{
|
||||
shape = vtkm::CELL_SHAPE_VERTEX;
|
||||
shape = vtkm::io::internal::CELL_SHAPE_POLY_VERTEX;
|
||||
}
|
||||
else if (tag == "LINES")
|
||||
{
|
||||
shape = vtkm::CELL_SHAPE_LINE;
|
||||
shape = vtkm::io::internal::CELL_SHAPE_POLY_LINE;
|
||||
}
|
||||
else if (tag == "POLYGONS")
|
||||
{
|
||||
@ -69,7 +101,7 @@ private:
|
||||
}
|
||||
else if (tag == "TRIANGLE_STRIPS")
|
||||
{
|
||||
std::cerr << "Triangle strips are not supported. Skipping.";
|
||||
shape = vtkm::io::internal::CELL_SHAPE_TRIANGLE_STRIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -78,90 +110,47 @@ private:
|
||||
break;
|
||||
}
|
||||
|
||||
std::size_t prevConnLength = connectivity.size();
|
||||
std::size_t prevNumIndicesLength = numIndices.size();
|
||||
sameShape = (prevNumIndicesLength == 0);
|
||||
this->ReadCells(connectivity, numIndices);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellConnectivity;
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> cellNumIndices;
|
||||
this->ReadCells(cellConnectivity, cellNumIndices);
|
||||
|
||||
std::size_t numNewCells = prevNumIndicesLength - numIndices.size();
|
||||
std::size_t newConnSize = prevConnLength - connectivity.size();
|
||||
switch (shape)
|
||||
{
|
||||
case vtkm::CELL_SHAPE_VERTEX:
|
||||
if (newConnSize != numNewCells)
|
||||
{
|
||||
throw vtkm::io::ErrorIO("POLY_VERTEX not supported");
|
||||
}
|
||||
shapes.insert(shapes.end(), numNewCells, vtkm::CELL_SHAPE_VERTEX);
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_LINE:
|
||||
if (newConnSize != (numNewCells * 2))
|
||||
{
|
||||
throw vtkm::io::ErrorIO("POLY_LINE not supported");
|
||||
}
|
||||
shapes.insert(shapes.end(), numNewCells, vtkm::CELL_SHAPE_LINE);
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_POLYGON:
|
||||
for (std::size_t i = prevNumIndicesLength; i < numIndices.size() - 1; ++i)
|
||||
{
|
||||
switch (numIndices[i])
|
||||
{
|
||||
case 3:
|
||||
shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE);
|
||||
break;
|
||||
case 4:
|
||||
shapes.push_back(vtkm::CELL_SHAPE_QUAD);
|
||||
break;
|
||||
default:
|
||||
sameShape = false;
|
||||
shapes.push_back(vtkm::CELL_SHAPE_POLYGON);
|
||||
break;
|
||||
}
|
||||
if (i > prevNumIndicesLength && sameShape && shapes[i - 1] != shapes[i])
|
||||
{
|
||||
sameShape = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_EMPTY: // TRIANGLE_STRIPS
|
||||
continue;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
connectivityArrays.push_back(cellConnectivity);
|
||||
numIndicesArrays.push_back(cellNumIndices);
|
||||
shapesBuffer.insert(shapesBuffer.end(),
|
||||
static_cast<std::size_t>(cellNumIndices.GetNumberOfValues()),
|
||||
shape);
|
||||
}
|
||||
|
||||
if (sameShape)
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> connectivity =
|
||||
internal::ConcatinateArrayHandles(connectivityArrays);
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices =
|
||||
internal::ConcatinateArrayHandles(numIndicesArrays);
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
|
||||
shapes.Allocate(static_cast<vtkm::Id>(shapesBuffer.size()));
|
||||
std::copy(shapesBuffer.begin(), shapesBuffer.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(shapes.GetPortalControl()));
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> permutation;
|
||||
vtkm::io::internal::FixupCellSet(connectivity, numIndices, shapes, permutation);
|
||||
this->SetCellsPermutation(permutation);
|
||||
|
||||
if (vtkm::io::internal::IsSingleShape(shapes))
|
||||
{
|
||||
vtkm::cont::CellSetSingleType<> cs;
|
||||
switch(shapes[0])
|
||||
switch(shapes.GetPortalConstControl().Get(0))
|
||||
{
|
||||
case vtkm::CELL_SHAPE_VERTEX:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagVertex(),
|
||||
"cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_LINE:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagLine(),
|
||||
"cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_TRIANGLE:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagTriangle(),
|
||||
"cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_QUAD:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagQuad(),
|
||||
"cells");
|
||||
break;
|
||||
vtkmGenericCellShapeMacro(
|
||||
(cs = vtkm::cont::CellSetSingleType<>(CellShapeTag(), "cells")));
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
cs.FillViaCopy(connectivity);
|
||||
cs.Fill(connectivity);
|
||||
this->DataSet.AddCellSet(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::CellSetExplicit<> cs(0, "cells");
|
||||
cs.FillViaCopy(shapes, numIndices, connectivity);
|
||||
cs.Fill(shapes, numIndices, connectivity);
|
||||
this->DataSet.AddCellSet(cs);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
private:
|
||||
virtual void Read()
|
||||
{
|
||||
if (this->DataFile->Structure != internal::DATASET_STRUCTURED_GRID)
|
||||
if (this->DataFile->Structure != vtkm::io::internal::DATASET_STRUCTURED_GRID)
|
||||
{
|
||||
throw vtkm::io::ErrorIO("Incorrect DataSet type");
|
||||
}
|
||||
@ -45,7 +45,6 @@ private:
|
||||
|
||||
// Read structured grid specific meta-data
|
||||
vtkm::Id3 dim;
|
||||
vtkm::Vec<vtkm::Float32, 3> origin, spacing;
|
||||
this->DataFile->Stream >> tag >> dim[0] >> dim[1] >> dim[2] >> std::ws;
|
||||
internal::parseAssert(tag == "DIMENSIONS");
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
private:
|
||||
virtual void Read()
|
||||
{
|
||||
if (this->DataFile->Structure != internal::DATASET_STRUCTURED_POINTS)
|
||||
if (this->DataFile->Structure != vtkm::io::internal::DATASET_STRUCTURED_POINTS)
|
||||
{
|
||||
throw vtkm::io::ErrorIO("Incorrect DataSet type");
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
private:
|
||||
virtual void Read()
|
||||
{
|
||||
if (this->DataFile->Structure != internal::DATASET_UNSTRUCTURED_GRID)
|
||||
if (this->DataFile->Structure != vtkm::io::internal::DATASET_UNSTRUCTURED_GRID)
|
||||
{
|
||||
throw vtkm::io::ErrorIO("Incorrect DataSet type");
|
||||
}
|
||||
@ -47,65 +47,35 @@ private:
|
||||
this->ReadPoints();
|
||||
|
||||
// Read the cellset
|
||||
std::vector<vtkm::Id> connectivity;
|
||||
std::vector<vtkm::IdComponent> numIndices;
|
||||
std::vector<vtkm::UInt8> shapes;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
|
||||
|
||||
this->DataFile->Stream >> tag;
|
||||
internal::parseAssert(tag == "CELLS");
|
||||
this->ReadCells(connectivity, numIndices);
|
||||
this->ReadShapes(shapes);
|
||||
|
||||
bool sameShape = true;
|
||||
for (std::size_t i = 1; i < shapes.size(); ++i)
|
||||
{
|
||||
if (shapes[i] != shapes[i - 1])
|
||||
{
|
||||
sameShape = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> permutation;
|
||||
vtkm::io::internal::FixupCellSet(connectivity, numIndices, shapes, permutation);
|
||||
this->SetCellsPermutation(permutation);
|
||||
|
||||
if (sameShape)
|
||||
if (vtkm::io::internal::IsSingleShape(shapes))
|
||||
{
|
||||
vtkm::cont::CellSetSingleType<> cs;
|
||||
switch(shapes[0])
|
||||
switch(shapes.GetPortalConstControl().Get(0))
|
||||
{
|
||||
case vtkm::CELL_SHAPE_VERTEX:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagVertex(), "cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_LINE:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagLine(), "cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_TRIANGLE:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagTriangle(), "cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_QUAD:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagQuad(), "cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_TETRA:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagTetra(), "cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_HEXAHEDRON:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagHexahedron(), "cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_WEDGE:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagWedge(), "cells");
|
||||
break;
|
||||
case vtkm::CELL_SHAPE_PYRAMID:
|
||||
cs = vtkm::cont::CellSetSingleType<>(vtkm::CellShapeTagPyramid(), "cells");
|
||||
break;
|
||||
vtkmGenericCellShapeMacro((cs = vtkm::cont::CellSetSingleType<>(CellShapeTag(), "cells")));
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
cs.FillViaCopy(connectivity);
|
||||
cs.Fill(connectivity);
|
||||
this->DataSet.AddCellSet(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::CellSetExplicit<> cs(0, "cells");
|
||||
cs.FillViaCopy(shapes, numIndices, connectivity);
|
||||
cs.Fill(shapes, numIndices, connectivity);
|
||||
this->DataSet.AddCellSet(cs);
|
||||
}
|
||||
|
||||
|
@ -139,33 +139,32 @@ const char unsturctureGridAscii[] =
|
||||
"Unstructured Grid Example\n"
|
||||
"ASCII\n"
|
||||
"DATASET UNSTRUCTURED_GRID\n"
|
||||
"POINTS 27 float\n"
|
||||
"0 0 0 1 0 0 2 0 0 0 1 0 1 1 0 2 1 0 0 0 1 1 0 1 2 0 1 0 1 1\n"
|
||||
"1 1 1 2 1 1 0 1 2 1 1 2 2 1 2 0 1 3 1 1 3 2 1 3 0 1 4 1 1 4\n"
|
||||
"2 1 4 0 1 5 1 1 5 2 1 5 0 1 6 1 1 6 2 1 6\n"
|
||||
"CELLS 11 60\n"
|
||||
"8 0 1 4 3 6 7 10 9 8 1 2 5 4 7 8 11 10 4 6 10 9 12 4 5 11 10 14\n"
|
||||
"6 15 16 17 14 13 12 6 18 15 19 16 20 17 4 22 23 20 19 3 21 22 18\n"
|
||||
"3 22 19 18 2 26 25 1 24\n"
|
||||
"CELL_TYPES 11\n"
|
||||
"12 12 10 10 7 6 9 5 5 3 1\n"
|
||||
"POINT_DATA 27\n"
|
||||
"POINTS 26 float\n"
|
||||
"0 0 0 1 0 0 2 0 0 0 1 0 1 1 0 2 1 0 0 0 1 1 0 1 2 0 1\n"
|
||||
"0 1 1 1 1 1 2 1 1 0.5 1.7 0.5 1.5 1.7 0.5 0 1 2 1 1 2 2 1 2\n"
|
||||
"0 1 3 1 1 3 2 1 3 0 1 4 1 1 4 2 1 4 0 1 5 1 1 5 2 1 5\n"
|
||||
"CELLS 12 64\n"
|
||||
"8 0 1 4 3 6 7 10 9 6 1 7 2 4 10 5 6 2 7 8 5 10 11 5 4 3 9 10 12\n"
|
||||
"4 5 4 10 13 4 5 10 11 13 6 17 14 18 15 19 16 4 21 22 19 18\n"
|
||||
"3 20 21 17 3 21 18 17 2 25 24 1 23\n"
|
||||
"CELL_TYPES 12\n"
|
||||
"12 13 13 14 10 10 6 9 5 5 3 1\n"
|
||||
"POINT_DATA 26\n"
|
||||
"SCALARS scalars float 1\n"
|
||||
"LOOKUP_TABLE default\n"
|
||||
"0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0\n"
|
||||
"12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0\n"
|
||||
"24.0 25.0 26.0\n"
|
||||
"0 1 2 3 4 5 6 7 8 9 10 11 12\n"
|
||||
"13 14 15 16 17 18 19 20 21 22 23 24 25\n"
|
||||
"VECTORS vectors float\n"
|
||||
"1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0 1 0 0\n"
|
||||
"1 1 0 0 2 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1\n"
|
||||
"0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1\n";
|
||||
"1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0 1 0 0 1 1 0 0 2 0\n"
|
||||
"1 0 0 1 1 0 0 2 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1\n"
|
||||
"0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1\n";
|
||||
|
||||
const char unsturctureGridBin[] =
|
||||
"# vtk DataFile Version 4.0\n"
|
||||
"Unstructured Grid Example\n"
|
||||
"BINARY\n"
|
||||
"DATASET UNSTRUCTURED_GRID\n"
|
||||
"POINTS 27 float\n"
|
||||
"POINTS 26 float\n"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00"
|
||||
@ -173,35 +172,34 @@ const char unsturctureGridBin[] =
|
||||
"\x3f\x80\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x40\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00"
|
||||
"\x3f\x80\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x3f\x80\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x3f\x80\x00\x00\x40\x00\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00\x40\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x40\x40\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00"
|
||||
"\x40\x40\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00\x40\x40\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x40\x80\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00\x40\x80\x00\x00"
|
||||
"\x40\x00\x00\x00\x3f\x80\x00\x00\x40\x80\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x40\xa0\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00\x40\xa0\x00\x00\x40\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x40\xa0\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x40\xc0\x00\x00"
|
||||
"\x3f\x80\x00\x00\x3f\x80\x00\x00\x40\xc0\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x40\xc0\x00\x00\n"
|
||||
"CELLS 11 60\n"
|
||||
"\x3f\x80\x00\x00\x3f\x00\x00\x00\x3f\xd9\x99\x9a\x3f\x00\x00\x00\x3f\xc0\x00\x00"
|
||||
"\x3f\xd9\x99\x9a\x3f\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x40\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x3f\x80\x00\x00\x40\x00\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x40\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x40\x40\x00\x00\x3f\x80\x00\x00"
|
||||
"\x3f\x80\x00\x00\x40\x40\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00\x40\x40\x00\x00"
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x40\x80\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00"
|
||||
"\x40\x80\x00\x00\x40\x00\x00\x00\x3f\x80\x00\x00\x40\x80\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x40\xa0\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00\x40\xa0\x00\x00"
|
||||
"\x40\x00\x00\x00\x3f\x80\x00\x00\x40\xa0\x00\x00\n"
|
||||
"CELLS 12 64\n"
|
||||
"\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x04\x00\x00\x00\x03"
|
||||
"\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x0a\x00\x00\x00\x09\x00\x00\x00\x08"
|
||||
"\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x00\x07"
|
||||
"\x00\x00\x00\x08\x00\x00\x00\x0b\x00\x00\x00\x0a\x00\x00\x00\x04\x00\x00\x00\x06"
|
||||
"\x00\x00\x00\x0a\x00\x00\x00\x09\x00\x00\x00\x0c\x00\x00\x00\x04\x00\x00\x00\x05"
|
||||
"\x00\x00\x00\x0b\x00\x00\x00\x0a\x00\x00\x00\x0e\x00\x00\x00\x06\x00\x00\x00\x0f"
|
||||
"\x00\x00\x00\x10\x00\x00\x00\x11\x00\x00\x00\x0e\x00\x00\x00\x0d\x00\x00\x00\x0c"
|
||||
"\x00\x00\x00\x06\x00\x00\x00\x12\x00\x00\x00\x0f\x00\x00\x00\x13\x00\x00\x00\x10"
|
||||
"\x00\x00\x00\x14\x00\x00\x00\x11\x00\x00\x00\x04\x00\x00\x00\x16\x00\x00\x00\x17"
|
||||
"\x00\x00\x00\x14\x00\x00\x00\x13\x00\x00\x00\x03\x00\x00\x00\x15\x00\x00\x00\x16"
|
||||
"\x00\x00\x00\x12\x00\x00\x00\x03\x00\x00\x00\x16\x00\x00\x00\x13\x00\x00\x00\x12"
|
||||
"\x00\x00\x00\x02\x00\x00\x00\x1a\x00\x00\x00\x19\x00\x00\x00\x01\x00\x00\x00\x18"
|
||||
"\n"
|
||||
"CELL_TYPES 11\n"
|
||||
"\x00\x00\x00\x0c\x00\x00\x00\x0c\x00\x00\x00\x0a\x00\x00\x00\x0a\x00\x00\x00\x07"
|
||||
"\x00\x00\x00\x06\x00\x00\x00\x09\x00\x00\x00\x05\x00\x00\x00\x05\x00\x00\x00\x03"
|
||||
"\x00\x00\x00\x01\n"
|
||||
"POINT_DATA 27\n"
|
||||
"\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x0a\x00\x00\x00\x09\x00\x00\x00\x06"
|
||||
"\x00\x00\x00\x01\x00\x00\x00\x07\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x0a"
|
||||
"\x00\x00\x00\x05\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x07\x00\x00\x00\x08"
|
||||
"\x00\x00\x00\x05\x00\x00\x00\x0a\x00\x00\x00\x0b\x00\x00\x00\x05\x00\x00\x00\x04"
|
||||
"\x00\x00\x00\x03\x00\x00\x00\x09\x00\x00\x00\x0a\x00\x00\x00\x0c\x00\x00\x00\x04"
|
||||
"\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x00\x0a\x00\x00\x00\x0d\x00\x00\x00\x04"
|
||||
"\x00\x00\x00\x05\x00\x00\x00\x0a\x00\x00\x00\x0b\x00\x00\x00\x0d\x00\x00\x00\x06"
|
||||
"\x00\x00\x00\x11\x00\x00\x00\x0e\x00\x00\x00\x12\x00\x00\x00\x0f\x00\x00\x00\x13"
|
||||
"\x00\x00\x00\x10\x00\x00\x00\x04\x00\x00\x00\x15\x00\x00\x00\x16\x00\x00\x00\x13"
|
||||
"\x00\x00\x00\x12\x00\x00\x00\x03\x00\x00\x00\x14\x00\x00\x00\x15\x00\x00\x00\x11"
|
||||
"\x00\x00\x00\x03\x00\x00\x00\x15\x00\x00\x00\x12\x00\x00\x00\x11\x00\x00\x00\x02"
|
||||
"\x00\x00\x00\x19\x00\x00\x00\x18\x00\x00\x00\x01\x00\x00\x00\x17\n"
|
||||
"CELL_TYPES 12\n"
|
||||
"\x00\x00\x00\x0c\x00\x00\x00\x0d\x00\x00\x00\x0d\x00\x00\x00\x0e\x00\x00\x00\x0a"
|
||||
"\x00\x00\x00\x0a\x00\x00\x00\x06\x00\x00\x00\x09\x00\x00\x00\x05\x00\x00\x00\x05"
|
||||
"\x00\x00\x00\x03\x00\x00\x00\x01\n"
|
||||
"POINT_DATA 26\n"
|
||||
"SCALARS scalars float\n"
|
||||
"LOOKUP_TABLE default\n"
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x40\x00\x00\x00\x40\x40\x00\x00\x40\x80\x00\x00"
|
||||
@ -209,7 +207,7 @@ const char unsturctureGridBin[] =
|
||||
"\x41\x20\x00\x00\x41\x30\x00\x00\x41\x40\x00\x00\x41\x50\x00\x00\x41\x60\x00\x00"
|
||||
"\x41\x70\x00\x00\x41\x80\x00\x00\x41\x88\x00\x00\x41\x90\x00\x00\x41\x98\x00\x00"
|
||||
"\x41\xa0\x00\x00\x41\xa8\x00\x00\x41\xb0\x00\x00\x41\xb8\x00\x00\x41\xc0\x00\x00"
|
||||
"\x41\xc8\x00\x00\x41\xd0\x00\x00\n"
|
||||
"\x41\xc8\x00\x00\n"
|
||||
"VECTORS vectors float\n"
|
||||
"\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00"
|
||||
@ -218,16 +216,15 @@ const char unsturctureGridBin[] =
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x40\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x3f\x80\x00\x00\n";
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x3f\x80\x00\x00\n";
|
||||
|
||||
inline void createFile(const char *buffer, std::size_t size, const char *fname)
|
||||
{
|
||||
@ -314,9 +311,9 @@ void TestReadingUnstructuredGrid(Format format)
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2,
|
||||
"Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 27,
|
||||
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 26,
|
||||
"Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetCellSet().GetNumberOfCells() == 11,
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetCellSet().GetNumberOfCells() == 15,
|
||||
"Incorrect number of cells");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().IsType(vtkm::cont::CellSetExplicit<>()),
|
||||
"Incorrect cellset type");
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/io/internal/VTKDataSetTypes.h>
|
||||
|
||||
namespace {
|
||||
#define VTK_EMPTY_CELL 0
|
||||
@ -156,51 +157,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct DataTypeName
|
||||
{
|
||||
static const char* Name() { return "unknown"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int8>
|
||||
{
|
||||
static const char* Name() { return "char"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt8>
|
||||
{
|
||||
static const char* Name() { return "unsigned_char"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int16>
|
||||
{
|
||||
static const char* Name() { return "short"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt16>
|
||||
{
|
||||
static const char* Name() { return "unsigned_short"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int32>
|
||||
{
|
||||
static const char* Name() { return "int"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt32>
|
||||
{
|
||||
static const char* Name() { return "unsigned_int"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Int64>
|
||||
{
|
||||
static const char* Name() { return "long"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::UInt64>
|
||||
{
|
||||
static const char* Name() { return "unsigned_long"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Float32>
|
||||
{
|
||||
static const char* Name() { return "float"; }
|
||||
};
|
||||
template <> struct DataTypeName<vtkm::Float64>
|
||||
{
|
||||
static const char* Name() { return "double"; }
|
||||
};
|
||||
|
||||
class GetDataTypeName
|
||||
{
|
||||
public:
|
||||
@ -213,7 +169,7 @@ public:
|
||||
{
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType::ValueType>::ComponentType
|
||||
DataType;
|
||||
*this->Name = DataTypeName<DataType>::Name();
|
||||
*this->Name = vtkm::io::internal::DataTypeName<DataType>::Name();
|
||||
}
|
||||
private:
|
||||
std::string *Name;
|
||||
|
Loading…
Reference in New Issue
Block a user