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.
This commit is contained in:
Kenneth Moreland 2016-12-20 16:14:50 -07:00
parent be1e6588c1
commit 713cf4228a
38 changed files with 386 additions and 309 deletions

@ -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;
};

@ -54,47 +54,29 @@ class CellSetSingleType :
public:
template<typename CellShapeTag>
VTKM_CONT
CellSetSingleType(CellShapeTag, vtkm::Id numpoints, const std::string &name = std::string())
: Superclass(numpoints, name),
CellTypeAsId(CellShapeTag::Id)
{
}
template<typename CellShapeTag>
VTKM_CONT
CellSetSingleType(CellShapeTag, const std::string &name = std::string())
: Superclass(0, name),
CellTypeAsId(CellShapeTag::Id)
{
}
VTKM_CONT
CellSetSingleType(vtkm::Id numpoints,
const std::string &name = std::string())
: Superclass(numpoints, name),
CellTypeAsId(CellShapeTagEmpty::Id)
{
}
VTKM_CONT
CellSetSingleType(const std::string &name = std::string())
: Superclass(0, name),
CellTypeAsId(CellShapeTagEmpty::Id)
: Superclass(name),
ExpectedNumberOfCellsAdded(-1),
CellShapeAsId(CellShapeTagEmpty::Id),
NumberOfPointsPerCell(0)
{
}
VTKM_CONT
CellSetSingleType(const Thisclass &src)
: Superclass(src), CellTypeAsId(src.CellTypeAsId)
: Superclass(src),
ExpectedNumberOfCellsAdded(-1),
CellShapeAsId(src.CellShapeAsId),
NumberOfPointsPerCell(src.NumberOfPointsPerCell)
{ }
VTKM_CONT
Thisclass &operator=(const Thisclass &src)
{
this->Superclass::operator=(src);
this->CellTypeAsId = src.CellTypeAsId;
this->CellShapeAsId = src.CellShapeAsId;
this->NumberOfPointsPerCell = src.NumberOfPointsPerCell;
return *this;
}
@ -102,69 +84,133 @@ 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)
{
vtkm::IdComponent numberOfPointsPerCell = this->DetermineNumberOfPoints();
const vtkm::UInt8 shapeTypeValue = static_cast<vtkm::UInt8>(this->CellTypeAsId);
this->PointToCell.Shapes =
vtkm::cont::make_ArrayHandleConstant(shapeTypeValue, numShapes);
this->PointToCell.NumIndices =
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell,
numShapes);
this->PointToCell.IndexOffsets =
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0),
static_cast<vtkm::Id>(numberOfPointsPerCell),
numShapes );
this->CellShapeAsId = vtkm::CELL_SHAPE_EMPTY;
this->PointToCell.Connectivity.Allocate(connectivityMaxLen);
this->NumberOfCells = 0;
this->ConnectivityLength = 0;
this->NumberOfCellsAdded = 0;
this->ConnectivityAdded = 0;
this->ExpectedNumberOfCellsAdded = numCells;
}
/// Second method to add cells -- one at a time.
template <vtkm::IdComponent ItemTupleLength>
template <typename IdVecType>
VTKM_CONT
void AddCell(vtkm::UInt8 vtkmNotUsed(cellType),
void AddCell(vtkm::UInt8 shapeId,
vtkm::IdComponent numVertices,
const vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
const IdVecType &ids)
{
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->ConnectivityAdded+numVertices >
this->PointToCell.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorControlBadValue(
"Connectivity increased passed estimated maximum connectivity.");
}
if (this->CellShapeAsId == vtkm::CELL_SHAPE_EMPTY)
{
if (shapeId == vtkm::CELL_SHAPE_EMPTY)
{
throw vtkm::cont::ErrorControlBadValue(
"Cannot create cells of type empty.");
}
this->CellShapeAsId = shapeId;
this->CheckNumberOfPointsPerCell(numVertices);
this->NumberOfPointsPerCell = numVertices;
}
else
{
if (shapeId != this->GetCellShape(0))
{
throw vtkm::cont::ErrorControlBadValue(
"Cannot have differing shapes in CellSetSingleType.");
}
if (numVertices != this->NumberOfPointsPerCell)
{
throw vtkm::cont::ErrorControlBadValue(
"Inconsistent number of points in cells for CellSetSingleType.");
}
}
for (vtkm::IdComponent iVert=0; iVert < numVertices; ++iVert)
{
this->PointToCell.Connectivity.GetPortalControl().Set(
this->ConnectivityLength+i,ids[i]);
this->ConnectivityAdded+iVert, Traits::GetComponent(ids,iVert));
}
this->NumberOfCells++;
this->ConnectivityLength += numVertices;
this->NumberOfCellsAdded++;
this->ConnectivityAdded += numVertices;
}
/// Third and final method to add cells -- one at a time.
VTKM_CONT
void CompleteAddingCells()
void CompleteAddingCells(vtkm::Id numPoints)
{
this->PointToCell.Connectivity.Shrink(this->ConnectivityLength);
this->NumberOfPoints = numPoints;
this->PointToCell.Connectivity.Shrink(this->ConnectivityAdded);
vtkm::Id numCells = this->NumberOfCellsAdded;
this->PointToCell.Shapes =
vtkm::cont::make_ArrayHandleConstant(this->GetCellShape(0), numCells);
this->PointToCell.NumIndices =
vtkm::cont::make_ArrayHandleConstant(this->NumberOfPointsPerCell,
numCells);
this->PointToCell.IndexOffsets =
vtkm::cont::make_ArrayHandleCounting(
vtkm::Id(0),
static_cast<vtkm::Id>(this->NumberOfPointsPerCell),
numCells);
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
this->NumberOfCells = this->ConnectivityLength = -1;
if (this->ExpectedNumberOfCellsAdded != this->GetNumberOfCells())
{
throw vtkm::cont::ErrorControlBadValue(
"Did not add the expected number of cells.");
}
this->NumberOfCellsAdded = -1;
this->ConnectivityAdded = -1;
this->ExpectedNumberOfCellsAdded = -1;
}
//This is the way you can fill the memory from another system without copying
VTKM_CONT
void Fill(const vtkm::cont::ArrayHandle<vtkm::Id,
ConnectivityStorageTag> &connectivity)
void Fill(vtkm::Id numPoints,
vtkm::UInt8 shapeId,
vtkm::IdComponent numberOfPointsPerCell,
const vtkm::cont::ArrayHandle<vtkm::Id,ConnectivityStorageTag>
&connectivity)
{
vtkm::IdComponent numberOfPointsPerCell = this->DetermineNumberOfPoints();
const vtkm::Id length = connectivity.GetNumberOfValues() / numberOfPointsPerCell;
const vtkm::UInt8 shapeTypeValue = static_cast<vtkm::UInt8>(this->CellTypeAsId);
this->NumberOfPoints = numPoints;
this->CellShapeAsId = shapeId;
this->CheckNumberOfPointsPerCell(numberOfPointsPerCell);
const vtkm::Id numCells =
connectivity.GetNumberOfValues() / numberOfPointsPerCell;
VTKM_ASSERT((connectivity.GetNumberOfValues() % numberOfPointsPerCell) == 0);
this->PointToCell.Shapes =
vtkm::cont::make_ArrayHandleConstant(shapeTypeValue, length);
vtkm::cont::make_ArrayHandleConstant(shapeId, numCells);
this->PointToCell.NumIndices =
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell,
length);
numCells);
this->PointToCell.IndexOffsets =
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0),
static_cast<vtkm::Id>(numberOfPointsPerCell),
length );
numCells );
this->PointToCell.Connectivity = connectivity;
this->PointToCell.ElementsValid = true;
@ -172,14 +218,20 @@ public:
}
VTKM_CONT
vtkm::Id GetCellTypeAsId() const
vtkm::Id GetCellShapeAsId() const
{
return this->CellTypeAsId;
return this->CellShapeAsId;
}
VTKM_CONT
vtkm::UInt8 GetCellShape(vtkm::Id vtkmNotUsed(cellIndex)) const
{
return static_cast<vtkm::UInt8>(this->CellShapeAsId);
}
virtual void PrintSummary(std::ostream &out) const
{
out << " ExplicitSingleCellSet: " << this->Name << " Type "<<this->CellTypeAsId<<std::endl;
out << " ExplicitSingleCellSet: " << this->Name << " Type "<<this->CellShapeAsId<<std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
@ -188,38 +240,45 @@ public:
private:
template< typename CellShapeTag>
void DetermineNumberOfPoints(CellShapeTag,
vtkm::CellTraitsTagSizeFixed,
vtkm::IdComponent& numberOfPoints) const
void CheckNumberOfPointsPerCell(CellShapeTag,
vtkm::CellTraitsTagSizeFixed,
vtkm::IdComponent numVertices) const
{
numberOfPoints = vtkm::CellTraits<CellShapeTag>::NUM_POINTS;
if (numVertices != vtkm::CellTraits<CellShapeTag>::NUM_POINTS)
{
throw vtkm::cont::ErrorControlBadValue(
"Passed invalid number of points for cell shape.");
}
}
template< typename CellShapeTag>
void DetermineNumberOfPoints(CellShapeTag,
vtkm::CellTraitsTagSizeVariable,
vtkm::IdComponent& numberOfPoints) const
{ //variable length cells can't be used with this class
numberOfPoints = -1;
void CheckNumberOfPointsPerCell(CellShapeTag,
vtkm::CellTraitsTagSizeVariable,
vtkm::IdComponent vtkmNotUsed(numVertices)) const
{
// Technically, a shape with a variable number of points probably has a
// minimum number of points, but we are not being sophisticated enough to
// check that. Instead, just pass the check by returning without error.
}
vtkm::IdComponent DetermineNumberOfPoints() const
void CheckNumberOfPointsPerCell(vtkm::IdComponent numVertices) const
{
vtkm::IdComponent numberOfPointsPerCell = -1;
switch (this->CellTypeAsId)
switch (this->CellShapeAsId)
{
vtkmGenericCellShapeMacro( this->DetermineNumberOfPoints(CellShapeTag(),
vtkm::CellTraits<CellShapeTag>::IsSizeFixed(),
numberOfPointsPerCell) );
vtkmGenericCellShapeMacro(
this->CheckNumberOfPointsPerCell(CellShapeTag(),
vtkm::CellTraits<CellShapeTag>::IsSizeFixed(),
numVertices) );
default:
throw vtkm::cont::ErrorControlBadValue(
"CellSetSingleType unable to determine the cell type");
}
return numberOfPointsPerCell;
}
vtkm::Id CellTypeAsId;
vtkm::Id ExpectedNumberOfCellsAdded;
vtkm::Id CellShapeAsId;
vtkm::IdComponent NumberOfPointsPerCell;
};
}

@ -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);
this->DataSet.AddCellSet(cs);
vtkm::cont::CellSetExplicit<> cellSet("cells");
cellSet.Fill(numPoints, shapes, numIndices, connectivity);
this->DataSet.AddCellSet(cellSet);
}
// Read points and cell attributes

@ -58,6 +58,9 @@ private:
// Read the points
this->ReadPoints();
vtkm::Id numPoints =
this->DataSet.GetCoordinateSystem().GetData().GetNumberOfValues();
// Read the cellset
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
@ -75,21 +78,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);
this->DataSet.AddCellSet(cs);
vtkm::cont::CellSetExplicit<> cellSet("cells");
cellSet.Fill(numPoints, shapes, numIndices, connectivity);
this->DataSet.AddCellSet(cellSet);
}
// Read points and cell attributes

@ -396,6 +396,8 @@ void TestReadingPolyData(Format format)
"Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 8,
"Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 8,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == 6,
"Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetSingleType<> >(),
@ -414,6 +416,8 @@ void TestReadingStructuredPoints(Format format)
"Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 72,
"Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == 30,
"Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetStructured<3> >(),
@ -432,6 +436,8 @@ void TestReadingStructuredPointsVisIt(Format format)
"Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 64,
"Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 64,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == 27,
"Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetStructured<3> >(),
@ -452,6 +458,8 @@ void TestReadingUnstructuredGrid(Format format)
"Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 26,
"Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == 15,
"Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetExplicit<> >(),
@ -469,6 +477,8 @@ void TestReadingUnstructuredGridVisIt(Format format)
"Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 26,
"Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == 15,
"Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetExplicit<> >(),
@ -488,6 +498,8 @@ void TestReadingRectilinearGrid1(Format format)
"Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 125,
"Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 125,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == 64,
"Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetStructured<3> >(),
@ -507,6 +519,8 @@ void TestReadingRectilinearGrid2(Format format)
"Incorrect number of fields");
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == 24,
"Incorrect number of points");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 24,
"Incorrect number of points (from cell set)");
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == 6,
"Incorrect number of cells");
VTKM_TEST_ASSERT(ds.GetCellSet().IsType<vtkm::cont::CellSetStructured<3> >(),

@ -409,7 +409,7 @@ void MapperGL::RenderCells(const vtkm::cont::DynamicCellSet &cellset,
RenderStructuredLineSegments(numVerts, verts, sf);
}
else if (cellset.IsSameType(vtkm::cont::CellSetSingleType<>()) &&
cellset.Cast<vtkm::cont::CellSetSingleType<> >().GetCellTypeAsId() ==
cellset.Cast<vtkm::cont::CellSetSingleType<> >().GetCellShapeAsId() ==
vtkm::CELL_SHAPE_LINE)
{
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > verts;

@ -111,8 +111,12 @@ struct CellDeepCopy
vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
vtkm::cont::CellSetExplicit<ShapeStorage,NumIndicesStorage,ConnectivityStorage,OffsetsStorage>
newCellSet(inCellSet.GetNumberOfPoints(), inCellSet.GetName());
newCellSet.Fill(shapes, numIndices, connectivity, offsets);
newCellSet(inCellSet.GetName());
newCellSet.Fill(inCellSet.GetNumberOfPoints(),
shapes,
numIndices,
connectivity,
offsets);
outCellSet = newCellSet;
}

@ -515,7 +515,10 @@ public:
vtkm::cont::CellSetExplicit<> output;
output.Fill(shapes, numIndices, connectivity);
output.Fill(this->NewPointsOffset + uniqueNewPoints.GetNumberOfValues(),
shapes,
numIndices,
connectivity);
return output;
}

@ -337,7 +337,11 @@ public:
IdPermutationHandleType faceConn(connIndices, conn);
PermutedCellSetExplicit permutedCellSet;
permutedCellSet.Fill(pt1, pt2, faceConn);
// Warning: This cell set is created with 0 points, which simply means that
// if you call GetNumberOfPoints it will return 0, which is of course not
// consistent with the indices. We are getting away with this because this
// is a temporary cell set that is not scheduled on points.
permutedCellSet.Fill(0, pt1, pt2, faceConn);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 3> > faceVertices;
vtkm::worklet::DispatcherMapTopology<GetFace> faceHashDispatcher;

@ -633,11 +633,6 @@ vtkm::cont::CellSetSingleType< >
}
}
//assign the connectivity to the cell set
CellShapeTagTriangle triangleTag;
vtkm::cont::CellSetSingleType< > outputCells( triangleTag );
outputCells.Fill( connectivity );
//generate the vertices's
ApplyToField applyToField;
vtkm::worklet::DispatcherMapField<ApplyToField,
@ -648,6 +643,13 @@ vtkm::cont::CellSetSingleType< >
coordinateSystem,
vertices);
//assign the connectivity to the cell set
vtkm::cont::CellSetSingleType< > outputCells("contour");
outputCells.Fill( vertices.GetNumberOfValues(),
vtkm::CELL_SHAPE_TRIANGLE,
3,
connectivity );
return outputCells;
}

@ -191,8 +191,9 @@ public:
vtkm::Id numberOfPoints =
this->PointScatter->GetOutputToInputMap().GetNumberOfValues();
vtkm::cont::CellSetExplicit<ShapeStorage,NumIndicesStorage,NewConnectivityStorage,OffsetsStorage>
outCellSet(numberOfPoints, inCellSet.GetName());
outCellSet.Fill(inCellSet.GetShapesArray(FromTopology(),ToTopology()),
outCellSet(inCellSet.GetName());
outCellSet.Fill(numberOfPoints,
inCellSet.GetShapesArray(FromTopology(),ToTopology()),
inCellSet.GetNumIndicesArray(FromTopology(),ToTopology()),
newConnectivityArray,
inCellSet.GetIndexOffsetArray(FromTopology(),ToTopology()));

@ -425,7 +425,8 @@ public:
vtkm::cont::DataSet OutDataSet;
vtkm::cont::CellSetExplicit<> outCellSet;
outCellSet.Fill(cellTypes, numIndices, connectivity);
outCellSet.Fill(
coordinates.GetNumberOfValues(), cellTypes, numIndices, connectivity);
OutDataSet.AddCellSet(outCellSet);
OutDataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));

@ -171,7 +171,11 @@ public:
vtkm::cont::make_ArrayHandleGroupVec<4>(outConnectivity));
// Add cells to output cellset
cellSet.Fill(outConnectivity);
cellSet.Fill(
this->OutDataSet.GetCoordinateSystem().GetData().GetNumberOfValues(),
vtkm::CellShapeTagTetra::Id,
4,
outConnectivity);
}
};

@ -143,7 +143,11 @@ public:
vtkm::cont::make_ArrayHandleGroupVec<4>(connectivity));
// Add cells to output cellset
cellSet.Fill(connectivity);
cellSet.Fill(
this->OutDataSet.GetCoordinateSystem().GetData().GetNumberOfValues(),
vtkm::CellShapeTagTetra::Id,
4,
connectivity);
}
};

@ -174,7 +174,11 @@ public:
vtkm::cont::make_ArrayHandleGroupVec<3>(outConnectivity));
// Add cells to output cellset
cellSet.Fill(outConnectivity);
cellSet.Fill(
this->OutDataSet.GetCoordinateSystem().GetData().GetNumberOfValues(),
vtkm::CellShapeTagTriangle::Id,
3,
outConnectivity);
}
};

@ -121,7 +121,11 @@ public:
vtkm::cont::make_ArrayHandleGroupVec<3>(connectivity));
// Add cells to output cellset
cellSet.Fill(connectivity);
cellSet.Fill(
this->OutDataSet.GetCoordinateSystem().GetData().GetNumberOfValues(),
vtkm::CellShapeTagTriangle::Id,
3,
connectivity);
}
};

@ -477,9 +477,11 @@ public:
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", repPointArray));
vtkm::cont::CellSetSingleType< > triangles(vtkm::CellShapeTagTriangle(),
0, "cells");
triangles.Fill( internal::copyFromVec(pointId3Array, DeviceAdapter()) );
vtkm::cont::CellSetSingleType< > triangles("cells");
triangles.Fill( repPointArray.GetNumberOfValues(),
vtkm::CellShapeTagTriangle::Id,
3,
internal::copyFromVec(pointId3Array, DeviceAdapter()) );
output.AddCellSet( triangles );
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK

@ -77,7 +77,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);
@ -143,6 +143,9 @@ void TestClippingExplicit()
};
vtkm::Float32 expectedScalars[] = { 1, 2, 1, 0, 0.5, 0.5, 0.5 };
VTKM_TEST_ASSERT(outputCellSet.GetNumberOfPoints() == fieldSize,
"Wrong number of points in cell set.");
VTKM_TEST_ASSERT(
TestArrayHandle(outputCellSet.GetConnectivityArray(
vtkm::TopologyElementTagPoint(),vtkm::TopologyElementTagCell()),
@ -197,6 +200,9 @@ void TestClippingStrucutred()
};
vtkm::Float32 expectedScalars[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5 };
VTKM_TEST_ASSERT(outputCellSet.GetNumberOfPoints() == fieldSize,
"Wrong number of points in cell set.");
VTKM_TEST_ASSERT(
TestArrayHandle(outputCellSet.GetConnectivityArray(
vtkm::TopologyElementTagPoint(),vtkm::TopologyElementTagCell()),

@ -61,8 +61,11 @@ vtkm::cont::DataSet RunExternalFaces(vtkm::cont::DataSet &ds)
}
vtkm::cont::CellSetExplicit<> new_cs(cellset.GetNumberOfPoints(),"cells");
new_cs.Fill(output_shapes, output_numIndices, output_conn);
vtkm::cont::CellSetExplicit<> new_cs("cells");
new_cs.Fill(cellset.GetNumberOfPoints(),
output_shapes,
output_numIndices,
output_conn);
new_ds.AddCellSet(new_cs);
return new_ds;

@ -198,7 +198,7 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
const vtkm::IdComponent nCells = dim*dim*dim;
vtkm::Float32 spacing = vtkm::Float32(1./dim);
vtkm::Float32 spacing = vtkm::Float32(1./dim);
CoordinateArrayHandle coordinates(vtkm::Id3(dim+1,dim+1,dim+1),
CoordType(-.5,-.5,-.5),
CoordType(spacing,spacing,spacing));
@ -222,8 +222,11 @@ vtkm::Float32 spacing = vtkm::Float32(1./dim);
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::ASSOC_POINTS,
vtkm::cont::DynamicArrayHandle(distanceToOther)));
CellSet cellSet(HexTag(), (dim+1)*(dim+1)*(dim+1), "cells");
cellSet.Fill(connectivity);
CellSet cellSet("cells");
cellSet.Fill((dim+1)*(dim+1)*(dim+1),
HexTag::Id,
HexTraits::NUM_POINTS,
connectivity);
dataSet.AddCellSet(cellSet);

@ -53,7 +53,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)
{
@ -67,7 +67,7 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
(j + 1) * dim + i));
}
}
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(vtkm::Id(coordinates.size()));
dataSet.AddCellSet(cellSet);
return dataSet;

@ -27,11 +27,11 @@ namespace {
vtkm::cont::CellSetExplicit<>
CreateInputCellSet()
{
vtkm::cont::CellSetExplicit<> cellSet(11, "cells");
vtkm::cont::CellSetExplicit<> cellSet("cells");
cellSet.PrepareToAddCells(2, 7);
cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE,3,vtkm::make_Vec<vtkm::Id>(0,2,4));
cellSet.AddCell(vtkm::CELL_SHAPE_QUAD,4,vtkm::make_Vec<vtkm::Id>(4,2,6,8));
cellSet.CompleteAddingCells();
cellSet.CompleteAddingCells(11);
return cellSet;
}

@ -177,7 +177,7 @@ void TestExplicitGrid2D()
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::DataSet outDataSet;
vtkm::cont::CellSetSingleType<> outCellSet(vtkm::CellShapeTagTriangle(), "cells");
vtkm::cont::CellSetSingleType<> outCellSet("cells");
outDataSet.AddCellSet(outCellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
@ -215,7 +215,7 @@ void TestExplicitGrid3D()
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::DataSet outDataSet;
vtkm::cont::CellSetSingleType<> outCellSet(vtkm::CellShapeTagTetra(), "cells");
vtkm::cont::CellSetSingleType<> outCellSet("cells");
outDataSet.AddCellSet(outCellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));

@ -104,7 +104,7 @@ void TestUniformGrid2D()
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::DataSet outDataSet;
vtkm::cont::CellSetSingleType<> outCellSet(vtkm::CellShapeTagTriangle(), "cells");
vtkm::cont::CellSetSingleType<> outCellSet("cells");
outDataSet.AddCellSet(outCellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
@ -152,7 +152,7 @@ void TestUniformGrid3D()
// Create the output dataset explicit cell set with same coordinate system
vtkm::cont::DataSet outDataSet;
vtkm::cont::CellSetSingleType<> outCellSet(vtkm::CellShapeTagTetra(), "cells");
vtkm::cont::CellSetSingleType<> outCellSet("cells");
outDataSet.AddCellSet(outCellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));