Commit 2b102e2b authored by Li-Ta Lo's avatar Li-Ta Lo Committed by Kitware Robot
Browse files

Merge topic 'probe_refactor'

84910676 remove include CellDeepCopy
4108febd remove #include functional
daaac78f minor changes based on code review
aecdd770 Update vtkm/filter/resampling/testing/CMakeLists.txt
38000ed6 Use ALL_BACKENDS for unit test
ab09f77b

 migrate Probe filter
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland's avatarKenneth Moreland <morelandkd@ornl.gov>
Merge-request: !2771
parents a046ac0f 84910676
......@@ -17,7 +17,6 @@
#include <vtkm/filter/vector_analysis/Gradient.h>
namespace
{
......
......@@ -14,6 +14,8 @@
#include <vtkm/internal/Meta.h>
#include <functional>
namespace vtkm
{
......
......@@ -45,6 +45,7 @@ set(deprecated_headers
PointAverage.h
PointElevation.h
PointTransform.h
Probe.h
Slice.h
SplitSharpEdges.h
SurfaceNormals.h
......@@ -106,7 +107,6 @@ set(extra_headers
ParticleAdvection.h
Pathline.h
PathParticle.h
Probe.h
Streamline.h
StreamSurface.h
)
......@@ -122,7 +122,6 @@ set(extra_header_template_sources
ParticleAdvection.hxx
Pathline.hxx
PathParticle.hxx
Probe.hxx
Streamline.hxx
StreamSurface.hxx
)
......@@ -200,6 +199,7 @@ add_subdirectory(field_conversion)
add_subdirectory(field_transform)
add_subdirectory(geometry_refinement)
add_subdirectory(mesh_info)
add_subdirectory(resampling)
add_subdirectory(vector_analysis)
add_subdirectory(zfp)
......
......@@ -420,9 +420,6 @@ protected:
const vtkm::cont::PartitionedDataSet& inData);
private:
VTKM_CONT
virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input);
template <typename FieldMapper>
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
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;
bool RunFilterWithMultipleThreads = false;
};
......
......@@ -10,53 +10,23 @@
#ifndef vtk_m_filter_Probe_h
#define vtk_m_filter_Probe_h
#include <vtkm/filter/FilterDataSet.h>
#include <vtkm/worklet/Probe.h>
#include <vtkm/Deprecated.h>
#include <vtkm/filter/resampling //Probe.h>
namespace vtkm
{
namespace filter
{
class Probe : public vtkm::filter::FilterDataSet<Probe>
{
public:
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);
VTKM_DEPRECATED(1.8, "Use vtkm/filter/resampling/Probe.h instead of vtkm/filter/Probe.h.")
inline void Probe_deprecated() {}
//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();
};
inline void Probe_deprecated_warning()
{
Probe_deprecated();
}
} // vtkm::filter
#ifndef vtk_m_filter_Probe_hxx
#include <vtkm/filter/Probe.hxx>
#endif
}
} // namespace vtkm::filter
#endif // vtk_m_filter_Probe_h
#endif //vtk_m_filter_Probe_h
##============================================================================
## 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 ()
......@@ -7,71 +7,58 @@
// 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/cont/internal/CastInvalidValue.h>
#include <vtkm/filter/MapFieldPermutation.h>
#include <vtkm/cont/internal/CastInvalidValue.h>
#include <vtkm/filter/resampling/Probe.h>
#include <vtkm/filter/resampling/worklet/Probe.h>
namespace vtkm
{
namespace filter
{
VTKM_CONT
inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry)
namespace resampling
{
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
vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input)
{
return this->Geometry;
}
vtkm::worklet::Probe worklet;
worklet.Run(input.GetCellSet(),
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
this->Geometry.GetCoordinateSystem().GetData());
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));
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;
}
template <typename DerivedPolicy>
VTKM_CONT inline bool Probe::MapFieldOntoOutput(vtkm::cont::DataSet& result,
const vtkm::cont::Field& field,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
bool Probe::DoMapField(vtkm::cont::DataSet& result,
const vtkm::cont::Field& field,
const vtkm::worklet::Probe& worklet)
{
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);
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, this->Worklet.GetCellIds(), outField, this->InvalidValue))
field, worklet.GetCellIds(), outField, this->InvalidValue))
{
// output field should be associated with points
outField = vtkm::cont::Field(
......@@ -91,21 +78,6 @@ VTKM_CONT inline bool Probe::MapFieldOntoOutput(vtkm::cont::DataSet& result,
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
} // namespace resampling
} // namespace filter
} // namespace vtkm
//============================================================================
// 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
##============================================================================
## 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
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/filter/Probe.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/DataSetBuilderUniform.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
{
......@@ -46,22 +45,9 @@ vtkm::cont::DataSet MakeGeometryDataSet()
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;
vtkm::filter::clean_grid::CleanGrid toUnstructured;
toUnstructured.SetMergePoints(true);
return toUnstructured.Execute(uds);
}
const std::vector<vtkm::Float32>& GetExpectedPointData()
......@@ -153,7 +139,7 @@ private:
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
auto geometry = MakeGeometryDataSet();
vtkm::filter::Probe probe;
vtkm::filter::resampling::Probe probe;
probe.SetGeometry(geometry);
probe.SetFieldsToPass({ "pointdata", "celldata" });
auto output = probe.Execute(input);
......@@ -175,7 +161,7 @@ private:
auto input = MakeInputDataSet();
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
vtkm::filter::Probe probe;
vtkm::filter::resampling::Probe probe;
probe.SetGeometry(geometry);
probe.SetFieldsToPass({ "pointdata", "celldata" });
auto output = probe.Execute(input);
......@@ -197,7 +183,7 @@ private:
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
vtkm::filter::Probe probe;
vtkm::filter::resampling::Probe probe;
probe.SetGeometry(geometry);
probe.SetFieldsToPass({ "pointdata", "celldata" });
auto output = probe.Execute(input);
......
##============================================================================
## 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
UnitTestMultiBlockFilter.cxx
UnitTestPartitionedDataSetFilters.cxx
UnitTestProbe.cxx
UnitTestStreamlineFilter.cxx
UnitTestStreamSurfaceFilter.cxx
)
......
......@@ -33,7 +33,6 @@ set(headers
NDimsHistMarginalization.h
Normalize.h
ParticleAdvection.h
Probe.h
ScalarsToColors.h
ScatterCounting.h
ScatterIdentity.h
......
......@@ -29,7 +29,6 @@ set(unit_tests
UnitTestNormalize.cxx
UnitTestNDimsHistMarginalization.cxx
UnitTestParticleAdvection.cxx
UnitTestProbe.cxx
UnitTestScalarsToColors.cxx
UnitTestScatterAndMask.cxx
UnitTestScatterCounting.cxx
......
//============================================================================
// 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