Commit 925f0524 authored by Allison Vacanti's avatar Allison Vacanti Committed by Kitware Robot

Merge topic 'range_dispatch_misc_2'

462d04d6 Remove GetVoidPointer usage in vtkFieldDataSerializer.
a6c79a6b Remove GetVoidPointer usage from vtkBMPWriter.
9c574739 Remove GetVoidPointer usage from vtkPointCloudFilter.
2399a9bc Remove GetVoidPointer usage from vtkMaskPointsFilter.
a0b8779e Remove GetVoidPointer usage from vtkExtractEnclosedPoints.
350d8874 Remove GetVoidPointer usage from vtkRandomPool.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !6233
parents 2cd2b99f 462d04d6
......@@ -12,7 +12,10 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkRandomPool.h"
#include "vtkArrayDispatch.h"
#include "vtkDataArray.h"
#include "vtkDataArrayRange.h"
#include "vtkMath.h"
#include "vtkMersenneTwister.h"
#include "vtkMinimalStandardRandomSequence.h"
......@@ -21,6 +24,7 @@
#include "vtkObjectFactory.h"
#include "vtkSMPTools.h"
#include <algorithm>
#include <cassert>
vtkStandardNewMacro(vtkRandomPool);
......@@ -32,15 +36,16 @@ namespace
{
// This method scales all components between (min,max)
template <typename T>
template <typename ArrayT>
struct PopulateDA
{
using T = vtk::GetAPIType<ArrayT>;
const double* Pool;
T* Array;
ArrayT* Array;
T Min;
T Max;
PopulateDA(const double* pool, T* array, double min, double max)
PopulateDA(const double* pool, ArrayT* array, double min, double max)
: Pool(pool)
, Array(array)
{
......@@ -52,41 +57,44 @@ struct PopulateDA
void operator()(vtkIdType dataId, vtkIdType endDataId)
{
const double* p = this->Pool + dataId;
T* array = this->Array + dataId;
double range = static_cast<double>(this->Max - this->Min);
const double* pool = this->Pool + dataId;
const double* poolEnd = this->Pool + endDataId;
const double range = static_cast<double>(this->Max - this->Min);
for (; dataId < endDataId; ++dataId, ++array, ++p)
{
*array = this->Min + static_cast<T>(*p * range);
}
auto output = vtk::DataArrayValueRange(this->Array, dataId, endDataId);
std::transform(pool, poolEnd, output.begin(),
[&](const double p) -> T { return this->Min + static_cast<T>(p * range); });
}
void Reduce() {}
};
static void Execute(const double* pool, T* array, double min, double max, vtkIdType totalSize)
struct PopulateLauncher
{
template <typename ArrayT>
void operator()(ArrayT* array, const double* pool, double min, double max) const
{
PopulateDA popDA(pool, array, min, max);
vtkSMPTools::For(0, totalSize, popDA);
PopulateDA<ArrayT> popDA{ pool, array, min, max };
vtkSMPTools::For(0, array->GetNumberOfValues(), popDA);
}
};
// This method scales a selected component between (min,max)
template <typename T>
template <typename ArrayT>
struct PopulateDAComponent
{
using T = vtk::GetAPIType<ArrayT>;
const double* Pool;
T* Array;
int NumComp;
ArrayT* Array;
int CompNum;
T Min;
T Max;
PopulateDAComponent(
const double* pool, T* array, double min, double max, int numComp, int compNum)
PopulateDAComponent(const double* pool, ArrayT* array, double min, double max, int compNum)
: Pool(pool)
, Array(array)
, NumComp(numComp)
, CompNum(compNum)
{
this->Min = static_cast<T>(min);
......@@ -97,24 +105,34 @@ struct PopulateDAComponent
void operator()(vtkIdType tupleId, vtkIdType endTupleId)
{
int numComp = this->NumComp;
const double* p = this->Pool + tupleId * numComp + this->CompNum;
T* array = this->Array + tupleId * numComp + this->CompNum;
double range = static_cast<double>(this->Max - this->Min);
const int numComp = this->Array->GetNumberOfComponents();
const double range = static_cast<double>(this->Max - this->Min);
for (; tupleId < endTupleId; ++tupleId, array += numComp, p += numComp)
const vtkIdType valueId = tupleId * numComp + this->CompNum;
const vtkIdType endValueId = endTupleId * numComp;
const double* poolIter = this->Pool + valueId;
const double* poolEnd = this->Pool + endValueId;
auto data = vtk::DataArrayValueRange(this->Array, valueId, endValueId);
auto dataIter = data.begin();
for (; poolIter < poolEnd; dataIter += numComp, poolIter += numComp)
{
*array = this->Min + static_cast<T>(*p * range);
*dataIter = this->Min + static_cast<T>(*poolIter * range);
}
}
void Reduce() {}
};
static void Execute(
const double* pool, T* array, double min, double max, vtkIdType size, int numComp, int compNum)
struct PopulateDAComponentLauncher
{
template <typename ArrayT>
void operator()(ArrayT* array, const double* pool, double min, double max, int compNum)
{
PopulateDAComponent popDAC(pool, array, min, max, numComp, compNum);
vtkSMPTools::For(0, size, popDAC);
PopulateDAComponent<ArrayT> popDAC{ pool, array, min, max, compNum };
vtkSMPTools::For(0, array->GetNumberOfTuples(), popDAC);
}
};
......@@ -164,11 +182,11 @@ void vtkRandomPool::PopulateDataArray(vtkDataArray* da, double minRange, double
}
// Now perform the scaling of all components
void* ptr = da->GetVoidPointer(0);
switch (da->GetDataType())
{
vtkTemplateMacro(
PopulateDA<VTK_TT>::Execute(pool, (VTK_TT*)ptr, minRange, maxRange, this->GetTotalSize()));
using Dispatcher = vtkArrayDispatch::Dispatch;
PopulateLauncher worker;
if (!Dispatcher::Execute(da, worker, pool, minRange, maxRange))
{ // Fallback for unknown array types:
worker(da, pool, minRange, maxRange);
}
// Make sure that the data array is marked modified
......@@ -198,11 +216,11 @@ void vtkRandomPool::PopulateDataArray(
}
// Now perform the scaling for one of the components
void* ptr = da->GetVoidPointer(0);
switch (da->GetDataType())
{
vtkTemplateMacro(PopulateDAComponent<VTK_TT>::Execute(
pool, (VTK_TT*)ptr, minRange, maxRange, size, numComp, compNum));
using Dispatcher = vtkArrayDispatch::Dispatch;
PopulateDAComponentLauncher worker;
if (!Dispatcher::Execute(da, worker, pool, minRange, maxRange, compNum))
{ // fallback
worker(da, pool, minRange, maxRange, compNum);
}
// Make sure that the data array is marked modified
......
......@@ -14,7 +14,9 @@
=========================================================================*/
#include "vtkExtractEnclosedPoints.h"
#include "vtkArrayDispatch.h"
#include "vtkCellData.h"
#include "vtkDataArrayRange.h"
#include "vtkDataSet.h"
#include "vtkExecutive.h"
#include "vtkFeatureEdges.h"
......@@ -37,6 +39,8 @@
#include "vtkStaticCellLocator.h"
#include "vtkUnsignedCharArray.h"
#include <algorithm>
vtkStandardNewMacro(vtkExtractEnclosedPoints);
//----------------------------------------------------------------------------
......@@ -47,11 +51,10 @@ namespace
//----------------------------------------------------------------------------
// The threaded core of the algorithm. Thread on point type.
template <typename T>
template <typename ArrayT>
struct ExtractInOutCheck
{
vtkIdType NumPts;
T* Points;
ArrayT* Points;
vtkPolyData* Surface;
double Bounds[6];
double Length;
......@@ -66,15 +69,16 @@ struct ExtractInOutCheck
vtkSMPThreadLocalObject<vtkIdList> CellIds;
vtkSMPThreadLocalObject<vtkGenericCell> Cell;
ExtractInOutCheck(vtkIdType numPts, T* pts, vtkPolyData* surface, double bds[6], double tol,
ExtractInOutCheck(ArrayT* pts, vtkPolyData* surface, double bds[6], double tol,
vtkStaticCellLocator* loc, vtkIdType* map)
: NumPts(numPts)
, Points(pts)
: Points(pts)
, Surface(surface)
, Tolerance(tol)
, Locator(loc)
, PointMap(map)
{
const vtkIdType numPts = pts->GetNumberOfTuples();
this->Bounds[0] = bds[0];
this->Bounds[1] = bds[1];
this->Bounds[2] = bds[2];
......@@ -86,7 +90,7 @@ struct ExtractInOutCheck
// Precompute a sufficiently large enough random sequence
this->Sequence = vtkRandomPool::New();
this->Sequence->SetSize((numPts > 1500 ? numPts : 1500));
this->Sequence->SetSize(std::max(numPts, vtkIdType{ 1500 }));
this->Sequence->GeneratePool();
}
......@@ -103,18 +107,20 @@ struct ExtractInOutCheck
void operator()(vtkIdType ptId, vtkIdType endPtId)
{
double x[3];
const T* pts = this->Points + 3 * ptId;
const auto points = vtk::DataArrayTupleRange(this->Points);
vtkIdType* map = this->PointMap + ptId;
vtkGenericCell*& cell = this->Cell.Local();
vtkIdList*& cellIds = this->CellIds.Local();
vtkIdType hit;
vtkIntersectionCounter& counter = this->Counter.Local();
for (; ptId < endPtId; ++ptId, pts += 3)
for (; ptId < endPtId; ++ptId)
{
x[0] = static_cast<double>(pts[0]);
x[1] = static_cast<double>(pts[1]);
x[2] = static_cast<double>(pts[2]);
const auto pt = points[ptId];
x[0] = static_cast<double>(pt[0]);
x[1] = static_cast<double>(pt[1]);
x[2] = static_cast<double>(pt[2]);
hit = vtkSelectEnclosedPoints::IsInsideSurface(x, this->Surface, this->Bounds, this->Length,
this->Tolerance, this->Locator, cellIds, cell, counter, this->Sequence, ptId);
......@@ -123,14 +129,18 @@ struct ExtractInOutCheck
}
void Reduce() {}
}; // ExtractInOutCheck
static void Execute(vtkIdType numPts, T* pts, vtkPolyData* surface, double bds[6], double tol,
struct ExtractLauncher
{
template <typename ArrayT>
void operator()(ArrayT* pts, vtkPolyData* surface, double bds[6], double tol,
vtkStaticCellLocator* loc, vtkIdType* hits)
{
ExtractInOutCheck inOut(numPts, pts, surface, bds, tol, loc, hits);
vtkSMPTools::For(0, numPts, inOut);
ExtractInOutCheck<ArrayT> inOut(pts, surface, bds, tol, loc, hits);
vtkSMPTools::For(0, pts->GetNumberOfTuples(), inOut);
}
}; // ExtractInOutCheck
};
} // anonymous namespace
......@@ -194,12 +204,14 @@ int vtkExtractEnclosedPoints::FilterPoints(vtkPointSet* input)
locator->BuildLocator();
// Loop over all input points determining inside/outside
vtkIdType numPts = input->GetNumberOfPoints();
void* inPtr = input->GetPoints()->GetVoidPointer(0);
switch (input->GetPoints()->GetDataType())
{
vtkTemplateMacro(ExtractInOutCheck<VTK_TT>::Execute(
numPts, (VTK_TT*)inPtr, surface, bds, this->Tolerance, locator, this->PointMap));
// Use fast path for float/double points:
using vtkArrayDispatch::Reals;
using Dispatcher = vtkArrayDispatch::DispatchByValueType<Reals>;
ExtractLauncher worker;
vtkDataArray* ptArray = input->GetPoints()->GetData();
if (!Dispatcher::Execute(ptArray, worker, surface, bds, this->Tolerance, locator, this->PointMap))
{ // fallback for other arrays:
worker(ptArray, surface, bds, this->Tolerance, locator, this->PointMap);
}
// Clean up and get out
......
......@@ -14,6 +14,8 @@
=========================================================================*/
#include "vtkMaskPointsFilter.h"
#include "vtkArrayDispatch.h"
#include "vtkDataArrayRange.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
......@@ -32,76 +34,54 @@ namespace
//----------------------------------------------------------------------------
// The threaded core of the algorithm
template <typename T>
struct ExtractPoints
{
unsigned char* Mask;
unsigned char EmptyValue;
const T* Points;
vtkIdType* PointMap;
double hX, hY, hZ; // internal data members for performance
double fX, fY, fZ, bX, bY, bZ;
vtkIdType xD, yD, zD, xyD;
ExtractPoints(unsigned char* mask, unsigned char ev, int dims[3], double origin[3],
double spacing[3], T* points, vtkIdType* map)
: Mask(mask)
, EmptyValue(ev)
, Points(points)
, PointMap(map)
template <typename PtArrayT>
void operator()(PtArrayT* ptArray, const unsigned char* mask, unsigned char emptyValue,
int dims[3], double origin[3], double spacing[3], vtkIdType* pointMap) const
{
this->hX = spacing[0];
this->hY = spacing[1];
this->hZ = spacing[2];
this->fX = 1.0 / spacing[0];
this->fY = 1.0 / spacing[1];
this->fZ = 1.0 / spacing[2];
this->bX = origin[0] - 0.5 * this->hX;
this->bY = origin[1] - 0.5 * this->hY;
this->bZ = origin[2] - 0.5 * this->hZ;
this->xD = dims[0];
this->yD = dims[1];
this->zD = dims[2];
this->xyD = dims[0] * dims[1];
const vtkIdType numPts = ptArray->GetNumberOfTuples();
const double fX = 1.0 / spacing[0];
const double fY = 1.0 / spacing[1];
const double fZ = 1.0 / spacing[2];
const double bX = origin[0] - 0.5 * spacing[0];
const double bY = origin[1] - 0.5 * spacing[1];
const double bZ = origin[2] - 0.5 * spacing[2];
const vtkIdType xD = dims[0];
const vtkIdType yD = dims[1];
const vtkIdType zD = dims[2];
const vtkIdType xyD = dims[0] * dims[1];
vtkSMPTools::For(0, numPts, [&](vtkIdType ptId, vtkIdType endPtId) {
const auto pts = vtk::DataArrayTupleRange<3>(ptArray, ptId, endPtId);
using PtCRefT = typename decltype(pts)::ConstTupleReferenceType;
vtkIdType* map = pointMap + ptId;
std::transform(pts.cbegin(), pts.cend(), map, [&](PtCRefT pt) -> vtkIdType {
const int i = static_cast<int>(((pt[0] - bX) * fX));
const int j = static_cast<int>(((pt[1] - bY) * fY));
const int k = static_cast<int>(((pt[2] - bZ) * fZ));
// If not inside image then skip
if (i < 0 || i >= xD || j < 0 || j >= yD || k < 0 || k >= zD)
{
return -1;
}
else if (mask[i + j * xD + k * xyD] != emptyValue)
{
return 1;
}
else
{
return -1;
}
});
});
}
void operator()(vtkIdType ptId, vtkIdType endPtId)
{
const T* x = this->Points + 3 * ptId;
vtkIdType* map = this->PointMap + ptId;
const unsigned char* mask = this->Mask;
const unsigned char emptyValue = this->EmptyValue;
int i, j, k;
for (; ptId < endPtId; ++ptId, x += 3, ++map)
{
i = static_cast<int>(((x[0] - this->bX) * this->fX));
j = static_cast<int>(((x[1] - this->bY) * this->fY));
k = static_cast<int>(((x[2] - this->bZ) * this->fZ));
// If not inside image then skip
if (i < 0 || i >= this->xD || j < 0 || j >= this->yD || k < 0 || k >= this->zD)
{
*map = -1;
}
else if (mask[i + j * this->xD + k * this->xyD] != emptyValue)
{
*map = 1;
}
else
{
*map = -1;
}
}
}
static void Execute(unsigned char* mask, unsigned char ev, int dims[3], double origin[3],
double spacing[3], vtkIdType numPts, T* points, vtkIdType* map)
{
ExtractPoints extract(mask, ev, dims, origin, spacing, points, map);
vtkSMPTools::For(0, numPts, extract);
}
}; // ExtractPoints
} // anonymous namespace
......@@ -176,12 +156,15 @@ int vtkMaskPointsFilter::FilterPoints(vtkPointSet* input)
// Determine which points, if any, should be removed. We create a map
// to keep track. The bulk of the algorithmic work is done in this pass.
vtkIdType numPts = input->GetNumberOfPoints();
void* inPtr = input->GetPoints()->GetVoidPointer(0);
switch (input->GetPoints()->GetDataType())
{
vtkTemplateMacro(ExtractPoints<VTK_TT>::Execute(
m, ev, dims, origin, spacing, numPts, (VTK_TT*)inPtr, this->PointMap));
vtkDataArray* ptArray = input->GetPoints()->GetData();
// Use a fast path for double/float points:
using vtkArrayDispatch::Reals;
using Dispatcher = vtkArrayDispatch::DispatchByValueType<Reals>;
ExtractPoints worker;
if (!Dispatcher::Execute(ptArray, worker, m, ev, dims, origin, spacing, this->PointMap))
{ // fallback for weird types
worker(ptArray, m, ev, dims, origin, spacing, this->PointMap);
}
return 1;
......
......@@ -15,8 +15,10 @@
#include "vtkPointCloudFilter.h"
#include "vtkAbstractPointLocator.h"
#include "vtkArrayDispatch.h"
#include "vtkArrayListTemplate.h" // For processing attribute data
#include "vtkDataArray.h"
#include "vtkDataArrayRange.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkMath.h"
......@@ -36,102 +38,60 @@ namespace
//----------------------------------------------------------------------------
// Map input points to output. Basically the third pass of the algorithm.
template <typename T>
struct MapPoints
{
T* InPoints;
T* OutPoints;
const vtkIdType* PointMap;
ArrayList Arrays;
MapPoints(vtkIdType, T* inPts, vtkIdType numOutPts, T* outPts, vtkIdType* map, vtkPointData* inPD,
vtkPointData* outPD)
: InPoints(inPts)
, OutPoints(outPts)
, PointMap(map)
template <typename InPointsT, typename OutPointsT>
void operator()(InPointsT* inPointsArray, OutPointsT* outPointsArray, vtkIdType* map,
vtkPointData* inPD, vtkPointData* outPD)
{
this->Arrays.AddArrays(numOutPts, inPD, outPD, 0.0, false);
}
const auto inPts = vtk::DataArrayTupleRange<3>(inPointsArray);
auto outPts = vtk::DataArrayTupleRange<3>(outPointsArray);
void operator()(vtkIdType ptId, vtkIdType endPtId)
{
T *inP, *outP;
const vtkIdType* map = this->PointMap;
vtkIdType outPtId;
ArrayList arrays;
arrays.AddArrays(outPts.size(), inPD, outPD, 0.0, false);
for (; ptId < endPtId; ++ptId)
{
outPtId = map[ptId];
if (outPtId != -1)
vtkSMPTools::For(0, inPts.size(), [&](vtkIdType ptId, vtkIdType endPtId) {
for (; ptId < endPtId; ++ptId)
{
inP = this->InPoints + 3 * ptId;
outP = this->OutPoints + 3 * outPtId;
*outP++ = *inP++;
*outP++ = *inP++;
*outP = *inP;
this->Arrays.Copy(ptId, outPtId);
const vtkIdType outPtId = map[ptId];
if (outPtId != -1)
{
outPts[outPtId] = inPts[ptId];
arrays.Copy(ptId, outPtId);
}
}
}
}
static void Execute(vtkIdType numInPts, T* inPts, vtkIdType numOutPts, T* outPts, vtkIdType* map,
vtkPointData* inPD, vtkPointData* outPD)
{
MapPoints copy(numInPts, inPts, numOutPts, outPts, map, inPD, outPD);
vtkSMPTools::For(0, numInPts, copy);
});
}
}; // MapPoints
};
//----------------------------------------------------------------------------
// Map outlier points to second output. This is an optional pass of the
// algorithm.
template <typename T>
struct MapOutliers
{
T* InPoints;
T* OutPoints;
const vtkIdType* PointMap;
ArrayList Arrays;
MapOutliers(vtkIdType, T* inPts, vtkIdType numOutPts, T* outPts, vtkIdType* map,
vtkPointData* inPD, vtkPointData* outPD2)
: InPoints(inPts)
, OutPoints(outPts)
, PointMap(map)
template <typename InPointsT, typename OutPointsT>
void operator()(InPointsT* inPtArray, OutPointsT* outPtArray, vtkIdType* map, vtkPointData* inPD,
vtkPointData* outPD)
{
this->Arrays.AddArrays(numOutPts, inPD, outPD2, 0.0, false);
}
const auto inPts = vtk::DataArrayTupleRange<3>(inPtArray);
auto outPts = vtk::DataArrayTupleRange<3>(outPtArray);
void operator()(vtkIdType ptId, vtkIdType endPtId)
{
T *inP, *outP;
const vtkIdType* map = this->PointMap;
vtkIdType outPtId;
ArrayList arrays;
arrays.AddArrays(outPts.size(), inPD, outPD, 0.0, false);
for (; ptId < endPtId; ++ptId)
{
outPtId = map[ptId];
if (outPtId < 0)
vtkSMPTools::For(0, inPts.size(), [&](vtkIdType ptId, vtkIdType endPtId) {
for (; ptId < endPtId; ++ptId)
{
outPtId = (-outPtId) - 1;
inP = this->InPoints + 3 * ptId;
outP = this->OutPoints + 3 * outPtId;
*outP++ = *inP++;
*outP++ = *inP++;
*outP = *inP;
this->Arrays.Copy(ptId, outPtId);
vtkIdType outPtId = map[ptId];
if (outPtId < 0)
{
outPtId = (-outPtId) - 1;
outPts[outPtId] = inPts[ptId];
arrays.Copy(ptId, outPtId);
}
}
}
}
static void Execute(vtkIdType numInPts, T* inPts, vtkIdType numOutPts, T* outPts, vtkIdType* map,
vtkPointData* inPD, vtkPointData* outPD2)
{
MapOutliers copy(numInPts, inPts, numOutPts, outPts, map, inPD, outPD2);
vtkSMPTools::For(0, numInPts, copy);
});
}
}; // MapOutliers
} // anonymous namespace
......@@ -245,12 +205,15 @@ int vtkPointCloudFilter::RequestData(vtkInformation* vtkNotUsed(request),
points->SetNumberOfPoints(count);
output->SetPoints(points);
void* inPtr = input->GetPoints()->GetVoidPointer(0);
void* outPtr = output->GetPoints()->GetVoidPointer(0);
switch (output->GetPoints()->GetDataType())
{
vtkTemplateMacro(MapPoints<VTK_TT>::Execute(
numPts, (VTK_TT*)inPtr, count, (VTK_TT*)outPtr, this->PointMap, inPD, outPD));
// Use fast path for float/double points:
using vtkArrayDispatch::Reals;
using Dispatcher = vtkArrayDispatch::Dispatch2BySameValueType<Reals>;
MapPoints worker;
vtkDataArray* inPtArray = input->GetPoints()->GetData();
vtkDataArray* outPtArray = output->GetPoints()->GetData();
if (!Dispatcher::Execute(inPtArray, outPtArray, worker, this->PointMap, inPD, outPD))
{ // fallback for weird types:
worker(inPtArray, outPtArray, this->PointMap, inPD, outPD);
}
// Generate poly vertex cell if requested
......@@ -287,11 +250,14 @@ int vtkPointCloudFilter::RequestData(vtkInformation* vtkNotUsed(request),
points2->SetDataType(input->GetPoints()->GetDataType());
points2->SetNumberOfPoints(count - 1);
output2->SetPoints(points2);
void* outPtr2 = output2->GetPoints()->GetVoidPointer(0);
switch (output->GetPoints()->GetDataType())
{
vtkTemplateMacro(MapOutliers<VTK_TT>::Execute(
numPts, (VTK_TT*)inPtr, (count - 1), (VTK_TT*)outPtr2, this->PointMap, inPD, outPD2));
MapOutliers outliersWorker;
inPtArray = input->GetPoints()->GetData();
outPtArray = output2->GetPoints()->GetData();
// Fast path for float/double:
if (!Dispatcher::Execute(inPtArray, outPtArray, outliersWorker, this->PointMap, inPD, outPD2))
{ // fallback for weird types:
outliersWorker(inPtArray, outPtArray, this->PointMap, inPD, outPD2);
}
points2->Delete();
......
......@@ -197,7 +197,7 @@ void vtkBMPWriter::MemoryWrite(int dim, vtkImageData* input, int wExt[6], vtkInf
r->SetNumberOfComponents(1);
size_t alen = oss->str().length();
r->SetNumberOfTuples(static_cast<vtkIdType>(alen));
unsigned char* buff = static_cast<unsigned char*>(r->GetVoidPointer(0));
unsigned char* buff = r->GetPointer(0);
memcpy(buff, oss->str().data(), alen);
this->SetResult(r);
r->Delete();
......
......@@ -14,8 +14,11 @@
=========================================================================*/
#include "vtkFieldDataSerializer.h"
#include "vtkDataArray.h"
#include "vtkDoubleArray.h"
#include "vtkFieldData.h"
#include "vtkFloatArray.h"
#include "vtkIdList.h"
#include "vtkIdTypeArray.h"
#include "vtkIntArray.h"
#include "vtkMultiProcessStream.h"
#include "vtkObjectFactory.h"
......@@ -99,9 +102,9 @@ void vtkFieldDataSerializer::DeserializeMetaData(vtkMultiProcessStream& bytestre
dimensions->SetNumberOfComponents(2);
dimensions->SetNumberOfTuples(NumberOfArrays);
std::string* namesPtr = static_cast<std::string*>(names->GetVoidPointer(0));
int* datatypesPtr = static_cast<int*>(datatypes->GetVoidPointer(0));
int* dimensionsPtr = static_cast<int*>(dimensions->GetVoidPointer(0));
std::string* namesPtr = names->GetPointer(0);
int* datatypesPtr = datatypes->GetPointer(0);
int* dimensionsPtr = dimensions->GetPointer(0);
// STEP 2: Extract metadata for each array in corresponding output arrays
for (int arrayIdx = 0; arrayIdx < NumberOfArrays; ++arrayIdx)
......@@ -347,23 +350,26 @@ void vtkFieldDataSerializer::SerializeDataArray(
// STEP 1: Push the raw data into the bytestream
// TODO: Add more cases for more datatypes here (?)
unsigned int size = numComp * numTuples;
switch (dataArray->GetDataType())