2015-05-18 17:17: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 2014 Sandia Corporation.
|
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-06-03 19:06:43 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2015-05-18 17:17:03 +00:00
|
|
|
//
|
|
|
|
// 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_cont_testing_MakeTestDataSet_h
|
|
|
|
#define vtk_m_cont_testing_MakeTestDataSet_h
|
|
|
|
|
2015-08-17 18:47:46 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
2015-05-18 17:17:03 +00:00
|
|
|
#include <vtkm/cont/DataSet.h>
|
2015-11-03 10:59:37 +00:00
|
|
|
#include <vtkm/cont/DataSetBuilderRegular.h>
|
|
|
|
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
|
|
|
#include <vtkm/cont/DataSetFieldAdd.h>
|
2015-05-18 17:17:03 +00:00
|
|
|
|
|
|
|
namespace vtkm {
|
|
|
|
namespace cont {
|
|
|
|
namespace testing {
|
|
|
|
|
|
|
|
class MakeTestDataSet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// 2D regular datasets.
|
2015-11-03 10:59:37 +00:00
|
|
|
VTKM_CONT_EXPORT
|
2015-05-28 19:35:19 +00:00
|
|
|
vtkm::cont::DataSet Make2DRegularDataSet0();
|
2015-05-18 17:17:03 +00:00
|
|
|
|
|
|
|
// 3D regular datasets.
|
2015-11-03 10:59:37 +00:00
|
|
|
VTKM_CONT_EXPORT
|
2015-05-28 19:35:19 +00:00
|
|
|
vtkm::cont::DataSet Make3DRegularDataSet0();
|
2015-05-19 17:10:56 +00:00
|
|
|
|
|
|
|
// 3D explicit datasets.
|
2015-11-03 10:59:37 +00:00
|
|
|
VTKM_CONT_EXPORT
|
2015-05-28 19:35:19 +00:00
|
|
|
vtkm::cont::DataSet Make3DExplicitDataSet0();
|
2015-11-03 10:59:37 +00:00
|
|
|
VTKM_CONT_EXPORT
|
2015-06-19 18:23:20 +00:00
|
|
|
vtkm::cont::DataSet Make3DExplicitDataSetCowNose(double *pBounds = NULL);
|
2015-05-18 17:17:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//Make a simple 2D, 2 cell regular dataset.
|
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSet
|
2015-05-18 17:17:03 +00:00
|
|
|
MakeTestDataSet::Make2DRegularDataSet0()
|
|
|
|
{
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSetBuilderRegular dsb;
|
|
|
|
vtkm::cont::DataSet dataSet = dsb.Create(3,2);
|
2015-05-18 17:17:03 +00:00
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSetFieldAdd dsf;
|
|
|
|
const vtkm::Id nVerts = 6;
|
|
|
|
vtkm::Float32 var[nVerts] = {10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f};
|
|
|
|
|
|
|
|
dsf.AddPointField(dataSet, "pointvar", var, nVerts);
|
2015-05-19 20:49:17 +00:00
|
|
|
|
2015-06-04 13:06:47 +00:00
|
|
|
vtkm::Float32 cellvar[2] = {100.1f, 200.1f};
|
2015-11-03 10:59:37 +00:00
|
|
|
dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells");
|
2015-05-18 17:17:03 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
return dataSet;
|
2015-05-18 17:17:03 +00:00
|
|
|
}
|
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSet
|
2015-05-18 17:17:03 +00:00
|
|
|
MakeTestDataSet::Make3DRegularDataSet0()
|
|
|
|
{
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSetBuilderRegular dsb;
|
|
|
|
vtkm::cont::DataSet dataSet = dsb.Create(3,2,3);
|
2015-05-18 17:17:03 +00:00
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSetFieldAdd dsf;
|
2015-05-18 17:17:03 +00:00
|
|
|
const int nVerts = 18;
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.1f, 40.1f, 50.2f,
|
|
|
|
60.2f, 70.2f, 80.2f, 90.3f, 100.3f,
|
|
|
|
110.3f, 120.3f, 130.4f, 140.4f,
|
|
|
|
150.4f, 160.4f, 170.5f, 180.5f};
|
2015-05-18 17:17:03 +00:00
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
//Set point and cell scalar
|
|
|
|
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
|
2015-05-18 17:17:03 +00:00
|
|
|
|
2015-06-04 13:06:47 +00:00
|
|
|
vtkm::Float32 cellvar[4] = {100.1f, 100.2f, 100.3f, 100.4f};
|
2015-11-03 10:59:37 +00:00
|
|
|
dsf.AddCellField(dataSet, "cellvar", cellvar, 4, "cells");
|
2015-05-18 17:17:03 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
return dataSet;
|
2015-05-18 17:17:03 +00:00
|
|
|
}
|
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSet
|
2015-05-19 17:10:56 +00:00
|
|
|
MakeTestDataSet::Make3DExplicitDataSet0()
|
|
|
|
{
|
2015-08-02 21:59:44 +00:00
|
|
|
vtkm::cont::DataSet dataSet;
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSetBuilderExplicit dsb;
|
2015-05-19 17:10:56 +00:00
|
|
|
|
|
|
|
const int nVerts = 5;
|
2015-08-17 18:47:46 +00:00
|
|
|
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
2015-11-03 10:59:37 +00:00
|
|
|
std::vector<CoordType> coords(nVerts);
|
|
|
|
coords[0] = CoordType(0, 0, 0);
|
|
|
|
coords[1] = CoordType(1, 0, 0);
|
|
|
|
coords[2] = CoordType(1, 1, 0);
|
|
|
|
coords[3] = CoordType(2, 1, 0);
|
|
|
|
coords[4] = CoordType(2, 2, 0);
|
|
|
|
|
|
|
|
//Connectivity
|
2015-09-01 21:51:21 +00:00
|
|
|
std::vector<vtkm::UInt8> shapes;
|
2015-08-16 18:53:44 +00:00
|
|
|
shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE);
|
|
|
|
shapes.push_back(vtkm::CELL_SHAPE_QUAD);
|
2015-05-19 17:10:56 +00:00
|
|
|
|
2015-09-01 21:51:21 +00:00
|
|
|
std::vector<vtkm::IdComponent> numindices;
|
2015-05-19 17:10:56 +00:00
|
|
|
numindices.push_back(3);
|
|
|
|
numindices.push_back(4);
|
|
|
|
|
|
|
|
std::vector<vtkm::Id> conn;
|
|
|
|
// First Cell: Triangle
|
|
|
|
conn.push_back(0);
|
|
|
|
conn.push_back(1);
|
|
|
|
conn.push_back(2);
|
|
|
|
// Second Cell: Quad
|
|
|
|
conn.push_back(2);
|
|
|
|
conn.push_back(1);
|
|
|
|
conn.push_back(3);
|
|
|
|
conn.push_back(4);
|
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
//Create the dataset.
|
|
|
|
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
2015-05-19 18:30:41 +00:00
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
|
|
|
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
|
|
|
|
|
|
|
vtkm::cont::DataSetFieldAdd dsf;
|
|
|
|
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
|
|
|
|
dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells");
|
2015-05-19 18:30:41 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
return dataSet;
|
2015-05-19 18:30:41 +00:00
|
|
|
}
|
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
/*
|
|
|
|
vtkm::cont::DataSet
|
2015-05-19 18:30:41 +00:00
|
|
|
MakeTestDataSet::Make3DExplicitDataSet1()
|
|
|
|
{
|
2015-08-02 21:59:44 +00:00
|
|
|
vtkm::cont::DataSet dataSet;
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSetBuilderExplicit dsb;
|
2015-05-19 18:30:41 +00:00
|
|
|
|
|
|
|
const int nVerts = 5;
|
2015-08-17 18:47:46 +00:00
|
|
|
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
|
2015-11-03 10:59:37 +00:00
|
|
|
std::vector<CoordType> coords(nVerts);
|
|
|
|
|
|
|
|
coords[0] = CoordType(0, 0, 0);
|
|
|
|
coords[1] = CoordType(1, 0, 0);
|
|
|
|
coords[2] = CoordType(1, 1, 0);
|
|
|
|
coords[3] = CoordType(2, 1, 0);
|
|
|
|
coords[4] = CoordType(2, 2, 0);
|
2015-08-17 18:47:46 +00:00
|
|
|
CoordType coordinates[nVerts] = {
|
|
|
|
CoordType(0, 0, 0),
|
|
|
|
CoordType(1, 0, 0),
|
|
|
|
CoordType(1, 1, 0),
|
|
|
|
CoordType(2, 1, 0),
|
|
|
|
CoordType(2, 2, 0)
|
|
|
|
};
|
2015-06-04 13:06:47 +00:00
|
|
|
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
2015-05-19 18:30:41 +00:00
|
|
|
|
2015-08-17 18:47:46 +00:00
|
|
|
dataSet.AddCoordinateSystem(
|
|
|
|
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
2015-05-19 18:30:41 +00:00
|
|
|
|
2015-08-03 16:06:59 +00:00
|
|
|
//Set point scalar
|
|
|
|
dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
|
2015-05-19 18:30:41 +00:00
|
|
|
|
|
|
|
//Set cell scalar
|
2015-06-04 13:06:47 +00:00
|
|
|
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
2015-08-02 21:59:44 +00:00
|
|
|
dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
2015-05-19 17:10:56 +00:00
|
|
|
|
2015-08-28 17:51:42 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", 2);
|
2015-05-19 18:30:41 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
cellSet.PrepareToAddCells(2, 7);
|
2015-08-16 18:53:44 +00:00
|
|
|
cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
|
|
|
|
cellSet.AddCell(vtkm::CELL_SHAPE_QUAD, 4, make_Vec<vtkm::Id>(2,1,3,4));
|
2015-08-02 21:59:44 +00:00
|
|
|
cellSet.CompleteAddingCells();
|
2015-05-19 17:10:56 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
dataSet.AddCellSet(cellSet);
|
2015-05-19 17:10:56 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
return dataSet;
|
2015-05-19 17:10:56 +00:00
|
|
|
}
|
2015-11-03 10:59:37 +00:00
|
|
|
*/
|
2015-05-19 17:10:56 +00:00
|
|
|
|
2015-11-03 10:59:37 +00:00
|
|
|
vtkm::cont::DataSet
|
2015-06-19 18:23:20 +00:00
|
|
|
MakeTestDataSet::Make3DExplicitDataSetCowNose(double *pBounds)
|
|
|
|
{
|
|
|
|
// prepare data array
|
|
|
|
const int nVerts = 17;
|
2015-08-17 18:47:46 +00:00
|
|
|
typedef vtkm::Vec<vtkm::Float64,3> CoordType;
|
|
|
|
CoordType coordinates[nVerts] = {
|
|
|
|
CoordType(0.0480879,0.151874,0.107334),
|
|
|
|
CoordType(0.0293568,0.245532,0.125337),
|
|
|
|
CoordType(0.0224398,0.246495,0.1351),
|
|
|
|
CoordType(0.0180085,0.20436,0.145316),
|
|
|
|
CoordType(0.0307091,0.152142,0.0539249),
|
|
|
|
CoordType(0.0270341,0.242992,0.107567),
|
|
|
|
CoordType(0.000684071,0.00272505,0.175648),
|
|
|
|
CoordType(0.00946217,0.077227,0.187097),
|
|
|
|
CoordType(-0.000168991,0.0692243,0.200755),
|
|
|
|
CoordType(-0.000129414,0.00247137,0.176561),
|
|
|
|
CoordType(0.0174172,0.137124,0.124553),
|
|
|
|
CoordType(0.00325994,0.0797155,0.184912),
|
|
|
|
CoordType(0.00191765,0.00589327,0.16608),
|
|
|
|
CoordType(0.0174716,0.0501928,0.0930275),
|
|
|
|
CoordType(0.0242103,0.250062,0.126256),
|
|
|
|
CoordType(0.0108188,0.152774,0.167914),
|
|
|
|
CoordType(5.41687e-05,0.00137834,0.175119)
|
|
|
|
};
|
2015-06-19 18:23:20 +00:00
|
|
|
const int nPointIds = 57;
|
2015-08-17 18:47:46 +00:00
|
|
|
vtkm::Id pointId[nPointIds] = {
|
|
|
|
0, 1, 3,
|
|
|
|
2, 3, 1,
|
|
|
|
4, 5, 0,
|
|
|
|
1, 0, 5,
|
|
|
|
7, 8, 6,
|
|
|
|
9, 6, 8,
|
|
|
|
0, 10, 7,
|
|
|
|
11, 7, 10,
|
|
|
|
0, 6, 13,
|
|
|
|
12, 13, 6,
|
|
|
|
1, 5, 14,
|
|
|
|
1, 14, 2,
|
|
|
|
0, 3, 15,
|
|
|
|
0, 13, 4,
|
|
|
|
6, 16, 12,
|
|
|
|
6, 9, 16,
|
|
|
|
7, 11, 8,
|
|
|
|
0, 15, 10,
|
|
|
|
7, 6, 0
|
|
|
|
};
|
2015-06-19 18:23:20 +00:00
|
|
|
double _bounds[6] = {-0.000169, 0.048088, 0.001378, 0.250062, 0.053925, 0.200755};
|
|
|
|
|
|
|
|
// create DataSet
|
2015-08-02 21:59:44 +00:00
|
|
|
vtkm::cont::DataSet dataSet;
|
2015-08-17 18:47:46 +00:00
|
|
|
dataSet.AddCoordinateSystem(
|
|
|
|
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
|
2015-06-19 18:23:20 +00:00
|
|
|
|
2015-09-24 20:14:09 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
|
|
|
|
connectivity.Allocate(nPointIds);
|
2015-06-19 18:23:20 +00:00
|
|
|
|
2015-09-24 20:14:09 +00:00
|
|
|
for(vtkm::Id i=0; i < nPointIds; ++i)
|
2015-08-02 21:59:44 +00:00
|
|
|
{
|
2015-09-24 20:14:09 +00:00
|
|
|
connectivity.GetPortalControl().Set(i, pointId[i]);
|
2015-08-02 21:59:44 +00:00
|
|
|
}
|
2015-09-24 20:14:09 +00:00
|
|
|
vtkm::cont::CellSetSingleType< > cellSet(vtkm::CellShapeTagTriangle(),
|
|
|
|
"cells");
|
|
|
|
cellSet.Fill(connectivity);
|
2015-08-02 21:59:44 +00:00
|
|
|
dataSet.AddCellSet(cellSet);
|
2015-06-19 18:23:20 +00:00
|
|
|
|
|
|
|
// copy bounds
|
|
|
|
if (pBounds != NULL)
|
2015-08-17 18:47:46 +00:00
|
|
|
{
|
|
|
|
for (vtkm::IdComponent i=0; i<6; i++)
|
|
|
|
{
|
2015-06-19 18:23:20 +00:00
|
|
|
pBounds[i] = _bounds[i];
|
2015-08-17 18:47:46 +00:00
|
|
|
}
|
|
|
|
}
|
2015-06-19 18:23:20 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
return dataSet;
|
2015-06-19 18:23:20 +00:00
|
|
|
}
|
2015-11-03 10:59:37 +00:00
|
|
|
|
2015-05-18 17:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::cont::testing
|
|
|
|
|
|
|
|
#endif //vtk_m_cont_testing_MakeTestDataSet_h
|