2016-01-19 14:59:31 +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).
|
2016-01-19 14:59:31 +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,
|
2016-01-19 14:59:31 +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_MarchingCubes_h
|
|
|
|
#define vtk_m_filter_MarchingCubes_h
|
|
|
|
|
2016-05-05 18:42:46 +00:00
|
|
|
#include <vtkm/filter/FilterDataSetWithField.h>
|
2016-01-19 14:59:31 +00:00
|
|
|
#include <vtkm/worklet/MarchingCubes.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
2017-07-06 17:51:45 +00:00
|
|
|
/// \brief generate isosurface(s) from a Volume
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-07-06 17:51:45 +00:00
|
|
|
/// Takes as input a volume (e.g., 3D structured point set) and generates on
|
|
|
|
/// output one or more isosurfaces.
|
|
|
|
/// Multiple contour values must be specified to generate the isosurfaces.
|
|
|
|
/// @warning
|
|
|
|
/// This filter is currently only supports 3D volumes.
|
2016-05-05 18:42:46 +00:00
|
|
|
class MarchingCubes : public vtkm::filter::FilterDataSetWithField<MarchingCubes>
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-19 14:59:31 +00:00
|
|
|
MarchingCubes();
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-03-14 12:56:44 +00:00
|
|
|
void SetNumberOfIsoValues(vtkm::Id num);
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-03-14 12:56:44 +00:00
|
|
|
vtkm::Id GetNumberOfIsoValues() const;
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void SetIsoValue(vtkm::Float64 v) { this->SetIsoValue(0, v); }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void SetIsoValue(vtkm::Id index, vtkm::Float64);
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void SetIsoValues(const std::vector<vtkm::Float64>& values);
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Float64 GetIsoValue(vtkm::Id index) const;
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-07-06 17:51:45 +00:00
|
|
|
/// Set/Get whether the points generated should be unique for every triangle
|
|
|
|
/// or will duplicate points be merged together. Duplicate points are identified
|
|
|
|
/// by the unique edge it was generated from.
|
|
|
|
///
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-07-21 20:54:33 +00:00
|
|
|
void SetMergeDuplicatePoints(bool on) { this->Worklet.SetMergeDuplicatePoints(on); }
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
bool GetMergeDuplicatePoints() const { return this->Worklet.GetMergeDuplicatePoints(); }
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-06-19 17:44:36 +00:00
|
|
|
/// Set/Get whether normals should be generated. Off by default. If enabled,
|
|
|
|
/// the default behaviour is to generate high quality normals for structured
|
|
|
|
/// datasets, using gradients, and generate fast normals for unstructured
|
|
|
|
/// datasets based on the result triangle mesh.
|
|
|
|
///
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-19 14:59:31 +00:00
|
|
|
void SetGenerateNormals(bool on) { this->GenerateNormals = on; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
bool GetGenerateNormals() const { return this->GenerateNormals; }
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2017-06-19 17:44:36 +00:00
|
|
|
/// Set/Get whether the fast path should be used for normals computation for
|
|
|
|
/// structured datasets. Off by default.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetComputeFastNormalsForStructured(bool on) { this->ComputeFastNormalsForStructured = on; }
|
|
|
|
VTKM_CONT
|
|
|
|
bool GetComputeFastNormalsForStructured() const { return this->ComputeFastNormalsForStructured; }
|
|
|
|
|
|
|
|
/// Set/Get whether the fast path should be used for normals computation for
|
|
|
|
/// unstructured datasets. On by default.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetComputeFastNormalsForUnstructured(bool on)
|
|
|
|
{
|
|
|
|
this->ComputeFastNormalsForUnstructured = on;
|
|
|
|
}
|
|
|
|
VTKM_CONT
|
|
|
|
bool GetComputeFastNormalsForUnstructured() const
|
|
|
|
{
|
|
|
|
return this->ComputeFastNormalsForUnstructured;
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:15:20 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetNormalArrayName(const std::string& name) { this->NormalArrayName = name; }
|
2017-03-02 17:15:20 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
const std::string& GetNormalArrayName() const { return this->NormalArrayName; }
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
|
2017-08-10 17:56:19 +00:00
|
|
|
VTKM_CONT vtkm::filter::Result DoExecute(const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
|
|
|
const DeviceAdapter& tag);
|
2016-01-19 14:59:31 +00:00
|
|
|
|
|
|
|
//Map a new field onto the resulting dataset after running the filter
|
|
|
|
//this call is only valid
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy, typename DeviceAdapter>
|
2017-08-10 17:56:19 +00:00
|
|
|
VTKM_CONT bool DoMapField(vtkm::filter::Result& 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);
|
2016-01-19 14:59:31 +00:00
|
|
|
|
|
|
|
private:
|
2017-03-14 12:56:44 +00:00
|
|
|
std::vector<vtkm::Float64> IsoValues;
|
2016-01-19 14:59:31 +00:00
|
|
|
bool GenerateNormals;
|
2017-06-19 17:44:36 +00:00
|
|
|
bool ComputeFastNormalsForStructured;
|
|
|
|
bool ComputeFastNormalsForUnstructured;
|
2017-03-02 17:15:20 +00:00
|
|
|
std::string NormalArrayName;
|
2016-07-21 20:54:33 +00:00
|
|
|
vtkm::worklet::MarchingCubes Worklet;
|
2016-01-19 14:59:31 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <>
|
2016-01-19 14:59:31 +00:00
|
|
|
class FilterTraits<MarchingCubes>
|
|
|
|
{
|
|
|
|
public:
|
2017-05-18 14:29:41 +00:00
|
|
|
struct TypeListTagMCScalars
|
|
|
|
: vtkm::ListTagBase<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>
|
|
|
|
{
|
|
|
|
};
|
2018-02-22 13:29:13 +00:00
|
|
|
using InputFieldTypeList = TypeListTagMCScalars;
|
2016-01-19 14:59:31 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
|
|
|
|
|
|
|
#include <vtkm/filter/MarchingCubes.hxx>
|
|
|
|
|
2016-04-07 21:09:11 +00:00
|
|
|
#endif // vtk_m_filter_MarchingCubes_h
|