Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Todd Kordenbrock
VTK-m
Commits
7dfa1009
Commit
7dfa1009
authored
Nov 02, 2015
by
Dave Pugmire
Committed by
dpugmire
Dec 01, 2015
Browse files
Add dataset builder classes.
parent
034d5648
Changes
5
Hide whitespace changes
Inline
Side-by-side
vtkm/cont/DataSetBuilderExplicit.h
0 → 100644
View file @
7dfa1009
//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_cont_DataSetBuilderExplicit_h
#define vtk_m_cont_DataSetBuilderExplicit_h
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/Assert.h>
namespace
vtkm
{
namespace
cont
{
//Coordinates builder??
//Need a singlecellset handler.
class
DataSetBuilderExplicit
{
public:
VTKM_CONT_EXPORT
DataSetBuilderExplicit
()
{}
template
<
typename
T
>
VTKM_CONT_EXPORT
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"
);
template
<
typename
T
>
VTKM_CONT_EXPORT
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"
);
template
<
typename
T
>
VTKM_CONT_EXPORT
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"
);
private:
};
template
<
typename
T
>
vtkm
::
cont
::
DataSet
DataSetBuilderExplicit
::
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
,
const
std
::
string
&
cellNm
)
{
VTKM_CONT_ASSERT
(
xVals
.
size
()
==
yVals
.
size
()
&&
xVals
.
size
()
>
0
);
vtkm
::
cont
::
DataSet
dataSet
;
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
std
::
vector
<
CoordType
>
coords
(
xVals
.
size
());
size_t
nPts
=
xVals
.
size
();
for
(
size_t
i
=
0
;
i
<
nPts
;
i
++
)
{
coords
[
i
][
0
]
=
xVals
[
i
];
coords
[
i
][
1
]
=
yVals
[
i
];
coords
[
i
][
2
]
=
0
;
}
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
coordsNm
,
1
,
coords
));
vtkm
::
cont
::
CellSetExplicit
<>
cellSet
((
vtkm
::
Id
)
nPts
,
cellNm
,
2
);
cellSet
.
FillViaCopy
(
shapes
,
numIndices
,
connectivity
);
dataSet
.
AddCellSet
(
cellSet
);
return
dataSet
;
}
template
<
typename
T
>
vtkm
::
cont
::
DataSet
DataSetBuilderExplicit
::
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
,
const
std
::
string
&
cellNm
)
{
VTKM_CONT_ASSERT
(
xVals
.
size
()
==
yVals
.
size
()
&&
yVals
.
size
()
==
zVals
.
size
()
&&
xVals
.
size
()
>
0
);
vtkm
::
cont
::
DataSet
dataSet
;
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
std
::
vector
<
CoordType
>
coords
(
xVals
.
size
());
size_t
nPts
=
xVals
.
size
();
for
(
size_t
i
=
0
;
i
<
nPts
;
i
++
)
{
coords
[
i
][
0
]
=
xVals
[
i
];
coords
[
i
][
1
]
=
yVals
[
i
];
coords
[
i
][
2
]
=
zVals
[
i
];
}
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
coordsNm
,
1
,
coords
));
vtkm
::
cont
::
CellSetExplicit
<>
cellSet
((
vtkm
::
Id
)
nPts
,
cellNm
,
3
);
cellSet
.
FillViaCopy
(
shapes
,
numIndices
,
connectivity
);
dataSet
.
AddCellSet
(
cellSet
);
return
dataSet
;
}
template
<
typename
T
>
vtkm
::
cont
::
DataSet
DataSetBuilderExplicit
::
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
,
const
std
::
string
&
cellNm
)
{
vtkm
::
cont
::
DataSet
dataSet
;
size_t
nPts
=
coords
.
size
();
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
coordsNm
,
1
,
coords
));
vtkm
::
cont
::
CellSetExplicit
<>
cellSet
((
vtkm
::
Id
)
nPts
,
cellNm
,
3
);
cellSet
.
FillViaCopy
(
shapes
,
numIndices
,
connectivity
);
dataSet
.
AddCellSet
(
cellSet
);
return
dataSet
;
}
}
}
#endif //vtk_m_cont_DataSetBuilderExplicit_h
vtkm/cont/DataSetBuilderRegular.h
0 → 100644
View file @
7dfa1009
//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_cont_DataSetBuilderRegular_h
#define vtk_m_cont_DataSetBuilderRegular_h
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/Assert.h>
namespace
vtkm
{
namespace
cont
{
class
DataSetBuilderRegular
{
public:
VTKM_CONT_EXPORT
DataSetBuilderRegular
()
{}
//2D regular grids.
VTKM_CONT_EXPORT
vtkm
::
cont
::
DataSet
Create
(
vtkm
::
Id
nx
,
vtkm
::
Id
ny
,
std
::
string
coordNm
=
"coords"
,
std
::
string
cellNm
=
"cells"
)
{
return
Create
(
2
,
nx
,
ny
,
1
,
0
,
0
,
0
,
1
,
1
,
1
,
coordNm
,
cellNm
);
}
template
<
typename
T
>
VTKM_CONT_EXPORT
vtkm
::
cont
::
DataSet
Create
(
vtkm
::
Id
nx
,
vtkm
::
Id
ny
,
T
originX
,
T
originY
,
T
spacingX
,
T
spacingY
,
std
::
string
coordNm
=
"coords"
,
std
::
string
cellNm
=
"cells"
)
{
Create
(
2
,
nx
,
ny
,
1
,
originX
,
originY
,
0
,
spacingX
,
spacingY
,
1
,
coordNm
,
cellNm
);
}
//3D regular grids.
VTKM_CONT_EXPORT
vtkm
::
cont
::
DataSet
Create
(
vtkm
::
Id
nx
,
vtkm
::
Id
ny
,
vtkm
::
Id
nz
,
std
::
string
coordNm
=
"coords"
,
std
::
string
cellNm
=
"cells"
)
{
return
Create
(
3
,
nx
,
ny
,
nz
,
0
,
0
,
0
,
1
,
1
,
1
,
coordNm
,
cellNm
);
}
template
<
typename
T
>
VTKM_CONT_EXPORT
vtkm
::
cont
::
DataSet
Create
(
vtkm
::
Id
nx
,
vtkm
::
Id
ny
,
vtkm
::
Id
nz
,
T
originX
,
T
originY
,
T
originZ
,
T
spacingX
,
T
spacingY
,
T
spacingZ
,
std
::
string
coordNm
=
"coords"
,
std
::
string
cellNm
=
"cells"
)
{
return
Create
(
3
,
nx
,
ny
,
nz
,
originX
,
originY
,
originZ
,
spacingX
,
spacingY
,
spacingZ
,
coordNm
,
cellNm
);
}
private:
template
<
typename
T
>
VTKM_CONT_EXPORT
vtkm
::
cont
::
DataSet
Create
(
int
dim
,
vtkm
::
Id
nx
,
vtkm
::
Id
ny
,
vtkm
::
Id
nz
,
T
originX
,
T
originY
,
T
originZ
,
T
spacingX
,
T
spacingY
,
T
spacingZ
,
std
::
string
coordNm
,
std
::
string
cellNm
)
{
VTKM_ASSERT_CONT
(
nx
>
1
&&
ny
>
1
&&
((
dim
==
2
&&
nz
==
1
)
||
(
dim
==
3
&&
nz
>
1
)));
vtkm
::
cont
::
DataSet
dataSet
;
vtkm
::
cont
::
ArrayHandleUniformPointCoordinates
coords
(
vtkm
::
Id3
(
nx
,
ny
,
nz
),
vtkm
::
Vec
<
T
,
3
>
(
originX
,
originY
,
originZ
),
vtkm
::
Vec
<
T
,
3
>
(
spacingX
,
spacingY
,
spacingZ
));
vtkm
::
cont
::
CoordinateSystem
cs
(
coordNm
,
1
,
coords
);
dataSet
.
AddCoordinateSystem
(
cs
);
if
(
dim
==
2
)
{
vtkm
::
cont
::
CellSetStructured
<
2
>
cellSet
(
cellNm
);
cellSet
.
SetPointDimensions
(
vtkm
::
make_Vec
(
nx
,
ny
));
dataSet
.
AddCellSet
(
cellSet
);
}
else
{
vtkm
::
cont
::
CellSetStructured
<
3
>
cellSet
(
cellNm
);
cellSet
.
SetPointDimensions
(
vtkm
::
make_Vec
(
nx
,
ny
,
nz
));
dataSet
.
AddCellSet
(
cellSet
);
}
return
dataSet
;
}
};
}
// namespace cont
}
// namespace vtkm
#endif //vtk_m_cont_DataSetBuilderRegular_h
vtkm/cont/DataSetFieldAdd.h
0 → 100644
View file @
7dfa1009
//============================================================================
// 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.
// Copyright 2014 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.
//============================================================================
#ifndef vtk_m_cont_DataSetFieldAdd_h
#define vtk_m_cont_DataSetFieldAdd_h
namespace
vtkm
{
namespace
cont
{
class
DataSetFieldAdd
{
public:
VTKM_CONT_EXPORT
DataSetFieldAdd
()
{}
//Point centered fields.
template
<
typename
T
,
typename
Storage
>
VTKM_CONT_EXPORT
void
AddPointField
(
vtkm
::
cont
::
DataSet
&
dataSet
,
const
std
::
string
&
fieldName
,
vtkm
::
cont
::
ArrayHandle
<
T
,
Storage
>
&
field
)
{
dataSet
.
AddField
(
Field
(
fieldName
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
field
));
}
template
<
typename
T
>
VTKM_CONT_EXPORT
void
AddPointField
(
vtkm
::
cont
::
DataSet
&
dataSet
,
const
std
::
string
&
fieldName
,
const
std
::
vector
<
T
>
&
field
)
{
dataSet
.
AddField
(
Field
(
fieldName
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
field
));
}
template
<
typename
T
>
VTKM_CONT_EXPORT
void
AddPointField
(
vtkm
::
cont
::
DataSet
&
dataSet
,
const
std
::
string
&
fieldName
,
const
T
*
field
,
const
vtkm
::
Id
&
n
)
{
dataSet
.
AddField
(
Field
(
fieldName
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
field
,
n
));
}
//Cell centered field
template
<
typename
T
,
typename
Storage
>
VTKM_CONT_EXPORT
void
AddCellField
(
vtkm
::
cont
::
DataSet
&
dataSet
,
const
std
::
string
&
fieldName
,
vtkm
::
cont
::
ArrayHandle
<
T
,
Storage
>
&
field
,
const
std
::
string
&
cellSetName
)
{
dataSet
.
AddField
(
Field
(
fieldName
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
,
cellSetName
,
field
));
}
template
<
typename
T
>
VTKM_CONT_EXPORT
void
AddCellField
(
vtkm
::
cont
::
DataSet
&
dataSet
,
const
std
::
string
&
fieldName
,
const
std
::
vector
<
T
>
&
field
,
const
std
::
string
&
cellSetName
)
{
dataSet
.
AddField
(
Field
(
fieldName
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
,
cellSetName
,
field
));
}
template
<
typename
T
>
VTKM_CONT_EXPORT
void
AddCellField
(
vtkm
::
cont
::
DataSet
&
dataSet
,
const
std
::
string
&
fieldName
,
const
T
*
field
,
const
vtkm
::
Id
&
n
,
const
std
::
string
&
cellSetName
)
{
dataSet
.
AddField
(
Field
(
fieldName
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
,
cellSetName
,
field
,
n
));
}
};
}
}
//namespace vtkm::cont
#endif //vtk_m_cont_DataSetFieldAdd_h
vtkm/cont/testing/UnitTestDataSetExplicit.cxx
View file @
7dfa1009
...
...
@@ -20,6 +20,119 @@
#include <vtkm/cont/DeviceAdapterSerial.h>
#include <vtkm/cont/testing/TestingDataSetExplicit.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
namespace
{
template
<
typename
T
,
typename
Storage
>
bool
TestArrayHandle
(
const
vtkm
::
cont
::
ArrayHandle
<
T
,
Storage
>
&
ah
,
const
T
*
expected
,
vtkm
::
Id
size
)
{
if
(
size
!=
ah
.
GetNumberOfValues
())
{
return
false
;
}
for
(
vtkm
::
Id
i
=
0
;
i
<
size
;
++
i
)
{
if
(
ah
.
GetPortalConstControl
().
Get
(
i
)
!=
expected
[
i
])
{
return
false
;
}
}
return
true
;
}
void
TestDataSet_Explicit
()
{
vtkm
::
cont
::
testing
::
MakeTestDataSet
tds
;
vtkm
::
cont
::
DataSet
ds
=
tds
.
Make3DExplicitDataSet0
();
VTKM_TEST_ASSERT
(
ds
.
GetNumberOfCellSets
()
==
1
,
"Incorrect number of cell sets"
);
VTKM_TEST_ASSERT
(
ds
.
GetNumberOfFields
()
==
2
,
"Incorrect number of fields"
);
// test various field-getting methods and associations
const
vtkm
::
cont
::
Field
&
f1
=
ds
.
GetField
(
"pointvar"
);
VTKM_TEST_ASSERT
(
f1
.
GetAssociation
()
==
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
"Association of 'pointvar' was not ASSOC_POINTS"
);
try
{
ds
.
GetField
(
"cellvar"
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
);
}
catch
(...)
{
VTKM_TEST_FAIL
(
"Failed to get field 'cellvar' with ASSOC_CELL_SET."
);
}
try
{
ds
.
GetField
(
"pointvar"
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
);
}
catch
(...)
{
VTKM_TEST_FAIL
(
"Failed to get expected error for association mismatch."
);
}
VTKM_TEST_ASSERT
(
ds
.
GetNumberOfCoordinateSystems
()
==
1
,
"Incorrect number of coordinate systems"
);
// test cell-to-point connectivity
vtkm
::
cont
::
CellSetExplicit
<>
&
cellset
=
ds
.
GetCellSet
(
0
).
CastTo
<
vtkm
::
cont
::
CellSetExplicit
<>
>
();
cellset
.
BuildConnectivity
(
vtkm
::
TopologyElementTagCell
(),
vtkm
::
TopologyElementTagPoint
());
vtkm
::
Id
connectivitySize
=
7
;
vtkm
::
Id
numPoints
=
5
;
vtkm
::
UInt8
correctShapes
[]
=
{
1
,
1
,
1
,
1
,
1
};
vtkm
::
IdComponent
correctNumIndices
[]
=
{
1
,
2
,
2
,
1
,
1
};
vtkm
::
Id
correctConnectivity
[]
=
{
0
,
0
,
1
,
0
,
1
,
1
,
1
};
vtkm
::
cont
::
ArrayHandle
<
vtkm
::
UInt8
>
shapes
=
cellset
.
GetShapesArray
(
vtkm
::
TopologyElementTagCell
(),
vtkm
::
TopologyElementTagPoint
());
vtkm
::
cont
::
ArrayHandle
<
vtkm
::
IdComponent
>
numIndices
=
cellset
.
GetNumIndicesArray
(
vtkm
::
TopologyElementTagCell
(),
vtkm
::
TopologyElementTagPoint
());
vtkm
::
cont
::
ArrayHandle
<
vtkm
::
Id
>
conn
=
cellset
.
GetConnectivityArray
(
vtkm
::
TopologyElementTagCell
(),
vtkm
::
TopologyElementTagPoint
());
VTKM_TEST_ASSERT
(
TestArrayHandle
(
shapes
,
correctShapes
,
numPoints
),
"Got incorrect shapes"
);
VTKM_TEST_ASSERT
(
TestArrayHandle
(
numIndices
,
correctNumIndices
,
numPoints
),
"Got incorrect shapes"
);
VTKM_TEST_ASSERT
(
TestArrayHandle
(
conn
,
correctConnectivity
,
connectivitySize
),
"Got incorrect conectivity"
);
//verify that GetIndices works properly
vtkm
::
Id
expectedPointIds
[
4
]
=
{
2
,
1
,
3
,
4
};
vtkm
::
Vec
<
vtkm
::
Id
,
4
>
retrievedPointIds
;
cellset
.
GetIndices
(
1
,
retrievedPointIds
);
for
(
vtkm
::
IdComponent
i
=
0
;
i
<
4
;
i
++
)
{
VTKM_TEST_ASSERT
(
retrievedPointIds
[
i
]
==
expectedPointIds
[
i
],
"Incorrect point ID for quad cell"
);
}
}
}
int
UnitTestDataSetExplicit
(
int
,
char
*
[])
{
...
...
vtkm/cont/testing/UnitTestDataSetRegular.cxx
View file @
7dfa1009
...
...
@@ -49,8 +49,6 @@ TwoDimRegularTest()
vtkm
::
cont
::
DataSet
dataSet
=
testDataSet
.
Make2DRegularDataSet0
();
dataSet
.
PrintSummary
(
std
::
cout
);
typedef
vtkm
::
cont
::
CellSetStructured
<
2
>
CellSetType
;
CellSetType
cellSet
=
dataSet
.
GetCellSet
(
0
).
CastTo
<
CellSetType
>
();
...
...
@@ -66,30 +64,22 @@ TwoDimRegularTest()
"Incorrect number of cells"
);
// test various field-getting methods and associations
const
vtkm
::
cont
::
Field
&
f1
=
dataSet
.
GetField
(
"pointvar"
);
VTKM_TEST_ASSERT
(
f1
.
GetAssociation
()
==
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
"Association of 'pointvar' was not ASSOC_POINTS"
);
try
{
//const vtkm::cont::Field &f2 =
dataSet
.
GetField
(
"cellvar"
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
);
dataSet
.
GetField
(
"cellvar"
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
);
}
catch
(...)
{
VTKM_TEST_FAIL
(
"Failed to get field 'cellvar' with ASSOC_CELL_SET."
);
VTKM_TEST_FAIL
(
"Failed to get field 'cellvar' with ASSOC_CELL_SET."
);
}
try
{
//const vtkm::cont::Field &f3 =
dataSet
.
GetField
(
"cellvar"
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
);
VTKM_TEST_FAIL
(
"Failed to get expected error for association mismatch."
);
dataSet
.
GetField
(
"pointvar"
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
);
}
catch
(
vtkm
::
cont
::
ErrorControlBadValue
error
)
catch
(
...
)
{
std
::
cout
<<
"Caught expected error for association mismatch: "
<<
std
::
endl
<<
" "
<<
error
.
GetMessage
()
<<
std
::
endl
;
VTKM_TEST_FAIL
(
"Failed to get field 'pointvar' with ASSOC_POINT_SET."
);
}
vtkm
::
Id
numCells
=
cellSet
.
GetNumberOfCells
();
...
...
@@ -167,8 +157,6 @@ ThreeDimRegularTest()
vtkm
::
cont
::
DataSet
dataSet
=
testDataSet
.
Make3DRegularDataSet0
();
dataSet
.
PrintSummary
(
std
::
cout
);
typedef
vtkm
::
cont
::
CellSetStructured
<
3
>
CellSetType
;
CellSetType
cellSet
=
dataSet
.
GetCellSet
(
0
).
CastTo
<
CellSetType
>
();
...
...
@@ -187,34 +175,25 @@ ThreeDimRegularTest()
VTKM_TEST_ASSERT
(
cellSet
.
GetNumberOfCells
()
==
4
,
"Incorrect number of cells"
);
// test various field-getting methods and associations
const
vtkm
::
cont
::
Field
&
f1
=
dataSet
.
GetField
(
"pointvar"
);
VTKM_TEST_ASSERT
(
f1
.
GetAssociation
()
==
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
"Association of 'pointvar' was not ASSOC_POINTS"
);
try
{
//const vtkm::cont::Field &f2 =
dataSet
.
GetField
(
"cellvar"
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
);
dataSet
.
GetField
(
"cellvar"
,
vtkm
::
cont
::
Field
::
ASSOC_CELL_SET
);
}
catch
(...)
{
VTKM_TEST_FAIL
(
"Failed to get field 'cellvar' with ASSOC_CELL_SET."
);
VTKM_TEST_FAIL
(
"Failed to get field 'cellvar' with ASSOC_CELL_SET."
);
}
try
{
//const vtkm::cont::Field &f3 =
dataSet
.
GetField
(
"cellvar"
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
);
VTKM_TEST_FAIL
(
"Failed to get expected error for association mismatch."
);
dataSet
.
GetField
(
"pointvar"
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
);
}
catch
(
vtkm
::
cont
::
ErrorControlBadValue
error
)
catch
(
...
)
{