Commit 0c182780 authored by Jeremy Meredith's avatar Jeremy Meredith

removing cell set dimensionality and splitting tetrahedralizer.

parent 59f5f248
......@@ -68,7 +68,7 @@ int mouse_state = 1;
vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
{
vtkm::cont::DataSetBuilderExplicitIterative builder;
builder.Begin(3);
builder.Begin();
builder.AddPoint( 0, 0, 0);
builder.AddPoint( 1, 0, 0);
......
......@@ -61,7 +61,7 @@ vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
{
vtkm::cont::DataSetBuilderExplicitIterative builder;
builder.Begin(2);
builder.Begin();
builder.AddPoint(0, 0, 0); // 0
builder.AddPoint(1, 0, 0); // 1
......
......@@ -39,15 +39,14 @@ class CellSet
{
public:
VTKM_CONT_EXPORT
CellSet(const std::string &name, vtkm::IdComponent dimensionality)
: Name(name), Dimensionality(dimensionality), LogicalStructure()
CellSet(const std::string &name)
: Name(name), LogicalStructure()
{
}
VTKM_CONT_EXPORT
CellSet(const vtkm::cont::CellSet &src)
: Name(src.Name),
Dimensionality(src.Dimensionality),
LogicalStructure(src.LogicalStructure)
{ }
......@@ -55,7 +54,6 @@ public:
CellSet &operator=(const vtkm::cont::CellSet &src)
{
this->Name = src.Name;
this->Dimensionality = src.Dimensionality;
this->LogicalStructure = src.LogicalStructure;
return *this;
}
......@@ -69,19 +67,6 @@ public:
return this->Name;
}
/// The Dimensionality of the cells inside the cell set.
/// Lines = 1
/// Triangles, Quads = 2
/// Tets, Hexs, etc = 3
///
/// CellSetExplicit has the ability to contain cells of multiple
/// dimensions. These datasets generally report a dimensionality
/// of 3.
virtual vtkm::IdComponent GetDimensionality() const
{
return this->Dimensionality;
}
virtual vtkm::Id GetNumberOfCells() const = 0;
virtual vtkm::Id GetNumberOfFaces() const
......@@ -100,7 +85,6 @@ public:
protected:
std::string Name;
vtkm::IdComponent Dimensionality;
vtkm::cont::LogicalStructure LogicalStructure;
};
......
......@@ -107,9 +107,8 @@ public:
VTKM_CONT_EXPORT
CellSetExplicit(vtkm::Id numpoints = 0,
const std::string &name = std::string(),
vtkm::IdComponent dimensionality = 3)
: CellSet(name, dimensionality),
const std::string &name = std::string())
: CellSet(name),
ConnectivityLength(-1),
NumberOfCells(-1),
NumberOfPoints(numpoints)
......@@ -117,8 +116,8 @@ public:
}
VTKM_CONT_EXPORT
CellSetExplicit(vtkm::Id numpoints, int dimensionality)
: CellSet(std::string(), dimensionality),
CellSetExplicit(vtkm::Id numpoints)
: CellSet(std::string()),
ConnectivityLength(-1),
NumberOfCells(-1),
NumberOfPoints(numpoints)
......@@ -438,8 +437,7 @@ public:
virtual void PrintSummary(std::ostream &out) const
{
out << " ExplicitCellSet: " << this->Name
<< " dim= " << this->Dimensionality << std::endl;
out << " ExplicitCellSet: " << this->Name << std::endl;
out << " PointToCell: " << std::endl;
this->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
......
......@@ -41,18 +41,16 @@ public:
VTKM_CONT_EXPORT
CellSetGeneralPermutation(const PermutationArrayHandleType& validCellIds,
const OriginalCellSet& cellset,
const std::string &name,
vtkm::IdComponent dimensionality)
: CellSet(name,dimensionality),
const std::string &name)
: CellSet(name),
ValidCellIds(validCellIds),
FullCellSet(cellset)
{
}
VTKM_CONT_EXPORT
CellSetGeneralPermutation(const std::string &name,
vtkm::IdComponent dimensionality)
: CellSet(name,dimensionality),
CellSetGeneralPermutation(const std::string &name)
: CellSet(name),
ValidCellIds(),
FullCellSet()
{
......@@ -140,16 +138,14 @@ public:
VTKM_CONT_EXPORT
CellSetPermutation(const PermutationArrayHandleType& validCellIds,
const OriginalCellSet& cellset,
const std::string &name = std::string(),
vtkm::IdComponent dimensionality = 3)
: ParentType(validCellIds, cellset, name, dimensionality)
const std::string &name = std::string())
: ParentType(validCellIds, cellset, name)
{
}
VTKM_CONT_EXPORT
CellSetPermutation(const std::string &name = std::string(),
vtkm::IdComponent dimensionality = 3)
: ParentType(name, dimensionality)
CellSetPermutation(const std::string &name = std::string())
: ParentType(name)
{
}
......
......@@ -56,14 +56,14 @@ public:
template<typename CellShapeTag>
VTKM_CONT_EXPORT
CellSetSingleType(CellShapeTag, const std::string &name = std::string())
: Superclass(0, name, vtkm::CellTraits<CellShapeTag>::TOPOLOGICAL_DIMENSIONS),
: Superclass(0, name),
CellTypeAsId(CellShapeTag::Id)
{
}
VTKM_CONT_EXPORT
CellSetSingleType(const std::string &name = std::string())
: Superclass(0, name, vtkm::CellTraits<CellShapeTagEmpty>::TOPOLOGICAL_DIMENSIONS),
: Superclass(0, name),
CellTypeAsId(CellShapeTagEmpty::Id)
{
}
......
......@@ -46,7 +46,7 @@ public:
VTKM_CONT_EXPORT
CellSetStructured(const std::string &name = std::string())
: CellSet(name,Dimension)
: CellSet(name)
{
}
......@@ -130,8 +130,7 @@ public:
virtual void PrintSummary(std::ostream &out) const
{
out << " StructuredCellSet: " << this->GetName()
<< " dim= " << this->GetDimensionality() << std::endl;
out << " StructuredCellSet: " << this->GetName() << std::endl;
this->Structure.PrintSummary(out);
}
......
......@@ -61,14 +61,13 @@ public:
const std::vector<vtkm::UInt8> &shapes,
const std::vector<vtkm::IdComponent> &numIndices,
const std::vector<vtkm::Id> &connectivity,
int dimensionality=2,
const std::string &coordsNm="coords",
const std::string &cellNm="cells")
{
std::vector<T> zVals(xVals.size(),0);
return DataSetBuilderExplicit::Create(xVals,yVals,zVals,
shapes,numIndices,connectivity,
dimensionality, coordsNm,cellNm);
coordsNm,cellNm);
}
template<typename T>
......@@ -81,7 +80,6 @@ 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");
......@@ -95,14 +93,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 DataSetBuilderExplicit::BuildDataSet(
xVals,yVals,zVals,
shapes,numIndices,connectivity,
dimensionality, coordsNm,cellNm);
coordsNm,cellNm);
}
......@@ -114,7 +111,6 @@ 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");
......@@ -126,7 +122,6 @@ 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")
{
......@@ -134,7 +129,6 @@ public:
shapes,
numIndices,
connectivity,
dimensionality,
coordsNm,
cellNm);
}
......@@ -176,7 +170,6 @@ 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);
......@@ -188,7 +181,6 @@ 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);
......@@ -211,7 +203,6 @@ 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)
{
......@@ -232,7 +223,7 @@ DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
return DataSetBuilderExplicit::BuildDataSet(
Xc,Yc,Zc, Sc,Nc,Cc, dimensionality, coordsNm, cellNm);
Xc,Yc,Zc, Sc,Nc,Cc, coordsNm, cellNm);
}
template<typename T>
......@@ -244,7 +235,6 @@ DataSetBuilderExplicit::BuildDataSet(
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)
{
......@@ -258,7 +248,7 @@ 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, dimensionality);
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm);
cellSet.Fill(shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
......@@ -272,7 +262,6 @@ 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)
{
......@@ -287,7 +276,7 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
return DataSetBuilderExplicit::Create(
coordsArray, Sc, Nc, Cc, dimensionality, coordsNm, cellNm);
coordsArray, Sc, Nc, Cc, coordsNm, cellNm);
}
template<typename T>
......@@ -297,7 +286,6 @@ 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)
{
......@@ -306,7 +294,7 @@ 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, dimensionality);
vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm);
cellSet.Fill(shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
......@@ -359,11 +347,9 @@ public:
DataSetBuilderExplicitIterative() {}
VTKM_CONT_EXPORT
void Begin(int dim,
const std::string &coordName="coords",
void Begin(const std::string &coordName="coords",
const std::string &cellName="cells")
{
this->dimensionality = dim;
this->coordNm = coordName;
this->cellNm = cellName;
this->points.resize(0);
......@@ -447,7 +433,6 @@ public:
private:
std::string coordNm, cellNm;
int dimensionality;
std::vector<vtkm::Vec<vtkm::Float32,3> > points;
std::vector<vtkm::UInt8> shapes;
......@@ -459,7 +444,7 @@ vtkm::cont::DataSet
DataSetBuilderExplicitIterative::Create()
{
DataSetBuilderExplicit dsb;
return dsb.Create(points, shapes, numIdx, connectivity, dimensionality, coordNm, cellNm);
return dsb.Create(points, shapes, numIdx, connectivity, coordNm, cellNm);
}
......
......@@ -262,7 +262,7 @@ MakeTestDataSet::Make3DExplicitDataSet0()
conn.push_back(4);
//Create the dataset.
dataSet = dsb.Create(coords, shapes, numindices, conn, 2, "coordinates", "cells");
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
......@@ -334,7 +334,7 @@ MakeTestDataSet::Make3DExplicitDataSet1()
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", coordinates, nVerts));
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", 2);
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "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));
......
......@@ -67,8 +67,7 @@ public:
typedef vtkm::cont::CellSetPermutation<CellSetType> PermutationCellSetType;
PermutationCellSetType permCellSet(*this->ValidIds, cellset,
cellset.GetName(),
cellset.GetDimensionality());
cellset.GetName());
this->Output->AddCellSet(permCellSet);
}
......
......@@ -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", nCells);
vtkm::cont::CellSetExplicit<> cs(nVerts, "cells");
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
......
......@@ -48,7 +48,7 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", coordinates));
vtkm::cont::CellSetExplicit<> cellSet(vtkm::Id(coordinates.size()), "cells", 3);
vtkm::cont::CellSetExplicit<> cellSet(vtkm::Id(coordinates.size()), "cells");
cellSet.PrepareToAddCells(numCells, numCells * 4);
for (vtkm::Id j = 0; j < dim - 1; ++j)
{
......
......@@ -39,6 +39,8 @@ set(headers
StreamLineUniformGrid.h
TetrahedralizeExplicitGrid.h
TetrahedralizeUniformGrid.h
TriangulateExplicitGrid.h
TriangulateUniformGrid.h
Threshold.h
VertexClustering.h
)
......
......@@ -46,32 +46,6 @@ class TetrahedralizeFilterExplicitGrid
{
public:
//
// Worklet to count the number of triangles generated per cell
//
class TrianglesPerCell : public vtkm::worklet::WorkletMapField
{
public:
typedef void ControlSignature(FieldIn<> shapes,
FieldIn<> numPoints,
ExecObject tables,
FieldOut<> triangleCount);
typedef _4 ExecutionSignature(_1,_2,_3);
typedef _1 InputDomain;
VTKM_CONT_EXPORT
TrianglesPerCell() {}
VTKM_EXEC_EXPORT
vtkm::IdComponent operator()(
vtkm::UInt8 shape,
vtkm::IdComponent numPoints,
const vtkm::worklet::internal::TriangulateTablesExecutionObject<DeviceAdapter> &tables) const
{
return tables.GetCount(vtkm::CellShapeTagGeneric(shape), numPoints);
}
};
//
// Worklet to count the number of tetrahedra generated per cell
//
......@@ -80,7 +54,7 @@ public:
public:
typedef void ControlSignature(FieldIn<> shapes,
ExecObject tables,
FieldOut<> triangleCount);
FieldOut<> tetrahedronCount);
typedef _3 ExecutionSignature(_1, _2);
typedef _1 InputDomain;
......@@ -96,55 +70,6 @@ public:
}
};
//
// Worklet to turn cells into triangles
// Vertices remain the same and each cell is processed with needing topology
//
class TriangulateCell : public vtkm::worklet::WorkletMapPointToCell
{
public:
typedef void ControlSignature(TopologyIn topology,
ExecObject tables,
FieldOutCell<> connectivityOut);
typedef void ExecutionSignature(CellShape, PointIndices, _2, _3, VisitIndex);
typedef _1 InputDomain;
typedef vtkm::worklet::ScatterCounting ScatterType;
VTKM_CONT_EXPORT
ScatterType GetScatter() const
{
return this->Scatter;
}
template<typename CountArrayType>
VTKM_CONT_EXPORT
TriangulateCell(const CountArrayType &countArray)
: Scatter(countArray, DeviceAdapter())
{ }
// Each cell produces triangles and write result at the offset
template<typename CellShapeTag,
typename ConnectivityInVec,
typename ConnectivityOutVec>
VTKM_EXEC_EXPORT
void operator()(
CellShapeTag shape,
const ConnectivityInVec &connectivityIn,
const vtkm::worklet::internal::TriangulateTablesExecutionObject<DeviceAdapter> &tables,
ConnectivityOutVec &connectivityOut,
vtkm::IdComponent visitIndex) const
{
vtkm::Vec<vtkm::IdComponent,3> triIndices =
tables.GetIndices(shape, visitIndex);
connectivityOut[0] = connectivityIn[triIndices[0]];
connectivityOut[1] = connectivityIn[triIndices[1]];
connectivityOut[2] = connectivityIn[triIndices[2]];
}
private:
ScatterType Scatter;
};
//
// Worklet to turn cells into tetrahedra
// Vertices remain the same and each cell is processed with needing topology
......@@ -207,7 +132,7 @@ public:
vtkm::cont::DataSet OutDataSet; // output dataset with explicit cell set
//
// Populate the output dataset with triangles or tetrahedra based on input explicit dataset
// Populate the output dataset with tetrahedra based on input explicit dataset
//
void Run()
{
......@@ -217,9 +142,6 @@ public:
vtkm::cont::CellSetSingleType<> &cellSet =
this->OutDataSet.GetCellSet(0).template Cast<vtkm::cont::CellSetSingleType<> >();
// Input dataset vertices and cell counts
vtkm::Id dimensionality = inCellSet.GetDimensionality();
// Input topology
vtkm::cont::ArrayHandle<vtkm::UInt8> inShapes = inCellSet.GetShapesArray(
vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
......@@ -229,54 +151,24 @@ public:
// Output topology
vtkm::cont::ArrayHandle<vtkm::Id> outConnectivity;
if (dimensionality == 2)
{
vtkm::worklet::internal::TriangulateTables tables;
// Determine the number of output cells each input cell will generate
vtkm::cont::ArrayHandle<vtkm::IdComponent> numOutCellArray;
vtkm::worklet::DispatcherMapField<TrianglesPerCell,DeviceAdapter>
triPerCellDispatcher;
triPerCellDispatcher.Invoke(inShapes,
inNumIndices,
tables.PrepareForInput(DeviceAdapter()),
numOutCellArray);
// Build new cells
TriangulateCell triangulateWorklet(numOutCellArray);
vtkm::worklet::DispatcherMapTopology<TriangulateCell,DeviceAdapter>
triangulateDispatcher(triangulateWorklet);
triangulateDispatcher.Invoke(
inCellSet,
tables.PrepareForInput(DeviceAdapter()),
vtkm::cont::make_ArrayHandleGroupVec<3>(outConnectivity));
}
else if (dimensionality == 3)
{
vtkm::worklet::internal::TetrahedralizeTables tables;
// Determine the number of output cells each input cell will generate
vtkm::cont::ArrayHandle<vtkm::IdComponent> numOutCellArray;
vtkm::worklet::DispatcherMapField<TetrahedraPerCell,DeviceAdapter>
tetPerCellDispatcher;
tetPerCellDispatcher.Invoke(inShapes,
tables.PrepareForInput(DeviceAdapter()),
numOutCellArray);
// Build new cells
TetrahedralizeCell tetrahedralizeWorklet(numOutCellArray);
vtkm::worklet::DispatcherMapTopology<TetrahedralizeCell,DeviceAdapter>
tetrahedralizeDispatcher(tetrahedralizeWorklet);
tetrahedralizeDispatcher.Invoke(
inCellSet,
tables.PrepareForInput(DeviceAdapter()),
vtkm::cont::make_ArrayHandleGroupVec<4>(outConnectivity));
}
else
{
throw vtkm::cont::ErrorControlBadValue(
"Unsupported dimensionality for TetrahedralizeExplicitGrid.");
}
vtkm::worklet::internal::TetrahedralizeTables tables;
// Determine the number of output cells each input cell will generate
vtkm::cont::ArrayHandle<vtkm::IdComponent> numOutCellArray;
vtkm::worklet::DispatcherMapField<TetrahedraPerCell,DeviceAdapter>
tetPerCellDispatcher;
tetPerCellDispatcher.Invoke(inShapes,
tables.PrepareForInput(DeviceAdapter()),
numOutCellArray);
// Build new cells
TetrahedralizeCell tetrahedralizeWorklet(numOutCellArray);
vtkm::worklet::DispatcherMapTopology<TetrahedralizeCell,DeviceAdapter>
tetrahedralizeDispatcher(tetrahedralizeWorklet);
tetrahedralizeDispatcher.Invoke(
inCellSet,
tables.PrepareForInput(DeviceAdapter()),
vtkm::cont::make_ArrayHandleGroupVec<4>(outConnectivity));
// Add cells to output cellset
cellSet.Fill(outConnectivity);
......
......@@ -40,12 +40,6 @@ namespace worklet {
namespace detail {
VTKM_EXEC_CONSTANT_EXPORT
const static vtkm::IdComponent StructuredTriangleIndices[2][3] = {
{ 0, 1, 2 },
{ 0, 2, 3 }
};
VTKM_EXEC_CONSTANT_EXPORT
const static vtkm::IdComponent StructuredTetrahedronIndices[2][5][4] = {
{
......@@ -72,42 +66,6 @@ class TetrahedralizeFilterUniformGrid
{
public:
//
// Worklet to turn quads into triangles
// Vertices remain the same and each cell is processed with needing topology
//
class TriangulateCell : public vtkm::worklet::WorkletMapPointToCell
{
public:
typedef void ControlSignature(TopologyIn topology,
FieldOutCell<> connectivityOut);
typedef void ExecutionSignature(PointIndices, _2, VisitIndex);
typedef _1 InputDomain;
typedef vtkm::worklet::ScatterUniform ScatterType;
VTKM_CONT_EXPORT
ScatterType GetScatter() const
{
return ScatterType(2);
}
VTKM_CONT_EXPORT
TriangulateCell()
{ }
// Each quad cell produces 2 triangle cells
template<typename ConnectivityInVec, typename ConnectivityOutVec>
VTKM_EXEC_EXPORT
void operator()(const ConnectivityInVec &connectivityIn,
ConnectivityOutVec &connectivityOut,
vtkm::IdComponent visitIndex) const
{
connectivityOut[0] = connectivityIn[detail::StructuredTriangleIndices[visitIndex][0]];
connectivityOut[1] = connectivityIn[detail::StructuredTriangleIndices[visitIndex][1]];
connectivityOut[2] = connectivityIn[detail::StructuredTriangleIndices[visitIndex][2]];
}
};
//
// Worklet to turn hexahedra into tetrahedra
// Vertices remain the same and each cell is processed with needing topology
......@@ -168,7 +126,7 @@ public:
vtkm::cont::DataSet OutDataSet; // output dataset with explicit cell set
//
// Populate the output dataset with triangles or tetrahedra based on input uniform dataset
// Populate the output dataset with tetrahedra based on input uniform dataset
//
void Run()
{
......@@ -178,27 +136,11 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
if (cellSet.GetDimensionality() == 2)
{
vtkm::cont::CellSetStructured<2> inCellSet;
InDataSet.GetCellSet(0).CopyTo(inCellSet);
vtkm::worklet::DispatcherMapTopology<TriangulateCell,DeviceAdapter> dispatcher;
dispatcher.Invoke(inCellSet,
vtkm::cont::make_ArrayHandleGroupVec<3>(connectivity));
}
else if (cellSet.GetDimensionality() == 3)
{
vtkm::cont::CellSetStructured<3> inCellSet;
InDataSet.GetCellSet(0).CopyTo(inCellSet);
vtkm::worklet::DispatcherMapTopology<TetrahedralizeCell,DeviceAdapter> dispatcher;
dispatcher.Invoke(inCellSet,
vtkm::cont::make_ArrayHandleGroupVec<4>(connectivity));
}
else
{
throw vtkm::cont::ErrorControlBadValue(
"Unsupported dimensionality for TetrahedralizeUniformGrid.");
}
vtkm::cont::CellSetStructured<3> inCellSet;
InDataSet.GetCellSet(0).CopyTo(inCellSet);
vtkm::worklet::DispatcherMapTopology<TetrahedralizeCell,DeviceAdapter> dispatcher;
dispatcher.Invoke(inCellSet,
vtkm::cont::make_ArrayHandleGroupVec<4>(connectivity));
// Add cells to output cellset
cellSet.Fill(connectivity);
......
......@@ -140,8 +140,7 @@ public:
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>
::StreamCompact(passFlags, this->ValidCellIds);
return OutputType(this->ValidCellIds, cellSet, cellSet.GetName(),
cellSet.GetDimensionality());
return OutputType(this->ValidCellIds, cellSet, cellSet.GetName());
}
class PermuteCellData
......
//============================================================================
// Copyright (c) Kitware, Inc.