Merge topic 'vtkm_marching_cubes_filter_failure'
0a59a764 Correct issues with MarchingCubesFilter not merging points properly. 589da1f6 Simplify the General DeviceAdapter Unique method. 88f435d8 TriangulateTable warning fixes. Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !370
This commit is contained in:
commit
14e4be0d5e
@ -601,23 +601,7 @@ template<typename T, typename U, class CIn, class CStencil, class COut>
|
||||
VTKM_CONT_EXPORT static void Unique(
|
||||
vtkm::cont::ArrayHandle<T,Storage> &values)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic>
|
||||
stencilArray;
|
||||
vtkm::Id inputSize = values.GetNumberOfValues();
|
||||
|
||||
ClassifyUniqueKernel<
|
||||
typename vtkm::cont::ArrayHandle<T,Storage>::template ExecutionTypes<DeviceAdapterTag>::PortalConst,
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id,vtkm::cont::StorageTagBasic>::template ExecutionTypes<DeviceAdapterTag>::Portal>
|
||||
classifyKernel(values.PrepareForInput(DeviceAdapterTag()),
|
||||
stencilArray.PrepareForOutput(inputSize, DeviceAdapterTag()));
|
||||
DerivedAlgorithm::Schedule(classifyKernel, inputSize);
|
||||
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
|
||||
outputArray;
|
||||
|
||||
DerivedAlgorithm::StreamCompact(values, stencilArray, outputArray);
|
||||
|
||||
DerivedAlgorithm::Copy(outputArray, values);
|
||||
Unique(values, std::equal_to<T>());
|
||||
}
|
||||
|
||||
template<typename T, class Storage, class BinaryCompare>
|
||||
@ -629,13 +613,17 @@ template<typename T, typename U, class CIn, class CStencil, class COut>
|
||||
stencilArray;
|
||||
vtkm::Id inputSize = values.GetNumberOfValues();
|
||||
|
||||
typedef internal::WrappedBinaryOperator<bool,BinaryCompare> WrappedBOpType;
|
||||
WrappedBOpType wrappedCompare(binary_compare);
|
||||
|
||||
ClassifyUniqueComparisonKernel<
|
||||
typename vtkm::cont::ArrayHandle<T,Storage>::template ExecutionTypes<DeviceAdapterTag>::PortalConst,
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id,vtkm::cont::StorageTagBasic>::template ExecutionTypes<DeviceAdapterTag>::Portal,
|
||||
BinaryCompare>
|
||||
WrappedBOpType>
|
||||
classifyKernel(values.PrepareForInput(DeviceAdapterTag()),
|
||||
stencilArray.PrepareForOutput(inputSize, DeviceAdapterTag()),
|
||||
binary_compare);
|
||||
wrappedCompare);
|
||||
|
||||
DerivedAlgorithm::Schedule(classifyKernel, inputSize);
|
||||
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
|
||||
|
@ -298,6 +298,17 @@ class ApplyToField : public vtkm::worklet::WorkletMapField
|
||||
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
struct FirstValueSame
|
||||
{
|
||||
template<typename T, typename U>
|
||||
VTKM_EXEC_CONT_EXPORT bool operator()(const vtkm::Pair<T,U>& a,
|
||||
const vtkm::Pair<T,U>& b) const
|
||||
{
|
||||
return (a.first == b.first);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace vtkm {
|
||||
@ -393,6 +404,7 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
|
||||
this->TriangleTable,
|
||||
scatter);
|
||||
|
||||
|
||||
EdgeWeightGenerate<DeviceAdapter> weightGenerate(this->IsoValue,
|
||||
this->GenerateNormals,
|
||||
metaData);
|
||||
@ -421,33 +433,37 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
|
||||
|
||||
//Do merge duplicate points we need to do the following:
|
||||
//1. Copy the interpolation Ids
|
||||
Id2HandleType unqiueIds;
|
||||
Algorithm::Copy(this->InterpolationIds, unqiueIds);
|
||||
Id2HandleType uniqueIds;
|
||||
Algorithm::Copy(this->InterpolationIds, uniqueIds);
|
||||
|
||||
if(this->GenerateNormals)
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandleZip<WeightHandleType, Vec3HandleType> KeyType;
|
||||
KeyType keys = vtkm::cont::make_ArrayHandleZip(this->InterpolationWeights, normals);
|
||||
|
||||
//2. now we need to do a sort by key, giving us
|
||||
Algorithm::SortByKey(unqiueIds, keys);
|
||||
//2. now we need to do a sort by key, making duplicate ids be adjacent
|
||||
Algorithm::SortByKey(uniqueIds, keys);
|
||||
|
||||
//3. lastly we need to do a unique by key, but since vtkm doesn't
|
||||
// offer that feature, we use a zip handle
|
||||
// offer that feature, we use a zip handle.
|
||||
// We need to use a custom comparison operator as we only want to compare
|
||||
// the id2 which is the first entry in the zip pair
|
||||
vtkm::cont::ArrayHandleZip<Id2HandleType, KeyType> zipped =
|
||||
vtkm::cont::make_ArrayHandleZip(unqiueIds,keys);
|
||||
Algorithm::Unique( zipped );
|
||||
vtkm::cont::make_ArrayHandleZip(uniqueIds,keys);
|
||||
Algorithm::Unique( zipped, FirstValueSame());
|
||||
}
|
||||
else
|
||||
{
|
||||
//2. now we need to do a sort by key, giving us
|
||||
Algorithm::SortByKey(unqiueIds, this->InterpolationWeights);
|
||||
//2. now we need to do a sort by key, making duplicate ids be adjacent
|
||||
Algorithm::SortByKey(uniqueIds, this->InterpolationWeights);
|
||||
|
||||
//3. lastly we need to do a unique by key, but since vtkm doesn't
|
||||
// offer that feature, we use a zip handle
|
||||
// offer that feature, we use a zip handle.
|
||||
// We need to use a custom comparison operator as we only want to compare
|
||||
// the id2 which is the first entry in the zip pair
|
||||
vtkm::cont::ArrayHandleZip<Id2HandleType, WeightHandleType> zipped =
|
||||
vtkm::cont::make_ArrayHandleZip(unqiueIds, this->InterpolationWeights);
|
||||
Algorithm::Unique( zipped );
|
||||
vtkm::cont::make_ArrayHandleZip(uniqueIds, this->InterpolationWeights);
|
||||
Algorithm::Unique( zipped, FirstValueSame());
|
||||
}
|
||||
|
||||
//4.
|
||||
@ -457,8 +473,12 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
|
||||
//value.
|
||||
//
|
||||
vtkm::cont::ArrayHandle< vtkm::Id> connectivity;
|
||||
Algorithm::LowerBounds(unqiueIds, this->InterpolationIds, connectivity);
|
||||
Algorithm::LowerBounds(uniqueIds, this->InterpolationIds, connectivity);
|
||||
|
||||
//5.
|
||||
//We re-assign the shortened version of unique ids back into the
|
||||
//member variable so that 'DoMapField' will work properly
|
||||
this->InterpolationIds = uniqueIds;
|
||||
|
||||
CellShapeTagTriangle triangleTag;
|
||||
vtkm::cont::CellSetSingleType< > outputCells( triangleTag );
|
||||
@ -469,7 +489,7 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
|
||||
ApplyToField applyToField;
|
||||
vtkm::worklet::DispatcherMapField<ApplyToField,
|
||||
DeviceAdapter> applyFieldDispatcher(applyToField);
|
||||
applyFieldDispatcher.Invoke(unqiueIds,
|
||||
applyFieldDispatcher.Invoke(this->InterpolationIds,
|
||||
this->InterpolationWeights,
|
||||
vtkm::filter::ApplyPolicy(coords, policy),
|
||||
vertices);
|
||||
@ -536,6 +556,7 @@ bool MarchingCubes::DoMapField(vtkm::filter::DataSetResult& result,
|
||||
vtkm::worklet::DispatcherMapField<ApplyToField,
|
||||
DeviceAdapter> applyFieldDispatcher(applyToField);
|
||||
|
||||
|
||||
//todo: need to use the policy to get the correct storage tag for output
|
||||
vtkm::cont::ArrayHandle<T> output;
|
||||
applyFieldDispatcher.Invoke(this->InterpolationIds,
|
||||
|
@ -88,7 +88,7 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates));
|
||||
|
||||
dataSet.AddField(vtkm::cont::Field("nodevar", 1, vtkm::cont::Field::ASSOC_POINTS, fieldArray));
|
||||
dataSet.AddField(vtkm::cont::Field(std::string("nodevar"), 1, vtkm::cont::Field::ASSOC_POINTS, fieldArray));
|
||||
|
||||
static const vtkm::IdComponent ndim = 3;
|
||||
vtkm::cont::CellSetStructured<ndim> cellSet("cells");
|
||||
@ -290,16 +290,15 @@ void TestMarchingCubesUniformGrid()
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
//verify that the number of points is correct
|
||||
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
|
||||
VTKM_TEST_ASSERT(coords.GetData().GetNumberOfValues() == 402,
|
||||
"Should have less coordinates than the unmerged version");
|
||||
|
||||
//verify that the number of cells is correct (160)
|
||||
vtkm::cont::DynamicCellSet dcells = outputData.GetCellSet();
|
||||
|
||||
typedef vtkm::cont::CellSetSingleType<> CellSetType;
|
||||
const CellSetType& cells = dcells.Cast<CellSetType>();
|
||||
|
||||
//verify that the number of points is correct (72)
|
||||
//verify that the number of cells is correct (160)
|
||||
VTKM_TEST_ASSERT(coords.GetData().GetNumberOfValues() == 72,
|
||||
"Should have less coordinates than the unmerged version");
|
||||
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ public:
|
||||
vtkm::NUMBER_OF_CELL_SHAPES)),
|
||||
Indices(vtkm::cont::make_ArrayHandle(
|
||||
vtkm::worklet::internal::TriangleIndexData,
|
||||
sizeof(vtkm::worklet::internal::TriangleIndexData)/sizeof(vtkm::IdComponent)))
|
||||
vtkm::Id(9) ))
|
||||
{ }
|
||||
|
||||
template<typename Device>
|
||||
|
Loading…
Reference in New Issue
Block a user