mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 21:33:55 +00:00
migrate Contour, ClipWithField and Slice
This commit is contained in:
parent
a8d664da28
commit
3c700259a1
@ -28,7 +28,6 @@
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/FieldSelection.h>
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
#include <vtkm/filter/PointAverage.h>
|
||||
@ -40,6 +39,7 @@
|
||||
#include <vtkm/filter/VertexClustering.h>
|
||||
#include <vtkm/filter/WarpScalar.h>
|
||||
#include <vtkm/filter/WarpVector.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/filter/entity_extraction/ExternalFaces.h>
|
||||
#include <vtkm/filter/entity_extraction/ThresholdPoints.h>
|
||||
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
#include <vtkm/filter/Slice.h>
|
||||
#include <vtkm/filter/Streamline.h>
|
||||
#include <vtkm/filter/Tetrahedralize.h>
|
||||
#include <vtkm/filter/Tube.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/filter/contour/Slice.h>
|
||||
|
||||
#include <vtkm/rendering/Actor.h>
|
||||
#include <vtkm/rendering/CanvasRayTracer.h>
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <vtkm/io/VTKDataSetReader.h>
|
||||
#include <vtkm/io/VTKDataSetWriter.h>
|
||||
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
#include <vtkm/filter/contour/ClipWithField.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <vtkm/rendering/Scene.h>
|
||||
#include <vtkm/rendering/View3D.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
// This example creates a simple data set and uses VTK-m's rendering engine to render an image and
|
||||
// write that image to a file. It then computes an isosurface on the input data set and renders
|
||||
@ -64,7 +64,7 @@ int main(int argc, char* argv[])
|
||||
view.SaveAs("volume.png");
|
||||
|
||||
// Compute an isosurface:
|
||||
vtkm::filter::Contour filter;
|
||||
vtkm::filter::contour::Contour filter;
|
||||
// [min, max] of the tangle field is [-0.887, 24.46]:
|
||||
filter.SetIsoValue(3.0);
|
||||
filter.SetActiveField(fieldName);
|
||||
|
@ -8,26 +8,33 @@
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##============================================================================
|
||||
|
||||
vtkm_add_instantiations(ContourInstantiations FILTER Contour)
|
||||
vtkm_add_instantiations(GradientInstantiations FILTER Gradient)
|
||||
|
||||
vtkm_add_instantiations(ClipWithFieldInstantiations
|
||||
FILTER ClipWithField
|
||||
INSTANTIATIONS_FILE ClipWithFieldExternInstantiations.h
|
||||
)
|
||||
|
||||
vtkm_add_instantiations(ClipWithImplicitFunctionInstantiations
|
||||
FILTER ClipWithImplicitFunction
|
||||
INSTANTIATIONS_FILE ClipWithImplicitFunctionExternInstantiations.h
|
||||
)
|
||||
|
||||
set(deprecated_headers
|
||||
CleanGrid.h
|
||||
ClipWithField.h
|
||||
Contour.h
|
||||
DotProduct.h
|
||||
ExternalFaces.h
|
||||
ExtractPoints.h
|
||||
ExtractStructured.h
|
||||
GenerateIds.h
|
||||
MaskPoints.h
|
||||
Slice.h
|
||||
ThresholdPoints.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${deprecated_headers})
|
||||
|
||||
set(common_headers
|
||||
CellAverage.h
|
||||
CellMeasures.h
|
||||
CleanGrid.h
|
||||
ExtractGeometry.h
|
||||
ExtractPoints.h
|
||||
ExtractStructured.h
|
||||
FieldMetadata.h
|
||||
FilterCell.h
|
||||
FilterDataSet.h
|
||||
@ -41,7 +48,6 @@ set(common_headers
|
||||
PolicyDefault.h
|
||||
TaskQueue.h
|
||||
Threshold.h
|
||||
ThresholdPoints.h
|
||||
Instantiations.h
|
||||
)
|
||||
|
||||
@ -66,23 +72,22 @@ set(common_sources_device
|
||||
ExtractStructured.cxx
|
||||
PointAverage.cxx
|
||||
Threshold.cxx
|
||||
)
|
||||
)
|
||||
|
||||
set(extra_headers
|
||||
AmrArrays.h
|
||||
CellSetConnectivity.h
|
||||
ClipWithField.h
|
||||
ClipWithImplicitFunction.h
|
||||
ComputeMoments.h
|
||||
ContourTreeUniformAugmented.h
|
||||
ContourTreeUniformDistributed.h
|
||||
ContourTreeUniform.h
|
||||
CoordinateSystemTransform.h
|
||||
CreateResult.h
|
||||
CrossProduct.h
|
||||
DotProduct.h
|
||||
Entropy.h
|
||||
ExternalFaces.h
|
||||
FieldSelection.h
|
||||
FieldToColors.h
|
||||
GenerateIds.h
|
||||
GhostCellClassify.h
|
||||
GhostCellRemove.h
|
||||
Histogram.h
|
||||
@ -92,7 +97,6 @@ set(extra_headers
|
||||
Lagrangian.h
|
||||
LagrangianStructures.h
|
||||
Mask.h
|
||||
MaskPoints.h
|
||||
MeshQuality.h
|
||||
MIRFilter.h
|
||||
NDEntropy.h
|
||||
@ -129,11 +133,12 @@ set(extra_headers
|
||||
set(extra_header_template_sources
|
||||
AmrArrays.hxx
|
||||
CellSetConnectivity.hxx
|
||||
ClipWithField.hxx
|
||||
ClipWithImplicitFunction.hxx
|
||||
ClipWithFieldExternInstantiations.h
|
||||
ClipWithImplicitFunctionExternInstantiations.h
|
||||
ComputeMoments.hxx
|
||||
ContourTreeUniformAugmented.hxx
|
||||
ContourTreeUniformDistributed.hxx
|
||||
ContourTreeUniform.hxx
|
||||
CoordinateSystemTransform.hxx
|
||||
CrossProduct.hxx
|
||||
Entropy.hxx
|
||||
@ -179,33 +184,10 @@ set(extra_header_template_sources
|
||||
)
|
||||
|
||||
set(extra_sources_device
|
||||
${ClipWithFieldInstantiations}
|
||||
${ClipWithImplicitFunctionInstantiations}
|
||||
VectorMagnitude.cxx
|
||||
particleadvection/Messenger.cxx
|
||||
particleadvection/ParticleMessenger.cxx
|
||||
)
|
||||
|
||||
set(contour_headers
|
||||
Contour.h
|
||||
ContourTreeUniformAugmented.h
|
||||
ContourTreeUniformDistributed.h
|
||||
ContourTreeUniform.h
|
||||
Slice.h
|
||||
)
|
||||
|
||||
set(contour_header_template_sources
|
||||
Contour.hxx
|
||||
ContourTreeUniformAugmented.hxx
|
||||
ContourTreeUniformDistributed.hxx
|
||||
ContourTreeUniform.hxx
|
||||
Slice.hxx
|
||||
)
|
||||
|
||||
set(contour_sources_device
|
||||
Contour.cxx
|
||||
${ContourInstantiations}
|
||||
Slice.cxx
|
||||
)
|
||||
|
||||
set(gradient_headers
|
||||
@ -220,7 +202,6 @@ set(gradient_sources_device
|
||||
${GradientInstantiations}
|
||||
)
|
||||
|
||||
vtkm_pyexpander_generated_file(ClipWithFieldExternInstantiations.h)
|
||||
vtkm_pyexpander_generated_file(ClipWithImplicitFunctionExternInstantiations.h)
|
||||
|
||||
set(core_headers
|
||||
@ -254,7 +235,7 @@ vtkm_library(
|
||||
HEADERS ${common_headers}
|
||||
DEVICE_SOURCES ${common_sources_device}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_extra
|
||||
@ -262,15 +243,7 @@ vtkm_library(
|
||||
HEADERS ${extra_headers}
|
||||
DEVICE_SOURCES ${extra_sources_device}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_contour
|
||||
TEMPLATE_SOURCES ${contour_header_template_sources}
|
||||
HEADERS ${contour_headers}
|
||||
DEVICE_SOURCES ${contour_sources_device}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_gradient
|
||||
@ -278,33 +251,29 @@ vtkm_library(
|
||||
HEADERS ${gradient_headers}
|
||||
DEVICE_SOURCES ${gradient_sources_device}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
vtkm_filter_common
|
||||
vtkm_filter_core
|
||||
vtkm_filter_extra
|
||||
vtkm_filter_contour
|
||||
vtkm_filter_gradient
|
||||
PROPERTIES
|
||||
UNITY_BUILD ON
|
||||
UNITY_BUILD_MODE BATCH
|
||||
)
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_filter_common PUBLIC vtkm_filter_core vtkm_worklet) # TODO: deprecate vtkm_filter_common
|
||||
target_link_libraries(vtkm_filter_core PUBLIC vtkm_cont vtkm_worklet)
|
||||
target_link_libraries(vtkm_filter_extra PUBLIC vtkm_filter_common)
|
||||
target_link_libraries(vtkm_filter_contour PUBLIC vtkm_filter_common)
|
||||
target_link_libraries(vtkm_filter_gradient PUBLIC vtkm_filter_common)
|
||||
if (VTKm_ENABLE_MPI)
|
||||
target_link_libraries(vtkm_filter_common PUBLIC MPI::MPI_CXX)
|
||||
target_link_libraries(vtkm_filter_extra PUBLIC MPI::MPI_CXX)
|
||||
target_link_libraries(vtkm_filter_contour PUBLIC MPI::MPI_CXX)
|
||||
target_link_libraries(vtkm_filter_gradient PUBLIC MPI::MPI_CXX)
|
||||
endif()
|
||||
endif ()
|
||||
target_link_libraries(vtkm_filter PUBLIC INTERFACE
|
||||
vtkm_filter_extra
|
||||
vtkm_filter_contour
|
||||
vtkm_filter_gradient
|
||||
vtkm_filter_common
|
||||
vtkm_filter_core
|
||||
@ -313,6 +282,7 @@ target_link_libraries(vtkm_filter PUBLIC INTERFACE
|
||||
install(TARGETS vtkm_filter EXPORT ${VTKm_EXPORT_NAME})
|
||||
|
||||
add_subdirectory(clean_grid)
|
||||
add_subdirectory(contour)
|
||||
add_subdirectory(entity_extraction)
|
||||
add_subdirectory(internal)
|
||||
add_subdirectory(particleadvection)
|
||||
|
@ -7,110 +7,33 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithField_h
|
||||
#define vtk_m_filter_ClipWithField_h
|
||||
|
||||
#include <vtkm/filter/vtkm_filter_extra_export.h>
|
||||
|
||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
|
||||
#include <vtkm/worklet/Clip.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/contour/ClipWithField.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
/// \brief Clip a dataset using a field
|
||||
///
|
||||
/// Clip a dataset using a given field value. All points that are less than that
|
||||
/// value are considered outside, and will be discarded. All points that are greater
|
||||
/// are kept.
|
||||
/// The resulting geometry will not be water tight.
|
||||
class VTKM_FILTER_EXTRA_EXPORT ClipWithField
|
||||
: public vtkm::filter::FilterDataSetWithField<ClipWithField>
|
||||
|
||||
VTKM_DEPRECATED(1.8,
|
||||
"Use vtkm/filter/contour/ClipWithField.h instead of vtkm/filter/ClipWithField.h.")
|
||||
inline void ClipWithField_deprecated() {}
|
||||
|
||||
inline void ClipWithField_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
using SupportedTypes = vtkm::TypeListScalarAll;
|
||||
ClipWithField_deprecated();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetClipValue(vtkm::Float64 value) { this->ClipValue = value; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetInvertClip(bool invert) { this->Invert = invert; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 GetClipValue() const { return this->ClipValue; }
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT 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);
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
// If the field is a point field, then we need to do a custom interpolation of the points.
|
||||
// In this case, we need to call the superclass's MapFieldOntoOutput, which will in turn
|
||||
// call our DoMapField.
|
||||
return this->FilterDataSetWithField<ClipWithField>::MapFieldOntoOutput(result, field, policy);
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
// Use the precompiled field permutation function.
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> permutation = this->Worklet.GetCellMapOutputToInput();
|
||||
return vtkm::filter::MapFieldPermutation(field, permutation, result);
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter.
|
||||
//This call is only valid after Execute has been called.
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
// All other conditions should be handled by MapFieldOntoOutput directly.
|
||||
VTKM_ASSERT(fieldMeta.IsPointField());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> output;
|
||||
output = this->Worklet.ProcessPointField(input);
|
||||
|
||||
//use the same meta data as the input so we get the same field name, etc.
|
||||
result.AddField(fieldMeta.AsField(output));
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Float64 ClipValue = 0;
|
||||
vtkm::worklet::Clip Worklet;
|
||||
bool Invert = false;
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::ClipWithField.") ClipWithField
|
||||
: public vtkm::filter::contour::ClipWithField
|
||||
{
|
||||
using contour::ClipWithField::ClipWithField;
|
||||
};
|
||||
|
||||
#ifndef vtkm_filter_Clip_cxx
|
||||
VTKM_FILTER_EXTRA_EXPORT_EXECUTE_METHOD(ClipWithField);
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithFieldExternInstantiations_h
|
||||
#include <vtkm/filter/ClipWithFieldExternInstantiations.h>
|
||||
#endif
|
||||
|
||||
#endif // vtk_m_filter_ClipWithField_h
|
||||
#endif //vtk_m_filter_ClipWithField_h
|
||||
|
@ -1,81 +0,0 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithField_hxx
|
||||
#define vtk_m_filter_ClipWithField_hxx
|
||||
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct ClipWithFieldProcessCoords
|
||||
{
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
|
||||
const std::string& coordsName,
|
||||
const vtkm::worklet::Clip& worklet,
|
||||
vtkm::cont::DataSet& output) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
|
||||
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
|
||||
output.AddCoordinateSystem(outCoords);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
vtkm::cont::DataSet ClipWithField::DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (fieldMeta.IsPointField() == false)
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
||||
}
|
||||
|
||||
//get the cells and coordinates of the dataset
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
||||
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, this->ClipValue, this->Invert);
|
||||
|
||||
//create the output data
|
||||
vtkm::cont::DataSet output;
|
||||
output.SetCellSet(outputCellSet);
|
||||
|
||||
// Compute the new boundary points and add them to the output:
|
||||
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
|
||||
++coordSystemId)
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
|
||||
coords.GetData().CastAndCall(
|
||||
detail::ClipWithFieldProcessCoords{}, coords.GetName(), this->Worklet, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
} // end namespace vtkm::filter
|
||||
|
||||
#endif
|
@ -1,247 +0,0 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
////////////////////////// **** DO NOT EDIT THIS FILE!!! ****
|
||||
// This file is automatically generated by ClipWithFieldExternInstantiations.h.in
|
||||
// clang-format off
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithFieldExternInstantiations_h
|
||||
#define vtk_m_filter_ClipWithFieldExternInstantiations_h
|
||||
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
#include <vtkm/filter/ClipWithField.hxx>
|
||||
#include <vtkm/filter/Instantiations.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
#ifndef vtkm_filter_ClipWithFieldExecuteScalar_cxx
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
#endif // vtkm_filter_ClipWithFieldExecuteScalar_cxx
|
||||
|
||||
#ifndef vtkm_filter_ClipWithFieldExecuteSignedInteger_cxx
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int16>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int16, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
#endif // vtkm_filter_ClipWithFieldExecuteSignedInteger_cxx
|
||||
|
||||
#ifndef vtkm_filter_ClipWithFieldExecuteUnsignedInteger_cxx
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt16>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt16, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
#endif // vtkm_filter_ClipWithFieldExecuteUnsignedInteger_cxx
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,95 +0,0 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
//$# This file uses the pyexpander macro processing utility to build the
|
||||
//$# FunctionInterface facilities that use a variable number of arguments.
|
||||
//$# Information, documentation, and downloads for pyexpander can be found at:
|
||||
//$#
|
||||
//$# http://pyexpander.sourceforge.net/
|
||||
//$#
|
||||
//$# To build the source code, execute the following (after installing
|
||||
//$# pyexpander, of course):
|
||||
//$#
|
||||
//$# expander.py ClipWithFieldExternInstantiations.h.in > ClipWithFieldExternInstantiations.h
|
||||
//$#
|
||||
//$# Ignore the following comment. It is meant for the generated file.
|
||||
// **** DO NOT EDIT THIS FILE!!! ****
|
||||
// This file is automatically generated by ClipWithFieldExternInstantiations.h.in
|
||||
// clang-format off
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithFieldExternInstantiations_h
|
||||
#define vtk_m_filter_ClipWithFieldExternInstantiations_h
|
||||
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
#include <vtkm/filter/ClipWithField.hxx>
|
||||
#include <vtkm/filter/Instantiations.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
$py(
|
||||
# These values are taken from vtkm/TypeList.h
|
||||
translationUnits = {
|
||||
"vtkm_filter_ClipWithFieldExecuteScalar_cxx" :
|
||||
[
|
||||
"vtkm::Float32", "vtkm::Float64"
|
||||
],
|
||||
|
||||
"vtkm_filter_ClipWithFieldExecuteSignedInteger_cxx":
|
||||
[
|
||||
"vtkm::Int8", "vtkm::Int16", "vtkm::Int32", "vtkm::Int64"
|
||||
],
|
||||
|
||||
"vtkm_filter_ClipWithFieldExecuteUnsignedInteger_cxx":
|
||||
[
|
||||
"vtkm::UInt8", "vtkm::UInt16", "vtkm::UInt32", "vtkm::UInt64"
|
||||
]
|
||||
}
|
||||
)\
|
||||
\
|
||||
$for((TU, types) in translationUnits.items())\
|
||||
#ifndef $(TU)
|
||||
|
||||
$for(TYPE in types)\
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<$(TYPE)>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_EXTRA_EXPORT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<$(TYPE), vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
$endfor\
|
||||
#endif // $(TU)
|
||||
|
||||
$endfor\
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -15,7 +15,7 @@
|
||||
#include <vtkm/ImplicitFunction.h>
|
||||
#include <vtkm/filter/FilterDataSet.h>
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
#include <vtkm/worklet/Clip.h>
|
||||
#include <vtkm/filter/contour/worklet/Clip.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
|
@ -1,71 +0,0 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
#define vtkm_filter_Contour_cxx
|
||||
#include <vtkm/filter/Contour.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Contour::Contour()
|
||||
: vtkm::filter::FilterDataSetWithField<Contour>()
|
||||
, IsoValues()
|
||||
, GenerateNormals(false)
|
||||
, AddInterpolationEdgeIds(false)
|
||||
, ComputeFastNormalsForStructured(false)
|
||||
, ComputeFastNormalsForUnstructured(true)
|
||||
, NormalArrayName("normals")
|
||||
, InterpolationEdgeIdsArrayName("edgeIds")
|
||||
, Worklet()
|
||||
{
|
||||
// todo: keep an instance of marching cubes worklet as a member variable
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Contour::SetNumberOfIsoValues(vtkm::Id num)
|
||||
{
|
||||
if (num >= 0)
|
||||
{
|
||||
this->IsoValues.resize(static_cast<std::size_t>(num));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
vtkm::Id Contour::GetNumberOfIsoValues() const
|
||||
{
|
||||
return static_cast<vtkm::Id>(this->IsoValues.size());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Contour::SetIsoValue(vtkm::Id index, vtkm::Float64 v)
|
||||
{
|
||||
std::size_t i = static_cast<std::size_t>(index);
|
||||
if (i >= this->IsoValues.size())
|
||||
{
|
||||
this->IsoValues.resize(i + 1);
|
||||
}
|
||||
this->IsoValues[i] = v;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Contour::SetIsoValues(const std::vector<vtkm::Float64>& values)
|
||||
{
|
||||
this->IsoValues = values;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
vtkm::Float64 Contour::GetIsoValue(vtkm::Id index) const
|
||||
{
|
||||
return this->IsoValues[static_cast<std::size_t>(index)];
|
||||
}
|
||||
}
|
||||
}
|
@ -7,225 +7,32 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Contour_h
|
||||
#define vtk_m_filter_Contour_h
|
||||
|
||||
#include <vtkm/filter/vtkm_filter_contour_export.h>
|
||||
|
||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
|
||||
#include <vtkm/filter/Instantiations.h>
|
||||
#include <vtkm/worklet/Contour.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
/// \brief generate isosurface(s) from a Volume
|
||||
|
||||
/// 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.
|
||||
class VTKM_FILTER_CONTOUR_EXPORT Contour : public vtkm::filter::FilterDataSetWithField<Contour>
|
||||
VTKM_DEPRECATED(1.8, "Use vtkm/filter/contour/Contour.h instead of vtkm/filter/Contour.h.")
|
||||
inline void Contour_deprecated() {}
|
||||
|
||||
inline void Contour_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
using SupportedTypes = vtkm::List<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>;
|
||||
Contour_deprecated();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Filter* Clone() const override
|
||||
{
|
||||
Contour* clone = new Contour();
|
||||
clone->CopyStateFrom(this);
|
||||
return clone;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
bool CanThread() const override { return true; }
|
||||
|
||||
Contour();
|
||||
|
||||
void SetNumberOfIsoValues(vtkm::Id num);
|
||||
|
||||
vtkm::Id GetNumberOfIsoValues() const;
|
||||
|
||||
void SetIsoValue(vtkm::Float64 v) { this->SetIsoValue(0, v); }
|
||||
|
||||
void SetIsoValue(vtkm::Id index, vtkm::Float64);
|
||||
|
||||
void SetIsoValues(const std::vector<vtkm::Float64>& values);
|
||||
|
||||
vtkm::Float64 GetIsoValue(vtkm::Id index) const;
|
||||
|
||||
/// 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.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetMergeDuplicatePoints(bool on) { this->Worklet.SetMergeDuplicatePoints(on); }
|
||||
|
||||
VTKM_CONT
|
||||
bool GetMergeDuplicatePoints() const { return this->Worklet.GetMergeDuplicatePoints(); }
|
||||
|
||||
/// 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.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetGenerateNormals(bool on) { this->GenerateNormals = on; }
|
||||
VTKM_CONT
|
||||
bool GetGenerateNormals() const { return this->GenerateNormals; }
|
||||
|
||||
/// 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; }
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetNormalArrayName(const std::string& name) { this->NormalArrayName = name; }
|
||||
|
||||
VTKM_CONT
|
||||
const std::string& GetNormalArrayName() const { return this->NormalArrayName; }
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
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);
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
// If the field is a point field, then we need to do a custom interpolation of the points.
|
||||
// In this case, we need to call the superclass's MapFieldOntoOutput, which will in turn
|
||||
// call our DoMapField.
|
||||
return this->FilterDataSetWithField<Contour>::MapFieldOntoOutput(result, field, policy);
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
// Use the precompiled field permutation function.
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> permutation = this->Worklet.GetCellIdMap();
|
||||
return vtkm::filter::MapFieldPermutation(field, permutation, result);
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
//this call is only valid
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
// All other conditions should be handled by MapFieldOntoOutput directly.
|
||||
VTKM_ASSERT(fieldMeta.IsPointField());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> fieldArray;
|
||||
|
||||
fieldArray = this->Worklet.ProcessPointField(input);
|
||||
|
||||
//use the same meta data as the input so we get the same field name, etc.
|
||||
result.AddField(fieldMeta.AsField(fieldArray));
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
VTKM_CONT
|
||||
void CopyStateFrom(const Contour* contour)
|
||||
{
|
||||
this->FilterDataSetWithField<Contour>::CopyStateFrom(contour);
|
||||
|
||||
this->IsoValues = contour->IsoValues;
|
||||
this->GenerateNormals = contour->GenerateNormals;
|
||||
this->AddInterpolationEdgeIds = contour->AddInterpolationEdgeIds;
|
||||
this->ComputeFastNormalsForStructured = contour->ComputeFastNormalsForStructured;
|
||||
this->ComputeFastNormalsForUnstructured = contour->ComputeFastNormalsForUnstructured;
|
||||
this->NormalArrayName = contour->NormalArrayName;
|
||||
this->InterpolationEdgeIdsArrayName = contour->InterpolationEdgeIdsArrayName;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<vtkm::Float64> IsoValues;
|
||||
bool GenerateNormals;
|
||||
bool AddInterpolationEdgeIds;
|
||||
bool ComputeFastNormalsForStructured;
|
||||
bool ComputeFastNormalsForUnstructured;
|
||||
std::string NormalArrayName;
|
||||
std::string InterpolationEdgeIdsArrayName;
|
||||
vtkm::worklet::Contour Worklet;
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::Contour.") Contour
|
||||
: public vtkm::filter::contour::Contour
|
||||
{
|
||||
using contour::Contour::Contour;
|
||||
};
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_CONTOUR_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_CONTOUR_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_CONTOUR_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template VTKM_FILTER_CONTOUR_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#endif // vtk_m_filter_Contour_h
|
||||
#endif //vtk_m_filter_Contour_h
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <vtkm/exec/FunctorBase.h>
|
||||
|
||||
#include <vtkm/filter/contour/worklet/clip/ClipTables.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/DispatcherReduceByKey.h>
|
||||
@ -37,7 +38,6 @@
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/WorkletReduceByKey.h>
|
||||
#include <vtkm/worklet/clip/ClipTables.h>
|
||||
|
||||
#include <vtkm/filter/MeshQuality.h>
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Slice_cxx
|
||||
#define vtk_m_filter_Slice_cxx
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/Contour.hxx>
|
||||
#include <vtkm/filter/Slice.h>
|
||||
#include <vtkm/filter/Slice.hxx>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
template VTKM_FILTER_CONTOUR_EXPORT vtkm::cont::DataSet Slice::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
}
|
||||
} // vtkm::filter
|
||||
|
||||
#endif // vtk_m_filter_Slice_cxx
|
@ -10,124 +10,29 @@
|
||||
#ifndef vtk_m_filter_Slice_h
|
||||
#define vtk_m_filter_Slice_h
|
||||
|
||||
#include <vtkm/filter/vtkm_filter_contour_export.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/FilterDataSet.h>
|
||||
|
||||
#include <vtkm/ImplicitFunction.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/contour/Slice.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
class VTKM_FILTER_CONTOUR_EXPORT Slice : public vtkm::filter::FilterDataSet<Slice>
|
||||
VTKM_DEPRECATED(1.8, "Use vtkm/filter/contour/Slice.h instead of vtkm/filter/Slice.h.")
|
||||
inline void Slice_deprecated() {}
|
||||
|
||||
inline void Slice_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
/// Set/Get the implicit function that is used to perform the slicing.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetImplicitFunction(const vtkm::ImplicitFunctionGeneral& func) { this->Function = func; }
|
||||
VTKM_CONT
|
||||
const vtkm::ImplicitFunctionGeneral& GetImplicitFunction() const { return this->Function; }
|
||||
Slice_deprecated();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetMergeDuplicatePoints(bool on) { this->ContourFilter.SetMergeDuplicatePoints(on); }
|
||||
VTKM_CONT
|
||||
bool GetMergeDuplicatePoints() const { return this->ContourFilter.GetMergeDuplicatePoints(); }
|
||||
|
||||
/// 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.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetGenerateNormals(bool on) { this->ContourFilter.SetGenerateNormals(on); }
|
||||
VTKM_CONT
|
||||
bool GetGenerateNormals() const { return this->ContourFilter.GetGenerateNormals(); }
|
||||
|
||||
/// 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->ContourFilter.SetAddInterpolationEdgeIds(on); }
|
||||
VTKM_CONT
|
||||
bool GetAddInterpolationEdgeIds() const
|
||||
{
|
||||
return this->ContourFilter.GetAddInterpolationEdgeIds();
|
||||
}
|
||||
|
||||
/// 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->ContourFilter.SetComputeFastNormalsForStructured(on);
|
||||
}
|
||||
VTKM_CONT
|
||||
bool GetComputeFastNormalsForStructured() const
|
||||
{
|
||||
return this->ContourFilter.GetComputeFastNormalsForStructured();
|
||||
}
|
||||
|
||||
/// 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->ContourFilter.SetComputeFastNormalsForUnstructured(on);
|
||||
}
|
||||
VTKM_CONT
|
||||
bool GetComputeFastNormalsForUnstructured() const
|
||||
{
|
||||
return this->ContourFilter.GetComputeFastNormalsForUnstructured();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetNormalArrayName(const std::string& name) { this->ContourFilter.SetNormalArrayName(name); }
|
||||
|
||||
VTKM_CONT
|
||||
const std::string& GetNormalArrayName() const { return this->ContourFilter.GetNormalArrayName(); }
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
return this->ContourFilter.MapFieldOntoOutput(result, field, policy);
|
||||
}
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
//this call is only valid
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
return this->ContourFilter.DoMapField(result, input, fieldMeta, policy);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::ImplicitFunctionGeneral Function;
|
||||
vtkm::filter::Contour ContourFilter;
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::contour::Slice.") Slice
|
||||
: public vtkm::filter::contour::Slice
|
||||
{
|
||||
using contour::Slice::Slice;
|
||||
};
|
||||
|
||||
#ifndef vtk_m_filter_Slice_cxx
|
||||
extern template VTKM_FILTER_CONTOUR_TEMPLATE_EXPORT vtkm::cont::DataSet Slice::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
#endif
|
||||
|
||||
}
|
||||
} // vtkm::filter
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#endif // vtk_m_filter_Slice_h
|
||||
#endif //vtk_m_filter_Slice_h
|
||||
|
@ -18,6 +18,6 @@ set(libraries
|
||||
vtkm_unit_tests(
|
||||
SOURCES ${unit_tests}
|
||||
LIBRARIES ${libraries}
|
||||
ALL_BACKENDS # we still need it because Contour has not been migrated yet.
|
||||
ALL_BACKENDS # deivce compiler needed, uses ArrayCopy
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -78,7 +78,7 @@ void TestPointMerging()
|
||||
vtkm::cont::ArrayCopy(baseData.GetCoordinateSystem().GetData(), newcoords);
|
||||
baseData.GetCoordinateSystem().SetData(newcoords);
|
||||
|
||||
vtkm::filter::Contour marchingCubes;
|
||||
vtkm::filter::contour::Contour marchingCubes;
|
||||
marchingCubes.SetIsoValue(0.05);
|
||||
marchingCubes.SetMergeDuplicatePoints(false);
|
||||
marchingCubes.SetActiveField("pointvar");
|
||||
|
52
vtkm/filter/contour/CMakeLists.txt
Normal file
52
vtkm/filter/contour/CMakeLists.txt
Normal file
@ -0,0 +1,52 @@
|
||||
##============================================================================
|
||||
## 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.
|
||||
##============================================================================
|
||||
|
||||
set(contour_headers
|
||||
ClipWithField.h
|
||||
Contour.h
|
||||
Slice.h
|
||||
)
|
||||
|
||||
set(contour_sources_device
|
||||
ClipWithField.cxx
|
||||
Contour.cxx
|
||||
Slice.cxx
|
||||
)
|
||||
|
||||
set_source_files_properties(Contour.cxx PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_contour
|
||||
HEADERS ${contour_headers}
|
||||
DEVICE_SOURCES ${contour_sources_device}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
||||
set_property(TARGET
|
||||
vtkm_filter_contour
|
||||
PROPERTY UNITY_BUILD_MODE GROUP
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_filter_contour PUBLIC vtkm_worklet vtkm_filter_core)
|
||||
|
||||
if (VTKm_ENABLE_MPI)
|
||||
target_link_libraries(vtkm_filter_contour PUBLIC MPI::MPI_CXX)
|
||||
endif ()
|
||||
|
||||
target_link_libraries(vtkm_filter PUBLIC INTERFACE
|
||||
vtkm_filter_contour
|
||||
)
|
||||
|
||||
add_subdirectory(worklet)
|
||||
|
||||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
|
||||
if (VTKm_ENABLE_TESTING)
|
||||
add_subdirectory(testing)
|
||||
endif ()
|
118
vtkm/filter/contour/ClipWithField.cxx
Normal file
118
vtkm/filter/contour/ClipWithField.cxx
Normal file
@ -0,0 +1,118 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
#include <vtkm/filter/contour/ClipWithField.h>
|
||||
#include <vtkm/filter/contour/worklet/Clip.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace
|
||||
{
|
||||
struct ClipWithFieldProcessCoords
|
||||
{
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
|
||||
const std::string& coordsName,
|
||||
const vtkm::worklet::Clip& worklet,
|
||||
vtkm::cont::DataSet& output) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
|
||||
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
|
||||
output.AddCoordinateSystem(outCoords);
|
||||
}
|
||||
};
|
||||
|
||||
bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::worklet::Clip& worklet)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
auto array = field.GetData();
|
||||
auto functor = [&](auto concrete) {
|
||||
using T = typename decltype(concrete)::ValueType;
|
||||
vtkm::cont::ArrayHandle<T> output;
|
||||
output = worklet.ProcessPointField(concrete);
|
||||
result.template AddPointField(field.GetName(), output);
|
||||
};
|
||||
|
||||
array.CastAndCallForTypesWithFloatFallback<vtkm::TypeListScalarAll, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
functor);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
// Use the precompiled field permutation function.
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> permutation = worklet.GetCellMapOutputToInput();
|
||||
return vtkm::filter::MapFieldPermutation(field, permutation, result);
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // anonymous
|
||||
|
||||
namespace contour
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
vtkm::cont::DataSet ClipWithField::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
auto field = this->GetFieldFromDataSet(input);
|
||||
if (!field.IsFieldPoint())
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
||||
}
|
||||
|
||||
vtkm::worklet::Clip Worklet;
|
||||
|
||||
//get the cells and coordinates of the dataset
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
|
||||
const auto& inArray = this->GetFieldFromDataSet(input).GetData();
|
||||
vtkm::cont::DataSet output;
|
||||
|
||||
auto ResolveFieldType = [&, this](auto concrete) {
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
Worklet.Run(cells, concrete, this->ClipValue, this->Invert);
|
||||
|
||||
output.SetCellSet(outputCellSet);
|
||||
|
||||
// Compute the new boundary points and add them to the output:
|
||||
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
|
||||
++coordSystemId)
|
||||
{
|
||||
const vtkm::cont::CoordinateSystem& coords = input.GetCoordinateSystem(coordSystemId);
|
||||
coords.GetData().CastAndCall(ClipWithFieldProcessCoords{}, coords.GetName(), Worklet, output);
|
||||
}
|
||||
};
|
||||
|
||||
inArray.CastAndCallForTypesWithFloatFallback<vtkm::TypeListScalarAll, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
ResolveFieldType);
|
||||
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, Worklet); };
|
||||
MapFieldsOntoOutput(input, output, mapper);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end namespace vtkm::filter
|
51
vtkm/filter/contour/ClipWithField.h
Normal file
51
vtkm/filter/contour/ClipWithField.h
Normal file
@ -0,0 +1,51 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_contour_ClipWithField_h
|
||||
#define vtk_m_filter_contour_ClipWithField_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/contour/vtkm_filter_contour_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace contour
|
||||
{
|
||||
/// \brief Clip a dataset using a field
|
||||
///
|
||||
/// Clip a dataset using a given field value. All points that are less than that
|
||||
/// value are considered outside, and will be discarded. All points that are greater
|
||||
/// are kept.
|
||||
/// The resulting geometry will not be water tight.
|
||||
class VTKM_FILTER_CONTOUR_EXPORT ClipWithField : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
void SetClipValue(vtkm::Float64 value) { this->ClipValue = value; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetInvertClip(bool invert) { this->Invert = invert; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 GetClipValue() const { return this->ClipValue; }
|
||||
|
||||
private:
|
||||
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& result) override;
|
||||
|
||||
vtkm::Float64 ClipValue = 0;
|
||||
bool Invert = false;
|
||||
};
|
||||
} // namespace contour
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_contour_ClipWithField_h
|
@ -7,15 +7,16 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_filter_Contour_hxx
|
||||
#define vtk_m_filter_Contour_hxx
|
||||
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/filter/contour/worklet/Contour.h>
|
||||
|
||||
#include <vtkm/worklet/SurfaceNormals.h>
|
||||
|
||||
namespace vtkm
|
||||
@ -23,6 +24,8 @@ namespace vtkm
|
||||
namespace filter
|
||||
{
|
||||
|
||||
using SupportedTypes = vtkm::List<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -36,41 +39,89 @@ inline bool IsCellSetStructured(const vtkm::cont::UnknownCellSet& cellset)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::worklet::Contour& Worklet)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
auto array = field.GetData();
|
||||
|
||||
auto functor = [&](auto concrete) {
|
||||
auto fieldArray = Worklet.ProcessPointField(concrete);
|
||||
result.AddPointField(field.GetName(), fieldArray);
|
||||
};
|
||||
array.CastAndCallForTypesWithFloatFallback<SupportedTypes, VTKM_DEFAULT_STORAGE_LIST>(functor);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
// Use the precompiled field permutation function.
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> permutation = Worklet.GetCellIdMap();
|
||||
return vtkm::filter::MapFieldPermutation(field, permutation, result);
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
namespace contour
|
||||
{
|
||||
if (fieldMeta.IsPointField() == false)
|
||||
//-----------------------------------------------------------------------------
|
||||
void Contour::SetMergeDuplicatePoints(bool on)
|
||||
{
|
||||
this->MergeDuplicatedPoints = on;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
bool Contour::GetMergeDuplicatePoints() const
|
||||
{
|
||||
return MergeDuplicatedPoints;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
||||
{
|
||||
vtkm::worklet::Contour Worklet;
|
||||
Worklet.SetMergeDuplicatePoints(this->GetMergeDuplicatePoints());
|
||||
|
||||
if (!this->GetFieldFromDataSet(inDataSet).IsFieldPoint())
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
||||
throw vtkm::cont::ErrorFilterExecution("Point fieldArray expected.");
|
||||
}
|
||||
|
||||
if (this->IsoValues.size() == 0)
|
||||
if (this->IsoValues.empty())
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("No iso-values provided.");
|
||||
}
|
||||
|
||||
// Check the fields of the dataset to see what kinds of fields are present so
|
||||
// we can free the mapping arrays that won't be needed. A point field must
|
||||
// we can free the mapping arrays that won't be needed. A point fieldArray must
|
||||
// exist for this algorithm, so just check cells.
|
||||
const vtkm::Id numFields = input.GetNumberOfFields();
|
||||
const vtkm::Id numFields = inDataSet.GetNumberOfFields();
|
||||
bool hasCellFields = false;
|
||||
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
|
||||
{
|
||||
auto f = input.GetField(fieldIdx);
|
||||
const auto& f = inDataSet.GetField(fieldIdx);
|
||||
hasCellFields = f.IsFieldCell();
|
||||
}
|
||||
|
||||
//get the cells and coordinates of the dataset
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
const vtkm::cont::UnknownCellSet& cells = inDataSet.GetCellSet();
|
||||
|
||||
const vtkm::cont::CoordinateSystem& coords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
inDataSet.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
|
||||
const auto& fieldArray = this->GetFieldFromDataSet(inDataSet).GetData();
|
||||
|
||||
using Vec3HandleType = vtkm::cont::ArrayHandle<vtkm::Vec3f>;
|
||||
Vec3HandleType vertices;
|
||||
@ -79,37 +130,25 @@ vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& input,
|
||||
vtkm::cont::DataSet output;
|
||||
vtkm::cont::CellSetSingleType<> outputCells;
|
||||
|
||||
std::vector<T> ivalues(this->IsoValues.size());
|
||||
for (std::size_t i = 0; i < ivalues.size(); ++i)
|
||||
{
|
||||
ivalues[i] = static_cast<T>(this->IsoValues[i]);
|
||||
}
|
||||
|
||||
//not sold on this as we have to generate more signatures for the
|
||||
//worklet with the design
|
||||
//But I think we should get this to compile before we tinker with
|
||||
//a more efficient api
|
||||
|
||||
bool generateHighQualityNormals = IsCellSetStructured(cells)
|
||||
? !this->ComputeFastNormalsForStructured
|
||||
: !this->ComputeFastNormalsForUnstructured;
|
||||
if (this->GenerateNormals && generateHighQualityNormals)
|
||||
{
|
||||
outputCells = this->Worklet.Run(ivalues,
|
||||
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||
coords.GetData(),
|
||||
field,
|
||||
vertices,
|
||||
normals);
|
||||
}
|
||||
else
|
||||
{
|
||||
outputCells = this->Worklet.Run(ivalues,
|
||||
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||
coords.GetData(),
|
||||
field,
|
||||
vertices);
|
||||
}
|
||||
|
||||
auto ResolveFieldType = [&, this](auto concrete) {
|
||||
std::vector<typename decltype(concrete)::ValueType> ivalues(IsoValues.begin(), IsoValues.end());
|
||||
|
||||
if (this->GenerateNormals && generateHighQualityNormals)
|
||||
{
|
||||
outputCells = Worklet.Run(ivalues, cells, coords.GetData(), concrete, vertices, normals);
|
||||
}
|
||||
else
|
||||
{
|
||||
outputCells = Worklet.Run(ivalues, cells, coords.GetData(), concrete, vertices);
|
||||
}
|
||||
};
|
||||
|
||||
fieldArray.CastAndCallForTypesWithFloatFallback<SupportedTypes, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
ResolveFieldType);
|
||||
|
||||
if (this->GenerateNormals)
|
||||
{
|
||||
@ -130,7 +169,7 @@ vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& input,
|
||||
{
|
||||
vtkm::cont::Field interpolationEdgeIdsField(InterpolationEdgeIdsArrayName,
|
||||
vtkm::cont::Field::Association::POINTS,
|
||||
this->Worklet.GetInterpolationEdgeIds());
|
||||
Worklet.GetInterpolationEdgeIds());
|
||||
output.AddField(interpolationEdgeIdsField);
|
||||
}
|
||||
|
||||
@ -143,12 +182,14 @@ vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& input,
|
||||
|
||||
if (!hasCellFields)
|
||||
{
|
||||
this->Worklet.ReleaseCellMapArrays();
|
||||
Worklet.ReleaseCellMapArrays();
|
||||
}
|
||||
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, Worklet); };
|
||||
MapFieldsOntoOutput(inDataSet, output, mapper);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#endif
|
||||
} // namespace contour
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
134
vtkm/filter/contour/Contour.h
Normal file
134
vtkm/filter/contour/Contour.h
Normal file
@ -0,0 +1,134 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_contour_Contour_h
|
||||
#define vtk_m_filter_contour_Contour_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/contour/vtkm_filter_contour_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace contour
|
||||
{
|
||||
/// \brief generate isosurface(s) from a Volume
|
||||
|
||||
/// 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.
|
||||
class VTKM_FILTER_CONTOUR_EXPORT Contour : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
void SetNumberOfIsoValues(vtkm::Id num)
|
||||
{
|
||||
if (num >= 0)
|
||||
{
|
||||
this->IsoValues.resize(static_cast<std::size_t>(num));
|
||||
}
|
||||
}
|
||||
|
||||
vtkm::Id GetNumberOfIsoValues() const { return static_cast<vtkm::Id>(this->IsoValues.size()); }
|
||||
|
||||
void SetIsoValue(vtkm::Float64 v) { this->SetIsoValue(0, v); }
|
||||
|
||||
void SetIsoValue(vtkm::Id index, vtkm::Float64 v)
|
||||
{
|
||||
std::size_t i = static_cast<std::size_t>(index);
|
||||
if (i >= this->IsoValues.size())
|
||||
{
|
||||
this->IsoValues.resize(i + 1);
|
||||
}
|
||||
this->IsoValues[i] = v;
|
||||
}
|
||||
|
||||
void SetIsoValues(const std::vector<vtkm::Float64>& values) { this->IsoValues = values; }
|
||||
|
||||
vtkm::Float64 GetIsoValue(vtkm::Id index) const
|
||||
{
|
||||
return this->IsoValues[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
/// 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.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetMergeDuplicatePoints(bool on);
|
||||
|
||||
VTKM_CONT
|
||||
bool GetMergeDuplicatePoints() const;
|
||||
|
||||
/// 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.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetGenerateNormals(bool on) { this->GenerateNormals = on; }
|
||||
VTKM_CONT
|
||||
bool GetGenerateNormals() const { return this->GenerateNormals; }
|
||||
|
||||
/// 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; }
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetNormalArrayName(const std::string& name) { this->NormalArrayName = name; }
|
||||
|
||||
VTKM_CONT
|
||||
const std::string& GetNormalArrayName() const { return this->NormalArrayName; }
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
|
||||
std::vector<vtkm::Float64> IsoValues;
|
||||
bool GenerateNormals = false;
|
||||
bool AddInterpolationEdgeIds = false;
|
||||
bool ComputeFastNormalsForStructured = false;
|
||||
bool ComputeFastNormalsForUnstructured = true;
|
||||
bool MergeDuplicatedPoints = true;
|
||||
std::string NormalArrayName = "normals";
|
||||
std::string InterpolationEdgeIdsArrayName = "edgeIds";
|
||||
|
||||
protected:
|
||||
// Needed by the subclass Slice
|
||||
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& result) override;
|
||||
};
|
||||
} // namespace contour
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_contour_Contour_h
|
@ -7,37 +7,37 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_filter_Slice_hxx
|
||||
#define vtk_m_filter_Slice_hxx
|
||||
|
||||
#include <vtkm/cont/ArrayHandleTransform.h>
|
||||
#include <vtkm/filter/contour/Slice.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
vtkm::cont::DataSet Slice::DoExecute(const vtkm::cont::DataSet& input,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
namespace contour
|
||||
{
|
||||
vtkm::cont::DataSet Slice::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
const auto& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
|
||||
vtkm::cont::DataSet result;
|
||||
auto impFuncEval =
|
||||
vtkm::ImplicitFunctionValueFunctor<vtkm::ImplicitFunctionGeneral>(this->Function);
|
||||
// FIXME: do we still need GetDataAsMultiplexer()? Can GetData() do it?
|
||||
auto sliceScalars =
|
||||
vtkm::cont::make_ArrayHandleTransform(coords.GetDataAsMultiplexer(), impFuncEval);
|
||||
auto field = vtkm::cont::make_FieldPoint("sliceScalars", sliceScalars);
|
||||
// input is a const, we can not AddField to it.
|
||||
vtkm::cont::DataSet clone = input;
|
||||
clone.AddField(field);
|
||||
|
||||
this->ContourFilter.SetIsoValue(0.0);
|
||||
result =
|
||||
this->ContourFilter.DoExecute(input, sliceScalars, vtkm::filter::FieldMetadata(field), policy);
|
||||
this->Contour::SetIsoValue(0.0);
|
||||
this->Contour::SetActiveField("sliceScalars");
|
||||
result = this->Contour::DoExecute(clone);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // vtkm::filter
|
||||
|
||||
#endif // vtk_m_filter_Slice_hxx
|
||||
} // namespace contour
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
43
vtkm/filter/contour/Slice.h
Normal file
43
vtkm/filter/contour/Slice.h
Normal file
@ -0,0 +1,43 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_filter_contour_Slice_h
|
||||
#define vtk_m_filter_contour_Slice_h
|
||||
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/filter/contour/vtkm_filter_contour_export.h>
|
||||
|
||||
#include <vtkm/ImplicitFunction.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace contour
|
||||
{
|
||||
class VTKM_FILTER_CONTOUR_EXPORT Slice : public vtkm::filter::contour::Contour
|
||||
{
|
||||
public:
|
||||
/// Set/Get the implicit function that is used to perform the slicing.
|
||||
///
|
||||
VTKM_CONT
|
||||
void SetImplicitFunction(const vtkm::ImplicitFunctionGeneral& func) { this->Function = func; }
|
||||
VTKM_CONT
|
||||
const vtkm::ImplicitFunctionGeneral& GetImplicitFunction() const { return this->Function; }
|
||||
|
||||
private:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
|
||||
vtkm::ImplicitFunctionGeneral Function;
|
||||
};
|
||||
} // namespace contour
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_contour_Slice_h
|
40
vtkm/filter/contour/testing/CMakeLists.txt
Normal file
40
vtkm/filter/contour/testing/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
||||
##============================================================================
|
||||
## 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.
|
||||
##============================================================================
|
||||
set(unit_tests
|
||||
UnitTestClipWithFieldFilter.cxx
|
||||
UnitTestContourFilter.cxx
|
||||
UnitTestContourFilterNormals.cxx
|
||||
)
|
||||
|
||||
set(libraries
|
||||
vtkm_filter_clean_grid
|
||||
vtkm_filter_contour
|
||||
vtkm_filter_field_transform
|
||||
vtkm_io
|
||||
vtkm_source
|
||||
)
|
||||
|
||||
if (VTKm_ENABLE_RENDERING)
|
||||
list(APPEND libraries
|
||||
vtkm_rendering_testing
|
||||
vtkm_rendering)
|
||||
|
||||
list(APPEND unit_tests
|
||||
RenderTestContourFilter.cxx
|
||||
RenderTestSliceFilter.cxx
|
||||
)
|
||||
endif()
|
||||
|
||||
vtkm_unit_tests(
|
||||
SOURCES ${unit_tests}
|
||||
LIBRARIES ${libraries}
|
||||
ALL_BACKENDS # ArrayCopy/Sort called, needs device compiler
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
@ -13,8 +13,8 @@
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/source/Tangle.h>
|
||||
|
||||
#include <vtkm/io/VTKDataSetReader.h>
|
||||
@ -32,7 +32,7 @@ void TestContourFilterWedge()
|
||||
vtkm::io::VTKDataSetReader reader(pathname);
|
||||
vtkm::cont::DataSet dataSet = reader.ReadDataSet();
|
||||
|
||||
vtkm::filter::Contour contour;
|
||||
vtkm::filter::contour::Contour contour;
|
||||
contour.SetIsoValue(0, 1);
|
||||
contour.SetActiveField("gyroid");
|
||||
contour.SetFieldsToPass({ "gyroid", "cellvar" });
|
||||
@ -57,7 +57,7 @@ void TestContourFilterUniform()
|
||||
std::string fieldName = "pointvar";
|
||||
VTKM_TEST_ASSERT(inputData.HasField(fieldName));
|
||||
|
||||
vtkm::filter::Contour contour;
|
||||
vtkm::filter::contour::Contour contour;
|
||||
contour.SetGenerateNormals(false);
|
||||
contour.SetMergeDuplicatePoints(true);
|
||||
contour.SetIsoValue(0, 100.0);
|
||||
@ -83,7 +83,7 @@ void TestContourFilterTangle()
|
||||
vtkm::source::Tangle tangle(dims);
|
||||
vtkm::cont::DataSet dataSet = tangle.Execute();
|
||||
|
||||
vtkm::filter::Contour contour;
|
||||
vtkm::filter::contour::Contour contour;
|
||||
contour.SetGenerateNormals(true);
|
||||
contour.SetIsoValue(0, 1);
|
||||
contour.SetActiveField("tangle");
|
@ -8,7 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/filter/Slice.h>
|
||||
#include <vtkm/filter/contour/Slice.h>
|
||||
|
||||
#include <vtkm/ImplicitFunction.h>
|
||||
#include <vtkm/filter/Tetrahedralize.h>
|
||||
@ -28,7 +28,7 @@ void TestSliceStructuredPointsPlane()
|
||||
auto ds = wavelet.Execute();
|
||||
|
||||
vtkm::Plane plane(vtkm::Plane::Vector{ 1, 1, 1 });
|
||||
vtkm::filter::Slice slice;
|
||||
vtkm::filter::contour::Slice slice;
|
||||
slice.SetImplicitFunction(plane);
|
||||
auto result = slice.Execute(ds);
|
||||
|
||||
@ -49,7 +49,7 @@ void TestSliceStructuredPointsSphere()
|
||||
auto ds = wavelet.Execute();
|
||||
|
||||
vtkm::Sphere sphere(8.5f);
|
||||
vtkm::filter::Slice slice;
|
||||
vtkm::filter::contour::Slice slice;
|
||||
slice.SetImplicitFunction(sphere);
|
||||
auto result = slice.Execute(ds);
|
||||
|
||||
@ -72,7 +72,7 @@ void TestSliceUnstructuredGridPlane()
|
||||
ds = tetrahedralize.Execute(ds);
|
||||
|
||||
vtkm::Plane plane(vtkm::Plane::Vector{ 1 });
|
||||
vtkm::filter::Slice slice;
|
||||
vtkm::filter::contour::Slice slice;
|
||||
slice.SetImplicitFunction(plane);
|
||||
auto result = slice.Execute(ds);
|
||||
|
||||
@ -95,7 +95,7 @@ void TestSliceUnstructuredGridCylinder()
|
||||
ds = tetrahedralize.Execute(ds);
|
||||
|
||||
vtkm::Cylinder cylinder(vtkm::Cylinder::Vector{ 0, 1, 0 }, 8.5f);
|
||||
vtkm::filter::Slice slice;
|
||||
vtkm::filter::contour::Slice slice;
|
||||
slice.SetImplicitFunction(cylinder);
|
||||
auto result = slice.Execute(ds);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
#include <vtkm/filter/contour/ClipWithField.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -54,7 +54,7 @@ void TestClipExplicit()
|
||||
|
||||
vtkm::cont::DataSet ds = MakeTestDatasetExplicit();
|
||||
|
||||
vtkm::filter::ClipWithField clip;
|
||||
vtkm::filter::contour::ClipWithField clip;
|
||||
clip.SetClipValue(0.5);
|
||||
clip.SetActiveField("scalars");
|
||||
clip.SetFieldsToPass("scalars", vtkm::cont::Field::Association::POINTS);
|
||||
@ -90,7 +90,7 @@ void TestClipVolume()
|
||||
vtkm::cont::testing::MakeTestDataSet maker;
|
||||
vtkm::cont::DataSet ds = maker.Make3DUniformDataSet3(dims);
|
||||
|
||||
vtkm::filter::ClipWithField clip;
|
||||
vtkm::filter::contour::ClipWithField clip;
|
||||
clip.SetClipValue(0.0);
|
||||
clip.SetActiveField("pointvar");
|
||||
clip.SetFieldsToPass("pointvar", vtkm::cont::Field::Association::POINTS);
|
@ -9,12 +9,13 @@
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/filter/field_transform/GenerateIds.h>
|
||||
|
||||
#include <vtkm/io/VTKDataSetReader.h>
|
||||
@ -38,7 +39,7 @@ public:
|
||||
genIds.SetCellFieldName("cellvar");
|
||||
vtkm::cont::DataSet dataSet = genIds.Execute(tangle.Execute());
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
vtkm::filter::contour::Contour mc;
|
||||
|
||||
mc.SetGenerateNormals(true);
|
||||
mc.SetIsoValue(0, 0.5);
|
||||
@ -133,7 +134,7 @@ public:
|
||||
vtkm::FloatDefault isovalue = 100.0;
|
||||
// Range = [10.1, 180.5]
|
||||
VTKM_TEST_ASSERT(range.Contains(isovalue));
|
||||
vtkm::filter::Contour filter;
|
||||
vtkm::filter::contour::Contour filter;
|
||||
filter.SetGenerateNormals(false);
|
||||
filter.SetMergeDuplicatePoints(true);
|
||||
filter.SetIsoValue(isovalue);
|
||||
@ -158,17 +159,16 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> fieldArray;
|
||||
dataSet.GetPointField("gyroid").GetData().AsArrayHandle(fieldArray);
|
||||
|
||||
vtkm::worklet::Contour isosurfaceFilter;
|
||||
vtkm::filter::contour::Contour isosurfaceFilter;
|
||||
isosurfaceFilter.SetActiveField("gyroid");
|
||||
isosurfaceFilter.SetMergeDuplicatePoints(false);
|
||||
isosurfaceFilter.SetIsoValue(0.0);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
||||
|
||||
auto result = isosurfaceFilter.Run(
|
||||
{ 0.0f }, cellSet, dataSet.GetCoordinateSystem(), fieldArray, verticesArray, normalsArray);
|
||||
auto result = isosurfaceFilter.Execute(dataSet);
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == 52);
|
||||
}
|
||||
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
this->Test3DUniformDataSet0();
|
@ -14,7 +14,7 @@
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
#include <vtkm/io/VTKDataSetWriter.h>
|
||||
|
||||
@ -102,7 +102,7 @@ void TestNormals(const vtkm::cont::DataSet& dataset, bool structured)
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> normals;
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
vtkm::filter::contour::Contour mc;
|
||||
mc.SetIsoValue(0, 200);
|
||||
mc.SetGenerateNormals(true);
|
||||
|
@ -9,7 +9,9 @@
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
Clip.h
|
||||
CommonState.h
|
||||
Contour.h
|
||||
FieldPropagation.h
|
||||
FlyingEdges.h
|
||||
FlyingEdgesHelpers.h
|
||||
@ -25,5 +27,7 @@ set(headers
|
||||
MarchingCells.h
|
||||
)
|
||||
|
||||
add_subdirectory(clip)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
vtkm_declare_headers(${headers})
|
@ -10,6 +10,7 @@
|
||||
#ifndef vtkm_m_worklet_Clip_h
|
||||
#define vtkm_m_worklet_Clip_h
|
||||
|
||||
#include <vtkm/filter/contour/worklet/clip/ClipTables.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/DispatcherReduceByKey.h>
|
||||
@ -17,7 +18,6 @@
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/WorkletReduceByKey.h>
|
||||
#include <vtkm/worklet/clip/ClipTables.h>
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
@ -15,10 +15,10 @@
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
|
||||
#include <vtkm/worklet/contour/CommonState.h>
|
||||
#include <vtkm/worklet/contour/FieldPropagation.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdges.h>
|
||||
#include <vtkm/worklet/contour/MarchingCells.h>
|
||||
#include <vtkm/filter/contour/worklet/CommonState.h>
|
||||
#include <vtkm/filter/contour/worklet/FieldPropagation.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdges.h>
|
||||
#include <vtkm/filter/contour/worklet/MarchingCells.h>
|
||||
|
||||
|
||||
namespace vtkm
|
@ -12,10 +12,10 @@
|
||||
#ifndef vtk_m_worklet_contour_flyingedges_h
|
||||
#define vtk_m_worklet_contour_flyingedges_h
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass1.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass2.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass4.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass1.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass2.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass4.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleGroupVec.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
@ -13,8 +13,8 @@
|
||||
#ifndef vtk_m_worklet_contour_flyingedges_pass1_h
|
||||
#define vtk_m_worklet_contour_flyingedges_pass1_h
|
||||
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
@ -13,8 +13,8 @@
|
||||
#ifndef vtk_m_worklet_contour_flyingedges_pass2_h
|
||||
#define vtk_m_worklet_contour_flyingedges_pass2_h
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesTables.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesTables.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
@ -13,10 +13,10 @@
|
||||
#ifndef vtk_m_worklet_contour_flyingedges_pass4_h
|
||||
#define vtk_m_worklet_contour_flyingedges_pass4_h
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass4Common.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass4X.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass4XWithNormals.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass4Y.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass4Common.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass4X.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass4XWithNormals.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass4Y.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
4
vtkm/worklet/contour/FlyingEdgesPass4Common.h → vtkm/filter/contour/worklet/FlyingEdgesPass4Common.h
4
vtkm/worklet/contour/FlyingEdgesPass4Common.h → vtkm/filter/contour/worklet/FlyingEdgesPass4Common.h
@ -13,8 +13,8 @@
|
||||
#ifndef vtk_m_worklet_contour_flyingedges_pass4_common_h
|
||||
#define vtk_m_worklet_contour_flyingedges_pass4_common_h
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesTables.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesTables.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
@ -14,8 +14,8 @@
|
||||
#define vtk_m_worklet_contour_flyingedges_pass4x_h
|
||||
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesTables.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesTables.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
@ -14,10 +14,10 @@
|
||||
#define vtk_m_worklet_contour_flyingedges_pass4x_with_norms_h
|
||||
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesTables.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesTables.h>
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesPass4.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesPass4.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
@ -14,8 +14,8 @@
|
||||
#define vtk_m_worklet_contour_flyingedges_pass4y_h
|
||||
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/worklet/contour/FlyingEdgesTables.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesTables.h>
|
||||
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
#include <vtkm/worklet/gradient/StructuredPointGradient.h>
|
@ -12,7 +12,7 @@
|
||||
#ifndef vtk_m_worklet_contour_flyingedges_tables_h
|
||||
#define vtk_m_worklet_contour_flyingedges_tables_h
|
||||
|
||||
#include <vtkm/worklet/contour/FlyingEdgesHelpers.h>
|
||||
#include <vtkm/filter/contour/worklet/FlyingEdgesHelpers.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
@ -28,9 +28,9 @@
|
||||
#include <vtkm/worklet/ScatterCounting.h>
|
||||
#include <vtkm/worklet/ScatterPermutation.h>
|
||||
|
||||
#include <vtkm/filter/contour/worklet/CommonState.h>
|
||||
#include <vtkm/filter/contour/worklet/MarchingCellTables.h>
|
||||
#include <vtkm/worklet/WorkletReduceByKey.h>
|
||||
#include <vtkm/worklet/contour/CommonState.h>
|
||||
#include <vtkm/worklet/contour/MarchingCellTables.h>
|
||||
#include <vtkm/worklet/gradient/PointGradient.h>
|
||||
#include <vtkm/worklet/gradient/StructuredPointGradient.h>
|
||||
|
@ -16,10 +16,7 @@ set(unit_tests
|
||||
UnitTestCellAverageFilter.cxx
|
||||
UnitTestCellMeasuresFilter.cxx
|
||||
UnitTestCellSetConnectivityFilter.cxx
|
||||
UnitTestClipWithFieldFilter.cxx
|
||||
UnitTestClipWithImplicitFunctionFilter.cxx
|
||||
UnitTestContourFilter.cxx
|
||||
UnitTestContourFilterNormals.cxx
|
||||
UnitTestContourTreeUniformFilter.cxx
|
||||
UnitTestContourTreeUniformAugmentedFilter.cxx
|
||||
UnitTestContourTreeUniformDistributedFilter.cxx
|
||||
@ -93,9 +90,7 @@ if (VTKm_ENABLE_RENDERING)
|
||||
|
||||
list(APPEND unit_tests
|
||||
RenderTestAmrArrays.cxx
|
||||
RenderTestContourFilter.cxx
|
||||
RenderTestPointTransform.cxx
|
||||
RenderTestSliceFilter.cxx
|
||||
RenderTestSplitSharpEdges.cxx
|
||||
RenderTestStreamline.cxx
|
||||
RenderTestSurfaceNormals.cxx
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/CellSetConnectivity.h>
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/source/Tangle.h>
|
||||
|
||||
namespace
|
||||
@ -27,7 +27,7 @@ public:
|
||||
vtkm::source::Tangle tangle(dims);
|
||||
vtkm::cont::DataSet dataSet = tangle.Execute();
|
||||
|
||||
vtkm::filter::Contour filter;
|
||||
vtkm::filter::contour::Contour filter;
|
||||
filter.SetGenerateNormals(true);
|
||||
filter.SetMergeDuplicatePoints(true);
|
||||
filter.SetIsoValue(0, 0.1);
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
#include <vtkm/filter/contour/ClipWithField.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
#include <vtkm/io/VTKDataSetReader.h>
|
||||
#include <vtkm/source/Tangle.h>
|
||||
@ -102,7 +102,7 @@ void TestMultiBlockFilter()
|
||||
std::vector<bool> flags = { false, true };
|
||||
for (const auto doThreading : flags)
|
||||
{
|
||||
vtkm::filter::ClipWithField clip;
|
||||
vtkm::filter::contour::ClipWithField clip;
|
||||
clip.SetRunMultiThreadedFilter(doThreading);
|
||||
clip.SetClipValue(0.0);
|
||||
clip.SetActiveField("tangle");
|
||||
@ -117,7 +117,7 @@ void TestMultiBlockFilter()
|
||||
results.clear();
|
||||
for (const auto doThreading : flags)
|
||||
{
|
||||
vtkm::filter::Contour mc;
|
||||
vtkm::filter::contour::Contour mc;
|
||||
mc.SetRunMultiThreadedFilter(doThreading);
|
||||
mc.SetGenerateNormals(true);
|
||||
mc.SetIsoValue(0, 0.5);
|
||||
|
@ -8,9 +8,9 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/SplitSharpEdges.h>
|
||||
#include <vtkm/filter/SurfaceNormals.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -225,7 +225,7 @@ void TestWithStructuredData()
|
||||
vtkm::cont::DataSet dataSet = Make3DWavelet();
|
||||
|
||||
// Cut a contour:
|
||||
vtkm::filter::Contour contour;
|
||||
vtkm::filter::contour::Contour contour;
|
||||
contour.SetActiveField("RTData", vtkm::cont::Field::Association::POINTS);
|
||||
contour.SetNumberOfIsoValues(1);
|
||||
contour.SetIsoValue(192);
|
||||
|
@ -15,7 +15,6 @@ set(headers
|
||||
CellAverage.h
|
||||
CellDeepCopy.h
|
||||
CellMeasure.h
|
||||
Clip.h
|
||||
ContourTreeUniform.h
|
||||
ContourTreeUniformAugmented.h
|
||||
CoordinateSystemTransform.h
|
||||
@ -39,7 +38,6 @@ set(headers
|
||||
Keys.h
|
||||
LagrangianStructures.h
|
||||
Magnitude.h
|
||||
Contour.h
|
||||
Mask.h
|
||||
MaskIndices.h
|
||||
MaskNone.h
|
||||
@ -118,10 +116,8 @@ set(sources_device
|
||||
#-----------------------------------------------------------------------------
|
||||
add_subdirectory(internal)
|
||||
add_subdirectory(cellmetrics)
|
||||
add_subdirectory(clip)
|
||||
add_subdirectory(colorconversion)
|
||||
add_subdirectory(connectivities)
|
||||
add_subdirectory(contour)
|
||||
add_subdirectory(contourtree)
|
||||
add_subdirectory(contourtree_augmented)
|
||||
add_subdirectory(contourtree_distributed)
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/WorkletReduceByKey.h>
|
||||
|
||||
#include <vtkm/worklet/clip/ClipTables.h>
|
||||
#include <vtkm/filter/contour/worklet/clip/ClipTables.h>
|
||||
#include <vtkm/worklet/mir/MIRTables.h>
|
||||
|
||||
namespace vtkm
|
||||
|
@ -11,6 +11,7 @@
|
||||
#ifndef vtk_m_worklet_connectivity_InnerJoin_h
|
||||
#define vtk_m_worklet_connectivity_InnerJoin_h
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/ScatterCounting.h>
|
||||
|
@ -23,7 +23,6 @@ set(unit_tests
|
||||
UnitTestCellSetDualGraph.cxx
|
||||
UnitTestCellMeasure.cxx
|
||||
UnitTestClipping.cxx
|
||||
UnitTestContour.cxx
|
||||
UnitTestContourTreeUniform.cxx
|
||||
UnitTestContourTreeUniformAugmented.cxx
|
||||
UnitTestContourTreeUniformDistributed.cxx
|
||||
|
@ -7,7 +7,7 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
|
||||
@ -26,7 +26,7 @@ public:
|
||||
vtkm::source::Tangle tangle(dims);
|
||||
vtkm::cont::DataSet dataSet = tangle.Execute();
|
||||
|
||||
vtkm::filter::Contour filter;
|
||||
vtkm::filter::contour::Contour filter;
|
||||
filter.SetGenerateNormals(true);
|
||||
filter.SetMergeDuplicatePoints(true);
|
||||
filter.SetIsoValue(0, 0.1);
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <vtkm/cont/ArrayHandleGroupVecVariable.h>
|
||||
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
#include <vtkm/worklet/connectivities/CellSetDualGraph.h>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/worklet/Clip.h>
|
||||
#include <vtkm/filter/contour/worklet/Clip.h>
|
||||
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
|
@ -8,7 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/worklet/Clip.h>
|
||||
#include <vtkm/filter/contour/worklet/Clip.h>
|
||||
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
|
@ -1,436 +0,0 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/ClipWithImplicitFunction.h>
|
||||
#include <vtkm/filter/field_transform/GenerateIds.h>
|
||||
#include <vtkm/source/Tangle.h>
|
||||
#include <vtkm/worklet/Contour.h>
|
||||
|
||||
namespace vtkm_ut_mc_worklet
|
||||
{
|
||||
class EuclideanNorm
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
EuclideanNorm()
|
||||
: Reference(0., 0., 0.)
|
||||
{
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
EuclideanNorm(vtkm::Vec3f_32 reference)
|
||||
: Reference(reference)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Float32 operator()(vtkm::Vec3f_32 v) const
|
||||
{
|
||||
vtkm::Vec3f_32 d(
|
||||
v[0] - this->Reference[0], v[1] - this->Reference[1], v[2] - this->Reference[2]);
|
||||
return vtkm::Magnitude(d);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Vec3f_32 Reference;
|
||||
};
|
||||
|
||||
class CubeGridConnectivity
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
CubeGridConnectivity()
|
||||
: Dimension(1)
|
||||
, DimSquared(1)
|
||||
, DimPlus1Squared(4)
|
||||
{
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
CubeGridConnectivity(vtkm::Id dim)
|
||||
: Dimension(dim)
|
||||
, DimSquared(dim * dim)
|
||||
, DimPlus1Squared((dim + 1) * (dim + 1))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id operator()(vtkm::Id vertex) const
|
||||
{
|
||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
||||
|
||||
vtkm::Id cellId = vertex / HexTraits::NUM_POINTS;
|
||||
vtkm::Id localId = vertex % HexTraits::NUM_POINTS;
|
||||
vtkm::Id globalId =
|
||||
(cellId + cellId / this->Dimension + (this->Dimension + 1) * (cellId / (this->DimSquared)));
|
||||
|
||||
switch (localId)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
globalId += 1;
|
||||
break;
|
||||
case 2:
|
||||
globalId += this->Dimension + 2;
|
||||
break;
|
||||
case 3:
|
||||
globalId += this->Dimension + 1;
|
||||
break;
|
||||
case 4:
|
||||
globalId += this->DimPlus1Squared;
|
||||
break;
|
||||
case 5:
|
||||
globalId += this->DimPlus1Squared + 1;
|
||||
break;
|
||||
case 6:
|
||||
globalId += this->Dimension + this->DimPlus1Squared + 2;
|
||||
break;
|
||||
case 7:
|
||||
globalId += this->Dimension + this->DimPlus1Squared + 1;
|
||||
break;
|
||||
}
|
||||
return globalId;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Id Dimension;
|
||||
vtkm::Id DimSquared;
|
||||
vtkm::Id DimPlus1Squared;
|
||||
};
|
||||
|
||||
class MakeRadiantDataSet
|
||||
{
|
||||
public:
|
||||
using CoordinateArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||
using DataArrayHandle =
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleUniformPointCoordinates, EuclideanNorm>;
|
||||
using ConnectivityArrayHandle =
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
||||
CubeGridConnectivity>;
|
||||
|
||||
using CellSet = vtkm::cont::CellSetSingleType<
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
||||
CubeGridConnectivity>::StorageTag>;
|
||||
|
||||
vtkm::cont::DataSet Make3DRadiantDataSet(vtkm::IdComponent dim = 5);
|
||||
};
|
||||
|
||||
inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComponent dim)
|
||||
{
|
||||
// create a cube from -.5 to .5 in x,y,z, consisting of <dim> cells on each
|
||||
// axis, with point values equal to the Euclidean distance from the origin.
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
||||
|
||||
using CoordType = vtkm::Vec3f_32;
|
||||
|
||||
const vtkm::IdComponent nCells = dim * dim * dim;
|
||||
|
||||
vtkm::Float32 spacing = vtkm::Float32(1. / dim);
|
||||
CoordinateArrayHandle coordinates(vtkm::Id3(dim + 1, dim + 1, dim + 1),
|
||||
CoordType(-.5, -.5, -.5),
|
||||
CoordType(spacing, spacing, spacing));
|
||||
|
||||
DataArrayHandle distanceToOrigin(coordinates);
|
||||
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
|
||||
vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, nCells),
|
||||
cellFieldArray);
|
||||
|
||||
ConnectivityArrayHandle connectivity(
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
|
||||
CubeGridConnectivity(dim));
|
||||
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
//Set point scalar
|
||||
dataSet.AddField(vtkm::cont::Field(
|
||||
"distanceToOrigin", vtkm::cont::Field::Association::POINTS, distanceToOrigin));
|
||||
dataSet.AddField(
|
||||
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::Association::POINTS, distanceToOther));
|
||||
|
||||
CellSet cellSet;
|
||||
cellSet.Fill((dim + 1) * (dim + 1) * (dim + 1), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
|
||||
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
dataSet.AddField(
|
||||
vtkm::cont::Field("cellvar", vtkm::cont::Field::Association::CELL_SET, cellFieldArray));
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
} // vtkm_ut_mc_worklet namespace
|
||||
|
||||
void TestContourUniformGrid()
|
||||
{
|
||||
std::cout << "Testing Contour worklet on a uniform grid" << std::endl;
|
||||
|
||||
vtkm::Id3 dims(4, 4, 4);
|
||||
vtkm::source::Tangle tangle(dims);
|
||||
vtkm::filter::field_transform::GenerateIds genIds;
|
||||
genIds.SetUseFloat(true);
|
||||
genIds.SetGeneratePointIds(false);
|
||||
genIds.SetCellFieldName("cellvar");
|
||||
vtkm::cont::DataSet dataSet = genIds.Execute(tangle.Execute());
|
||||
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet().AsCellSet(cellSet);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> pointFieldArray;
|
||||
dataSet.GetField("tangle").GetData().AsArrayHandle(pointFieldArray);
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
|
||||
dataSet.GetField("cellvar").GetData().AsArrayHandle(cellFieldArray);
|
||||
|
||||
vtkm::worklet::Contour contour;
|
||||
contour.SetMergeDuplicatePoints(false);
|
||||
|
||||
std::vector<vtkm::Float32> contourValue{ 0.5f, 0.5f };
|
||||
const vtkm::Id numContours = static_cast<vtkm::Id>(contourValue.size());
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
|
||||
|
||||
auto result = contour.Run(contourValue,
|
||||
cellSet,
|
||||
dataSet.GetCoordinateSystem(),
|
||||
pointFieldArray,
|
||||
verticesArray,
|
||||
normalsArray);
|
||||
|
||||
scalarsArray = contour.ProcessPointField(pointFieldArray);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
|
||||
cellFieldArrayOut = contour.ProcessCellField(cellFieldArray);
|
||||
|
||||
std::cout << "vertices: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(verticesArray, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "normals: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(normalsArray, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "scalars: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(scalarsArray, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "cell field: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(cellFieldArrayOut, std::cout);
|
||||
std::cout << std::endl;
|
||||
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == cellFieldArrayOut.GetNumberOfValues());
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == (160 * numContours));
|
||||
|
||||
VTKM_TEST_ASSERT(verticesArray.GetNumberOfValues() == (72 * numContours));
|
||||
|
||||
|
||||
// The flying edge and marching cube algorithms differ in how the generate
|
||||
// multi-contour results. Marching Cubes interlaces output from all contours
|
||||
// together, while flying edges outputs all of contour 1 before any of contour 2.
|
||||
//
|
||||
// To make it possible to consistently compare the result we sort the cell-ids
|
||||
//
|
||||
vtkm::cont::Algorithm::Sort(cellFieldArrayOut);
|
||||
{
|
||||
std::vector<vtkm::Id> correctcellIdStart = { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4,
|
||||
4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 };
|
||||
std::vector<vtkm::Id> correctcellIdEnd = { 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 59, 59, 59,
|
||||
59, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 63, 63 };
|
||||
|
||||
auto id_portal = cellFieldArrayOut.ReadPortal();
|
||||
for (std::size_t i = 0; i < correctcellIdStart.size(); ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(id_portal.Get(vtkm::Id(i)) == correctcellIdStart[i]);
|
||||
}
|
||||
|
||||
vtkm::Id index = cellFieldArrayOut.GetNumberOfValues() - vtkm::Id(correctcellIdEnd.size());
|
||||
for (std::size_t i = 0; i < correctcellIdEnd.size(); ++i, ++index)
|
||||
{
|
||||
VTKM_TEST_ASSERT(id_portal.Get(index) == correctcellIdEnd[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that multiple contours of the same iso value are identical
|
||||
{
|
||||
auto normal_portal = normalsArray.ReadPortal();
|
||||
for (vtkm::Id i = 0; i < 72; ++i)
|
||||
{
|
||||
for (vtkm::Id j = 1; j < numContours; ++j)
|
||||
{
|
||||
vtkm::Id jIndex = i + (72 * j);
|
||||
VTKM_TEST_ASSERT(test_equal(normal_portal.Get(i), normal_portal.Get(jIndex)),
|
||||
"multi contour failed");
|
||||
}
|
||||
}
|
||||
|
||||
auto outCellPortal =
|
||||
result.GetConnectivityArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint())
|
||||
.ReadPortal();
|
||||
for (vtkm::Id i = 0; i < 480; ++i)
|
||||
{ //(3*160) as we are iterating triangle soup so the length is numOfCells*3
|
||||
for (vtkm::Id j = 1; j < numContours; ++j)
|
||||
{
|
||||
vtkm::Id jIndex = i + (480 * j);
|
||||
vtkm::Id expectedValue = (72 * j) + outCellPortal.Get(i);
|
||||
VTKM_TEST_ASSERT(test_equal(outCellPortal.Get(jIndex), expectedValue),
|
||||
"multi contour failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestContourExplicit()
|
||||
{
|
||||
std::cout << "Testing Contour worklet on explicit data" << std::endl;
|
||||
|
||||
using DataSetGenerator = vtkm_ut_mc_worklet::MakeRadiantDataSet;
|
||||
using Vec3Handle = vtkm::cont::ArrayHandle<vtkm::Vec3f_32>;
|
||||
using DataHandle = vtkm::cont::ArrayHandle<vtkm::Float32>;
|
||||
|
||||
DataSetGenerator dataSetGenerator;
|
||||
|
||||
vtkm::IdComponent Dimension = 10;
|
||||
std::vector<vtkm::Float32> contourValue{ 0.45f };
|
||||
|
||||
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
|
||||
|
||||
DataSetGenerator::CellSet cellSet;
|
||||
dataSet.GetCellSet().AsCellSet(cellSet);
|
||||
|
||||
vtkm::cont::Field contourField = dataSet.GetField("distanceToOrigin");
|
||||
DataSetGenerator::DataArrayHandle contourArray;
|
||||
contourField.GetData().AsArrayHandle(contourArray);
|
||||
Vec3Handle vertices;
|
||||
Vec3Handle normals;
|
||||
|
||||
vtkm::worklet::Contour Contour;
|
||||
Contour.SetMergeDuplicatePoints(false);
|
||||
|
||||
auto result = Contour.Run(
|
||||
contourValue, cellSet, dataSet.GetCoordinateSystem(), contourArray, vertices, normals);
|
||||
|
||||
DataHandle scalars;
|
||||
|
||||
vtkm::cont::Field projectedField = dataSet.GetField("distanceToOther");
|
||||
|
||||
DataSetGenerator::DataArrayHandle projectedArray;
|
||||
projectedField.GetData().AsArrayHandle(projectedArray);
|
||||
|
||||
scalars = Contour.ProcessPointField(projectedArray);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
|
||||
dataSet.GetField("cellvar").GetData().AsArrayHandle(cellFieldArray);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
|
||||
cellFieldArrayOut = Contour.ProcessCellField(cellFieldArray);
|
||||
|
||||
std::cout << "vertices: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(vertices, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "normals: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(normals, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "scalars: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(scalars, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "cell field: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(cellFieldArrayOut, std::cout);
|
||||
std::cout << std::endl;
|
||||
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == cellFieldArrayOut.GetNumberOfValues());
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == 824);
|
||||
VTKM_TEST_ASSERT(test_equal(vertices.GetNumberOfValues(), 2472));
|
||||
VTKM_TEST_ASSERT(test_equal(normals.GetNumberOfValues(), 2472));
|
||||
VTKM_TEST_ASSERT(test_equal(scalars.GetNumberOfValues(), 2472));
|
||||
}
|
||||
|
||||
void TestContourClipped()
|
||||
{
|
||||
std::cout << "Testing Contour worklet on a clipped uniform grid" << std::endl;
|
||||
|
||||
vtkm::Id3 dims(4, 4, 4);
|
||||
vtkm::source::Tangle tangle(dims);
|
||||
vtkm::filter::field_transform::GenerateIds genIds;
|
||||
genIds.SetUseFloat(true);
|
||||
genIds.SetGeneratePointIds(false);
|
||||
genIds.SetCellFieldName("cellvar");
|
||||
vtkm::cont::DataSet dataSet = genIds.Execute(tangle.Execute());
|
||||
|
||||
vtkm::Plane plane(vtkm::make_Vec(0.51, 0.51, 0.51), vtkm::make_Vec(1, 1, 1));
|
||||
vtkm::filter::ClipWithImplicitFunction clip;
|
||||
clip.SetImplicitFunction(plane);
|
||||
vtkm::cont::DataSet clipped = clip.Execute(dataSet);
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
clipped.GetCellSet().AsCellSet(cellSet);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> pointFieldArray;
|
||||
clipped.GetField("tangle").GetData().AsArrayHandle(pointFieldArray);
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
|
||||
clipped.GetField("cellvar").GetData().AsArrayHandle(cellFieldArray);
|
||||
|
||||
std::vector<vtkm::Float32> contourValue{ 0.5f };
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
|
||||
|
||||
vtkm::worklet::Contour isosurfaceFilter;
|
||||
isosurfaceFilter.SetMergeDuplicatePoints(false);
|
||||
|
||||
auto result = isosurfaceFilter.Run(contourValue,
|
||||
cellSet,
|
||||
clipped.GetCoordinateSystem(),
|
||||
pointFieldArray,
|
||||
verticesArray,
|
||||
normalsArray);
|
||||
|
||||
scalarsArray = isosurfaceFilter.ProcessPointField(pointFieldArray);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
|
||||
cellFieldArrayOut = isosurfaceFilter.ProcessCellField(cellFieldArray);
|
||||
|
||||
std::cout << "vertices: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(verticesArray, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "normals: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(normalsArray, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "scalars: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(scalarsArray, std::cout);
|
||||
std::cout << std::endl;
|
||||
std::cout << "cell field: ";
|
||||
vtkm::cont::printSummary_ArrayHandle(cellFieldArrayOut, std::cout);
|
||||
std::cout << std::endl;
|
||||
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == cellFieldArrayOut.GetNumberOfValues());
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == 170);
|
||||
VTKM_TEST_ASSERT(verticesArray.GetNumberOfValues() == 510);
|
||||
VTKM_TEST_ASSERT(normalsArray.GetNumberOfValues() == 510);
|
||||
VTKM_TEST_ASSERT(scalarsArray.GetNumberOfValues() == 510);
|
||||
}
|
||||
|
||||
void TestContour()
|
||||
{
|
||||
TestContourUniformGrid();
|
||||
TestContourExplicit();
|
||||
TestContourClipped();
|
||||
}
|
||||
|
||||
int UnitTestContour(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestContour, argc, argv);
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
//============================================================================
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <vtkm/worklet/connectivities/ImageConnectivity.h>
|
||||
|
@ -32,10 +32,10 @@
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/PolicyBase.h>
|
||||
#include <vtkm/filter/SurfaceNormals.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
|
||||
#include <vtkm/source/Wavelet.h>
|
||||
|
||||
@ -59,7 +59,7 @@ vtkm::cont::DataSet CreateDataSet(bool pointNormals, bool cellNormals)
|
||||
vtkm::filter::clean_grid::CleanGrid toGrid;
|
||||
|
||||
// unstructured grid contour
|
||||
vtkm::filter::Contour contour;
|
||||
vtkm::filter::contour::Contour contour;
|
||||
contour.SetActiveField("RTData", vtkm::cont::Field::Association::POINTS);
|
||||
contour.SetNumberOfIsoValues(1);
|
||||
contour.SetIsoValue(192);
|
||||
|
Loading…
Reference in New Issue
Block a user