Merge topic 'dataset-uses-uknowncellset'

0a89a5fff Store UnknownCellSet instead of DynamicCellSet in DataSet

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Li-Ta Lo <ollie@lanl.gov>
Merge-request: !2654
This commit is contained in:
Kenneth Moreland 2022-01-04 14:51:13 +00:00 committed by Kitware Robot
commit 3b0206e45c
13 changed files with 91 additions and 45 deletions

@ -65,7 +65,7 @@ template <typename T>
struct CellSetCheck
{
using U = typename std::remove_pointer<T>::type;
using type = typename std::is_base_of<vtkm::cont::CellSet, U>;
using type = typename std::is_base_of<vtkm::cont::CellSet, U>::type;
};
#define VTKM_IS_CELL_SET(T) VTKM_STATIC_ASSERT(::vtkm::cont::internal::CellSetCheck<T>::type::value)

@ -14,10 +14,10 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Field.h>
#include <vtkm/cont/UnknownArrayHandle.h>
#include <vtkm/cont/UnknownCellSet.h>
namespace vtkm
{
@ -221,21 +221,18 @@ public:
vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name);
//@}
VTKM_CONT
void SetCellSet(const vtkm::cont::DynamicCellSet& cellSet) { this->CellSet = cellSet; }
template <typename CellSetType>
VTKM_CONT void SetCellSet(const CellSetType& cellSet)
{
VTKM_IS_CELL_SET(CellSetType);
this->CellSet = vtkm::cont::DynamicCellSet(cellSet);
VTKM_IS_KNOWN_OR_UNKNOWN_CELL_SET(CellSetType);
this->CellSet = vtkm::cont::UnknownCellSet(cellSet);
}
VTKM_CONT
const vtkm::cont::DynamicCellSet& GetCellSet() const { return this->CellSet; }
const vtkm::cont::UnknownCellSet& GetCellSet() const { return this->CellSet; }
VTKM_CONT
vtkm::cont::DynamicCellSet& GetCellSet() { return this->CellSet; }
vtkm::cont::UnknownCellSet& GetCellSet() { return this->CellSet; }
VTKM_CONT
vtkm::IdComponent GetNumberOfFields() const
@ -290,7 +287,7 @@ private:
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
std::map<FieldCompare::Key, vtkm::cont::Field, FieldCompare> Fields;
vtkm::cont::DynamicCellSet CellSet;
vtkm::cont::UnknownCellSet CellSet;
VTKM_CONT
vtkm::Id FindFieldIndex(const std::string& name,
@ -370,9 +367,9 @@ public:
dataset.AddCoordinateSystem(coords);
}
vtkm::cont::DynamicCellSetBase<CellSetTypesList> cells;
vtkm::cont::UncertainCellSet<CellSetTypesList> cells;
vtkmdiy::load(bb, cells);
dataset.SetCellSet(vtkm::cont::DynamicCellSet(cells));
dataset.SetCellSet(cells);
vtkm::IdComponent numberOfFields = 0;
vtkmdiy::load(bb, numberOfFields);

@ -22,6 +22,7 @@
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/UncertainCellSet.h>
#include <vtkm/cont/UnknownArrayHandle.h>
#include <vtkm/cont/testing/vtkm_cont_testing_export.h>
@ -459,10 +460,24 @@ namespace detail
struct TestEqualCellSet
{
template <typename CellSetType1, typename CellSetType2>
void operator()(const CellSetType1& cs1, const CellSetType2& cs2, TestEqualResult& result) const
{
// Avoid ambiguous overloads by specifying whether each cell type is known or unknown.
this->Run(cs1,
typename vtkm::cont::internal::CellSetCheck<CellSetType1>::type{},
cs2,
typename vtkm::cont::internal::CellSetCheck<CellSetType2>::type{},
result);
}
private:
template <typename ShapeST, typename ConnectivityST, typename OffsetST>
void operator()(const vtkm::cont::CellSetExplicit<ShapeST, ConnectivityST, OffsetST>& cs1,
const vtkm::cont::CellSetExplicit<ShapeST, ConnectivityST, OffsetST>& cs2,
TestEqualResult& result) const
void Run(const vtkm::cont::CellSetExplicit<ShapeST, ConnectivityST, OffsetST>& cs1,
std::true_type,
const vtkm::cont::CellSetExplicit<ShapeST, ConnectivityST, OffsetST>& cs2,
std::true_type,
TestEqualResult& result) const
{
vtkm::TopologyElementTagCell visitTopo{};
vtkm::TopologyElementTagPoint incidentTopo{};
@ -505,9 +520,11 @@ struct TestEqualCellSet
}
template <vtkm::IdComponent DIMENSION>
void operator()(const vtkm::cont::CellSetStructured<DIMENSION>& cs1,
const vtkm::cont::CellSetStructured<DIMENSION>& cs2,
TestEqualResult& result) const
void Run(const vtkm::cont::CellSetStructured<DIMENSION>& cs1,
std::true_type,
const vtkm::cont::CellSetStructured<DIMENSION>& cs2,
std::true_type,
TestEqualResult& result) const
{
if (cs1.GetPointDimensions() != cs2.GetPointDimensions())
{
@ -517,26 +534,56 @@ struct TestEqualCellSet
}
template <typename CellSetTypes1, typename CellSetTypes2>
void operator()(const vtkm::cont::DynamicCellSetBase<CellSetTypes1>& cs1,
const vtkm::cont::DynamicCellSetBase<CellSetTypes2>& cs2,
TestEqualResult& result) const
void Run(const vtkm::cont::DynamicCellSetBase<CellSetTypes1>& cs1,
std::false_type,
const vtkm::cont::DynamicCellSetBase<CellSetTypes2>& cs2,
std::false_type,
TestEqualResult& result) const
{
cs1.CastAndCall(*this, cs2, result);
}
template <typename CellSet, typename CellSetTypes>
void operator()(const CellSet& cs,
const vtkm::cont::DynamicCellSetBase<CellSetTypes>& dcs,
TestEqualResult& result) const
template <typename CellSetType>
void Run(const CellSetType& cs1,
std::true_type,
const vtkm::cont::UnknownCellSet& cs2,
std::false_type,
TestEqualResult& result) const
{
if (!dcs.IsSameType(cs))
if (!cs2.CanConvert<CellSetType>())
{
result.PushMessage("types don't match");
return;
}
this->operator()(cs, dcs.template Cast<CellSet>(), result);
this->Run(cs1, std::true_type{}, cs2.AsCellSet<CellSetType>(), std::true_type{}, result);
}
template <typename CellSetType>
void Run(const vtkm::cont::UnknownCellSet& cs1,
std::false_type,
const CellSetType& cs2,
std::true_type,
TestEqualResult& result) const
{
if (!cs1.CanConvert<CellSetType>())
{
result.PushMessage("types don't match");
return;
}
this->Run(cs1.AsCellSet<CellSetType>(), std::true_type{}, cs2, std::true_type{}, result);
}
template <typename UnknownCellSetType>
void Run(const UnknownCellSetType& cs1,
std::false_type,
const vtkm::cont::UnknownCellSet& cs2,
std::false_type,
TestEqualResult& result) const
{
vtkm::cont::CastAndCall(cs1, *this, cs2, result);
}
};
} // detail
template <typename CellSet1, typename CellSet2>

@ -64,7 +64,7 @@ struct StreamIOType<vtkm::UInt8>
using Type = vtkm::UInt16;
};
inline vtkm::cont::DynamicCellSet CreateCellSetStructured(const vtkm::Id3& dim)
inline vtkm::cont::UnknownCellSet CreateCellSetStructured(const vtkm::Id3& dim)
{
if (dim[0] > 1 && dim[1] > 1 && dim[2] > 1)
{

@ -516,7 +516,7 @@ void Write(std::ostream& out, const vtkm::cont::DataSet& dataSet, vtkm::io::File
break;
}
vtkm::cont::DynamicCellSet cellSet = dataSet.GetCellSet();
vtkm::cont::UnknownCellSet cellSet = dataSet.GetCellSet();
if (cellSet.IsType<vtkm::cont::CellSetExplicit<>>())
{
WriteDataSetAsUnstructured(

@ -212,7 +212,7 @@ public:
} //namespace detail
void CylinderExtractor::ExtractCells(const vtkm::cont::DynamicCellSet& cells,
void CylinderExtractor::ExtractCells(const vtkm::cont::UnknownCellSet& cells,
const vtkm::Float32 radius)
{
vtkm::Id numOfSegments;
@ -222,7 +222,7 @@ void CylinderExtractor::ExtractCells(const vtkm::cont::DynamicCellSet& cells,
this->SetUniformRadius(radius);
}
void CylinderExtractor::ExtractCells(const vtkm::cont::DynamicCellSet& cells,
void CylinderExtractor::ExtractCells(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::Field& field,
const vtkm::Float32 minRadius,
const vtkm::Float32 maxRadius)
@ -243,7 +243,7 @@ void CylinderExtractor::SetUniformRadius(const vtkm::Float32 radius)
vtkm::cont::Algorithm::Copy(radiusHandle, Radii);
}
void CylinderExtractor::SetCylinderIdsFromCells(const vtkm::cont::DynamicCellSet& cells)
void CylinderExtractor::SetCylinderIdsFromCells(const vtkm::cont::UnknownCellSet& cells)
{
vtkm::Id numCells = cells.GetNumberOfCells();
if (numCells == 0)

@ -34,12 +34,12 @@ public:
//
// Extract all vertex shapes with constant radius
//
void ExtractCells(const vtkm::cont::DynamicCellSet& cells, vtkm::Float32 radius);
void ExtractCells(const vtkm::cont::UnknownCellSet& cells, vtkm::Float32 radius);
//
// Extract all vertex elements with radius based on scalar values
//
void ExtractCells(const vtkm::cont::DynamicCellSet& cells,
void ExtractCells(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::Field& field,
const vtkm::Float32 minRadius,
const vtkm::Float32 maxRadius);
@ -57,7 +57,7 @@ protected:
const vtkm::cont::Field& field);
// void SetPointIdsFromCoords(const vtkm::cont::CoordinateSystem& coords);
void SetCylinderIdsFromCells(const vtkm::cont::DynamicCellSet& cells);
void SetCylinderIdsFromCells(const vtkm::cont::UnknownCellSet& cells);
}; // class ShapeIntersector
}

@ -199,7 +199,7 @@ public:
} //namespace detail
void QuadExtractor::ExtractCells(const vtkm::cont::DynamicCellSet& cells)
void QuadExtractor::ExtractCells(const vtkm::cont::UnknownCellSet& cells)
{
vtkm::Id numOfQuads;
vtkm::rendering::Quadralizer quadrizer;
@ -209,7 +209,7 @@ void QuadExtractor::ExtractCells(const vtkm::cont::DynamicCellSet& cells)
}
void QuadExtractor::SetQuadIdsFromCells(const vtkm::cont::DynamicCellSet& cells)
void QuadExtractor::SetQuadIdsFromCells(const vtkm::cont::UnknownCellSet& cells)
{
vtkm::Id numCells = cells.GetNumberOfCells();
if (numCells == 0)

@ -26,14 +26,14 @@ protected:
vtkm::cont::ArrayHandle<vtkm::Float32> Radii;
public:
void ExtractCells(const vtkm::cont::DynamicCellSet& cells);
void ExtractCells(const vtkm::cont::UnknownCellSet& cells);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 5>> GetQuadIds();
vtkm::Id GetNumberOfQuads() const;
protected:
void SetQuadIdsFromCells(const vtkm::cont::DynamicCellSet& cells);
void SetQuadIdsFromCells(const vtkm::cont::UnknownCellSet& cells);
}; // class ShapeIntersector
}

@ -181,13 +181,13 @@ void SphereExtractor::ExtractCoordinates(const vtkm::cont::CoordinateSystem& coo
this->SetVaryingRadius(minRadius, maxRadius, field);
}
void SphereExtractor::ExtractCells(const vtkm::cont::DynamicCellSet& cells,
void SphereExtractor::ExtractCells(const vtkm::cont::UnknownCellSet& cells,
const vtkm::Float32 radius)
{
this->SetPointIdsFromCells(cells);
this->SetUniformRadius(radius);
}
void SphereExtractor::ExtractCells(const vtkm::cont::DynamicCellSet& cells,
void SphereExtractor::ExtractCells(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::Field& field,
const vtkm::Float32 minRadius,
const vtkm::Float32 maxRadius)
@ -212,7 +212,7 @@ void SphereExtractor::SetPointIdsFromCoords(const vtkm::cont::CoordinateSystem&
vtkm::worklet::DispatcherMapField<detail::Iterator>(detail::Iterator()).Invoke(this->PointIds);
}
void SphereExtractor::SetPointIdsFromCells(const vtkm::cont::DynamicCellSet& cells)
void SphereExtractor::SetPointIdsFromCells(const vtkm::cont::UnknownCellSet& cells)
{
using SingleType = vtkm::cont::CellSetSingleType<>;
vtkm::Id numCells = cells.GetNumberOfCells();

@ -42,12 +42,12 @@ public:
//
// Extract all vertex shapes with constant radius
//
void ExtractCells(const vtkm::cont::DynamicCellSet& cells, vtkm::Float32 radius);
void ExtractCells(const vtkm::cont::UnknownCellSet& cells, vtkm::Float32 radius);
//
// Extract all vertex elements with radius based on scalar values
//
void ExtractCells(const vtkm::cont::DynamicCellSet& cells,
void ExtractCells(const vtkm::cont::UnknownCellSet& cells,
const vtkm::cont::Field& field,
const vtkm::Float32 minRadius,
const vtkm::Float32 maxRadius);
@ -64,7 +64,7 @@ protected:
const vtkm::cont::Field& field);
void SetPointIdsFromCoords(const vtkm::cont::CoordinateSystem& coords);
void SetPointIdsFromCells(const vtkm::cont::DynamicCellSet& cells);
void SetPointIdsFromCells(const vtkm::cont::UnknownCellSet& cells);
}; // class ShapeIntersector
}

@ -19,6 +19,7 @@
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/ImplicitFunction.h>

@ -15,6 +15,7 @@
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>