2017-04-18 14:32:13 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2017-04-18 14:32:13 +00:00
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
|
|
|
// Copyright 2014 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2017-04-18 14:32:13 +00:00
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef vtk_m_filter_ExtractStructured_h
|
|
|
|
#define vtk_m_filter_ExtractStructured_h
|
|
|
|
|
|
|
|
#include <vtkm/filter/FilterDataSet.h>
|
|
|
|
#include <vtkm/worklet/ExtractStructured.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2017-07-06 17:51:45 +00:00
|
|
|
/// \brief Select piece (e.g., volume of interest) and/or subsample structured points dataset
|
|
|
|
///
|
|
|
|
/// Select or subsample a portion of an input structured dataset. The selected
|
|
|
|
/// portion of interested is referred to as the Volume Of Interest, or VOI.
|
|
|
|
/// The output of this filter is a structured dataset. The filter treats input
|
|
|
|
/// data of any topological dimension (i.e., point, line, plane, or volume) and
|
|
|
|
/// can generate output data of any topological dimension.
|
|
|
|
///
|
|
|
|
/// To use this filter set the VOI ivar which are i-j-k min/max indices that
|
|
|
|
/// specify a rectangular region in the data. (Note that these are 0-offset.)
|
|
|
|
/// You can also specify a sampling rate to subsample the data.
|
|
|
|
///
|
|
|
|
/// Typical applications of this filter are to extract a slice from a volume
|
|
|
|
/// for image processing, subsampling large volumes to reduce data size, or
|
|
|
|
/// extracting regions of a volume with interesting data.
|
|
|
|
///
|
2017-04-18 14:32:13 +00:00
|
|
|
class ExtractStructured : public vtkm::filter::FilterDataSet<ExtractStructured>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VTKM_CONT
|
|
|
|
ExtractStructured();
|
|
|
|
|
|
|
|
// Set the bounding box for the volume of interest
|
|
|
|
VTKM_CONT
|
2017-05-23 19:18:50 +00:00
|
|
|
vtkm::RangeId3 GetVOI() const { return this->VOI; }
|
2017-04-27 20:53:51 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
2017-05-23 19:18:50 +00:00
|
|
|
void SetVOI(vtkm::Id i0, vtkm::Id i1, vtkm::Id j0, vtkm::Id j1, vtkm::Id k0, vtkm::Id k1)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
2017-05-23 19:18:50 +00:00
|
|
|
this->VOI = vtkm::RangeId3(i0, i1, j0, j1, k0, k1);
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2017-04-27 20:53:51 +00:00
|
|
|
VTKM_CONT
|
2017-05-23 19:18:50 +00:00
|
|
|
void SetVOI(vtkm::Id extents[6]) { this->VOI = vtkm::RangeId3(extents); }
|
2017-04-27 20:53:51 +00:00
|
|
|
VTKM_CONT
|
2017-05-02 20:41:47 +00:00
|
|
|
void SetVOI(vtkm::Id3 minPoint, vtkm::Id3 maxPoint)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
2017-05-23 19:18:50 +00:00
|
|
|
this->VOI = vtkm::RangeId3(minPoint, maxPoint);
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2017-04-18 14:32:13 +00:00
|
|
|
VTKM_CONT
|
2017-05-23 19:18:50 +00:00
|
|
|
void SetVOI(const vtkm::RangeId3& voi) { this->VOI = voi; }
|
2017-04-18 14:32:13 +00:00
|
|
|
|
2017-07-06 17:51:45 +00:00
|
|
|
/// Get the Sampling rate
|
2017-04-18 14:32:13 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id3 GetSampleRate() const { return this->SampleRate; }
|
2017-07-06 17:51:45 +00:00
|
|
|
|
|
|
|
/// Set the Sampling rate
|
2017-04-27 20:53:51 +00:00
|
|
|
VTKM_CONT
|
2017-05-23 19:18:50 +00:00
|
|
|
void SetSampleRate(vtkm::Id i, vtkm::Id j, vtkm::Id k) { this->SampleRate = vtkm::Id3(i, j, k); }
|
2017-07-06 17:51:45 +00:00
|
|
|
|
|
|
|
/// Set the Sampling rate
|
2017-04-27 20:53:51 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetSampleRate(vtkm::Id3 sampleRate) { this->SampleRate = sampleRate; }
|
2017-04-27 20:53:51 +00:00
|
|
|
|
2017-07-06 17:51:45 +00:00
|
|
|
/// Get if we should include the outer boundary on a subsample
|
2017-04-27 20:53:51 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
bool GetIncludeBoundary() { return this->IncludeBoundary; }
|
2017-07-06 17:51:45 +00:00
|
|
|
/// Set if we should include the outer boundary on a subsample
|
2017-04-18 14:32:13 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetIncludeBoundary(bool value) { this->IncludeBoundary = value; }
|
2017-04-18 14:32:13 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename DerivedPolicy, typename DeviceAdapter>
|
2018-04-02 21:58:21 +00:00
|
|
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
|
|
|
const DeviceAdapter& tag);
|
2017-04-18 14:32:13 +00:00
|
|
|
|
|
|
|
// Map new field onto the resulting dataset after running the filter
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
|
2018-04-02 21:58:21 +00:00
|
|
|
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
|
|
|
const DeviceAdapter& tag);
|
2017-04-18 14:32:13 +00:00
|
|
|
|
|
|
|
private:
|
2017-05-23 19:18:50 +00:00
|
|
|
vtkm::RangeId3 VOI;
|
2017-04-18 14:32:13 +00:00
|
|
|
vtkm::Id3 SampleRate;
|
2017-04-27 20:53:51 +00:00
|
|
|
bool IncludeBoundary;
|
2017-04-18 14:32:13 +00:00
|
|
|
vtkm::worklet::ExtractStructured Worklet;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
|
|
|
|
|
|
|
#include <vtkm/filter/ExtractStructured.hxx>
|
|
|
|
|
|
|
|
#endif // vtk_m_filter_ExtractStructured_h
|