//============================================================================ // 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 #include #include #include #include #include namespace vtkm { template 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 struct IndexLookupHelper { template VTKM_EXEC_CONT_EXPORT static void GetIndices(RegularStructure &rs, vtkm::Id index, vtkm::Vec &ids) { rs.GetNodesOfCells(index,ids); } }; template struct IndexLookupHelper { template VTKM_EXEC_CONT_EXPORT static void GetIndices(RegularStructure &rs, vtkm::Id index, vtkm::Vec &ids) { rs.GetCellsOfNode(index,ids); } }; template class RegularConnectivity { public: RegularConnectivity(): rs() { } RegularConnectivity(RegularStructure regularStructure): rs(regularStructure) { } RegularConnectivity( const RegularConnectivity& other): rs(other.rs) { } VTKM_EXEC_CONT_EXPORT vtkm::Id GetNumberOfElements() const {return rs.GetNumberOfElements();} VTKM_EXEC_CONT_EXPORT vtkm::Id GetNumberOfIndices(vtkm::Id=0) const {return rs.GetNumberOfIndices();} VTKM_EXEC_CONT_EXPORT vtkm::CellType GetElementShapeType(vtkm::Id=0) const {return rs.GetElementShapeType();} template VTKM_EXEC_CONT_EXPORT void GetIndices(vtkm::Id index, vtkm::Vec &ids) { IndexLookupHelper::GetIndices(rs,index,ids); } template struct ExecutionTypes { //Using this style so we can template the RegularConnecivity based on the //backend in the future without have to change the Transport logic typedef vtkm::RegularConnectivity ExecObjectType; }; template typename ExecutionTypes::ExecObjectType PrepareForInput(DeviceAdapterTag) const { return typename ExecutionTypes::ExecObjectType(*this); } private: RegularStructure rs; }; } // namespace vtkm #endif //vtk_m_RegularConnectivity_h