mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
VTKDataSetWriter: remove just_points argument
Signed-off-by: Vicente Adolfo Bolea Sanchez <vicente.bolea@kitware.com>
This commit is contained in:
parent
744edbf428
commit
ab0fecda7f
7
docs/changelog/VTKDataSetWriter-remove-justpoints.md
Normal file
7
docs/changelog/VTKDataSetWriter-remove-justpoints.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Remove VTKDataSetWriter::WriteDataSet just_points parameter
|
||||
|
||||
In the method `VTKDataSetWriter::WriteDataSet`, `just_points` parameter has been
|
||||
removed due to lack of usage.
|
||||
|
||||
The purpose of `just_points` was to allow exporting only the points of a
|
||||
DataSet without its cell data.
|
@ -201,22 +201,6 @@ void WriteExplicitCells(std::ostream& out, const CellSetType& cellSet)
|
||||
}
|
||||
}
|
||||
|
||||
void WriteVertexCells(std::ostream& out, const vtkm::cont::DataSet& dataSet)
|
||||
{
|
||||
vtkm::Id nCells = dataSet.GetCoordinateSystem(0).GetNumberOfPoints();
|
||||
|
||||
out << "CELLS " << nCells << " " << nCells * 2 << '\n';
|
||||
for (int i = 0; i < nCells; i++)
|
||||
{
|
||||
out << "1 " << i << '\n';
|
||||
}
|
||||
out << "CELL_TYPES " << nCells << '\n';
|
||||
for (int i = 0; i < nCells; i++)
|
||||
{
|
||||
out << vtkm::CELL_SHAPE_VERTEX << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void WritePointFields(std::ostream& out, const vtkm::cont::DataSet& dataSet)
|
||||
{
|
||||
bool wrote_header = false;
|
||||
@ -305,13 +289,6 @@ void WriteCellFields(std::ostream& out, const vtkm::cont::DataSet& dataSet)
|
||||
}
|
||||
}
|
||||
|
||||
void WriteDataSetAsPoints(std::ostream& out, const vtkm::cont::DataSet& dataSet)
|
||||
{
|
||||
out << "DATASET UNSTRUCTURED_GRID" << '\n';
|
||||
WritePoints(out, dataSet);
|
||||
WriteVertexCells(out, dataSet);
|
||||
}
|
||||
|
||||
template <class CellSetType>
|
||||
void WriteDataSetAsUnstructured(std::ostream& out,
|
||||
const vtkm::cont::DataSet& dataSet,
|
||||
@ -407,7 +384,7 @@ void WriteDataSetAsStructured(std::ostream& out,
|
||||
}
|
||||
}
|
||||
|
||||
void Write(std::ostream& out, const vtkm::cont::DataSet& dataSet, bool just_points = false)
|
||||
void Write(std::ostream& out, const vtkm::cont::DataSet& dataSet)
|
||||
{
|
||||
// The Paraview parser cannot handle scientific notation:
|
||||
out << std::fixed;
|
||||
@ -415,43 +392,35 @@ void Write(std::ostream& out, const vtkm::cont::DataSet& dataSet, bool just_poin
|
||||
out << "vtk output" << '\n';
|
||||
out << "ASCII" << '\n';
|
||||
|
||||
if (just_points)
|
||||
vtkm::cont::DynamicCellSet cellSet = dataSet.GetCellSet();
|
||||
if (cellSet.IsType<vtkm::cont::CellSetExplicit<>>())
|
||||
{
|
||||
WriteDataSetAsPoints(out, dataSet);
|
||||
WritePointFields(out, dataSet);
|
||||
WriteDataSetAsUnstructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetExplicit<>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetStructured<1>>())
|
||||
{
|
||||
WriteDataSetAsStructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetStructured<1>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetStructured<2>>())
|
||||
{
|
||||
WriteDataSetAsStructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetStructured<2>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetStructured<3>>())
|
||||
{
|
||||
WriteDataSetAsStructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetStructured<3>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetSingleType<>>())
|
||||
{
|
||||
// these function just like explicit cell sets
|
||||
WriteDataSetAsUnstructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetSingleType<>>());
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::DynamicCellSet cellSet = dataSet.GetCellSet();
|
||||
if (cellSet.IsType<vtkm::cont::CellSetExplicit<>>())
|
||||
{
|
||||
WriteDataSetAsUnstructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetExplicit<>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetStructured<1>>())
|
||||
{
|
||||
WriteDataSetAsStructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetStructured<1>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetStructured<2>>())
|
||||
{
|
||||
WriteDataSetAsStructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetStructured<2>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetStructured<3>>())
|
||||
{
|
||||
WriteDataSetAsStructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetStructured<3>>());
|
||||
}
|
||||
else if (cellSet.IsType<vtkm::cont::CellSetSingleType<>>())
|
||||
{
|
||||
// these function just like explicit cell sets
|
||||
WriteDataSetAsUnstructured(out, dataSet, cellSet.Cast<vtkm::cont::CellSetSingleType<>>());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("Could not determine type to write out.");
|
||||
}
|
||||
|
||||
WritePointFields(out, dataSet);
|
||||
WriteCellFields(out, dataSet);
|
||||
throw vtkm::cont::ErrorBadType("Could not determine type to write out.");
|
||||
}
|
||||
|
||||
WritePointFields(out, dataSet);
|
||||
WriteCellFields(out, dataSet);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@ -471,7 +440,7 @@ VTKDataSetWriter::VTKDataSetWriter(const std::string& fileName)
|
||||
{
|
||||
}
|
||||
|
||||
void VTKDataSetWriter::WriteDataSet(const vtkm::cont::DataSet& dataSet, bool just_points) const
|
||||
void VTKDataSetWriter::WriteDataSet(const vtkm::cont::DataSet& dataSet) const
|
||||
{
|
||||
if (dataSet.GetNumberOfCoordinateSystems() < 1)
|
||||
{
|
||||
@ -481,7 +450,7 @@ void VTKDataSetWriter::WriteDataSet(const vtkm::cont::DataSet& dataSet, bool jus
|
||||
try
|
||||
{
|
||||
std::ofstream fileStream(this->FileName.c_str(), std::fstream::trunc);
|
||||
Write(fileStream, dataSet, just_points);
|
||||
Write(fileStream, dataSet);
|
||||
fileStream.close();
|
||||
}
|
||||
catch (std::ofstream::failure& error)
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
VTKM_CONT VTKDataSetWriter(const char* fileName);
|
||||
VTKM_CONT VTKDataSetWriter(const std::string& fileName);
|
||||
|
||||
VTKM_CONT void WriteDataSet(const vtkm::cont::DataSet& dataSet, bool just_points = false) const;
|
||||
VTKM_CONT void WriteDataSet(const vtkm::cont::DataSet& dataSet) const;
|
||||
|
||||
private:
|
||||
std::string FileName;
|
||||
|
@ -141,9 +141,9 @@ void TestVTKExplicitWrite()
|
||||
WRITE_FILE(Make3DExplicitDataSetPolygonal);
|
||||
WRITE_FILE(Make3DExplicitDataSetCowNose);
|
||||
|
||||
std::cout << "Force writer to output an explicit grid as points" << std::endl;
|
||||
vtkm::io::VTKDataSetWriter writer("Make3DExplicitDataSet0-no-grid.vtk");
|
||||
writer.WriteDataSet(tds.Make3DExplicitDataSet0(), true);
|
||||
std::cout << "Set writer to output an explicit grid" << std::endl;
|
||||
vtkm::io::VTKDataSetWriter writer("Make3DExplicitDataSet0.vtk");
|
||||
writer.WriteDataSet(tds.Make3DExplicitDataSet0());
|
||||
}
|
||||
|
||||
void TestVTKUniformWrite()
|
||||
@ -166,9 +166,9 @@ void TestVTKUniformWrite()
|
||||
WRITE_FILE(Make3DRegularDataSet0);
|
||||
WRITE_FILE(Make3DRegularDataSet1);
|
||||
|
||||
std::cout << "Force writer to output a uniform grid as points" << std::endl;
|
||||
vtkm::io::VTKDataSetWriter writer("Make3DUniformDataSet0-no-grid.vtk");
|
||||
writer.WriteDataSet(tds.Make3DUniformDataSet0(), true);
|
||||
std::cout << "Set writer to output an uniform grid" << std::endl;
|
||||
vtkm::io::VTKDataSetWriter writer("Make3DUniformDataSet0.vtk");
|
||||
writer.WriteDataSet(tds.Make3DUniformDataSet0());
|
||||
}
|
||||
|
||||
void TestVTKRectilinearWrite()
|
||||
@ -179,9 +179,9 @@ void TestVTKRectilinearWrite()
|
||||
|
||||
WRITE_FILE(Make3DRectilinearDataSet0);
|
||||
|
||||
std::cout << "Force writer to output a rectilinear grid as points" << std::endl;
|
||||
vtkm::io::VTKDataSetWriter writer("Make3DRectilinearDataSet0-no-grid.vtk");
|
||||
writer.WriteDataSet(tds.Make3DRectilinearDataSet0(), true);
|
||||
std::cout << "Set writer to output a rectilinear grid" << std::endl;
|
||||
vtkm::io::VTKDataSetWriter writer("Make3DRectilinearDataSet0.vtk");
|
||||
writer.WriteDataSet(tds.Make3DRectilinearDataSet0());
|
||||
}
|
||||
|
||||
void TestVTKCompoundWrite()
|
||||
|
Loading…
Reference in New Issue
Block a user