Commit 37efba15 authored by Robert Maynard's avatar Robert Maynard
Browse files

CellSetSingleType now can be constructed with proper number of points

This is important so that when we execute a Cell->Point worklet we
don't have to compute the number of points from the connectivity array.
parent 23a17333
......@@ -305,7 +305,8 @@ 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(), "cells");
vtkm::cont::CellSetSingleType<> cellSet(
vtkm::CellShapeTagTetra(), numberOfInPoints, "cells");
outDataSet.AddCellSet(cellSet);
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
......
......@@ -293,7 +293,8 @@ 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(), "cells");
vtkm::cont::CellSetSingleType<> cellSet(
vtkm::CellShapeTagTetra(), numberOfInPoints, "cells");
tetDataSet.AddCellSet(cellSet);
tetDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
......
......@@ -53,6 +53,15 @@ class CellSetSingleType :
typename vtkm::cont::ArrayHandleCounting<vtkm::Id>::StorageTag > Superclass;
public:
template<typename CellShapeTag>
VTKM_CONT_EXPORT
CellSetSingleType(CellShapeTag, vtkm::Id numpoints, const std::string &name = std::string())
: Superclass(numpoints, name),
CellTypeAsId(CellShapeTag::Id)
{
}
template<typename CellShapeTag>
VTKM_CONT_EXPORT
CellSetSingleType(CellShapeTag, const std::string &name = std::string())
......@@ -61,6 +70,14 @@ public:
{
}
VTKM_CONT_EXPORT
CellSetSingleType(vtkm::Id numpoints,
const std::string &name = std::string())
: Superclass(numpoints, name),
CellTypeAsId(CellShapeTagEmpty::Id)
{
}
VTKM_CONT_EXPORT
CellSetSingleType(const std::string &name = std::string())
: Superclass(0, name),
......
......@@ -330,7 +330,7 @@ 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, cellNm);
vtkm::cont::CellSetSingleType<> cellSet(tag, coords.GetNumberOfValues(), cellNm);
cellSet.Fill(connectivity);
dataSet.AddCellSet(cellSet);
......
......@@ -37,7 +37,7 @@ class MakeTestDataSet
public:
// 1D uniform datasets.
vtkm::cont::DataSet Make1DUniformDataSet0();
// 2D uniform datasets.
vtkm::cont::DataSet Make2DUniformDataSet0();
......@@ -82,7 +82,7 @@ MakeTestDataSet::Make1DUniformDataSet0()
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
return dataSet;
}
}
//Make a simple 2D, 2 cell uniform dataset.
......@@ -592,6 +592,7 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose()
connectivity.GetPortalControl().Set(i, pointId[i]);
}
vtkm::cont::CellSetSingleType< > cellSet(vtkm::CellShapeTagTriangle(),
nPointIds,
"cells");
cellSet.Fill(connectivity);
dataSet.AddCellSet(cellSet);
......
......@@ -159,7 +159,7 @@ private:
switch(shapes.GetPortalConstControl().Get(0))
{
vtkmGenericCellShapeMacro(
(cs = vtkm::cont::CellSetSingleType<>(CellShapeTag(), "cells")));
(cs = vtkm::cont::CellSetSingleType<>(CellShapeTag(), 0, "cells")));
default:
break;
}
......
......@@ -78,7 +78,7 @@ private:
vtkm::cont::CellSetSingleType<> cs;
switch(shapes.GetPortalConstControl().Get(0))
{
vtkmGenericCellShapeMacro((cs = vtkm::cont::CellSetSingleType<>(CellShapeTag(), "cells")));
vtkmGenericCellShapeMacro((cs = vtkm::cont::CellSetSingleType<>(CellShapeTag(), 0, "cells")));
default:
break;
}
......
......@@ -478,7 +478,7 @@ public:
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", repPointArray));
vtkm::cont::CellSetSingleType< > triangles(vtkm::CellShapeTagTriangle(),
"cells");
0, "cells");
triangles.Fill( internal::copyFromVec(pointId3Array, DeviceAdapter()) );
output.AddCellSet( triangles );
......
......@@ -222,7 +222,7 @@ vtkm::Float32 spacing = vtkm::Float32(1./dim);
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::ASSOC_POINTS,
vtkm::cont::DynamicArrayHandle(distanceToOther)));
CellSet cellSet(HexTag(), "cells");
CellSet cellSet(HexTag(), (dim+1)*(dim+1)*(dim+1), "cells");
cellSet.Fill(connectivity);
dataSet.AddCellSet(cellSet);
......
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