MarchingCubes filter now generates coordinates when point merging is enabled.

This commit is contained in:
Robert Maynard 2016-02-22 11:37:39 -05:00
parent c00fb53b54
commit d370155e74
2 changed files with 54 additions and 33 deletions

@ -422,6 +422,7 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
this->InterpolationWeights, this->InterpolationWeights,
vtkm::filter::ApplyPolicy(coords, policy), vtkm::filter::ApplyPolicy(coords, policy),
vertices); vertices);
vtkm::cont::printSummary_ArrayHandle(vertices, std::cout);
} }
else else
@ -436,7 +437,9 @@ vtkm::filter::DataSetResult MarchingCubes::DoExecute(const vtkm::cont::DataSet&
vertices); vertices);
//when we don't merge points, the connectivity array can be represented //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; typedef typename vtkm::cont::ArrayHandleIndex::StorageTag IndexStorageTag;
CellShapeTagTriangle triangleTag; CellShapeTagTriangle triangleTag;
vtkm::cont::CellSetSingleType< IndexStorageTag > outputCells( triangleTag ); vtkm::cont::CellSetSingleType< IndexStorageTag > outputCells( triangleTag );

@ -273,27 +273,57 @@ void TestMarchingCubesUniformGrid()
result = mc.Execute( dataSet, result = mc.Execute( dataSet,
dataSet.GetField("nodevar") ); dataSet.GetField("nodevar") );
vtkm::cont::DataSet& outputData = result.GetDataSet(); {
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1, vtkm::cont::DataSet& outputData = result.GetDataSet();
"Wrong number of cellsets in the output dataset"); VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1, "Wrong number of cellsets in the output dataset");
"Wrong number of coordinate systems in the output dataset"); VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
//since normals is on we have one field "Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1, //since normals is on we have one field
"Wrong number of fields in the output dataset"); VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
"Wrong number of fields in the output dataset");
//Map a field onto the resulting dataset //Map a field onto the resulting dataset
const bool isMapped = mc.MapFieldOntoOutput(result, dataSet.GetField("nodevar")); const bool isMapped = mc.MapFieldOntoOutput(result, dataSet.GetField("nodevar"));
VTKM_TEST_ASSERT( isMapped, "mapping should pass" ); VTKM_TEST_ASSERT( isMapped, "mapping should pass" );
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2, VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
"Wrong number of fields in the output dataset"); "Wrong number of fields in the output dataset");
//verify that the number of cells is correct //verify that the number of points is correct
//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");
//should have 480 coordinates //verify that the number of cells is correct (160)
//should have 160 cells vtkm::cont::DynamicCellSet dcells = outputData.GetCellSet();
typedef vtkm::cont::CellSetSingleType<> CellSetType;
const CellSetType& cells = dcells.Cast<CellSetType>();
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
}
//Now try with vertex merging disabled
mc.SetMergeDuplicatePoints(false);
result = mc.Execute( dataSet,
dataSet.GetField("nodevar") );
{
vtkm::cont::DataSet& outputData = result.GetDataSet();
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
VTKM_TEST_ASSERT(coords.GetData().GetNumberOfValues() == 480,
"Should have less coordinates than the unmerged version");
//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() void TestMarchingCubesCustomPolicy()
@ -334,27 +364,15 @@ void TestMarchingCubesCustomPolicy()
"Wrong number of fields in the output dataset"); "Wrong number of fields in the output dataset");
//data arrays vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
// VTKM_TEST_ASSERT(test_equal(vertices.GetNumberOfValues(), 2472), VTKM_TEST_ASSERT(coords.GetData().GetNumberOfValues() == 414,
// "Wrong vertices result for MarchingCubes filter"); "Should have some coordinates");
// 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");
} }
void TestMarchingCubesNonDefaultCoordinates()
{
}
void TestMarchingCubesFilter() void TestMarchingCubesFilter()
{ {
TestMarchingCubesUniformGrid(); TestMarchingCubesUniformGrid();
TestMarchingCubesCustomPolicy(); TestMarchingCubesCustomPolicy();
TestMarchingCubesNonDefaultCoordinates();
} }
} // anonymous namespace } // anonymous namespace