mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Convert contour worklet to expect isovalues to a std::vector
This reduces an ugly component of the Contour API
This commit is contained in:
parent
c2bab6c6bb
commit
1b256281f4
@ -97,8 +97,7 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
|
|||||||
: !this->ComputeFastNormalsForUnstructured;
|
: !this->ComputeFastNormalsForUnstructured;
|
||||||
if (this->GenerateNormals && generateHighQualityNormals)
|
if (this->GenerateNormals && generateHighQualityNormals)
|
||||||
{
|
{
|
||||||
outputCells = this->Worklet.Run(&ivalues[0],
|
outputCells = this->Worklet.Run(ivalues,
|
||||||
static_cast<vtkm::Id>(ivalues.size()),
|
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
||||||
coords.GetData(),
|
coords.GetData(),
|
||||||
field,
|
field,
|
||||||
@ -107,12 +106,8 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outputCells = this->Worklet.Run(&ivalues[0],
|
outputCells = this->Worklet.Run(
|
||||||
static_cast<vtkm::Id>(ivalues.size()),
|
ivalues, vtkm::filter::ApplyPolicyCellSet(cells, policy), coords.GetData(), field, vertices);
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
|
||||||
coords.GetData(),
|
|
||||||
field,
|
|
||||||
vertices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->GenerateNormals)
|
if (this->GenerateNormals)
|
||||||
|
@ -92,8 +92,7 @@ public:
|
|||||||
typename CoordinateType,
|
typename CoordinateType,
|
||||||
typename StorageTagVertices>
|
typename StorageTagVertices>
|
||||||
vtkm::cont::CellSetSingleType<> Run(
|
vtkm::cont::CellSetSingleType<> Run(
|
||||||
const ValueType* const isovalues,
|
const std::vector<ValueType>& isovalues,
|
||||||
const vtkm::Id numIsoValues,
|
|
||||||
const CellSetType& cells,
|
const CellSetType& cells,
|
||||||
const CoordinateSystem& coordinateSystem,
|
const CoordinateSystem& coordinateSystem,
|
||||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
||||||
@ -108,7 +107,6 @@ public:
|
|||||||
coordinateSystem,
|
coordinateSystem,
|
||||||
outputCells,
|
outputCells,
|
||||||
isovalues,
|
isovalues,
|
||||||
numIsoValues,
|
|
||||||
input,
|
input,
|
||||||
vertices,
|
vertices,
|
||||||
normals,
|
normals,
|
||||||
@ -125,8 +123,7 @@ public:
|
|||||||
typename StorageTagVertices,
|
typename StorageTagVertices,
|
||||||
typename StorageTagNormals>
|
typename StorageTagNormals>
|
||||||
vtkm::cont::CellSetSingleType<> Run(
|
vtkm::cont::CellSetSingleType<> Run(
|
||||||
const ValueType* const isovalues,
|
const std::vector<ValueType>& isovalues,
|
||||||
const vtkm::Id numIsoValues,
|
|
||||||
const CellSetType& cells,
|
const CellSetType& cells,
|
||||||
const CoordinateSystem& coordinateSystem,
|
const CoordinateSystem& coordinateSystem,
|
||||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
||||||
@ -141,7 +138,6 @@ public:
|
|||||||
coordinateSystem,
|
coordinateSystem,
|
||||||
outputCells,
|
outputCells,
|
||||||
isovalues,
|
isovalues,
|
||||||
numIsoValues,
|
|
||||||
input,
|
input,
|
||||||
vertices,
|
vertices,
|
||||||
normals,
|
normals,
|
||||||
|
@ -86,8 +86,7 @@ template <typename ValueType,
|
|||||||
vtkm::cont::CellSetSingleType<> execute(
|
vtkm::cont::CellSetSingleType<> execute(
|
||||||
const vtkm::cont::CellSetStructured<3>& cells,
|
const vtkm::cont::CellSetStructured<3>& cells,
|
||||||
const vtkm::cont::ArrayHandleUniformPointCoordinates& coordinateSystem,
|
const vtkm::cont::ArrayHandleUniformPointCoordinates& coordinateSystem,
|
||||||
const ValueType* isovalues,
|
const std::vector<ValueType>& isovalues,
|
||||||
const vtkm::Id numIsoValues,
|
|
||||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& inputField,
|
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& inputField,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& points,
|
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& points,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<NormalType, 3>, StorageTagNormals>& normals,
|
vtkm::cont::ArrayHandle<vtkm::Vec<NormalType, 3>, StorageTagNormals>& normals,
|
||||||
@ -127,7 +126,7 @@ vtkm::cont::CellSetSingleType<> execute(
|
|||||||
sharedState.CellIdMap.Shrink(0);
|
sharedState.CellIdMap.Shrink(0);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> triangle_topology;
|
vtkm::cont::ArrayHandle<vtkm::Id> triangle_topology;
|
||||||
for (vtkm::Id i = 0; i < numIsoValues; ++i)
|
for (std::size_t i = 0; i < isovalues.size(); ++i)
|
||||||
{
|
{
|
||||||
ValueType isoval = isovalues[i];
|
ValueType isoval = isovalues[i];
|
||||||
|
|
||||||
|
@ -608,8 +608,7 @@ template <typename CellSetType,
|
|||||||
vtkm::cont::CellSetSingleType<> execute(
|
vtkm::cont::CellSetSingleType<> execute(
|
||||||
const CellSetType& cells,
|
const CellSetType& cells,
|
||||||
const CoordinateSystem& coordinateSystem,
|
const CoordinateSystem& coordinateSystem,
|
||||||
const ValueType* isovalues,
|
const std::vector<ValueType>& isovalues,
|
||||||
const vtkm::Id numIsoValues,
|
|
||||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& inputField,
|
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& inputField,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& vertices,
|
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& vertices,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<NormalType, 3>, StorageTagNormals>& normals,
|
vtkm::cont::ArrayHandle<vtkm::Vec<NormalType, 3>, StorageTagNormals>& normals,
|
||||||
@ -626,8 +625,7 @@ vtkm::cont::CellSetSingleType<> execute(
|
|||||||
// Setup the invoker
|
// Setup the invoker
|
||||||
vtkm::cont::Invoker invoker;
|
vtkm::cont::Invoker invoker;
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> isoValuesHandle =
|
vtkm::cont::ArrayHandle<ValueType> isoValuesHandle = vtkm::cont::make_ArrayHandle(isovalues);
|
||||||
vtkm::cont::make_ArrayHandle(isovalues, numIsoValues);
|
|
||||||
|
|
||||||
// Call the ClassifyCell functor to compute the Marching Cubes case numbers
|
// Call the ClassifyCell functor to compute the Marching Cubes case numbers
|
||||||
// for each cell, and the number of vertices to be generated
|
// for each cell, and the number of vertices to be generated
|
||||||
@ -664,7 +662,7 @@ vtkm::cont::CellSetSingleType<> execute(
|
|||||||
triTable);
|
triTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numIsoValues <= 1 || !sharedState.MergeDuplicatePoints)
|
if (isovalues.size() <= 1 || !sharedState.MergeDuplicatePoints)
|
||||||
{ //release memory early that we are not going to need again
|
{ //release memory early that we are not going to need again
|
||||||
contourIds.ReleaseResources();
|
contourIds.ReleaseResources();
|
||||||
}
|
}
|
||||||
@ -676,7 +674,7 @@ vtkm::cont::CellSetSingleType<> execute(
|
|||||||
// are updated. That is because MergeDuplicates will internally update
|
// are updated. That is because MergeDuplicates will internally update
|
||||||
// the InterpolationWeights and InterpolationOriginCellIds arrays to be the correct for the
|
// the InterpolationWeights and InterpolationOriginCellIds arrays to be the correct for the
|
||||||
// output. But for InterpolationEdgeIds we need to do it manually once done
|
// output. But for InterpolationEdgeIds we need to do it manually once done
|
||||||
if (numIsoValues == 1)
|
if (isovalues.size() == 1)
|
||||||
{
|
{
|
||||||
marching_cells::MergeDuplicates(invoker,
|
marching_cells::MergeDuplicates(invoker,
|
||||||
sharedState.InterpolationEdgeIds, //keys
|
sharedState.InterpolationEdgeIds, //keys
|
||||||
@ -685,7 +683,7 @@ vtkm::cont::CellSetSingleType<> execute(
|
|||||||
originalCellIdsForPoints, //values
|
originalCellIdsForPoints, //values
|
||||||
connectivity); // computed using lower bounds
|
connectivity); // computed using lower bounds
|
||||||
}
|
}
|
||||||
else if (numIsoValues > 1)
|
else
|
||||||
{
|
{
|
||||||
marching_cells::MergeDuplicates(
|
marching_cells::MergeDuplicates(
|
||||||
invoker,
|
invoker,
|
||||||
|
@ -199,13 +199,12 @@ void TestContourUniformGrid()
|
|||||||
vtkm::worklet::Contour isosurfaceFilter;
|
vtkm::worklet::Contour isosurfaceFilter;
|
||||||
isosurfaceFilter.SetMergeDuplicatePoints(false);
|
isosurfaceFilter.SetMergeDuplicatePoints(false);
|
||||||
|
|
||||||
vtkm::Float32 contourValue = 0.5f;
|
std::vector<vtkm::Float32> contourValue{ 0.5f };
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
|
||||||
|
|
||||||
auto result = isosurfaceFilter.Run(&contourValue,
|
auto result = isosurfaceFilter.Run(contourValue,
|
||||||
1,
|
|
||||||
cellSet,
|
cellSet,
|
||||||
dataSet.GetCoordinateSystem(),
|
dataSet.GetCoordinateSystem(),
|
||||||
pointFieldArray,
|
pointFieldArray,
|
||||||
@ -248,7 +247,7 @@ void TestContourExplicit()
|
|||||||
DataSetGenerator dataSetGenerator;
|
DataSetGenerator dataSetGenerator;
|
||||||
|
|
||||||
vtkm::IdComponent Dimension = 10;
|
vtkm::IdComponent Dimension = 10;
|
||||||
vtkm::Float32 contourValue = vtkm::Float32(.45);
|
std::vector<vtkm::Float32> contourValue{ 0.45f };
|
||||||
|
|
||||||
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
|
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
|
||||||
|
|
||||||
@ -265,7 +264,7 @@ void TestContourExplicit()
|
|||||||
Contour.SetMergeDuplicatePoints(false);
|
Contour.SetMergeDuplicatePoints(false);
|
||||||
|
|
||||||
auto result = Contour.Run(
|
auto result = Contour.Run(
|
||||||
&contourValue, 1, cellSet, dataSet.GetCoordinateSystem(), contourArray, vertices, normals);
|
contourValue, cellSet, dataSet.GetCoordinateSystem(), contourArray, vertices, normals);
|
||||||
|
|
||||||
DataHandle scalars;
|
DataHandle scalars;
|
||||||
|
|
||||||
@ -322,7 +321,7 @@ void TestContourClipped()
|
|||||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
|
||||||
clipped.GetField("cellvar").GetData().CopyTo(cellFieldArray);
|
clipped.GetField("cellvar").GetData().CopyTo(cellFieldArray);
|
||||||
|
|
||||||
vtkm::Float32 contourValue = 0.5f;
|
std::vector<vtkm::Float32> contourValue{ 0.5f };
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
|
||||||
@ -330,8 +329,7 @@ void TestContourClipped()
|
|||||||
vtkm::worklet::Contour isosurfaceFilter;
|
vtkm::worklet::Contour isosurfaceFilter;
|
||||||
isosurfaceFilter.SetMergeDuplicatePoints(false);
|
isosurfaceFilter.SetMergeDuplicatePoints(false);
|
||||||
|
|
||||||
auto result = isosurfaceFilter.Run(&contourValue,
|
auto result = isosurfaceFilter.Run(contourValue,
|
||||||
1,
|
|
||||||
cellSet,
|
cellSet,
|
||||||
clipped.GetCoordinateSystem(),
|
clipped.GetCoordinateSystem(),
|
||||||
pointFieldArray,
|
pointFieldArray,
|
||||||
|
Loading…
Reference in New Issue
Block a user