mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-18 18:15:44 +00:00
Merge topic 'build_filter_lib'
8520d70e0 Compile most frequently used VTK-m filters into a library d1d61b9eb vtkm::filter::Filter passes filter policies by value 4ff021b08 Improve VTK-m compilation times by compiling more keys<T> types Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1836
This commit is contained in:
commit
4faf1bf0b8
@ -142,7 +142,6 @@ using UnstructuredCellList =
|
|||||||
|
|
||||||
using AllCellList = vtkm::ListTagJoin<StructuredCellList, UnstructuredCellList>;
|
using AllCellList = vtkm::ListTagJoin<StructuredCellList, UnstructuredCellList>;
|
||||||
|
|
||||||
using CoordinateList = vtkm::ListTagBase<vtkm::Vec3f_32, vtkm::Vec3f_64>;
|
|
||||||
|
|
||||||
class BenchmarkFilterPolicy : public vtkm::filter::PolicyBase<BenchmarkFilterPolicy>
|
class BenchmarkFilterPolicy : public vtkm::filter::PolicyBase<BenchmarkFilterPolicy>
|
||||||
{
|
{
|
||||||
@ -152,8 +151,6 @@ public:
|
|||||||
using StructuredCellSetList = StructuredCellList;
|
using StructuredCellSetList = StructuredCellList;
|
||||||
using UnstructuredCellSetList = UnstructuredCellList;
|
using UnstructuredCellSetList = UnstructuredCellList;
|
||||||
using AllCellSetList = AllCellList;
|
using AllCellSetList = AllCellList;
|
||||||
|
|
||||||
using CoordinateTypeList = CoordinateList;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Class implementing all filter benchmarks:
|
// Class implementing all filter benchmarks:
|
||||||
@ -307,7 +304,7 @@ class BenchmarkFilters
|
|||||||
{
|
{
|
||||||
Timer timer{ DeviceAdapter() };
|
Timer timer{ DeviceAdapter() };
|
||||||
timer.Start();
|
timer.Start();
|
||||||
auto result = this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto result = this->Filter.Execute(InputDataSet);
|
||||||
(void)result;
|
(void)result;
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
@ -374,7 +371,7 @@ class BenchmarkFilters
|
|||||||
{
|
{
|
||||||
Timer timer{ DeviceAdapter() };
|
Timer timer{ DeviceAdapter() };
|
||||||
timer.Start();
|
timer.Start();
|
||||||
auto result = this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto result = this->Filter.Execute(InputDataSet);
|
||||||
(void)result;
|
(void)result;
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
@ -400,7 +397,7 @@ class BenchmarkFilters
|
|||||||
{
|
{
|
||||||
Timer timer{ DeviceAdapter() };
|
Timer timer{ DeviceAdapter() };
|
||||||
timer.Start();
|
timer.Start();
|
||||||
auto result = this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto result = this->Filter.Execute(InputDataSet);
|
||||||
(void)result;
|
(void)result;
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
@ -501,7 +498,7 @@ class BenchmarkFilters
|
|||||||
{
|
{
|
||||||
Timer timer{ DeviceAdapter() };
|
Timer timer{ DeviceAdapter() };
|
||||||
timer.Start();
|
timer.Start();
|
||||||
auto result = this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto result = this->Filter.Execute(InputDataSet);
|
||||||
(void)result;
|
(void)result;
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
@ -547,7 +544,7 @@ class BenchmarkFilters
|
|||||||
{
|
{
|
||||||
Timer timer{ DeviceAdapter() };
|
Timer timer{ DeviceAdapter() };
|
||||||
timer.Start();
|
timer.Start();
|
||||||
auto result = this->Filter.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto result = this->Filter.Execute(InputDataSet);
|
||||||
(void)result;
|
(void)result;
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
@ -954,7 +951,7 @@ void CreateFields(bool needPointScalars, bool needCellScalars, bool needPointVec
|
|||||||
vtkm::filter::PointAverage avg;
|
vtkm::filter::PointAverage avg;
|
||||||
avg.SetActiveField(CellScalarsName, vtkm::cont::Field::Association::CELL_SET);
|
avg.SetActiveField(CellScalarsName, vtkm::cont::Field::Association::CELL_SET);
|
||||||
avg.SetOutputFieldName("GeneratedPointScalars");
|
avg.SetOutputFieldName("GeneratedPointScalars");
|
||||||
auto outds = avg.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto outds = avg.Execute(InputDataSet);
|
||||||
InputDataSet.AddField(
|
InputDataSet.AddField(
|
||||||
outds.GetField("GeneratedPointScalars", vtkm::cont::Field::Association::POINTS));
|
outds.GetField("GeneratedPointScalars", vtkm::cont::Field::Association::POINTS));
|
||||||
PointScalarsName = "GeneratedPointScalars";
|
PointScalarsName = "GeneratedPointScalars";
|
||||||
@ -977,7 +974,7 @@ void CreateFields(bool needPointScalars, bool needCellScalars, bool needPointVec
|
|||||||
vtkm::filter::VectorMagnitude mag;
|
vtkm::filter::VectorMagnitude mag;
|
||||||
mag.SetActiveField(PointVectorsName, vtkm::cont::Field::Association::POINTS);
|
mag.SetActiveField(PointVectorsName, vtkm::cont::Field::Association::POINTS);
|
||||||
mag.SetOutputFieldName("GeneratedPointScalars");
|
mag.SetOutputFieldName("GeneratedPointScalars");
|
||||||
auto outds = mag.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto outds = mag.Execute(InputDataSet);
|
||||||
InputDataSet.AddField(
|
InputDataSet.AddField(
|
||||||
outds.GetField("GeneratedPointScalars", vtkm::cont::Field::Association::POINTS));
|
outds.GetField("GeneratedPointScalars", vtkm::cont::Field::Association::POINTS));
|
||||||
PointScalarsName = "GeneratedPointScalars";
|
PointScalarsName = "GeneratedPointScalars";
|
||||||
@ -999,7 +996,7 @@ void CreateFields(bool needPointScalars, bool needCellScalars, bool needPointVec
|
|||||||
vtkm::filter::CellAverage avg;
|
vtkm::filter::CellAverage avg;
|
||||||
avg.SetActiveField(PointScalarsName, vtkm::cont::Field::Association::POINTS);
|
avg.SetActiveField(PointScalarsName, vtkm::cont::Field::Association::POINTS);
|
||||||
avg.SetOutputFieldName("GeneratedCellScalars");
|
avg.SetOutputFieldName("GeneratedCellScalars");
|
||||||
auto outds = avg.Execute(InputDataSet, BenchmarkFilterPolicy());
|
auto outds = avg.Execute(InputDataSet);
|
||||||
InputDataSet.AddField(
|
InputDataSet.AddField(
|
||||||
outds.GetField("GeneratedCellScalars", vtkm::cont::Field::Association::CELL_SET));
|
outds.GetField("GeneratedCellScalars", vtkm::cont::Field::Association::CELL_SET));
|
||||||
CellScalarsName = "GeneratedCellScalars";
|
CellScalarsName = "GeneratedCellScalars";
|
||||||
|
73
docs/changelog/provide-prebuilt-filters.md
Normal file
73
docs/changelog/provide-prebuilt-filters.md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# Provide pre-built filters in the vtkm_filter library.
|
||||||
|
|
||||||
|
VTK-m now provides the following pre built versions of
|
||||||
|
the following filters as part of the vtkm_filter library,
|
||||||
|
when executed with the default types.
|
||||||
|
- CellAverage
|
||||||
|
- CleanGrid
|
||||||
|
- ClipWithField
|
||||||
|
- ClipWithImplicitFunction
|
||||||
|
- Contour
|
||||||
|
- ExternalFaces
|
||||||
|
- ExtractStuctured
|
||||||
|
- PointAverage
|
||||||
|
- Threshold
|
||||||
|
- VectorMagnitude
|
||||||
|
|
||||||
|
The decision on providing a subset of filters as a library
|
||||||
|
was based on balancing the resulting library size and cross domain
|
||||||
|
applicibaility of the filter. So the initial set of algorithms
|
||||||
|
have been selected by looking at what is commonly used by
|
||||||
|
current VTK-m consuming applications.
|
||||||
|
|
||||||
|
By default types we mean that no explicit user policy has been
|
||||||
|
passed to the `Execute` method on these filters. For example
|
||||||
|
the following will use the pre-build `Threshold` and `CleanGrid`
|
||||||
|
filters:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
vtkm::cont::DataSet input = ...;
|
||||||
|
|
||||||
|
//convert input to an unstructured grid
|
||||||
|
vtkm::filter::CleanGrid clean;
|
||||||
|
auto cleaned = clean.Execute(input);
|
||||||
|
|
||||||
|
vtkm::filter::Threshold threshold;
|
||||||
|
threshold.SetLowerThreshold(60.1);
|
||||||
|
threshold.SetUpperThreshold(60.1);
|
||||||
|
threshold.SetActiveField("pointvar");
|
||||||
|
threshold.SetFieldsToPass("cellvar");
|
||||||
|
auto output = threshold.Execute(cleaned);
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
While the following, even though it is a subset of the default
|
||||||
|
policy will need to be compiled by the consuming library by
|
||||||
|
including the relevant `.hxx` files
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <vtkm/filter/CleanGrid.hxx>
|
||||||
|
#include <vtkm/filter/Threshold.hxx>
|
||||||
|
|
||||||
|
...
|
||||||
|
struct CustomPolicy : vtkm::filter::PolicyBase<CustomPolicy>
|
||||||
|
{
|
||||||
|
// Defaults are the same as PolicyDefault expect for the field types
|
||||||
|
using FieldTypeList = vtkm::ListTagBase<vtkm::FloatDefault, vtkm::Vec3f>;
|
||||||
|
};
|
||||||
|
...
|
||||||
|
|
||||||
|
vtkm::cont::DataSet input = ...;
|
||||||
|
|
||||||
|
//convert input to an unstructured grid
|
||||||
|
vtkm::filter::CleanGrid clean;
|
||||||
|
auto cleaned = clean.Execute(input, CustomPolicy{});
|
||||||
|
|
||||||
|
vtkm::filter::Threshold threshold;
|
||||||
|
threshold.SetLowerThreshold(60.1);
|
||||||
|
threshold.SetUpperThreshold(60.1);
|
||||||
|
threshold.SetActiveField("pointvar");
|
||||||
|
threshold.SetFieldsToPass("cellvar");
|
||||||
|
auto output = threshold.Execute(cleaned, CustomPolicy{});
|
||||||
|
...
|
||||||
|
```
|
@ -15,7 +15,7 @@ find_package(VTKm REQUIRED QUIET)
|
|||||||
|
|
||||||
if(TARGET vtkm_rendering)
|
if(TARGET vtkm_rendering)
|
||||||
add_executable(Demo Demo.cxx)
|
add_executable(Demo Demo.cxx)
|
||||||
target_link_libraries(Demo PRIVATE vtkm_rendering)
|
target_link_libraries(Demo PRIVATE vtkm_filter vtkm_rendering)
|
||||||
vtkm_add_target_information(Demo
|
vtkm_add_target_information(Demo
|
||||||
DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS
|
DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS
|
||||||
DEVICE_SOURCES Demo.cxx)
|
DEVICE_SOURCES Demo.cxx)
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
|
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
|
||||||
#include <vtkm/cont/CellSetExtrude.h>
|
#include <vtkm/cont/CellSetExtrude.h>
|
||||||
#include <vtkm/cont/testing/Testing.h>
|
#include <vtkm/cont/testing/Testing.h>
|
||||||
#include <vtkm/filter/CellAverage.h>
|
|
||||||
#include <vtkm/filter/PointAverage.h>
|
#include <vtkm/filter/PointAverage.h>
|
||||||
|
#include <vtkm/filter/PointAverage.hxx>
|
||||||
#include <vtkm/filter/PolicyExtrude.h>
|
#include <vtkm/filter/PolicyExtrude.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -139,16 +139,26 @@ set(header_template_sources
|
|||||||
ZFPCompressor3D.hxx
|
ZFPCompressor3D.hxx
|
||||||
ZFPDecompressor3D.hxx
|
ZFPDecompressor3D.hxx
|
||||||
)
|
)
|
||||||
|
set(sources_device
|
||||||
|
CellAverage.cxx
|
||||||
|
CleanGrid.cxx
|
||||||
|
ClipWithField.cxx
|
||||||
|
ClipWithImplicitFunction.cxx
|
||||||
|
Contour.cxx
|
||||||
|
ExternalFaces.cxx
|
||||||
|
ExtractStructured.cxx
|
||||||
|
PointAverage.cxx
|
||||||
|
Threshold.cxx
|
||||||
|
VectorMagnitude.cxx
|
||||||
|
)
|
||||||
|
|
||||||
vtkm_declare_headers(${headers})
|
vtkm_library(
|
||||||
vtkm_declare_headers(${header_template_sources})
|
NAME vtkm_filter
|
||||||
|
TEMPLATE_SOURCES ${header_template_sources}
|
||||||
# Create an interface library for vtkm_filter. At some point, this will be replaced with a real
|
HEADERS ${headers}
|
||||||
# library that contains pre-built filters. That would be created with the vtkm_library CMake
|
DEVICE_SOURCES ${sources_device}
|
||||||
# function (defined in VTKmWrappers.cmake).
|
)
|
||||||
add_library(vtkm_filter INTERFACE)
|
target_link_libraries(vtkm_filter PUBLIC vtkm_worklet)
|
||||||
target_link_libraries(vtkm_filter INTERFACE vtkm_worklet)
|
|
||||||
install(TARGETS vtkm_filter EXPORT ${VTKm_EXPORT_NAME})
|
|
||||||
|
|
||||||
add_subdirectory(internal)
|
add_subdirectory(internal)
|
||||||
|
|
||||||
|
22
vtkm/filter/CellAverage.cxx
Normal file
22
vtkm/filter/CellAverage.cxx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_CellAverage_cxx
|
||||||
|
|
||||||
|
#include <vtkm/filter/CellAverage.h>
|
||||||
|
#include <vtkm/filter/CellAverage.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(CellAverage);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,9 @@
|
|||||||
#ifndef vtk_m_filter_CellAverage_h
|
#ifndef vtk_m_filter_CellAverage_h
|
||||||
#define vtk_m_filter_CellAverage_h
|
#define vtk_m_filter_CellAverage_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||||
#include <vtkm/filter/FilterCell.h>
|
#include <vtkm/filter/FilterCell.h>
|
||||||
#include <vtkm/worklet/CellAverage.h>
|
#include <vtkm/worklet/CellAverage.h>
|
||||||
|
|
||||||
@ -25,24 +28,23 @@ namespace filter
|
|||||||
/// The method of transformation is based on averaging the data
|
/// The method of transformation is based on averaging the data
|
||||||
/// values of all points used by particular cell.
|
/// values of all points used by particular cell.
|
||||||
///
|
///
|
||||||
class CellAverage : public vtkm::filter::FilterCell<CellAverage>
|
class VTKM_ALWAYS_EXPORT CellAverage : public vtkm::filter::FilterCell<CellAverage>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VTKM_CONT
|
|
||||||
CellAverage();
|
|
||||||
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::worklet::CellAverage Worklet;
|
vtkm::worklet::CellAverage Worklet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_CellAverage_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(CellAverage);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/CellAverage.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_CellAverage_h
|
#endif // vtk_m_filter_CellAverage_h
|
||||||
|
@ -15,21 +15,13 @@ namespace vtkm
|
|||||||
{
|
{
|
||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT CellAverage::CellAverage()
|
|
||||||
: vtkm::filter::FilterCell<CellAverage>()
|
|
||||||
, Worklet()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
|
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
|
||||||
const vtkm::filter::FieldMetadata& fieldMetadata,
|
const vtkm::filter::FieldMetadata& fieldMetadata,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
if (!fieldMetadata.IsPointField())
|
if (!fieldMetadata.IsPointField())
|
||||||
{
|
{
|
||||||
|
122
vtkm/filter/CleanGrid.cxx
Normal file
122
vtkm/filter/CleanGrid.cxx
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// 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_CleanGrid_cxx
|
||||||
|
#include <vtkm/filter/CleanGrid.h>
|
||||||
|
#include <vtkm/filter/CleanGrid.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CleanGrid::CleanGrid()
|
||||||
|
: CompactPointFields(true)
|
||||||
|
, MergePoints(true)
|
||||||
|
, Tolerance(1.0e-6)
|
||||||
|
, ToleranceIsAbsolute(false)
|
||||||
|
, RemoveDegenerateCells(true)
|
||||||
|
, FastMerge(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
vtkm::cont::DataSet CleanGrid::GenerateOutput(const vtkm::cont::DataSet& inData,
|
||||||
|
vtkm::cont::CellSetExplicit<>& outputCellSet)
|
||||||
|
{
|
||||||
|
using VecId = std::size_t;
|
||||||
|
const VecId activeCoordIndex = static_cast<VecId>(this->GetActiveCoordinateSystemIndex());
|
||||||
|
const VecId numCoordSystems = static_cast<VecId>(inData.GetNumberOfCoordinateSystems());
|
||||||
|
|
||||||
|
std::vector<vtkm::cont::CoordinateSystem> outputCoordinateSystems(numCoordSystems);
|
||||||
|
|
||||||
|
// Start with a shallow copy of the coordinate systems
|
||||||
|
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
||||||
|
{
|
||||||
|
outputCoordinateSystems[coordSystemIndex] =
|
||||||
|
inData.GetCoordinateSystem(static_cast<vtkm::IdComponent>(coordSystemIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optionally adjust the cell set indices to remove all unused points
|
||||||
|
if (this->GetCompactPointFields())
|
||||||
|
{
|
||||||
|
this->PointCompactor.FindPointsStart();
|
||||||
|
this->PointCompactor.FindPoints(outputCellSet);
|
||||||
|
this->PointCompactor.FindPointsEnd();
|
||||||
|
|
||||||
|
outputCellSet = this->PointCompactor.MapCellSet(outputCellSet);
|
||||||
|
|
||||||
|
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
||||||
|
{
|
||||||
|
outputCoordinateSystems[coordSystemIndex] =
|
||||||
|
vtkm::cont::CoordinateSystem(outputCoordinateSystems[coordSystemIndex].GetName(),
|
||||||
|
this->PointCompactor.MapPointFieldDeep(
|
||||||
|
outputCoordinateSystems[coordSystemIndex].GetData()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optionally find and merge coincident points
|
||||||
|
if (this->GetMergePoints())
|
||||||
|
{
|
||||||
|
vtkm::cont::CoordinateSystem activeCoordSystem = outputCoordinateSystems[activeCoordIndex];
|
||||||
|
vtkm::Bounds bounds = activeCoordSystem.GetBounds();
|
||||||
|
|
||||||
|
vtkm::Float64 delta = this->GetTolerance();
|
||||||
|
if (!this->GetToleranceIsAbsolute())
|
||||||
|
{
|
||||||
|
delta *=
|
||||||
|
vtkm::Magnitude(vtkm::make_Vec(bounds.X.Length(), bounds.Y.Length(), bounds.Z.Length()));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto coordArray = activeCoordSystem.GetData();
|
||||||
|
this->PointMerger.Run(delta, this->GetFastMerge(), bounds, coordArray);
|
||||||
|
activeCoordSystem = vtkm::cont::CoordinateSystem(activeCoordSystem.GetName(), coordArray);
|
||||||
|
|
||||||
|
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
||||||
|
{
|
||||||
|
if (coordSystemIndex == activeCoordIndex)
|
||||||
|
{
|
||||||
|
outputCoordinateSystems[coordSystemIndex] = activeCoordSystem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outputCoordinateSystems[coordSystemIndex] = vtkm::cont::CoordinateSystem(
|
||||||
|
outputCoordinateSystems[coordSystemIndex].GetName(),
|
||||||
|
this->PointMerger.MapPointField(outputCoordinateSystems[coordSystemIndex].GetData()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
outputCellSet = this->PointMerger.MapCellSet(outputCellSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optionally remove degenerate cells
|
||||||
|
if (this->GetRemoveDegenerateCells())
|
||||||
|
{
|
||||||
|
outputCellSet = this->CellCompactor.Run(outputCellSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct resulting data set with new cell sets
|
||||||
|
vtkm::cont::DataSet outData;
|
||||||
|
outData.SetCellSet(outputCellSet);
|
||||||
|
|
||||||
|
// Pass the coordinate systems
|
||||||
|
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
||||||
|
{
|
||||||
|
outData.AddCoordinateSystem(outputCoordinateSystems[coordSystemIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outData;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(CleanGrid);
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,8 @@
|
|||||||
#ifndef vtk_m_filter_CleanGrid_h
|
#ifndef vtk_m_filter_CleanGrid_h
|
||||||
#define vtk_m_filter_CleanGrid_h
|
#define vtk_m_filter_CleanGrid_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/filter/FilterDataSet.h>
|
#include <vtkm/filter/FilterDataSet.h>
|
||||||
|
|
||||||
#include <vtkm/worklet/PointMerge.h>
|
#include <vtkm/worklet/PointMerge.h>
|
||||||
@ -35,10 +37,10 @@ namespace filter
|
|||||||
/// \todo Add a feature to merge points that are coincident or within a
|
/// \todo Add a feature to merge points that are coincident or within a
|
||||||
/// tolerance.
|
/// tolerance.
|
||||||
///
|
///
|
||||||
class CleanGrid : public vtkm::filter::FilterDataSet<CleanGrid>
|
class VTKM_ALWAYS_EXPORT CleanGrid : public vtkm::filter::FilterDataSet<CleanGrid>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
CleanGrid();
|
CleanGrid();
|
||||||
|
|
||||||
/// When the CompactPointFields flag is true, the filter will identify any
|
/// When the CompactPointFields flag is true, the filter will identify any
|
||||||
@ -85,15 +87,41 @@ public:
|
|||||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData,
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData,
|
||||||
vtkm::filter::PolicyBase<Policy> policy);
|
vtkm::filter::PolicyBase<Policy> policy);
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType, typename Storage, typename Policy>
|
template <typename ValueType, typename Storage, typename Policy>
|
||||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::ArrayHandle<ValueType, Storage>& input,
|
const vtkm::cont::ArrayHandle<ValueType, Storage>& input,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
vtkm::filter::PolicyBase<Policy>);
|
vtkm::filter::PolicyBase<Policy>)
|
||||||
|
{
|
||||||
|
if (fieldMeta.IsPointField() && (this->GetCompactPointFields() || this->GetMergePoints()))
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> compactedArray;
|
||||||
|
if (this->GetCompactPointFields())
|
||||||
|
{
|
||||||
|
compactedArray = this->PointCompactor.MapPointFieldDeep(input);
|
||||||
|
if (this->GetMergePoints())
|
||||||
|
{
|
||||||
|
compactedArray = this->PointMerger.MapPointField(compactedArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this->GetMergePoints())
|
||||||
|
{
|
||||||
|
compactedArray = this->PointMerger.MapPointField(input);
|
||||||
|
}
|
||||||
|
result.AddField(fieldMeta.AsField(compactedArray));
|
||||||
|
}
|
||||||
|
else if (fieldMeta.IsCellField() && this->GetRemoveDegenerateCells())
|
||||||
|
{
|
||||||
|
result.AddField(fieldMeta.AsField(this->CellCompactor.ProcessCellField(input)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.AddField(fieldMeta.AsField(input));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename ValueType, typename Storage>
|
return true;
|
||||||
VTKM_CONT vtkm::cont::ArrayHandle<ValueType> MapPointField(
|
}
|
||||||
const vtkm::cont::ArrayHandle<ValueType, Storage>& inArray) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool CompactPointFields;
|
bool CompactPointFields;
|
||||||
@ -103,13 +131,19 @@ private:
|
|||||||
bool RemoveDegenerateCells;
|
bool RemoveDegenerateCells;
|
||||||
bool FastMerge;
|
bool FastMerge;
|
||||||
|
|
||||||
|
VTKM_FILTER_EXPORT vtkm::cont::DataSet GenerateOutput(
|
||||||
|
const vtkm::cont::DataSet& inData,
|
||||||
|
vtkm::cont::CellSetExplicit<>& outputCellSet);
|
||||||
|
|
||||||
vtkm::worklet::RemoveUnusedPoints PointCompactor;
|
vtkm::worklet::RemoveUnusedPoints PointCompactor;
|
||||||
vtkm::worklet::RemoveDegenerateCells CellCompactor;
|
vtkm::worklet::RemoveDegenerateCells CellCompactor;
|
||||||
vtkm::worklet::PointMerge PointMerger;
|
vtkm::worklet::PointMerge PointMerger;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_CleanGrid_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(CleanGrid);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/CleanGrid.hxx>
|
|
||||||
|
|
||||||
#endif //vtk_m_filter_CleanGrid_h
|
#endif //vtk_m_filter_CleanGrid_h
|
||||||
|
@ -20,24 +20,11 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
inline VTKM_CONT CleanGrid::CleanGrid()
|
|
||||||
: CompactPointFields(true)
|
|
||||||
, MergePoints(true)
|
|
||||||
, Tolerance(1.0e-6)
|
|
||||||
, ToleranceIsAbsolute(false)
|
|
||||||
, RemoveDegenerateCells(true)
|
|
||||||
, FastMerge(true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Policy>
|
template <typename Policy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::DataSet& inData,
|
inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::DataSet& inData,
|
||||||
vtkm::filter::PolicyBase<Policy> policy)
|
vtkm::filter::PolicyBase<Policy> policy)
|
||||||
{
|
{
|
||||||
using CellSetType = vtkm::cont::CellSetExplicit<>;
|
using CellSetType = vtkm::cont::CellSetExplicit<>;
|
||||||
using VecId = std::size_t;
|
|
||||||
|
|
||||||
VecId activeCoordIndex = static_cast<VecId>(this->GetActiveCoordinateSystemIndex());
|
|
||||||
|
|
||||||
CellSetType outputCellSet;
|
CellSetType outputCellSet;
|
||||||
// Do a deep copy of the cells to new CellSetExplicit structures
|
// Do a deep copy of the cells to new CellSetExplicit structures
|
||||||
@ -78,122 +65,7 @@ inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::Data
|
|||||||
deducedCellSet.ReleaseResourcesExecution();
|
deducedCellSet.ReleaseResourcesExecution();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this->GenerateOutput(inData, outputCellSet);
|
||||||
VecId numCoordSystems = static_cast<VecId>(inData.GetNumberOfCoordinateSystems());
|
|
||||||
std::vector<vtkm::cont::CoordinateSystem> outputCoordinateSystems(numCoordSystems);
|
|
||||||
|
|
||||||
// Start with a shallow copy of the coordinate systems
|
|
||||||
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
|
||||||
{
|
|
||||||
outputCoordinateSystems[coordSystemIndex] =
|
|
||||||
inData.GetCoordinateSystem(static_cast<vtkm::IdComponent>(coordSystemIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optionally adjust the cell set indices to remove all unused points
|
|
||||||
if (this->GetCompactPointFields())
|
|
||||||
{
|
|
||||||
this->PointCompactor.FindPointsStart();
|
|
||||||
this->PointCompactor.FindPoints(outputCellSet);
|
|
||||||
this->PointCompactor.FindPointsEnd();
|
|
||||||
|
|
||||||
outputCellSet = this->PointCompactor.MapCellSet(outputCellSet);
|
|
||||||
|
|
||||||
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
|
||||||
{
|
|
||||||
outputCoordinateSystems[coordSystemIndex] =
|
|
||||||
vtkm::cont::CoordinateSystem(outputCoordinateSystems[coordSystemIndex].GetName(),
|
|
||||||
this->PointCompactor.MapPointFieldDeep(
|
|
||||||
outputCoordinateSystems[coordSystemIndex].GetData()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optionally find and merge coincident points
|
|
||||||
if (this->GetMergePoints())
|
|
||||||
{
|
|
||||||
vtkm::cont::CoordinateSystem activeCoordSystem = outputCoordinateSystems[activeCoordIndex];
|
|
||||||
vtkm::Bounds bounds = activeCoordSystem.GetBounds();
|
|
||||||
|
|
||||||
vtkm::Float64 delta = this->GetTolerance();
|
|
||||||
if (!this->GetToleranceIsAbsolute())
|
|
||||||
{
|
|
||||||
delta *=
|
|
||||||
vtkm::Magnitude(vtkm::make_Vec(bounds.X.Length(), bounds.Y.Length(), bounds.Z.Length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto coordArray = activeCoordSystem.GetData();
|
|
||||||
this->PointMerger.Run(delta, this->GetFastMerge(), bounds, coordArray);
|
|
||||||
activeCoordSystem = vtkm::cont::CoordinateSystem(activeCoordSystem.GetName(), coordArray);
|
|
||||||
|
|
||||||
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
|
||||||
{
|
|
||||||
if (coordSystemIndex == activeCoordIndex)
|
|
||||||
{
|
|
||||||
outputCoordinateSystems[coordSystemIndex] = activeCoordSystem;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
outputCoordinateSystems[coordSystemIndex] = vtkm::cont::CoordinateSystem(
|
|
||||||
outputCoordinateSystems[coordSystemIndex].GetName(),
|
|
||||||
this->PointMerger.MapPointField(outputCoordinateSystems[coordSystemIndex].GetData()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
outputCellSet = this->PointMerger.MapCellSet(outputCellSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optionally remove degenerate cells
|
|
||||||
if (this->GetRemoveDegenerateCells())
|
|
||||||
{
|
|
||||||
outputCellSet = this->CellCompactor.Run(outputCellSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct resulting data set with new cell sets
|
|
||||||
vtkm::cont::DataSet outData;
|
|
||||||
outData.SetCellSet(outputCellSet);
|
|
||||||
|
|
||||||
// Pass the coordinate systems
|
|
||||||
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
|
|
||||||
{
|
|
||||||
outData.AddCoordinateSystem(outputCoordinateSystems[coordSystemIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return outData;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename ValueType, typename Storage, typename Policy>
|
|
||||||
inline VTKM_CONT bool CleanGrid::DoMapField(
|
|
||||||
vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<ValueType, Storage>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
vtkm::filter::PolicyBase<Policy>)
|
|
||||||
{
|
|
||||||
if (fieldMeta.IsPointField() && (this->GetCompactPointFields() || this->GetMergePoints()))
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> compactedArray;
|
|
||||||
if (this->GetCompactPointFields())
|
|
||||||
{
|
|
||||||
compactedArray = this->PointCompactor.MapPointFieldDeep(input);
|
|
||||||
if (this->GetMergePoints())
|
|
||||||
{
|
|
||||||
compactedArray = this->PointMerger.MapPointField(compactedArray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this->GetMergePoints())
|
|
||||||
{
|
|
||||||
compactedArray = this->PointMerger.MapPointField(input);
|
|
||||||
}
|
|
||||||
result.AddField(fieldMeta.AsField(compactedArray));
|
|
||||||
}
|
|
||||||
else if (fieldMeta.IsCellField() && this->GetRemoveDegenerateCells())
|
|
||||||
{
|
|
||||||
result.AddField(fieldMeta.AsField(this->CellCompactor.ProcessCellField(input)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.AddField(fieldMeta.AsField(input));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
vtkm/filter/ClipWithField.cxx
Normal file
22
vtkm/filter/ClipWithField.cxx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_Clip_cxx
|
||||||
|
|
||||||
|
#include <vtkm/filter/ClipWithField.h>
|
||||||
|
#include <vtkm/filter/ClipWithField.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(ClipWithField);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef vtk_m_filter_ClipWithField_h
|
#ifndef vtk_m_filter_ClipWithField_h
|
||||||
#define vtk_m_filter_ClipWithField_h
|
#define vtk_m_filter_ClipWithField_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||||
#include <vtkm/worklet/Clip.h>
|
#include <vtkm/worklet/Clip.h>
|
||||||
|
|
||||||
@ -24,14 +26,11 @@ namespace filter
|
|||||||
/// value are considered outside, and will be discarded. All points that are greater
|
/// value are considered outside, and will be discarded. All points that are greater
|
||||||
/// are kept.
|
/// are kept.
|
||||||
/// The resulting geometry will not be water tight.
|
/// The resulting geometry will not be water tight.
|
||||||
class ClipWithField : public vtkm::filter::FilterDataSetWithField<ClipWithField>
|
class VTKM_ALWAYS_EXPORT ClipWithField : public vtkm::filter::FilterDataSetWithField<ClipWithField>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using SupportedTypes = vtkm::TypeListTagScalarAll;
|
using SupportedTypes = vtkm::TypeListTagScalarAll;
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
ClipWithField();
|
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void SetClipValue(vtkm::Float64 value) { this->ClipValue = value; }
|
void SetClipValue(vtkm::Float64 value) { this->ClipValue = value; }
|
||||||
|
|
||||||
@ -53,16 +52,38 @@ public:
|
|||||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<T> output;
|
||||||
|
|
||||||
|
if (fieldMeta.IsPointField())
|
||||||
|
{
|
||||||
|
output = this->Worklet.ProcessPointField(input);
|
||||||
|
}
|
||||||
|
else if (fieldMeta.IsCellField())
|
||||||
|
{
|
||||||
|
output = this->Worklet.ProcessCellField(input);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//use the same meta data as the input so we get the same field name, etc.
|
||||||
|
result.AddField(fieldMeta.AsField(output));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::Float64 ClipValue;
|
vtkm::Float64 ClipValue = 0;
|
||||||
vtkm::worklet::Clip Worklet;
|
vtkm::worklet::Clip Worklet;
|
||||||
bool Invert;
|
bool Invert = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_Clip_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithField);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/ClipWithField.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_ClipWithField_h
|
#endif // vtk_m_filter_ClipWithField_h
|
||||||
|
@ -18,16 +18,6 @@ namespace vtkm
|
|||||||
{
|
{
|
||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT ClipWithField::ClipWithField()
|
|
||||||
: vtkm::filter::FilterDataSetWithField<ClipWithField>()
|
|
||||||
, ClipValue(0)
|
|
||||||
, Worklet()
|
|
||||||
, Invert(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||||
@ -60,33 +50,5 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
|||||||
output.AddCoordinateSystem(outputCoords);
|
output.AddCoordinateSystem(outputCoords);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
||||||
inline VTKM_CONT bool ClipWithField::DoMapField(
|
|
||||||
vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<T> output;
|
|
||||||
|
|
||||||
if (fieldMeta.IsPointField())
|
|
||||||
{
|
|
||||||
output = this->Worklet.ProcessPointField(input);
|
|
||||||
}
|
|
||||||
else if (fieldMeta.IsCellField())
|
|
||||||
{
|
|
||||||
output = this->Worklet.ProcessCellField(input);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//use the same meta data as the input so we get the same field name, etc.
|
|
||||||
result.AddField(fieldMeta.AsField(output));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // end namespace vtkm::filter
|
} // end namespace vtkm::filter
|
||||||
|
22
vtkm/filter/ClipWithImplicitFunction.cxx
Normal file
22
vtkm/filter/ClipWithImplicitFunction.cxx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// 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_ClipWithImplicitFunction_cxx
|
||||||
|
#include <vtkm/filter/ClipWithImplicitFunction.h>
|
||||||
|
#include <vtkm/filter/ClipWithImplicitFunction.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(ClipWithImplicitFunction);
|
||||||
|
}
|
||||||
|
}
|
@ -7,10 +7,11 @@
|
|||||||
// 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.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef vtk_m_filter_ClipWithImplicitFunction_h
|
#ifndef vtk_m_filter_ClipWithImplicitFunction_h
|
||||||
#define vtk_m_filter_ClipWithImplicitFunction_h
|
#define vtk_m_filter_ClipWithImplicitFunction_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/cont/ImplicitFunctionHandle.h>
|
#include <vtkm/cont/ImplicitFunctionHandle.h>
|
||||||
#include <vtkm/filter/FilterDataSet.h>
|
#include <vtkm/filter/FilterDataSet.h>
|
||||||
#include <vtkm/worklet/Clip.h>
|
#include <vtkm/worklet/Clip.h>
|
||||||
@ -25,11 +26,10 @@ namespace filter
|
|||||||
/// Clip a dataset using a given implicit function value, such as vtkm::Sphere
|
/// Clip a dataset using a given implicit function value, such as vtkm::Sphere
|
||||||
/// or vtkm::Frustum.
|
/// or vtkm::Frustum.
|
||||||
/// The resulting geometry will not be water tight.
|
/// The resulting geometry will not be water tight.
|
||||||
class ClipWithImplicitFunction : public vtkm::filter::FilterDataSet<ClipWithImplicitFunction>
|
class VTKM_ALWAYS_EXPORT ClipWithImplicitFunction
|
||||||
|
: public vtkm::filter::FilterDataSet<ClipWithImplicitFunction>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClipWithImplicitFunction();
|
|
||||||
|
|
||||||
void SetImplicitFunction(const vtkm::cont::ImplicitFunctionHandle& func)
|
void SetImplicitFunction(const vtkm::cont::ImplicitFunctionHandle& func)
|
||||||
{
|
{
|
||||||
this->Function = func;
|
this->Function = func;
|
||||||
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
//Map a new field onto the resulting dataset after running the filter.
|
//Map a new field onto the resulting dataset after running the filter.
|
||||||
//This call is only valid after Execute has been called.
|
//This call is only valid after Execute has been called.
|
||||||
@ -49,16 +49,39 @@ public:
|
|||||||
bool DoMapField(vtkm::cont::DataSet& result,
|
bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<T> output;
|
||||||
|
|
||||||
|
if (fieldMeta.IsPointField())
|
||||||
|
{
|
||||||
|
output = this->Worklet.ProcessPointField(input);
|
||||||
|
}
|
||||||
|
else if (fieldMeta.IsCellField())
|
||||||
|
{
|
||||||
|
output = this->Worklet.ProcessCellField(input);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//use the same meta data as the input so we get the same field name, etc.
|
||||||
|
result.AddField(fieldMeta.AsField(output));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::cont::ImplicitFunctionHandle Function;
|
vtkm::cont::ImplicitFunctionHandle Function;
|
||||||
vtkm::worklet::Clip Worklet;
|
vtkm::worklet::Clip Worklet;
|
||||||
bool Invert;
|
bool Invert = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_ClipWithImplicitFunction_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithImplicitFunction);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/ClipWithImplicitFunction.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_ClipWithImplicitFunction_h
|
#endif // vtk_m_filter_ClipWithImplicitFunction_h
|
||||||
|
@ -17,16 +17,10 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ClipWithImplicitFunction::ClipWithImplicitFunction()
|
|
||||||
: Invert(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
//get the cells and coordinates of the dataset
|
//get the cells and coordinates of the dataset
|
||||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||||
@ -48,34 +42,5 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
|||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
||||||
inline bool ClipWithImplicitFunction::DoMapField(
|
|
||||||
vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<T> output;
|
|
||||||
|
|
||||||
if (fieldMeta.IsPointField())
|
|
||||||
{
|
|
||||||
output = this->Worklet.ProcessPointField(input);
|
|
||||||
}
|
|
||||||
else if (fieldMeta.IsCellField())
|
|
||||||
{
|
|
||||||
output = this->Worklet.ProcessCellField(input);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//use the same meta data as the input so we get the same field name, etc.
|
|
||||||
result.AddField(fieldMeta.AsField(output));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // end namespace vtkm::filter
|
} // end namespace vtkm::filter
|
||||||
|
75
vtkm/filter/Contour.cxx
Normal file
75
vtkm/filter/Contour.cxx
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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>
|
||||||
|
#include <vtkm/filter/Contour.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_EXPORT 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
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_EXPORT void Contour::SetNumberOfIsoValues(vtkm::Id num)
|
||||||
|
{
|
||||||
|
if (num >= 0)
|
||||||
|
{
|
||||||
|
this->IsoValues.resize(static_cast<std::size_t>(num));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_EXPORT vtkm::Id Contour::GetNumberOfIsoValues() const
|
||||||
|
{
|
||||||
|
return static_cast<vtkm::Id>(this->IsoValues.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_EXPORT 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_EXPORT void Contour::SetIsoValues(const std::vector<vtkm::Float64>& values)
|
||||||
|
{
|
||||||
|
this->IsoValues = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_EXPORT vtkm::Float64 Contour::GetIsoValue(vtkm::Id index) const
|
||||||
|
{
|
||||||
|
return this->IsoValues[static_cast<std::size_t>(index)];
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(Contour);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef vtk_m_filter_Contour_h
|
#ifndef vtk_m_filter_Contour_h
|
||||||
#define vtk_m_filter_Contour_h
|
#define vtk_m_filter_Contour_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||||
#include <vtkm/worklet/Contour.h>
|
#include <vtkm/worklet/Contour.h>
|
||||||
|
|
||||||
@ -25,30 +27,30 @@ namespace filter
|
|||||||
/// Multiple contour values must be specified to generate the isosurfaces.
|
/// Multiple contour values must be specified to generate the isosurfaces.
|
||||||
/// @warning
|
/// @warning
|
||||||
/// This filter is currently only supports 3D volumes.
|
/// This filter is currently only supports 3D volumes.
|
||||||
class Contour : public vtkm::filter::FilterDataSetWithField<Contour>
|
class VTKM_ALWAYS_EXPORT Contour : public vtkm::filter::FilterDataSetWithField<Contour>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using SupportedTypes = vtkm::ListTagBase<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>;
|
using SupportedTypes = vtkm::ListTagBase<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>;
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
Contour();
|
Contour();
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
void SetNumberOfIsoValues(vtkm::Id num);
|
void SetNumberOfIsoValues(vtkm::Id num);
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
vtkm::Id GetNumberOfIsoValues() const;
|
vtkm::Id GetNumberOfIsoValues() const;
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
void SetIsoValue(vtkm::Float64 v) { this->SetIsoValue(0, v); }
|
void SetIsoValue(vtkm::Float64 v) { this->SetIsoValue(0, v); }
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
void SetIsoValue(vtkm::Id index, vtkm::Float64);
|
void SetIsoValue(vtkm::Id index, vtkm::Float64);
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
void SetIsoValues(const std::vector<vtkm::Float64>& values);
|
void SetIsoValues(const std::vector<vtkm::Float64>& values);
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
vtkm::Float64 GetIsoValue(vtkm::Id index) const;
|
vtkm::Float64 GetIsoValue(vtkm::Id index) const;
|
||||||
|
|
||||||
/// Set/Get whether the points generated should be unique for every triangle
|
/// Set/Get whether the points generated should be unique for every triangle
|
||||||
@ -104,10 +106,10 @@ public:
|
|||||||
const std::string& GetNormalArrayName() const { return this->NormalArrayName; }
|
const std::string& GetNormalArrayName() const { return this->NormalArrayName; }
|
||||||
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
//Map a new field onto the resulting dataset after running the filter
|
//Map a new field onto the resulting dataset after running the filter
|
||||||
//this call is only valid
|
//this call is only valid
|
||||||
@ -115,7 +117,27 @@ public:
|
|||||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<T> fieldArray;
|
||||||
|
|
||||||
|
if (fieldMeta.IsPointField())
|
||||||
|
{
|
||||||
|
fieldArray = this->Worklet.ProcessPointField(input);
|
||||||
|
}
|
||||||
|
else if (fieldMeta.IsCellField())
|
||||||
|
{
|
||||||
|
fieldArray = this->Worklet.ProcessCellField(input);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//use the same meta data as the input so we get the same field name, etc.
|
||||||
|
result.AddField(fieldMeta.AsField(fieldArray));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<vtkm::Float64> IsoValues;
|
std::vector<vtkm::Float64> IsoValues;
|
||||||
@ -127,9 +149,11 @@ private:
|
|||||||
std::string InterpolationEdgeIdsArrayName;
|
std::string InterpolationEdgeIdsArrayName;
|
||||||
vtkm::worklet::Contour Worklet;
|
vtkm::worklet::Contour Worklet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_Contour_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(Contour);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/Contour.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_Contour_h
|
#endif // vtk_m_filter_Contour_h
|
||||||
|
@ -25,7 +25,7 @@ namespace
|
|||||||
{
|
{
|
||||||
|
|
||||||
template <typename CellSetList>
|
template <typename CellSetList>
|
||||||
bool IsCellSetStructured(const vtkm::cont::DynamicCellSetBase<CellSetList>& cellset)
|
inline bool IsCellSetStructured(const vtkm::cont::DynamicCellSetBase<CellSetList>& cellset)
|
||||||
{
|
{
|
||||||
if (cellset.template IsType<vtkm::cont::CellSetStructured<1>>() ||
|
if (cellset.template IsType<vtkm::cont::CellSetStructured<1>>() ||
|
||||||
cellset.template IsType<vtkm::cont::CellSetStructured<2>>() ||
|
cellset.template IsType<vtkm::cont::CellSetStructured<2>>() ||
|
||||||
@ -37,66 +37,13 @@ bool IsCellSetStructured(const vtkm::cont::DynamicCellSetBase<CellSetList>& cell
|
|||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT 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
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline void Contour::SetNumberOfIsoValues(vtkm::Id num)
|
|
||||||
{
|
|
||||||
if (num >= 0)
|
|
||||||
{
|
|
||||||
this->IsoValues.resize(static_cast<std::size_t>(num));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline vtkm::Id Contour::GetNumberOfIsoValues() const
|
|
||||||
{
|
|
||||||
return static_cast<vtkm::Id>(this->IsoValues.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline void Contour::SetIsoValues(const std::vector<vtkm::Float64>& values)
|
|
||||||
{
|
|
||||||
this->IsoValues = values;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline vtkm::Float64 Contour::GetIsoValue(vtkm::Id index) const
|
|
||||||
{
|
|
||||||
return this->IsoValues[static_cast<std::size_t>(index)];
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
if (fieldMeta.IsPointField() == false)
|
if (fieldMeta.IsPointField() == false)
|
||||||
{
|
{
|
||||||
@ -203,32 +150,5 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
|
|||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
||||||
inline VTKM_CONT bool Contour::DoMapField(vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<T> fieldArray;
|
|
||||||
|
|
||||||
if (fieldMeta.IsPointField())
|
|
||||||
{
|
|
||||||
fieldArray = this->Worklet.ProcessPointField(input);
|
|
||||||
}
|
|
||||||
else if (fieldMeta.IsCellField())
|
|
||||||
{
|
|
||||||
fieldArray = this->Worklet.ProcessCellField(input);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//use the same meta data as the input so we get the same field name, etc.
|
|
||||||
result.AddField(fieldMeta.AsField(fieldArray));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
71
vtkm/filter/ExternalFaces.cxx
Normal file
71
vtkm/filter/ExternalFaces.cxx
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// 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_ExternalFaces_cxx
|
||||||
|
#include <vtkm/filter/ExternalFaces.h>
|
||||||
|
#include <vtkm/filter/ExternalFaces.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
ExternalFaces::ExternalFaces()
|
||||||
|
: vtkm::filter::FilterDataSet<ExternalFaces>()
|
||||||
|
, CompactPoints(false)
|
||||||
|
, Worklet()
|
||||||
|
{
|
||||||
|
this->SetPassPolyData(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
vtkm::cont::DataSet ExternalFaces::GenerateOutput(const vtkm::cont::DataSet& input,
|
||||||
|
vtkm::cont::CellSetExplicit<>& outCellSet)
|
||||||
|
{
|
||||||
|
//This section of ExternalFaces is independent of any input so we can build it
|
||||||
|
//into the vtkm_filter library
|
||||||
|
|
||||||
|
//3. Check the fields of the dataset to see what kinds of fields are present so
|
||||||
|
// we can free the cell mapping array if it won't be needed.
|
||||||
|
const vtkm::Id numFields = input.GetNumberOfFields();
|
||||||
|
bool hasCellFields = false;
|
||||||
|
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
|
||||||
|
{
|
||||||
|
auto f = input.GetField(fieldIdx);
|
||||||
|
hasCellFields = f.IsFieldCell();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasCellFields)
|
||||||
|
{
|
||||||
|
this->Worklet.ReleaseCellMapArrays();
|
||||||
|
}
|
||||||
|
|
||||||
|
//4. create the output dataset
|
||||||
|
vtkm::cont::DataSet output;
|
||||||
|
output.SetCellSet(outCellSet);
|
||||||
|
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
||||||
|
|
||||||
|
if (this->CompactPoints)
|
||||||
|
{
|
||||||
|
this->Compactor.SetCompactPointFields(true);
|
||||||
|
this->Compactor.SetMergePoints(false);
|
||||||
|
return this->Compactor.Execute(output, PolicyDefault{});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(ExternalFaces);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef vtk_m_filter_ExternalFaces_h
|
#ifndef vtk_m_filter_ExternalFaces_h
|
||||||
#define vtk_m_filter_ExternalFaces_h
|
#define vtk_m_filter_ExternalFaces_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/filter/CleanGrid.h>
|
#include <vtkm/filter/CleanGrid.h>
|
||||||
#include <vtkm/filter/FilterDataSet.h>
|
#include <vtkm/filter/FilterDataSet.h>
|
||||||
#include <vtkm/worklet/ExternalFaces.h>
|
#include <vtkm/worklet/ExternalFaces.h>
|
||||||
@ -28,10 +30,10 @@ namespace filter
|
|||||||
/// @warning
|
/// @warning
|
||||||
/// This filter is currently only supports propagation of point properties
|
/// This filter is currently only supports propagation of point properties
|
||||||
///
|
///
|
||||||
class ExternalFaces : public vtkm::filter::FilterDataSet<ExternalFaces>
|
class VTKM_ALWAYS_EXPORT ExternalFaces : public vtkm::filter::FilterDataSet<ExternalFaces>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
ExternalFaces();
|
ExternalFaces();
|
||||||
|
|
||||||
// When CompactPoints is set, instead of copying the points and point fields
|
// When CompactPoints is set, instead of copying the points and point fields
|
||||||
@ -63,17 +65,45 @@ public:
|
|||||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
|
{
|
||||||
|
if (fieldMeta.IsPointField())
|
||||||
|
{
|
||||||
|
if (this->CompactPoints)
|
||||||
|
{
|
||||||
|
return this->Compactor.DoMapField(result, input, fieldMeta, policy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.AddField(fieldMeta.AsField(input));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (fieldMeta.IsCellField())
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<T> fieldArray;
|
||||||
|
fieldArray = this->Worklet.ProcessCellField(input);
|
||||||
|
result.AddField(fieldMeta.AsField(fieldArray));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
bool CompactPoints;
|
bool CompactPoints;
|
||||||
bool PassPolyData;
|
bool PassPolyData;
|
||||||
|
|
||||||
|
VTKM_FILTER_EXPORT vtkm::cont::DataSet GenerateOutput(const vtkm::cont::DataSet& input,
|
||||||
|
vtkm::cont::CellSetExplicit<>& outCellSet);
|
||||||
|
|
||||||
vtkm::filter::CleanGrid Compactor;
|
vtkm::filter::CleanGrid Compactor;
|
||||||
vtkm::worklet::ExternalFaces Worklet;
|
vtkm::worklet::ExternalFaces Worklet;
|
||||||
};
|
};
|
||||||
|
#ifndef vtkm_filter_ExternalFaces_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(ExternalFaces);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/ExternalFaces.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_ExternalFaces_h
|
#endif // vtk_m_filter_ExternalFaces_h
|
||||||
|
@ -13,33 +13,6 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT ExternalFaces::ExternalFaces()
|
|
||||||
: vtkm::filter::FilterDataSet<ExternalFaces>()
|
|
||||||
, CompactPoints(false)
|
|
||||||
, Worklet()
|
|
||||||
{
|
|
||||||
this->SetPassPolyData(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename BasePolicy>
|
|
||||||
struct CellSetExplicitPolicy : public BasePolicy
|
|
||||||
{
|
|
||||||
using AllCellSetList = vtkm::cont::CellSetListTagExplicitDefault;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
inline vtkm::filter::PolicyBase<CellSetExplicitPolicy<DerivedPolicy>> GetCellSetExplicitPolicy(
|
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
|
||||||
{
|
|
||||||
return vtkm::filter::PolicyBase<CellSetExplicitPolicy<DerivedPolicy>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
|
||||||
@ -64,68 +37,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
|
|||||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(cells, policy), outCellSet);
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(cells, policy), outCellSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
//3. Check the fields of the dataset to see what kinds of fields are present so
|
return this->GenerateOutput(input, outCellSet);
|
||||||
// we can free the cell mapping array if it won't be needed.
|
|
||||||
const vtkm::Id numFields = input.GetNumberOfFields();
|
|
||||||
bool hasCellFields = false;
|
|
||||||
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
|
|
||||||
{
|
|
||||||
auto f = input.GetField(fieldIdx);
|
|
||||||
hasCellFields = f.IsFieldCell();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasCellFields)
|
|
||||||
{
|
|
||||||
this->Worklet.ReleaseCellMapArrays();
|
|
||||||
}
|
|
||||||
|
|
||||||
//4. create the output dataset
|
|
||||||
vtkm::cont::DataSet output;
|
|
||||||
output.SetCellSet(outCellSet);
|
|
||||||
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
|
||||||
|
|
||||||
if (this->CompactPoints)
|
|
||||||
{
|
|
||||||
this->Compactor.SetCompactPointFields(true);
|
|
||||||
this->Compactor.SetMergePoints(false);
|
|
||||||
return this->Compactor.DoExecute(output, GetCellSetExplicitPolicy(policy));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
||||||
inline VTKM_CONT bool ExternalFaces::DoMapField(
|
|
||||||
vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
|
||||||
{
|
|
||||||
if (fieldMeta.IsPointField())
|
|
||||||
{
|
|
||||||
if (this->CompactPoints)
|
|
||||||
{
|
|
||||||
return this->Compactor.DoMapField(result, input, fieldMeta, policy);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.AddField(fieldMeta.AsField(input));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (fieldMeta.IsCellField())
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<T> fieldArray;
|
|
||||||
fieldArray = this->Worklet.ProcessCellField(input);
|
|
||||||
result.AddField(fieldMeta.AsField(fieldArray));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,24 +11,6 @@
|
|||||||
#include <vtkm/cont/CoordinateSystem.h>
|
#include <vtkm/cont/CoordinateSystem.h>
|
||||||
#include <vtkm/cont/DynamicCellSet.h>
|
#include <vtkm/cont/DynamicCellSet.h>
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
// Needed to CompactPoints
|
|
||||||
template <typename BasePolicy>
|
|
||||||
struct CellSetSingleTypePolicy : public BasePolicy
|
|
||||||
{
|
|
||||||
using AllCellSetList = vtkm::cont::CellSetListTagUnstructured;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
inline vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>> GetCellSetSingleTypePolicy(
|
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
|
||||||
{
|
|
||||||
return vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
namespace filter
|
namespace filter
|
||||||
@ -71,7 +53,7 @@ inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& i
|
|||||||
{
|
{
|
||||||
this->Compactor.SetCompactPointFields(true);
|
this->Compactor.SetCompactPointFields(true);
|
||||||
this->Compactor.SetMergePoints(false);
|
this->Compactor.SetMergePoints(false);
|
||||||
return this->Compactor.DoExecute(output, GetCellSetSingleTypePolicy(policy));
|
return this->Compactor.Execute(output, PolicyDefault{});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
34
vtkm/filter/ExtractStructured.cxx
Normal file
34
vtkm/filter/ExtractStructured.cxx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_ExtractStructured_cxx
|
||||||
|
#include <vtkm/filter/ExtractStructured.h>
|
||||||
|
#include <vtkm/filter/ExtractStructured.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
ExtractStructured::ExtractStructured()
|
||||||
|
: vtkm::filter::FilterDataSet<ExtractStructured>()
|
||||||
|
, VOI(vtkm::RangeId3(0, -1, 0, -1, 0, -1))
|
||||||
|
, SampleRate(vtkm::Id3(1, 1, 1))
|
||||||
|
, IncludeBoundary(false)
|
||||||
|
, IncludeOffset(false)
|
||||||
|
, Worklet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(ExtractStructured);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef vtk_m_filter_ExtractStructured_h
|
#ifndef vtk_m_filter_ExtractStructured_h
|
||||||
#define vtk_m_filter_ExtractStructured_h
|
#define vtk_m_filter_ExtractStructured_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/filter/FilterDataSet.h>
|
#include <vtkm/filter/FilterDataSet.h>
|
||||||
#include <vtkm/worklet/ExtractStructured.h>
|
#include <vtkm/worklet/ExtractStructured.h>
|
||||||
|
|
||||||
@ -34,10 +36,10 @@ namespace filter
|
|||||||
/// for image processing, subsampling large volumes to reduce data size, or
|
/// for image processing, subsampling large volumes to reduce data size, or
|
||||||
/// extracting regions of a volume with interesting data.
|
/// extracting regions of a volume with interesting data.
|
||||||
///
|
///
|
||||||
class ExtractStructured : public vtkm::filter::FilterDataSet<ExtractStructured>
|
class VTKM_ALWAYS_EXPORT ExtractStructured : public vtkm::filter::FilterDataSet<ExtractStructured>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
ExtractStructured();
|
ExtractStructured();
|
||||||
|
|
||||||
// Set the bounding box for the volume of interest
|
// Set the bounding box for the volume of interest
|
||||||
@ -90,7 +92,27 @@ public:
|
|||||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
|
{
|
||||||
|
if (fieldMeta.IsPointField())
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessPointField(input);
|
||||||
|
|
||||||
|
result.AddField(fieldMeta.AsField(output));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cell data must be scattered to the cells created per input cell
|
||||||
|
if (fieldMeta.IsCellField())
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessCellField(input);
|
||||||
|
|
||||||
|
result.AddField(fieldMeta.AsField(output));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::RangeId3 VOI;
|
vtkm::RangeId3 VOI;
|
||||||
@ -99,9 +121,12 @@ private:
|
|||||||
bool IncludeOffset;
|
bool IncludeOffset;
|
||||||
vtkm::worklet::ExtractStructured Worklet;
|
vtkm::worklet::ExtractStructured Worklet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_ExtractStructured_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(ExtractStructured);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/ExtractStructured.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_ExtractStructured_h
|
#endif // vtk_m_filter_ExtractStructured_h
|
||||||
|
@ -12,18 +12,6 @@ namespace vtkm
|
|||||||
{
|
{
|
||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT ExtractStructured::ExtractStructured()
|
|
||||||
: vtkm::filter::FilterDataSet<ExtractStructured>()
|
|
||||||
, VOI(vtkm::RangeId3(0, -1, 0, -1, 0, -1))
|
|
||||||
, SampleRate(vtkm::Id3(1, 1, 1))
|
|
||||||
, IncludeBoundary(false)
|
|
||||||
, IncludeOffset(false)
|
|
||||||
, Worklet()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
|
||||||
@ -47,33 +35,5 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
|
|||||||
output.AddCoordinateSystem(outputCoordinates);
|
output.AddCoordinateSystem(outputCoordinates);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
||||||
inline VTKM_CONT bool ExtractStructured::DoMapField(
|
|
||||||
vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
|
||||||
{
|
|
||||||
if (fieldMeta.IsPointField())
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessPointField(input);
|
|
||||||
|
|
||||||
result.AddField(fieldMeta.AsField(output));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cell data must be scattered to the cells created per input cell
|
|
||||||
if (fieldMeta.IsCellField())
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<T> output = this->Worklet.ProcessCellField(input);
|
|
||||||
|
|
||||||
result.AddField(fieldMeta.AsField(output));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ public:
|
|||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input,
|
VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
@ -253,9 +253,8 @@ public:
|
|||||||
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input);
|
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input);
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(
|
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input,
|
||||||
const vtkm::cont::PartitionedDataSet& input,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// Map fields from input dataset to output.
|
/// Map fields from input dataset to output.
|
||||||
@ -264,7 +263,7 @@ public:
|
|||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT void MapFieldsToPass(const vtkm::cont::DataSet& input,
|
VTKM_CONT void MapFieldsToPass(const vtkm::cont::DataSet& input,
|
||||||
vtkm::cont::DataSet& output,
|
vtkm::cont::DataSet& output,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
/// Specify the vtkm::cont::Invoker to be used to execute worklets by
|
/// Specify the vtkm::cont::Invoker to be used to execute worklets by
|
||||||
/// this filter instance. Overriding the default allows callers to control
|
/// this filter instance. Overriding the default allows callers to control
|
||||||
@ -280,5 +279,18 @@ private:
|
|||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
|
#define VTKM_FILTER_EXPORT_EXECUTE_METHOD_WITH_POLICY(Name, Policy) \
|
||||||
|
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::PartitionedDataSet \
|
||||||
|
vtkm::filter::Filter<Name>::Execute(vtkm::cont::PartitionedDataSet const&, \
|
||||||
|
vtkm::filter::PolicyBase<Policy>)
|
||||||
|
#define VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD_WITH_POLICY(Name, Policy) \
|
||||||
|
template VTKM_FILTER_EXPORT vtkm::cont::PartitionedDataSet Filter<Name>::Execute( \
|
||||||
|
vtkm::cont::PartitionedDataSet const&, vtkm::filter::PolicyBase<Policy>)
|
||||||
|
|
||||||
|
#define VTKM_FILTER_EXPORT_EXECUTE_METHOD(Name) \
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD_WITH_POLICY(Name, vtkm::filter::PolicyDefault)
|
||||||
|
#define VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(Name) \
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD_WITH_POLICY(Name, vtkm::filter::PolicyDefault)
|
||||||
|
|
||||||
#include <vtkm/filter/Filter.hxx>
|
#include <vtkm/filter/Filter.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
@ -147,7 +147,7 @@ template <typename Derived, typename DerivedPolicy>
|
|||||||
void CallMapFieldOntoOutput(Derived* self,
|
void CallMapFieldOntoOutput(Derived* self,
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
vtkm::cont::DataSet& output,
|
vtkm::cont::DataSet& output,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
using call_supported_t = typename SupportsMapFieldOntoOutput<Derived, DerivedPolicy>::type;
|
using call_supported_t = typename SupportsMapFieldOntoOutput<Derived, DerivedPolicy>::type;
|
||||||
CallMapFieldOntoOutputInternal(call_supported_t(), self, input, output, policy);
|
CallMapFieldOntoOutputInternal(call_supported_t(), self, input, output, policy);
|
||||||
@ -264,9 +264,9 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet Filter<Derived>::Execute(
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(
|
VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
VTKM_LOG_SCOPE(
|
VTKM_LOG_SCOPE(
|
||||||
vtkm::cont::LogLevel::Perf, "Filter: '%s'", vtkm::cont::TypeToString<Derived>().c_str());
|
vtkm::cont::LogLevel::Perf, "Filter: '%s'", vtkm::cont::TypeToString<Derived>().c_str());
|
||||||
@ -284,9 +284,9 @@ inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::PartitionedDataSet Filter<Derived>::Execute(
|
VTKM_CONT vtkm::cont::PartitionedDataSet Filter<Derived>::Execute(
|
||||||
const vtkm::cont::PartitionedDataSet& input,
|
const vtkm::cont::PartitionedDataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf,
|
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf,
|
||||||
"Filter (PartitionedDataSet): '%s'",
|
"Filter (PartitionedDataSet): '%s'",
|
||||||
@ -311,7 +311,7 @@ template <typename DerivedPolicy>
|
|||||||
inline VTKM_CONT void Filter<Derived>::MapFieldsToPass(
|
inline VTKM_CONT void Filter<Derived>::MapFieldsToPass(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
vtkm::cont::DataSet& output,
|
vtkm::cont::DataSet& output,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
Derived* self = static_cast<Derived*>(this);
|
Derived* self = static_cast<Derived*>(this);
|
||||||
for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc)
|
for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc)
|
||||||
|
@ -51,12 +51,11 @@ public:
|
|||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::Field& field,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::DataSet& input,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::Id CoordinateSystemIndex;
|
vtkm::Id CoordinateSystemIndex;
|
||||||
|
@ -38,7 +38,7 @@ template <typename Derived>
|
|||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet FilterDataSet<Derived>::PrepareForExecution(
|
inline VTKM_CONT vtkm::cont::DataSet FilterDataSet<Derived>::PrepareForExecution(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
return (static_cast<Derived*>(this))->DoExecute(input, policy);
|
return (static_cast<Derived*>(this))->DoExecute(input, policy);
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ template <typename DerivedPolicy>
|
|||||||
inline VTKM_CONT bool FilterDataSet<Derived>::MapFieldOntoOutput(
|
inline VTKM_CONT bool FilterDataSet<Derived>::MapFieldOntoOutput(
|
||||||
vtkm::cont::DataSet& result,
|
vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::Field& field,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
|
@ -77,26 +77,23 @@ public:
|
|||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::Field& field,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::DataSet& input,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::cont::Field& field,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
|
|
||||||
//How do we specify float/double coordinate types?
|
//How do we specify float/double coordinate types?
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::CoordinateSystem& field,
|
||||||
const vtkm::cont::CoordinateSystem& field,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
|
|
||||||
std::string OutputFieldName;
|
std::string OutputFieldName;
|
||||||
vtkm::Id CoordinateSystemIndex;
|
vtkm::Id CoordinateSystemIndex;
|
||||||
|
@ -49,7 +49,7 @@ template <typename Derived>
|
|||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareForExecution(
|
inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareForExecution(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
if (this->UseCoordinateSystemAsField)
|
if (this->UseCoordinateSystemAsField)
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ template <typename DerivedPolicy>
|
|||||||
inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareForExecution(
|
inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareForExecution(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::Field& field,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
vtkm::filter::FieldMetadata metaData(field);
|
vtkm::filter::FieldMetadata metaData(field);
|
||||||
vtkm::cont::DataSet result;
|
vtkm::cont::DataSet result;
|
||||||
@ -92,7 +92,7 @@ template <typename DerivedPolicy>
|
|||||||
inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareForExecution(
|
inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareForExecution(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::CoordinateSystem& field,
|
const vtkm::cont::CoordinateSystem& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
//We have a special signature just for CoordinateSystem, so that we can ask
|
//We have a special signature just for CoordinateSystem, so that we can ask
|
||||||
//the policy for the storage types and value types just for coordinate systems
|
//the policy for the storage types and value types just for coordinate systems
|
||||||
@ -122,7 +122,7 @@ template <typename DerivedPolicy>
|
|||||||
inline VTKM_CONT bool FilterDataSetWithField<Derived>::MapFieldOntoOutput(
|
inline VTKM_CONT bool FilterDataSetWithField<Derived>::MapFieldOntoOutput(
|
||||||
vtkm::cont::DataSet& result,
|
vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::Field& field,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
|
@ -83,21 +83,18 @@ public:
|
|||||||
//@{
|
//@{
|
||||||
/// These are provided to satisfy the Filter API requirements.
|
/// These are provided to satisfy the Filter API requirements.
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::DataSet& input,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::cont::Field& field,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::CoordinateSystem& field,
|
||||||
const vtkm::cont::CoordinateSystem& field,
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -46,9 +46,9 @@ inline VTKM_CONT FilterField<Derived>::~FilterField()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
if (this->UseCoordinateSystemAsField)
|
if (this->UseCoordinateSystemAsField)
|
||||||
{
|
{
|
||||||
@ -67,10 +67,10 @@ inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::Field& field,
|
const vtkm::cont::Field& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
vtkm::filter::FieldMetadata metaData(field);
|
vtkm::filter::FieldMetadata metaData(field);
|
||||||
vtkm::cont::DataSet result;
|
vtkm::cont::DataSet result;
|
||||||
@ -89,10 +89,10 @@ inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::CoordinateSystem& field,
|
const vtkm::cont::CoordinateSystem& field,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
//We have a special signature just for CoordinateSystem, so that we can ask
|
//We have a special signature just for CoordinateSystem, so that we can ask
|
||||||
//the policy for the storage types and value types just for coordinate systems
|
//the policy for the storage types and value types just for coordinate systems
|
||||||
|
@ -328,7 +328,7 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
|
|||||||
extract.SetFieldsToPass(this->GetActiveFieldName(),
|
extract.SetFieldsToPass(this->GetActiveFieldName(),
|
||||||
vtkm::filter::FieldSelection::MODE_EXCLUDE);
|
vtkm::filter::FieldSelection::MODE_EXCLUDE);
|
||||||
|
|
||||||
auto output = extract.Execute(input, vtkm::filter::GhostCellRemovePolicy());
|
auto output = extract.Execute(input);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#ifndef vtk_m_filter_Mask_h
|
#ifndef vtk_m_filter_Mask_h
|
||||||
#define vtk_m_filter_Mask_h
|
#define vtk_m_filter_Mask_h
|
||||||
|
|
||||||
#include <vtkm/filter/CleanGrid.h>
|
|
||||||
#include <vtkm/filter/FilterDataSet.h>
|
#include <vtkm/filter/FilterDataSet.h>
|
||||||
#include <vtkm/worklet/Mask.h>
|
#include <vtkm/worklet/Mask.h>
|
||||||
|
|
||||||
|
@ -8,24 +8,6 @@
|
|||||||
// PURPOSE. See the above copyright notice for more information.
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
// Needed to CompactPoints
|
|
||||||
template <typename BasePolicy>
|
|
||||||
struct CellSetSingleTypePolicy : public BasePolicy
|
|
||||||
{
|
|
||||||
using AllCellSetList = vtkm::cont::CellSetListTagUnstructured;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
inline vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>> GetCellSetSingleTypePolicy(
|
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
|
||||||
{
|
|
||||||
return vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
namespace filter
|
namespace filter
|
||||||
@ -64,7 +46,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(
|
|||||||
{
|
{
|
||||||
this->Compactor.SetCompactPointFields(true);
|
this->Compactor.SetCompactPointFields(true);
|
||||||
this->Compactor.SetMergePoints(false);
|
this->Compactor.SetMergePoints(false);
|
||||||
return this->Compactor.DoExecute(output, GetCellSetSingleTypePolicy(policy));
|
return this->Compactor.Execute(output, PolicyDefault{});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
22
vtkm/filter/PointAverage.cxx
Normal file
22
vtkm/filter/PointAverage.cxx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_PointAverage_cxx
|
||||||
|
|
||||||
|
#include <vtkm/filter/PointAverage.h>
|
||||||
|
#include <vtkm/filter/PointAverage.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(PointAverage);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,9 @@
|
|||||||
#ifndef vtk_m_filter_PointAverage_h
|
#ifndef vtk_m_filter_PointAverage_h
|
||||||
#define vtk_m_filter_PointAverage_h
|
#define vtk_m_filter_PointAverage_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||||
#include <vtkm/filter/FilterCell.h>
|
#include <vtkm/filter/FilterCell.h>
|
||||||
#include <vtkm/worklet/PointAverage.h>
|
#include <vtkm/worklet/PointAverage.h>
|
||||||
|
|
||||||
@ -24,24 +27,23 @@ namespace filter
|
|||||||
/// specified per cell) into point data (i.e., data specified at cell
|
/// specified per cell) into point data (i.e., data specified at cell
|
||||||
/// points). The method of transformation is based on averaging the data
|
/// points). The method of transformation is based on averaging the data
|
||||||
/// values of all cells using a particular point.
|
/// values of all cells using a particular point.
|
||||||
class PointAverage : public vtkm::filter::FilterCell<PointAverage>
|
class VTKM_ALWAYS_EXPORT PointAverage : public vtkm::filter::FilterCell<PointAverage>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VTKM_CONT
|
|
||||||
PointAverage();
|
|
||||||
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::worklet::PointAverage Worklet;
|
vtkm::worklet::PointAverage Worklet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_PointAverage_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(PointAverage);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/PointAverage.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_PointAverage_h
|
#endif // vtk_m_filter_PointAverage_h
|
||||||
|
@ -16,20 +16,13 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT PointAverage::PointAverage()
|
|
||||||
: vtkm::filter::FilterCell<PointAverage>()
|
|
||||||
, Worklet()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet PointAverage::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet PointAverage::DoExecute(
|
||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
|
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
|
||||||
const vtkm::filter::FieldMetadata& fieldMetadata,
|
const vtkm::filter::FieldMetadata& fieldMetadata,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
if (!fieldMetadata.IsCellField())
|
if (!fieldMetadata.IsCellField())
|
||||||
{
|
{
|
||||||
|
21
vtkm/filter/Threshold.cxx
Normal file
21
vtkm/filter/Threshold.cxx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_Threshold_cxx
|
||||||
|
#include <vtkm/filter/Threshold.h>
|
||||||
|
#include <vtkm/filter/Threshold.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(Threshold);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef vtk_m_filter_Threshold_h
|
#ifndef vtk_m_filter_Threshold_h
|
||||||
#define vtk_m_filter_Threshold_h
|
#define vtk_m_filter_Threshold_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||||
#include <vtkm/worklet/Threshold.h>
|
#include <vtkm/worklet/Threshold.h>
|
||||||
|
|
||||||
@ -28,14 +30,11 @@ namespace filter
|
|||||||
/// filter is an permutation of the input dataset.
|
/// filter is an permutation of the input dataset.
|
||||||
///
|
///
|
||||||
/// You can threshold either on point or cell fields
|
/// You can threshold either on point or cell fields
|
||||||
class Threshold : public vtkm::filter::FilterDataSetWithField<Threshold>
|
class VTKM_ALWAYS_EXPORT Threshold : public vtkm::filter::FilterDataSetWithField<Threshold>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using SupportedTypes = vtkm::TypeListTagScalarAll;
|
using SupportedTypes = vtkm::TypeListTagScalarAll;
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
Threshold();
|
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void SetLowerThreshold(vtkm::Float64 value) { this->LowerValue = value; }
|
void SetLowerThreshold(vtkm::Float64 value) { this->LowerValue = value; }
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
@ -58,16 +57,36 @@ public:
|
|||||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
|
{
|
||||||
|
if (fieldMeta.IsPointField())
|
||||||
|
{
|
||||||
|
//we copy the input handle to the result dataset, reusing the metadata
|
||||||
|
result.AddField(fieldMeta.AsField(input));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (fieldMeta.IsCellField())
|
||||||
|
{
|
||||||
|
vtkm::cont::ArrayHandle<T> out = this->Worklet.ProcessCellField(input);
|
||||||
|
result.AddField(fieldMeta.AsField(out));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double LowerValue;
|
double LowerValue = 0;
|
||||||
double UpperValue;
|
double UpperValue = 0;
|
||||||
vtkm::worklet::Threshold Worklet;
|
vtkm::worklet::Threshold Worklet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef vtkm_filter_Threshold_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(Threshold);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/Threshold.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_Threshold_h
|
#endif // vtk_m_filter_Threshold_h
|
||||||
|
@ -44,14 +44,6 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT Threshold::Threshold()
|
|
||||||
: vtkm::filter::FilterDataSetWithField<Threshold>()
|
|
||||||
, LowerValue(0)
|
|
||||||
, UpperValue(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet Threshold::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet Threshold::DoExecute(
|
||||||
@ -72,30 +64,5 @@ inline VTKM_CONT vtkm::cont::DataSet Threshold::DoExecute(
|
|||||||
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
||||||
inline VTKM_CONT bool Threshold::DoMapField(vtkm::cont::DataSet& result,
|
|
||||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
|
||||||
{
|
|
||||||
if (fieldMeta.IsPointField())
|
|
||||||
{
|
|
||||||
//we copy the input handle to the result dataset, reusing the metadata
|
|
||||||
result.AddField(fieldMeta.AsField(input));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (fieldMeta.IsCellField())
|
|
||||||
{
|
|
||||||
vtkm::cont::ArrayHandle<T> out = this->Worklet.ProcessCellField(input);
|
|
||||||
result.AddField(fieldMeta.AsField(out));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,21 +12,6 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
// Needed to CompactPoints
|
|
||||||
template <typename BasePolicy>
|
|
||||||
struct CellSetSingleTypePolicy : public BasePolicy
|
|
||||||
{
|
|
||||||
using AllCellSetList = vtkm::cont::CellSetListTagUnstructured;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
|
||||||
inline vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>> GetCellSetSingleTypePolicy(
|
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
|
||||||
{
|
|
||||||
return vtkm::filter::PolicyBase<CellSetSingleTypePolicy<DerivedPolicy>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Predicate for values less than minimum
|
// Predicate for values less than minimum
|
||||||
class ValuesBelow
|
class ValuesBelow
|
||||||
{
|
{
|
||||||
@ -191,7 +176,7 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(
|
|||||||
{
|
{
|
||||||
this->Compactor.SetCompactPointFields(true);
|
this->Compactor.SetCompactPointFields(true);
|
||||||
this->Compactor.SetMergePoints(true);
|
this->Compactor.SetMergePoints(true);
|
||||||
return this->Compactor.DoExecute(output, GetCellSetSingleTypePolicy(policy));
|
return this->Compactor.Execute(output, PolicyDefault{});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
31
vtkm/filter/VectorMagnitude.cxx
Normal file
31
vtkm/filter/VectorMagnitude.cxx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_VectorMagnitude_cxx
|
||||||
|
|
||||||
|
#include <vtkm/filter/VectorMagnitude.h>
|
||||||
|
#include <vtkm/filter/VectorMagnitude.hxx>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace filter
|
||||||
|
{
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VectorMagnitude::VectorMagnitude()
|
||||||
|
: vtkm::filter::FilterField<VectorMagnitude>()
|
||||||
|
, Worklet()
|
||||||
|
{
|
||||||
|
this->SetOutputFieldName("magnitude");
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
VTKM_FILTER_INSTANTIATE_EXECUTE_METHOD(VectorMagnitude);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef vtk_m_filter_VectorMagnitude_h
|
#ifndef vtk_m_filter_VectorMagnitude_h
|
||||||
#define vtk_m_filter_VectorMagnitude_h
|
#define vtk_m_filter_VectorMagnitude_h
|
||||||
|
|
||||||
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/filter/FilterField.h>
|
#include <vtkm/filter/FilterField.h>
|
||||||
#include <vtkm/worklet/Magnitude.h>
|
#include <vtkm/worklet/Magnitude.h>
|
||||||
|
|
||||||
@ -19,13 +21,13 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
class VectorMagnitude : public vtkm::filter::FilterField<VectorMagnitude>
|
class VTKM_ALWAYS_EXPORT VectorMagnitude : public vtkm::filter::FilterField<VectorMagnitude>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//currently the VectorMagnitude filter only works on vector data.
|
//currently the VectorMagnitude filter only works on vector data.
|
||||||
using SupportedTypes = vtkm::TypeListTagVecCommon;
|
using SupportedTypes = vtkm::TypeListTagVecCommon;
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_FILTER_EXPORT
|
||||||
VectorMagnitude();
|
VectorMagnitude();
|
||||||
|
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
@ -37,9 +39,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
vtkm::worklet::Magnitude Worklet;
|
vtkm::worklet::Magnitude Worklet;
|
||||||
};
|
};
|
||||||
|
#ifndef vtkm_filter_VectorMagnitude_cxx
|
||||||
|
VTKM_FILTER_EXPORT_EXECUTE_METHOD(VectorMagnitude);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace vtkm::filter
|
} // namespace vtkm::filter
|
||||||
|
|
||||||
#include <vtkm/filter/VectorMagnitude.hxx>
|
|
||||||
|
|
||||||
#endif // vtk_m_filter_VectorMagnitude_h
|
#endif // vtk_m_filter_VectorMagnitude_h
|
||||||
|
@ -15,14 +15,6 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
inline VTKM_CONT VectorMagnitude::VectorMagnitude()
|
|
||||||
: vtkm::filter::FilterField<VectorMagnitude>()
|
|
||||||
, Worklet()
|
|
||||||
{
|
|
||||||
this->SetOutputFieldName("magnitude");
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet VectorMagnitude::DoExecute(
|
inline VTKM_CONT vtkm::cont::DataSet VectorMagnitude::DoExecute(
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <vtkm/filter/CleanGrid.h>
|
#include <vtkm/filter/CleanGrid.h>
|
||||||
|
|
||||||
#include <vtkm/filter/Contour.h>
|
#include <vtkm/filter/Contour.h>
|
||||||
|
#include <vtkm/filter/Contour.hxx>
|
||||||
#include <vtkm/source/Tangle.h>
|
#include <vtkm/source/Tangle.h>
|
||||||
|
|
||||||
namespace vtkm_ut_mc_filter
|
namespace vtkm_ut_mc_filter
|
||||||
|
@ -242,12 +242,12 @@ void TestWithStructuredData()
|
|||||||
contour.SetGenerateNormals(true);
|
contour.SetGenerateNormals(true);
|
||||||
contour.SetComputeFastNormalsForStructured(true);
|
contour.SetComputeFastNormalsForStructured(true);
|
||||||
contour.SetNormalArrayName("normals");
|
contour.SetNormalArrayName("normals");
|
||||||
dataSet = contour.Execute(dataSet, SplitSharpTestPolicy{});
|
dataSet = contour.Execute(dataSet);
|
||||||
|
|
||||||
// Compute cell normals:
|
// Compute cell normals:
|
||||||
vtkm::filter::CellAverage cellNormals;
|
vtkm::filter::CellAverage cellNormals;
|
||||||
cellNormals.SetActiveField("normals", vtkm::cont::Field::Association::POINTS);
|
cellNormals.SetActiveField("normals", vtkm::cont::Field::Association::POINTS);
|
||||||
dataSet = cellNormals.Execute(dataSet, SplitSharpTestPolicy{});
|
dataSet = cellNormals.Execute(dataSet);
|
||||||
|
|
||||||
// Split sharp edges:
|
// Split sharp edges:
|
||||||
std::cout << dataSet.GetNumberOfCells() << std::endl;
|
std::cout << dataSet.GetNumberOfCells() << std::endl;
|
||||||
|
@ -97,6 +97,7 @@ set(headers
|
|||||||
|
|
||||||
set(header_impls
|
set(header_impls
|
||||||
ScalarsToColors.hxx
|
ScalarsToColors.hxx
|
||||||
|
Keys.hxx
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +109,8 @@ set(sources_no_device
|
|||||||
# This is a list of sources that has code that runs on devices and might need to
|
# This is a list of sources that has code that runs on devices and might need to
|
||||||
# be compiled with a device-specific compiler (like CUDA).
|
# be compiled with a device-specific compiler (like CUDA).
|
||||||
set(sources_device
|
set(sources_device
|
||||||
Keys.cxx
|
KeysUnsignedTypes.cxx
|
||||||
|
KeysSignedTypes.cxx
|
||||||
MaskSelect.cxx
|
MaskSelect.cxx
|
||||||
ScatterCounting.cxx
|
ScatterCounting.cxx
|
||||||
)
|
)
|
||||||
|
@ -96,27 +96,10 @@ public:
|
|||||||
/// efficient for stable sorted arrays, but requires an extra copy of the
|
/// efficient for stable sorted arrays, but requires an extra copy of the
|
||||||
/// keys for unstable sorting.
|
/// keys for unstable sorting.
|
||||||
template <typename KeyArrayType>
|
template <typename KeyArrayType>
|
||||||
VTKM_CONT void BuildArrays(const KeyArrayType& keys,
|
VTKM_CONT void BuildArrays(
|
||||||
KeysSortType sort,
|
const KeyArrayType& keys,
|
||||||
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
|
KeysSortType sort,
|
||||||
{
|
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny());
|
||||||
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArrays");
|
|
||||||
|
|
||||||
switch (sort)
|
|
||||||
{
|
|
||||||
case KeysSortType::Unstable:
|
|
||||||
{
|
|
||||||
KeyArrayHandleType mutableKeys;
|
|
||||||
vtkm::cont::Algorithm::Copy(device, keys, mutableKeys);
|
|
||||||
|
|
||||||
this->BuildArraysInternal(mutableKeys, device);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KeysSortType::Stable:
|
|
||||||
this->BuildArraysInternalStable(keys, device);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build the internal arrays and also sort the input keys. This is more
|
/// Build the internal arrays and also sort the input keys. This is more
|
||||||
/// efficient for unstable sorting, but requires an extra copy for stable
|
/// efficient for unstable sorting, but requires an extra copy for stable
|
||||||
@ -125,28 +108,7 @@ public:
|
|||||||
VTKM_CONT void BuildArraysInPlace(
|
VTKM_CONT void BuildArraysInPlace(
|
||||||
KeyArrayType& keys,
|
KeyArrayType& keys,
|
||||||
KeysSortType sort,
|
KeysSortType sort,
|
||||||
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
|
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny());
|
||||||
{
|
|
||||||
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArraysInPlace");
|
|
||||||
|
|
||||||
switch (sort)
|
|
||||||
{
|
|
||||||
case KeysSortType::Unstable:
|
|
||||||
this->BuildArraysInternal(keys, device);
|
|
||||||
break;
|
|
||||||
case KeysSortType::Stable:
|
|
||||||
{
|
|
||||||
this->BuildArraysInternalStable(keys, device);
|
|
||||||
KeyArrayHandleType tmp;
|
|
||||||
// Copy into a temporary array so that the permutation array copy
|
|
||||||
// won't alias input/output memory:
|
|
||||||
vtkm::cont::Algorithm::Copy(device, keys, tmp);
|
|
||||||
vtkm::cont::Algorithm::Copy(
|
|
||||||
device, vtkm::cont::make_ArrayHandlePermutation(this->SortedValuesMap, tmp), keys);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
vtkm::Id GetInputRange() const { return this->UniqueKeys.GetNumberOfValues(); }
|
vtkm::Id GetInputRange() const { return this->UniqueKeys.GetNumberOfValues(); }
|
||||||
@ -205,61 +167,11 @@ private:
|
|||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> Counts;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> Counts;
|
||||||
|
|
||||||
template <typename KeyArrayType>
|
template <typename KeyArrayType>
|
||||||
VTKM_CONT void BuildArraysInternal(KeyArrayType& keys, vtkm::cont::DeviceAdapterId device)
|
VTKM_CONT void BuildArraysInternal(KeyArrayType& keys, vtkm::cont::DeviceAdapterId device);
|
||||||
{
|
|
||||||
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArraysInternal");
|
|
||||||
|
|
||||||
const vtkm::Id numKeys = keys.GetNumberOfValues();
|
|
||||||
|
|
||||||
vtkm::cont::Algorithm::Copy(
|
|
||||||
device, vtkm::cont::ArrayHandleIndex(numKeys), this->SortedValuesMap);
|
|
||||||
|
|
||||||
// TODO: Do we need the ability to specify a comparison functor for sort?
|
|
||||||
vtkm::cont::Algorithm::SortByKey(device, keys, this->SortedValuesMap);
|
|
||||||
|
|
||||||
// Find the unique keys and the number of values per key.
|
|
||||||
vtkm::cont::Algorithm::ReduceByKey(
|
|
||||||
device,
|
|
||||||
keys,
|
|
||||||
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(1, numKeys),
|
|
||||||
this->UniqueKeys,
|
|
||||||
this->Counts,
|
|
||||||
vtkm::Sum());
|
|
||||||
|
|
||||||
// Get the offsets from the counts with a scan.
|
|
||||||
vtkm::Id offsetsTotal = vtkm::cont::Algorithm::ScanExclusive(
|
|
||||||
device, vtkm::cont::make_ArrayHandleCast(this->Counts, vtkm::Id()), this->Offsets);
|
|
||||||
VTKM_ASSERT(offsetsTotal == numKeys); // Sanity check
|
|
||||||
(void)offsetsTotal; // Shut up, compiler
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename KeyArrayType>
|
template <typename KeyArrayType>
|
||||||
VTKM_CONT void BuildArraysInternalStable(const KeyArrayType& keys,
|
VTKM_CONT void BuildArraysInternalStable(const KeyArrayType& keys,
|
||||||
vtkm::cont::DeviceAdapterId device)
|
vtkm::cont::DeviceAdapterId device);
|
||||||
{
|
|
||||||
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArraysInternalStable");
|
|
||||||
|
|
||||||
const vtkm::Id numKeys = keys.GetNumberOfValues();
|
|
||||||
|
|
||||||
// Produce a stable sorted map of the keys:
|
|
||||||
this->SortedValuesMap = StableSortIndices::Sort(device, keys);
|
|
||||||
auto sortedKeys = vtkm::cont::make_ArrayHandlePermutation(this->SortedValuesMap, keys);
|
|
||||||
|
|
||||||
// Find the unique keys and the number of values per key.
|
|
||||||
vtkm::cont::Algorithm::ReduceByKey(
|
|
||||||
device,
|
|
||||||
sortedKeys,
|
|
||||||
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(1, numKeys),
|
|
||||||
this->UniqueKeys,
|
|
||||||
this->Counts,
|
|
||||||
vtkm::Sum());
|
|
||||||
|
|
||||||
// Get the offsets from the counts with a scan.
|
|
||||||
vtkm::Id offsetsTotal = vtkm::cont::Algorithm::ScanExclusive(
|
|
||||||
vtkm::cont::make_ArrayHandleCast(this->Counts, vtkm::Id()), this->Offsets);
|
|
||||||
VTKM_ASSERT(offsetsTotal == numKeys); // Sanity check
|
|
||||||
(void)offsetsTotal; // Shut up, compiler
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -433,9 +345,13 @@ struct Transport<vtkm::cont::arg::TransportTagKeyedValuesOut, ArrayHandleType, D
|
|||||||
vtkm::worklet::KeysSortType sort, \
|
vtkm::worklet::KeysSortType sort, \
|
||||||
vtkm::cont::DeviceAdapterId device)
|
vtkm::cont::DeviceAdapterId device)
|
||||||
|
|
||||||
|
VTK_M_KEYS_EXPORT(vtkm::UInt8);
|
||||||
VTK_M_KEYS_EXPORT(vtkm::HashType);
|
VTK_M_KEYS_EXPORT(vtkm::HashType);
|
||||||
VTK_M_KEYS_EXPORT(vtkm::Id);
|
VTK_M_KEYS_EXPORT(vtkm::Id);
|
||||||
|
VTK_M_KEYS_EXPORT(vtkm::Id2);
|
||||||
VTK_M_KEYS_EXPORT(vtkm::Id3);
|
VTK_M_KEYS_EXPORT(vtkm::Id3);
|
||||||
|
using Pair_UInt8_Id2 = vtkm::Pair<vtkm::UInt8, vtkm::Id2>;
|
||||||
|
VTK_M_KEYS_EXPORT(Pair_UInt8_Id2);
|
||||||
#ifdef VTKM_USE_64BIT_IDS
|
#ifdef VTKM_USE_64BIT_IDS
|
||||||
VTK_M_KEYS_EXPORT(vtkm::IdComponent);
|
VTK_M_KEYS_EXPORT(vtkm::IdComponent);
|
||||||
#endif
|
#endif
|
||||||
|
133
vtkm/worklet/Keys.hxx
Normal file
133
vtkm/worklet/Keys.hxx
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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_worklet_Keys_hxx
|
||||||
|
#define vtk_m_worklet_Keys_hxx
|
||||||
|
|
||||||
|
#include <vtkm/worklet/Keys.h>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace worklet
|
||||||
|
{
|
||||||
|
/// Build the internal arrays without modifying the input. This is more
|
||||||
|
/// efficient for stable sorted arrays, but requires an extra copy of the
|
||||||
|
/// keys for unstable sorting.
|
||||||
|
template <typename T>
|
||||||
|
template <typename KeyArrayType>
|
||||||
|
VTKM_CONT void Keys<T>::BuildArrays(const KeyArrayType& keys,
|
||||||
|
KeysSortType sort,
|
||||||
|
vtkm::cont::DeviceAdapterId device)
|
||||||
|
{
|
||||||
|
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArrays");
|
||||||
|
|
||||||
|
switch (sort)
|
||||||
|
{
|
||||||
|
case KeysSortType::Unstable:
|
||||||
|
{
|
||||||
|
KeyArrayHandleType mutableKeys;
|
||||||
|
vtkm::cont::Algorithm::Copy(device, keys, mutableKeys);
|
||||||
|
|
||||||
|
this->BuildArraysInternal(mutableKeys, device);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KeysSortType::Stable:
|
||||||
|
this->BuildArraysInternalStable(keys, device);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build the internal arrays and also sort the input keys. This is more
|
||||||
|
/// efficient for unstable sorting, but requires an extra copy for stable
|
||||||
|
/// sorting.
|
||||||
|
template <typename T>
|
||||||
|
template <typename KeyArrayType>
|
||||||
|
VTKM_CONT void Keys<T>::BuildArraysInPlace(KeyArrayType& keys,
|
||||||
|
KeysSortType sort,
|
||||||
|
vtkm::cont::DeviceAdapterId device)
|
||||||
|
{
|
||||||
|
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArraysInPlace");
|
||||||
|
|
||||||
|
switch (sort)
|
||||||
|
{
|
||||||
|
case KeysSortType::Unstable:
|
||||||
|
this->BuildArraysInternal(keys, device);
|
||||||
|
break;
|
||||||
|
case KeysSortType::Stable:
|
||||||
|
{
|
||||||
|
this->BuildArraysInternalStable(keys, device);
|
||||||
|
KeyArrayHandleType tmp;
|
||||||
|
// Copy into a temporary array so that the permutation array copy
|
||||||
|
// won't alias input/output memory:
|
||||||
|
vtkm::cont::Algorithm::Copy(device, keys, tmp);
|
||||||
|
vtkm::cont::Algorithm::Copy(
|
||||||
|
device, vtkm::cont::make_ArrayHandlePermutation(this->SortedValuesMap, tmp), keys);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
template <typename KeyArrayType>
|
||||||
|
VTKM_CONT void Keys<T>::BuildArraysInternal(KeyArrayType& keys, vtkm::cont::DeviceAdapterId device)
|
||||||
|
{
|
||||||
|
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArraysInternal");
|
||||||
|
|
||||||
|
const vtkm::Id numKeys = keys.GetNumberOfValues();
|
||||||
|
|
||||||
|
vtkm::cont::Algorithm::Copy(device, vtkm::cont::ArrayHandleIndex(numKeys), this->SortedValuesMap);
|
||||||
|
|
||||||
|
// TODO: Do we need the ability to specify a comparison functor for sort?
|
||||||
|
vtkm::cont::Algorithm::SortByKey(device, keys, this->SortedValuesMap);
|
||||||
|
|
||||||
|
// Find the unique keys and the number of values per key.
|
||||||
|
vtkm::cont::Algorithm::ReduceByKey(device,
|
||||||
|
keys,
|
||||||
|
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(1, numKeys),
|
||||||
|
this->UniqueKeys,
|
||||||
|
this->Counts,
|
||||||
|
vtkm::Sum());
|
||||||
|
|
||||||
|
// Get the offsets from the counts with a scan.
|
||||||
|
vtkm::Id offsetsTotal = vtkm::cont::Algorithm::ScanExclusive(
|
||||||
|
device, vtkm::cont::make_ArrayHandleCast(this->Counts, vtkm::Id()), this->Offsets);
|
||||||
|
VTKM_ASSERT(offsetsTotal == numKeys); // Sanity check
|
||||||
|
(void)offsetsTotal; // Shut up, compiler
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
template <typename KeyArrayType>
|
||||||
|
VTKM_CONT void Keys<T>::BuildArraysInternalStable(const KeyArrayType& keys,
|
||||||
|
vtkm::cont::DeviceAdapterId device)
|
||||||
|
{
|
||||||
|
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf, "Keys::BuildArraysInternalStable");
|
||||||
|
|
||||||
|
const vtkm::Id numKeys = keys.GetNumberOfValues();
|
||||||
|
|
||||||
|
// Produce a stable sorted map of the keys:
|
||||||
|
this->SortedValuesMap = StableSortIndices::Sort(device, keys);
|
||||||
|
auto sortedKeys = vtkm::cont::make_ArrayHandlePermutation(this->SortedValuesMap, keys);
|
||||||
|
|
||||||
|
// Find the unique keys and the number of values per key.
|
||||||
|
vtkm::cont::Algorithm::ReduceByKey(device,
|
||||||
|
sortedKeys,
|
||||||
|
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>(1, numKeys),
|
||||||
|
this->UniqueKeys,
|
||||||
|
this->Counts,
|
||||||
|
vtkm::Sum());
|
||||||
|
|
||||||
|
// Get the offsets from the counts with a scan.
|
||||||
|
vtkm::Id offsetsTotal = vtkm::cont::Algorithm::ScanExclusive(
|
||||||
|
vtkm::cont::make_ArrayHandleCast(this->Counts, vtkm::Id()), this->Offsets);
|
||||||
|
VTKM_ASSERT(offsetsTotal == numKeys); // Sanity check
|
||||||
|
(void)offsetsTotal; // Shut up, compiler
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#define vtk_m_worklet_Keys_cxx
|
#define vtk_m_worklet_Keys_cxx
|
||||||
#include <vtkm/worklet/Keys.h>
|
#include <vtkm/worklet/Keys.h>
|
||||||
|
#include <vtkm/worklet/Keys.hxx>
|
||||||
|
|
||||||
#define VTK_M_KEYS_EXPORT(T) \
|
#define VTK_M_KEYS_EXPORT(T) \
|
||||||
template class VTKM_WORKLET_EXPORT vtkm::worklet::Keys<T>; \
|
template class VTKM_WORKLET_EXPORT vtkm::worklet::Keys<T>; \
|
||||||
@ -22,8 +23,8 @@
|
|||||||
vtkm::worklet::KeysSortType sort, \
|
vtkm::worklet::KeysSortType sort, \
|
||||||
vtkm::cont::DeviceAdapterId device)
|
vtkm::cont::DeviceAdapterId device)
|
||||||
|
|
||||||
VTK_M_KEYS_EXPORT(vtkm::HashType);
|
|
||||||
VTK_M_KEYS_EXPORT(vtkm::Id);
|
VTK_M_KEYS_EXPORT(vtkm::Id);
|
||||||
|
VTK_M_KEYS_EXPORT(vtkm::Id2);
|
||||||
VTK_M_KEYS_EXPORT(vtkm::Id3);
|
VTK_M_KEYS_EXPORT(vtkm::Id3);
|
||||||
#ifdef VTKM_USE_64BIT_IDS
|
#ifdef VTKM_USE_64BIT_IDS
|
||||||
VTK_M_KEYS_EXPORT(vtkm::IdComponent);
|
VTK_M_KEYS_EXPORT(vtkm::IdComponent);
|
32
vtkm/worklet/KeysUnsignedTypes.cxx
Normal file
32
vtkm/worklet/KeysUnsignedTypes.cxx
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.
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#define vtk_m_worklet_Keys_cxx
|
||||||
|
#include <vtkm/worklet/Keys.h>
|
||||||
|
#include <vtkm/worklet/Keys.hxx>
|
||||||
|
|
||||||
|
#define VTK_M_KEYS_EXPORT(T) \
|
||||||
|
template class VTKM_WORKLET_EXPORT vtkm::worklet::Keys<T>; \
|
||||||
|
template VTKM_WORKLET_EXPORT VTKM_CONT void vtkm::worklet::Keys<T>::BuildArrays( \
|
||||||
|
const vtkm::cont::ArrayHandle<T>& keys, \
|
||||||
|
vtkm::worklet::KeysSortType sort, \
|
||||||
|
vtkm::cont::DeviceAdapterId device); \
|
||||||
|
template VTKM_WORKLET_EXPORT VTKM_CONT void vtkm::worklet::Keys<T>::BuildArrays( \
|
||||||
|
const vtkm::cont::ArrayHandleVirtual<T>& keys, \
|
||||||
|
vtkm::worklet::KeysSortType sort, \
|
||||||
|
vtkm::cont::DeviceAdapterId device)
|
||||||
|
|
||||||
|
VTK_M_KEYS_EXPORT(vtkm::HashType);
|
||||||
|
VTK_M_KEYS_EXPORT(vtkm::UInt8);
|
||||||
|
using Pair_UInt8_Id2 = vtkm::Pair<vtkm::UInt8, vtkm::Id2>;
|
||||||
|
VTK_M_KEYS_EXPORT(Pair_UInt8_Id2);
|
||||||
|
|
||||||
|
|
||||||
|
#undef VTK_M_KEYS_EXPORT
|
@ -88,7 +88,7 @@ set(unit_tests
|
|||||||
|
|
||||||
vtkm_unit_tests(
|
vtkm_unit_tests(
|
||||||
SOURCES ${unit_tests}
|
SOURCES ${unit_tests}
|
||||||
LIBRARIES vtkm_worklet vtkm_source
|
LIBRARIES vtkm_source vtkm_worklet vtkm_filter
|
||||||
ALL_BACKENDS
|
ALL_BACKENDS
|
||||||
)
|
)
|
||||||
if (TARGET vtkm::cuda)
|
if (TARGET vtkm::cuda)
|
||||||
|
@ -71,7 +71,7 @@ vtkm::cont::DataSet CreateDataSet(bool pointNormals, bool cellNormals)
|
|||||||
contour.SetIsoValue(192);
|
contour.SetIsoValue(192);
|
||||||
contour.SetMergeDuplicatePoints(true);
|
contour.SetMergeDuplicatePoints(true);
|
||||||
contour.SetGenerateNormals(false);
|
contour.SetGenerateNormals(false);
|
||||||
dataSet = contour.Execute(dataSet, TestPolicy{});
|
dataSet = contour.Execute(dataSet);
|
||||||
|
|
||||||
vtkm::filter::SurfaceNormals normals;
|
vtkm::filter::SurfaceNormals normals;
|
||||||
normals.SetGeneratePointNormals(pointNormals);
|
normals.SetGeneratePointNormals(pointNormals);
|
||||||
|
Loading…
Reference in New Issue
Block a user