Commit dd312516 authored by Robert Maynard's avatar Robert Maynard
Browse files

Fix issue found be moving over to DataSetBuilderExplicit.

Mainly issue dealing with dimensionality of cell sets and what that represents.
Have added in code to allow user to specify a custom dimensionality so that
tests continue to work properly.
parent e7456fa1
......@@ -51,13 +51,14 @@ public:
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
int dimensionality=3,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
std::vector<T> zVals(xVals.size(),0);
return Create(xVals,yVals,zVals,
shapes,numIndices,connectivity,
coordsNm,cellNm);
dimensionality, coordsNm,cellNm);
}
template<typename T>
......@@ -69,6 +70,7 @@ public:
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
int dimensionality=3,
const std::string &coordsNm="coords",
const std::string &cellNm="cells");
......@@ -81,12 +83,13 @@ public:
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
int dimensionality=3,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
return BuildDataSet(xVals,yVals,zVals,
shapes,numIndices,connectivity,
coordsNm,cellNm);
dimensionality, coordsNm,cellNm);
}
......@@ -97,6 +100,7 @@ public:
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
int dimensionality=3,
const std::string &coordsNm="coords",
const std::string &cellNm="cells");
......@@ -107,11 +111,12 @@ public:
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
int dimensionality=3,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
return BuildDataSet(coords, shapes, numIndices, connectivity,
coordsNm, cellNm);
dimensionality, coordsNm, cellNm);
}
template<typename T, typename CellShapeTag>
......@@ -144,6 +149,7 @@ private:
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
int dimensionality,
const std::string &coordsNm,
const std::string &cellNm);
......@@ -154,6 +160,7 @@ private:
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
int dimensionality,
const std::string &coordsNm,
const std::string &cellNm);
......@@ -175,6 +182,7 @@ DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
int dimensionality,
const std::string &coordsNm,
const std::string &cellNm)
{
......@@ -194,7 +202,7 @@ DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
DFA::Copy(vtkm::cont::make_ArrayHandle(numIndices), Nc);
DFA::Copy(vtkm::cont::make_ArrayHandle(connectivity), Cc);
return BuildDataSet(Xc,Yc,Zc, Sc,Nc,Cc, coordsNm, cellNm);
return BuildDataSet(Xc,Yc,Zc, Sc,Nc,Cc, dimensionality, coordsNm, cellNm);
}
template<typename T>
......@@ -205,6 +213,7 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<T> &X,
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
int dimensionality,
const std::string &coordsNm,
const std::string &cellNm)
{
......@@ -218,7 +227,7 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<T> &X,
vtkm::cont::CoordinateSystem(coordsNm, 1,
make_ArrayHandleCompositeVector(X,0, Y,0, Z,0)));
vtkm::Id nPts = X.GetNumberOfValues();
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm, 3);
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm, dimensionality);
cellSet.Fill(shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
......@@ -232,6 +241,7 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
int dimensionality,
const std::string &coordsNm,
const std::string &cellNm)
{
......@@ -245,7 +255,7 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
DFA::Copy(vtkm::cont::make_ArrayHandle(numIndices), Nc);
DFA::Copy(vtkm::cont::make_ArrayHandle(connectivity), Cc);
return Create(coordsArray, Sc, Nc, Cc, coordsNm, cellNm);
return Create(coordsArray, Sc, Nc, Cc, dimensionality, coordsNm, cellNm);
}
template<typename T>
......@@ -255,6 +265,7 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
int dimensionality,
const std::string &coordsNm,
const std::string &cellNm)
{
......@@ -263,7 +274,7 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm,
1, coords));
vtkm::Id nPts = static_cast<vtkm::Id>(coords.GetNumberOfValues());
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm, 3);
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm, dimensionality);
cellSet.Fill(shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
......@@ -318,15 +329,17 @@ public:
DataSetBuilderExplicitIterative() {}
VTKM_CONT_EXPORT
void Begin(const std::string &_coordNm="coords",
const std::string &_cellNm="cells")
void Begin(int dim,
const std::string &coordName="coords",
const std::string &cellName="cells")
{
this->coordNm = _coordNm;
this->cellNm = _cellNm;
this->points.resize(0);
this->shapes.resize(0);
this->numIdx.resize(0);
this->connectivity.resize(0);
this->dimensionality = dim;
this->coordNm = coordName;
this->cellNm = cellName;
this->points.resize(0);
this->shapes.resize(0);
this->numIdx.resize(0);
this->connectivity.resize(0);
}
//Define points.
......@@ -398,6 +411,7 @@ public:
private:
std::string coordNm, cellNm;
int dimensionality;
std::vector<vtkm::Vec<vtkm::Float32,3> > points;
std::vector<vtkm::UInt8> shapes;
......@@ -409,7 +423,7 @@ vtkm::cont::DataSet
DataSetBuilderExplicitIterative::Create()
{
DataSetBuilderExplicit dsb;
return dsb.Create(points, shapes, numIdx, connectivity, coordNm, cellNm);
return dsb.Create(points, shapes, numIdx, connectivity, dimensionality, coordNm, cellNm);
}
......
......@@ -197,7 +197,7 @@ MakeTestDataSet::Make3DExplicitDataSet0()
conn.push_back(4);
//Create the dataset.
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
dataSet = dsb.Create(coords, shapes, numindices, conn, 2, "coordinates", "cells");
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
......
......@@ -77,7 +77,7 @@ vtkm::cont::DataSet MakeTestDatasetExplicit()
vtkm::cont::DataSet ds;
vtkm::cont::DataSetBuilderExplicit builder;
ds = builder.Create(coords, vtkm::CellShapeTagTriangle(), connectivity);
ds = builder.Create(coords, vtkm::CellShapeTagTriangle(), connectivity, "coords");
std::vector<vtkm::Float32> values;
values.push_back(1.0);
......@@ -124,7 +124,7 @@ void TestClippingExplicit()
vtkm::cont::DynamicArrayHandle coords =
clip.ProcessField(ds.GetCoordinateSystem("coordinates").GetData());
clip.ProcessField(ds.GetCoordinateSystem("coords").GetData());
vtkm::cont::DynamicArrayHandle scalars =
clip.ProcessField(ds.GetField("scalars").GetData());
......@@ -150,7 +150,7 @@ void TestClippingExplicit()
VTKM_TEST_ASSERT(
TestArrayHandle(coords.CastToArrayHandle(Coord3D(),
VTKM_DEFAULT_STORAGE_TAG()), expectedCoords, fieldSize),
"Got incorrect coordinates");
"Got incorrect coords");
VTKM_TEST_ASSERT(
TestArrayHandle(scalars.CastToArrayHandle(vtkm::Float32(),
......@@ -169,7 +169,7 @@ void TestClippingStrucutred()
vtkm::cont::DynamicArrayHandle coords =
clip.ProcessField(ds.GetCoordinateSystem("coordinates").GetData());
clip.ProcessField(ds.GetCoordinateSystem("coords").GetData());
vtkm::cont::DynamicArrayHandle scalars =
clip.ProcessField(ds.GetField("scalars").GetData());
......@@ -197,7 +197,7 @@ void TestClippingStrucutred()
VTKM_TEST_ASSERT(
TestArrayHandle(coords.CastToArrayHandle(Coord3D(),
VTKM_DEFAULT_STORAGE_TAG()), expectedCoords, fieldSize),
"Got incorrect coordinates");
"Got incorrect coords");
VTKM_TEST_ASSERT(
TestArrayHandle(scalars.CastToArrayHandle(vtkm::Float32(),
......@@ -216,11 +216,11 @@ void TestClippingWithImplicitFunction()
vtkm::worklet::Clip<DeviceAdapter> clip;
vtkm::cont::CellSetExplicit<> outputCellSet =
clip.Run(ds.GetCellSet(0), sphere, ds.GetCoordinateSystem("coordinates"));
clip.Run(ds.GetCellSet(0), sphere, ds.GetCoordinateSystem("coords"));
vtkm::cont::DynamicArrayHandle coords =
clip.ProcessField(ds.GetCoordinateSystem("coordinates").GetData());
clip.ProcessField(ds.GetCoordinateSystem("coords").GetData());
vtkm::cont::DynamicArrayHandle scalars =
clip.ProcessField(ds.GetField("scalars").GetData());
......@@ -249,7 +249,7 @@ void TestClippingWithImplicitFunction()
VTKM_TEST_ASSERT(
TestArrayHandle(coords.CastToArrayHandle(Coord3D(),
VTKM_DEFAULT_STORAGE_TAG()), expectedCoords, fieldSize),
"Got incorrect coordinates");
"Got incorrect coords");
VTKM_TEST_ASSERT(
TestArrayHandle(scalars.CastToArrayHandle(vtkm::Float32(),
......
......@@ -107,7 +107,7 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
conn.push_back(12);
vtkm::cont::DataSetBuilderExplicit builder;
return builder.Create(coordinates, shapes, numindices, conn);
return builder.Create(coordinates, shapes, numindices, conn, 2);
}
//
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment