Commit 91db8ad0 authored by Kenneth Moreland's avatar Kenneth Moreland

Remove PointCoordinates classes

The idea of the PointCoordinate classes was to make it easier to define
new special types of point coordinate arrays. But ultimately you have to
create an array handle type, and the CoordinateSystem class pretty much
handles everything else for you. Thus, these classes where being used
nowhere.
parent a99f828c
......@@ -44,7 +44,6 @@ set(headers
DeviceAdapterSerial.h
DynamicArrayHandle.h
DynamicCellSet.h
DynamicPointCoordinates.h
Error.h
ErrorControl.h
ErrorControlAssert.h
......@@ -55,9 +54,6 @@ set(headers
ErrorExecution.h
Field.h
LogicalStructure.h
PointCoordinatesArray.h
PointCoordinatesListTag.h
PointCoordinatesUniform.h
Storage.h
StorageBasic.h
StorageImplicit.h
......
This diff is collapsed.
//============================================================================
// 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.
//
// Copyright 2014 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_PointCoordinatesArray_h
#define vtk_m_cont_PointCoordinatesArray_h
#include <vtkm/TypeListTag.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/internal/PointCoordinatesBase.h>
namespace vtkm {
namespace cont {
/// \brief Point coordinates stored in a \c Vector3 array.
///
/// The \c PointCoordinatesArray class is a simple PointCoordinates class
/// that stores the point coordinates in a single array. The array is managed
/// by a \c DynamicArrayHandle.
///
/// Like other PointCoordinates classes, \c PointCoordinatesArray is intended
/// to be used in conjunction with \c DynamicPointCoordinates.
///
class PointCoordinatesArray : public internal::PointCoordinatesBase
{
public:
VTKM_CONT_EXPORT
PointCoordinatesArray() { }
VTKM_CONT_EXPORT
PointCoordinatesArray(const vtkm::cont::DynamicArrayHandle &array)
: Array(array) { }
template<typename Storage>
VTKM_CONT_EXPORT
PointCoordinatesArray(
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,3>,Storage> &array)
: Array(array) { }
template<typename Storage>
VTKM_CONT_EXPORT
PointCoordinatesArray(
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64,3>,Storage> &array)
: Array(array) { }
/// In this \c CastAndCall, \c TypeList is ignored. All point coordinates are
/// expressed as Vector3, so that must be how the array is represented.
///
template<typename Functor, typename TypeList, typename StorageList>
VTKM_CONT_EXPORT
void CastAndCall(const Functor &f, TypeList, StorageList) const
{
this->Array
.ResetTypeList(vtkm::TypeListTagFieldVec3())
.ResetStorageList(StorageList())
.CastAndCall(f);
}
private:
vtkm::cont::DynamicArrayHandle Array;
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_PointCoordinatesArray_h
//============================================================================
// 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.
//
// Copyright 2014 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_PointCoordinatesListTag_h
#define vtk_m_cont_PointCoordinatesListTag_h
#ifndef VTKM_DEFAULT_POINT_COORDINATES_LIST_TAG
#define VTKM_DEFAULT_POINT_COORDINATES_LIST_TAG \
::vtkm::cont::PointCoordinatesListTagCommon
#endif
#include <vtkm/ListTag.h>
#include <vtkm/cont/PointCoordinatesArray.h>
#include <vtkm/cont/PointCoordinatesUniform.h>
namespace vtkm {
namespace cont {
struct PointCoordinatesListTagArray :
vtkm::ListTagBase<vtkm::cont::PointCoordinatesArray> { };
struct PointCoordinatesListTagUniform :
vtkm::ListTagBase<vtkm::cont::PointCoordinatesUniform> { };
/// A list of the most commonly used point coordinate types. Includes \c
/// PointCoordinatesArray.
///
struct PointCoordinatesListTagCommon
: vtkm::ListTagBase<
vtkm::cont::PointCoordinatesArray,
vtkm::cont::PointCoordinatesUniform>
{ };
}
} // namespace vtkm::cont
#endif //vtk_m_cont_PointCoordinatesListTag_h
//============================================================================
// 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.
//
// Copyright 2014 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_PointCoordinatesUniform_h
#define vtk_m_cont_PointCoordinatesUniform_h
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/internal/PointCoordinatesBase.h>
namespace vtkm {
namespace cont {
/// \brief Implicitly defined uniform point coordinates.
///
/// The \c PointCoordinatesUniform class is a PointCoordinates class that
/// implicitly defines the points for a uniform rectilinear grid of data
/// (defined by an extent, an origin, and spacing in each dimension).
///
/// Like other PointCoordinates classes, \c PointCoordinatesArray is intended
/// to be used in conjunction with \c DynamicPointCoordinates.
///
class PointCoordinatesUniform : public internal::PointCoordinatesBase
{
public:
typedef vtkm::Vec<vtkm::FloatDefault,3> ValueType;
VTKM_CONT_EXPORT
PointCoordinatesUniform() { }
VTKM_CONT_EXPORT
PointCoordinatesUniform(const vtkm::Id3 &dimensions,
const ValueType &origin,
const ValueType &spacing)
: Array(dimensions, origin, spacing)
{ }
/// In this \c CastAndCall, both \c TypeList and \c StorageList are
/// ignored. All point coordinates are expressed as Vector3, so that must be
/// how the array is represented.
///
template<typename Functor, typename TypeList, typename StorageList>
VTKM_CONT_EXPORT
void CastAndCall(const Functor &f, TypeList, StorageList) const
{
f(this->Array);
}
private:
vtkm::cont::ArrayHandleUniformPointCoordinates Array;
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_PointCoordinatesUniform_h
......@@ -23,7 +23,6 @@
#include "vtkm/cont/ArrayHandle.h"
#include "vtkm/cont/DynamicArrayHandle.h"
#include "vtkm/cont/DynamicCellSet.h"
#include "vtkm/cont/DynamicPointCoordinates.h"
#include "vtkm/internal/FunctionInterface.h"
......@@ -101,8 +100,7 @@ struct FunctionInterfaceFunctor {
void(vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<std::string>,
vtkm::cont::CellSetStructured<3>,
vtkm::cont::ArrayHandleUniformPointCoordinates)> &) const {
vtkm::cont::CellSetStructured<3>)> &) const {
std::cout << " In FunctionInterface<...> functor." << std::endl;
g_FunctionCalls++;
}
......@@ -152,7 +150,6 @@ void TestFunctionTransform()
vtkm::cont::ArrayHandle<vtkm::FloatDefault> scalarArray;
vtkm::cont::ArrayHandle<std::string> stringArray;
vtkm::cont::CellSetStructured<3> structuredCellSet;
vtkm::cont::ArrayHandleUniformPointCoordinates pointCoordinatesArray;
std::cout << " Trying basic functor call w/o transform (make sure it works)."
<< std::endl;
......@@ -161,8 +158,7 @@ void TestFunctionTransform()
scalarArray,
scalarArray,
stringArray,
structuredCellSet,
pointCoordinatesArray)));
structuredCellSet)));
std::cout << " Trying dynamic cast" << std::endl;
TRY_TRANSFORM(
......@@ -170,8 +166,7 @@ void TestFunctionTransform()
scalarArray,
vtkm::cont::DynamicArrayHandle(scalarArray),
vtkm::cont::DynamicArrayHandle(stringArray).ResetTypeList(TypeListTagString()),
vtkm::cont::DynamicCellSet(structuredCellSet),
vtkm::cont::DynamicPointCoordinates(vtkm::cont::PointCoordinatesUniform()))
vtkm::cont::DynamicCellSet(structuredCellSet))
.DynamicTransformCont(vtkm::cont::internal::DynamicTransform(),
FunctionInterfaceFunctor()));
}
......
......@@ -48,8 +48,6 @@ set(unit_tests
UnitTestDeviceAdapterSerial.cxx
UnitTestDynamicArrayHandle.cxx
UnitTestDynamicCellSet.cxx
UnitTestDynamicPointCoordinates.cxx
UnitTestPointCoordinates.cxx
UnitTestStorageBasic.cxx
UnitTestStorageImplicit.cxx
UnitTestStorageListTag.cxx
......
//============================================================================
// 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.
//
// Copyright 2014 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#include <vtkm/cont/DynamicPointCoordinates.h>
#include <vtkm/cont/StorageImplicit.h>
#include <vtkm/cont/StorageListTag.h>
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
#include <vtkm/cont/testing/Testing.h>
#include <vector>
namespace {
const vtkm::Id3 DIMENSIONS = vtkm::Id3(9,9,9);
const vtkm::Vec<vtkm::FloatDefault,3> ORIGIN =
vtkm::Vec<vtkm::FloatDefault,3>(0, 0, 0);
const vtkm::Vec<vtkm::FloatDefault,3> SPACING =
vtkm::Vec<vtkm::FloatDefault,3>(1, 1, 1);
const vtkm::Id ARRAY_SIZE = DIMENSIONS[0]*DIMENSIONS[1]*DIMENSIONS[2];
vtkm::Vec<vtkm::FloatDefault,3> ExpectedCoordinates(vtkm::Id index)
{
return vtkm::make_Vec(
vtkm::FloatDefault(index%DIMENSIONS[0]),
vtkm::FloatDefault((index/DIMENSIONS[0])%DIMENSIONS[1]),
vtkm::FloatDefault(index/(DIMENSIONS[0]*DIMENSIONS[1])));
}
int g_CheckArrayInvocations;
struct CheckArray
{
CheckArray() {
g_CheckArrayInvocations = 0;
}
template<typename ArrayType>
void operator()(const ArrayType &array) const
{
typedef typename ArrayType::ValueType ValueType;
std::cout << " In CastAndCall functor" << std::endl;
g_CheckArrayInvocations++;
typename ArrayType::PortalConstControl portal =
array.GetPortalConstControl();
VTKM_TEST_ASSERT(portal.GetNumberOfValues() == ARRAY_SIZE,
"Array has wrong number of values.");
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
const ValueType receivedValue = portal.Get(index);
const ValueType expectedValue = ExpectedCoordinates(index);
VTKM_TEST_ASSERT(receivedValue == expectedValue,
"Got bad value in array.");
}
}
};
struct UnusualPortal
{
typedef vtkm::Vec<vtkm::FloatDefault,3> ValueType;
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfValues() const { return ARRAY_SIZE; }
VTKM_EXEC_CONT_EXPORT
ValueType Get(vtkm::Id index) const { return ExpectedCoordinates(index); }
};
class ArrayHandleWithUnusualStorage
: public vtkm::cont::ArrayHandle<UnusualPortal::ValueType, vtkm::cont::StorageTagImplicit<UnusualPortal> >
{
typedef vtkm::cont::ArrayHandle<UnusualPortal::ValueType, vtkm::cont::StorageTagImplicit<UnusualPortal> >
Superclass;
public:
VTKM_CONT_EXPORT
ArrayHandleWithUnusualStorage()
: Superclass(Superclass::PortalConstControl()) { }
};
struct StorageListTagUnusual :
vtkm::ListTagBase<ArrayHandleWithUnusualStorage::StorageTag>
{ };
struct PointCoordinatesUnusual : vtkm::cont::internal::PointCoordinatesBase
{
template<typename Functor, typename TypeList, typename StorageList>
void CastAndCall(const Functor &f, TypeList, StorageList) const
{
f(ArrayHandleWithUnusualStorage());
}
};
struct PointCoordinatesListUnusual
: vtkm::ListTagBase<PointCoordinatesUnusual> { };
struct TryDefaultArray
{
template<typename Vector3>
void operator()(Vector3) const
{
std::cout << "Trying basic point coordinates array with a default storage."
<< std::endl;
std::vector<Vector3> buffer( static_cast<vtkm::UInt32>(ARRAY_SIZE) );
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
vtkm::UInt32 i = static_cast< vtkm::UInt32 >(index);
buffer[i] = ExpectedCoordinates(index);
}
vtkm::cont::DynamicPointCoordinates pointCoordinates =
vtkm::cont::DynamicPointCoordinates(
vtkm::cont::make_ArrayHandle(buffer));
pointCoordinates.CastAndCall(CheckArray());
VTKM_TEST_ASSERT(g_CheckArrayInvocations == 1,
"CastAndCall functor not called expected number of times.");
}
};
void TryUnusualStorage()
{
std::cout << "Trying a basic point coordinates array with an unusual storage."
<< std::endl;
vtkm::cont::DynamicPointCoordinates pointCoordinates =
vtkm::cont::DynamicPointCoordinates(
vtkm::cont::PointCoordinatesArray(ArrayHandleWithUnusualStorage()));
std::cout << " Make sure we get an exception when we can't find the type."
<< std::endl;
try
{
pointCoordinates.CastAndCall(CheckArray());
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage.");
}
catch (vtkm::cont::ErrorControlBadValue error)
{
std::cout << " Caught expected exception for unrecognized storage: "
<< std::endl << " " << error.GetMessage() << std::endl;
}
std::cout << " Recast storage and try again." << std::endl;
pointCoordinates.ResetStorageList(StorageListTagUnusual())
.CastAndCall(CheckArray());
VTKM_TEST_ASSERT(g_CheckArrayInvocations == 1,
"CastAndCall functor not called expected number of times.");
}
void TryUniformPointCoordinates()
{
std::cout << "Trying uniform point coordinates." << std::endl;
vtkm::cont::DynamicPointCoordinates pointCoordinates =
vtkm::cont::DynamicPointCoordinates(
vtkm::cont::PointCoordinatesUniform(DIMENSIONS, ORIGIN, SPACING));
pointCoordinates.CastAndCall(CheckArray());
VTKM_TEST_ASSERT(g_CheckArrayInvocations == 1,
"CastAndCall functor not called expected number of times.");
}
void TryUnusualPointCoordinates()
{
std::cout << "Trying an unusual point coordinates object." << std::endl;
vtkm::cont::DynamicPointCoordinates pointCoordinates =
vtkm::cont::DynamicPointCoordinates(PointCoordinatesUnusual());
std::cout << " Make sure we get an exception when we can't find the type."
<< std::endl;
try
{
pointCoordinates.CastAndCall(CheckArray());
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized storage.");
}
catch (vtkm::cont::ErrorControlBadValue error)
{
std::cout << " Caught expected exception for unrecognized point coordinates: "
<< std::endl << " " << error.GetMessage() << std::endl;
}
std::cout << " Recast storage and try again." << std::endl;
pointCoordinates.ResetPointCoordinatesList(PointCoordinatesListUnusual())
.CastAndCall(CheckArray());
VTKM_TEST_ASSERT(g_CheckArrayInvocations == 1,
"CastAndCall functor not called expected number of times.");
}
void DynamicPointCoordiantesTest()
{
vtkm::testing::Testing::TryTypes(TryDefaultArray(),
vtkm::TypeListTagFieldVec3());
TryUnusualStorage();
TryUniformPointCoordinates();
TryUnusualPointCoordinates();
}
} // anonymous namespace
int UnitTestDynamicPointCoordinates(int, char *[])
{
return vtkm::cont::testing::Testing::Run(DynamicPointCoordiantesTest);
}
//============================================================================
// 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.
//
// Copyright 2014 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
// Make sure nothing relies on default storage or device adapter.
#define VTKM_STORAGE VTKM_STORAGE_ERROR
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_ERROR
// Make sure nothing relies on default lists.
#define VTKM_DEFAULT_TYPE_LIST_TAG ::vtkm::ListTagEmpty
#define VTKM_DEFAULT_STORAGE_LIST_TAG ::vtkm::ListTagEmpty
#include <vtkm/cont/PointCoordinatesArray.h>
#include <vtkm/cont/PointCoordinatesUniform.h>
#include <vtkm/TypeListTag.h>
#include <vtkm/cont/DeviceAdapterSerial.h>
#include <vtkm/cont/StorageBasic.h>
#include <vtkm/cont/testing/Testing.h>
#include <vector>
namespace {
const vtkm::Id3 DIMENSIONS = vtkm::Id3(9,9,9);
const vtkm::Vec<vtkm::FloatDefault,3> ORIGIN =
vtkm::Vec<vtkm::FloatDefault,3>(0, 0, 0);
const vtkm::Vec<vtkm::FloatDefault,3> SPACING =
vtkm::Vec<vtkm::FloatDefault,3>(1, 1, 1);
const vtkm::Id ARRAY_SIZE = DIMENSIONS[0]*DIMENSIONS[1]*DIMENSIONS[2];
typedef vtkm::cont::StorageTagBasic StorageTag;
struct StorageListTag : vtkm::cont::StorageListTagBasic { };
vtkm::Vec<vtkm::FloatDefault,3> ExpectedCoordinates(vtkm::Id index)
{
return vtkm::make_Vec(
vtkm::FloatDefault(index%DIMENSIONS[0]),
vtkm::FloatDefault((index/DIMENSIONS[0])%DIMENSIONS[1]),
vtkm::FloatDefault(index/(DIMENSIONS[0]*DIMENSIONS[1])));
}
struct CheckArray
{
template<typename ArrayType>
void operator()(const ArrayType &array) const
{
typedef typename ArrayType::ValueType ValueType;
std::cout << " In CastAndCall functor" << std::endl;
typename ArrayType::PortalConstControl portal =
array.GetPortalConstControl();
VTKM_TEST_ASSERT(portal.GetNumberOfValues() == ARRAY_SIZE,
"Array has wrong number of values.");
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
const ValueType receivedValue = portal.Get(index);
const ValueType expectedValue = ExpectedCoordinates(index);
VTKM_TEST_ASSERT(receivedValue == expectedValue,
"Got bad value in array.");
}
}
};
struct TestPointCoordinatesArray
{
template<typename Vector3>
void operator()(Vector3) const
{
std::cout << "Testing PointCoordinatesArray" << std::endl;
std::cout << " Creating buffer of data values" << std::endl;
std::vector<Vector3> buffer( static_cast<vtkm::UInt32>(ARRAY_SIZE) );
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
vtkm::UInt32 i = static_cast<vtkm::UInt32>(index);
buffer[i] = ExpectedCoordinates(index);
}
std::cout << " Creating and checking array handle" << std::endl;
vtkm::cont::ArrayHandle<Vector3,StorageTag> array =
vtkm::cont::make_ArrayHandle(buffer);
CheckArray()(array);
std::cout << " Creating and checking PointCoordinatesArray" << std::endl;
vtkm::cont::PointCoordinatesArray pointCoordinates =
vtkm::cont::PointCoordinatesArray(array);
pointCoordinates.CastAndCall(
CheckArray(),
vtkm::ListTagEmpty(), // Internally sets to Vector3
vtkm::cont::StorageListTagBasic());
}
};
void TestPointCoordinatesUniform()
{
std::cout << "Testing PointCoordinatesUniform" << std::endl;
vtkm::cont::PointCoordinatesUniform pointCoordinates =
vtkm::cont::PointCoordinatesUniform(DIMENSIONS, ORIGIN, SPACING);
pointCoordinates.CastAndCall(
CheckArray(),
vtkm::ListTagEmpty(), // Not used
vtkm::ListTagEmpty()); // Not used
}
void PointCoordinatesTests()
{
vtkm::testing::Testing::TryTypes(TestPointCoordinatesArray(),
vtkm::TypeListTagFieldVec3());
TestPointCoordinatesUniform();
}
} // anonymous namespace
int UnitTestPointCoordinates(int, char *[])
{
return vtkm::cont::testing::Testing::Run(PointCoordinatesTests);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment