//============================================================================ // 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 2015 Sandia Corporation. // Copyright 2015 UT-Battelle, LLC. // Copyright 2015 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 "vtkmlib/Storage.h" #include "vtkmConnectivityExec.h" namespace vtkm { namespace exec { //------------------------------------------------------------------------------ template ConnectivityVTKAOS::ConnectivityVTKAOS() { } //------------------------------------------------------------------------------ template ConnectivityVTKAOS::ConnectivityVTKAOS( const ShapePortalType& shapePortal, const ConnectivityPortalType& connPortal, const IndexOffsetPortalType& indexOffsetPortal) : Shapes(shapePortal), Connectivity(connPortal), IndexOffsets(indexOffsetPortal) { } //------------------------------------------------------------------------------ template vtkm::Id ConnectivityVTKAOS::GetNumberOfElements() const { return this->Shapes.GetNumberOfValues(); } //------------------------------------------------------------------------------ template typename ConnectivityVTKAOS::CellShapeTag ConnectivityVTKAOS::GetCellShape(vtkm::Id index) const { // VTK-m and VTK cell shape numeric values are identical so no // conversion is needed return CellShapeTag(this->Shapes.Get(index)); } //------------------------------------------------------------------------------ template typename ConnectivityVTKAOS::IndicesType ConnectivityVTKAOS::GetIndices(vtkm::Id index) const { vtkm::Id offset = this->IndexOffsets.Get(index); vtkm::IdComponent length = this->Connectivity.Get(offset); return IndicesType(this->Connectivity, length, offset + 1); } //------------------------------------------------------------------------------ template ConnectivityVTKSingleType::ConnectivityVTKSingleType() : Connectivity(), NumberOfCells(0), NumberOfPointsPerCell(0), ShapeType(0) { } //------------------------------------------------------------------------------ template ConnectivityVTKSingleType::ConnectivityVTKSingleType( const ConnectivityPortalType& connPortal, vtkm::Id numCells, vtkm::IdComponent numPointsPerCell, vtkm::UInt8 shapeType) : Connectivity(connPortal), NumberOfCells(numCells), NumberOfPointsPerCell(numPointsPerCell), ShapeType(shapeType) { } //------------------------------------------------------------------------------ template vtkm::Id ConnectivityVTKSingleType::GetNumberOfElements() const { return this->NumberOfCells; } //------------------------------------------------------------------------------ template typename ConnectivityVTKSingleType::CellShapeTag ConnectivityVTKSingleType::GetCellShape( vtkm::Id vtkmNotUsed(index)) const { // VTK-m and VTK cell shape numeric values are identical so no // conversion is needed return this->ShapeType; } //------------------------------------------------------------------------------ template typename ConnectivityVTKSingleType::IndicesType ConnectivityVTKSingleType::GetIndices(vtkm::Id index) const { // compute the offset, accounting for the VTK padding per cell const vtkm::Id offset = index * (this->NumberOfPointsPerCell + 1); // we do offset + 1 to skip the padding on the current cell return IndicesType(this->Connectivity, this->NumberOfPointsPerCell, offset + 1); } //------------------------------------------------------------------------------ template ReverseConnectivityVTK::ReverseConnectivityVTK() { } //------------------------------------------------------------------------------ template ReverseConnectivityVTK::ReverseConnectivityVTK( const ConnectivityPortalType& connPortal, const NumIndicesPortalType& numIndicesPortal, const IndexOffsetPortalType& indexOffsetPortal) : Connectivity(connPortal), NumIndices(numIndicesPortal), IndexOffsets(indexOffsetPortal) { } //------------------------------------------------------------------------------ template vtkm::Id ReverseConnectivityVTK::GetNumberOfElements() const { return this->NumIndices.GetNumberOfValues(); } //------------------------------------------------------------------------------ template typename ReverseConnectivityVTK::IndicesType ReverseConnectivityVTK::GetIndices(vtkm::Id index) const { vtkm::Id offset = this->IndexOffsets.Get(index); vtkm::IdComponent length = this->NumIndices.Get(index); return IndicesType(this->Connectivity, length, offset); } // template methods we want to compile only once template class ConnectivityVTKAOS; template class ConnectivityVTKSingleType; template class ReverseConnectivityVTK; #ifdef VTKM_ENABLE_TBB template class ConnectivityVTKAOS; template class ConnectivityVTKSingleType; template class ReverseConnectivityVTK; #endif } }