mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Improve parallelization when compiling filter tests
This commit is contained in:
parent
142d151caf
commit
d7ab1a6084
@ -147,8 +147,13 @@ set(sources_device
|
||||
ClipWithField.cxx
|
||||
ClipWithImplicitFunction.cxx
|
||||
Contour.cxx
|
||||
ContourInteger.cxx
|
||||
ContourScalar.cxx
|
||||
ExternalFaces.cxx
|
||||
ExtractStructured.cxx
|
||||
GradientScalar.cxx
|
||||
GradientUniformPoints.cxx
|
||||
GradientVector.cxx
|
||||
PointAverage.cxx
|
||||
Threshold.cxx
|
||||
VectorMagnitude.cxx
|
||||
|
@ -67,8 +67,5 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -150,8 +150,56 @@ private:
|
||||
vtkm::worklet::Contour Worklet;
|
||||
};
|
||||
|
||||
#ifndef vtkm_filter_Contour_cxx
|
||||
VTKM_FILTER_EXPORT_EXECUTE_METHOD(Contour);
|
||||
#ifndef vtkm_filter_ContourExecute_cxx
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
46
vtkm/filter/ContourInteger.cxx
Normal file
46
vtkm/filter/ContourInteger.cxx
Normal file
@ -0,0 +1,46 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_ContourExecute_cxx
|
||||
#define vtk_m_filter_ContourExecute_cxx
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
46
vtkm/filter/ContourScalar.cxx
Normal file
46
vtkm/filter/ContourScalar.cxx
Normal file
@ -0,0 +1,46 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_ContourExecute_cxx
|
||||
#define vtk_m_filter_ContourExecute_cxx
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Contour::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -11,6 +11,8 @@
|
||||
#ifndef vtk_m_filter_Gradient_h
|
||||
#define vtk_m_filter_Gradient_h
|
||||
|
||||
#include <vtkm/filter/vtkm_filter_export.h>
|
||||
|
||||
#include <vtkm/filter/FilterCell.h>
|
||||
|
||||
namespace vtkm
|
||||
@ -91,7 +93,7 @@ public:
|
||||
vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
bool ComputePointGradient = false;
|
||||
@ -106,6 +108,64 @@ private:
|
||||
std::string QCriterionName = "QCriterion";
|
||||
std::string VorticityName = "Vorticity";
|
||||
};
|
||||
|
||||
#ifndef vtkm_filter_Gradient_cxx
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
|
@ -45,7 +45,7 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
|
||||
const vtkm::filter::FieldMetadata& fieldMetadata,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (!fieldMetadata.IsPointField())
|
||||
{
|
||||
|
46
vtkm/filter/GradientScalar.cxx
Normal file
46
vtkm/filter/GradientScalar.cxx
Normal file
@ -0,0 +1,46 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Gradient_cxx
|
||||
#define vtk_m_filter_Gradient_cxx
|
||||
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
28
vtkm/filter/GradientUniformPoints.cxx
Normal file
28
vtkm/filter/GradientUniformPoints.cxx
Normal file
@ -0,0 +1,28 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Gradient_cxx
|
||||
#define vtk_m_filter_Gradient_cxx
|
||||
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
46
vtkm/filter/GradientVector.cxx
Normal file
46
vtkm/filter/GradientVector.cxx
Normal file
@ -0,0 +1,46 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Gradient_cxx
|
||||
#define vtk_m_filter_Gradient_cxx
|
||||
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, vtkm::cont::StorageTagVirtual>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -16,6 +16,8 @@ set(unit_tests
|
||||
UnitTestClipWithFieldFilter.cxx
|
||||
UnitTestClipWithImplicitFunctionFilter.cxx
|
||||
UnitTestContourFilter.cxx
|
||||
UnitTestContourFilterCustomPolicy.cxx
|
||||
UnitTestContourFilterNormals.cxx
|
||||
UnitTestContourTreeUniformFilter.cxx
|
||||
UnitTestContourTreeUniformAugmentedFilter.cxx
|
||||
UnitTestCoordinateSystemTransform.cxx
|
||||
@ -29,7 +31,8 @@ set(unit_tests
|
||||
UnitTestFieldMetadata.cxx
|
||||
UnitTestFieldSelection.cxx
|
||||
UnitTestFieldToColors.cxx
|
||||
UnitTestGradient.cxx
|
||||
UnitTestGradientExplicit.cxx
|
||||
UnitTestGradientUniform.cxx
|
||||
UnitTestGhostCellClassify.cxx
|
||||
UnitTestGhostCellRemove.cxx
|
||||
UnitTestHistogramFilter.cxx
|
||||
|
@ -9,8 +9,6 @@
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
@ -18,168 +16,10 @@
|
||||
#include <vtkm/filter/CleanGrid.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/Contour.hxx>
|
||||
#include <vtkm/source/Tangle.h>
|
||||
|
||||
namespace vtkm_ut_mc_filter
|
||||
{
|
||||
class EuclideanNorm
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
EuclideanNorm()
|
||||
: Reference(0., 0., 0.)
|
||||
{
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
EuclideanNorm(vtkm::Vec3f_32 reference)
|
||||
: Reference(reference)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Float32 operator()(vtkm::Vec3f_32 v) const
|
||||
{
|
||||
vtkm::Vec3f_32 d(
|
||||
v[0] - this->Reference[0], v[1] - this->Reference[1], v[2] - this->Reference[2]);
|
||||
return vtkm::Magnitude(d);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Vec3f_32 Reference;
|
||||
};
|
||||
|
||||
class CubeGridConnectivity
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
CubeGridConnectivity()
|
||||
: Dimension(1)
|
||||
, DimSquared(1)
|
||||
, DimPlus1Squared(4)
|
||||
{
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
CubeGridConnectivity(vtkm::Id dim)
|
||||
: Dimension(dim)
|
||||
, DimSquared(dim * dim)
|
||||
, DimPlus1Squared((dim + 1) * (dim + 1))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id operator()(vtkm::Id vertex) const
|
||||
{
|
||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
||||
|
||||
vtkm::Id cellId = vertex / HexTraits::NUM_POINTS;
|
||||
vtkm::Id localId = vertex % HexTraits::NUM_POINTS;
|
||||
vtkm::Id globalId =
|
||||
(cellId + cellId / this->Dimension + (this->Dimension + 1) * (cellId / (this->DimSquared)));
|
||||
|
||||
switch (localId)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
globalId += 1;
|
||||
break;
|
||||
case 2:
|
||||
globalId += this->Dimension + 2;
|
||||
break;
|
||||
case 3:
|
||||
globalId += this->Dimension + 1;
|
||||
break;
|
||||
case 4:
|
||||
globalId += this->DimPlus1Squared;
|
||||
break;
|
||||
case 5:
|
||||
globalId += this->DimPlus1Squared + 1;
|
||||
break;
|
||||
case 6:
|
||||
globalId += this->Dimension + this->DimPlus1Squared + 2;
|
||||
break;
|
||||
case 7:
|
||||
globalId += this->Dimension + this->DimPlus1Squared + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return globalId;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Id Dimension;
|
||||
vtkm::Id DimSquared;
|
||||
vtkm::Id DimPlus1Squared;
|
||||
};
|
||||
|
||||
class MakeRadiantDataSet
|
||||
{
|
||||
public:
|
||||
using CoordinateArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||
using DataArrayHandle =
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleUniformPointCoordinates, EuclideanNorm>;
|
||||
using ConnectivityArrayHandle =
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
||||
CubeGridConnectivity>;
|
||||
|
||||
using CellSet = vtkm::cont::CellSetSingleType<
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
||||
CubeGridConnectivity>::StorageTag>;
|
||||
|
||||
vtkm::cont::DataSet Make3DRadiantDataSet(vtkm::IdComponent dim = 5);
|
||||
};
|
||||
|
||||
class PolicyRadiantDataSet : public vtkm::filter::PolicyBase<PolicyRadiantDataSet>
|
||||
{
|
||||
public:
|
||||
using TypeListRadiantCellSetTypes = vtkm::List<MakeRadiantDataSet::CellSet>;
|
||||
|
||||
using AllCellSetList = TypeListRadiantCellSetTypes;
|
||||
};
|
||||
|
||||
inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComponent dim)
|
||||
{
|
||||
// create a cube from -.5 to .5 in x,y,z, consisting of <dim> cells on each
|
||||
// axis, with point values equal to the Euclidean distance from the origin.
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
||||
|
||||
using CoordType = vtkm::Vec3f_32;
|
||||
|
||||
const vtkm::IdComponent nCells = dim * dim * dim;
|
||||
|
||||
vtkm::Float32 spacing = vtkm::Float32(1. / dim);
|
||||
CoordinateArrayHandle coordinates(vtkm::Id3(dim + 1, dim + 1, dim + 1),
|
||||
CoordType(-.5, -.5, -.5),
|
||||
CoordType(spacing, spacing, spacing));
|
||||
|
||||
DataArrayHandle distanceToOrigin(coordinates);
|
||||
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
|
||||
|
||||
ConnectivityArrayHandle connectivity(
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
|
||||
CubeGridConnectivity(dim));
|
||||
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
//Set point scalar
|
||||
dataSet.AddField(vtkm::cont::Field(
|
||||
"distanceToOrigin", vtkm::cont::Field::Association::POINTS, distanceToOrigin));
|
||||
dataSet.AddField(
|
||||
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::Association::POINTS, distanceToOther));
|
||||
|
||||
CellSet cellSet;
|
||||
cellSet.Fill(coordinates.GetNumberOfValues(), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
|
||||
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
void TestContourUniformGrid()
|
||||
{
|
||||
@ -248,176 +88,9 @@ void TestContourUniformGrid()
|
||||
}
|
||||
}
|
||||
|
||||
void TestContourCustomPolicy()
|
||||
{
|
||||
std::cout << "Testing Contour filter with custom field and cellset" << std::endl;
|
||||
|
||||
using DataSetGenerator = MakeRadiantDataSet;
|
||||
DataSetGenerator dataSetGenerator;
|
||||
|
||||
const vtkm::IdComponent Dimension = 10;
|
||||
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
|
||||
mc.SetGenerateNormals(false);
|
||||
mc.SetIsoValue(0, 0.45);
|
||||
mc.SetIsoValue(1, 0.45);
|
||||
mc.SetIsoValue(2, 0.45);
|
||||
mc.SetIsoValue(3, 0.45);
|
||||
|
||||
//We specify a custom execution policy here, since the "distanceToOrigin" is a
|
||||
//custom field type
|
||||
mc.SetActiveField("distanceToOrigin");
|
||||
mc.SetFieldsToPass({ "distanceToOrigin", "distanceToOther" });
|
||||
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet{});
|
||||
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
|
||||
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == (414 * 4), "Should have some coordinates");
|
||||
}
|
||||
|
||||
|
||||
vtkm::cont::DataSet MakeNormalsTestDataSet()
|
||||
{
|
||||
vtkm::cont::DataSetBuilderUniform dsb;
|
||||
vtkm::Id3 dimensions(3, 4, 4);
|
||||
vtkm::cont::DataSet dataSet = dsb.Create(dimensions);
|
||||
|
||||
vtkm::cont::DataSetFieldAdd dsf;
|
||||
const int nVerts = 48;
|
||||
vtkm::Float32 vars[nVerts] = { 60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
|
||||
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f,
|
||||
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
|
||||
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
|
||||
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
|
||||
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
|
||||
60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
|
||||
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f };
|
||||
|
||||
//Set point and cell scalar
|
||||
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
void TestNormals(const vtkm::cont::DataSet& dataset, bool structured)
|
||||
{
|
||||
const vtkm::Id numVerts = 16;
|
||||
|
||||
//Calculated using PointGradient
|
||||
const vtkm::Vec3f hq_ug[numVerts] = {
|
||||
{ 0.1510f, 0.6268f, 0.7644f }, { 0.1333f, -0.3974f, 0.9079f },
|
||||
{ 0.1626f, 0.7642f, 0.6242f }, { 0.3853f, 0.6643f, 0.6405f },
|
||||
{ -0.1337f, 0.7136f, 0.6876f }, { 0.7705f, -0.4212f, 0.4784f },
|
||||
{ -0.7360f, -0.4452f, 0.5099f }, { 0.1234f, -0.8871f, 0.4448f },
|
||||
{ 0.1626f, 0.7642f, -0.6242f }, { 0.3853f, 0.6643f, -0.6405f },
|
||||
{ -0.1337f, 0.7136f, -0.6876f }, { 0.1510f, 0.6268f, -0.7644f },
|
||||
{ 0.7705f, -0.4212f, -0.4784f }, { -0.7360f, -0.4452f, -0.5099f },
|
||||
{ 0.1234f, -0.8871f, -0.4448f }, { 0.1333f, -0.3974f, -0.9079f }
|
||||
};
|
||||
|
||||
//Calculated using StructuredPointGradient
|
||||
const vtkm::Vec3f hq_sg[numVerts] = {
|
||||
{ 0.151008f, 0.626778f, 0.764425f }, { 0.133328f, -0.397444f, 0.907889f },
|
||||
{ 0.162649f, 0.764163f, 0.624180f }, { 0.385327f, 0.664323f, 0.640467f },
|
||||
{ -0.133720f, 0.713645f, 0.687626f }, { 0.770536f, -0.421248f, 0.478356f },
|
||||
{ -0.736036f, -0.445244f, 0.509910f }, { 0.123446f, -0.887088f, 0.444788f },
|
||||
{ 0.162649f, 0.764163f, -0.624180f }, { 0.385327f, 0.664323f, -0.640467f },
|
||||
{ -0.133720f, 0.713645f, -0.687626f }, { 0.151008f, 0.626778f, -0.764425f },
|
||||
{ 0.770536f, -0.421248f, -0.478356f }, { -0.736036f, -0.445244f, -0.509910f },
|
||||
{ 0.123446f, -0.887088f, -0.444788f }, { 0.133328f, -0.397444f, -0.907889f }
|
||||
};
|
||||
|
||||
//Calculated using normals of the output triangles
|
||||
const vtkm::Vec3f fast[numVerts] = {
|
||||
{ -0.1351f, 0.4377f, 0.8889f }, { 0.2863f, -0.1721f, 0.9426f },
|
||||
{ 0.3629f, 0.8155f, 0.4509f }, { 0.8486f, 0.3560f, 0.3914f },
|
||||
{ -0.8315f, 0.4727f, 0.2917f }, { 0.9395f, -0.2530f, 0.2311f },
|
||||
{ -0.9105f, -0.0298f, 0.4124f }, { -0.1078f, -0.9585f, 0.2637f },
|
||||
{ -0.2538f, 0.8534f, -0.4553f }, { 0.8953f, 0.3902f, -0.2149f },
|
||||
{ -0.8295f, 0.4188f, -0.3694f }, { 0.2434f, 0.4297f, -0.8695f },
|
||||
{ 0.8951f, -0.1347f, -0.4251f }, { -0.8467f, -0.4258f, -0.3191f },
|
||||
{ 0.2164f, -0.9401f, -0.2635f }, { -0.1589f, -0.1642f, -0.9735f }
|
||||
};
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> normals;
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
mc.SetIsoValue(0, 200);
|
||||
mc.SetGenerateNormals(true);
|
||||
|
||||
// Test default normals generation: high quality for structured, fast for unstructured.
|
||||
auto expected = structured ? hq_sg : fast;
|
||||
|
||||
mc.SetActiveField("pointvar");
|
||||
auto result = mc.Execute(dataset);
|
||||
result.GetField("normals").GetData().CopyTo(normals);
|
||||
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
||||
"Wrong number of values in normals field");
|
||||
for (vtkm::Id i = 0; i < numVerts; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
|
||||
"Result (",
|
||||
normals.ReadPortal().Get(i),
|
||||
") does not match expected value (",
|
||||
expected[i],
|
||||
") vert ",
|
||||
i);
|
||||
}
|
||||
|
||||
// Test the other normals generation method
|
||||
if (structured)
|
||||
{
|
||||
mc.SetComputeFastNormalsForStructured(true);
|
||||
expected = fast;
|
||||
}
|
||||
else
|
||||
{
|
||||
mc.SetComputeFastNormalsForUnstructured(false);
|
||||
expected = hq_ug;
|
||||
}
|
||||
|
||||
result = mc.Execute(dataset);
|
||||
result.GetField("normals").GetData().CopyTo(normals);
|
||||
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
||||
"Wrong number of values in normals field");
|
||||
for (vtkm::Id i = 0; i < numVerts; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
|
||||
"Result does not match expected values");
|
||||
}
|
||||
}
|
||||
|
||||
void TestContourNormals()
|
||||
{
|
||||
std::cout << "Testing Contour normals generation" << std::endl;
|
||||
|
||||
std::cout << "\tStructured dataset\n";
|
||||
vtkm::cont::DataSet dataset = MakeNormalsTestDataSet();
|
||||
TestNormals(dataset, true);
|
||||
|
||||
std::cout << "\tUnstructured dataset\n";
|
||||
vtkm::filter::CleanGrid makeUnstructured;
|
||||
makeUnstructured.SetCompactPointFields(false);
|
||||
makeUnstructured.SetMergePoints(false);
|
||||
makeUnstructured.SetFieldsToPass("pointvar");
|
||||
auto result = makeUnstructured.Execute(dataset);
|
||||
TestNormals(result, false);
|
||||
}
|
||||
|
||||
void TestContourFilter()
|
||||
{
|
||||
TestContourUniformGrid();
|
||||
TestContourCustomPolicy();
|
||||
TestContourNormals();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
|
||||
int UnitTestContourFilter(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_filter::TestContourFilter, argc, argv);
|
||||
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_filter::TestContourUniformGrid, argc, argv);
|
||||
}
|
||||
|
218
vtkm/filter/testing/UnitTestContourFilterCustomPolicy.cxx
Normal file
218
vtkm/filter/testing/UnitTestContourFilterCustomPolicy.cxx
Normal file
@ -0,0 +1,218 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/filter/Contour.hxx>
|
||||
|
||||
namespace vtkm_ut_mc_policy
|
||||
{
|
||||
class EuclideanNorm
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
EuclideanNorm()
|
||||
: Reference(0., 0., 0.)
|
||||
{
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
EuclideanNorm(vtkm::Vec3f_32 reference)
|
||||
: Reference(reference)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Float32 operator()(vtkm::Vec3f_32 v) const
|
||||
{
|
||||
vtkm::Vec3f_32 d(
|
||||
v[0] - this->Reference[0], v[1] - this->Reference[1], v[2] - this->Reference[2]);
|
||||
return vtkm::Magnitude(d);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Vec3f_32 Reference;
|
||||
};
|
||||
|
||||
class CubeGridConnectivity
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
CubeGridConnectivity()
|
||||
: Dimension(1)
|
||||
, DimSquared(1)
|
||||
, DimPlus1Squared(4)
|
||||
{
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
CubeGridConnectivity(vtkm::Id dim)
|
||||
: Dimension(dim)
|
||||
, DimSquared(dim * dim)
|
||||
, DimPlus1Squared((dim + 1) * (dim + 1))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id operator()(vtkm::Id vertex) const
|
||||
{
|
||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
||||
|
||||
vtkm::Id cellId = vertex / HexTraits::NUM_POINTS;
|
||||
vtkm::Id localId = vertex % HexTraits::NUM_POINTS;
|
||||
vtkm::Id globalId =
|
||||
(cellId + cellId / this->Dimension + (this->Dimension + 1) * (cellId / (this->DimSquared)));
|
||||
|
||||
switch (localId)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
globalId += 1;
|
||||
break;
|
||||
case 2:
|
||||
globalId += this->Dimension + 2;
|
||||
break;
|
||||
case 3:
|
||||
globalId += this->Dimension + 1;
|
||||
break;
|
||||
case 4:
|
||||
globalId += this->DimPlus1Squared;
|
||||
break;
|
||||
case 5:
|
||||
globalId += this->DimPlus1Squared + 1;
|
||||
break;
|
||||
case 6:
|
||||
globalId += this->Dimension + this->DimPlus1Squared + 2;
|
||||
break;
|
||||
case 7:
|
||||
globalId += this->Dimension + this->DimPlus1Squared + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return globalId;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::Id Dimension;
|
||||
vtkm::Id DimSquared;
|
||||
vtkm::Id DimPlus1Squared;
|
||||
};
|
||||
|
||||
class MakeRadiantDataSet
|
||||
{
|
||||
public:
|
||||
using CoordinateArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||
using DataArrayHandle =
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleUniformPointCoordinates, EuclideanNorm>;
|
||||
using ConnectivityArrayHandle =
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
||||
CubeGridConnectivity>;
|
||||
|
||||
using CellSet = vtkm::cont::CellSetSingleType<
|
||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
||||
CubeGridConnectivity>::StorageTag>;
|
||||
|
||||
vtkm::cont::DataSet Make3DRadiantDataSet(vtkm::IdComponent dim = 5);
|
||||
};
|
||||
|
||||
class PolicyRadiantDataSet : public vtkm::filter::PolicyBase<PolicyRadiantDataSet>
|
||||
{
|
||||
public:
|
||||
using TypeListRadiantCellSetTypes = vtkm::List<MakeRadiantDataSet::CellSet>;
|
||||
|
||||
using AllCellSetList = TypeListRadiantCellSetTypes;
|
||||
};
|
||||
|
||||
inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComponent dim)
|
||||
{
|
||||
// create a cube from -.5 to .5 in x,y,z, consisting of <dim> cells on each
|
||||
// axis, with point values equal to the Euclidean distance from the origin.
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
||||
|
||||
using CoordType = vtkm::Vec3f_32;
|
||||
|
||||
const vtkm::IdComponent nCells = dim * dim * dim;
|
||||
|
||||
vtkm::Float32 spacing = vtkm::Float32(1. / dim);
|
||||
CoordinateArrayHandle coordinates(vtkm::Id3(dim + 1, dim + 1, dim + 1),
|
||||
CoordType(-.5, -.5, -.5),
|
||||
CoordType(spacing, spacing, spacing));
|
||||
|
||||
DataArrayHandle distanceToOrigin(coordinates);
|
||||
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
|
||||
|
||||
ConnectivityArrayHandle connectivity(
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
|
||||
CubeGridConnectivity(dim));
|
||||
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
//Set point scalar
|
||||
dataSet.AddField(vtkm::cont::Field(
|
||||
"distanceToOrigin", vtkm::cont::Field::Association::POINTS, distanceToOrigin));
|
||||
dataSet.AddField(
|
||||
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::Association::POINTS, distanceToOther));
|
||||
|
||||
CellSet cellSet;
|
||||
cellSet.Fill(coordinates.GetNumberOfValues(), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
|
||||
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
void TestContourCustomPolicy()
|
||||
{
|
||||
std::cout << "Testing Contour filter with custom field and cellset" << std::endl;
|
||||
|
||||
using DataSetGenerator = MakeRadiantDataSet;
|
||||
DataSetGenerator dataSetGenerator;
|
||||
|
||||
const vtkm::IdComponent Dimension = 10;
|
||||
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
|
||||
mc.SetGenerateNormals(false);
|
||||
mc.SetIsoValue(0, 0.45);
|
||||
mc.SetIsoValue(1, 0.45);
|
||||
mc.SetIsoValue(2, 0.45);
|
||||
mc.SetIsoValue(3, 0.45);
|
||||
|
||||
//We specify a custom execution policy here, since the "distanceToOrigin" is a
|
||||
//custom field type
|
||||
mc.SetActiveField("distanceToOrigin");
|
||||
mc.SetFieldsToPass({ "distanceToOrigin", "distanceToOther" });
|
||||
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet{});
|
||||
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
|
||||
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == (414 * 4), "Should have some coordinates");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int UnitTestContourFilterCustomPolicy(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_policy::TestContourCustomPolicy, argc, argv);
|
||||
}
|
156
vtkm/filter/testing/UnitTestContourFilterNormals.cxx
Normal file
156
vtkm/filter/testing/UnitTestContourFilterNormals.cxx
Normal file
@ -0,0 +1,156 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/CleanGrid.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
|
||||
namespace vtkm_ut_mc_normals
|
||||
{
|
||||
|
||||
vtkm::cont::DataSet MakeNormalsTestDataSet()
|
||||
{
|
||||
vtkm::cont::DataSetBuilderUniform dsb;
|
||||
vtkm::Id3 dimensions(3, 4, 4);
|
||||
vtkm::cont::DataSet dataSet = dsb.Create(dimensions);
|
||||
|
||||
vtkm::cont::DataSetFieldAdd dsf;
|
||||
const int nVerts = 48;
|
||||
vtkm::Float32 vars[nVerts] = { 60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
|
||||
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f,
|
||||
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
|
||||
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
|
||||
95.202f, 162.649f, 114.962f, 115.896f, 215.56f, 135.657f,
|
||||
150.418f, 250.081f, 170.178f, 71.791f, 139.239f, 91.552f,
|
||||
60.764f, 107.555f, 80.524f, 63.639f, 131.087f, 83.4f,
|
||||
98.161f, 165.608f, 117.921f, 37.353f, 84.145f, 57.114f };
|
||||
|
||||
//Set point and cell scalar
|
||||
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
void TestNormals(const vtkm::cont::DataSet& dataset, bool structured)
|
||||
{
|
||||
const vtkm::Id numVerts = 16;
|
||||
|
||||
//Calculated using PointGradient
|
||||
const vtkm::Vec3f hq_ug[numVerts] = {
|
||||
{ 0.1510f, 0.6268f, 0.7644f }, { 0.1333f, -0.3974f, 0.9079f },
|
||||
{ 0.1626f, 0.7642f, 0.6242f }, { 0.3853f, 0.6643f, 0.6405f },
|
||||
{ -0.1337f, 0.7136f, 0.6876f }, { 0.7705f, -0.4212f, 0.4784f },
|
||||
{ -0.7360f, -0.4452f, 0.5099f }, { 0.1234f, -0.8871f, 0.4448f },
|
||||
{ 0.1626f, 0.7642f, -0.6242f }, { 0.3853f, 0.6643f, -0.6405f },
|
||||
{ -0.1337f, 0.7136f, -0.6876f }, { 0.1510f, 0.6268f, -0.7644f },
|
||||
{ 0.7705f, -0.4212f, -0.4784f }, { -0.7360f, -0.4452f, -0.5099f },
|
||||
{ 0.1234f, -0.8871f, -0.4448f }, { 0.1333f, -0.3974f, -0.9079f }
|
||||
};
|
||||
|
||||
//Calculated using StructuredPointGradient
|
||||
const vtkm::Vec3f hq_sg[numVerts] = {
|
||||
{ 0.151008f, 0.626778f, 0.764425f }, { 0.133328f, -0.397444f, 0.907889f },
|
||||
{ 0.162649f, 0.764163f, 0.624180f }, { 0.385327f, 0.664323f, 0.640467f },
|
||||
{ -0.133720f, 0.713645f, 0.687626f }, { 0.770536f, -0.421248f, 0.478356f },
|
||||
{ -0.736036f, -0.445244f, 0.509910f }, { 0.123446f, -0.887088f, 0.444788f },
|
||||
{ 0.162649f, 0.764163f, -0.624180f }, { 0.385327f, 0.664323f, -0.640467f },
|
||||
{ -0.133720f, 0.713645f, -0.687626f }, { 0.151008f, 0.626778f, -0.764425f },
|
||||
{ 0.770536f, -0.421248f, -0.478356f }, { -0.736036f, -0.445244f, -0.509910f },
|
||||
{ 0.123446f, -0.887088f, -0.444788f }, { 0.133328f, -0.397444f, -0.907889f }
|
||||
};
|
||||
|
||||
//Calculated using normals of the output triangles
|
||||
const vtkm::Vec3f fast[numVerts] = {
|
||||
{ -0.1351f, 0.4377f, 0.8889f }, { 0.2863f, -0.1721f, 0.9426f },
|
||||
{ 0.3629f, 0.8155f, 0.4509f }, { 0.8486f, 0.3560f, 0.3914f },
|
||||
{ -0.8315f, 0.4727f, 0.2917f }, { 0.9395f, -0.2530f, 0.2311f },
|
||||
{ -0.9105f, -0.0298f, 0.4124f }, { -0.1078f, -0.9585f, 0.2637f },
|
||||
{ -0.2538f, 0.8534f, -0.4553f }, { 0.8953f, 0.3902f, -0.2149f },
|
||||
{ -0.8295f, 0.4188f, -0.3694f }, { 0.2434f, 0.4297f, -0.8695f },
|
||||
{ 0.8951f, -0.1347f, -0.4251f }, { -0.8467f, -0.4258f, -0.3191f },
|
||||
{ 0.2164f, -0.9401f, -0.2635f }, { -0.1589f, -0.1642f, -0.9735f }
|
||||
};
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> normals;
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
mc.SetIsoValue(0, 200);
|
||||
mc.SetGenerateNormals(true);
|
||||
|
||||
// Test default normals generation: high quality for structured, fast for unstructured.
|
||||
auto expected = structured ? hq_sg : fast;
|
||||
|
||||
mc.SetActiveField("pointvar");
|
||||
auto result = mc.Execute(dataset);
|
||||
result.GetField("normals").GetData().CopyTo(normals);
|
||||
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
||||
"Wrong number of values in normals field");
|
||||
for (vtkm::Id i = 0; i < numVerts; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
|
||||
"Result (",
|
||||
normals.ReadPortal().Get(i),
|
||||
") does not match expected value (",
|
||||
expected[i],
|
||||
") vert ",
|
||||
i);
|
||||
}
|
||||
|
||||
// Test the other normals generation method
|
||||
if (structured)
|
||||
{
|
||||
mc.SetComputeFastNormalsForStructured(true);
|
||||
expected = fast;
|
||||
}
|
||||
else
|
||||
{
|
||||
mc.SetComputeFastNormalsForUnstructured(false);
|
||||
expected = hq_ug;
|
||||
}
|
||||
|
||||
result = mc.Execute(dataset);
|
||||
result.GetField("normals").GetData().CopyTo(normals);
|
||||
VTKM_TEST_ASSERT(normals.GetNumberOfValues() == numVerts,
|
||||
"Wrong number of values in normals field");
|
||||
for (vtkm::Id i = 0; i < numVerts; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(normals.ReadPortal().Get(i), expected[i], 0.001),
|
||||
"Result does not match expected values");
|
||||
}
|
||||
}
|
||||
|
||||
void TestContourNormals()
|
||||
{
|
||||
std::cout << "Testing Contour normals generation" << std::endl;
|
||||
|
||||
std::cout << "\tStructured dataset\n";
|
||||
vtkm::cont::DataSet dataset = MakeNormalsTestDataSet();
|
||||
TestNormals(dataset, true);
|
||||
|
||||
std::cout << "\tUnstructured dataset\n";
|
||||
vtkm::filter::CleanGrid makeUnstructured;
|
||||
makeUnstructured.SetCompactPointFields(false);
|
||||
makeUnstructured.SetMergePoints(false);
|
||||
makeUnstructured.SetFieldsToPass("pointvar");
|
||||
auto result = makeUnstructured.Execute(dataset);
|
||||
TestNormals(result, false);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int UnitTestContourFilterNormals(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_normals::TestContourNormals, argc, argv);
|
||||
}
|
82
vtkm/filter/testing/UnitTestGradientExplicit.cxx
Normal file
82
vtkm/filter/testing/UnitTestGradientExplicit.cxx
Normal file
@ -0,0 +1,82 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void TestCellGradientExplicit()
|
||||
{
|
||||
std::cout << "Testing Gradient Filter with cell output on Explicit data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
|
||||
|
||||
vtkm::filter::Gradient gradient;
|
||||
gradient.SetOutputFieldName("gradient");
|
||||
gradient.SetActiveField("pointvar");
|
||||
|
||||
vtkm::cont::DataSet result = gradient.Execute(dataSet);
|
||||
|
||||
VTKM_TEST_ASSERT(result.HasCellField("gradient"), "Result field missing.");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
|
||||
result.GetCellField("gradient").GetData().CopyTo(resultArrayHandle);
|
||||
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, -0.0f } };
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellGradient filter on 3D explicit data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestPointGradientExplicit()
|
||||
{
|
||||
std::cout << "Testing Gradient Filter with point output on Explicit data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
|
||||
|
||||
vtkm::filter::Gradient gradient;
|
||||
gradient.SetComputePointGradient(true);
|
||||
gradient.SetOutputFieldName("gradient");
|
||||
gradient.SetActiveField("pointvar");
|
||||
|
||||
vtkm::cont::DataSet result = gradient.Execute(dataSet);
|
||||
|
||||
VTKM_TEST_ASSERT(result.HasPointField("gradient"), "Result field missing.");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
|
||||
result.GetPointField("gradient").GetData().CopyTo(resultArrayHandle);
|
||||
|
||||
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, 0.0f } };
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellGradient filter on 3D explicit data");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TestGradient()
|
||||
{
|
||||
TestCellGradientExplicit();
|
||||
TestPointGradientExplicit();
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestGradientExplicit(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestGradient, argc, argv);
|
||||
}
|
@ -112,30 +112,6 @@ void TestCellGradientUniform3DWithVectorField()
|
||||
}
|
||||
}
|
||||
|
||||
void TestCellGradientExplicit()
|
||||
{
|
||||
std::cout << "Testing Gradient Filter with cell output on Explicit data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
|
||||
|
||||
vtkm::filter::Gradient gradient;
|
||||
gradient.SetOutputFieldName("gradient");
|
||||
gradient.SetActiveField("pointvar");
|
||||
|
||||
vtkm::cont::DataSet result = gradient.Execute(dataSet);
|
||||
|
||||
VTKM_TEST_ASSERT(result.HasCellField("gradient"), "Result field missing.");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
|
||||
result.GetCellField("gradient").GetData().CopyTo(resultArrayHandle);
|
||||
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, -0.0f } };
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellGradient filter on 3D explicit data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestPointGradientUniform3DWithVectorField()
|
||||
{
|
||||
@ -187,45 +163,17 @@ void TestPointGradientUniform3DWithVectorField()
|
||||
}
|
||||
}
|
||||
|
||||
void TestPointGradientExplicit()
|
||||
{
|
||||
std::cout << "Testing Gradient Filter with point output on Explicit data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
|
||||
|
||||
vtkm::filter::Gradient gradient;
|
||||
gradient.SetComputePointGradient(true);
|
||||
gradient.SetOutputFieldName("gradient");
|
||||
gradient.SetActiveField("pointvar");
|
||||
|
||||
vtkm::cont::DataSet result = gradient.Execute(dataSet);
|
||||
|
||||
VTKM_TEST_ASSERT(result.HasPointField("gradient"), "Result field missing.");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> resultArrayHandle;
|
||||
result.GetPointField("gradient").GetData().CopyTo(resultArrayHandle);
|
||||
|
||||
vtkm::Vec3f_32 expected[2] = { { 10.f, 10.1f, 0.0f }, { 10.f, 10.1f, 0.0f } };
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellGradient filter on 3D explicit data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestGradient()
|
||||
{
|
||||
TestCellGradientUniform3D();
|
||||
TestCellGradientUniform3DWithVectorField();
|
||||
TestCellGradientExplicit();
|
||||
|
||||
TestPointGradientUniform3DWithVectorField();
|
||||
TestPointGradientExplicit();
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestGradient(int argc, char* argv[])
|
||||
int UnitTestGradientUniform(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestGradient, argc, argv);
|
||||
}
|
Loading…
Reference in New Issue
Block a user