//============================================================================ // 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. //============================================================================ #include #include #include #include namespace vtkm { namespace cont { CellSetExtrude::CellSetExtrude(const std::string& name) : vtkm::cont::CellSet(name) , IsPeriodic(false) , NumberOfPointsPerPlane(0) , NumberOfCellsPerPlane(0) , NumberOfPlanes(0) , ReverseConnectivityBuilt(false) { } CellSetExtrude::CellSetExtrude(const vtkm::cont::ArrayHandle& conn, vtkm::Int32 numberOfPointsPerPlane, vtkm::Int32 numberOfPlanes, const vtkm::cont::ArrayHandle& nextNode, bool periodic, const std::string& name) : vtkm::cont::CellSet(name) , IsPeriodic(periodic) , NumberOfPointsPerPlane(numberOfPointsPerPlane) , NumberOfCellsPerPlane( static_cast(conn.GetNumberOfValues() / static_cast(3))) , NumberOfPlanes(numberOfPlanes) , Connectivity(conn) , NextNode(nextNode) , ReverseConnectivityBuilt(false) { } vtkm::Int32 CellSetExtrude::GetNumberOfPlanes() const { return this->NumberOfPlanes; } vtkm::Id CellSetExtrude::GetNumberOfCells() const { if (this->IsPeriodic) { return static_cast(this->NumberOfPlanes) * static_cast(this->NumberOfCellsPerPlane); } else { return static_cast(this->NumberOfPlanes - 1) * static_cast(this->NumberOfCellsPerPlane); } } vtkm::Id CellSetExtrude::GetNumberOfPoints() const { return static_cast(this->NumberOfPlanes) * static_cast(this->NumberOfPointsPerPlane); } vtkm::Id CellSetExtrude::GetNumberOfFaces() const { return -1; } vtkm::Id CellSetExtrude::GetNumberOfEdges() const { return -1; } vtkm::UInt8 CellSetExtrude::GetCellShape(vtkm::Id) const { return vtkm::CellShapeTagWedge::Id; } vtkm::IdComponent CellSetExtrude::GetNumberOfPointsInCell(vtkm::Id) const { return 6; } void CellSetExtrude::GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const { auto conn = this->PrepareForInput(vtkm::cont::DeviceAdapterTagSerial{}, vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{}); auto indices = conn.GetIndices(id); for (int i = 0; i < 6; ++i) { ptids[i] = indices[i]; } } std::shared_ptr CellSetExtrude::NewInstance() const { return std::make_shared(); } void CellSetExtrude::DeepCopy(const CellSet* src) { const auto* other = dynamic_cast(src); if (!other) { throw vtkm::cont::ErrorBadType("CellSetExplicit::DeepCopy types don't match"); } this->IsPeriodic = other->IsPeriodic; this->NumberOfPointsPerPlane = other->NumberOfPointsPerPlane; this->NumberOfCellsPerPlane = other->NumberOfCellsPerPlane; this->NumberOfPlanes = other->NumberOfPlanes; vtkm::cont::ArrayCopy(other->Connectivity, this->Connectivity); vtkm::cont::ArrayCopy(other->NextNode, this->NextNode); this->ReverseConnectivityBuilt = other->ReverseConnectivityBuilt; if (this->ReverseConnectivityBuilt) { vtkm::cont::ArrayCopy(other->RConnectivity, this->RConnectivity); vtkm::cont::ArrayCopy(other->ROffsets, this->ROffsets); vtkm::cont::ArrayCopy(other->RCounts, this->RCounts); vtkm::cont::ArrayCopy(other->PrevNode, this->PrevNode); } } void CellSetExtrude::ReleaseResourcesExecution() { this->Connectivity.ReleaseResourcesExecution(); this->NextNode.ReleaseResourcesExecution(); this->RConnectivity.ReleaseResourcesExecution(); this->ROffsets.ReleaseResourcesExecution(); this->RCounts.ReleaseResourcesExecution(); this->PrevNode.ReleaseResourcesExecution(); } vtkm::Id2 CellSetExtrude::GetSchedulingRange(vtkm::TopologyElementTagCell) const { if (this->IsPeriodic) { return vtkm::Id2(this->NumberOfCellsPerPlane, this->NumberOfPlanes); } else { return vtkm::Id2(this->NumberOfCellsPerPlane, this->NumberOfPlanes - 1); } } vtkm::Id2 CellSetExtrude::GetSchedulingRange(vtkm::TopologyElementTagPoint) const { return vtkm::Id2(this->NumberOfPointsPerPlane, this->NumberOfPlanes); } void CellSetExtrude::PrintSummary(std::ostream& out) const { out << " vtkmCellSetSingleType: " << this->Name << std::endl; out << " NumberOfCellsPerPlane: " << this->NumberOfCellsPerPlane << std::endl; out << " NumberOfPointsPerPlane: " << this->NumberOfPointsPerPlane << std::endl; out << " NumberOfPlanes: " << this->NumberOfPlanes << std::endl; out << " Connectivity: " << std::endl; vtkm::cont::printSummary_ArrayHandle(this->Connectivity, out); out << " NextNode: " << std::endl; vtkm::cont::printSummary_ArrayHandle(this->NextNode, out); out << " ReverseConnectivityBuilt: " << this->NumberOfPlanes << std::endl; } } } // vtkm::cont