OBJ, PLY, and STL used a mix of fprintf, std::cout, and std::cerr to trace warnings, errors, and general messages to the console. Now, we instead use CLOG which provides real facilities for warnings and errors and generally removes the need to pull in and use the heavy `<iostream>` machinery. For traces that should always be printed, `fmt::print` is used since CLOG currently doesn't provide that particular level of trace. Tests were only minimally changed to drop usage of streams while keeping their prior usage of older stdio APIs. We can change to using fmtlib there too if desired. Pull Request: https://projects.blender.org/blender/blender/pulls/130107
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup obj
|
|
*/
|
|
|
|
#include "BLI_path_utils.hh"
|
|
#include "BLI_timeit.hh"
|
|
|
|
#include "IO_wavefront_obj.hh"
|
|
|
|
#include "obj_exporter.hh"
|
|
#include "obj_importer.hh"
|
|
|
|
#include <fmt/core.h>
|
|
|
|
using namespace blender::timeit;
|
|
|
|
static void report_duration(const char *job, const TimePoint &start_time, const char *path)
|
|
{
|
|
Nanoseconds duration = Clock::now() - start_time;
|
|
fmt::print("OBJ {} of '{}' took ", job, BLI_path_basename(path));
|
|
print_duration(duration);
|
|
fmt::print("\n");
|
|
}
|
|
|
|
void OBJ_export(bContext *C, const OBJExportParams *export_params)
|
|
{
|
|
TimePoint start_time = Clock::now();
|
|
blender::io::obj::exporter_main(C, *export_params);
|
|
report_duration("export", start_time, export_params->filepath);
|
|
}
|
|
|
|
void OBJ_import(bContext *C, const OBJImportParams *import_params)
|
|
{
|
|
TimePoint start_time = Clock::now();
|
|
blender::io::obj::importer_main(C, *import_params);
|
|
report_duration("import", start_time, import_params->filepath);
|
|
}
|
|
|
|
void OBJ_import_geometries(const OBJImportParams *import_params,
|
|
blender::Vector<blender::bke::GeometrySet> &geometries)
|
|
{
|
|
blender::io::obj::importer_geometry(*import_params, geometries);
|
|
}
|