mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Merge topic 'marching-cubes-instantiations'
db2dbbbcc Simplify MarchingCells execute method 0ee495f31 Split the compilation of ContourMarchingCells into instantiations Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3089
This commit is contained in:
commit
99c548ef52
@ -9,3 +9,6 @@ Although `Contour` is still the preferred option for most cases because it selec
|
||||
Deprecate functions `GetComputeFastNormalsForStructured`, `SetComputeFastNormalsForStructured`, `GetComputeFastNormalsForUnstructured` and `GetComputeFastNormalsForUnstructured`, to use the more general `GetComputeFastNormals` and `SetComputeFastNormals` instead.
|
||||
|
||||
By default, for the `Contour` filter, `GenerateNormals` is now `true`, and `ComputeFastNormals` is `false`.
|
||||
|
||||
The marching cubes version of contour still has several possible compile paths, so it can still take a bit to compile. To help manage the compile time further, the contour filter compilation is broken up even further using the instantiation build capabilities.
|
||||
|
||||
|
@ -34,6 +34,9 @@ set(contour_sources
|
||||
Contour.cxx
|
||||
)
|
||||
|
||||
vtkm_add_instantiations(contour_instantiations INSTANTIATIONS_FILE worklet/ContourMarchingCells.h)
|
||||
list(APPEND contour_sources_device ${contour_instantiations})
|
||||
|
||||
set_source_files_properties(Contour.cxx PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
|
||||
vtkm_library(
|
||||
|
@ -59,12 +59,11 @@ vtkm::cont::DataSet ContourMarchingCells::DoExecute(const vtkm::cont::DataSet& i
|
||||
|
||||
if (this->GenerateNormals && !this->GetComputeFastNormals())
|
||||
{
|
||||
outputCells =
|
||||
worklet.Run(ivalues, inputCells, inputCoords.GetData(), concrete, vertices, normals);
|
||||
outputCells = worklet.Run(ivalues, inputCells, inputCoords, concrete, vertices, normals);
|
||||
}
|
||||
else
|
||||
{
|
||||
outputCells = worklet.Run(ivalues, inputCells, inputCoords.GetData(), concrete, vertices);
|
||||
outputCells = worklet.Run(ivalues, inputCells, inputCoords, concrete, vertices);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -11,10 +11,19 @@
|
||||
#ifndef vtk_m_worklet_ContourMarchingCells_h
|
||||
#define vtk_m_worklet_ContourMarchingCells_h
|
||||
|
||||
#include <vtkm/filter/contour/vtkm_filter_contour_export.h>
|
||||
#include <vtkm/filter/contour/worklet/contour/CommonState.h>
|
||||
#include <vtkm/filter/contour/worklet/contour/FieldPropagation.h>
|
||||
#include <vtkm/filter/contour/worklet/contour/MarchingCells.h>
|
||||
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
|
||||
#include <vtkm/internal/Instantiations.h>
|
||||
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -22,6 +31,7 @@ namespace worklet
|
||||
{
|
||||
namespace contour
|
||||
{
|
||||
|
||||
struct DeduceCoordType
|
||||
{
|
||||
template <typename CoordinateType, typename CellSetType, typename... Args>
|
||||
@ -36,15 +46,41 @@ struct DeduceCoordType
|
||||
|
||||
struct DeduceCellType
|
||||
{
|
||||
template <typename CellSetType, typename CoordinateType, typename... Args>
|
||||
void operator()(const CellSetType& cells, CoordinateType&& coordinateSystem, Args&&... args) const
|
||||
{
|
||||
vtkm::cont::CastAndCall(
|
||||
coordinateSystem, contour::DeduceCoordType{}, cells, std::forward<Args>(args)...);
|
||||
}
|
||||
template <typename CellSetType, typename ValueType, typename StorageTagField>
|
||||
void operator()(const CellSetType& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<ValueType>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
};
|
||||
|
||||
// Declared outside of class, non-inline so that instantiations can be exported correctly.
|
||||
template <typename CellSetType, typename ValueType, typename StorageTagField>
|
||||
void DeduceCellType::operator()(const CellSetType& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<ValueType>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const
|
||||
{
|
||||
vtkm::cont::CastAndCall(coordinateSystem,
|
||||
contour::DeduceCoordType{},
|
||||
cells,
|
||||
outputCells,
|
||||
isovalues,
|
||||
input,
|
||||
vertices,
|
||||
normals,
|
||||
sharedState);
|
||||
}
|
||||
|
||||
} // namespace contour
|
||||
|
||||
/// \brief Compute the isosurface of a given 3D data set, supports all linear cell types
|
||||
class ContourMarchingCells
|
||||
{
|
||||
@ -87,22 +123,18 @@ public:
|
||||
//----------------------------------------------------------------------------
|
||||
void ReleaseCellMapArrays() { this->SharedState.CellIdMap.ReleaseResources(); }
|
||||
|
||||
public:
|
||||
// Filter called without normals generation
|
||||
template <typename ValueType,
|
||||
typename CellSetType,
|
||||
typename CoordinateSystem,
|
||||
typename StorageTagField,
|
||||
typename CoordinateType,
|
||||
typename StorageTagVertices>
|
||||
vtkm::cont::CellSetSingleType<> Run(
|
||||
template <typename ValueType, typename StorageTagField>
|
||||
VTKM_CONT vtkm::cont::CellSetSingleType<> Run(
|
||||
const std::vector<ValueType>& isovalues,
|
||||
const CellSetType& cells,
|
||||
const CoordinateSystem& coordinateSystem,
|
||||
const vtkm::cont::UnknownCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& vertices)
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices)
|
||||
{
|
||||
this->SharedState.GenerateNormals = false;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>> normals;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> normals;
|
||||
|
||||
vtkm::cont::CellSetSingleType<> outputCells;
|
||||
vtkm::cont::CastAndCall(cells,
|
||||
@ -118,20 +150,14 @@ public:
|
||||
}
|
||||
|
||||
// Filter called with normals generation
|
||||
template <typename ValueType,
|
||||
typename CellSetType,
|
||||
typename CoordinateSystem,
|
||||
typename StorageTagField,
|
||||
typename CoordinateType,
|
||||
typename StorageTagVertices,
|
||||
typename StorageTagNormals>
|
||||
vtkm::cont::CellSetSingleType<> Run(
|
||||
template <typename ValueType, typename StorageTagField>
|
||||
VTKM_CONT vtkm::cont::CellSetSingleType<> Run(
|
||||
const std::vector<ValueType>& isovalues,
|
||||
const CellSetType& cells,
|
||||
const CoordinateSystem& coordinateSystem,
|
||||
const vtkm::cont::UnknownCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagNormals>& normals)
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals)
|
||||
{
|
||||
this->SharedState.GenerateNormals = true;
|
||||
|
||||
@ -152,7 +178,100 @@ public:
|
||||
private:
|
||||
vtkm::worklet::contour::CommonState SharedState;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::worklet
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetStructured<2>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float32>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetStructured<2>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float64>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetStructured<3>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float32>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetStructured<3>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float64>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetExplicit<>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float32>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetExplicit<>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float64>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetSingleType<>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float32>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
extern template void vtkm::worklet::contour::DeduceCellType::operator()(
|
||||
const vtkm::cont::CellSetSingleType<>& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinateSystem,
|
||||
vtkm::cont::CellSetSingleType<>& outputCells,
|
||||
const std::vector<vtkm::Float64>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState) const;
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
#endif // vtk_m_worklet_ContourMarchingCells_h
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <vtkm/worklet/ScatterPermutation.h>
|
||||
|
||||
#include <vtkm/filter/contour/worklet/contour/CommonState.h>
|
||||
#include <vtkm/filter/contour/worklet/contour/FieldPropagation.h>
|
||||
#include <vtkm/filter/contour/worklet/contour/MarchingCellTables.h>
|
||||
#include <vtkm/filter/vector_analysis/worklet/gradient/PointGradient.h>
|
||||
#include <vtkm/filter/vector_analysis/worklet/gradient/StructuredPointGradient.h>
|
||||
@ -594,18 +595,14 @@ struct GenerateNormals
|
||||
template <typename CellSetType,
|
||||
typename CoordinateSystem,
|
||||
typename ValueType,
|
||||
typename StorageTagField,
|
||||
typename StorageTagVertices,
|
||||
typename StorageTagNormals,
|
||||
typename CoordinateType,
|
||||
typename NormalType>
|
||||
typename StorageTagField>
|
||||
vtkm::cont::CellSetSingleType<> execute(
|
||||
const CellSetType& cells,
|
||||
const CoordinateSystem& coordinateSystem,
|
||||
const std::vector<ValueType>& isovalues,
|
||||
const vtkm::cont::ArrayHandle<ValueType, StorageTagField>& inputField,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<CoordinateType, 3>, StorageTagVertices>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<NormalType, 3>, StorageTagNormals>& normals,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& vertices,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f>& normals,
|
||||
vtkm::worklet::contour::CommonState& sharedState)
|
||||
{
|
||||
using vtkm::worklet::contour::MapPointField;
|
||||
|
Loading…
Reference in New Issue
Block a user