vtk-m/vtkm/filter/ImageConnectivity.hxx
Robert Maynard 89fa2c0293 Remove multiple vtkm::cont::CellSet from vtkm::cont::DataSet
By removing the ability to have multiple CellSets in a DataSet
we can simplify the following things:

  - Cell Fields now don't require a CellSet name when being constructed
  - Filters don't need to manage what the active cellset is
2019-09-02 09:04:51 -04:00

43 lines
1.3 KiB
C++

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
namespace vtkm
{
namespace filter
{
VTKM_CONT ImageConnectivity::ImageConnectivity()
{
this->SetOutputFieldName("component");
}
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet ImageConnectivity::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMetadata,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
if (!fieldMetadata.IsPointField())
{
throw vtkm::cont::ErrorBadValue("Active field for ImageConnectivity must be a point field.");
}
vtkm::cont::ArrayHandle<vtkm::Id> component;
vtkm::worklet::connectivity::ImageConnectivity().Run(
vtkm::filter::ApplyPolicy(input.GetCellSet(), policy), field, component);
auto result = CreateResult(input, component, this->GetOutputFieldName(), fieldMetadata);
return result;
}
}
}