mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Compound datatypes for writer.
This commit is contained in:
parent
23a202b881
commit
b3d170f2d9
@ -235,12 +235,14 @@ private:
|
||||
}
|
||||
|
||||
std::string typeName;
|
||||
vtkm::cont::CastAndCall(field, detail::GetDataTypeName(typeName));
|
||||
vtkm::cont::CastAndCall(field.GetData().ResetTypes(TypeListAll{}),
|
||||
detail::GetDataTypeName(typeName));
|
||||
|
||||
out << "SCALARS " << field.GetName() << " " << typeName << " " << ncomps << std::endl;
|
||||
out << "LOOKUP_TABLE default" << std::endl;
|
||||
|
||||
vtkm::cont::CastAndCall(field, detail::OutputFieldFunctor(out));
|
||||
vtkm::cont::CastAndCall(field.GetData().ResetTypes(TypeListAll{}),
|
||||
detail::OutputFieldFunctor(out));
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,12 +270,14 @@ private:
|
||||
}
|
||||
|
||||
std::string typeName;
|
||||
vtkm::cont::CastAndCall(field, detail::GetDataTypeName(typeName));
|
||||
vtkm::cont::CastAndCall(field.GetData().ResetTypes(TypeListAll{}),
|
||||
detail::GetDataTypeName(typeName));
|
||||
|
||||
out << "SCALARS " << field.GetName() << " " << typeName << " " << ncomps << std::endl;
|
||||
out << "LOOKUP_TABLE default" << std::endl;
|
||||
|
||||
vtkm::cont::CastAndCall(field, detail::OutputFieldFunctor(out));
|
||||
vtkm::cont::CastAndCall(field.GetData().ResetTypes(TypeListAll{}),
|
||||
detail::OutputFieldFunctor(out));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <vtkm/io/writer/VTKDataSetWriter.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
@ -90,11 +93,50 @@ void TestVTKRectilinearWrite()
|
||||
writer.WriteDataSet(tds.Make3DRectilinearDataSet0(), true);
|
||||
}
|
||||
|
||||
void TestVTKCompoundWrite()
|
||||
{
|
||||
double s_min = 0.00001;
|
||||
double s_max = 1.0;
|
||||
double t_min = -2.0;
|
||||
double t_max = 2.0;
|
||||
int s_samples = 16;
|
||||
vtkm::cont::DataSetBuilderUniform dsb;
|
||||
vtkm::Id2 dims(s_samples, s_samples);
|
||||
vtkm::Vec2f_64 origin(t_min, s_min);
|
||||
vtkm::Float64 ds = (s_max - s_min) / vtkm::Float64(dims[0] - 1);
|
||||
vtkm::Float64 dt = (t_max - t_min) / vtkm::Float64(dims[1] - 1);
|
||||
vtkm::Vec2f_64 spacing(dt, ds);
|
||||
vtkm::cont::DataSet dataSet = dsb.Create(dims, origin, spacing);
|
||||
vtkm::cont::DataSetFieldAdd dsf;
|
||||
size_t nVerts = static_cast<size_t>(s_samples * s_samples);
|
||||
std::vector<vtkm::Vec2f_64> points(nVerts);
|
||||
|
||||
size_t idx = 0;
|
||||
for (vtkm::Id y = 0; y < dims[0]; ++y)
|
||||
{
|
||||
for (vtkm::Id x = 0; x < dims[1]; ++x)
|
||||
{
|
||||
double s = s_min + y * ds;
|
||||
double t = t_min + x * dt;
|
||||
// This function is not meaningful:
|
||||
auto z = std::exp(std::complex<double>(s, t));
|
||||
points[idx] = { std::sqrt(std::norm(z)), std::arg(z) };
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
dsf.AddPointField(dataSet, "z", points.data(), static_cast<vtkm::Id>(points.size()));
|
||||
vtkm::io::writer::VTKDataSetWriter writer("chirp.vtk");
|
||||
writer.WriteDataSet(dataSet);
|
||||
std::remove("chirp.vtk");
|
||||
}
|
||||
|
||||
void TestVTKWrite()
|
||||
{
|
||||
TestVTKExplicitWrite();
|
||||
TestVTKUniformWrite();
|
||||
TestVTKRectilinearWrite();
|
||||
TestVTKCompoundWrite();
|
||||
}
|
||||
|
||||
} //Anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user