2016-01-19 14:59:31 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-01-19 14:59:31 +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-08-18 01:10:57 +00:00
|
|
|
#ifndef vtk_m_filter_Contour_h
|
|
|
|
#define vtk_m_filter_Contour_h
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
#include <vtkm/filter/vtkm_filter_export.h>
|
|
|
|
|
2016-05-05 18:42:46 +00:00
|
|
|
#include <vtkm/filter/FilterDataSetWithField.h>
|
2019-08-18 01:10:57 +00:00
|
|
|
#include <vtkm/worklet/Contour.h>
|
2016-01-19 14:59:31 +00:00
|
|
|
|
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.
|
2019-09-09 13:39:23 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT Contour : public vtkm::filter::FilterDataSetWithField<Contour>
|
2016-01-19 14:59:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-12-05 21:38:41 +00:00
|
|
|
using SupportedTypes = vtkm::List<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>;
|
2019-08-02 02:03:04 +00:00
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_FILTER_EXPORT
|
2019-08-18 01:10:57 +00:00
|
|
|
Contour();
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_FILTER_EXPORT
|
2017-03-14 12:56:44 +00:00
|
|
|
void SetNumberOfIsoValues(vtkm::Id num);
|
2016-01-19 14:59:31 +00:00
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_FILTER_EXPORT
|
2017-03-14 12:56:44 +00:00
|
|
|
vtkm::Id GetNumberOfIsoValues() const;
|
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_FILTER_EXPORT
|
2017-03-14 12:56:44 +00:00
|
|
|
void SetIsoValue(vtkm::Float64 v) { this->SetIsoValue(0, v); }
|
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_FILTER_EXPORT
|
2017-03-14 12:56:44 +00:00
|
|
|
void SetIsoValue(vtkm::Id index, vtkm::Float64);
|
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_FILTER_EXPORT
|
2017-03-14 12:56:44 +00:00
|
|
|
void SetIsoValues(const std::vector<vtkm::Float64>& values);
|
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
VTKM_FILTER_EXPORT
|
2017-03-14 12:56:44 +00:00
|
|
|
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
|
|
|
|
2019-07-26 01:28:38 +00:00
|
|
|
/// Set/Get whether to append the ids of the intersected edges to the vertices of the isosurface triangles. Off by default.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetAddInterpolationEdgeIds(bool on) { this->AddInterpolationEdgeIds = on; }
|
|
|
|
VTKM_CONT
|
|
|
|
bool GetAddInterpolationEdgeIds() const { return this->AddInterpolationEdgeIds; }
|
|
|
|
|
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; }
|
|
|
|
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2019-09-09 13:39:23 +00:00
|
|
|
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
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
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
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,
|
2019-09-09 13:39:23 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
|
|
|
{
|
|
|
|
vtkm::cont::ArrayHandle<T> fieldArray;
|
|
|
|
|
|
|
|
if (fieldMeta.IsPointField())
|
|
|
|
{
|
|
|
|
fieldArray = this->Worklet.ProcessPointField(input);
|
|
|
|
}
|
|
|
|
else if (fieldMeta.IsCellField())
|
|
|
|
{
|
|
|
|
fieldArray = this->Worklet.ProcessCellField(input);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//use the same meta data as the input so we get the same field name, etc.
|
|
|
|
result.AddField(fieldMeta.AsField(fieldArray));
|
|
|
|
return true;
|
|
|
|
}
|
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;
|
2019-07-26 01:28:38 +00:00
|
|
|
bool AddInterpolationEdgeIds;
|
2017-06-19 17:44:36 +00:00
|
|
|
bool ComputeFastNormalsForStructured;
|
|
|
|
bool ComputeFastNormalsForUnstructured;
|
2017-03-02 17:15:20 +00:00
|
|
|
std::string NormalArrayName;
|
2019-07-26 01:28:38 +00:00
|
|
|
std::string InterpolationEdgeIdsArrayName;
|
2019-08-18 01:10:57 +00:00
|
|
|
vtkm::worklet::Contour Worklet;
|
2016-01-19 14:59:31 +00:00
|
|
|
};
|
2019-09-09 13:39:23 +00:00
|
|
|
|
|
|
|
#ifndef vtkm_filter_Contour_cxx
|
|
|
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(Contour);
|
|
|
|
#endif
|
2016-01-19 14:59:31 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
|
|
|
|
2019-10-07 19:39:02 +00:00
|
|
|
#include <vtkm/filter/Contour.hxx>
|
|
|
|
|
2019-08-18 01:10:57 +00:00
|
|
|
#endif // vtk_m_filter_Contour_h
|