mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Make PrintSummary actually work for Field and CoordinateSystem.
The PrintSummary for CoordinateSystem went in an infinite loop. It was supposed to call PrintSummary of its superclass (Field), but instead it called itself. The PrintSummary for Field only worked for fields of type vtkm::Float32. To make it work for all array types, I added a PrintSummary method to DynamicArrayHandle, and Field calls that without trying to cast to a static type.
This commit is contained in:
parent
a9190e79e9
commit
9cd8cb22eb
10
vtkm/Pair.h
10
vtkm/Pair.h
@ -25,6 +25,7 @@
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
#include <vtkm/TypeTraits.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
namespace vtkm {
|
||||
@ -166,4 +167,13 @@ struct TypeTraits<vtkm::Pair<T,U> >
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
/// Helper function for printing out pairs during testing.
|
||||
///
|
||||
template<typename T, typename U>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
std::ostream &operator<<(std::ostream &stream, const vtkm::Pair<T,U> &vec)
|
||||
{
|
||||
return stream << "[" << vec.first << "," << vec.second << "]";
|
||||
}
|
||||
|
||||
#endif //vtk_m_Pair_h
|
||||
|
16
vtkm/Types.h
16
vtkm/Types.h
@ -31,6 +31,8 @@ VTKM_THIRDPARTY_PRE_INCLUDE
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
VTKM_THIRDPARTY_POST_INCLUDE
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*!
|
||||
* \namespace vtkm
|
||||
* \brief VTKm Toolkit.
|
||||
@ -1164,4 +1166,18 @@ operator-(const vtkm::Vec<T,Size> &x)
|
||||
x, vtkm::internal::Negate());
|
||||
}
|
||||
|
||||
/// Helper function for printing out vectors during testing.
|
||||
///
|
||||
template<typename T, vtkm::IdComponent Size>
|
||||
VTKM_CONT_EXPORT
|
||||
std::ostream &operator<<(std::ostream &stream, const vtkm::Vec<T,Size> &vec)
|
||||
{
|
||||
stream << "[";
|
||||
for (vtkm::IdComponent component = 0; component < Size-1; component++)
|
||||
{
|
||||
stream << vec[component] << ",";
|
||||
}
|
||||
return stream << vec[Size-1] << "]";
|
||||
}
|
||||
|
||||
#endif //vtk_m_Types_h
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
virtual void PrintSummary(std::ostream &out) const
|
||||
{
|
||||
out << " Coordinate System ";
|
||||
this->PrintSummary(out);
|
||||
this->Superclass::PrintSummary(out);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,6 +53,8 @@ struct PolymorphicArrayHandleContainerBase
|
||||
virtual vtkm::IdComponent GetNumberOfComponents() const = 0;
|
||||
virtual vtkm::Id GetNumberOfValues() const = 0;
|
||||
|
||||
virtual void PrintSummary(std::ostream &out) const = 0;
|
||||
|
||||
virtual boost::shared_ptr<PolymorphicArrayHandleContainerBase>
|
||||
NewInstance() const = 0;
|
||||
};
|
||||
@ -90,6 +92,11 @@ struct PolymorphicArrayHandleContainer
|
||||
return this->Array.GetNumberOfValues();
|
||||
}
|
||||
|
||||
virtual void PrintSummary(std::ostream &out) const
|
||||
{
|
||||
vtkm::cont::printSummary_ArrayHandle(this->Array, out);
|
||||
}
|
||||
|
||||
virtual boost::shared_ptr<PolymorphicArrayHandleContainerBase>
|
||||
NewInstance() const
|
||||
{
|
||||
@ -277,6 +284,12 @@ public:
|
||||
return this->ArrayContainer->GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
virtual void PrintSummary(std::ostream &out) const
|
||||
{
|
||||
this->ArrayContainer->PrintSummary(out);
|
||||
}
|
||||
|
||||
private:
|
||||
boost::shared_ptr<vtkm::cont::detail::PolymorphicArrayHandleContainerBase>
|
||||
ArrayContainer;
|
||||
|
@ -682,10 +682,7 @@ public:
|
||||
case ASSOC_CELL_SET: out<<"Cells "; break;
|
||||
case ASSOC_LOGICAL_DIM: out<<"LogicalDim "; break;
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> vals;
|
||||
vals = this->Data.CastToArrayHandle(
|
||||
vtkm::Float32(), VTKM_DEFAULT_STORAGE_TAG());
|
||||
printSummary_ArrayHandle(vals, out);
|
||||
this->Data.PrintSummary(out);
|
||||
//out<<" Order= "<<Order;
|
||||
out<<"\n";
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ void TestDataSet_Explicit()
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet1();
|
||||
|
||||
ds.PrintSummary(std::cout);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
|
||||
"Incorrect number of cell sets");
|
||||
|
||||
|
@ -49,6 +49,8 @@ TwoDimRegularTest()
|
||||
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DRegularDataSet0();
|
||||
|
||||
dataSet.PrintSummary(std::cout);
|
||||
|
||||
typedef vtkm::cont::CellSetStructured<2> CellSetType;
|
||||
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
|
||||
|
||||
@ -157,6 +159,8 @@ ThreeDimRegularTest()
|
||||
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DRegularDataSet0();
|
||||
|
||||
dataSet.PrintSummary(std::cout);
|
||||
|
||||
typedef vtkm::cont::CellSetStructured<3> CellSetType;
|
||||
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
|
||||
|
||||
|
@ -29,8 +29,6 @@ VTKM_THIRDPARTY_PRE_INCLUDE
|
||||
#include <boost/static_assert.hpp>
|
||||
VTKM_THIRDPARTY_POST_INCLUDE
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace vtkm {
|
||||
namespace internal {
|
||||
|
||||
|
@ -346,29 +346,6 @@ bool test_equal(const vtkm::Pair<T1,T2> &pair1,
|
||||
&& test_equal(pair1.second, pair2.second, tolerance);
|
||||
}
|
||||
|
||||
/// Helper function for printing out vectors during testing.
|
||||
///
|
||||
template<typename T, vtkm::IdComponent Size>
|
||||
VTKM_CONT_EXPORT
|
||||
std::ostream &operator<<(std::ostream &stream, const vtkm::Vec<T,Size> &vec)
|
||||
{
|
||||
stream << "[";
|
||||
for (vtkm::IdComponent component = 0; component < Size-1; component++)
|
||||
{
|
||||
stream << vec[component] << ",";
|
||||
}
|
||||
return stream << vec[Size-1] << "]";
|
||||
}
|
||||
|
||||
/// Helper function for printing out pairs during testing.
|
||||
///
|
||||
template<typename T, typename U>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
std::ostream &operator<<(std::ostream &stream, const vtkm::Pair<T,U> &vec)
|
||||
{
|
||||
return stream << "[" << vec.first << "," << vec.second << "]";
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
|
Loading…
Reference in New Issue
Block a user