vtk-m/tutorial/logging.cxx

39 lines
1.6 KiB
C++
Raw Normal View History

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
2022-01-05 20:30:40 +00:00
#include <vtkm/cont/Initialize.h>
#include <vtkm/io/VTKDataSetReader.h>
#include <vtkm/io/VTKDataSetWriter.h>
2022-01-05 20:30:40 +00:00
// Note that to see all of the logging output generated by this example, run
// the program with the --vtkm-log-level=1 argument.
2022-01-05 20:30:40 +00:00
int main(int argc, char** argv)
{
auto opts = vtkm::cont::InitializeOptions::AddHelp;
2022-01-05 20:30:40 +00:00
// SetLogLevelName must be called before Initialize
vtkm::cont::SetLogLevelName(vtkm::cont::LogLevel::UserFirst, "tlog");
2022-01-05 20:30:40 +00:00
vtkm::cont::InitializeResult config = vtkm::cont::Initialize(argc, argv, opts);
const std::string input = "data/kitchen.vtk";
vtkm::io::VTKDataSetReader reader(input);
VTKM_LOG_F(vtkm::cont::LogLevel::Info, "Reading from file %s", input.c_str());
vtkm::cont::DataSet ds_from_file = reader.ReadDataSet();
VTKM_LOG_F(vtkm::cont::LogLevel::Info, "Done reading from file %s", input.c_str());
const std::string output = "out_logging.vtk";
VTKM_LOG_S(vtkm::cont::LogLevel::UserFirst, "Writing to file" << output);
2022-01-05 20:30:40 +00:00
vtkm::io::VTKDataSetWriter writer(output);
writer.WriteDataSet(ds_from_file);
VTKM_LOG_S(vtkm::cont::LogLevel::UserFirst, "Done writing to file" << output);
2022-01-05 20:30:40 +00:00
return 0;
}