Commit 713cf422 authored by Kenneth Moreland's avatar Kenneth Moreland

Make it not possible to create a cell set without specifying num points

The CellSetExplicit and CellSetSingleType classes have an ivar that
marks the number of points. There were several instances of code
creating cell sets without specifying the number of points. This can be
very bad if subsequent code needs that information.
parent be1e6588
......@@ -305,8 +305,7 @@ int main(int argc, char* argv[])
numberOfInPoints = inCellSet.GetNumberOfPoints();
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(
vtkm::CellShapeTagTetra(), numberOfInPoints, "cells");
vtkm::cont::CellSetSingleType<> cellSet("cells");
outDataSet.AddCellSet(cellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
......
......@@ -293,8 +293,7 @@ int main(int argc, char* argv[])
numberOfInPoints = (dims[0] + 1) * (dims[1] + 1) * (dims[2] + 1);
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(
vtkm::CellShapeTagTetra(), numberOfInPoints, "cells");
vtkm::cont::CellSetSingleType<> cellSet("cells");
tetDataSet.AddCellSet(cellSet);
tetDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
......
......@@ -226,7 +226,7 @@ int main(int argc, char* argv[])
numberOfInPoints = inCellSet.GetNumberOfPoints();
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(vtkm::CellShapeTagTriangle(), "cells");;
vtkm::cont::CellSetSingleType<> cellSet("cells");;
outDataSet.AddCellSet(cellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
......
......@@ -201,7 +201,7 @@ int main(int argc, char* argv[])
vtkm::cont::DataSet inDataSet = MakeTriangulateTestDataSet(dims);
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::CellSetSingleType<> cellSet(vtkm::CellShapeTagTriangle(), "cells");
vtkm::cont::CellSetSingleType<> cellSet("cells");
tetDataSet.AddCellSet(cellSet);
tetDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
......
......@@ -106,12 +106,11 @@ public:
typedef typename PointToCellConnectivityType::IndexOffsetArrayType IndexOffsetArrayType;
VTKM_CONT
CellSetExplicit(vtkm::Id numpoints = 0,
const std::string &name = std::string())
CellSetExplicit(const std::string &name = std::string())
: CellSet(name),
ConnectivityLength(-1),
NumberOfCells(-1),
NumberOfPoints(numpoints)
ConnectivityAdded(-1),
NumberOfCellsAdded(-1),
NumberOfPoints(0)
{
}
......@@ -120,8 +119,8 @@ public:
: CellSet(src),
PointToCell(src.PointToCell),
CellToPoint(src.CellToPoint),
ConnectivityLength(src.ConnectivityLength),
NumberOfCells(src.NumberOfCells),
ConnectivityAdded(src.ConnectivityAdded),
NumberOfCellsAdded(src.NumberOfCellsAdded),
NumberOfPoints(src.NumberOfPoints)
{ }
......@@ -131,8 +130,8 @@ public:
this->CellSet::operator=(src);
this->PointToCell = src.PointToCell;
this->CellToPoint = src.CellToPoint;
this->ConnectivityLength = src.ConnectivityLength;
this->NumberOfCells = src.NumberOfCells;
this->ConnectivityAdded = src.ConnectivityAdded;
this->NumberOfCellsAdded = src.NumberOfCellsAdded;
this->NumberOfPoints = src.NumberOfPoints;
return *this;
}
......@@ -168,7 +167,7 @@ public:
}
VTKM_CONT
vtkm::Id GetCellShape(vtkm::Id cellIndex) const
vtkm::UInt8 GetCellShape(vtkm::Id cellIndex) const
{
return this->PointToCell.Shapes.GetPortalConstControl().Get(cellIndex);
}
......@@ -188,54 +187,88 @@ public:
/// First method to add cells -- one at a time.
VTKM_CONT
void PrepareToAddCells(vtkm::Id numShapes, vtkm::Id connectivityMaxLen)
void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen)
{
this->PointToCell.Shapes.Allocate(numShapes);
this->PointToCell.NumIndices.Allocate(numShapes);
this->PointToCell.Shapes.Allocate(numCells);
this->PointToCell.NumIndices.Allocate(numCells);
this->PointToCell.Connectivity.Allocate(connectivityMaxLen);
this->PointToCell.IndexOffsets.Allocate(numShapes);
this->NumberOfCells = 0;
this->ConnectivityLength = 0;
this->PointToCell.IndexOffsets.Allocate(numCells);
this->NumberOfCellsAdded = 0;
this->ConnectivityAdded = 0;
}
template <typename IndexableType>
template <typename IdVecType>
VTKM_CONT
void AddCell(vtkm::UInt8 cellType,
vtkm::IdComponent numVertices,
const IndexableType &ids)
const IdVecType &ids)
{
this->PointToCell.Shapes.GetPortalControl().Set(this->NumberOfCells, cellType);
this->PointToCell.NumIndices.GetPortalControl().Set(this->NumberOfCells, numVertices);
for (vtkm::IdComponent i=0; i < numVertices; ++i)
using Traits = vtkm::VecTraits<IdVecType>;
VTKM_STATIC_ASSERT_MSG(
(std::is_same<typename Traits::ComponentType,vtkm::Id>::value),
"CellSetSingleType::AddCell requires vtkm::Id for indices.");
if (Traits::GetNumberOfComponents(ids) < numVertices)
{
throw vtkm::cont::ErrorControlBadValue(
"Not enough indices given to CellSetSingleType::AddCell.");
}
if (this->NumberOfCellsAdded >= this->PointToCell.Shapes.GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
"Added more cells then expected.");
}
if (this->ConnectivityAdded+numVertices >
this->PointToCell.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
"Connectivity increased passed estimated maximum connectivity.");
}
this->PointToCell.Shapes.GetPortalControl().Set(this->NumberOfCellsAdded, cellType);
this->PointToCell.NumIndices.GetPortalControl().Set(this->NumberOfCellsAdded, numVertices);
for (vtkm::IdComponent iVec=0; iVec < numVertices; ++iVec)
{
this->PointToCell.Connectivity.GetPortalControl().Set(
this->ConnectivityLength+i,ids[i]);
this->ConnectivityAdded+iVec, Traits::GetComponent(ids,iVec));
}
this->PointToCell.IndexOffsets.GetPortalControl().Set(
this->NumberOfCells, this->ConnectivityLength);
this->NumberOfCells++;
this->ConnectivityLength += numVertices;
this->NumberOfCellsAdded, this->ConnectivityAdded);
this->NumberOfCellsAdded++;
this->ConnectivityAdded += numVertices;
}
VTKM_CONT
void CompleteAddingCells()
void CompleteAddingCells(vtkm::Id numPoints)
{
this->PointToCell.Connectivity.Shrink(ConnectivityLength);
this->NumberOfPoints = numPoints;
this->PointToCell.Connectivity.Shrink(ConnectivityAdded);
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
this->NumberOfCells = this->ConnectivityLength = -1;
if (this->NumberOfCellsAdded != this->GetNumberOfCells())
{
throw vtkm::cont::ErrorControlBadValue(
"Did not add as many cells as expected.");
}
this->NumberOfCellsAdded = -1;
this->ConnectivityAdded = -1;
}
/// Second method to add cells -- all at once.
/// Assigns the array handles to the explicit connectivity. This is
/// the way you can fill the memory from another system without copying
VTKM_CONT
void Fill(const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
void Fill(vtkm::Id numPoints,
const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity,
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag> &offsets
= vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>() )
{
this->NumberOfPoints = numPoints;
this->PointToCell.Shapes = cellTypes;
this->PointToCell.NumIndices = numIndices;
this->PointToCell.Connectivity = connectivity;
......@@ -509,8 +542,8 @@ protected:
// These are used in the AddCell and related methods to incrementally add
// cells. They need to be protected as subclasses of CellSetExplicit
// need to set these values when implementing Fill()
vtkm::Id ConnectivityLength;
vtkm::Id NumberOfCells;
vtkm::Id ConnectivityAdded;
vtkm::Id NumberOfCellsAdded;
vtkm::Id NumberOfPoints;
};
......
This diff is collapsed.
......@@ -155,6 +155,7 @@ public:
vtkm::cont::DataSet
Create(const std::vector<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm="coords",
const std::string &cellNm="cells");
......@@ -165,12 +166,14 @@ public:
vtkm::cont::DataSet
Create(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
return DataSetBuilderExplicit::BuildDataSet(coords,
tag,
numberOfPointsPerCell,
connectivity,
coordsNm,
cellNm);
......@@ -206,6 +209,7 @@ private:
vtkm::cont::DataSet
BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm);
......@@ -266,9 +270,9 @@ DataSetBuilderExplicit::BuildDataSet(
vtkm::cont::CoordinateSystem(coordsNm,
make_ArrayHandleCompositeVector(X,0, Y,0, Z,0)));
vtkm::Id nPts = X.GetNumberOfValues();
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm);
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
cellSet.Fill(shapes, numIndices, connectivity);
cellSet.Fill(nPts, shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
......@@ -313,9 +317,9 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm,
coords));
vtkm::Id nPts = static_cast<vtkm::Id>(coords.GetNumberOfValues());
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm);
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
cellSet.Fill(shapes, numIndices, connectivity);
cellSet.Fill(nPts, shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
......@@ -326,6 +330,7 @@ inline VTKM_CONT
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
......@@ -336,7 +341,8 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
vtkm::cont::ArrayHandle<vtkm::Id> Cc;
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
return DataSetBuilderExplicit::Create(coordsArray, tag, Cc, coordsNm, cellNm);
return DataSetBuilderExplicit::Create(
coordsArray, tag, numberOfPointsPerCell, Cc, coordsNm, cellNm);
}
template<typename T, typename CellShapeTag>
......@@ -344,6 +350,7 @@ inline VTKM_CONT
vtkm::cont::DataSet
DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
CellShapeTag tag,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
......@@ -351,9 +358,12 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3
vtkm::cont::DataSet dataSet;
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
vtkm::cont::CellSetSingleType<> cellSet(tag, coords.GetNumberOfValues(), cellNm);
vtkm::cont::CellSetSingleType<> cellSet(cellNm);
cellSet.Fill(connectivity);
cellSet.Fill(coords.GetNumberOfValues(),
tag.Id,
numberOfPointsPerCell,
connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
......@@ -469,94 +479,6 @@ DataSetBuilderExplicitIterative::Create()
}
#if 0
template<typename T, typename CellType>
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
const std::vector<T> &yVals,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
{
VTKM_CONT_ASSERT(xVals.size() == yVals.size() && xVals.size() > 0);
vtkm::cont::DataSet dataSet;
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
std::vector<CoordType> coords(xVals.size());
for (size_t i=0; i < coords.size(); i++)
{
coords[i][0] = xVals[i];
coords[i][1] = yVals[i];
coords[i][2] = 0;
}
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, coords));
vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm);
cellSet.FillViaCopy(connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
}
template<typename T, typename CellType>
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
const std::vector<T> &yVals,
const std::vector<T> &zVals,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
{
VTKM_CONT_ASSERT(xVals.size() == yVals.size() &&
yVals.size() == zVals.size() &&
xVals.size() > 0);
vtkm::cont::DataSet dataSet;
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
std::vector<CoordType> coords(xVals.size());
vtkm::Id nPts = static_cast<vtkm::Id>(coords.size());
for (vtkm::Id i=0; i < nPts; i++)
{
coords[i][0] = xVals[i];
coords[i][1] = yVals[i];
coords[i][2] = zVals[i];
}
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, coords));
vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm);
cellSet.FillViaCopy(connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
}
template<typename T, typename CellType>
vtkm::cont::DataSet
DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
const std::vector<vtkm::Id> &connectivity,
const std::string &coordsNm,
const std::string &cellNm)
{
vtkm::cont::DataSet dataSet;
vtkm::cont::ArrayHandle<Vec<T,3> > coordsArray;
CopyInto(coords, coordsArray);
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, coordsArray));
vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm);
cellSet.FillViaCopy(connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
}
#endif
}
}
......
......@@ -64,11 +64,11 @@ void TransportWholeCellSetIn(Device)
{
//build a fake cell set
const int nVerts = 5;
vtkm::cont::CellSetExplicit<> contObject(nVerts, "cells");
vtkm::cont::CellSetExplicit<> contObject("cells");
contObject.PrepareToAddCells(2, 7);
contObject.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, vtkm::make_Vec<vtkm::Id>(0,1,2));
contObject.AddCell(vtkm::CELL_SHAPE_QUAD, 4, vtkm::make_Vec<vtkm::Id>(2,1,3,4));
contObject.CompleteAddingCells();
contObject.CompleteAddingCells(nVerts);
typedef vtkm::TopologyElementTagPoint FromType;
typedef vtkm::TopologyElementTagCell ToType;
......
......@@ -92,14 +92,18 @@ MakeTestDataSet::Make1DExplicitDataSet0()
coords[3] = CoordType(1.2f,0.f,0.f);
coords[4] = CoordType(4.0f,0.f,0.f);
// Each line connects two consecutive vertices
std::vector<vtkm::Id> conn;
for (int i = 0; i < nVerts; i++)
conn.push_back(i);
for (int i = 0; i < nVerts-1; i++)
{
conn.push_back(i);
conn.push_back(i+1);
}
vtkm::cont::DataSet dataSet;
vtkm::cont::DataSetBuilderExplicit dsb;
dataSet = dsb.Create(coords, vtkm::CellShapeTagLine(), conn, "coordinates", "cells");
dataSet = dsb.Create(coords, vtkm::CellShapeTagLine(), 2, conn, "coordinates", "cells");
vtkm::cont::DataSetFieldAdd dsf;
vtkm::Float32 var[nVerts] = {-1.0f, .5f, -.2f, 1.7f, .8f};
......@@ -382,11 +386,11 @@ MakeTestDataSet::Make3DExplicitDataSet1()
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", coordinates, nVerts));
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
cellSet.PrepareToAddCells(2, 7);
cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
cellSet.AddCell(vtkm::CELL_SHAPE_QUAD, 4, make_Vec<vtkm::Id>(2,1,3,4));
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(nVerts);
dataSet.AddCellSet(cellSet);
//Set point scalar
......@@ -428,7 +432,7 @@ MakeTestDataSet::Make3DExplicitDataSet2()
vtkm::Float32 cellvar[2] = {100.1f};
dataSet.AddField(Field("cellvar", vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 1));
vtkm::cont::CellSetExplicit<> cellSet(nVerts,"cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
vtkm::Vec<vtkm::Id, 8> ids;
ids[0] = 0;
ids[1] = 1;
......@@ -441,7 +445,7 @@ MakeTestDataSet::Make3DExplicitDataSet2()
cellSet.PrepareToAddCells(1, 8);
cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids);
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(nVerts);
//todo this need to be a reference/shared_ptr style class
dataSet.AddCellSet(cellSet);
......@@ -482,7 +486,7 @@ MakeTestDataSet::Make3DExplicitDataSet4()
vtkm::Float32 cellvar[2] = {100.1f, 110.f};
dataSet.AddField(Field("cellvar", vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
vtkm::cont::CellSetExplicit<> cellSet(nVerts,"cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
vtkm::Vec<vtkm::Id, 8> ids;
ids[0] = 0;
ids[1] = 4;
......@@ -504,7 +508,7 @@ MakeTestDataSet::Make3DExplicitDataSet4()
ids[6] = 10;
ids[7] = 9;
cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids);
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(nVerts);
//todo this need to be a reference/shared_ptr style class
dataSet.AddCellSet(cellSet);
......@@ -537,7 +541,7 @@ MakeTestDataSet::Make3DExplicitDataSet3()
vtkm::Float32 cellvar[2] = {100.1f};
dataSet.AddField(Field("cellvar", vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 1));
vtkm::cont::CellSetExplicit<> cellSet(nVerts,"cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
vtkm::Vec<vtkm::Id, 4> ids;
ids[0] = 0;
ids[1] = 1;
......@@ -546,7 +550,7 @@ MakeTestDataSet::Make3DExplicitDataSet3()
cellSet.PrepareToAddCells(1, 4);
cellSet.AddCell(vtkm::CELL_SHAPE_TETRA, 4, ids);
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(nVerts);
//todo this need to be a reference/shared_ptr style class
dataSet.AddCellSet(cellSet);
......@@ -594,7 +598,7 @@ MakeTestDataSet::Make3DExplicitDataSet5()
cellvar,
nCells));
vtkm::cont::CellSetExplicit<> cellSet(nVerts,"cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
vtkm::Vec<vtkm::Id, 8> ids;
cellSet.PrepareToAddCells(nCells, 23);
......@@ -630,7 +634,7 @@ MakeTestDataSet::Make3DExplicitDataSet5()
ids[5] = 6;
cellSet.AddCell(vtkm::CELL_SHAPE_WEDGE, 6, ids);
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(nVerts);
//todo this need to be a reference/shared_ptr style class
dataSet.AddCellSet(cellSet);
......@@ -663,8 +667,8 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose()
CoordType(0.0108188,0.152774,0.167914),
CoordType(5.41687e-05,0.00137834,0.175119)
};
const int nPointIds = 57;
vtkm::Id pointId[nPointIds] = {
const int connectivitySize = 57;
vtkm::Id pointId[connectivitySize] = {
0, 1, 3,
2, 3, 1,
4, 5, 0,
......@@ -692,16 +696,14 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose()
vtkm::cont::CoordinateSystem("coordinates", coordinates, nVerts));
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
connectivity.Allocate(nPointIds);
connectivity.Allocate(connectivitySize);
for(vtkm::Id i=0; i < nPointIds; ++i)
for(vtkm::Id i=0; i < connectivitySize; ++i)
{
connectivity.GetPortalControl().Set(i, pointId[i]);
}
vtkm::cont::CellSetSingleType< > cellSet(vtkm::CellShapeTagTriangle(),
nVerts,
"cells");
cellSet.Fill(connectivity);
vtkm::cont::CellSetSingleType< > cellSet("cells");
cellSet.Fill(nVerts, vtkm::CELL_SHAPE_TRIANGLE, 3, connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
......
......@@ -88,7 +88,7 @@ private:
vtkm::cont::DataSet ds;
vtkm::cont::DataSetBuilderExplicit builder;
ds = builder.Create(coordinates, vtkm::CellShapeTagTriangle(), conn);
ds = builder.Create(coordinates, vtkm::CellShapeTagTriangle(), 3, conn);
//Set point scalar
......
......@@ -78,7 +78,7 @@ inline vtkm::cont::DataSet make_SingleTypeDataSet()
vtkm::cont::DataSet ds;
vtkm::cont::DataSetBuilderExplicit builder;
ds = builder.Create(coordinates, vtkm::CellShapeTagTriangle(), conn);
ds = builder.Create(coordinates, vtkm::CellShapeTagTriangle(), 3, conn);
//Set point scalar
const int nVerts = 5;
......
......@@ -63,9 +63,11 @@ public:
output_shapes, output_numIndices, output_conn,
DeviceAdapter());
vtkm::cont::CellSetExplicit<> output_cs(cellset.GetNumberOfPoints(),
cellset.GetName());
output_cs.Fill(output_shapes, output_numIndices, output_conn);
vtkm::cont::CellSetExplicit<> output_cs(cellset.GetName());
output_cs.Fill(cellset.GetNumberOfPoints(),
output_shapes,
output_numIndices,
output_conn);
this->Output->AddCellSet(output_cs);
*this->Valid = true;
......
......@@ -47,7 +47,7 @@ vtkm::cont::DataSet MakeTestDatasetExplicit()
vtkm::cont::DataSet ds;
vtkm::cont::DataSetBuilderExplicit builder;
ds = builder.Create(coords, vtkm::CellShapeTagTriangle(), connectivity, "coords");
ds = builder.Create(coords, vtkm::CellShapeTagTriangle(), 3, connectivity, "coords");
std::vector<vtkm::Float32> values;
values.push_back(1.0);
......
......@@ -52,7 +52,7 @@ void TestExternalFacesExplicitGrid()
{4,7,6,3}, {4,6,3,2}, {4,0,3,2},
{4,6,5,2}, {4,5,0,2}, {1,0,5,2}
};
vtkm::cont::CellSetExplicit<> cs(nVerts, "cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
......@@ -70,10 +70,10 @@ void TestExternalFacesExplicitGrid()
conn.GetPortalControl().Set(index++, cellVerts[j][k]);
}
cs.Fill(shapes, numIndices, conn);
cellSet.Fill(nVerts, shapes, numIndices, conn);
//Add the VTK-m cell set
ds.AddCellSet(cs);
ds.AddCellSet(cellSet);
//Run the External Faces filter
vtkm::filter::ExternalFaces externalFaces;
......@@ -82,10 +82,10 @@ void TestExternalFacesExplicitGrid()
//Validate the number of external faces (output) returned by the worklet
VTKM_TEST_ASSERT(result.IsValid(), "Results should be valid");
vtkm::cont::CellSetExplicit<> &new_cs =
vtkm::cont::CellSetExplicit<> &new_cellSet =
result.GetDataSet().GetCellSet(0).Cast<vtkm::cont::CellSetExplicit<> >();
const vtkm::Id numExtFaces_out = new_cs.GetNumberOfCells();
const vtkm::Id numExtFaces_out = new_cellSet.GetNumberOfCells();
const vtkm::Id numExtFaces_actual = 12;
VTKM_TEST_ASSERT(numExtFaces_out == numExtFaces_actual, "Number of External Faces mismatch");
}
......
......@@ -245,8 +245,11 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::ASSOC_POINTS,
vtkm::cont::DynamicArrayHandle(distanceToOther)));
CellSet cellSet(HexTag(), coordinates.GetNumberOfValues(), "cells");
cellSet.Fill(connectivity);
CellSet cellSet("cells");
cellSet.Fill(coordinates.GetNumberOfValues(),
HexTag::Id,
HexTraits::NUM_POINTS,
connectivity);
dataSet.AddCellSet(cellSet);
......
......@@ -48,7 +48,7 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", coordinates));
vtkm::cont::CellSetExplicit<> cellSet(vtkm::Id(coordinates.size()), "cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
cellSet.PrepareToAddCells(numCells, numCells * 4);
for (vtkm::Id j = 0; j < dim - 1; ++j)
{
......@@ -62,7 +62,7 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
(j + 1) * dim + i));
}
}
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(vtkm::Id(coordinates.size()));
dataSet.AddCellSet(cellSet);
return dataSet;
......
......@@ -98,6 +98,9 @@ private:
// Read the points
this->ReadPoints();
vtkm::Id numPoints =
this->DataSet.GetCoordinateSystem().GetData().GetNumberOfValues();
// Read the cellset
std::vector<vtkm::cont::ArrayHandle<vtkm::Id> > connectivityArrays;
std::vector<vtkm::cont::ArrayHandle<vtkm::IdComponent> > numIndicesArrays;
......@@ -155,22 +158,18 @@ private:
if (vtkm::io::internal::IsSingleShape(shapes))
{
vtkm::cont::CellSetSingleType<> cs;
switch(shapes.GetPortalConstControl().Get(0))
{
vtkmGenericCellShapeMacro(
(cs = vtkm::cont::CellSetSingleType<>(CellShapeTag(), 0, "cells")));
default:
break;
}
cs.Fill(connectivity);
this->DataSet.AddCellSet(cs);
vtkm::cont::CellSetSingleType<> cellSet("cells");
cellSet.Fill(numPoints,
shapes.GetPortalConstControl().Get(0),
numIndices.GetPortalConstControl().Get(0),
connectivity);
this->DataSet.AddCellSet(cellSet);
}
else
{
vtkm::cont::CellSetExplicit<> cs(0, "cells");
cs.Fill(shapes, numIndices, connectivity);