mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Merge topic 'probe_refactor'
849106762 remove include CellDeepCopy 4108febd3 remove #include functional daaac78f1 minor changes based on code review aecdd7705 Update vtkm/filter/resampling/testing/CMakeLists.txt 38000ed6d Use ALL_BACKENDS for unit test ab09f77b7 migrate Probe filter Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <morelandkd@ornl.gov> Merge-request: !2771
This commit is contained in:
commit
2b102e2b7c
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <vtkm/filter/vector_analysis/Gradient.h>
|
#include <vtkm/filter/vector_analysis/Gradient.h>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include <vtkm/internal/Meta.h>
|
#include <vtkm/internal/Meta.h>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ set(deprecated_headers
|
|||||||
PointAverage.h
|
PointAverage.h
|
||||||
PointElevation.h
|
PointElevation.h
|
||||||
PointTransform.h
|
PointTransform.h
|
||||||
|
Probe.h
|
||||||
Slice.h
|
Slice.h
|
||||||
SplitSharpEdges.h
|
SplitSharpEdges.h
|
||||||
SurfaceNormals.h
|
SurfaceNormals.h
|
||||||
@ -106,7 +107,6 @@ set(extra_headers
|
|||||||
ParticleAdvection.h
|
ParticleAdvection.h
|
||||||
Pathline.h
|
Pathline.h
|
||||||
PathParticle.h
|
PathParticle.h
|
||||||
Probe.h
|
|
||||||
Streamline.h
|
Streamline.h
|
||||||
StreamSurface.h
|
StreamSurface.h
|
||||||
)
|
)
|
||||||
@ -122,7 +122,6 @@ set(extra_header_template_sources
|
|||||||
ParticleAdvection.hxx
|
ParticleAdvection.hxx
|
||||||
Pathline.hxx
|
Pathline.hxx
|
||||||
PathParticle.hxx
|
PathParticle.hxx
|
||||||
Probe.hxx
|
|
||||||
Streamline.hxx
|
Streamline.hxx
|
||||||
StreamSurface.hxx
|
StreamSurface.hxx
|
||||||
)
|
)
|
||||||
@ -200,6 +199,7 @@ add_subdirectory(field_conversion)
|
|||||||
add_subdirectory(field_transform)
|
add_subdirectory(field_transform)
|
||||||
add_subdirectory(geometry_refinement)
|
add_subdirectory(geometry_refinement)
|
||||||
add_subdirectory(mesh_info)
|
add_subdirectory(mesh_info)
|
||||||
|
add_subdirectory(resampling)
|
||||||
add_subdirectory(vector_analysis)
|
add_subdirectory(vector_analysis)
|
||||||
add_subdirectory(zfp)
|
add_subdirectory(zfp)
|
||||||
|
|
||||||
|
@ -420,9 +420,6 @@ protected:
|
|||||||
const vtkm::cont::PartitionedDataSet& inData);
|
const vtkm::cont::PartitionedDataSet& inData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VTKM_CONT
|
|
||||||
virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input);
|
|
||||||
|
|
||||||
template <typename FieldMapper>
|
template <typename FieldMapper>
|
||||||
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
|
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
|
||||||
vtkm::cont::DataSet& output,
|
vtkm::cont::DataSet& output,
|
||||||
@ -438,6 +435,10 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input);
|
||||||
|
|
||||||
|
|
||||||
vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All;
|
vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All;
|
||||||
bool RunFilterWithMultipleThreads = false;
|
bool RunFilterWithMultipleThreads = false;
|
||||||
};
|
};
|
||||||
|
@ -10,53 +10,23 @@
|
|||||||
#ifndef vtk_m_filter_Probe_h
|
#ifndef vtk_m_filter_Probe_h
|
||||||
#define vtk_m_filter_Probe_h
|
#define vtk_m_filter_Probe_h
|
||||||
|
|
||||||
#include <vtkm/filter/FilterDataSet.h>
|
#include <vtkm/Deprecated.h>
|
||||||
#include <vtkm/worklet/Probe.h>
|
#include <vtkm/filter/resampling //Probe.h>
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
class Probe : public vtkm::filter::FilterDataSet<Probe>
|
VTKM_DEPRECATED(1.8, "Use vtkm/filter/resampling/Probe.h instead of vtkm/filter/Probe.h.")
|
||||||
|
inline void Probe_deprecated() {}
|
||||||
|
|
||||||
|
inline void Probe_deprecated_warning()
|
||||||
{
|
{
|
||||||
public:
|
Probe_deprecated();
|
||||||
VTKM_CONT
|
|
||||||
void SetGeometry(const vtkm::cont::DataSet& geometry);
|
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
const vtkm::cont::DataSet& GetGeometry() const;
|
|
||||||
|
|
||||||
VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; }
|
|
||||||
VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; }
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
|
||||||
|
|
||||||
//Map a new field onto the resulting dataset after running the filter
|
|
||||||
//this call is only valid after calling DoExecute.
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::Field& field,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
vtkm::cont::DataSet Geometry;
|
|
||||||
vtkm::worklet::Probe Worklet;
|
|
||||||
vtkm::Float64 InvalidValue = vtkm::Nan64();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
} // vtkm::filter
|
|
||||||
|
|
||||||
#ifndef vtk_m_filter_Probe_hxx
|
}
|
||||||
#include <vtkm/filter/Probe.hxx>
|
} // namespace vtkm::filter
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_Probe_h
|
#endif //vtk_m_filter_Probe_h
|
||||||
|
@ -1,111 +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_Probe_hxx
|
|
||||||
#define vtk_m_filter_Probe_hxx
|
|
||||||
|
|
||||||
#include <vtkm/filter/Probe.h>
|
|
||||||
|
|
||||||
#include <vtkm/filter/MapFieldPermutation.h>
|
|
||||||
|
|
||||||
#include <vtkm/cont/internal/CastInvalidValue.h>
|
|
||||||
|
|
||||||
namespace vtkm
|
|
||||||
{
|
|
||||||
namespace filter
|
|
||||||
{
|
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry)
|
|
||||||
{
|
|
||||||
this->Geometry = vtkm::cont::DataSet();
|
|
||||||
this->Geometry.SetCellSet(geometry.GetCellSet());
|
|
||||||
this->Geometry.AddCoordinateSystem(geometry.GetCoordinateSystem());
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
inline const vtkm::cont::DataSet& Probe::GetGeometry() const
|
|
||||||
{
|
|
||||||
return this->Geometry;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
|
|
||||||
const vtkm::cont::DataSet& input,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
|
||||||
{
|
|
||||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this),
|
|
||||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
|
||||||
this->Geometry.GetCoordinateSystem().GetData());
|
|
||||||
|
|
||||||
auto output = this->Geometry;
|
|
||||||
auto hpf = this->Worklet.GetHiddenPointsField();
|
|
||||||
auto hcf = this->Worklet.GetHiddenCellsField(
|
|
||||||
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy, *this));
|
|
||||||
|
|
||||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
|
|
||||||
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
VTKM_CONT inline bool Probe::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->FilterDataSet<Probe>::MapFieldOntoOutput(result, field, policy);
|
|
||||||
}
|
|
||||||
else if (field.IsFieldCell())
|
|
||||||
{
|
|
||||||
vtkm::cont::Field outField;
|
|
||||||
if (vtkm::filter::MapFieldPermutation(
|
|
||||||
field, this->Worklet.GetCellIds(), outField, this->InvalidValue))
|
|
||||||
{
|
|
||||||
// output field should be associated with points
|
|
||||||
outField = vtkm::cont::Field(
|
|
||||||
field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData());
|
|
||||||
result.AddField(outField);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (field.IsFieldGlobal())
|
|
||||||
{
|
|
||||||
result.AddField(field);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
||||||
VTKM_CONT inline bool Probe::DoMapField(vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
|
||||||
{
|
|
||||||
VTKM_ASSERT(fieldMeta.IsPointField());
|
|
||||||
auto fieldArray =
|
|
||||||
this->Worklet.ProcessPointField(input,
|
|
||||||
vtkm::cont::internal::CastInvalidValue<T>(this->InvalidValue),
|
|
||||||
typename DerivedPolicy::AllCellSetList());
|
|
||||||
result.AddField(fieldMeta.AsField(fieldArray));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // vtkm::filter
|
|
||||||
#endif
|
|
32
vtkm/filter/resampling/CMakeLists.txt
Normal file
32
vtkm/filter/resampling/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
##============================================================================
|
||||||
|
## 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(resampling_headers
|
||||||
|
Probe.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(resampling_sources
|
||||||
|
Probe.cxx)
|
||||||
|
|
||||||
|
vtkm_library(
|
||||||
|
NAME vtkm_filter_resampling
|
||||||
|
HEADERS ${resampling_headers}
|
||||||
|
DEVICE_SOURCES ${resampling_sources}
|
||||||
|
USE_VTKM_JOB_POOL
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(vtkm_filter_resampling PUBLIC vtkm_worklet vtkm_filter_core)
|
||||||
|
target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_resampling)
|
||||||
|
|
||||||
|
add_subdirectory(worklet)
|
||||||
|
|
||||||
|
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
|
||||||
|
if (VTKm_ENABLE_TESTING)
|
||||||
|
add_subdirectory(testing)
|
||||||
|
endif ()
|
83
vtkm/filter/resampling/Probe.cxx
Normal file
83
vtkm/filter/resampling/Probe.cxx
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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/internal/CastInvalidValue.h>
|
||||||
|
|
||||||
|
#include <vtkm/filter/MapFieldPermutation.h>
|
||||||
|
#include <vtkm/filter/resampling/Probe.h>
|
||||||
|
#include <vtkm/filter/resampling/worklet/Probe.h>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
namespace resampling
|
||||||
|
{
|
||||||
|
vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input)
|
||||||
|
{
|
||||||
|
vtkm::worklet::Probe worklet;
|
||||||
|
worklet.Run(input.GetCellSet(),
|
||||||
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
||||||
|
this->Geometry.GetCoordinateSystem().GetData());
|
||||||
|
|
||||||
|
auto mapper = [&](auto& outDataSet, const auto& f) { this->DoMapField(outDataSet, f, worklet); };
|
||||||
|
auto output = this->CreateResult(
|
||||||
|
input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystems(), mapper);
|
||||||
|
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField()));
|
||||||
|
output.AddField(
|
||||||
|
vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet())));
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Probe::DoMapField(vtkm::cont::DataSet& result,
|
||||||
|
const vtkm::cont::Field& field,
|
||||||
|
const vtkm::worklet::Probe& worklet)
|
||||||
|
{
|
||||||
|
if (field.IsFieldPoint())
|
||||||
|
{
|
||||||
|
auto resolve = [&](const auto& concrete) {
|
||||||
|
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||||
|
vtkm::cont::ArrayHandle<T> outputArray = worklet.ProcessPointField(
|
||||||
|
concrete, vtkm::cont::internal::CastInvalidValue<T>(this->InvalidValue));
|
||||||
|
result.AddPointField(field.GetName(), outputArray);
|
||||||
|
};
|
||||||
|
field.GetData()
|
||||||
|
.CastAndCallForTypesWithFloatFallback<vtkm::TypeListField, VTKM_DEFAULT_STORAGE_LIST>(
|
||||||
|
resolve);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (field.IsFieldCell())
|
||||||
|
{
|
||||||
|
vtkm::cont::Field outField;
|
||||||
|
if (vtkm::filter::MapFieldPermutation(
|
||||||
|
field, worklet.GetCellIds(), outField, this->InvalidValue))
|
||||||
|
{
|
||||||
|
// output field should be associated with points
|
||||||
|
outField = vtkm::cont::Field(
|
||||||
|
field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData());
|
||||||
|
result.AddField(outField);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (field.IsFieldGlobal())
|
||||||
|
{
|
||||||
|
result.AddField(field);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace resampling
|
||||||
|
} // namespace filter
|
||||||
|
} // namespace vtkm
|
65
vtkm/filter/resampling/Probe.h
Normal file
65
vtkm/filter/resampling/Probe.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_Probe_h
|
||||||
|
#define vtk_m_filter_Probe_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/NewFilterField.h>
|
||||||
|
#include <vtkm/filter/resampling/vtkm_filter_resampling_export.h>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace worklet
|
||||||
|
{
|
||||||
|
class Probe;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
namespace resampling
|
||||||
|
{
|
||||||
|
class VTKM_FILTER_RESAMPLING_EXPORT Probe : public vtkm::filter::NewFilterField
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VTKM_CONT
|
||||||
|
void SetGeometry(const vtkm::cont::DataSet& geometry)
|
||||||
|
{
|
||||||
|
this->Geometry = vtkm::cont::DataSet();
|
||||||
|
this->Geometry.CopyStructure(geometry);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
const vtkm::cont::DataSet& GetGeometry() const { return this->Geometry; }
|
||||||
|
|
||||||
|
VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; }
|
||||||
|
VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||||
|
|
||||||
|
bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
|
const vtkm::cont::Field& field,
|
||||||
|
const vtkm::worklet::Probe& worklet);
|
||||||
|
|
||||||
|
vtkm::cont::DataSet Geometry;
|
||||||
|
|
||||||
|
vtkm::Float64 InvalidValue = vtkm::Nan64();
|
||||||
|
};
|
||||||
|
} // namespace resampling
|
||||||
|
|
||||||
|
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::resampling::Probe.") Probe
|
||||||
|
: public vtkm::filter::resampling::Probe
|
||||||
|
{
|
||||||
|
using resampling::Probe::Probe;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace filter
|
||||||
|
} // namespace vtkm
|
||||||
|
|
||||||
|
#endif // vtk_m_filter_Probe_h
|
24
vtkm/filter/resampling/testing/CMakeLists.txt
Normal file
24
vtkm/filter/resampling/testing/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
##============================================================================
|
||||||
|
## 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
|
||||||
|
UnitTestProbe.cxx
|
||||||
|
)
|
||||||
|
|
||||||
|
set(libraries
|
||||||
|
vtkm_filter_clean_grid
|
||||||
|
vtkm_filter_resampling
|
||||||
|
)
|
||||||
|
|
||||||
|
vtkm_unit_tests(
|
||||||
|
SOURCES ${unit_tests}
|
||||||
|
LIBRARIES ${libraries}
|
||||||
|
USE_VTKM_JOB_POOL
|
||||||
|
)
|
@ -7,13 +7,12 @@
|
|||||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
// PURPOSE. See the above copyright notice for more information.
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <vtkm/filter/Probe.h>
|
|
||||||
|
|
||||||
#include <vtkm/cont/ArrayCopy.h>
|
#include <vtkm/cont/ArrayCopy.h>
|
||||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||||
#include <vtkm/cont/testing/Testing.h>
|
#include <vtkm/cont/testing/Testing.h>
|
||||||
|
|
||||||
#include <vtkm/worklet/CellDeepCopy.h>
|
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||||
|
#include <vtkm/filter/resampling/Probe.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -46,22 +45,9 @@ vtkm::cont::DataSet MakeGeometryDataSet()
|
|||||||
|
|
||||||
vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds)
|
vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds)
|
||||||
{
|
{
|
||||||
vtkm::cont::DataSet eds;
|
vtkm::filter::clean_grid::CleanGrid toUnstructured;
|
||||||
vtkm::cont::CellSetExplicit<> cs;
|
toUnstructured.SetMergePoints(true);
|
||||||
vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs);
|
return toUnstructured.Execute(uds);
|
||||||
eds.SetCellSet(cs);
|
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> points;
|
|
||||||
vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points);
|
|
||||||
eds.AddCoordinateSystem(
|
|
||||||
vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points));
|
|
||||||
|
|
||||||
for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i)
|
|
||||||
{
|
|
||||||
eds.AddField(uds.GetField(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return eds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<vtkm::Float32>& GetExpectedPointData()
|
const std::vector<vtkm::Float32>& GetExpectedPointData()
|
||||||
@ -153,7 +139,7 @@ private:
|
|||||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||||
auto geometry = MakeGeometryDataSet();
|
auto geometry = MakeGeometryDataSet();
|
||||||
|
|
||||||
vtkm::filter::Probe probe;
|
vtkm::filter::resampling::Probe probe;
|
||||||
probe.SetGeometry(geometry);
|
probe.SetGeometry(geometry);
|
||||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||||
auto output = probe.Execute(input);
|
auto output = probe.Execute(input);
|
||||||
@ -175,7 +161,7 @@ private:
|
|||||||
auto input = MakeInputDataSet();
|
auto input = MakeInputDataSet();
|
||||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||||
|
|
||||||
vtkm::filter::Probe probe;
|
vtkm::filter::resampling::Probe probe;
|
||||||
probe.SetGeometry(geometry);
|
probe.SetGeometry(geometry);
|
||||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||||
auto output = probe.Execute(input);
|
auto output = probe.Execute(input);
|
||||||
@ -197,7 +183,7 @@ private:
|
|||||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||||
|
|
||||||
vtkm::filter::Probe probe;
|
vtkm::filter::resampling::Probe probe;
|
||||||
probe.SetGeometry(geometry);
|
probe.SetGeometry(geometry);
|
||||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||||
auto output = probe.Execute(input);
|
auto output = probe.Execute(input);
|
15
vtkm/filter/resampling/worklet/CMakeLists.txt
Normal file
15
vtkm/filter/resampling/worklet/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
##============================================================================
|
||||||
|
## 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(headers
|
||||||
|
Probe.h
|
||||||
|
)
|
||||||
|
|
||||||
|
vtkm_declare_headers(${headers})
|
@ -25,7 +25,6 @@ set(unit_tests
|
|||||||
UnitTestMIRFilter.cxx
|
UnitTestMIRFilter.cxx
|
||||||
UnitTestMultiBlockFilter.cxx
|
UnitTestMultiBlockFilter.cxx
|
||||||
UnitTestPartitionedDataSetFilters.cxx
|
UnitTestPartitionedDataSetFilters.cxx
|
||||||
UnitTestProbe.cxx
|
|
||||||
UnitTestStreamlineFilter.cxx
|
UnitTestStreamlineFilter.cxx
|
||||||
UnitTestStreamSurfaceFilter.cxx
|
UnitTestStreamSurfaceFilter.cxx
|
||||||
)
|
)
|
||||||
|
@ -33,7 +33,6 @@ set(headers
|
|||||||
NDimsHistMarginalization.h
|
NDimsHistMarginalization.h
|
||||||
Normalize.h
|
Normalize.h
|
||||||
ParticleAdvection.h
|
ParticleAdvection.h
|
||||||
Probe.h
|
|
||||||
ScalarsToColors.h
|
ScalarsToColors.h
|
||||||
ScatterCounting.h
|
ScatterCounting.h
|
||||||
ScatterIdentity.h
|
ScatterIdentity.h
|
||||||
|
@ -29,7 +29,6 @@ set(unit_tests
|
|||||||
UnitTestNormalize.cxx
|
UnitTestNormalize.cxx
|
||||||
UnitTestNDimsHistMarginalization.cxx
|
UnitTestNDimsHistMarginalization.cxx
|
||||||
UnitTestParticleAdvection.cxx
|
UnitTestParticleAdvection.cxx
|
||||||
UnitTestProbe.cxx
|
|
||||||
UnitTestScalarsToColors.cxx
|
UnitTestScalarsToColors.cxx
|
||||||
UnitTestScatterAndMask.cxx
|
UnitTestScatterAndMask.cxx
|
||||||
UnitTestScatterCounting.cxx
|
UnitTestScatterCounting.cxx
|
||||||
|
@ -1,211 +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/worklet/Probe.h>
|
|
||||||
|
|
||||||
#include <vtkm/cont/ArrayCopy.h>
|
|
||||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
|
||||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
|
||||||
#include <vtkm/cont/testing/Testing.h>
|
|
||||||
|
|
||||||
#include <vtkm/worklet/CellDeepCopy.h>
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
vtkm::cont::DataSet MakeInputDataSet()
|
|
||||||
{
|
|
||||||
auto input = vtkm::cont::DataSetBuilderUniform::Create(
|
|
||||||
vtkm::Id2(4, 4), vtkm::make_Vec(0.0f, 0.0f), vtkm::make_Vec(1.0f, 1.0f));
|
|
||||||
input.AddPointField("pointdata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.3f, 16));
|
|
||||||
input.AddCellField("celldata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.7f, 9));
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
vtkm::cont::DataSet MakeGeometryDataSet()
|
|
||||||
{
|
|
||||||
auto geometry = vtkm::cont::DataSetBuilderUniform::Create(
|
|
||||||
vtkm::Id2(9, 9), vtkm::make_Vec(0.7f, 0.7f), vtkm::make_Vec(0.35f, 0.35f));
|
|
||||||
return geometry;
|
|
||||||
}
|
|
||||||
|
|
||||||
vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds)
|
|
||||||
{
|
|
||||||
vtkm::cont::DataSet eds;
|
|
||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> cs;
|
|
||||||
vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs);
|
|
||||||
eds.SetCellSet(cs);
|
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> points;
|
|
||||||
vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points);
|
|
||||||
eds.AddCoordinateSystem(
|
|
||||||
vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points));
|
|
||||||
|
|
||||||
for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i)
|
|
||||||
{
|
|
||||||
eds.AddField(uds.GetField(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return eds;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<vtkm::Float32>& GetExpectedPointData()
|
|
||||||
{
|
|
||||||
static std::vector<vtkm::Float32> expected = {
|
|
||||||
1.05f, 1.155f, 1.26f, 1.365f, 1.47f, 1.575f, 1.68f, 0.0f, 0.0f, 1.47f, 1.575f, 1.68f,
|
|
||||||
1.785f, 1.89f, 1.995f, 2.1f, 0.0f, 0.0f, 1.89f, 1.995f, 2.1f, 2.205f, 2.31f, 2.415f,
|
|
||||||
2.52f, 0.0f, 0.0f, 2.31f, 2.415f, 2.52f, 2.625f, 2.73f, 2.835f, 2.94f, 0.0f, 0.0f,
|
|
||||||
2.73f, 2.835f, 2.94f, 3.045f, 3.15f, 3.255f, 3.36f, 0.0f, 0.0f, 3.15f, 3.255f, 3.36f,
|
|
||||||
3.465f, 3.57f, 3.675f, 3.78f, 0.0f, 0.0f, 3.57f, 3.675f, 3.78f, 3.885f, 3.99f, 4.095f,
|
|
||||||
4.2f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
|
||||||
};
|
|
||||||
return expected;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<vtkm::Float32>& GetExpectedCellData()
|
|
||||||
{
|
|
||||||
static std::vector<vtkm::Float32> expected = {
|
|
||||||
0.0f, 0.7f, 0.7f, 0.7f, 1.4f, 1.4f, 1.4f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f,
|
|
||||||
3.5f, 3.5f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 2.1f,
|
|
||||||
2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f,
|
|
||||||
5.6f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 4.2f, 4.9f,
|
|
||||||
4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
|
||||||
};
|
|
||||||
return expected;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<vtkm::UInt8>& GetExpectedHiddenPoints()
|
|
||||||
{
|
|
||||||
static std::vector<vtkm::UInt8> expected = { 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2,
|
|
||||||
2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
|
|
||||||
return expected;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<vtkm::UInt8>& GetExpectedHiddenCells()
|
|
||||||
{
|
|
||||||
static std::vector<vtkm::UInt8> expected = { 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
|
||||||
0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
|
||||||
0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
|
|
||||||
return expected;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void TestResultArray(const vtkm::cont::ArrayHandle<T>& result, const std::vector<T>& expected)
|
|
||||||
{
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(result, std::cout);
|
|
||||||
VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
|
|
||||||
"Incorrect field size");
|
|
||||||
|
|
||||||
auto portal = result.ReadPortal();
|
|
||||||
vtkm::Id size = portal.GetNumberOfValues();
|
|
||||||
for (vtkm::Id i = 0; i < size; ++i)
|
|
||||||
{
|
|
||||||
VTKM_TEST_ASSERT(test_equal(portal.Get(i), expected[static_cast<std::size_t>(i)]),
|
|
||||||
"Incorrect field value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestProbe
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
using FieldArrayType = vtkm::cont::ArrayHandleCounting<vtkm::Float32>;
|
|
||||||
|
|
||||||
static void ExplicitToUnifrom()
|
|
||||||
{
|
|
||||||
std::cout << "Testing Probe Explicit to Uniform:\n";
|
|
||||||
|
|
||||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
|
||||||
auto geometry = MakeGeometryDataSet();
|
|
||||||
|
|
||||||
vtkm::worklet::Probe probe;
|
|
||||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
|
||||||
|
|
||||||
auto pf = probe.ProcessPointField(
|
|
||||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
|
||||||
auto cf = probe.ProcessCellField(
|
|
||||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
|
||||||
auto hp = probe.GetHiddenPointsField();
|
|
||||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
|
||||||
|
|
||||||
TestResultArray(pf, GetExpectedPointData());
|
|
||||||
TestResultArray(cf, GetExpectedCellData());
|
|
||||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
|
||||||
TestResultArray(hc, GetExpectedHiddenCells());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UniformToExplict()
|
|
||||||
{
|
|
||||||
std::cout << "Testing Probe Uniform to Explicit:\n";
|
|
||||||
|
|
||||||
auto input = MakeInputDataSet();
|
|
||||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
|
||||||
|
|
||||||
vtkm::worklet::Probe probe;
|
|
||||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
|
||||||
|
|
||||||
auto pf = probe.ProcessPointField(
|
|
||||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
|
||||||
auto cf = probe.ProcessCellField(
|
|
||||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
|
||||||
|
|
||||||
auto hp = probe.GetHiddenPointsField();
|
|
||||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
|
||||||
|
|
||||||
TestResultArray(pf, GetExpectedPointData());
|
|
||||||
TestResultArray(cf, GetExpectedCellData());
|
|
||||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
|
||||||
TestResultArray(hc, GetExpectedHiddenCells());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ExplicitToExplict()
|
|
||||||
{
|
|
||||||
std::cout << "Testing Probe Explicit to Explicit:\n";
|
|
||||||
|
|
||||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
|
||||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
|
||||||
|
|
||||||
vtkm::worklet::Probe probe;
|
|
||||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
|
||||||
|
|
||||||
auto pf = probe.ProcessPointField(
|
|
||||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
|
||||||
auto cf = probe.ProcessCellField(
|
|
||||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
|
||||||
|
|
||||||
auto hp = probe.GetHiddenPointsField();
|
|
||||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
|
||||||
|
|
||||||
TestResultArray(pf, GetExpectedPointData());
|
|
||||||
TestResultArray(cf, GetExpectedCellData());
|
|
||||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
|
||||||
TestResultArray(hc, GetExpectedHiddenCells());
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
static void Run()
|
|
||||||
{
|
|
||||||
ExplicitToUnifrom();
|
|
||||||
UniformToExplict();
|
|
||||||
ExplicitToExplict();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
int UnitTestProbe(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
return vtkm::cont::testing::Testing::Run(TestProbe::Run, argc, argv);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user