Return VecVariable when getting cell to point in structured

When getting cell indices in a cell to point structured connectivity, it
was previously returning a vtkm::Vec of the maximum size and setting
invalid indices to -1. This is changed to vtkm::VecVariable, which will
reflect the actual number of indices.

I thought I made this change a while ago, but I guess I missed it.
This commit is contained in:
Kenneth Moreland 2015-08-27 16:49:24 -06:00
parent fe65124922
commit ed6ff1e931
2 changed files with 36 additions and 32 deletions

@ -141,9 +141,13 @@ TwoDimRegularTest()
for (vtkm::Id pointIndex = 0; pointIndex < 6; pointIndex++)
{
vtkm::Vec<vtkm::Id,4> retrievedCellIds =
vtkm::VecVariable<vtkm::Id,4> retrievedCellIds =
cellToPoint.GetIndices(pointIndex);
for (vtkm::IdComponent cellIndex = 0; cellIndex < 4; cellIndex++)
VTKM_TEST_ASSERT(retrievedCellIds.GetNumberOfComponents() <= 4,
"Got wrong number of cell ids.");
for (vtkm::IdComponent cellIndex = 0;
cellIndex < retrievedCellIds.GetNumberOfComponents();
cellIndex++)
VTKM_TEST_ASSERT(
retrievedCellIds[cellIndex] == expectedCellIds[pointIndex][cellIndex],
"Incorrect cell ID for point");
@ -242,9 +246,11 @@ ThreeDimRegularTest()
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::Id retrievedCellIds[6] = {0,-1,-1,-1,-1,-1};
vtkm::Vec<vtkm::Id,6> expectedCellIds = cellToPoint.GetIndices(0);
vtkm::VecVariable<vtkm::Id,6> expectedCellIds = cellToPoint.GetIndices(0);
VTKM_TEST_ASSERT(expectedCellIds.GetNumberOfComponents() <= 6,
"Got unexpected number of cell ids");
for (vtkm::IdComponent localPointIndex = 0;
localPointIndex < 6;
localPointIndex < expectedCellIds.GetNumberOfComponents();
localPointIndex++)
{
VTKM_TEST_ASSERT(

@ -24,6 +24,7 @@
#include <vtkm/CellShape.h>
#include <vtkm/TopologyElementTag.h>
#include <vtkm/Types.h>
#include <vtkm/VecVariable.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/static_assert.hpp>
@ -105,19 +106,18 @@ public:
}
VTKM_EXEC_CONT_EXPORT
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
vtkm::VecVariable<vtkm::Id,MAX_CELL_TO_POINT>
GetCellsOfPoint(vtkm::Id index) const
{
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
vtkm::VecVariable<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
cellIds[0] = cellIds[1] = -1;
vtkm::IdComponent idx = 0;
if (index > 0)
{
cellIds[idx++] = index-1;
cellIds.Append(index-1);
}
if (index < this->PointDimensions-1)
{
cellIds[idx++] = index;
cellIds.Append(index);
}
return cellIds;
@ -216,29 +216,28 @@ public:
}
VTKM_EXEC_CONT_EXPORT
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
vtkm::VecVariable<vtkm::Id,MAX_CELL_TO_POINT>
GetCellsOfPoint(vtkm::Id index) const
{
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
vtkm::VecVariable<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
cellIds[0] = cellIds[1] = cellIds[2] = cellIds[3] = -1;
vtkm::Id i, j;
vtkm::IdComponent idx = 0;
this->CalculateLogicalPointIndices(index, i, j);
if ((i > 0) && (j > 0))
{
cellIds[idx++] = this->CalculateCellIndex(i-1, j-1);
cellIds.Append(this->CalculateCellIndex(i-1, j-1));
}
if ((i < this->PointDimensions[0]-1) && (j > 0))
{
cellIds[idx++] = this->CalculateCellIndex(i , j-1);
cellIds.Append(this->CalculateCellIndex(i , j-1));
}
if ((i > 0) && (j < this->PointDimensions[1]-1))
{
cellIds[idx++] = this->CalculateCellIndex(i-1, j );
cellIds.Append(this->CalculateCellIndex(i-1, j ));
}
if ((i < this->PointDimensions[0]-1) && (j < this->PointDimensions[1]-1))
{
cellIds[idx++] = this->CalculateCellIndex(i , j );
cellIds.Append(this->CalculateCellIndex(i , j ));
}
return cellIds;
@ -352,56 +351,54 @@ public:
}
VTKM_EXEC_CONT_EXPORT
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> GetCellsOfPoint(vtkm::Id index) const
vtkm::VecVariable<vtkm::Id,MAX_CELL_TO_POINT>
GetCellsOfPoint(vtkm::Id index) const
{
vtkm::Vec<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
cellIds[0]=cellIds[1]=cellIds[2]=cellIds[3]=cellIds[4]=cellIds[5]=-1;
vtkm::VecVariable<vtkm::Id,MAX_CELL_TO_POINT> cellIds;
vtkm::Id i, j, k;
vtkm::IdComponent idx=0;
this->CalculateLogicalPointIndices(index, i, j, k);
if ((i > 0) && (j > 0) && (k > 0))
{
cellIds[idx++] = this->CalculateCellIndex(i-1, j-1, k-1);
cellIds.Append(this->CalculateCellIndex(i-1, j-1, k-1));
}
if ((i < this->PointDimensions[0]-1) && (j > 0) && (k > 0))
{
cellIds[idx++] = this->CalculateCellIndex(i , j-1, k-1);
cellIds.Append(this->CalculateCellIndex(i , j-1, k-1));
}
if ((i > 0) && (j < this->PointDimensions[1]-1) && (k > 0))
{
cellIds[idx++] = this->CalculateCellIndex(i-1, j , k-1);
cellIds.Append(this->CalculateCellIndex(i-1, j , k-1));
}
if ((i < this->PointDimensions[0]-1) &&
(j < this->PointDimensions[1]-1) &&
(k > 0))
{
cellIds[idx++] = this->CalculateCellIndex(i , j , k-1);
cellIds.Append(this->CalculateCellIndex(i , j , k-1));
}
if ((i > 0) && (j > 0) && (k < this->PointDimensions[2]-1))
{
cellIds[idx++] = this->CalculateCellIndex(i-1, j-1, k);
cellIds.Append(this->CalculateCellIndex(i-1, j-1, k));
}
if ((i < this->PointDimensions[0]-1) &&
(j > 0) &&
(k < this->PointDimensions[2]-1))
{
cellIds[idx++] = this->CalculateCellIndex(i , j-1, k);
cellIds.Append(this->CalculateCellIndex(i , j-1, k));
}
if ((i > 0) &&
(j < this->PointDimensions[1]-1) &&
(k < this->PointDimensions[2]-1))
{
cellIds[idx++] = this->CalculateCellIndex(i-1, j , k);
cellIds.Append(this->CalculateCellIndex(i-1, j , k));
}
if ((i < this->PointDimensions[0]-1) &&
(j < this->PointDimensions[1]-1) &&
(k < this->PointDimensions[2]-1))
{
cellIds[idx++] = this->CalculateCellIndex(i , j , k);
cellIds.Append(this->CalculateCellIndex(i , j , k));
}
return cellIds;
@ -486,7 +483,8 @@ struct ConnectivityStructuredIndexHelper<
// TODO: This needs to change to a Vec-like that supports a max size.
// Likewise, all the GetCellsOfPoint methods need to use it as well.
typedef vtkm::Vec<vtkm::Id,ConnectivityType::MAX_CELL_TO_POINT> IndicesType;
typedef vtkm::VecVariable<vtkm::Id,ConnectivityType::MAX_CELL_TO_POINT>
IndicesType;
VTKM_EXEC_CONT_EXPORT
static IndicesType GetIndices(const ConnectivityType &connectivity,