Commit 8ac5975c authored by Daniel Loyd's avatar Daniel Loyd

Update CellMetrics.cxx

parent fdd2d589
......@@ -37,16 +37,26 @@ TestMetric(vtkm::io::writer::VTKDataSetWriter *writer, DataSet data)
{
//
// Takes a pointer to a DataSetWriter and a set of data as parameters. Executes a filter on the data set to generate a new field.
// Writes the resulting DataSet into an output file and returns the new field for calculation
// Writes the resulting DataSet into an output file and returns the new field for calculation. NOTE: If a field with the same name as the
// new field is already in the DataSet, TestMetric will return NULL
//
vtkm::filter::CellMeasures<vtkm::AllMeasures> c_measure;
c_measure.SetCellMeasureName("volume");
DataSet outputData = c_measure.Execute(data); //TODO: try catch this for vtkm::cont::ErrorExecution
DynamicArrayHandle temp = outputData.GetField(c_measure.GetCellMeasureName()).GetData();
DataSetFieldAdd::AddCellField(outputData, c_measure.GetCellMeasureName(), temp, "cells");
writer->WriteDataSet(outputData);
ArrayHandle<vtkm::FloatDefault> *metricArrPtr = new ArrayHandle<vtkm::FloatDefault>;
temp.CopyTo(*metricArrPtr);
if (!data.HasField(c_measure.GetCellMeasureName()))
{
DataSet outputData = c_measure.Execute(data); //TODO: try catch this for vtkm::cont::ErrorExecution
DynamicArrayHandle temp = outputData.GetField(c_measure.GetCellMeasureName()).GetData();
DataSetFieldAdd::AddCellField(outputData, c_measure.GetCellMeasureName(), temp, "cells");
writer->WriteDataSet(outputData);
temp.CopyTo(*metricArrPtr);
}
else
{
std::cerr << "data field already in DataSet" << std::endl;
delete metricArrPtr;
metricArrPtr = NULL;
}
return metricArrPtr;
}
......@@ -142,6 +152,10 @@ int main(int argc, char* argv[])
std::cerr << "Error occured while writing output. Exiting" << std::endl;
return 1;
}
if (metricArrayPtr == NULL)
{
return 1;
}
DetermineMeshQuality(metricArrayPtr);
delete metricArrayPtr;
return 0;
......
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