Commit d370155e authored by Robert Maynard's avatar Robert Maynard

MarchingCubes filter now generates coordinates when point merging is enabled.

parent c00fb53b
......@@ -422,6 +422,7 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
this->InterpolationWeights,
vtkm::filter::ApplyPolicy(coords, policy),
vertices);
vtkm::cont::printSummary_ArrayHandle(vertices, std::cout);
}
else
......@@ -436,7 +437,9 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
vertices);
//when we don't merge points, the connectivity array can be represented
//by a counting array
//by a counting array. The danger of doing it this way is that the output
//type is unknown. We should use explicit connectivity, or add this type
//to the default output types
typedef typename vtkm::cont::ArrayHandleIndex::StorageTag IndexStorageTag;
CellShapeTagTriangle triangleTag;
vtkm::cont::CellSetSingleType< IndexStorageTag > outputCells( triangleTag );
......
......@@ -273,27 +273,57 @@ void TestMarchingCubesUniformGrid()
result = mc.Execute( dataSet,
dataSet.GetField("nodevar") );
vtkm::cont::DataSet& outputData = result.GetDataSet();
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
//since normals is on we have one field
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
"Wrong number of fields in the output dataset");
{
vtkm::cont::DataSet& outputData = result.GetDataSet();
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
//since normals is on we have one field
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
"Wrong number of fields in the output dataset");
//Map a field onto the resulting dataset
const bool isMapped = mc.MapFieldOntoOutput(result, dataSet.GetField("nodevar"));
VTKM_TEST_ASSERT( isMapped, "mapping should pass" );
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
"Wrong number of fields in the output dataset");
//verify that the number of points is correct
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
VTKM_TEST_ASSERT(coords.GetData().GetNumberOfValues() == 402,
"Should have less coordinates than the unmerged version");
//verify that the number of cells is correct (160)
vtkm::cont::DynamicCellSet dcells = outputData.GetCellSet();
typedef vtkm::cont::CellSetSingleType<> CellSetType;
const CellSetType& cells = dcells.Cast<CellSetType>();
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
}
//Map a field onto the resulting dataset
const bool isMapped = mc.MapFieldOntoOutput(result, dataSet.GetField("nodevar"));
VTKM_TEST_ASSERT( isMapped, "mapping should pass" );
//Now try with vertex merging disabled
mc.SetMergeDuplicatePoints(false);
result = mc.Execute( dataSet,
dataSet.GetField("nodevar") );
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
"Wrong number of fields in the output dataset");
{
vtkm::cont::DataSet& outputData = result.GetDataSet();
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
//verify that the number of cells is correct
//verify that the number of points is correct
VTKM_TEST_ASSERT(coords.GetData().GetNumberOfValues() == 480,
"Should have less coordinates than the unmerged version");
//should have 480 coordinates
//should have 160 cells
//verify that the number of cells is correct (160)
vtkm::cont::DynamicCellSet dcells = outputData.GetCellSet();
//todo: this needs to be an explicit storage tag
typedef vtkm::cont::ArrayHandleIndex::StorageTag IndexStorageTag;
typedef vtkm::cont::CellSetSingleType<IndexStorageTag> CellSetType;
const CellSetType& cells = dcells.Cast<CellSetType>();
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
}
}
void TestMarchingCubesCustomPolicy()
......@@ -334,27 +364,15 @@ void TestMarchingCubesCustomPolicy()
"Wrong number of fields in the output dataset");
//data arrays
// VTKM_TEST_ASSERT(test_equal(vertices.GetNumberOfValues(), 2472),
// "Wrong vertices result for MarchingCubes filter");
// VTKM_TEST_ASSERT(test_equal(normals.GetNumberOfValues(), 2472),
// "Wrong normals result for MarchingCubes filter");
// VTKM_TEST_ASSERT(test_equal(scalars.GetNumberOfValues(), 2472),
// "Wrong scalars result for MarchingCubes filter");
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
VTKM_TEST_ASSERT(coords.GetData().GetNumberOfValues() == 414,
"Should have some coordinates");
}
void TestMarchingCubesNonDefaultCoordinates()
{
}
void TestMarchingCubesFilter()
{
TestMarchingCubesUniformGrid();
TestMarchingCubesCustomPolicy();
TestMarchingCubesNonDefaultCoordinates();
}
} // anonymous namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment