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