vtk-m/vtkm/RegularConnectivity.h

87 lines
2.9 KiB
C
Raw Normal View History

2015-05-15 16:03:52 +00:00
//============================================================================
// 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_RegularConnectivity_h
#define vtk_m_RegularConnectivity_h
2015-04-15 14:45:39 +00:00
#include <vtkm/Types.h>
#include <vtkm/RegularStructure.h>
2015-05-14 20:08:28 +00:00
#include <vtkm/cont/TopologyType.h>
2015-04-15 14:45:39 +00:00
#include <boost/static_assert.hpp>
2015-04-15 14:45:39 +00:00
namespace vtkm {
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To, vtkm::IdComponent Dimension>
struct IndexLookupHelper
{
// We want an unconditional failure if this unspecialized class ever gets
// instantiated, because it means someone missed a topology mapping type.
// We need to create a test which depends on the templated types so
// it doesn't get picked up without a concrete instantiation.
BOOST_STATIC_ASSERT_MSG(From != To && From == To,
"Missing Specialization for Topologies");
};
template<vtkm::IdComponent Dimension>
struct IndexLookupHelper<vtkm::cont::NODE,vtkm::cont::CELL,Dimension>
{
template <vtkm::IdComponent ItemTupleLength>
VTKM_EXEC_CONT_EXPORT
static void GetIndices(RegularStructure<Dimension> &rs,
vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
{
rs.GetNodesOfCells(index,ids);
}
};
template<vtkm::cont::TopologyType FromTopology, vtkm::cont::TopologyType ToTopoogy,
2015-05-14 20:18:30 +00:00
vtkm::IdComponent Dimension>
class RegularConnectivity
{
public:
VTKM_EXEC_CONT_EXPORT
void SetNodeDimension(int node_i, int node_j=0, int node_k=0)
2015-04-15 14:45:39 +00:00
{
rs.SetNodeDimension(node_i, node_j, node_k);
2015-04-15 14:45:39 +00:00
}
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfElements() const {return rs.GetNumberOfElements();}
VTKM_EXEC_CONT_EXPORT
2015-05-15 16:03:52 +00:00
vtkm::Id GetNumberOfIndices(vtkm::Id=0) const {return rs.GetNumberOfIndices();}
VTKM_EXEC_CONT_EXPORT
2015-05-15 16:03:52 +00:00
vtkm::CellType GetElementShapeType(vtkm::Id=0) const {return rs.GetElementShapeType();}
2015-05-14 20:18:30 +00:00
template <vtkm::IdComponent ItemTupleLength>
VTKM_EXEC_CONT_EXPORT
2015-05-14 20:26:59 +00:00
void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
{
IndexLookupHelper<FromTopology,ToTopoogy,Dimension>::GetIndices(rs,index,ids);
2015-05-14 20:26:59 +00:00
}
private:
RegularStructure<Dimension> rs;
2015-04-15 14:45:39 +00:00
};
} // namespace vtkm
2015-04-15 14:45:39 +00:00
#endif //vtk_m_RegularConnectivity_h