2015-11-03 03:24:57 +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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2015-11-03 03:24:57 +00:00
|
|
|
// Copyright 2015 UT-Battelle, LLC.
|
|
|
|
// Copyright 2015 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2015-11-03 03:24:57 +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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_cont_DataSetBuilderExplicit_h
|
|
|
|
#define vtk_m_cont_DataSetBuilderExplicit_h
|
|
|
|
|
2016-01-06 18:47:34 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
2016-01-15 21:31:05 +00:00
|
|
|
#include <vtkm/cont/ArrayPortalToIterators.h>
|
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
|
|
|
#include <vtkm/cont/DataSet.h>
|
2015-11-03 03:24:57 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2015-11-03 03:24:57 +00:00
|
|
|
|
|
|
|
//Coordinates builder??
|
|
|
|
//Need a singlecellset handler.
|
|
|
|
|
|
|
|
class DataSetBuilderExplicit
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT static void CopyInto(const std::vector<T>& input, vtkm::cont::ArrayHandle<T>& output)
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
output.Allocate(static_cast<vtkm::Id>(input.size()));
|
|
|
|
std::copy(input.begin(), input.end(), ArrayPortalToIteratorBegin(output.GetPortalControl()));
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
|
2015-11-03 03:24:57 +00:00
|
|
|
public:
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-15 21:31:05 +00:00
|
|
|
DataSetBuilderExplicit() {}
|
|
|
|
|
|
|
|
//Single cell explicits.
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
//Zoo explicit cell
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xVals,
|
|
|
|
const std::vector<vtkm::UInt8>& shapes,
|
|
|
|
const std::vector<vtkm::IdComponent>& numIndices,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
|
|
|
const std::string& cellNm = "cells")
|
2016-11-28 21:07:40 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
std::vector<T> yVals(xVals.size(), 0), zVals(xVals.size(), 0);
|
2017-05-26 17:53:28 +00:00
|
|
|
return DataSetBuilderExplicit::Create(
|
|
|
|
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm, cellNm);
|
2016-11-28 21:07:40 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xVals,
|
|
|
|
const std::vector<T>& yVals,
|
|
|
|
const std::vector<vtkm::UInt8>& shapes,
|
|
|
|
const std::vector<vtkm::IdComponent>& numIndices,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
|
|
|
const std::string& cellNm = "cells")
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
std::vector<T> zVals(xVals.size(), 0);
|
2017-05-26 17:53:28 +00:00
|
|
|
return DataSetBuilderExplicit::Create(
|
|
|
|
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm, cellNm);
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xVals,
|
|
|
|
const std::vector<T>& yVals,
|
|
|
|
const std::vector<T>& zVals,
|
|
|
|
const std::vector<vtkm::UInt8>& shapes,
|
|
|
|
const std::vector<vtkm::IdComponent>& numIndices,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
|
|
|
const std::string& cellNm = "cells");
|
2017-05-18 14:29:41 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T>& xVals,
|
|
|
|
const vtkm::cont::ArrayHandle<T>& yVals,
|
|
|
|
const vtkm::cont::ArrayHandle<T>& zVals,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::string& cellNm = "cells")
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-26 17:53:28 +00:00
|
|
|
return DataSetBuilderExplicit::BuildDataSet(
|
|
|
|
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm, cellNm);
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<vtkm::Vec<T, 3>>& coords,
|
|
|
|
const std::vector<vtkm::UInt8>& shapes,
|
|
|
|
const std::vector<vtkm::IdComponent>& numIndices,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
|
|
|
const std::string& cellNm = "cells");
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::string& cellNm = "cells")
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-26 17:53:28 +00:00
|
|
|
return DataSetBuilderExplicit::BuildDataSet(
|
|
|
|
coords, shapes, numIndices, connectivity, coordsNm, cellNm);
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename CellShapeTag>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<vtkm::Vec<T, 3>>& coords,
|
|
|
|
CellShapeTag tag,
|
|
|
|
vtkm::IdComponent numberOfPointsPerCell,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
|
|
|
const std::string& cellNm = "cells");
|
|
|
|
|
|
|
|
template <typename T, typename CellShapeTag>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet Create(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
|
|
|
CellShapeTag tag,
|
|
|
|
vtkm::IdComponent numberOfPointsPerCell,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm = "coords",
|
|
|
|
const std::string& cellNm = "cells")
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-26 17:53:28 +00:00
|
|
|
return DataSetBuilderExplicit::BuildDataSet(
|
|
|
|
coords, tag, numberOfPointsPerCell, connectivity, coordsNm, cellNm);
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2016-01-05 21:28:57 +00:00
|
|
|
private:
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
static vtkm::cont::DataSet BuildDataSet(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T>& X,
|
|
|
|
const vtkm::cont::ArrayHandle<T>& Y,
|
|
|
|
const vtkm::cont::ArrayHandle<T>& Z,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::string& cellNm);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::string& cellNm);
|
|
|
|
|
|
|
|
template <typename T, typename CellShapeTag>
|
|
|
|
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
|
|
|
CellShapeTag tag,
|
|
|
|
vtkm::IdComponent numberOfPointsPerCell,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
|
|
|
const std::string& cellNm);
|
2016-01-05 21:28:57 +00:00
|
|
|
};
|
2015-12-11 14:53:06 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
2017-05-26 17:53:28 +00:00
|
|
|
const std::vector<T>& xVals,
|
|
|
|
const std::vector<T>& yVals,
|
|
|
|
const std::vector<T>& zVals,
|
|
|
|
const std::vector<vtkm::UInt8>& shapes,
|
|
|
|
const std::vector<vtkm::IdComponent>& numIndices,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
|
|
|
const std::string& cellNm)
|
2015-11-03 03:24:57 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_ASSERT(xVals.size() == yVals.size() && yVals.size() == zVals.size() && xVals.size() > 0);
|
2016-01-15 21:31:05 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<T> Xc, Yc, Zc;
|
2016-01-21 17:45:33 +00:00
|
|
|
DataSetBuilderExplicit::CopyInto(xVals, Xc);
|
|
|
|
DataSetBuilderExplicit::CopyInto(yVals, Yc);
|
|
|
|
DataSetBuilderExplicit::CopyInto(zVals, Zc);
|
2016-01-15 21:31:05 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::UInt8> Sc;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> Nc;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> Cc;
|
2016-01-21 17:45:33 +00:00
|
|
|
DataSetBuilderExplicit::CopyInto(shapes, Sc);
|
|
|
|
DataSetBuilderExplicit::CopyInto(numIndices, Nc);
|
|
|
|
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
2016-01-15 21:31:05 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
return DataSetBuilderExplicit::BuildDataSet(Xc, Yc, Zc, Sc, Nc, Cc, coordsNm, cellNm);
|
2015-11-03 03:24:57 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T>& X,
|
|
|
|
const vtkm::cont::ArrayHandle<T>& Y,
|
|
|
|
const vtkm::cont::ArrayHandle<T>& Z,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::string& cellNm)
|
2015-11-03 03:24:57 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(X.GetNumberOfValues() == Y.GetNumberOfValues() &&
|
2017-05-18 14:29:41 +00:00
|
|
|
Y.GetNumberOfValues() == Z.GetNumberOfValues() && X.GetNumberOfValues() > 0 &&
|
|
|
|
shapes.GetNumberOfValues() == numIndices.GetNumberOfValues());
|
2016-01-15 21:31:05 +00:00
|
|
|
|
|
|
|
vtkm::cont::DataSet dataSet;
|
|
|
|
dataSet.AddCoordinateSystem(
|
2018-05-10 17:06:08 +00:00
|
|
|
vtkm::cont::CoordinateSystem(coordsNm, make_ArrayHandleCompositeVector(X, Y, Z)));
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::Id nPts = X.GetNumberOfValues();
|
2016-12-20 23:14:50 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
|
2016-01-15 21:31:05 +00:00
|
|
|
|
2016-12-20 23:14:50 +00:00
|
|
|
cellSet.Fill(nPts, shapes, numIndices, connectivity);
|
2016-01-15 21:31:05 +00:00
|
|
|
dataSet.AddCellSet(cellSet);
|
|
|
|
|
|
|
|
return dataSet;
|
2015-11-03 03:24:57 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
2017-05-26 17:53:28 +00:00
|
|
|
const std::vector<vtkm::Vec<T, 3>>& coords,
|
|
|
|
const std::vector<vtkm::UInt8>& shapes,
|
|
|
|
const std::vector<vtkm::IdComponent>& numIndices,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
|
|
|
const std::string& cellNm)
|
2015-11-03 03:24:57 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<Vec<T, 3>> coordsArray;
|
2016-01-21 17:45:33 +00:00
|
|
|
DataSetBuilderExplicit::CopyInto(coords, coordsArray);
|
2015-12-04 21:15:51 +00:00
|
|
|
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::UInt8> Sc;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> Nc;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> Cc;
|
2016-01-21 17:45:33 +00:00
|
|
|
DataSetBuilderExplicit::CopyInto(shapes, Sc);
|
|
|
|
DataSetBuilderExplicit::CopyInto(numIndices, Nc);
|
|
|
|
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
return DataSetBuilderExplicit::Create(coordsArray, Sc, Nc, Cc, coordsNm, cellNm);
|
2016-01-05 21:28:57 +00:00
|
|
|
}
|
2015-12-04 21:15:51 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::string& cellNm)
|
2016-01-05 21:28:57 +00:00
|
|
|
{
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::cont::DataSet dataSet;
|
2016-01-05 21:28:57 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::Id nPts = static_cast<vtkm::Id>(coords.GetNumberOfValues());
|
2016-12-20 23:14:50 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2016-12-20 23:14:50 +00:00
|
|
|
cellSet.Fill(nPts, shapes, numIndices, connectivity);
|
2016-01-15 21:31:05 +00:00
|
|
|
dataSet.AddCellSet(cellSet);
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2016-01-15 21:31:05 +00:00
|
|
|
return dataSet;
|
2015-11-03 03:24:57 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename CellShapeTag>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
2017-05-26 17:53:28 +00:00
|
|
|
const std::vector<vtkm::Vec<T, 3>>& coords,
|
|
|
|
CellShapeTag tag,
|
|
|
|
vtkm::IdComponent numberOfPointsPerCell,
|
|
|
|
const std::vector<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
|
|
|
const std::string& cellNm)
|
2016-01-15 20:06:09 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<Vec<T, 3>> coordsArray;
|
2016-01-21 17:45:33 +00:00
|
|
|
DataSetBuilderExplicit::CopyInto(coords, coordsArray);
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> Cc;
|
2016-01-21 17:45:33 +00:00
|
|
|
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
return DataSetBuilderExplicit::Create(
|
|
|
|
coordsArray, tag, numberOfPointsPerCell, Cc, coordsNm, cellNm);
|
2016-01-15 20:06:09 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename CellShapeTag>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
|
|
|
CellShapeTag tag,
|
|
|
|
vtkm::IdComponent numberOfPointsPerCell,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
|
|
|
const std::string& coordsNm,
|
|
|
|
const std::string& cellNm)
|
2016-01-15 20:06:09 +00:00
|
|
|
{
|
2017-09-21 14:33:17 +00:00
|
|
|
(void)tag; //C4100 false positive workaround
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::cont::DataSet dataSet;
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2016-03-23 14:38:14 +00:00
|
|
|
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
2016-12-20 23:14:50 +00:00
|
|
|
vtkm::cont::CellSetSingleType<> cellSet(cellNm);
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
cellSet.Fill(coords.GetNumberOfValues(), tag.Id, numberOfPointsPerCell, connectivity);
|
2016-01-15 21:31:05 +00:00
|
|
|
dataSet.AddCellSet(cellSet);
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2016-01-15 21:31:05 +00:00
|
|
|
return dataSet;
|
2016-01-15 20:06:09 +00:00
|
|
|
}
|
|
|
|
|
2015-12-16 20:39:06 +00:00
|
|
|
class DataSetBuilderExplicitIterative
|
2015-11-04 12:45:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-15 21:31:05 +00:00
|
|
|
DataSetBuilderExplicitIterative() {}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void Begin(const std::string& coordName = "coords", const std::string& cellName = "cells")
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
|
|
|
this->coordNm = coordName;
|
|
|
|
this->cellNm = cellName;
|
2016-01-15 21:16:38 +00:00
|
|
|
this->points.resize(0);
|
|
|
|
this->shapes.resize(0);
|
|
|
|
this->numIdx.resize(0);
|
|
|
|
this->connectivity.resize(0);
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Define points.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::cont::DataSet Create();
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id AddPoint(const vtkm::Vec<vtkm::Float32, 3>& pt)
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
|
|
|
points.push_back(pt);
|
|
|
|
vtkm::Id id = static_cast<vtkm::Id>(points.size());
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id AddPoint(const vtkm::Float32& x, const vtkm::Float32& y, const vtkm::Float32& z = 0)
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
points.push_back(vtkm::make_Vec(x, y, z));
|
2016-01-15 21:31:05 +00:00
|
|
|
vtkm::Id id = static_cast<vtkm::Id>(points.size());
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT vtkm::Id AddPoint(const T& x, const T& y, const T& z = 0)
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-26 17:53:28 +00:00
|
|
|
return AddPoint(
|
|
|
|
static_cast<vtkm::Float32>(x), static_cast<vtkm::Float32>(y), static_cast<vtkm::Float32>(z));
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_CONT vtkm::Id AddPoint(const vtkm::Vec<T, 3>& pt)
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
return AddPoint(static_cast<vtkm::Vec<vtkm::Float32, 3>>(pt));
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Define cells.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-15 21:31:05 +00:00
|
|
|
void AddCell(vtkm::UInt8 shape)
|
|
|
|
{
|
|
|
|
this->shapes.push_back(shape);
|
|
|
|
this->numIdx.push_back(0);
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void AddCell(const vtkm::UInt8& shape, const std::vector<vtkm::Id>& conn)
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
|
|
|
this->shapes.push_back(shape);
|
|
|
|
this->numIdx.push_back(static_cast<vtkm::IdComponent>(conn.size()));
|
|
|
|
connectivity.insert(connectivity.end(), conn.begin(), conn.end());
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void AddCell(const vtkm::UInt8& shape, const vtkm::Id* conn, const vtkm::IdComponent& n)
|
2016-01-15 21:31:05 +00:00
|
|
|
{
|
|
|
|
this->shapes.push_back(shape);
|
|
|
|
this->numIdx.push_back(n);
|
|
|
|
for (int i = 0; i < n; i++)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
connectivity.push_back(conn[i]);
|
|
|
|
}
|
2016-01-15 21:31:05 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-15 21:31:05 +00:00
|
|
|
void AddCellPoint(vtkm::Id pointIndex)
|
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->numIdx.size() > 0);
|
2016-01-15 21:31:05 +00:00
|
|
|
this->connectivity.push_back(pointIndex);
|
|
|
|
this->numIdx.back() += 1;
|
|
|
|
}
|
2016-01-15 20:06:09 +00:00
|
|
|
|
2015-11-04 12:45:51 +00:00
|
|
|
private:
|
2016-01-15 21:31:05 +00:00
|
|
|
std::string coordNm, cellNm;
|
2015-11-04 12:45:51 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
std::vector<vtkm::Vec<vtkm::Float32, 3>> points;
|
2016-01-15 21:31:05 +00:00
|
|
|
std::vector<vtkm::UInt8> shapes;
|
|
|
|
std::vector<vtkm::IdComponent> numIdx;
|
|
|
|
std::vector<vtkm::Id> connectivity;
|
2015-11-04 12:45:51 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicitIterative::Create()
|
2015-11-04 12:45:51 +00:00
|
|
|
{
|
2016-01-15 21:31:05 +00:00
|
|
|
DataSetBuilderExplicit dsb;
|
2016-05-13 18:26:59 +00:00
|
|
|
return dsb.Create(points, shapes, numIdx, connectivity, coordNm, cellNm);
|
2015-11-04 12:45:51 +00:00
|
|
|
}
|
2015-11-03 03:24:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //vtk_m_cont_DataSetBuilderExplicit_h
|