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
e7456fa1
Commit
e7456fa1
authored
Jan 15, 2016
by
Robert Maynard
Browse files
Update vtkm tests and examples to use DataSetBuilders.
parent
449c425a
Changes
9
Hide whitespace changes
Inline
Side-by-side
examples/tetrahedra/TetrahedralizeExplicitGrid.cxx
View file @
e7456fa1
...
...
@@ -26,6 +26,7 @@
#include
<vtkm/worklet/DispatcherMapField.h>
#include
<vtkm/Math.h>
#include
<vtkm/cont/DataSet.h>
#include
<vtkm/cont/DataSetBuilderExplicit.h>
#include
<vtkm/cont/testing/Testing.h>
...
...
@@ -66,33 +67,26 @@ int mouse_state = 1;
//
vtkm
::
cont
::
DataSet
MakeTetrahedralizeExplicitDataSet
()
{
vtkm
::
cont
::
DataSet
dataSet
;
const
int
nVerts
=
18
;
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
CoordType
coordinates
[
nVerts
]
=
{
CoordType
(
0
,
0
,
0
),
CoordType
(
1
,
0
,
0
),
CoordType
(
2
,
0
,
0
),
CoordType
(
3
,
0
,
0
),
CoordType
(
0
,
1
,
0
),
CoordType
(
1
,
1
,
0
),
CoordType
(
2
,
1
,
0
),
CoordType
(
2.5
,
1
,
0
),
CoordType
(
0
,
2
,
0
),
CoordType
(
1
,
2
,
0
),
CoordType
(
0.5
,
0.5
,
1
),
CoordType
(
1
,
0
,
1
),
CoordType
(
2
,
0
,
1
),
CoordType
(
3
,
0
,
1
),
CoordType
(
1
,
1
,
1
),
CoordType
(
2
,
1
,
1
),
CoordType
(
2.5
,
1
,
1
),
CoordType
(
0.5
,
1.5
,
1
),
};
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
coordinates
,
nVerts
));
std
::
vector
<
CoordType
>
coordinates
;
coordinates
.
push_back
(
CoordType
(
0
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
1
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
2
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
3
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
0
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
1
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
2
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
2.5
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
0
,
2
,
0
)
);
coordinates
.
push_back
(
CoordType
(
1
,
2
,
0
)
);
coordinates
.
push_back
(
CoordType
(
0.5
,
0.5
,
1
)
);
coordinates
.
push_back
(
CoordType
(
1
,
0
,
1
)
);
coordinates
.
push_back
(
CoordType
(
2
,
0
,
1
)
);
coordinates
.
push_back
(
CoordType
(
3
,
0
,
1
)
);
coordinates
.
push_back
(
CoordType
(
1
,
1
,
1
)
);
coordinates
.
push_back
(
CoordType
(
2
,
1
,
1
)
);
coordinates
.
push_back
(
CoordType
(
2.5
,
1
,
1
)
);
coordinates
.
push_back
(
CoordType
(
0.5
,
1.5
,
1
)
);
std
::
vector
<
vtkm
::
UInt8
>
shapes
;
shapes
.
push_back
(
vtkm
::
CELL_SHAPE_TETRA
);
...
...
@@ -134,13 +128,8 @@ vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
conn
.
push_back
(
8
);
conn
.
push_back
(
17
);
static
const
vtkm
::
IdComponent
ndim
=
3
;
vtkm
::
cont
::
CellSetExplicit
<>
cellSet
(
nVerts
,
"cells"
,
ndim
);
cellSet
.
FillViaCopy
(
shapes
,
numindices
,
conn
);
dataSet
.
AddCellSet
(
cellSet
);
return
dataSet
;
vtkm
::
cont
::
DataSetBuilderExplicit
builder
;
return
builder
.
Create
(
coordinates
,
shapes
,
numindices
,
conn
);
}
//
...
...
examples/tetrahedra/TriangulateExplicitGrid.cxx
View file @
e7456fa1
...
...
@@ -25,6 +25,7 @@
#include
<vtkm/worklet/TetrahedralizeExplicitGrid.h>
#include
<vtkm/cont/CellSetExplicit.h>
#include
<vtkm/cont/DataSet.h>
#include
<vtkm/cont/DataSetBuilderExplicit.h>
#include
<vtkm/cont/testing/Testing.h>
...
...
@@ -63,27 +64,23 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
const
int
nVerts
=
16
;
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
CoordType
coordinates
[
nVerts
]
=
{
CoordType
(
0
,
0
,
0
),
// 0
CoordType
(
1
,
0
,
0
),
// 1
CoordType
(
2
,
0
,
0
),
// 2
CoordType
(
3
,
0
,
0
),
// 3
CoordType
(
0
,
1
,
0
),
// 4
CoordType
(
1
,
1
,
0
),
// 5
CoordType
(
2
,
1
,
0
),
// 6
CoordType
(
3
,
1
,
0
),
// 7
CoordType
(
0
,
2
,
0
),
// 8
CoordType
(
1
,
2
,
0
),
// 9
CoordType
(
2
,
2
,
0
),
// 10
CoordType
(
3
,
2
,
0
),
// 11
CoordType
(
0
,
3
,
0
),
// 12
CoordType
(
3
,
3
,
0
),
// 13
CoordType
(
1
,
4
,
0
),
// 14
CoordType
(
2
,
4
,
0
),
// 15
};
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
coordinates
,
nVerts
));
std
::
vector
<
CoordType
>
coordinates
;
coordinates
.
push_back
(
CoordType
(
0
,
0
,
0
)
);
// 0
coordinates
.
push_back
(
CoordType
(
1
,
0
,
0
)
);
// 1
coordinates
.
push_back
(
CoordType
(
2
,
0
,
0
)
);
// 2
coordinates
.
push_back
(
CoordType
(
3
,
0
,
0
)
);
// 3
coordinates
.
push_back
(
CoordType
(
0
,
1
,
0
)
);
// 4
coordinates
.
push_back
(
CoordType
(
1
,
1
,
0
)
);
// 5
coordinates
.
push_back
(
CoordType
(
2
,
1
,
0
)
);
// 6
coordinates
.
push_back
(
CoordType
(
3
,
1
,
0
)
);
// 7
coordinates
.
push_back
(
CoordType
(
0
,
2
,
0
)
);
// 8
coordinates
.
push_back
(
CoordType
(
1
,
2
,
0
)
);
// 9
coordinates
.
push_back
(
CoordType
(
2
,
2
,
0
)
);
// 10
coordinates
.
push_back
(
CoordType
(
3
,
2
,
0
)
);
// 11
coordinates
.
push_back
(
CoordType
(
0
,
3
,
0
)
);
// 12
coordinates
.
push_back
(
CoordType
(
3
,
3
,
0
)
);
// 13
coordinates
.
push_back
(
CoordType
(
1
,
4
,
0
)
);
// 14
coordinates
.
push_back
(
CoordType
(
2
,
4
,
0
)
);
// 15
std
::
vector
<
vtkm
::
UInt8
>
shapes
;
shapes
.
push_back
(
vtkm
::
CELL_SHAPE_TRIANGLE
);
...
...
@@ -139,13 +136,9 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
conn
.
push_back
(
14
);
conn
.
push_back
(
12
);
static
const
vtkm
::
IdComponent
ndim
=
2
;
vtkm
::
cont
::
CellSetExplicit
<>
cellSet
(
nVerts
,
"cells"
,
ndim
);
cellSet
.
FillViaCopy
(
shapes
,
numindices
,
conn
);
dataSet
.
AddCellSet
(
cellSet
);
return
dataSet
;
vtkm
::
cont
::
DataSet
ds
;
vtkm
::
cont
::
DataSetBuilderExplicit
builder
;
return
builder
.
Create
(
coordinates
,
shapes
,
numindices
,
conn
);
}
//
...
...
vtkm/cont/CellSetExplicit.h
View file @
e7456fa1
...
...
@@ -236,52 +236,6 @@ public:
this
->
NumberOfCells
=
this
->
ConnectivityLength
=
-
1
;
}
/// Second method to add cells -- all at once.
/// Copies the data from the vectors, so they can be released.
VTKM_CONT_EXPORT
void
FillViaCopy
(
const
std
::
vector
<
vtkm
::
UInt8
>
&
cellTypes
,
const
std
::
vector
<
vtkm
::
IdComponent
>
&
numIndices
,
const
std
::
vector
<
vtkm
::
Id
>
&
connectivity
,
const
std
::
vector
<
vtkm
::
Id
>
&
offsets
=
std
::
vector
<
vtkm
::
Id
>
()
)
{
this
->
PointToCell
.
Shapes
.
Allocate
(
static_cast
<
vtkm
::
Id
>
(
cellTypes
.
size
())
);
std
::
copy
(
cellTypes
.
begin
(),
cellTypes
.
end
(),
vtkm
::
cont
::
ArrayPortalToIteratorBegin
(
this
->
PointToCell
.
Shapes
.
GetPortalControl
()));
this
->
PointToCell
.
NumIndices
.
Allocate
(
static_cast
<
vtkm
::
IdComponent
>
(
numIndices
.
size
())
);
std
::
copy
(
numIndices
.
begin
(),
numIndices
.
end
(),
vtkm
::
cont
::
ArrayPortalToIteratorBegin
(
this
->
PointToCell
.
NumIndices
.
GetPortalControl
()));
this
->
PointToCell
.
Connectivity
.
Allocate
(
static_cast
<
vtkm
::
Id
>
(
connectivity
.
size
())
);
std
::
copy
(
connectivity
.
begin
(),
connectivity
.
end
(),
vtkm
::
cont
::
ArrayPortalToIteratorBegin
(
this
->
PointToCell
.
Connectivity
.
GetPortalControl
()));
this
->
PointToCell
.
ElementsValid
=
true
;
if
(
offsets
.
size
()
==
cellTypes
.
size
())
{
this
->
PointToCell
.
IndexOffsets
.
Allocate
(
static_cast
<
vtkm
::
Id
>
(
offsets
.
size
())
);
std
::
copy
(
offsets
.
begin
(),
offsets
.
end
(),
vtkm
::
cont
::
ArrayPortalToIteratorBegin
(
this
->
PointToCell
.
IndexOffsets
.
GetPortalControl
()));
this
->
PointToCell
.
IndexOffsetsValid
=
true
;
}
else
{
this
->
PointToCell
.
IndexOffsetsValid
=
false
;
if
(
offsets
.
size
()
!=
0
)
{
throw
vtkm
::
cont
::
ErrorControlBadValue
(
"Explicit cell offsets array unexpected size. "
"Use an empty array to automatically generate."
);
}
}
}
/// Second method to add cells -- all at once.
/// Assigns the array handles to the explicit connectivity. This is
/// the way you can fill the memory from another system without copying
...
...
vtkm/cont/CellSetSingleType.h
View file @
e7456fa1
...
...
@@ -154,36 +154,6 @@ public:
this
->
PointToCell
.
IndexOffsetsValid
=
true
;
}
/// Second method to add cells -- all at once.
/// Copies the data from the vectors, so they can be released.
VTKM_CONT_EXPORT
void
FillViaCopy
(
const
std
::
vector
<
vtkm
::
Id
>
&
connectivity
)
{
vtkm
::
IdComponent
numberOfPointsPerCell
=
this
->
DetermineNumberOfPoints
();
const
vtkm
::
Id
connectSize
=
static_cast
<
vtkm
::
Id
>
(
connectivity
.
size
());
const
vtkm
::
Id
length
=
connectSize
/
numberOfPointsPerCell
;
const
vtkm
::
UInt8
shapeTypeValue
=
static_cast
<
vtkm
::
UInt8
>
(
this
->
CellTypeAsId
);
this
->
PointToCell
.
Shapes
=
vtkm
::
cont
::
make_ArrayHandleConstant
(
shapeTypeValue
,
length
);
this
->
PointToCell
.
NumIndices
=
vtkm
::
cont
::
make_ArrayHandleConstant
(
numberOfPointsPerCell
,
length
);
this
->
PointToCell
.
IndexOffsets
=
vtkm
::
cont
::
make_ArrayHandleCounting
(
vtkm
::
Id
(
0
),
static_cast
<
vtkm
::
Id
>
(
numberOfPointsPerCell
),
length
);
this
->
PointToCell
.
Connectivity
.
Allocate
(
connectSize
);
std
::
copy
(
connectivity
.
begin
(),
connectivity
.
end
(),
vtkm
::
cont
::
ArrayPortalToIteratorBegin
(
this
->
PointToCell
.
Connectivity
.
GetPortalControl
()));
this
->
PointToCell
.
ElementsValid
=
true
;
this
->
PointToCell
.
IndexOffsetsValid
=
true
;
}
private:
template
<
typename
CellShapeTag
>
void
DetermineNumberOfPoints
(
CellShapeTag
,
...
...
vtkm/cont/testing/TestingDataSetSingleType.h
View file @
e7456fa1
...
...
@@ -23,6 +23,8 @@
#include
<vtkm/cont/testing/Testing.h>
#include
<vtkm/cont/DataSet.h>
#include
<vtkm/cont/DataSetBuilderExplicit.h>
#include
<vtkm/cont/DataSetFieldAdd.h>
#include
<vtkm/cont/CellSetSingleType.h>
#include
<vtkm/cont/DeviceAdapterAlgorithm.h>
...
...
@@ -62,27 +64,13 @@ private:
static
inline
vtkm
::
cont
::
DataSet
make_SingleTypeDataSet
()
{
using
vtkm
::
cont
::
Field
;
vtkm
::
cont
::
DataSet
dataSet
;
const
int
nVerts
=
5
;
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
CoordType
coordinates
[
nVerts
]
=
{
CoordType
(
0
,
0
,
0
),
CoordType
(
1
,
0
,
0
),
CoordType
(
1
,
1
,
0
),
CoordType
(
2
,
1
,
0
),
CoordType
(
2
,
2
,
0
)
};
//Set coordinate system
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
coordinates
,
nVerts
));
//Set point scalar
vtkm
::
Float32
vars
[
nVerts
]
=
{
10.1
f
,
20.1
f
,
30.2
f
,
40.2
f
,
50.3
f
};
dataSet
.
AddField
(
Field
(
"pointvar"
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
vars
,
nVerts
));
std
::
vector
<
CoordType
>
coordinates
;
coordinates
.
push_back
(
CoordType
(
0
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
1
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
1
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
2
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
2
,
2
,
0
)
);
std
::
vector
<
vtkm
::
Id
>
conn
;
// First Cell
...
...
@@ -98,13 +86,19 @@ private:
conn
.
push_back
(
3
);
conn
.
push_back
(
4
);
vtkm
::
cont
::
CellSetSingleType
<>
cellSet
(
vtkm
::
CellShapeTagTriangle
(),
"cells"
);
cellSet
.
FillViaCopy
(
conn
);
vtkm
::
cont
::
DataSet
ds
;
vtkm
::
cont
::
DataSetBuilderExplicit
builder
;
ds
=
builder
.
Create
(
coordinates
,
vtkm
::
CellShapeTagTriangle
(),
conn
);
//Set point scalar
const
int
nVerts
=
5
;
vtkm
::
Float32
vars
[
nVerts
]
=
{
10.1
f
,
20.1
f
,
30.2
f
,
40.2
f
,
50.3
f
};
dataSet
.
AddCellSet
(
cellSet
);
vtkm
::
cont
::
DataSetFieldAdd
fieldAdder
;
fieldAdder
.
AddPointField
(
ds
,
"pointvar"
,
vars
,
nVerts
);
return
d
ataSet
;
return
d
s
;
}
static
void
TestDataSet_SingleType
()
...
...
vtkm/cont/testing/UnitTestDataSetPermutation.cxx
View file @
e7456fa1
...
...
@@ -54,27 +54,13 @@ bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage> &ah, const T *exp
inline
vtkm
::
cont
::
DataSet
make_SingleTypeDataSet
()
{
using
vtkm
::
cont
::
Field
;
vtkm
::
cont
::
DataSet
dataSet
;
const
int
nVerts
=
5
;
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
CoordType
coordinates
[
nVerts
]
=
{
CoordType
(
0
,
0
,
0
),
CoordType
(
1
,
0
,
0
),
CoordType
(
1
,
1
,
0
),
CoordType
(
2
,
1
,
0
),
CoordType
(
2
,
2
,
0
)
};
//Set coordinate system
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
coordinates
,
nVerts
));
//Set point scalar
vtkm
::
Float32
vars
[
nVerts
]
=
{
10.1
f
,
20.1
f
,
30.2
f
,
40.2
f
,
50.3
f
};
dataSet
.
AddField
(
Field
(
"pointvar"
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
vars
,
nVerts
));
std
::
vector
<
CoordType
>
coordinates
;
coordinates
.
push_back
(
CoordType
(
0
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
1
,
0
,
0
)
);
coordinates
.
push_back
(
CoordType
(
1
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
2
,
1
,
0
)
);
coordinates
.
push_back
(
CoordType
(
2
,
2
,
0
)
);
std
::
vector
<
vtkm
::
Id
>
conn
;
// First Cell
...
...
@@ -90,13 +76,18 @@ inline vtkm::cont::DataSet make_SingleTypeDataSet()
conn
.
push_back
(
3
);
conn
.
push_back
(
4
);
vtkm
::
cont
::
CellSetSingleType
<>
cellSet
(
vtkm
::
CellShapeTagTriangle
(),
"cells"
);
cellSet
.
FillViaCopy
(
conn
);
vtkm
::
cont
::
DataSet
ds
;
vtkm
::
cont
::
DataSetBuilderExplicit
builder
;
ds
=
builder
.
Create
(
coordinates
,
vtkm
::
CellShapeTagTriangle
(),
conn
);
//Set point scalar
const
int
nVerts
=
5
;
vtkm
::
Float32
vars
[
nVerts
]
=
{
10.1
f
,
20.1
f
,
30.2
f
,
40.2
f
,
50.3
f
};
dataSet
.
AddCellSet
(
cellSet
);
vtkm
::
cont
::
DataSetFieldAdd
fieldAdder
;
fieldAdder
.
AddPointField
(
ds
,
"pointvar"
,
vars
,
nVerts
);
return
d
ataSet
;
return
d
s
;
}
void
TestDataSet_Explicit
()
...
...
vtkm/worklet/testing/UnitTestClipping.cxx
View file @
e7456fa1
...
...
@@ -25,6 +25,9 @@
#include
<vtkm/cont/CellSetStructured.h>
#include
<vtkm/cont/CoordinateSystem.h>
#include
<vtkm/cont/DataSet.h>
#include
<vtkm/cont/DataSetBuilderExplicit.h>
#include
<vtkm/cont/DataSetBuilderRegular.h>
#include
<vtkm/cont/DataSetFieldAdd.h>
#include
<vtkm/cont/DeviceAdapterAlgorithm.h>
#include
<vtkm/cont/Field.h>
#include
<vtkm/cont/testing/Testing.h>
...
...
@@ -58,42 +61,39 @@ bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage> &ah, const T *exp
vtkm
::
cont
::
DataSet
MakeTestDatasetExplicit
()
{
static
const
vtkm
::
Id
numVerts
=
4
;
static
const
vtkm
::
Id
numCells
=
2
;
static
const
Coord3D
coords
[
numVerts
]
=
{
Coord3D
(
0.0
f
,
0.0
f
,
0.0
f
),
Coord3D
(
1.0
f
,
0.0
f
,
0.0
f
),
Coord3D
(
1.0
f
,
1.0
f
,
0.0
f
),
Coord3D
(
0.0
f
,
1.0
f
,
0.0
f
),
};
static
vtkm
::
Float32
values
[]
=
{
1.0
,
2.0
,
1.0
,
0.0
};
static
vtkm
::
UInt8
shapes
[]
=
{
vtkm
::
CELL_SHAPE_TRIANGLE
,
vtkm
::
CELL_SHAPE_TRIANGLE
};
static
vtkm
::
IdComponent
numInds
[]
=
{
3
,
3
};
static
vtkm
::
Id
connectivity
[]
=
{
0
,
1
,
3
,
3
,
1
,
2
};
std
::
vector
<
Coord3D
>
coords
;
coords
.
push_back
(
Coord3D
(
0.0
f
,
0.0
f
,
0.0
f
)
);
coords
.
push_back
(
Coord3D
(
1.0
f
,
0.0
f
,
0.0
f
)
);
coords
.
push_back
(
Coord3D
(
1.0
f
,
1.0
f
,
0.0
f
)
);
coords
.
push_back
(
Coord3D
(
0.0
f
,
1.0
f
,
0.0
f
)
);
std
::
vector
<
vtkm
::
Id
>
connectivity
;
connectivity
.
push_back
(
0
);
connectivity
.
push_back
(
1
);
connectivity
.
push_back
(
3
);
connectivity
.
push_back
(
3
);
connectivity
.
push_back
(
1
);
connectivity
.
push_back
(
2
);
vtkm
::
cont
::
DataSet
ds
;
ds
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
coords
,
numVerts
));
ds
.
AddField
(
vtkm
::
cont
::
Field
(
"scalars"
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
values
,
numVerts
));
std
::
vector
<
vtkm
::
UInt8
>
shapesVec
(
shapes
,
shapes
+
numCells
);
std
::
vector
<
vtkm
::
IdComponent
>
numIndsVec
(
numInds
,
numInds
+
numCells
);
std
::
vector
<
vtkm
::
Id
>
connectivityVec
(
connectivity
,
connectivity
+
(
numCells
*
3
));
vtkm
::
cont
::
DataSetBuilderExplicit
builder
;
ds
=
builder
.
Create
(
coords
,
vtkm
::
CellShapeTagTriangle
(),
connectivity
);
vtkm
::
cont
::
CellSetExplicit
<>
cs
(
numVerts
,
"cells"
,
3
);
cs
.
FillViaCopy
(
shapesVec
,
numIndsVec
,
connectivityVec
);
ds
.
AddCellSet
(
cs
);
std
::
vector
<
vtkm
::
Float32
>
values
;
values
.
push_back
(
1.0
);
values
.
push_back
(
2.0
);
values
.
push_back
(
1.0
);
values
.
push_back
(
0.0
);
vtkm
::
cont
::
DataSetFieldAdd
fieldAdder
;
fieldAdder
.
AddPointField
(
ds
,
"scalars"
,
values
);
return
ds
;
}
vtkm
::
cont
::
DataSet
MakeTestDatasetStructured
()
{
static
const
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
origin
(
0.0
f
,
0.0
f
,
0.0
f
);
static
const
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
spacing
(
1.0
f
,
1.0
f
,
1.0
f
);
static
const
vtkm
::
Id
xdim
=
3
,
ydim
=
3
;
static
const
vtkm
::
Id
3
dim
(
xdim
,
ydim
,
1
);
static
const
vtkm
::
Id
2
dim
(
xdim
,
ydim
);
static
const
vtkm
::
Id
numVerts
=
xdim
*
ydim
;
vtkm
::
Float32
scalars
[
numVerts
];
...
...
@@ -104,14 +104,11 @@ vtkm::cont::DataSet MakeTestDatasetStructured()
scalars
[
4
]
=
0.0
f
;
vtkm
::
cont
::
DataSet
ds
;
ds
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
dim
,
origin
,
spacing
));
ds
.
AddField
(
vtkm
::
cont
::
Field
(
"scalars"
,
1
,
vtkm
::
cont
::
Field
::
ASSOC_POINTS
,
scalars
,
numVerts
));
vtkm
::
cont
::
DataSetBuilderRegular
builder
;
ds
=
builder
.
Create
(
dim
);
vtkm
::
cont
::
CellSetStructured
<
2
>
cs
(
"cells"
);
cs
.
SetPointDimensions
(
vtkm
::
make_Vec
(
dim
[
0
],
dim
[
1
]));
ds
.
AddCellSet
(
cs
);
vtkm
::
cont
::
DataSetFieldAdd
fieldAdder
;
fieldAdder
.
AddPointField
(
ds
,
"scalars"
,
scalars
,
numVerts
);
return
ds
;
}
...
...
vtkm/worklet/testing/UnitTestExternalFaces.cxx
View file @
e7456fa1
...
...
@@ -21,6 +21,7 @@
#include
<iostream>
#include
<algorithm>
#include
<vtkm/cont/DeviceAdapter.h>
#include
<vtkm/cont/DataSetBuilderExplicit.h>
#include
<vtkm/cont/testing/Testing.h>
#include
<vtkm/worklet/ExternalFaces.h>
...
...
@@ -70,24 +71,18 @@ vtkm::cont::DataSet RunExternalFaces(vtkm::cont::DataSet &ds)
void
TestExternalFaces
()
{
//--------------Construct a VTK-m Test Dataset----------------
vtkm
::
cont
::
DataSet
ds
;
const
int
nVerts
=
8
;
//A cube that is tetrahedralized
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
CoordType
coordinates
[
nVerts
]
=
{
CoordType
(
0
,
0
,
0
),
CoordType
(
1
,
0
,
0
),
CoordType
(
1
,
1
,
0
),
CoordType
(
0
,
1
,
0
),
CoordType
(
0
,
0
,
1
),
CoordType
(
1
,
0
,
1
),
CoordType
(
1
,
1
,
1
),
CoordType
(
0
,
1
,
1
)
};
ds
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
coordinates
,
nVerts
));
vtkm
::
cont
::
ArrayHandle
<
CoordType
>
coordinates
;
coordinates
.
Allocate
(
nVerts
);
coordinates
.
GetPortalControl
().
Set
(
0
,
CoordType
(
0.0
f
,
0.0
f
,
0.0
f
)
);
coordinates
.
GetPortalControl
().
Set
(
1
,
CoordType
(
1.0
f
,
0.0
f
,
0.0
f
)
);
coordinates
.
GetPortalControl
().
Set
(
2
,
CoordType
(
1.0
f
,
1.0
f
,
0.0
f
)
);
coordinates
.
GetPortalControl
().
Set
(
3
,
CoordType
(
0.0
f
,
1.0
f
,
0.0
f
)
);
coordinates
.
GetPortalControl
().
Set
(
4
,
CoordType
(
0.0
f
,
0.0
f
,
1.0
f
)
);
coordinates
.
GetPortalControl
().
Set
(
5
,
CoordType
(
1.0
f
,
0.0
f
,
1.0
f
)
);
coordinates
.
GetPortalControl
().
Set
(
6
,
CoordType
(
1.0
f
,
1.0
f
,
1.0
f
)
);
coordinates
.
GetPortalControl
().
Set
(
7
,
CoordType
(
0.0
f
,
1.0
f
,
1.0
f
)
);
//Construct the VTK-m shapes and numIndices connectivity arrays
const
int
nCells
=
6
;
//The tetrahedrons of the cube
...
...
@@ -95,7 +90,6 @@ void TestExternalFaces()
{
4
,
7
,
6
,
3
},
{
4
,
6
,
3
,
2
},
{
4
,
0
,
3
,
2
},
{
4
,
6
,
5
,
2
},
{
4
,
5
,
0
,
2
},
{
1
,
0
,
5
,
2
}
};
vtkm
::
cont
::
CellSetExplicit
<>
cs
(
nVerts
,
"cells"
,
nCells
);
vtkm
::
cont
::
ArrayHandle
<
vtkm
::
UInt8
>
shapes
;
vtkm
::
cont
::
ArrayHandle
<
vtkm
::
IdComponent
>
numIndices
;
...
...
@@ -113,10 +107,8 @@ void TestExternalFaces()
conn
.
GetPortalControl
().
Set
(
index
++
,
cellVerts
[
j
][
k
]);
}
cs
.
Fill
(
shapes
,
numIndices
,
conn
);
//Add the VTK-m cell set
ds
.
AddCellSet
(
cs
);
vtkm
::
cont
::
DataSetBuilderExplicit
builder
;
vtkm
::
cont
::
DataSet
ds
=
builder
.
Create
(
coordinates
,
shapes
,
numIndices
,
conn
);
//Run the External Faces worklet
vtkm
::
cont
::
DataSet
new_ds
=
RunExternalFaces
(
ds
);
...
...
vtkm/worklet/testing/UnitTestTetrahedralizeExplicitGrid.cxx
View file @
e7456fa1
...
...
@@ -22,6 +22,7 @@
#include
<vtkm/worklet/DispatcherMapField.h>
#include
<vtkm/cont/DataSet.h>
#include
<vtkm/cont/DataSetBuilderExplicit.h>
#include
<vtkm/cont/testing/Testing.h>
namespace
{
...
...
@@ -31,32 +32,25 @@ namespace {
//
vtkm
::
cont
::
DataSet
MakeTriangulateExplicitDataSet
()
{
vtkm
::
cont
::
DataSet
dataSet
;
const
int
nVerts
=
16
;
typedef
vtkm
::
Vec
<
vtkm
::
Float32
,
3
>
CoordType
;
CoordType
coordinates
[
nVerts
]
=
{
CoordType
(
0
,
0
,
0
),
// 0
CoordType
(
1
,
0
,
0
),
// 1
CoordType
(
2
,
0
,
0
),
// 2
CoordType
(
3
,
0
,
0
),
// 3
CoordType
(
0
,
1
,
0
),
// 4
CoordType
(
1
,
1
,
0
),
// 5
CoordType
(
2
,
1
,
0
),
// 6
CoordType
(
3
,
1
,
0
),
// 7
CoordType
(
0
,
2
,
0
),
// 8
CoordType
(
1
,
2
,
0
),
// 9
CoordType
(
2
,
2
,
0
),
// 10
CoordType
(
3
,
2
,
0
),
// 11
CoordType
(
0
,
3
,
0
),
// 12
CoordType
(
3
,
3
,
0
),
// 13
CoordType
(
1
,
4
,
0
),
// 14
CoordType
(
2
,
4
,
0
),
// 15
};
dataSet
.
AddCoordinateSystem
(
vtkm
::
cont
::
CoordinateSystem
(
"coordinates"
,
1
,
coordinates
,
nVerts
));
std
::
vector
<
CoordType
>
coordinates
;
coordinates
.
push_back
(
CoordType
(
0
,
0
,
0
)
);
// 0
coordinates
.
push_back
(
CoordType
(
1
,
0
,
0
)
);
// 1
coordinates
.
push_back
(
CoordType
(
2
,
0
,
0
)
);
// 2
coordinates
.
push_back
(
CoordType
(
3
,
0
,
0
)
);
// 3
coordinates
.
push_back
(
CoordType
(
0
,
1
,
0
)
);
// 4
coordinates
.
push_back
(
CoordType
(
1
,
1
,
0
)
);
// 5
coordinates
.
push_back
(
CoordType
(
2
,
1
,
0
)
);
// 6
coordinates
.
push_back
(
CoordType
(
3
,
1
,
0
)
);
// 7
coordinates
.
push_back
(
CoordType
(
0
,
2
,
0
)
);
// 8
coordinates
.
push_back
(
CoordType
(
1
,
2
,
0
)
);
// 9
coordinates
.
push_back
(
CoordType
(
2
,
2
,
0
)
);
// 10
coordinates
.
push_back
(
CoordType
(
3
,
2
,
0
)
);
// 11
coordinates
.
push_back
(
CoordType
(
0
,
3
,
0
)
);
// 12
coordinates
.
push_back
(
CoordType
(
3
,
3
,
0
)
);
// 13
coordinates
.
push_back
(
CoordType
(
1
,
4
,
0
)
);
// 14
coordinates
.
push_back
(
CoordType
(
2
,
4
,
0
)
);
// 15
std
::
vector
<
vtkm
::
UInt8
>
shapes
;