2017-05-03 21:07:06 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2017-05-03 21:07:06 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
|
2019-10-07 19:39:02 +00:00
|
|
|
#ifndef vtk_m_filter_ExtractPoints_hxx
|
|
|
|
#define vtk_m_filter_ExtractPoints_hxx
|
|
|
|
|
2017-05-03 21:07:06 +00:00
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/cont/DynamicCellSet.h>
|
2017-05-03 21:07:06 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2017-05-03 21:07:06 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-05-18 14:29:41 +00:00
|
|
|
inline VTKM_CONT ExtractPoints::ExtractPoints()
|
|
|
|
: vtkm::filter::FilterDataSet<ExtractPoints>()
|
|
|
|
, ExtractInside(true)
|
|
|
|
, CompactPoints(false)
|
2017-05-03 21:07:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& input,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2017-05-03 21:07:06 +00:00
|
|
|
{
|
|
|
|
// extract the input cell set and coordinates
|
2019-08-13 17:08:54 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
2017-05-03 21:07:06 +00:00
|
|
|
const vtkm::cont::CoordinateSystem& coords =
|
2017-05-18 14:29:41 +00:00
|
|
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
2017-05-03 21:07:06 +00:00
|
|
|
|
|
|
|
// run the worklet on the cell set
|
2019-08-13 21:28:37 +00:00
|
|
|
vtkm::cont::CellSetSingleType<> outCellSet;
|
2017-05-03 21:07:06 +00:00
|
|
|
vtkm::worklet::ExtractPoints worklet;
|
|
|
|
|
2020-05-15 23:47:30 +00:00
|
|
|
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
2017-12-12 19:26:23 +00:00
|
|
|
coords.GetData(),
|
2017-10-23 13:38:33 +00:00
|
|
|
this->Function,
|
2018-08-30 15:53:18 +00:00
|
|
|
this->ExtractInside);
|
2017-05-03 21:07:06 +00:00
|
|
|
|
|
|
|
// create the output dataset
|
|
|
|
vtkm::cont::DataSet output;
|
2019-08-13 17:08:54 +00:00
|
|
|
output.SetCellSet(outCellSet);
|
2017-05-03 21:07:06 +00:00
|
|
|
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
|
|
|
|
|
|
|
// compact the unused points in the output dataset
|
|
|
|
if (this->CompactPoints)
|
|
|
|
{
|
|
|
|
this->Compactor.SetCompactPointFields(true);
|
2019-01-28 14:24:48 +00:00
|
|
|
this->Compactor.SetMergePoints(false);
|
2020-05-15 23:47:30 +00:00
|
|
|
return this->Compactor.Execute(output);
|
2017-05-03 21:07:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-02 21:58:21 +00:00
|
|
|
return output;
|
2017-05-03 21:07:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2020-02-05 04:44:10 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
inline VTKM_CONT bool ExtractPoints::MapFieldOntoOutput(
|
2018-04-02 21:58:21 +00:00
|
|
|
vtkm::cont::DataSet& result,
|
2020-02-05 04:44:10 +00:00
|
|
|
const vtkm::cont::Field& field,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2017-05-03 21:07:06 +00:00
|
|
|
{
|
|
|
|
// point data is copied as is because it was not collapsed
|
2020-02-05 04:44:10 +00:00
|
|
|
if (field.IsFieldPoint())
|
2017-05-03 21:07:06 +00:00
|
|
|
{
|
|
|
|
if (this->CompactPoints)
|
|
|
|
{
|
2020-02-05 04:44:10 +00:00
|
|
|
return this->Compactor.MapFieldOntoOutput(result, field, policy);
|
2017-05-03 21:07:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-05 04:44:10 +00:00
|
|
|
result.AddField(field);
|
2017-05-03 21:07:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2020-02-19 17:34:24 +00:00
|
|
|
else if (field.IsFieldGlobal())
|
|
|
|
{
|
|
|
|
result.AddField(field);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// cell data does not apply
|
|
|
|
return false;
|
|
|
|
}
|
2017-05-03 21:07:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-07 19:39:02 +00:00
|
|
|
|
|
|
|
#endif
|