vtk-m/vtkm/cont/MultiBlock.h

104 lines
3.6 KiB
C
Raw Normal View History

2017-05-10 00:27:03 +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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
2017-05-10 00:27:03 +00:00
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
2017-05-10 00:27:03 +00:00
// 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.
//============================================================================
2017-08-01 23:38:35 +00:00
#ifndef vtk_m_cont_MultiBlock_h
2017-05-10 00:27:03 +00:00
#define vtk_m_cont_MultiBlock_h
2017-08-18 20:28:33 +00:00
#include <limits>
2017-05-10 00:27:03 +00:00
#include <vtkm/StaticAssert.h>
#include <vtkm/cont/ArrayHandle.h>
2017-05-11 19:25:08 +00:00
#include <vtkm/cont/DataSet.h>
2017-05-10 00:27:03 +00:00
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
2017-08-18 20:28:33 +00:00
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/Field.h>
2017-05-10 00:27:03 +00:00
2017-08-18 20:28:33 +00:00
namespace vtkm
{
namespace cont
{
2017-05-10 00:27:03 +00:00
2017-08-18 20:28:33 +00:00
class VTKM_CONT_EXPORT MultiBlock
2017-05-10 00:27:03 +00:00
{
public:
/// create a new MultiBlock containng a single DataSet "ds"
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
MultiBlock(const vtkm::cont::DataSet& ds);
/// create a new MultiBlock with the existing one "src"
2017-08-18 20:28:33 +00:00
VTKM_CONT
MultiBlock(const vtkm::cont::MultiBlock& src);
/// create a new MultiBlock with a DataSet vector "mblocks"
2017-08-02 02:11:17 +00:00
VTKM_CONT
explicit MultiBlock(const std::vector<vtkm::cont::DataSet>& mblocks);
/// create a new MultiBlock with the capacity set to be "size"
2017-08-02 02:11:17 +00:00
VTKM_CONT
explicit MultiBlock(vtkm::Id size);
2017-08-18 20:28:33 +00:00
2017-08-02 19:18:55 +00:00
VTKM_CONT
2017-08-02 03:15:41 +00:00
MultiBlock();
2017-08-18 20:28:33 +00:00
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
MultiBlock& operator=(const vtkm::cont::MultiBlock& src);
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-02 03:15:41 +00:00
~MultiBlock();
/// get the field "field_name" from block "block_index"
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-21 17:11:04 +00:00
vtkm::cont::Field GetField(const std::string& field_name, const int& block_index);
2017-08-18 20:28:33 +00:00
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-07-20 19:11:12 +00:00
vtkm::Id GetNumberOfBlocks() const;
2017-08-18 20:28:33 +00:00
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
const vtkm::cont::DataSet& GetBlock(vtkm::Id blockId) const;
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
const std::vector<vtkm::cont::DataSet>& GetBlocks() const;
2017-08-21 17:11:04 +00:00
/// add DataSet "ds" to the end of the contained DataSet vector
2017-08-18 20:28:33 +00:00
VTKM_CONT
void AddBlock(const vtkm::cont::DataSet& ds);
2017-08-21 17:11:04 +00:00
/// add DataSet "ds" to position "index" of the contained DataSet vector
2017-08-18 20:28:33 +00:00
VTKM_CONT
void InsertBlock(vtkm::Id index, const vtkm::cont::DataSet& ds);
2017-08-21 17:11:04 +00:00
/// replace the "index" positioned element of the contained DataSet vector with "ds"
2017-08-18 20:28:33 +00:00
VTKM_CONT
void ReplaceBlock(vtkm::Id index, const vtkm::cont::DataSet& ds);
2017-08-21 17:11:04 +00:00
/// append the DataSet vector "mblocks" to the end of the contained one
2017-08-18 20:28:33 +00:00
VTKM_CONT
void AddBlocks(const std::vector<vtkm::cont::DataSet>& mblocks);
2017-08-18 20:28:33 +00:00
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
void PrintSummary(std::ostream& stream) const;
//@{
/// API to support range-based for loops on blocks.
std::vector<DataSet>::iterator begin() noexcept { return this->Blocks.begin(); }
std::vector<DataSet>::iterator end() noexcept { return this->Blocks.end(); }
std::vector<DataSet>::const_iterator begin() const noexcept { return this->Blocks.begin(); }
std::vector<DataSet>::const_iterator end() const noexcept { return this->Blocks.end(); }
std::vector<DataSet>::const_iterator cbegin() const noexcept { return this->Blocks.begin(); }
std::vector<DataSet>::const_iterator cend() const noexcept { return this->Blocks.end(); }
//@}
2017-05-10 00:27:03 +00:00
private:
std::vector<vtkm::cont::DataSet> Blocks;
2017-05-10 00:27:03 +00:00
};
}
} // namespace vtkm::cont
2017-08-02 19:18:55 +00:00
#endif