Update vtkm tests and examples to use DataSetBuilders.
This commit is contained in:
parent
449c425a23
commit
e7456fa120
@ -26,6 +26,7 @@
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
@ -66,33 +67,26 @@ int mouse_state = 1;
|
||||
//
|
||||
vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 18;
|
||||
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
||||
CoordType coordinates[nVerts] = {
|
||||
CoordType(0, 0, 0),
|
||||
CoordType(1, 0, 0),
|
||||
CoordType(2, 0, 0),
|
||||
CoordType(3, 0, 0),
|
||||
CoordType(0, 1, 0),
|
||||
CoordType(1, 1, 0),
|
||||
CoordType(2, 1, 0),
|
||||
CoordType(2.5, 1, 0),
|
||||
CoordType(0, 2, 0),
|
||||
CoordType(1, 2, 0),
|
||||
CoordType(0.5, 0.5, 1),
|
||||
CoordType(1, 0, 1),
|
||||
CoordType(2, 0, 1),
|
||||
CoordType(3, 0, 1),
|
||||
CoordType(1, 1, 1),
|
||||
CoordType(2, 1, 1),
|
||||
CoordType(2.5, 1, 1),
|
||||
CoordType(0.5, 1.5, 1),
|
||||
};
|
||||
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
||||
std::vector< CoordType > coordinates;
|
||||
coordinates.push_back( CoordType(0, 0, 0) );
|
||||
coordinates.push_back( CoordType(1, 0, 0) );
|
||||
coordinates.push_back( CoordType(2, 0, 0) );
|
||||
coordinates.push_back( CoordType(3, 0, 0) );
|
||||
coordinates.push_back( CoordType(0, 1, 0) );
|
||||
coordinates.push_back( CoordType(1, 1, 0) );
|
||||
coordinates.push_back( CoordType(2, 1, 0) );
|
||||
coordinates.push_back( CoordType(2.5, 1, 0) );
|
||||
coordinates.push_back( CoordType(0, 2, 0) );
|
||||
coordinates.push_back( CoordType(1, 2, 0) );
|
||||
coordinates.push_back( CoordType(0.5, 0.5, 1) );
|
||||
coordinates.push_back( CoordType(1, 0, 1) );
|
||||
coordinates.push_back( CoordType(2, 0, 1) );
|
||||
coordinates.push_back( CoordType(3, 0, 1) );
|
||||
coordinates.push_back( CoordType(1, 1, 1) );
|
||||
coordinates.push_back( CoordType(2, 1, 1) );
|
||||
coordinates.push_back( CoordType(2.5, 1, 1) );
|
||||
coordinates.push_back( CoordType(0.5, 1.5, 1) );
|
||||
|
||||
std::vector<vtkm::UInt8> shapes;
|
||||
shapes.push_back(vtkm::CELL_SHAPE_TETRA);
|
||||
@ -134,13 +128,8 @@ vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
|
||||
conn.push_back(8);
|
||||
conn.push_back(17);
|
||||
|
||||
static const vtkm::IdComponent ndim = 3;
|
||||
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", ndim);
|
||||
cellSet.FillViaCopy(shapes, numindices, conn);
|
||||
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
return builder.Create(coordinates, shapes, numindices, conn);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <vtkm/worklet/TetrahedralizeExplicitGrid.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
@ -63,27 +64,23 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
|
||||
|
||||
const int nVerts = 16;
|
||||
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
||||
CoordType coordinates[nVerts] = {
|
||||
CoordType(0, 0, 0), // 0
|
||||
CoordType(1, 0, 0), // 1
|
||||
CoordType(2, 0, 0), // 2
|
||||
CoordType(3, 0, 0), // 3
|
||||
CoordType(0, 1, 0), // 4
|
||||
CoordType(1, 1, 0), // 5
|
||||
CoordType(2, 1, 0), // 6
|
||||
CoordType(3, 1, 0), // 7
|
||||
CoordType(0, 2, 0), // 8
|
||||
CoordType(1, 2, 0), // 9
|
||||
CoordType(2, 2, 0), // 10
|
||||
CoordType(3, 2, 0), // 11
|
||||
CoordType(0, 3, 0), // 12
|
||||
CoordType(3, 3, 0), // 13
|
||||
CoordType(1, 4, 0), // 14
|
||||
CoordType(2, 4, 0), // 15
|
||||
};
|
||||
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
||||
std::vector< CoordType > coordinates;
|
||||
coordinates.push_back( CoordType(0, 0, 0) ); // 0
|
||||
coordinates.push_back( CoordType(1, 0, 0) ); // 1
|
||||
coordinates.push_back( CoordType(2, 0, 0) ); // 2
|
||||
coordinates.push_back( CoordType(3, 0, 0) ); // 3
|
||||
coordinates.push_back( CoordType(0, 1, 0) ); // 4
|
||||
coordinates.push_back( CoordType(1, 1, 0) ); // 5
|
||||
coordinates.push_back( CoordType(2, 1, 0) ); // 6
|
||||
coordinates.push_back( CoordType(3, 1, 0) ); // 7
|
||||
coordinates.push_back( CoordType(0, 2, 0) ); // 8
|
||||
coordinates.push_back( CoordType(1, 2, 0) ); // 9
|
||||
coordinates.push_back( CoordType(2, 2, 0) ); // 10
|
||||
coordinates.push_back( CoordType(3, 2, 0) ); // 11
|
||||
coordinates.push_back( CoordType(0, 3, 0) ); // 12
|
||||
coordinates.push_back( CoordType(3, 3, 0) ); // 13
|
||||
coordinates.push_back( CoordType(1, 4, 0) ); // 14
|
||||
coordinates.push_back( CoordType(2, 4, 0) ); // 15
|
||||
|
||||
std::vector<vtkm::UInt8> shapes;
|
||||
shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE);
|
||||
@ -139,13 +136,9 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
|
||||
conn.push_back(14);
|
||||
conn.push_back(12);
|
||||
|
||||
static const vtkm::IdComponent ndim = 2;
|
||||
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", ndim);
|
||||
cellSet.FillViaCopy(shapes, numindices, conn);
|
||||
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
return builder.Create(coordinates, shapes, numindices, conn);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -236,52 +236,6 @@ public:
|
||||
this->NumberOfCells = this->ConnectivityLength = -1;
|
||||
}
|
||||
|
||||
/// Second method to add cells -- all at once.
|
||||
/// Copies the data from the vectors, so they can be released.
|
||||
VTKM_CONT_EXPORT
|
||||
void FillViaCopy(const std::vector<vtkm::UInt8> &cellTypes,
|
||||
const std::vector<vtkm::IdComponent> &numIndices,
|
||||
const std::vector<vtkm::Id> &connectivity,
|
||||
const std::vector<vtkm::Id> &offsets = std::vector<vtkm::Id>() )
|
||||
{
|
||||
|
||||
this->PointToCell.Shapes.Allocate( static_cast<vtkm::Id>(cellTypes.size()) );
|
||||
std::copy(cellTypes.begin(), cellTypes.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->PointToCell.Shapes.GetPortalControl()));
|
||||
|
||||
this->PointToCell.NumIndices.Allocate( static_cast<vtkm::IdComponent>(numIndices.size()) );
|
||||
std::copy(numIndices.begin(), numIndices.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->PointToCell.NumIndices.GetPortalControl()));
|
||||
|
||||
this->PointToCell.Connectivity.Allocate( static_cast<vtkm::Id>(connectivity.size()) );
|
||||
std::copy(connectivity.begin(), connectivity.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->PointToCell.Connectivity.GetPortalControl()));
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
|
||||
if(offsets.size() == cellTypes.size())
|
||||
{
|
||||
this->PointToCell.IndexOffsets.Allocate( static_cast<vtkm::Id>(offsets.size()) );
|
||||
std::copy(offsets.begin(), offsets.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->PointToCell.IndexOffsets.GetPortalControl()));
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->PointToCell.IndexOffsetsValid = false;
|
||||
if (offsets.size() != 0)
|
||||
{
|
||||
throw vtkm::cont::ErrorControlBadValue(
|
||||
"Explicit cell offsets array unexpected size. "
|
||||
"Use an empty array to automatically generate.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
@ -154,36 +154,6 @@ public:
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
}
|
||||
|
||||
/// Second method to add cells -- all at once.
|
||||
/// Copies the data from the vectors, so they can be released.
|
||||
VTKM_CONT_EXPORT
|
||||
void FillViaCopy(const std::vector<vtkm::Id> &connectivity)
|
||||
{
|
||||
vtkm::IdComponent numberOfPointsPerCell = this->DetermineNumberOfPoints();
|
||||
const vtkm::Id connectSize = static_cast<vtkm::Id>(connectivity.size());
|
||||
|
||||
const vtkm::Id length = connectSize / numberOfPointsPerCell;
|
||||
const vtkm::UInt8 shapeTypeValue = static_cast<vtkm::UInt8>(this->CellTypeAsId);
|
||||
this->PointToCell.Shapes =
|
||||
vtkm::cont::make_ArrayHandleConstant(shapeTypeValue, length);
|
||||
this->PointToCell.NumIndices =
|
||||
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell,
|
||||
length);
|
||||
this->PointToCell.IndexOffsets =
|
||||
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0),
|
||||
static_cast<vtkm::Id>(numberOfPointsPerCell),
|
||||
length );
|
||||
|
||||
|
||||
this->PointToCell.Connectivity.Allocate( connectSize );
|
||||
std::copy(connectivity.begin(), connectivity.end(),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->PointToCell.Connectivity.GetPortalControl()));
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
}
|
||||
|
||||
private:
|
||||
template< typename CellShapeTag>
|
||||
void DetermineNumberOfPoints(CellShapeTag,
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
|
||||
@ -62,27 +64,13 @@ private:
|
||||
|
||||
static inline vtkm::cont::DataSet make_SingleTypeDataSet()
|
||||
{
|
||||
using vtkm::cont::Field;
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 5;
|
||||
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
||||
CoordType coordinates[nVerts] = {
|
||||
CoordType(0, 0, 0),
|
||||
CoordType(1, 0, 0),
|
||||
CoordType(1, 1, 0),
|
||||
CoordType(2, 1, 0),
|
||||
CoordType(2, 2, 0)
|
||||
};
|
||||
|
||||
//Set coordinate system
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
||||
|
||||
//Set point scalar
|
||||
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||
dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
||||
std::vector< CoordType > coordinates;
|
||||
coordinates.push_back( CoordType(0, 0, 0) );
|
||||
coordinates.push_back( CoordType(1, 0, 0) );
|
||||
coordinates.push_back( CoordType(1, 1, 0) );
|
||||
coordinates.push_back( CoordType(2, 1, 0) );
|
||||
coordinates.push_back( CoordType(2, 2, 0) );
|
||||
|
||||
std::vector<vtkm::Id> conn;
|
||||
// First Cell
|
||||
@ -98,13 +86,19 @@ private:
|
||||
conn.push_back(3);
|
||||
conn.push_back(4);
|
||||
|
||||
vtkm::cont::CellSetSingleType<> cellSet(vtkm::CellShapeTagTriangle(),
|
||||
"cells");
|
||||
cellSet.FillViaCopy(conn);
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
ds = builder.Create(coordinates, vtkm::CellShapeTagTriangle(), conn);
|
||||
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
//Set point scalar
|
||||
const int nVerts = 5;
|
||||
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||
|
||||
vtkm::cont::DataSetFieldAdd fieldAdder;
|
||||
fieldAdder.AddPointField(ds, "pointvar", vars, nVerts);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
static void TestDataSet_SingleType()
|
||||
|
@ -54,27 +54,13 @@ bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage> &ah, const T *exp
|
||||
|
||||
inline vtkm::cont::DataSet make_SingleTypeDataSet()
|
||||
{
|
||||
using vtkm::cont::Field;
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 5;
|
||||
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
||||
CoordType coordinates[nVerts] = {
|
||||
CoordType(0, 0, 0),
|
||||
CoordType(1, 0, 0),
|
||||
CoordType(1, 1, 0),
|
||||
CoordType(2, 1, 0),
|
||||
CoordType(2, 2, 0)
|
||||
};
|
||||
|
||||
//Set coordinate system
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
||||
|
||||
//Set point scalar
|
||||
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||
dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
||||
std::vector< CoordType > coordinates;
|
||||
coordinates.push_back( CoordType(0, 0, 0) );
|
||||
coordinates.push_back( CoordType(1, 0, 0) );
|
||||
coordinates.push_back( CoordType(1, 1, 0) );
|
||||
coordinates.push_back( CoordType(2, 1, 0) );
|
||||
coordinates.push_back( CoordType(2, 2, 0) );
|
||||
|
||||
std::vector<vtkm::Id> conn;
|
||||
// First Cell
|
||||
@ -90,13 +76,18 @@ inline vtkm::cont::DataSet make_SingleTypeDataSet()
|
||||
conn.push_back(3);
|
||||
conn.push_back(4);
|
||||
|
||||
vtkm::cont::CellSetSingleType<> cellSet(vtkm::CellShapeTagTriangle(),
|
||||
"cells");
|
||||
cellSet.FillViaCopy(conn);
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
ds = builder.Create(coordinates, vtkm::CellShapeTagTriangle(), conn);
|
||||
|
||||
dataSet.AddCellSet(cellSet);
|
||||
//Set point scalar
|
||||
const int nVerts = 5;
|
||||
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||
|
||||
return dataSet;
|
||||
vtkm::cont::DataSetFieldAdd fieldAdder;
|
||||
fieldAdder.AddPointField(ds, "pointvar", vars, nVerts);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
void TestDataSet_Explicit()
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/DataSetBuilderRegular.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -58,42 +61,39 @@ bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage> &ah, const T *exp
|
||||
|
||||
vtkm::cont::DataSet MakeTestDatasetExplicit()
|
||||
{
|
||||
static const vtkm::Id numVerts = 4;
|
||||
static const vtkm::Id numCells = 2;
|
||||
static const Coord3D coords[numVerts] = {
|
||||
Coord3D(0.0f, 0.0f, 0.0f),
|
||||
Coord3D(1.0f, 0.0f, 0.0f),
|
||||
Coord3D(1.0f, 1.0f, 0.0f),
|
||||
Coord3D(0.0f, 1.0f, 0.0f),
|
||||
};
|
||||
static vtkm::Float32 values[] = { 1.0, 2.0, 1.0, 0.0 };
|
||||
static vtkm::UInt8 shapes[] = { vtkm::CELL_SHAPE_TRIANGLE, vtkm::CELL_SHAPE_TRIANGLE };
|
||||
static vtkm::IdComponent numInds[] = { 3, 3 };
|
||||
static vtkm::Id connectivity[] = { 0, 1, 3, 3, 1, 2 };
|
||||
std::vector<Coord3D> coords;
|
||||
coords.push_back( Coord3D(0.0f, 0.0f, 0.0f) );
|
||||
coords.push_back( Coord3D(1.0f, 0.0f, 0.0f) );
|
||||
coords.push_back( Coord3D(1.0f, 1.0f, 0.0f) );
|
||||
coords.push_back( Coord3D(0.0f, 1.0f, 0.0f) );
|
||||
|
||||
std::vector<vtkm::Id> connectivity;
|
||||
connectivity.push_back(0);
|
||||
connectivity.push_back(1);
|
||||
connectivity.push_back(3);
|
||||
connectivity.push_back(3);
|
||||
connectivity.push_back(1);
|
||||
connectivity.push_back(2);
|
||||
|
||||
vtkm::cont::DataSet ds;
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", 1, coords, numVerts));
|
||||
ds.AddField(vtkm::cont::Field("scalars", 1, vtkm::cont::Field::ASSOC_POINTS, values,
|
||||
numVerts));
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
ds = builder.Create(coords, vtkm::CellShapeTagTriangle(), connectivity);
|
||||
|
||||
std::vector<vtkm::UInt8> shapesVec(shapes, shapes + numCells);
|
||||
std::vector<vtkm::IdComponent> numIndsVec(numInds, numInds + numCells);
|
||||
std::vector<vtkm::Id> connectivityVec(connectivity, connectivity + (numCells * 3));
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cs(numVerts, "cells", 3);
|
||||
cs.FillViaCopy(shapesVec, numIndsVec, connectivityVec);
|
||||
|
||||
ds.AddCellSet(cs);
|
||||
std::vector<vtkm::Float32> values;
|
||||
values.push_back(1.0);
|
||||
values.push_back(2.0);
|
||||
values.push_back(1.0);
|
||||
values.push_back(0.0);
|
||||
vtkm::cont::DataSetFieldAdd fieldAdder;
|
||||
fieldAdder.AddPointField(ds, "scalars", values);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet MakeTestDatasetStructured()
|
||||
{
|
||||
static const vtkm::Vec<vtkm::Float32, 3> origin(0.0f, 0.0f, 0.0f);
|
||||
static const vtkm::Vec<vtkm::Float32, 3> spacing(1.0f, 1.0f, 1.0f);
|
||||
static const vtkm::Id xdim = 3, ydim = 3;
|
||||
static const vtkm::Id3 dim(xdim, ydim, 1);
|
||||
static const vtkm::Id2 dim(xdim, ydim);
|
||||
static const vtkm::Id numVerts = xdim * ydim;
|
||||
|
||||
vtkm::Float32 scalars[numVerts];
|
||||
@ -104,14 +104,11 @@ vtkm::cont::DataSet MakeTestDatasetStructured()
|
||||
scalars[4] = 0.0f;
|
||||
|
||||
vtkm::cont::DataSet ds;
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", 1, dim, origin, spacing));
|
||||
vtkm::cont::DataSetBuilderRegular builder;
|
||||
ds = builder.Create(dim);
|
||||
|
||||
ds.AddField(vtkm::cont::Field("scalars", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
scalars, numVerts));
|
||||
|
||||
vtkm::cont::CellSetStructured<2> cs("cells");
|
||||
cs.SetPointDimensions(vtkm::make_Vec(dim[0], dim[1]));
|
||||
ds.AddCellSet(cs);
|
||||
vtkm::cont::DataSetFieldAdd fieldAdder;
|
||||
fieldAdder.AddPointField(ds, "scalars", scalars, numVerts);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/worklet/ExternalFaces.h>
|
||||
|
||||
@ -70,24 +71,18 @@ vtkm::cont::DataSet RunExternalFaces(vtkm::cont::DataSet &ds)
|
||||
void TestExternalFaces()
|
||||
{
|
||||
//--------------Construct a VTK-m Test Dataset----------------
|
||||
|
||||
vtkm::cont::DataSet ds;
|
||||
|
||||
const int nVerts = 8; //A cube that is tetrahedralized
|
||||
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
||||
CoordType coordinates[nVerts] = {
|
||||
CoordType(0, 0, 0),
|
||||
CoordType(1, 0, 0),
|
||||
CoordType(1, 1, 0),
|
||||
CoordType(0, 1, 0),
|
||||
CoordType(0, 0, 1),
|
||||
CoordType(1, 0, 1),
|
||||
CoordType(1, 1, 1),
|
||||
CoordType(0, 1, 1)
|
||||
};
|
||||
|
||||
ds.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
||||
vtkm::cont::ArrayHandle< CoordType > coordinates;
|
||||
coordinates.Allocate(nVerts);
|
||||
coordinates.GetPortalControl().Set(0, CoordType(0.0f, 0.0f, 0.0f) );
|
||||
coordinates.GetPortalControl().Set(1, CoordType(1.0f, 0.0f, 0.0f) );
|
||||
coordinates.GetPortalControl().Set(2, CoordType(1.0f, 1.0f, 0.0f) );
|
||||
coordinates.GetPortalControl().Set(3, CoordType(0.0f, 1.0f, 0.0f) );
|
||||
coordinates.GetPortalControl().Set(4, CoordType(0.0f, 0.0f, 1.0f) );
|
||||
coordinates.GetPortalControl().Set(5, CoordType(1.0f, 0.0f, 1.0f) );
|
||||
coordinates.GetPortalControl().Set(6, CoordType(1.0f, 1.0f, 1.0f) );
|
||||
coordinates.GetPortalControl().Set(7, CoordType(0.0f, 1.0f, 1.0f) );
|
||||
|
||||
//Construct the VTK-m shapes and numIndices connectivity arrays
|
||||
const int nCells = 6; //The tetrahedrons of the cube
|
||||
@ -95,7 +90,6 @@ void TestExternalFaces()
|
||||
{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::ArrayHandle<vtkm::UInt8> shapes;
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
|
||||
@ -113,10 +107,8 @@ void TestExternalFaces()
|
||||
conn.GetPortalControl().Set(index++, cellVerts[j][k]);
|
||||
}
|
||||
|
||||
cs.Fill(shapes, numIndices, conn);
|
||||
|
||||
//Add the VTK-m cell set
|
||||
ds.AddCellSet(cs);
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
vtkm::cont::DataSet ds = builder.Create(coordinates, shapes, numIndices, conn);
|
||||
|
||||
//Run the External Faces worklet
|
||||
vtkm::cont::DataSet new_ds = RunExternalFaces(ds);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace {
|
||||
@ -31,32 +32,25 @@ namespace {
|
||||
//
|
||||
vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 16;
|
||||
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
||||
CoordType coordinates[nVerts] =
|
||||
{
|
||||
CoordType(0, 0, 0), // 0
|
||||
CoordType(1, 0, 0), // 1
|
||||
CoordType(2, 0, 0), // 2
|
||||
CoordType(3, 0, 0), // 3
|
||||
CoordType(0, 1, 0), // 4
|
||||
CoordType(1, 1, 0), // 5
|
||||
CoordType(2, 1, 0), // 6
|
||||
CoordType(3, 1, 0), // 7
|
||||
CoordType(0, 2, 0), // 8
|
||||
CoordType(1, 2, 0), // 9
|
||||
CoordType(2, 2, 0), // 10
|
||||
CoordType(3, 2, 0), // 11
|
||||
CoordType(0, 3, 0), // 12
|
||||
CoordType(3, 3, 0), // 13
|
||||
CoordType(1, 4, 0), // 14
|
||||
CoordType(2, 4, 0), // 15
|
||||
};
|
||||
std::vector<CoordType> coordinates;
|
||||
coordinates.push_back( CoordType(0, 0, 0) ); // 0
|
||||
coordinates.push_back( CoordType(1, 0, 0) ); // 1
|
||||
coordinates.push_back( CoordType(2, 0, 0) ); // 2
|
||||
coordinates.push_back( CoordType(3, 0, 0) ); // 3
|
||||
coordinates.push_back( CoordType(0, 1, 0) ); // 4
|
||||
coordinates.push_back( CoordType(1, 1, 0) ); // 5
|
||||
coordinates.push_back( CoordType(2, 1, 0) ); // 6
|
||||
coordinates.push_back( CoordType(3, 1, 0) ); // 7
|
||||
coordinates.push_back( CoordType(0, 2, 0) ); // 8
|
||||
coordinates.push_back( CoordType(1, 2, 0) ); // 9
|
||||
coordinates.push_back( CoordType(2, 2, 0) ); // 10
|
||||
coordinates.push_back( CoordType(3, 2, 0) ); // 11
|
||||
coordinates.push_back( CoordType(0, 3, 0) ); // 12
|
||||
coordinates.push_back( CoordType(3, 3, 0) ); // 13
|
||||
coordinates.push_back( CoordType(1, 4, 0) ); // 14
|
||||
coordinates.push_back( CoordType(2, 4, 0) ); // 15
|
||||
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
||||
|
||||
std::vector<vtkm::UInt8> shapes;
|
||||
shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE);
|
||||
@ -112,13 +106,8 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
|
||||
conn.push_back(14);
|
||||
conn.push_back(12);
|
||||
|
||||
static const vtkm::IdComponent ndim = 2;
|
||||
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", ndim);
|
||||
cellSet.FillViaCopy(shapes, numindices, conn);
|
||||
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
return builder.Create(coordinates, shapes, numindices, conn);
|
||||
}
|
||||
|
||||
//
|
||||
@ -126,34 +115,26 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
|
||||
//
|
||||
vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const int nVerts = 18;
|
||||
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
||||
CoordType coordinates[nVerts] =
|
||||
{
|
||||
CoordType(0, 0, 0),
|
||||
CoordType(1, 0, 0),
|
||||
CoordType(2, 0, 0),
|
||||
CoordType(3, 0, 0),
|
||||
CoordType(0, 1, 0),
|
||||
CoordType(1, 1, 0),
|
||||
CoordType(2, 1, 0),
|
||||
CoordType(2.5, 1, 0),
|
||||
CoordType(0, 2, 0),
|
||||
CoordType(1, 2, 0),
|
||||
CoordType(0.5, 0.5, 1),
|
||||
CoordType(1, 0, 1),
|
||||
CoordType(2, 0, 1),
|
||||
CoordType(3, 0, 1),
|
||||
CoordType(1, 1, 1),
|
||||
CoordType(2, 1, 1),
|
||||
CoordType(2.5, 1, 1),
|
||||
CoordType(0.5, 1.5, 1),
|
||||
};
|
||||
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
||||
std::vector<CoordType> coordinates;
|
||||
coordinates.push_back( CoordType(0, 0, 0) );
|
||||
coordinates.push_back( CoordType(1, 0, 0) );
|
||||
coordinates.push_back( CoordType(2, 0, 0) );
|
||||
coordinates.push_back( CoordType(3, 0, 0) );
|
||||
coordinates.push_back( CoordType(0, 1, 0) );
|
||||
coordinates.push_back( CoordType(1, 1, 0) );
|
||||
coordinates.push_back( CoordType(2, 1, 0) );
|
||||
coordinates.push_back( CoordType(2.5, 1, 0) );
|
||||
coordinates.push_back( CoordType(0, 2, 0) );
|
||||
coordinates.push_back( CoordType(1, 2, 0) );
|
||||
coordinates.push_back( CoordType(0.5, 0.5, 1) );
|
||||
coordinates.push_back( CoordType(1, 0, 1) );
|
||||
coordinates.push_back( CoordType(2, 0, 1) );
|
||||
coordinates.push_back( CoordType(3, 0, 1) );
|
||||
coordinates.push_back( CoordType(1, 1, 1) );
|
||||
coordinates.push_back( CoordType(2, 1, 1) );
|
||||
coordinates.push_back( CoordType(2.5, 1, 1) );
|
||||
coordinates.push_back( CoordType(0.5, 1.5, 1) );
|
||||
|
||||
std::vector<vtkm::UInt8> shapes;
|
||||
shapes.push_back(vtkm::CELL_SHAPE_TETRA);
|
||||
@ -195,13 +176,9 @@ vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
|
||||
conn.push_back(8);
|
||||
conn.push_back(17);
|
||||
|
||||
static const vtkm::IdComponent ndim = 3;
|
||||
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", ndim);
|
||||
cellSet.FillViaCopy(shapes, numindices, conn);
|
||||
vtkm::cont::DataSetBuilderExplicit builder;
|
||||
return builder.Create(coordinates, shapes, numindices, conn);
|
||||
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
}
|
||||
@ -226,7 +203,7 @@ void TestExplicitGrid2D()
|
||||
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
|
||||
|
||||
// Convert explicit cells to triangles
|
||||
vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter>
|
||||
vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter>
|
||||
tetrahedralizeFilter(inDataSet, outDataSet);
|
||||
tetrahedralizeFilter.Run();
|
||||
|
||||
@ -238,7 +215,7 @@ void TestExplicitGrid2D()
|
||||
std::cout << "Number of output components " << coordArray.GetNumberOfComponents() << std::endl;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> bounds = coordinates.GetBounds(DeviceAdapter());
|
||||
std::cout << "Bounds ("
|
||||
std::cout << "Bounds ("
|
||||
<< bounds.GetPortalControl().Get(0) << "," << bounds.GetPortalControl().Get(1) << ") ("
|
||||
<< bounds.GetPortalControl().Get(2) << "," << bounds.GetPortalControl().Get(3) << ")" << std::endl;
|
||||
|
||||
@ -265,7 +242,7 @@ void TestExplicitGrid3D()
|
||||
outDataSet.AddCoordinateSystem(inDataSet.GetCoordinateSystem(0));
|
||||
|
||||
// Convert explicit cells to triangles
|
||||
vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter>
|
||||
vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter>
|
||||
tetrahedralizeFilter(inDataSet, outDataSet);
|
||||
tetrahedralizeFilter.Run();
|
||||
|
||||
@ -277,7 +254,7 @@ void TestExplicitGrid3D()
|
||||
std::cout << "Number of output components " << coordArray.GetNumberOfComponents() << std::endl;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> bounds = coordinates.GetBounds(DeviceAdapter());
|
||||
std::cout << "Bounds ("
|
||||
std::cout << "Bounds ("
|
||||
<< bounds.GetPortalControl().Get(0) << "," << bounds.GetPortalControl().Get(1) << ") ("
|
||||
<< bounds.GetPortalControl().Get(2) << "," << bounds.GetPortalControl().Get(3) << ") ("
|
||||
<< bounds.GetPortalControl().Get(4) << "," << bounds.GetPortalControl().Get(5) << ")" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user