Pass around non-static logger instances and programmatic access to messages in-memory

This commit is contained in:
Thomas Krijnen
2026-06-10 18:30:54 +02:00
parent a751fb956d
commit a7738eeb64
132 changed files with 1029 additions and 884 deletions
+1 -1
View File
@@ -234,7 +234,7 @@ int main(int argc, char** argv) {
}
// Redirect the output (both progress and log) to stdout
Logger::SetOutput(&std::cout, &std::cout);
Logger::Root().SetOutput(&std::cout, &std::cout);
// Parse the IFC file provided in argv[1]
IfcParse::IfcFile file(argv[1]);
+85 -84
View File
@@ -174,7 +174,7 @@ bool file_exists(const std::string& filename) {
static std::basic_stringstream<path_t::value_type> log_stream;
void write_log(bool);
void fix_quantities(IfcParse::IfcFile&, bool, bool, bool);
void fix_quantities(IfcParse::IfcFile&, bool, bool, bool, Logger& logger = Logger::Root());
std::string format_duration(time_t start, time_t end);
/// @todo make the filters non-global
@@ -204,7 +204,7 @@ size_t read_filters_from_file(const std::string&, inclusion_filter&, inclusion_t
void parse_filter(geom_filter &, const std::vector<std::string>&);
std::vector<IfcGeom::filter_t> setup_filters(const std::vector<geom_filter>&, const std::string&);
bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file, bool no_progress, bool mmap, bool bypass_properties=false);
bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file, bool no_progress, bool mmap, bool bypass_properties=false, Logger& logger = Logger::Root());
// from https://stackoverflow.com/questions/31696328/boost-program-options-using-zero-parameter-options-multiple-times
struct verbosity_counter {
@@ -226,6 +226,7 @@ int main(int argc, char** argv) {
typedef po::command_line_parser command_line_parser;
typedef char char_t;
#endif
Logger logger;
inclusion_filter include_filter;
inclusion_traverse_filter include_traverse_filter;
@@ -492,15 +493,15 @@ int main(int argc, char** argv) {
if (num_threads <= 0) {
num_threads = std::thread::hardware_concurrency();
Logger::Notice("SYS", 7, "Using " + std::to_string(num_threads) + " threads");
logger.Notice("SYS", 7, "Using " + std::to_string(num_threads) + " threads");
}
if (vmap.count("log-format") == 1) {
boost::to_lower(log_format);
if (log_format == "plain") {
Logger::OutputFormat(Logger::FMT_PLAIN);
logger.OutputFormat(Logger::FMT_PLAIN);
} else if (log_format == "json") {
Logger::OutputFormat(Logger::FMT_JSON);
logger.OutputFormat(Logger::FMT_JSON);
} else {
cerr_ << "[Error] --log-format should be either plain or json" << std::endl;
print_usage();
@@ -511,7 +512,7 @@ int main(int argc, char** argv) {
if (!filter_filename.empty()) {
size_t num_filters = read_filters_from_file(IfcUtil::path::to_utf8(filter_filename), include_filter, include_traverse_filter, exclude_filter, exclude_traverse_filter);
if (num_filters) {
Logger::Notice("SYS", 8, boost::lexical_cast<std::string>(num_filters) + " filters read from specifified file.");
logger.Notice("SYS", 8, boost::lexical_cast<std::string>(num_filters) + " filters read from specifified file.");
} else {
cerr_ << "[Error] No filters read from specifified file.\n";
return EXIT_FAILURE;
@@ -601,27 +602,27 @@ int main(int argc, char** argv) {
if (vmap.count("log-file")) {
log_fs.open(log_file.c_str(), std::ios::app);
Logger::SetOutput(quiet ? nullptr : &cout_, &log_fs);
logger.SetOutput(quiet ? nullptr : &cout_, &log_fs);
} else {
Logger::SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
logger.SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
}
switch (vcounter.count) {
case 0:
Logger::Verbosity(Logger::LOG_ERROR);
logger.Verbosity(Logger::LOG_ERROR);
break;
case 1:
Logger::Verbosity(Logger::LOG_NOTICE);
logger.Verbosity(Logger::LOG_NOTICE);
break;
case 2:
Logger::Verbosity(Logger::LOG_DEBUG);
logger.Verbosity(Logger::LOG_DEBUG);
break;
case 3:
Logger::Verbosity(Logger::LOG_PERF);
logger.Verbosity(Logger::LOG_PERF);
break;
case 4:
Logger::Verbosity(Logger::LOG_PERF);
Logger::PrintPerformanceStatsOnElement(true);
logger.Verbosity(Logger::LOG_PERF);
logger.PrintPerformanceStatsOnElement(true);
break;
}
@@ -665,52 +666,52 @@ int main(int argc, char** argv) {
if (output_extension == XML || output_extension == JSON) {
int exit_code = EXIT_FAILURE;
try {
if (init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap)) {
if (init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap, false, logger)) {
time_t start, end;
time(&start);
if (output_extension == XML) {
XmlSerializer s(ifc_file, IfcUtil::path::to_utf8(output_temp_filename));
Logger::Status("Writing XML output...");
XmlSerializer s(ifc_file, IfcUtil::path::to_utf8(output_temp_filename), logger);
logger.Status("Writing XML output...");
s.finalize();
} else {
#ifdef WITH_GLTF
JsonSerializer s(ifc_file, IfcUtil::path::to_utf8(output_temp_filename), JsonSerializer::JSON_DIALECT_CREOOX);
Logger::Status("Writing JSON output...");
JsonSerializer s(ifc_file, IfcUtil::path::to_utf8(output_temp_filename), JsonSerializer::JSON_DIALECT_CREOOX, logger);
logger.Status("Writing JSON output...");
s.finalize();
#endif
}
time(&end);
Logger::Status("Done! Conversion took " + format_duration(start, end));
logger.Status("Done! Conversion took " + format_duration(start, end));
IfcUtil::path::rename_file(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(output_filename));
exit_code = EXIT_SUCCESS;
}
} catch (const std::exception& e) {
Logger::Error("SYS", 9, e);
logger.Error("SYS", 9, e);
}
write_log(!quiet);
return exit_code;
} else if (output_extension == IFC) {
int exit_code = EXIT_FAILURE;
try {
if (init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap)) {
if (init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap, false, logger)) {
time_t start, end;
time(&start);
std::ofstream fs(output_filename.c_str());
if (fs.is_open()) {
if (vmap.count("calculate-quantities")) {
fix_quantities(*ifc_file, no_progress, quiet, stderr_progress);
fix_quantities(*ifc_file, no_progress, quiet, stderr_progress, logger);
}
fs << *ifc_file;
exit_code = EXIT_SUCCESS;
} else {
Logger::Error("SYS", 10, "Unable to open output file for writing");
logger.Error("SYS", 10, "Unable to open output file for writing");
}
time(&end);
Logger::Status("Done! Writing IFC took " + format_duration(start, end));
logger.Status("Done! Writing IFC took " + format_duration(start, end));
}
} catch (const std::exception& e) {
Logger::Error("SYS", 11, e);
logger.Error("SYS", 11, e);
}
write_log(!quiet);
return exit_code;
@@ -722,26 +723,26 @@ int main(int argc, char** argv) {
if (vmap.count("stream")) {
time_t start, end;
time(&start);
RocksDbSerializer s(IfcUtil::path::to_utf8(input_filename), IfcUtil::path::to_utf8(output_filename), true);
Logger::Status("Populating RocksDB Key-Value store...");
RocksDbSerializer s(IfcUtil::path::to_utf8(input_filename), IfcUtil::path::to_utf8(output_filename), true, logger);
logger.Status("Populating RocksDB Key-Value store...");
s.finalize();
time(&end);
Logger::Status("Done! Conversion took " + format_duration(start, end));
logger.Status("Done! Conversion took " + format_duration(start, end));
exit_code = EXIT_SUCCESS;
} else {
if (init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap)) {
if (init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap, false, logger)) {
time_t start, end;
time(&start);
RocksDbSerializer s(ifc_file, IfcUtil::path::to_utf8(output_filename));
Logger::Status("Populating RocksDB Key-Value store...");
RocksDbSerializer s(ifc_file, IfcUtil::path::to_utf8(output_filename), logger);
logger.Status("Populating RocksDB Key-Value store...");
s.finalize();
time(&end);
Logger::Status("Done! Conversion took " + format_duration(start, end));
logger.Status("Done! Conversion took " + format_duration(start, end));
exit_code = EXIT_SUCCESS;
}
}
} catch (const std::exception& e) {
Logger::Error("SYS", 12, e);
logger.Error("SYS", 12, e);
}
write_log(!quiet);
return exit_code;
@@ -761,9 +762,9 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
if (!entity_filter.entity_names.empty()) { entity_filter.update_description(); Logger::Notice("SYS", 13, entity_filter.description); }
if (!layer_filter.values.empty()) { layer_filter.update_description(); Logger::Notice("SYS", 14, layer_filter.description); }
if (!attribute_filter.attribute_name.empty()) { attribute_filter.update_description(); Logger::Notice("SYS", 15, attribute_filter.description); }
if (!entity_filter.entity_names.empty()) { entity_filter.update_description(); logger.Notice("SYS", 13, entity_filter.description); }
if (!layer_filter.values.empty()) { layer_filter.update_description(); logger.Notice("SYS", 14, layer_filter.description); }
if (!attribute_filter.attribute_name.empty()) { attribute_filter.update_description(); logger.Notice("SYS", 15, attribute_filter.description); }
#ifdef _MSC_VER
if (output_extension == DAE || output_extension == STP || output_extension == IGS) {
@@ -828,39 +829,39 @@ int main(int argc, char** argv) {
if (output_extension == OBJ) {
// Do not use temp file for MTL as it's such a small file.
const path_t mtl_filename = change_extension(output_filename, MTL);
serializer = boost::make_shared<WaveFrontOBJSerializer>(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(mtl_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<WaveFrontOBJSerializer>(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(mtl_filename), geometry_settings, serializer_settings, logger);
#ifdef WITH_OPENCOLLADA
} else if (output_extension == DAE) {
serializer = boost::make_shared<ColladaSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<ColladaSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings, logger);
#endif
#ifdef WITH_GLTF
} else if (output_extension == GLB) {
serializer = boost::make_shared<GltfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<GltfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings, logger);
#endif
#ifdef WITH_USD
} else if (output_extension == USD || output_extension == USDA || output_extension == USDC) {
serializer = boost::make_shared<USDSerializer>(IfcUtil::path::to_utf8(output_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<USDSerializer>(IfcUtil::path::to_utf8(output_filename), geometry_settings, serializer_settings, logger);
#endif
#ifdef IFOPSH_WITH_OPENCASCADE
} else if (output_extension == STP) {
serializer = boost::make_shared<StepSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<StepSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings, logger);
} else if (output_extension == IGS) {
#if OCC_VERSION_HEX < 0x60900
// According to https://tracker.dev.opencascade.org/view.php?id=25689 something has been fixed in 6.9.0
IGESControl_Controller::Init(); // work around Open Cascade bug
#endif
serializer = boost::make_shared<IgesSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<IgesSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings, logger);
} else if (output_extension == SVG) {
geometry_settings.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
serializer = boost::make_shared<SvgSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<SvgSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings, logger);
#ifdef WITH_HDF5
} else if (output_extension == HDF) {
geometry_settings.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
serializer = boost::make_shared<HdfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<HdfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings, false, logger);
#endif
#endif
} else if (output_extension == TTL) {
serializer = boost::make_shared<TtlWktSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings);
serializer = boost::make_shared<TtlWktSerializer>(IfcUtil::path::to_utf8(output_temp_filename), geometry_settings, serializer_settings, logger);
} else {
cerr_ << "[Error] Unknown output filename extension '" << output_extension << "'\n";
write_log(!quiet);
@@ -871,13 +872,13 @@ int main(int argc, char** argv) {
const bool is_tesselated = serializer->isTesselated(); // isTesselated() doesn't change at run-time
if (!is_tesselated) {
if (geometry_settings.get<ifcopenshell::geometry::settings::WeldVertices>().get()) {
Logger::Notice("SYS", 16, "Weld vertices setting ignored when writing non-tesselated output");
logger.Notice("SYS", 16, "Weld vertices setting ignored when writing non-tesselated output");
}
if (geometry_settings.get<ifcopenshell::geometry::settings::GenerateUvs>().get()) {
Logger::Notice("SYS", 17, "Generate UVs setting ignored when writing non-tesselated output");
logger.Notice("SYS", 17, "Generate UVs setting ignored when writing non-tesselated output");
}
if (center_model || center_model_geometry) {
Logger::Notice("SYS", 18, "Centering/offsetting model setting ignored when writing non-tesselated output");
logger.Notice("SYS", 18, "Centering/offsetting model setting ignored when writing non-tesselated output");
}
geometry_settings.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
@@ -895,7 +896,7 @@ int main(int argc, char** argv) {
// @nb last argument true -> bypass_properties which are not read by any of the geometry serializers
// XML, RocksDB, IFC are already special-cased above
// SVG requires properties for IfcAnnotation/DRAWING properties
if (!init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap, output_extension != SVG)) {
if (!init_input_file(IfcUtil::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap, output_extension != SVG, logger)) {
write_log(!quiet);
serializer.reset();
IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename)); /**< @todo Windows Unicode support */
@@ -903,9 +904,9 @@ int main(int argc, char** argv) {
}
if (vmap.count("log-file")) {
Logger::SetOutput(quiet ? nullptr : &cout_, &log_fs);
logger.SetOutput(quiet ? nullptr : &cout_, &log_fs);
} else {
Logger::SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
logger.SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
}
if (model_rotation) {
@@ -920,13 +921,13 @@ int main(int argc, char** argv) {
std::stringstream msg;
msg << "Using model rotation (" << rotation[0] << "," << rotation[1] << "," << rotation[2] << "," << rotation[3] << ")";
Logger::Notice("SYS", 19, msg.str());
logger.Notice("SYS", 19, msg.str());
geometry_settings.get<ifcopenshell::geometry::settings::ModelRotation>().value = rotation;
}
if (model_offset && (center_model || center_model_geometry)) {
Logger::Notice("GEO", 22, "--model-offset ignored with --center-model or --center-model-geometry");
logger.Notice("GEO", 22, "--model-offset ignored with --center-model or --center-model-geometry");
}
if (model_offset && !(center_model || center_model_geometry)) {
@@ -941,7 +942,7 @@ int main(int argc, char** argv) {
std::stringstream msg;
msg << std::setprecision(std::numeric_limits<double>::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")";
Logger::Notice("SYS", 20, msg.str());
logger.Notice("SYS", 20, msg.str());
geometry_settings.get<ifcopenshell::geometry::settings::ModelOffset>().value = offset;
}
@@ -949,17 +950,17 @@ int main(int argc, char** argv) {
if (is_tesselated && (center_model || center_model_geometry)) {
std::vector<double> offset(3);
IfcGeom::Iterator tmp_context_iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings), geometry_settings, ifc_file, filter_funcs, num_threads);
IfcGeom::Iterator tmp_context_iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings, logger), geometry_settings, ifc_file, filter_funcs, num_threads, logger);
time_t start, end;
time(&start);
if (!quiet) Logger::Status("Computing bounds...");
if (!quiet) logger.Status("Computing bounds...");
if (center_model_geometry) {
if (!tmp_context_iterator.initialize()) {
/// @todo It would be nice to know and print separate error prints for a case where we found no entities
/// and for a case we found no entities that satisfy our filtering criteria.
Logger::Notice("GEO", 23, "No geometrical elements found or none successfully converted");
logger.Notice("GEO", 23, "No geometrical elements found or none successfully converted");
serializer.reset();
IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename));
write_log(!quiet);
@@ -970,7 +971,7 @@ int main(int argc, char** argv) {
tmp_context_iterator.compute_bounds(center_model_geometry);
time(&end);
if (!quiet) Logger::Status("Done ! Bounds computed in " + format_duration(start, end));
if (!quiet) logger.Status("Done ! Bounds computed in " + format_duration(start, end));
auto center = (tmp_context_iterator.bounds_min().ccomponents() + tmp_context_iterator.bounds_max().ccomponents()) * 0.5;
offset[0] = -center(0);
@@ -979,7 +980,7 @@ int main(int argc, char** argv) {
std::stringstream msg;
msg << std::setprecision (std::numeric_limits<double>::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")";
Logger::Notice("SYS", 21, msg.str());
logger.Notice("SYS", 21, msg.str());
geometry_settings.get<ifcopenshell::geometry::settings::ModelOffset>().value = offset;
}
@@ -995,7 +996,7 @@ int main(int argc, char** argv) {
std::unique_ptr<IfcGeom::Iterator> context_iterator;
if (!elems_from_adaptor) {
context_iterator.reset(new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings), geometry_settings, ifc_file, filter_funcs, num_threads));
context_iterator.reset(new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings, logger), geometry_settings, ifc_file, filter_funcs, num_threads, logger));
}
#if defined(WITH_HDF5) && defined(IFOPSH_WITH_OPENCASCADE)
@@ -1004,17 +1005,17 @@ int main(int argc, char** argv) {
if (!vmap.count("cache-file")) {
cache_file = input_filename + CACHE + HDF;
}
cache.reset(new HdfSerializer(IfcUtil::path::to_utf8(cache_file), geometry_settings, serializer_settings));
cache.reset(new HdfSerializer(IfcUtil::path::to_utf8(cache_file), geometry_settings, serializer_settings, false, logger));
context_iterator->set_cache(cache.get());
}
#endif
Logger::Message(Logger::LOG_PERF, "GEO", 24, "file geometry conversion");
logger.Message(Logger::LOG_PERF, "GEO", 24, "file geometry conversion");
if (context_iterator && !context_iterator->initialize()) {
/// @todo It would be nice to know and print separate error prints for a case where we found no entities
/// and for a case we found no entities that satisfy our filtering criteria.
Logger::Notice("GEO", 25, "No geometrical elements found or none successfully converted");
logger.Notice("GEO", 25, "No geometrical elements found or none successfully converted");
serializer.reset();
IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename));
write_log(!quiet);
@@ -1033,7 +1034,7 @@ int main(int argc, char** argv) {
static_cast<SvgSerializer*>(serializer.get())->setSectionHeightsFromStoreys();
}
} else if (vmap.count("section-height") != 0) {
Logger::Notice("SYS", 22, "Overriding section height");
logger.Notice("SYS", 22, "Overriding section height");
static_cast<SvgSerializer*>(serializer.get())->setSectionHeight(section_height);
}
if (vmap.count("print-space-names") != 0) {
@@ -1111,7 +1112,7 @@ int main(int argc, char** argv) {
int old_progress = quiet ? 0 : -1;
if (!quiet) {
Logger::Status("Creating geometry...");
logger.Status("Creating geometry...");
}
// The functions IfcGeom::Iterator::get() and IfcGeom::Iterator::next()
@@ -1156,10 +1157,10 @@ int main(int argc, char** argv) {
if (stderr_progress)
cerr_ << std::flush;
} else if (vcounter.count == 2) {
Logger::Message(Logger::LOG_DEBUG, "SYS", 23, "Progress " + boost::lexical_cast<std::string>(progress));
logger.Message(Logger::LOG_DEBUG, "SYS", 23, "Progress " + boost::lexical_cast<std::string>(progress));
} else {
progress = progress / 2;
if (old_progress != progress) Logger::ProgressBar(progress);
if (old_progress != progress) logger.ProgressBar(progress);
old_progress = progress;
}
}
@@ -1188,7 +1189,7 @@ int main(int argc, char** argv) {
}
} else {
const std::string task = ((num_threads == 1) ? "creating" : "writing");
Logger::Status("\rDone " + task + " geometry (" + boost::lexical_cast<std::string>(num_created) +
logger.Status("\rDone " + task + " geometry (" + boost::lexical_cast<std::string>(num_created) +
" objects) ");
}
@@ -1196,7 +1197,7 @@ int main(int argc, char** argv) {
// Make sure the dtor is explicitly run here (e.g. output files are closed before renaming them).
serializer.reset();
Logger::Message(Logger::LOG_PERF, "GEO", 26, "done file geometry conversion");
logger.Message(Logger::LOG_PERF, "GEO", 26, "done file geometry conversion");
bool successful;
if(output_extension == USD || output_extension == USDC || output_extension == USDA) {
@@ -1214,13 +1215,13 @@ int main(int argc, char** argv) {
output_temp_filename << "' for the conversion result.";
}
if (geometry_settings.get<ifcopenshell::geometry::settings::ValidateQuantities>().get() && Logger::MaxSeverity() >= Logger::LOG_ERROR) {
Logger::Error("SYS", 24, "Errors encountered during processing.");
if (geometry_settings.get<ifcopenshell::geometry::settings::ValidateQuantities>().get() && logger.MaxSeverity() >= Logger::LOG_ERROR) {
logger.Error("SYS", 24, "Errors encountered during processing.");
successful = false;
}
if (Logger::Verbosity() == Logger::LOG_PERF) {
Logger::PrintPerformanceStats();
if (logger.Verbosity() == Logger::LOG_PERF) {
logger.PrintPerformanceStats();
}
write_log(!quiet);
@@ -1228,7 +1229,7 @@ int main(int argc, char** argv) {
time(&end);
if (!quiet) {
Logger::Status("\nConversion took " + format_duration(start, end));
logger.Status("\nConversion took " + format_duration(start, end));
}
return successful ? EXIT_SUCCESS : EXIT_FAILURE;
@@ -1266,11 +1267,11 @@ void write_log(bool header) {
#include <boost/algorithm/string/predicate.hpp>
bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file, bool no_progress, bool mmap, bool bypass_properties) {
bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file, bool no_progress, bool mmap, bool bypass_properties, Logger& logger) {
time_t start, end;
// Prevent IfcFile::Init() prints by setting output to null temporarily
if (no_progress) { Logger::SetOutput(NULL, &log_stream); }
if (no_progress) { logger.SetOutput(NULL, &log_stream); }
time(&start);
@@ -1308,13 +1309,13 @@ bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file,
}
if (!ifc_file || !ifc_file->good()) {
Logger::Error("SYN", 1, "Unable to parse input file '" + filename + "'");
logger.Error("SYN", 1, "Unable to parse input file '" + filename + "'");
return false;
}
time(&end);
if (no_progress) { Logger::SetOutput(&cout_, &log_stream); }
else { Logger::Status("Parsing input file took " + format_duration(start, end)); }
if (no_progress) { logger.SetOutput(&cout_, &log_stream); }
else { logger.Status("Parsing input file took " + format_duration(start, end)); }
return true;
@@ -1533,7 +1534,7 @@ namespace latebound_access {
}
}
void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress) {
void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger) {
{
auto delete_reversed = [&f](const aggregate_of_instance::ptr& insts) {
if (!insts) {
@@ -1588,7 +1589,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
settings.get<ifcopenshell::geometry::settings::ConvertBackUnits>().value = true;
settings.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "opencascade", settings), settings, &f, {}, 1);
IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "opencascade", settings, logger), settings, &f, {}, 1, logger);
if (!context_iterator.initialize()) {
return;
@@ -1716,7 +1717,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
cerr_ << std::flush;
} else {
const int progress = context_iterator.progress() / 2;
if (old_progress != progress) Logger::ProgressBar(progress);
if (old_progress != progress) logger.ProgressBar(progress);
old_progress = progress;
}
}
@@ -1732,7 +1733,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
if (stderr_progress)
cerr_ << std::flush;
} else {
Logger::Status("\rDone writing quantities for " + boost::lexical_cast<std::string>(num_created) +
logger.Status("\rDone writing quantities for " + boost::lexical_cast<std::string>(num_created) +
" objects ");
}
+7 -7
View File
@@ -18,8 +18,8 @@ typedef CGAL::AABB_traits<Kernel_, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;
void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress) {
intersection_validator v(f, { "IfcWall", "IfcSpace", "IfcSlab", "IfcCovering" }, 1.e-5, no_progress, quiet, stderr_progress);
void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) {
intersection_validator v(f, { "IfcWall", "IfcSpace", "IfcSlab", "IfcCovering" }, 1.e-5, no_progress, quiet, stderr_progress, logger);
auto rels = f.instances_by_type("IfcRelSpaceBoundary");
@@ -54,7 +54,7 @@ void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, boo
settings.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
settings.get<ifcopenshell::geometry::settings::DisableOpeningSubtractions>().value = true;
ifcopenshell::geometry::Converter c("cgal", &f2, settings);
ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f2, "cgal", settings, logger), &f2, settings, logger);
std::map<std::set<std::string>, std::vector<Kernel_::Point_3>> elem_to_space_boundary_coords;
@@ -81,7 +81,7 @@ void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, boo
std::set< std::set<std::string> > guid_pairs_visited;
v([&rel_by_space_elem, &elem_to_space_boundary_coords, &guid_pairs_visited](const intersection_validator::Box& a, const intersection_validator::Box& b) {
v([&logger, &rel_by_space_elem, &elem_to_space_boundary_coords, &guid_pairs_visited](const intersection_validator::Box& a, const intersection_validator::Box& b) {
std::ostringstream ss;
// ss << id_map[a.id()]->first->data().toString() << "x" << id_map[b.id()]->first->data().toString() << std::endl;
// auto x = id_map[a.id()]->second * id_map[b.id()]->second;
@@ -128,7 +128,7 @@ void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, boo
auto itelem = elem_to_space_boundary_coords.find({ Aguid, Bguid });
if (itelem == elem_to_space_boundary_coords.end()) {
Logger::Error("VAL", 1, "Missing space boundary relationship " + Aguid + " " + Bguid);
logger.Error("VAL", 1, "Missing space boundary relationship " + Aguid + " " + Bguid);
return;
}
@@ -141,7 +141,7 @@ void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, boo
bool valid = *std::max_element(distances.begin(), distances.end()) < 0.4;
if (!valid) {
Logger::Error("VAL", 2, "Wrong connection geometry " + Aguid + " " + Bguid);
logger.Error("VAL", 2, "Wrong connection geometry " + Aguid + " " + Bguid);
}
/*{
@@ -178,7 +178,7 @@ void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, boo
auto g1 = n.substr(0, 22);
auto g2 = n.substr(23);
if (is_wall_space_or_slab(g1) && is_wall_space_or_slab(g2) && guid_pairs_visited.find({ g1, g2 }) == guid_pairs_visited.end()) {
Logger::Error("VAL", 3, "Space boundary for non-bounding geometry " + g1 + " " + g2);
logger.Error("VAL", 3, "Space boundary for non-bounding geometry " + g1 + " " + g2);
}
}
}
@@ -9,7 +9,7 @@
#include <algorithm>
void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress) {
void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) {
ifcopenshell::geometry::Settings settings;
settings.get<ifcopenshell::geometry::settings::UseWorldCoords>().value = false;
@@ -23,7 +23,7 @@ void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, b
IfcGeom::entity_filter(false, false, {"IfcOpeningElement", "IfcSpace"})
};
IfcGeom::Iterator context_iterator("cgal", settings, &f, no_openings_and_spaces, 1);
IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings, logger), settings, &f, no_openings_and_spaces, 1, logger);
auto get_elevation = [](const IfcUtil::IfcBaseClass* a) {
return ((const IfcUtil::IfcBaseEntity*)a)->get_value<double>("Elevation", 0.);
@@ -198,7 +198,7 @@ void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, b
auto s = geom_object->product()->get_value<std::string>("GlobalId");
auto s1 = ((IfcUtil::IfcBaseEntity*)storeys_sorted[calc_idx])->get_value<std::string>("GlobalId");
auto s2 = ((IfcUtil::IfcBaseEntity*)elem_to_storey[geom_object->product()])->get_value<std::string>("GlobalId");
Logger::Error("VAL", 4, "Element " + s + " contained in " + s2 + " located on " + s1);
logger.Error("VAL", 4, "Element " + s + " contained in " + s2 + " located on " + s1);
}
if (!no_progress) {
@@ -214,7 +214,7 @@ void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, b
std::cerr << std::flush;
} else {
const int progress = context_iterator.progress() / 2;
if (old_progress != progress) Logger::ProgressBar(progress);
if (old_progress != progress) logger.ProgressBar(progress);
old_progress = progress;
}
}
@@ -230,7 +230,7 @@ void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, b
if (stderr_progress)
std::cerr << std::flush;
} else {
Logger::Status("\rDone fixing space boundaries for " + boost::lexical_cast<std::string>(num_created) +
logger.Status("\rDone fixing space boundaries for " + boost::lexical_cast<std::string>(num_created) +
" objects ");
}
}
@@ -9,8 +9,8 @@
using namespace ifcopenshell::geometry;
void fix_wallconnectivity(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress) {
intersection_validator v(f, { "IfcWall" }, 1.e-3, no_progress, quiet, stderr_progress);
void fix_wallconnectivity(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) {
intersection_validator v(f, { "IfcWall" }, 1.e-3, no_progress, quiet, stderr_progress, logger);
ifcopenshell::geometry::Settings settings;
@@ -24,7 +24,7 @@ void fix_wallconnectivity(IfcParse::IfcFile& f, bool no_progress, bool quiet, bo
settings.get<ifcopenshell::geometry::settings::IncludeCurves>().value = true;
settings.get<ifcopenshell::geometry::settings::IncludeSurfaces>().value = false;
ifcopenshell::geometry::Converter c("cgal", &f, settings);
ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings, logger), &f, settings, logger);
auto rels = f.instances_by_type("IfcRelConnectsPathElements");
std::map<std::set<const IfcUtil::IfcBaseClass*>, const IfcUtil::IfcBaseClass*> rel_by_elem;
@@ -39,7 +39,7 @@ void fix_wallconnectivity(IfcParse::IfcFile& f, bool no_progress, bool quiet, bo
double total_nef_intersection_time = 0.;
double conversion_to_poly = 0.;
v([&c, &rel_by_elem, &rels_encounted, &total_nef_intersection_time, &conversion_to_poly](const intersection_validator::Box& a, const intersection_validator::Box& b) {
v([&logger, &c, &rel_by_elem, &rels_encounted, &total_nef_intersection_time, &conversion_to_poly](const intersection_validator::Box& a, const intersection_validator::Box& b) {
auto A = a.handle()->first;
auto B = b.handle()->first;
@@ -169,21 +169,21 @@ void fix_wallconnectivity(IfcParse::IfcFile& f, bool no_progress, bool quiet, bo
if (a_type != atype_computed || b_type != btype_computed) {
if (rel) {
Logger::Error("VAL", 5, std::string("Connection type ") + atype_computed + " " + btype_computed + " for:", rel);
logger.Error("VAL", 5, std::string("Connection type ") + atype_computed + " " + btype_computed + " for:", rel);
} else {
auto A_str = A->get_value<std::string>("GlobalId");
auto B_str = B->get_value<std::string>("GlobalId");
Logger::Error("VAL", 6, "No connection for adjacent " + A_str + " " + B_str);
logger.Error("VAL", 6, "No connection for adjacent " + A_str + " " + B_str);
}
}
});
std::for_each(rels->begin(), rels->end(), [&rels_encounted, &v](const IfcUtil::IfcBaseClass* rel) {
std::for_each(rels->begin(), rels->end(), [&logger, &rels_encounted, &v](const IfcUtil::IfcBaseClass* rel) {
if (rels_encounted.find(rel) == rels_encounted.end()) {
auto x = (IfcUtil::IfcBaseEntity*)((IfcUtil::IfcBaseEntity*)rel)->get_value<IfcUtil::IfcBaseClass*>("RelatingElement");
auto y = (IfcUtil::IfcBaseEntity*)((IfcUtil::IfcBaseEntity*)rel)->get_value<IfcUtil::IfcBaseClass*>("RelatedElement");
if (v.successfully_processed.find(x) != v.successfully_processed.end() && v.successfully_processed.find(y) != v.successfully_processed.end()) {
Logger::Error("VAL", 7, "Connection for non-adjacent walls", rel);
logger.Error("VAL", 7, "Connection for non-adjacent walls", rel);
}
}
});
+6 -5
View File
@@ -3,6 +3,7 @@
#include "../ifcgeom/kernels/cgal/CgalKernel.h"
#include "../ifcgeom/IfcGeomFilter.h"
#include "../ifcgeom/Iterator.h"
#include "../ifcgeom/hybrid_kernel.h"
#include <CGAL/box_intersection_d.h>
#include <CGAL/minkowski_sum_3.h>
@@ -445,7 +446,7 @@ struct intersection_validator {
std::set<const IfcUtil::IfcBaseEntity*> successfully_processed;
intersection_validator(IfcParse::IfcFile& f, std::initializer_list<std::string> entities, double eps, bool no_progress, bool quiet, bool stderr_progress) {
intersection_validator(IfcParse::IfcFile& f, std::initializer_list<std::string> entities, double eps, bool no_progress, bool quiet, bool stderr_progress, Logger& logger = Logger::Root()) {
ifcopenshell::geometry::Settings settings;
settings.get<ifcopenshell::geometry::settings::UseWorldCoords>().value = false;
@@ -459,7 +460,7 @@ struct intersection_validator {
IfcGeom::entity_filter(true, false, entities)
};
IfcGeom::Iterator context_iterator("cgal", settings, &f, spaces_and_walls, 1);
IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings, logger), settings, &f, spaces_and_walls, 1, logger);
if (!context_iterator.initialize()) {
return;
@@ -562,7 +563,7 @@ struct intersection_validator {
std::cerr << std::flush;
} else {
const int progress = context_iterator.progress() / 2;
if (old_progress != progress) Logger::ProgressBar(progress);
if (old_progress != progress) logger.ProgressBar(progress);
old_progress = progress;
}
}
@@ -578,7 +579,7 @@ struct intersection_validator {
if (stderr_progress)
std::cerr << std::flush;
} else {
Logger::Status("\rDone fixing space boundaries for " + boost::lexical_cast<std::string>(num_created) +
logger.Status("\rDone fixing space boundaries for " + boost::lexical_cast<std::string>(num_created) +
" objects ");
}
@@ -599,4 +600,4 @@ struct intersection_validator {
}
};
#endif
#endif
+2 -2
View File
@@ -20,7 +20,7 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt
auto it = cache_.find(item);
if (it != cache_.end()) {
results = it->second;
Logger::Notice("SYS", 25, "Cache hit #" + std::to_string(item->instance->as<IfcUtil::IfcBaseEntity>()->id()) +
logger_.Notice("SYS", 25, "Cache hit #" + std::to_string(item->instance->as<IfcUtil::IfcBaseEntity>()->id()) +
" -> #" + std::to_string(it->first->instance->as<IfcUtil::IfcBaseEntity>()->id()));
return true;
}
@@ -30,7 +30,7 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt
try {
return fn();
} catch (std::exception& e) {
Logger::Error("GEO", 27, e, item->instance);
logger_.Error("GEO", 27, e, item->instance);
return false;
} catch (...) {
// @todo we can't log OCCT exceptions here, can we do some reraising to solve this?
+10 -7
View File
@@ -64,13 +64,15 @@ namespace ifcopenshell {
protected:
std::string geometry_library_;
Settings settings_;
Logger& logger_;
public:
bool propagate_exceptions = false;
bool partial_success_is_success = true;
AbstractKernel(const std::string& geometry_library, const Settings& settings)
AbstractKernel(const std::string& geometry_library, const Settings& settings, Logger& logger = Logger::Root())
: geometry_library_(geometry_library)
, settings_(settings) {}
, settings_(settings)
, logger_(logger) {}
virtual ~AbstractKernel() = default;
@@ -79,6 +81,7 @@ namespace ifcopenshell {
const std::string& geometry_library() const {
return geometry_library_;
}
Logger& logger() const { return logger_; }
virtual bool supports_boolean_operations() const = 0;
@@ -154,7 +157,7 @@ namespace {
if (item->instance) {
created_from = " (created from " + item->instance->declaration().name() + ")";
}
Logger::Error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
kernel->logger().Error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
return false;
}
};
@@ -178,7 +181,7 @@ namespace {
if (item->instance) {
created_from = " (created from " + item->instance->declaration().name() + ")";
}
Logger::Error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
kernel->logger().Error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
return false;
}
};
@@ -214,7 +217,7 @@ namespace {
template <typename T>
struct dispatch_curve_creation<T, ifcopenshell::geometry::taxonomy::curves::max> {
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
Logger::Error("GEO", 28, "No conversion for " + std::to_string(item->kind()));
Logger::Root().Error("GEO", 28, "No conversion for " + std::to_string(item->kind()));
return false;
}
};
@@ -236,10 +239,10 @@ namespace {
template <typename T>
struct dispatch_surface_creation<T, ifcopenshell::geometry::taxonomy::surfaces::max> {
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
Logger::Error("GEO", 29, "No conversion for " + std::to_string(item->kind()));
Logger::Root().Error("GEO", 29, "No conversion for " + std::to_string(item->kind()));
return false;
}
};
}
#endif
#endif
+2 -2
View File
@@ -3,11 +3,11 @@
#include <iomanip>
IfcGeom::Representation::Triangulation * IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings) const
IfcGeom::Representation::Triangulation* IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings, Logger& logger) const
{
auto t = IfcGeom::Representation::Triangulation::empty(settings);
static ifcopenshell::geometry::taxonomy::matrix4 iden;
Triangulate(settings, iden, t, -1, -1);
Triangulate(settings, iden, t, -1, -1, logger);
return t;
}
+2 -2
View File
@@ -253,8 +253,8 @@ namespace IfcGeom {
class IFC_GEOM_API ConversionResultShape {
public:
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id) const = 0;
IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const = 0;
IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const = 0;
virtual int surface_genus() const = 0;
+11 -10
View File
@@ -4,10 +4,11 @@
using namespace ifcopenshell::geometry;
ifcopenshell::geometry::Converter::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& s)
ifcopenshell::geometry::Converter::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& s, Logger& logger)
: kernel_(std::move(geometry_library))
, logger_(logger)
{
mapping_ = impl::mapping_implementations().construct(file, s);
mapping_ = impl::mapping_implementations().construct(file, s, logger_);
// Mapping reads unit information and applies to settings
settings_ = mapping_->settings();
}
@@ -17,7 +18,7 @@ ifcopenshell::geometry::Converter::~Converter() {
}
namespace {
void substitute_with_box_based_on_density(IfcGeom::ConversionResults& items, double& density) {
void substitute_with_box_based_on_density(Logger& logger, IfcGeom::ConversionResults& items, double& density) {
int nv = 0;
void* box = nullptr;
double volume = 0.;
@@ -29,7 +30,7 @@ namespace {
if (density > 1e5) {
items[0].Shape()->set_box(box);
items.erase(items.begin() + 1, items.end());
Logger::Notice("GEO", 30, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
logger.Notice("GEO", 30, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
}
}
}
@@ -138,7 +139,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
}
}
if (some_items_without_style) {
Logger::Warning("GEO", 31, "No material and surface styles for:", product);
logger_.Warning("GEO", 31, "No material and surface styles for:", product);
}
}
@@ -162,7 +163,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
parent_id = parent_object->id();
}
} catch (const std::exception& e) {
Logger::Error("GEO", 32, e);
logger_.Error("GEO", 32, e);
}
const std::string name = product->get_value<std::string>("Name", "");
@@ -208,10 +209,10 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
kernel_->convert_openings(product, opening_items, shapes, *place, opened_shapes);
}
} catch (const std::exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product);
caught_error = true;
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product);
}
if (!(caught_error && opened_shapes.size() < shapes.size())) {
@@ -239,7 +240,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
std::swap(shapes, unified_shapes);
}
} catch (std::exception& e) {
Logger::Error("GEO", 35, e);
logger_.Error("GEO", 35, e);
}
}
@@ -357,7 +358,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process
parent_id = parent_object->id();
}
} catch (const std::exception& e) {
Logger::Error("GEO", 36, e);
logger_.Error("GEO", 36, e);
}
const std::string guid = product->get_value<std::string>("GlobalId");
+4 -2
View File
@@ -21,15 +21,17 @@ namespace ifcopenshell { namespace geometry {
std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel> kernel_;
ifcopenshell::geometry::Settings settings_;
std::map<ifcopenshell::geometry::taxonomy::ptr, brep_ptr, ifcopenshell::geometry::taxonomy::less_functor> cache_;
Logger& logger_;
public:
ifcopenshell::geometry::kernels::AbstractKernel* kernel() { return &*kernel_; }
Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& settings);
Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root());
~Converter();
ifcopenshell::geometry::abstract_mapping* mapping() const { return mapping_; }
Logger& logger() const { return logger_; }
/*
virtual NativeElement<double, double>* convert(
@@ -55,4 +57,4 @@ namespace ifcopenshell { namespace geometry {
};
}}
#endif
#endif
+4 -3
View File
@@ -143,8 +143,9 @@ class GeometrySerializer : public Serializer {
public:
enum read_type { READ_BREP, READ_TRIANGULATION };
GeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings)
: geometry_settings_(geometry_settings)
GeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root())
: Serializer(logger)
, geometry_settings_(geometry_settings)
, settings_(settings)
{}
virtual ~GeometrySerializer() {}
@@ -177,7 +178,7 @@ protected:
class WriteOnlyGeometrySerializer : public GeometrySerializer {
public:
WriteOnlyGeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings) : GeometrySerializer(geometry_settings, settings) {}
WriteOnlyGeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) : GeometrySerializer(geometry_settings, settings, logger) {}
virtual IfcGeom::Element* read(IfcParse::IfcFile&, const std::string&, const std::string&, read_type = READ_BREP) {
throw std::runtime_error("Not supported");
+1 -1
View File
@@ -125,7 +125,7 @@ namespace IfcGeom {
oss << "product-" << IfcParse::IfcGlobalId(guid).formatted();
} catch (const std::exception& e) {
oss << "product";
Logger::Error("GEO", 39, e);
Logger::Root().Error("GEO", 39, e);
}
}
+27 -27
View File
@@ -31,7 +31,7 @@ bool IfcGeom::Iterator::initialize() {
try {
converter_->mapping()->get_representations(reps, filters_);
} catch (const std::exception& e) {
Logger::Error("GEO", 50, e);
logger_.Error("GEO", 50, e);
}
time_points[1] = high_resolution_clock::now();
@@ -94,7 +94,7 @@ bool IfcGeom::Iterator::initialize() {
tasks_.back().item = p.first;
tasks_.back().products = p.second;
}
Logger::Notice("SYS", 26, "Merged " + std::to_string(old_size) + " tasks into " + std::to_string(tasks_.size()) + " tasks due to permissive shape reuse");
logger_.Notice("SYS", 26, "Merged " + std::to_string(old_size) + " tasks into " + std::to_string(tasks_.size()) + " tasks due to permissive shape reuse");
}
}
@@ -139,10 +139,10 @@ bool IfcGeom::Iterator::initialize() {
}
*/
Logger::Notice("SYS", 27, "Created " + boost::lexical_cast<std::string>(tasks_.size()) + " tasks for " + boost::lexical_cast<std::string>(num_products) + " products");
logger_.Notice("SYS", 27, "Created " + boost::lexical_cast<std::string>(tasks_.size()) + " tasks for " + boost::lexical_cast<std::string>(num_products) + " products");
if (tasks_.size() == 0) {
Logger::Warning("GEO", 51, "No representations encountered, aborting");
logger_.Warning("GEO", 51, "No representations encountered, aborting");
initialization_outcome_.reset(false);
} else if (!settings_.get<ifcopenshell::geometry::settings::DeferProcessingFirstElement>().get()) {
@@ -194,7 +194,7 @@ void IfcGeom::Iterator::process_concurrently() {
kernel_pool.reserve(conc_threads);
for (unsigned i = 0; i < conc_threads; ++i) {
kernel_pool.push_back(new ifcopenshell::geometry::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>(converter_->kernel()->clone()), ifc_file, settings_));
kernel_pool.push_back(new ifcopenshell::geometry::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>(converter_->kernel()->clone()), ifc_file, settings_, logger_));
}
std::vector<std::future<geometry_conversion_result*>> threadpool;
@@ -231,14 +231,14 @@ void IfcGeom::Iterator::process_concurrently() {
try {
this->create_element_(kernel, settings, rep);
} catch (const std::exception& e) {
Logger::Error("GEO", 52,
logger_.Error("GEO", 52,
std::string("Exception '") + e.what() +
std::string("' occurred while iterator was creating a shape: "),
rep->item->instance
);
had_error_processing_elements_ = true;
} catch (...) {
Logger::Error("GEO", 53,
logger_.Error("GEO", 53,
"Unknown exception occurred while iteartor was creating a shape: ",
rep->item->instance
);
@@ -263,10 +263,10 @@ void IfcGeom::Iterator::process_concurrently() {
finished_ = true;
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
if (!terminating_) {
Logger::Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(all_processed_elements_.size()) +
logger_.Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(all_processed_elements_.size()) +
" objects) ");
}
}
@@ -360,20 +360,20 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne
const IfcUtil::IfcBaseEntity* product = product_node.first;
const auto& place = product_node.second;
Logger::SetProduct(product);
logger_.SetProduct(product);
IfcGeom::BRepElement* brep = static_cast<IfcGeom::BRepElement*>(decorate_with_cache_(GeometrySerializer::READ_BREP, (std::string)product->get("GlobalId"), std::to_string(rep->item->instance->as<IfcUtil::IfcBaseEntity>()->id()), [kernel, settings, product, place, rep]() {
return kernel->create_brep_for_representation_and_product(rep->item, product, place);
}));
if (!brep) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
return;
}
auto elem = process_based_on_settings(settings, brep);
if (!elem) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
return;
}
@@ -397,7 +397,7 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne
}
}
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
}
IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geometry::Settings settings, IfcGeom::BRepElement* elem, IfcGeom::TriangulationElement* previous)
@@ -406,7 +406,7 @@ IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geo
try {
return new IfcGeom::SerializedElement(*elem);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed.");
logger_.Message(Logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed.");
return nullptr;
}
} else if (settings.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::TRIANGULATED) {
@@ -417,7 +417,7 @@ IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geo
gid2 = gid2.substr(0, hyphen);
}
return decorate_with_cache_(GeometrySerializer::READ_TRIANGULATION, elem->guid(), gid2, [elem, previous]() {
return decorate_with_cache_(GeometrySerializer::READ_TRIANGULATION, elem->guid(), gid2, [this, elem, previous]() {
try {
if (!previous) {
return new TriangulationElement(*elem);
@@ -425,7 +425,7 @@ IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geo
return new TriangulationElement(*elem, previous->geometry_pointer());
}
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed.");
logger_.Message(Logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed.");
}
return (TriangulationElement*)nullptr;
});
@@ -466,7 +466,7 @@ void IfcGeom::Iterator::log_timepoints() const {
for (auto it = time_points.begin() + 1; it != time_points.end(); ++it) {
auto jt = it - 1;
duration<double, std::milli> ms_double = (*it) - (*jt);
Logger::Notice("SYS", 28, labels[std::distance(time_points.begin(), jt)] + " took " + std::to_string(ms_double.count()) + "ms");
logger_.Notice("SYS", 28, labels[std::distance(time_points.begin(), jt)] + " took " + std::to_string(ms_double.count()) + "ms");
}
}
@@ -501,7 +501,7 @@ const IfcUtil::IfcBaseClass* IfcGeom::Iterator::next() {
if (num_threads_ != 1) {
if (!wait_for_element()) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
time_points[3] = high_resolution_clock::now();
log_timepoints();
task_result_ptr_exhausted = true;
@@ -517,7 +517,7 @@ const IfcUtil::IfcBaseClass* IfcGeom::Iterator::next() {
// shape representation
if (task_result_iterator_ == --all_processed_elements_.end()) {
if (!create()) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
time_points[3] = high_resolution_clock::now();
log_timepoints();
task_result_ptr_exhausted = true;
@@ -554,7 +554,7 @@ IfcGeom::Element* IfcGeom::Iterator::get()
try {
parent_object = get_object(ret->parent_id());
} catch (const std::exception& e) {
Logger::Error("GEO", 56, e);
logger_.Error("GEO", 56, e);
hasParent = false;
}
@@ -572,7 +572,7 @@ IfcGeom::Element* IfcGeom::Iterator::get()
try {
parent_object = get_object(pid);
} catch (const std::exception& e) {
Logger::Error("GEO", 57, e);
logger_.Error("GEO", 57, e);
hasParent = false;
}
}
@@ -619,9 +619,9 @@ const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) {
m4 = casted->matrix;
}
} catch (const std::exception& e) {
Logger::Error("GEO", 58, e);
logger_.Error("GEO", 58, e);
} catch (...) {
Logger::Error("GEO", 59, "Unknown error returning product");
logger_.Error("GEO", 59, "Unknown error returning product");
}
Element* ifc_object = new Element(settings_, id, parent_id, product_name, instance_type, product_guid, "", m4, ifc_product);
@@ -633,10 +633,10 @@ const IfcUtil::IfcBaseClass* IfcGeom::Iterator::create() {
try {
product = create_shape_model_for_next_entity();
} catch (const std::exception& e) {
Logger::Error("GEO", 60, e);
logger_.Error("GEO", 60, e);
had_error_processing_elements_ = true;
} catch (...) {
Logger::Error("GEO", 61, "Unknown error creating geometry");
logger_.Error("GEO", 61, "Unknown error creating geometry");
had_error_processing_elements_ = true;
}
return product;
@@ -808,8 +808,8 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs
}
}
Logger::Notice("SYS", 29, "Removed large offsets within " + std::to_string(num_offset_applied) + " products");
Logger::Notice("SYS", 30, "Offset applied (" + std::to_string(vec(0)) + "," + std::to_string(vec(1)) + "," + std::to_string(vec(2)) + ")");
logger_.Notice("SYS", 29, "Removed large offsets within " + std::to_string(num_offset_applied) + " products");
logger_.Notice("SYS", 30, "Offset applied (" + std::to_string(vec(0)) + "," + std::to_string(vec(1)) + "," + std::to_string(vec(2)) + ")");
return make<direction3>(vec);
}
+11 -7
View File
@@ -126,6 +126,7 @@ namespace IfcGeom {
std::vector<filter_t> filters_;
int num_threads_;
std::string geometry_library_;
Logger& logger_;
// When single-threaded
ifcopenshell::geometry::Converter* converter_;
@@ -209,32 +210,35 @@ namespace IfcGeom {
ifcopenshell::geometry::taxonomy::direction3::ptr remove_offset_();
public:
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads)
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads, Logger& logger = Logger::Root())
: settings_(settings)
, ifc_file(file)
, filters_(filters)
, num_threads_(num_threads)
, geometry_library_(geometry_library->geometry_library())
, logger_(logger)
// @todo verify whether settings are correctly passed on
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_))
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_))
{
}
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file)
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, Logger& logger = Logger::Root())
: settings_(settings)
, ifc_file(file)
, num_threads_(1)
, geometry_library_(geometry_library->geometry_library())
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_))
, logger_(logger)
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_))
{
}
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, int num_threads)
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, int num_threads, Logger& logger = Logger::Root())
: settings_(settings)
, ifc_file(file)
, num_threads_(num_threads)
, geometry_library_(geometry_library->geometry_library())
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_))
, logger_(logger)
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_))
{
}
@@ -301,7 +305,7 @@ namespace IfcGeom {
return progress_;
}
std::string getLog() const { return Logger::GetLog(); }
std::string getLog() const { return logger_.GetLog(); }
IfcParse::IfcFile* file() const { return ifc_file; }
+8 -1
View File
@@ -21,15 +21,22 @@
#define SERIALIZER_H
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcLogger.h"
class Serializer {
protected:
Logger& logger_;
public:
explicit Serializer(Logger& logger = Logger::Root()) : logger_(logger) {}
virtual ~Serializer() {}
Logger& logger() const { return logger_; }
virtual bool ready() = 0;
virtual void writeHeader() = 0;
virtual void finalize() = 0;
virtual void setFile(IfcParse::IfcFile*) = 0;
};
#endif
#endif
+2 -2
View File
@@ -37,14 +37,14 @@ void ifcopenshell::geometry::impl::MappingFactoryImplementation::bind(const std:
this->insert(std::make_pair(schema_name_lower, fn));
}
ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(IfcParse::IfcFile* file, Settings& s) {
ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(IfcParse::IfcFile* file, Settings& s, Logger& logger) {
const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name());
std::map<std::string, ifcopenshell::geometry::impl::mapping_fn>::const_iterator it;
it = this->find(schema_name_lower);
if (it == end()) {
throw IfcParse::IfcException("No geometry mapping registered for " + schema_name_lower);
}
auto new_mapping = it->second(file, s);
auto new_mapping = it->second(file, s, logger);
new_mapping->initialize_settings();
return new_mapping;
}
+7 -4
View File
@@ -21,6 +21,7 @@
#define ABSTRACT_MAPPING_H
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/IfcLogger.h"
#include "../ifcparse/aggregate_of_instance.h"
#include "../ifcgeom/taxonomy.h"
#include "../ifcgeom/ConversionSettings.h"
@@ -43,14 +44,15 @@ namespace geometry {
typedef boost::function<bool(IfcUtil::IfcBaseEntity*)> filter_t;
class IFC_GEOM_API abstract_mapping {
class IFC_GEOM_API abstract_mapping {
protected:
Settings settings_;
Logger& logger_;
bool use_caching_ = true;
public:
abstract_mapping(Settings& s) : settings_(s) {}
abstract_mapping(Settings& s, Logger& logger = Logger::Root()) : settings_(s), logger_(logger) {}
virtual ~abstract_mapping() {}
virtual ifcopenshell::geometry::taxonomy::ptr map(const IfcUtil::IfcBaseInterface*) = 0;
@@ -69,19 +71,20 @@ namespace geometry {
const Settings& settings() const { return settings_; }
Settings& settings() { return settings_; }
Logger& logger() const { return logger_; }
bool use_caching() const { return use_caching_; }
bool& use_caching() { return use_caching_; }
};
namespace impl {
typedef boost::function2<abstract_mapping*, IfcParse::IfcFile*, Settings&> mapping_fn;
typedef boost::function3<abstract_mapping*, IfcParse::IfcFile*, Settings&, Logger&> mapping_fn;
class IFC_GEOM_API MappingFactoryImplementation : public std::map<std::string, mapping_fn> {
public:
MappingFactoryImplementation();
void bind(const std::string& schema_name, mapping_fn);
abstract_mapping* construct(IfcParse::IfcFile*, Settings&);
abstract_mapping* construct(IfcParse::IfcFile*, Settings&, Logger& logger = Logger::Root());
};
IFC_GEOM_API MappingFactoryImplementation& mapping_implementations();
+4 -4
View File
@@ -76,7 +76,7 @@ struct piecewise_fn_evaluator : public fn_evaluator {
span_start += fn->length();
}
Logger::Error("GEO", 37, "piecewise span not found.");
logger_.Error("GEO", 37, "piecewise span not found.");
return {0, 0, nullptr};
}
@@ -208,7 +208,7 @@ struct offset_fn_evaluator : public fn_evaluator {
function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn) {
function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn, Logger& logger) : logger_(logger) {
auto kind = fn->kind();
if (kind == taxonomy::FUNCTOR_ITEM) {
fn_evaluator_ = new functor_fn_evaluator(std::dynamic_pointer_cast<const taxonomy::functor_item>(fn),settings);
@@ -221,11 +221,11 @@ function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::S
} else if (kind == taxonomy::OFFSET_FUNCTION) {
fn_evaluator_ = new offset_fn_evaluator(std::dynamic_pointer_cast<const taxonomy::offset_function>(fn), settings);
} else {
Logger::Error("GEO", 38, "Unexpected function type");
logger_.Error("GEO", 38, "Unexpected function type");
}
}
function_item_evaluator::function_item_evaluator(const function_item_evaluator& other) {
function_item_evaluator::function_item_evaluator(const function_item_evaluator& other) : logger_(other.logger_) {
fn_evaluator_ = other.fn_evaluator_->clone();
eval_points_ = other.eval_points_;
}
+6 -2
View File
@@ -23,7 +23,7 @@ static taxonomy::function_item::ptr convert_loop_to_function_item(taxonomy::loop
/// @brief Abstract class for evaluating a function_item. This class is specialized for each of the function_item types.
struct IFC_GEOM_API fn_evaluator {
fn_evaluator(const ifcopenshell::geometry::Settings& settings) : settings_(settings) {
fn_evaluator(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) : settings_(settings), logger_(logger) {
}
fn_evaluator(const fn_evaluator& other) = default;
virtual ~fn_evaluator() = default;
@@ -36,12 +36,15 @@ struct IFC_GEOM_API fn_evaluator {
double length() const { return end() - start(); }
ifcopenshell::geometry::Settings settings_;
protected:
Logger& logger_;
};
/// @brief utility class to evaluate function_item objects.
class IFC_GEOM_API function_item_evaluator {
public:
function_item_evaluator(const ifcopenshell::geometry::Settings& settings, taxonomy::function_item::const_ptr fn);
function_item_evaluator(const ifcopenshell::geometry::Settings& settings, taxonomy::function_item::const_ptr fn, Logger& logger = Logger::Root());
function_item_evaluator(const function_item_evaluator& other);
~function_item_evaluator();
@@ -77,6 +80,7 @@ class IFC_GEOM_API function_item_evaluator {
fn_evaluator* fn_evaluator_ = nullptr;
mutable boost::optional<std::vector<double>> eval_points_; // cache evaluation points
Logger& logger_;
};
}}
+13 -13
View File
@@ -64,10 +64,10 @@ namespace ifcopenshell {
ifcopenshell::geometry::abstract_mapping* mapping_;
IfcParse::IfcFile* file_;
public:
HybridKernel(const std::string& name, IfcParse::IfcFile* file, Settings& settings, std::vector<std::unique_ptr<AbstractKernel>>&& kernels)
: AbstractKernel(name, settings)
HybridKernel(const std::string& name, IfcParse::IfcFile* file, Settings& settings, std::vector<std::unique_ptr<AbstractKernel>>&& kernels, Logger& logger = Logger::Root())
: AbstractKernel(name, settings, logger)
, kernels_(std::move(kernels))
, mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings))
, mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings, logger))
, file_(file)
{
}
@@ -163,26 +163,26 @@ namespace ifcopenshell {
ks.emplace_back(k->clone());
}
// @todo ugly
return new HybridKernel(geometry_library(), file_, const_cast<Settings&>(settings()), std::move(ks));
return new HybridKernel(geometry_library(), file_, const_cast<Settings&>(settings()), std::move(ks), logger());
}
};
inline std::unique_ptr<AbstractKernel> construct(IfcParse::IfcFile* file, const std::string& geometry_library, Settings& conv_settings) {
inline std::unique_ptr<AbstractKernel> construct(IfcParse::IfcFile* file, const std::string& geometry_library, Settings& conv_settings, Logger& logger = Logger::Root()) {
std::string geometry_library_lower = boost::to_lower_copy(geometry_library);
#ifdef IFOPSH_WITH_OPENCASCADE
if (geometry_library_lower == "opencascade") {
return std::make_unique<IfcGeom::OpenCascadeKernel>(conv_settings);
return std::make_unique<IfcGeom::OpenCascadeKernel>(conv_settings, logger);
}
#endif
#ifdef IFOPSH_WITH_CGAL
if (geometry_library_lower == "cgal") {
return std::make_unique<CgalKernel>(conv_settings);
return std::make_unique<CgalKernel>(conv_settings, logger);
}
if (geometry_library_lower == "cgal-simple") {
return std::make_unique<SimpleCgalKernel>(conv_settings);
return std::make_unique<SimpleCgalKernel>(conv_settings, logger);
}
#endif
@@ -198,19 +198,19 @@ namespace ifcopenshell {
auto n = kernels.size();
#ifdef IFOPSH_WITH_OPENCASCADE
if (geometry_library_lower.find("opencascade", 0) == 0) {
kernels.emplace_back(new IfcGeom::OpenCascadeKernel(conv_settings));
kernels.emplace_back(new IfcGeom::OpenCascadeKernel(conv_settings, logger));
geometry_library_lower = geometry_library_lower.substr(strlen("opencascade"));
}
#endif
#ifdef IFOPSH_WITH_CGAL
if (geometry_library_lower.find("cgal-simple", 0) == 0) {
kernels.emplace_back(new SimpleCgalKernel(conv_settings));
kernels.emplace_back(new SimpleCgalKernel(conv_settings, logger));
geometry_library_lower = geometry_library_lower.substr(strlen("cgal-simple"));
}
if (geometry_library_lower.find("cgal", 0) == 0) {
kernels.emplace_back(new CgalKernel(conv_settings));
kernels.emplace_back(new CgalKernel(conv_settings, logger));
geometry_library_lower = geometry_library_lower.substr(strlen("cgal"));
}
#endif
@@ -225,7 +225,7 @@ namespace ifcopenshell {
}
if (!kernels.empty()) {
return std::make_unique<HybridKernel>(geometry_library, file, conv_settings, std::move(kernels));
return std::make_unique<HybridKernel>(geometry_library, file, conv_settings, std::move(kernels), logger);
}
}
@@ -236,4 +236,4 @@ namespace ifcopenshell {
}
}
#endif
#endif
+11 -11
View File
@@ -35,7 +35,7 @@ bool has_intersection(const std::set<T, Cmp>& A,
}
taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& fn, std::vector<cross_section>& cross_sections)
taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& fn, std::vector<cross_section>& cross_sections, Logger& logger)
{
std::sort(cross_sections.begin(), cross_sections.end());
@@ -51,7 +51,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
double end = std::min(fn->length(), cross_sections.back().dist_along);
if (end - start < 1.e-9) {
Logger::Warning("GEO", 40, "Empty sweep domain with start at " + std::to_string(cross_sections.front().dist_along) + " end at " + std::to_string(cross_sections.back().dist_along) + " and curve domain length " + std::to_string(fn->length()), inst);
Logger::Root().Warning("GEO", 40, "Empty sweep domain with start at " + std::to_string(cross_sections.front().dist_along) + " end at " + std::to_string(cross_sections.back().dist_along) + " and curve domain length " + std::to_string(fn->length()), inst);
return nullptr;
}
@@ -130,7 +130,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
auto profile_b_f = std::static_pointer_cast<taxonomy::face>(profile_b);
if (profile_a_f->children.size() != profile_b_f->children.size()) {
Logger::Warning("GEO", 41, "Mismatching number of face boundaries: " +
Logger::Root().Warning("GEO", 41, "Mismatching number of face boundaries: " +
std::to_string(profile_a_f->children.size()) + " vs " +
std::to_string(profile_b_f->children.size()),
inst
@@ -165,7 +165,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
// in which case we would need to lerp with the rotation component below in m4b.
interpolated_rotation = lerp(*rotation_a, *rotation_b, relative_dist_along);
} else if (rotation_a != rotation_b) {
Logger::Error("GEO", 42, "Direction vectors on cross section placements only supported when used consistently");
logger.Error("GEO", 42, "Direction vectors on cross section placements only supported when used consistently");
}
taxonomy::loop::ptr w1, w2;
@@ -176,12 +176,12 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
boost::tie(w1, w2) = tmp_;
if (w1->closed != w2->closed) {
Logger::Warning("GEO", 43, "Mismatching closed property on loops", inst);
logger.Warning("GEO", 43, "Mismatching closed property on loops", inst);
return nullptr;
}
if (w1->tags.is_initialized() != w2->tags.is_initialized()) {
Logger::Warning("GEO", 44, "Mismatching availability tags on loops", inst);
logger.Warning("GEO", 44, "Mismatching availability tags on loops", inst);
return nullptr;
}
@@ -190,7 +190,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
std::set<std::string> tags_seen;
for (const auto& t : *w1->tags) {
if (tags_seen.find(t) != tags_seen.end()) {
Logger::Warning("GEO", 45, "Duplicate tag '" + t + "' on loft profile", inst);
logger.Warning("GEO", 45, "Duplicate tag '" + t + "' on loft profile", inst);
return nullptr;
}
tags_seen.insert(t);
@@ -202,7 +202,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
std::set<std::string> tags_seen;
for (const auto& t : *w2->tags) {
if (tags_seen.find(t) != tags_seen.end()) {
Logger::Warning("GEO", 46, "Duplicate tag '" + t + "' on loft profile", inst);
logger.Warning("GEO", 46, "Duplicate tag '" + t + "' on loft profile", inst);
return nullptr;
}
tags_seen.insert(t);
@@ -303,20 +303,20 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
for (auto& p1_tags : w1_tags) {
if (!has_intersection(p1_tags, w2_tags_combined)) {
Logger::Warning("GEO", 47, "No matching tags found on loft profiles: " + join_tags(p1_tags) + " not in " + join_tags(w2_tags_combined), inst);
logger.Warning("GEO", 47, "No matching tags found on loft profiles: " + join_tags(p1_tags) + " not in " + join_tags(w2_tags_combined), inst);
return nullptr;
}
}
for (auto& p2_tags : w2_tags) {
if (!has_intersection(p2_tags, w1_tags_combined)) {
Logger::Warning("GEO", 48, "No matching tags found on loft profiles: " + join_tags(p2_tags) + " not in " + join_tags(w1_tags_combined), inst);
logger.Warning("GEO", 48, "No matching tags found on loft profiles: " + join_tags(p2_tags) + " not in " + join_tags(w1_tags_combined), inst);
return nullptr;
}
}
} else {
if (w1->children.size() != w2->children.size()) {
Logger::Warning("GEO", 49, "Mismatching number of edges: " +
logger.Warning("GEO", 49, "Mismatching number of edges: " +
std::to_string(w1->children.size()) + " vs " +
std::to_string(w2->children.size()),
inst);
+1 -1
View File
@@ -21,7 +21,7 @@ namespace ifcopenshell {
}
};
IFC_GEOM_API taxonomy::loft::ptr make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& directrix, std::vector<cross_section>& cross_sections);
IFC_GEOM_API taxonomy::loft::ptr make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& directrix, std::vector<cross_section>& cross_sections, Logger& logger = Logger::Root());
}
}
@@ -99,7 +99,7 @@ namespace {
}
}
ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool convex) {
ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool convex, Logger& logger) {
shape_ = shape;
convex_tag_ = convex;
@@ -112,7 +112,7 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con
auto b2 = plane.base2();
if (V.squared_length() == 0) {
Logger::Warning("GEO", 62, "Removed face due to self-intersections");
logger.Warning("GEO", 62, "Removed face due to self-intersections");
faces_to_remove.insert(face);
continue;
}
@@ -133,7 +133,7 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con
}
if (!CGAL::Polygon_2<Kernel_>(ps.begin(), ps.end()).is_simple()) {
Logger::Warning("GEO", 63, "Removed face due to self-intersections");
logger.Warning("GEO", 63, "Removed face due to self-intersections");
faces_to_remove.insert(face);
}
}
@@ -184,7 +184,7 @@ void ifcopenshell::geometry::CgalShape::to_nef() const {
}
#endif
void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const {
void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const {
const bool all_triangles = std::all_of(shape_->facets_begin(), shape_->facets_end(), [](auto f) { return f.is_triangle(); });
const bool has_iden_transform = place.is_identity();
@@ -233,7 +233,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
if (!all_triangles) {
if (!shape_to_use->is_valid()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)");
logger.Message(Logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)");
return;
}
@@ -241,19 +241,19 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
try {
success = CGAL::Polygon_mesh_processing::triangulate_faces(*shape_to_use);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 65, "Triangulation crashed");
logger.Message(Logger::LOG_ERROR, "GEO", 65, "Triangulation crashed");
return;
}
CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_to_use);
if (!success) {
Logger::Message(Logger::LOG_ERROR, "GEO", 66, "Triangulation failed");
logger.Message(Logger::LOG_ERROR, "GEO", 66, "Triangulation failed");
return;
}
if (!shape_to_use->is_valid()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)");
logger.Message(Logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)");
return;
}
}
@@ -282,7 +282,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
try {
CGAL::Polygon_mesh_processing::compute_face_normals(*shape_to_use, face_normals_map);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed");
logger.Message(Logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed");
return;
}
@@ -791,7 +791,7 @@ bool ifcopenshell::geometry::CgalShape::surface_area_along_direction(double tol,
#ifndef IFOPSH_SIMPLE_KERNEL
void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const {
void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const {
throw std::runtime_error("Not implemented");
}
@@ -185,7 +185,7 @@ namespace ifcopenshell { namespace geometry {
mutable boost::optional<CGAL::Nef_polyhedron_3<Kernel_>> nef_;
#endif
public:
CgalShape(const cgal_shape_t& shape, bool convex = false);
CgalShape(const cgal_shape_t& shape, bool convex = false, Logger& logger = Logger::Root());
#ifndef IFOPSH_SIMPLE_KERNEL
CgalShape(const CGAL::Nef_polyhedron_3<Kernel_>& shape, bool convex = false) {
@@ -209,7 +209,7 @@ namespace ifcopenshell { namespace geometry {
operator const cgal_shape_t& () const { to_poly(); return *shape_; }
const cgal_shape_t& poly() const { to_poly(); return *shape_; }
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
virtual IfcGeom::ConversionResultShape* clone() const {
@@ -285,7 +285,7 @@ namespace ifcopenshell { namespace geometry {
planes_.push_back(shape);
}
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const;
+50 -50
View File
@@ -46,18 +46,19 @@ namespace {
struct PolyhedronBuilder : public CGAL::Modifier_base<CGAL::Polyhedron_3<Kernel_>::HalfedgeDS> {
private:
std::list<cgal_face_t> *face_list;
Logger& logger_;
public:
boost::optional<cgal_shape_t> from_soup;
PolyhedronBuilder(std::list<cgal_face_t> *face_list);
PolyhedronBuilder(std::list<cgal_face_t> *face_list, Logger& logger = Logger::Root());
void operator()(CGAL::Polyhedron_3<Kernel_>::HalfedgeDS &hds);
};
}
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders) {
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders, Logger& logger) {
// Naive creation
CGAL::Polyhedron_3<Kernel_> polyhedron;
PolyhedronBuilder builder(&face_list);
PolyhedronBuilder builder(&face_list, logger);
polyhedron.delegate(builder);
if (builder.from_soup) {
polyhedron = *builder.from_soup;
@@ -76,7 +77,7 @@ CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std
polyhedron.normalize_border();
if (!polyhedron.is_valid(false, 1)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!");
logger.Message(Logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!");
// std::ofstream fresult;
// fresult.open("/Users/ken/Desktop/invalid.off");
// fresult << polyhedron << std::endl;
@@ -90,31 +91,31 @@ CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std
}
#ifndef IFOPSH_SIMPLE_KERNEL
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_>& nef_polyhedron) {
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_>& nef_polyhedron, Logger& logger) {
if (nef_polyhedron.is_simple()) {
try {
CGAL::Polyhedron_3<Kernel_> polyhedron;
nef_polyhedron.convert_to_polyhedron(polyhedron);
return polyhedron;
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!");
logger.Message(Logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!");
return CGAL::Polyhedron_3<Kernel_>();
}
} else {
Logger::Message(Logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!");
logger.Message(Logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!");
return CGAL::Polyhedron_3<Kernel_>();
}
}
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(std::list<cgal_face_t> &face_list) {
CGAL::Polyhedron_3<Kernel_> polyhedron = create_polyhedron(face_list);
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(std::list<cgal_face_t> &face_list, Logger& logger) {
CGAL::Polyhedron_3<Kernel_> polyhedron = create_polyhedron(face_list, true, logger);
if (polyhedron.is_closed()) {
try {
if (!CGAL::Polygon_mesh_processing::is_outward_oriented(polyhedron)) {
CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron);
}
} catch (CGAL::Failure_exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 72, e);
logger.Message(Logger::LOG_ERROR, "GEO", 72, e);
}
}
CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron);
@@ -122,12 +123,12 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
try {
nef_polyhedron = CGAL::Nef_polyhedron_3<Kernel_>(polyhedron);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!");
logger.Message(Logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!");
}
return nef_polyhedron;
}
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron) {
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron, Logger& logger) {
// @todo needed?
polyhedron.normalize_border();
@@ -137,7 +138,7 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron);
}
} catch (CGAL::Failure_exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 74, e);
logger.Message(Logger::LOG_ERROR, "GEO", 74, e);
}
}
@@ -148,11 +149,11 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
try {
nef_polyhedron = CGAL::Nef_polyhedron_3<Kernel_>(polyhedron);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!");
logger.Message(Logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!");
}
return nef_polyhedron;
} else {
Logger::Message(Logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!");
logger.Message(Logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!");
return CGAL::Nef_polyhedron_3<Kernel_>();
}
}
@@ -161,13 +162,13 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
for (auto& f : l->children) {
if (f->basis && f->basis->kind() != taxonomy::PLANE) {
Logger::Error("UNS", 3, "CGAL Kernel: Non-planar faces not supported at the moment");
logger_.Error("UNS", 3, "CGAL Kernel: Non-planar faces not supported at the moment");
throw not_supported_error();
}
for (auto& w : f->children) {
for (auto& e : w->children) {
if (e->basis && e->basis->kind() == taxonomy::BSPLINE_CURVE) {
Logger::Error("UNS", 4, "CGAL Kernel: B-spline edge curves not supported at the moment");
logger_.Error("UNS", 4, "CGAL Kernel: B-spline edge curves not supported at the moment");
throw not_supported_error();
}
}
@@ -196,9 +197,9 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
double volume = diag(0) * diag(1) * diag(2);
// @todo volume van be zero also..
double density = num_points / volume;
Logger::Notice("GEO", 77, "Density " + boost::lexical_cast<std::string>(density), l->instance);
logger_.Notice("GEO", 77, "Density " + boost::lexical_cast<std::string>(density), l->instance);
if (density > 5000) {
Logger::Notice("GEO", 78, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
logger_.Notice("GEO", 78, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
CGAL::Point_3<Kernel_> lower(minmax.first(0), minmax.first(1), minmax.first(2));
CGAL::Point_3<Kernel_> upper(minmax.second(0), minmax.second(1), minmax.second(2));
shape = utils::create_cube(lower, upper);
@@ -214,7 +215,7 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
} catch (...) {}
if (!success) {
Logger::Message(Logger::LOG_WARNING, "GEO", 79, "Failed to convert face:", f->instance);
logger_.Message(Logger::LOG_WARNING, "GEO", 79, "Failed to convert face:", f->instance);
continue;
}
@@ -236,7 +237,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
}
if (face->children.size() > 1 && num_outer_bounds > 1 && face->children.size() != num_outer_bounds) {
Logger::Message(Logger::LOG_ERROR, "GEO", 80, "Invalid configuration of boundaries for:", face->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 80, "Invalid configuration of boundaries for:", face->instance);
return false;
}
@@ -249,7 +250,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
cgal_wire_t wire;
if (!convert(bound, wire)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance);
return false;
}
@@ -703,7 +704,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
if (d < 1.e-5) {
points.erase(points.end() - 1);
} else {
Logger::Warning("GEO", 82, "Loop not closed", loop->instance);
logger_.Warning("GEO", 82, "Loop not closed", loop->instance);
}
}
@@ -717,7 +718,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
// A loop should consist of at least three vertices
std::size_t original_count = polygon.size();
if (original_count < 3) {
Logger::Warning("GEO", 83, "Not enough edges for:", loop->instance);
logger_.Warning("GEO", 83, "Not enough edges for:", loop->instance);
return false;
}
@@ -728,14 +729,14 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
std::size_t count = polygon.size();
if (original_count - count != 0) {
std::stringstream ss; ss << (original_count - count) << " edges removed for:";
Logger::Warning("GEO", 84, ss.str(), loop->instance);
logger_.Warning("GEO", 84, ss.str(), loop->instance);
}
{
std::set<cgal_point_t> visited_points;
for (auto& p : polygon) {
if (visited_points.find(p) != visited_points.end()) {
Logger::Error("GEO", 85, "Skipping self-intersecting loop", loop->instance);
logger_.Error("GEO", 85, "Skipping self-intersecting loop", loop->instance);
// @todo signal somehow that occt kernel might be able to solve this
// @todo implement cycle detection using Arrangement_2, but that only works in exact kernel
return false;
@@ -757,7 +758,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
}
if (do_segments_intersect(segments)) {
Logger::Message(Logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance);
logger_.Message(Logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance);
return false;
}
@@ -785,7 +786,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
*/
if (count < 3) {
Logger::Message(Logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance);
return false;
}
@@ -819,7 +820,7 @@ bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResult
bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResults& results) {
if (solid->children.size() > 1) {
Logger::Error("UNS", 5, "Multiple shells in solid not supported at the moment");
logger_.Error("UNS", 5, "Multiple shells in solid not supported at the moment");
return false;
}
cgal_shape_t shape;
@@ -964,7 +965,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
try {
a.convert_to_polyhedron(a_poly);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity);
logger_.Message(Logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity);
return false;
}
@@ -1189,7 +1190,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir
bool CgalKernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) {
const double& height = extrusion->depth;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
return false;
}
@@ -1325,13 +1326,13 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
cgal_shape_t shape = shape_const;
if (!shape.is_valid()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference);
logger_.Message(Logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference);
return false;
}
if (!shape.is_closed()) {
// TODO: There can be substractions to remove parts of non-volumetric objects. Maybe iterate over all faces of an entity and put them in a Nef_polyhedron_3 through Boolean union? Highly inefficient but maybe desirable...
Logger::Message(Logger::LOG_ERROR, "UNS", 6, "Subtraction of openings not supported for non-closed geometry:", log_reference);
logger_.Message(Logger::LOG_ERROR, "UNS", 6, "Subtraction of openings not supported for non-closed geometry:", log_reference);
return false;
}
@@ -1340,18 +1341,18 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
try {
success = CGAL::Polygon_mesh_processing::triangulate_faces(shape);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 91, e);
Logger::Message(Logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference);
logger_.Notice("GEO", 91, e);
logger_.Message(Logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference);
return false;
}
if (!success) {
Logger::Message(Logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference);
logger_.Message(Logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference);
return false;
}
if (CGAL::Polygon_mesh_processing::does_self_intersect(shape)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 94, "Conversion to Nef will fail. Self-intersecting geometry:", log_reference);
logger_.Message(Logger::LOG_ERROR, "GEO", 94, "Conversion to Nef will fail. Self-intersecting geometry:", log_reference);
return false;
}
@@ -1423,8 +1424,8 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
try {
result = CGAL::Nef_polyhedron_3<Kernel_>(shape);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 95, e);
Logger::Message(Logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference);
logger_.Notice("GEO", 95, e);
logger_.Message(Logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference);
return false;
}
@@ -1496,8 +1497,8 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
// @todo don't dilate in 3 dimensions but only in the XY plane, orthogonal to wall axis.
result = CGAL::minkowski_sum_3(result, precision_cube_);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 97, e);
Logger::Message(Logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference);
logger_.Notice("GEO", 97, e);
logger_.Message(Logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference);
return false;
}
}
@@ -1522,8 +1523,8 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
cgal_shape_t convert_back;
result.convert_to_polyhedron(convert_back);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 99, e);
Logger::Message(Logger::LOG_WARNING, "GEO", 100, "Final conversion will likely fail. Could not convert geometry from Nef:", log_reference);
logger_.Notice("GEO", 99, e);
logger_.Message(Logger::LOG_WARNING, "GEO", 100, "Final conversion will likely fail. Could not convert geometry from Nef:", log_reference);
}
return true;
@@ -1845,7 +1846,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
// even-odd fill rule will result in incorrect results.
// See for example the Duplex model roof.
Logger::Notice("GEO", 101, "Holes are not disjoint");
logger_.Notice("GEO", 101, "Holes are not disjoint");
CGAL::Polygon_set_2<Kernel_> result;
auto it = loops.begin();
@@ -1898,7 +1899,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
);
});
Logger::Notice("GEO", 102, "Processed boolean operation as 2d arrangement");
logger_.Notice("GEO", 102, "Processed boolean operation as 2d arrangement");
return true;
@@ -1984,7 +1985,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
ps.push_back({ p.x(), p.y() });
}
if (!ps.is_simple()) {
Logger::Warning("GEO", 103, "Polygonal boundary not simple", face->children[0]->instance);
logger_.Warning("GEO", 103, "Polygonal boundary not simple", face->children[0]->instance);
continue;
}
@@ -2130,7 +2131,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
try {
a.convert_to_polyhedron(a_poly);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance);
return false;
}
@@ -2145,8 +2146,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
#endif
}
PolyhedronBuilder::PolyhedronBuilder(std::list<cgal_face_t>* face_list) {
this->face_list = face_list;
PolyhedronBuilder::PolyhedronBuilder(std::list<cgal_face_t>* face_list, Logger& logger) : face_list(face_list), logger_(logger) {
}
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
@@ -2222,7 +2222,7 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3<Kernel_>::HalfedgeDS &hds)
// For now let's just skip over the triangle. We can also use
// the Aff_transformation_3 stored in place to convert the 2d
// coords back to 3d.
Logger::Warning("GEO", 105, "Ignoring triangulated facet with novel point likely due to self-intersections");
logger_.Warning("GEO", 105, "Ignoring triangulated facet with novel point likely due to self-intersections");
facet_vertices.erase(facet_vertices.end() - 1);
break;
}
+10 -8
View File
@@ -20,6 +20,8 @@
#ifndef CGAL_KERNEL_H
#define CGAL_KERNEL_H
#include "../../../ifcparse/IfcLogger.h"
/*
#ifdef NO_CACHE
@@ -58,12 +60,12 @@ namespace ifcopenshell {
namespace utils {
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_cube(double d);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_cube(const Kernel_::Point_3& lower, const Kernel_::Point_3& upper);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders = false);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders = false, Logger& logger = Logger::Root());
#ifndef IFOPSH_SIMPLE_KERNEL
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_> &nef_polyhedron);
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(std::list<cgal_face_t> &face_list);
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_> &nef_polyhedron, Logger& logger = Logger::Root());
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(std::list<cgal_face_t> &face_list, Logger& logger = Logger::Root());
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron, Logger& logger = Logger::Root());
#endif
}
@@ -91,12 +93,12 @@ namespace ifcopenshell {
#endif
public:
CgalKernel(const Settings& settings)
: AbstractKernel("cgal", settings)
CgalKernel(const Settings& settings, Logger& logger = Logger::Root())
: AbstractKernel("cgal", settings, logger)
{}
virtual AbstractKernel* clone() const {
return new CgalKernel(settings());
return new CgalKernel(settings(), logger());
}
virtual bool supports_boolean_operations() const {
@@ -133,4 +135,4 @@ namespace ifcopenshell {
}
}
}
#endif
#endif
@@ -47,7 +47,7 @@ namespace {
}
}
void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const {
void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const {
// @todo remove duplication with OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// above can be static?
@@ -87,7 +87,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
try {
BRepMesh_IncrementalMesh(shape_, settings.get<settings::MesherLinearDeflection>().get(), false, settings.get<settings::MesherAngularDeflection>().get());
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape");
return;
}
}
@@ -113,7 +113,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
Handle_Poly_Triangulation tri = BRep_Tool::Triangulation(face, loc);
if (tri.IsNull()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face");
} else {
// Keep track of the number of times an edge is used
// Manifold edges (i.e. edges used twice) are deemed invisible
@@ -174,7 +174,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
else triangles(i).Get(n1, n2, n3);
if (dict[n1] == dict[n2] || dict[n2] == dict[n3] || dict[n3] == dict[n1]) {
Logger::Warning("GEO", 185, "Mesher generated a degenerate triangle, ignoring");
logger.Warning("GEO", 185, "Mesher generated a degenerate triangle, ignoring");
continue;
}
@@ -619,7 +619,7 @@ namespace {
try {
BRepMesh_IncrementalMesh(s, tol);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape");
return;
}
meshed = true;
@@ -53,7 +53,7 @@ namespace ifcopenshell {
const TopoDS_Shape& shape() const { return shape_; }
operator const TopoDS_Shape& () { return shape_; }
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
virtual IfcGeom::ConversionResultShape* clone() const {
@@ -118,7 +118,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
auto it3_shape = std::static_pointer_cast<OpenCascadeShape>(it3->Shape())->shape();
if (it3_shape.IsNull()) {
Logger::Error("GEO", 187, "Null operand");
Logger::Root().Error("GEO", 187, "Null operand");
continue;
}
@@ -143,7 +143,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
IfcGeom::util::create_solid_from_faces(list, entity_part, settings_.get<settings::Precision>().get(), true);
is_manifold = util::is_manifold(entity_part);
if (is_manifold) {
Logger::Warning("GEO", 188, "Successfully sewed non-manifold first operand");
Logger::Root().Warning("GEO", 188, "Successfully sewed non-manifold first operand");
}
}
@@ -161,17 +161,17 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(IfcGeom::util::count(entity_part, TopAbs_FACE));
} else {
is_manifold = util::is_manifold(entity_part_2);
Logger::Warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold")));
Logger::Root().Warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold")));
entity_part = entity_part_2;
}
} catch (const Standard_Failure& e) {
failure.emplace(e.GetMessageString());
}
if (failure) {
Logger::Warning("GEO", 190, "MakeVolume failed: " + *failure, entity);
Logger::Root().Warning("GEO", 190, "MakeVolume failed: " + *failure, entity);
}
} else {
Logger::Warning("GEO", 191, "Non-manifold first operand, use --make-volume to try and make manifold");
Logger::Root().Warning("GEO", 191, "Non-manifold first operand, use --make-volume to try and make manifold");
}
}
@@ -214,7 +214,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
if (util::boolean_operation(bst, result, opening_list, BOPAlgo_CUT, intermediate_result)) {
result = intermediate_result;
} else {
Logger::Message(Logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast<std::string>(std::distance(jt, it)) + " openings", entity);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast<std::string>(std::distance(jt, it)) + " openings", entity);
}
jt = it;
@@ -235,7 +235,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
// where we keep the first operand as is (a compound of faces probably,
// unless --orient-shells was activated in which case we're already lost).
if (!is_manifold) {
Logger::Warning("GEO", 193, "Retrying boolean operation on individual faces");
Logger::Root().Warning("GEO", 193, "Retrying boolean operation on individual faces");
}
continue;
}
@@ -112,14 +112,14 @@ private:
double precision_;
public:
OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings)
: AbstractKernel("opencascade", settings)
OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root())
: AbstractKernel("opencascade", settings, logger)
, faceset_helper_(nullptr)
, precision_(settings.get<ifcopenshell::geometry::settings::Precision>().get())
{}
virtual AbstractKernel* clone() const {
return new OpenCascadeKernel(settings());
return new OpenCascadeKernel(settings(), logger());
}
virtual bool supports_boolean_operations() const { return true; }
+13 -13
View File
@@ -711,12 +711,12 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
valid_shell &= util::count(shape, TopAbs_SHELL) > 0;
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 106, e.GetMessageString());
Logger::Root().Error("GEO", 106, e.GetMessageString());
} else {
Logger::Error("GEO", 107, "Unknown error sewing shell");
Logger::Root().Error("GEO", 107, "Unknown error sewing shell");
}
} catch (...) {
Logger::Error("GEO", 108, "Unknown error sewing shell");
Logger::Root().Error("GEO", 108, "Unknown error sewing shell");
}
if (valid_shell) {
@@ -744,22 +744,22 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
}
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 109, e.GetMessageString());
Logger::Root().Error("GEO", 109, e.GetMessageString());
} else {
Logger::Error("GEO", 110, "Unknown error classifying solid");
Logger::Root().Error("GEO", 110, "Unknown error classifying solid");
}
} catch (...) {
Logger::Error("GEO", 111, "Unknown error classifying solid");
Logger::Root().Error("GEO", 111, "Unknown error classifying solid");
}
}
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 112, e.GetMessageString());
Logger::Root().Error("GEO", 112, e.GetMessageString());
} else {
Logger::Error("GEO", 113, "Unknown error creating solid");
Logger::Root().Error("GEO", 113, "Unknown error creating solid");
}
} catch (...) {
Logger::Error("GEO", 114, "Unknown error creating solid");
Logger::Root().Error("GEO", 114, "Unknown error creating solid");
}
if (complete_shape.IsNull()) {
@@ -771,7 +771,7 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
B.MakeCompound(C);
B.Add(C, complete_shape);
complete_shape = C;
Logger::Warning("GEO", 115, "Multiple components in IfcConnectedFaceSet");
Logger::Root().Warning("GEO", 115, "Multiple components in IfcConnectedFaceSet");
}
B.Add(complete_shape, result_shape);
}
@@ -786,7 +786,7 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
B.MakeCompound(C);
B.Add(C, complete_shape);
complete_shape = C;
Logger::Warning("GEO", 116, "Loose faces in IfcConnectedFaceSet");
Logger::Root().Warning("GEO", 116, "Loose faces in IfcConnectedFaceSet");
}
B.Add(complete_shape, loose_faces.Current());
}
@@ -794,7 +794,7 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
shape = complete_shape;
} else {
Logger::Error("GEO", 117, "Failed to sew faceset");
Logger::Root().Error("GEO", 117, "Failed to sew faceset");
}
return valid_shell;
@@ -898,7 +898,7 @@ bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) {
dump(s);
Logger::Warning("GEO", 118, str.str());
Logger::Root().Warning("GEO", 118, str.str());
return false;
}
@@ -118,14 +118,14 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
const double first_operand_volume = util::shape_volume(a);
if (first_operand_volume <= ALMOST_ZERO) {
Logger::Message(Logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance);
}
} else {
for (auto& r : cr) {
auto S = std::static_pointer_cast<OpenCascadeShape>(r.Shape())->shape();
if (S.IsNull()) {
Logger::Error("GEO", 120, "Null operand");
Logger::Root().Error("GEO", 120, "Null operand");
continue;
}
gp_GTrsf trsf;
@@ -140,7 +140,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
// #2665 we also set a precision-independent threshold, because in the boolean op routine
// the working fuzziness might still be increased.
if (d < tol * 20. || d < 0.00002) {
Logger::Message(Logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance);
continue;
} else {
S = result;
@@ -419,7 +419,7 @@ int IfcGeom::util::eliminate_narrow_operands(double prec, const TopTools_ListOfS
bool is_narrow = min_dimension < prec;
Logger::Notice("GEO", 122, "Min OBB dimension of operand = " + std::to_string(min_dimension));
Logger::Root().Notice("GEO", 122, "Min OBB dimension of operand = " + std::to_string(min_dimension));
if (!is_narrow) {
c.Append(it.Value());
@@ -704,7 +704,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
if (u11 < U1 && U1 < u12 && u21 < U2 && U2 < u22) {
// Edge curves belonging to different operands intersect, don't process
// using builder.
Logger::Notice("GEO", 123, "Intersecting boundaries");
Logger::Root().Notice("GEO", 123, "Intersecting boundaries");
return false;
}
}
@@ -751,7 +751,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
// any effect and marked as redundant. Feeding it to the builder algo
// will likely cause problems.
redundant[std::distance(wires.begin(), it)] = true;
Logger::Notice("GEO", 124, "Subtraction operand outside of outer bound");
Logger::Root().Notice("GEO", 124, "Subtraction operand outside of outer bound");
}
}
@@ -791,7 +791,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
if (wire_clss[wire_index].Perform(p2d) == TopAbs_IN) {
// A wire is contained within another operand
redundant[other_index] = true;
Logger::Notice("GEO", 125, "Subtraction operand contained in other");
Logger::Root().Notice("GEO", 125, "Subtraction operand contained in other");
}
}
}
@@ -849,7 +849,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
std::stringstream ss;
ss << "bool-" << std::this_thread::get_id() << "-" << (operation_counter_++);
debug_identifier = ss.str();
Logger::Notice("GEO", 126, "Boolean debug identifier: " + debug_identifier);
Logger::Root().Notice("GEO", 126, "Boolean debug identifier: " + debug_identifier);
}
if (fuzziness < 0.) {
@@ -885,7 +885,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
a = unify(a_input, fuzziness * 1000.);
Logger::Message(
Logger::Root().Message(
Logger::LOG_DEBUG, "GEO", 127,
"Simplified operand A from "s +
std::to_string(count(a_input, TopAbs_FACE)) +
@@ -897,7 +897,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
TopTools_ListIteratorOfListOfShape it(b_input);
for (; it.More(); it.Next()) {
b.Append(unify(it.Value(), fuzziness));
Logger::Message(
Logger::Root().Message(
Logger::LOG_DEBUG, "GEO", 128,
"Simplified operand B from "s +
std::to_string(count(it.Value(), TopAbs_FACE)) +
@@ -925,7 +925,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
auto N = bounding_box_overlap(fuzziness, a, b, b_tmp);
if (N) {
Logger::Notice("GEO", 129, "Eliminated " + std::to_string(N) + " disjoint operands");
Logger::Root().Notice("GEO", 129, "Eliminated " + std::to_string(N) + " disjoint operands");
std::swap(b, b_tmp);
}
}
@@ -936,7 +936,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
b_tmp.Clear();
auto N = eliminate_touching_operands(fuzziness, a, b, b_tmp);
if (N) {
Logger::Notice("GEO", 130, "Eliminated " + std::to_string(N) + " touching operands");
Logger::Root().Notice("GEO", 130, "Eliminated " + std::to_string(N) + " touching operands");
std::swap(b, b_tmp);
}
}
@@ -947,7 +947,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
b_tmp.Clear();
auto N = eliminate_narrow_operands(fuzziness, b, b_tmp);
if (N) {
Logger::Notice("GEO", 131, "Eliminated " + std::to_string(N) + " narrow operands");
Logger::Root().Notice("GEO", 131, "Eliminated " + std::to_string(N) + " narrow operands");
std::swap(b, b_tmp);
}
}
@@ -961,21 +961,21 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (b.Extent() == 0) {
Logger::Warning("GEO", 132, "No other operands remaining, using first operand");
Logger::Root().Warning("GEO", 132, "No other operands remaining, using first operand");
result = a;
return true;
}
if (!is_2d && Logger::LOG_NOTICE >= Logger::Verbosity()) {
if (!is_2d && Logger::LOG_NOTICE >= Logger::Root().Verbosity()) {
PERF("preliminary manifoldness check");
if (!a.IsNull()) {
Logger::Notice("GEO", 133, "Operand A is " + (is_manifold(a) ? ""s : "non-"s) + "manifold");
Logger::Root().Notice("GEO", 133, "Operand A is " + (is_manifold(a) ? ""s : "non-"s) + "manifold");
}
TopTools_ListIteratorOfListOfShape it(b);
for (int i = 0; it.More(); it.Next(), ++i) {
Logger::Notice("GEO", 134, "Operand B " + std::to_string(i) + " is " + (is_manifold(it.Value()) ? ""s : "non-"s) + "manifold");
Logger::Root().Notice("GEO", 134, "Operand B " + std::to_string(i) + " is " + (is_manifold(it.Value()) ? ""s : "non-"s) + "manifold");
}
}
@@ -1015,7 +1015,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
const double fuzz = (std::min)(min_length_orig / 3., fuzziness);
Logger::Notice("GEO", 135, "Used fuzziness: " + std::to_string(fuzz));
Logger::Root().Notice("GEO", 135, "Used fuzziness: " + std::to_string(fuzz));
const double new_fuzziness = fuzziness * 10.;
const bool allow_retry = new_fuzziness - 1e-15 <= settings.precision * 10000. && new_fuzziness < min_length_orig;
@@ -1049,7 +1049,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (is_extrusion_a) {
Logger::Notice("GEO", 136, "Operand A 1/1 is an extrusion");
Logger::Root().Notice("GEO", 136, "Operand A 1/1 is an extrusion");
TopTools_ListIteratorOfListOfShape it(b);
for (int nb = 1; it.More(); it.Next(), ++nb) {
@@ -1065,10 +1065,10 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (is_extrusion_b) {
Logger::Notice("GEO", 137, "Operand B " + std::to_string(nb) + "/" + std::to_string(b.Extent()) + " is an extrusion");
Logger::Root().Notice("GEO", 137, "Operand B " + std::to_string(nb) + "/" + std::to_string(b.Extent()) + " is an extrusion");
if (b_interval.first < a_interval.first + (fuzz * 100.) && b_interval.second > a_interval.second - (fuzz * 100.)) {
Logger::Notice("GEO", 138, "Operand B creates a through hole");
Logger::Root().Notice("GEO", 138, "Operand B creates a through hole");
// Align b with a operand
gp_Trsf trsf;
@@ -1108,23 +1108,23 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
BRepPrimAPI_MakePrism mp(face_result, gp_Vec(gp::DY()) * (a_interval.second - a_interval.first));
if (mp.IsDone()) {
if (b_remainder_3d.Extent()) {
Logger::Notice("GEO", 139, std::to_string(b_remainder_3d.Extent()) + " operands remaining to process in 3D");
Logger::Root().Notice("GEO", 139, std::to_string(b_remainder_3d.Extent()) + " operands remaining to process in 3D");
b = b_remainder_3d;
s1s.Clear();
s1s.Append(mp.Shape());
} else {
Logger::Notice("GEO", 140, "Processed fully in 2D");
Logger::Root().Notice("GEO", 140, "Processed fully in 2D");
result = mp.Shape();
return true;
}
} else {
Logger::Notice("GEO", 141, "Failed to extrude 2D boolean result. Retrying in 3D.");
Logger::Root().Notice("GEO", 141, "Failed to extrude 2D boolean result. Retrying in 3D.");
}
} else {
Logger::Notice("GEO", 142, "Failed to perform 2D boolean operation. Retrying in 3D.");
Logger::Root().Notice("GEO", 142, "Failed to perform 2D boolean operation. Retrying in 3D.");
}
} else {
Logger::Notice("GEO", 143, "No second operands can be processed as 2D inner bounds. Retrying in 3D.");
Logger::Root().Notice("GEO", 143, "No second operands can be processed as 2D inner bounds. Retrying in 3D.");
}
}
}
@@ -1146,7 +1146,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (builder->IsDone()) {
if (false && builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertAcquiredSelfIntersection))) {
Logger::Notice("GEO", 144, "Builder reports self-intersection in output");
Logger::Root().Notice("GEO", 144, "Builder reports self-intersection in output");
success = false;
/*
@@ -1160,7 +1160,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
*/
} else if(builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertBadPositioning)) && !TopoDS_Iterator(*builder).More()) {
Logger::Notice("GEO", 145, "Builder reports bad positioning and result is empty");
Logger::Root().Notice("GEO", 145, "Builder reports bad positioning and result is empty");
success = false;
} else {
TopoDS_Shape r = *builder;
@@ -1174,7 +1174,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
fix.Perform();
r = fix.Shape();
} catch (...) {
Logger::Error("GEO", 146, "Shape healing failed on boolean result");
Logger::Root().Error("GEO", 146, "Shape healing failed on boolean result");
}
}
@@ -1185,7 +1185,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
success = ana.IsValid() != 0;
if (!success) {
Logger::Notice("GEO", 147, "Boolean operation yields invalid result");
Logger::Root().Notice("GEO", 147, "Boolean operation yields invalid result");
std::stringstream str;
bool any_emitted = false;
@@ -1215,7 +1215,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
dump(r);
Logger::Notice("GEO", 148, str.str());
Logger::Root().Notice("GEO", 148, str.str());
}
}
@@ -1335,7 +1335,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
if (op == BOPAlgo_CUT && has_open_shells && all_faces_included_in_result && result_n_faces > first_op_n_faces) {
success = false;
Logger::Notice("GEO", 149, "Boolean result discarded because subtractions results in only the addition of faces");
Logger::Root().Notice("GEO", 149, "Boolean result discarded because subtractions results in only the addition of faces");
} else {
// when there are edges or vertex-edge distances close to the used fuzziness, the
// output is not trusted and the operation is attempted with a higher fuzziness.
@@ -1381,7 +1381,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
static const char* const reason_strings[] = { "edge length", "vertex-edge", "face-face" };
std::stringstream str;
str << "Boolean operation result failing " << reason_strings[reason] << " interference check, with fuzziness " << fuzziness << " with length " << v;
Logger::Notice("GEO", 150, str.str());
Logger::Root().Notice("GEO", 150, str.str());
}
}
@@ -1390,7 +1390,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
} else {
Logger::Notice("GEO", 151, "Boolean operation yields non-manifold result");
Logger::Root().Notice("GEO", 151, "Boolean operation yields non-manifold result");
}
}
}
@@ -1400,7 +1400,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
#if OCC_VERSION_HEX >= 0x70200
if (builder->HasError(STANDARD_TYPE(BOPAlgo_AlertBOPNotAllowed))) {
Logger::Error("GEO", 152, "Invalid operands. Using first operand");
Logger::Root().Error("GEO", 152, "Invalid operands. Using first operand");
result = a;
success = true;
}
@@ -1413,14 +1413,14 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
#endif
std::string str_str = str.str();
if (str_str.size()) {
Logger::Notice("GEO", 153, str_str);
Logger::Root().Notice("GEO", 153, str_str);
}
}
if (!success) {
if (allow_retry) {
return boolean_operation(settings, a, b, op, result, new_fuzziness);
} else {
Logger::Notice("GEO", 154, "No longer attempting boolean operation with higher fuzziness");
Logger::Root().Notice("GEO", 154, "No longer attempting boolean operation with higher fuzziness");
}
}
return success && !result.IsNull();
@@ -10,7 +10,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS
const double& height = extrusion->depth;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Error("GEO", 155, "Non-positive extrusion height encountered for:", extrusion->instance);
Logger::Root().Error("GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
return false;
}
+14 -14
View File
@@ -169,7 +169,7 @@ namespace {
} else if (crv_or_wire.which() == 2) {
// @todo
const double precision_ = 1.e-5;
Logger::Warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance);
Logger::Root().Warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance);
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
#if OCC_VERSION_HEX < 0x70600
BRepAdaptor_CompCurve cc(w, true);
@@ -289,12 +289,12 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
// the face will still be processed as long as there are no holes. A compound of faces
// is returned in that case.
if (num_bounds > 1 && num_outer_bounds > 1 && num_bounds != num_outer_bounds) {
Logger::Message(Logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance);
return false;
}
if (num_outer_bounds > 1) {
Logger::Message(Logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance);
fd.all_outer() = true;
}
@@ -315,11 +315,11 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
TopoDS_Wire wire;
if (faceset_helper_ && bound->is_polyhedron()) {
if (!faceset_helper_->wire(bound, wire)) {
Logger::Message(Logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance);
continue;
}
} else if (!convert(bound, wire)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance);
return false;
}
@@ -336,7 +336,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
};
TopTools_ListOfShape results;
if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) {
Logger::Warning("GEO", 161, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 161, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
util::select_largest(results, wire);
}
@@ -347,7 +347,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
}
if (fd.wires().empty()) {
Logger::Warning("GEO", 162, "Face with no boundaries", face->instance);
Logger::Root().Warning("GEO", 162, "Face with no boundaries", face->instance);
return false;
}
@@ -404,7 +404,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
if (fd.surface().IsNull()) {
// The set of wires is triangulated in case no surface can be found
Logger::Message(Logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance);
if (fd.all_outer()) {
for (const auto& w : fd.wires()) {
@@ -457,7 +457,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
kt.Value().Original().ToUTF8CString(c);
std::string message = c;
delete[] c;
Logger::Warning("GEO", 164, message, face->instance);
Logger::Root().Warning("GEO", 164, message, face->instance);
}
}
@@ -469,17 +469,17 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
if (it.Value().ShapeType() == TopAbs_FACE) {
face_list.Append(it.Value());
} else {
Logger::Error("UNS", 7, "Unsupported output from face healing");
Logger::Root().Error("UNS", 7, "Unsupported output from face healing");
}
}
} else {
Logger::Error("UNS", 8, "Unsupported output from face healing");
Logger::Root().Error("UNS", 8, "Unsupported output from face healing");
}
} else {
face_list.Append(f);
}
} else {
Logger::Error("GEO", 165, "Internal error in face creation");
Logger::Root().Error("GEO", 165, "Internal error in face creation");
return false;
}
} else {
@@ -520,14 +520,14 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
delete[] c;
#if OCC_VERSION_MAJOR==7 && OCC_VERSION_MINOR >= 7
if (!reversed_surface && !fd.surface().IsNull() && fd.surface()->IsUPeriodic() && message == "Unknown message invoked with the keyword FixAdvFace.FixOrientation.MSG0") {
Logger::Notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface");
Logger::Root().Notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface");
TopoDS_Face reversed_result;
convert(face, reversed_result, true);
result = reversed_result;
return true;
} else
#endif
Logger::Warning("GEO", 167, message, face->instance);
Logger::Root().Warning("GEO", 167, message, face->instance);
}
}
}
@@ -149,7 +149,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
auto num_retained = std::count(retained.begin(), retained.end(), true);
if (unique.size() != num_retained) {
Logger::Notice("GEO", 168, "Collapsed vertices from " + std::to_string(pnts.size()) + " (" + std::to_string(unique.size()) + " unique) to " + std::to_string(num_retained));
Logger::Root().Notice("GEO", 168, "Collapsed vertices from " + std::to_string(pnts.size()) + " (" + std::to_string(unique.size()) + " unique) to " + std::to_string(num_retained));
}
typedef std::array<int, 2> edge_t;
@@ -205,7 +205,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
}
if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.get_value_or(false))) {
Logger::Warning("GEO", 169, boost::lexical_cast<std::string>(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast<std::string>(loops_removed) + " degenerate loops eliminated and " + boost::lexical_cast<std::string>(non_manifold) + " non-manifold edges");
Logger::Root().Warning("GEO", 169, boost::lexical_cast<std::string>(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast<std::string>(loops_removed) + " degenerate loops eliminated and " + boost::lexical_cast<std::string>(non_manifold) + " non-manifold edges");
}
}
@@ -276,7 +276,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geome
!kernel_->settings().get<ifcopenshell::geometry::settings::NoWireIntersectionTolerance>().get(), 0.,
kernel_->settings().get<ifcopenshell::geometry::settings::Precision>().get()}))
{
Logger::Warning("GEO", 170, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 170, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
non_manifold_ = true;
wires = results;
} else {
+6 -6
View File
@@ -129,7 +129,7 @@ namespace {
}
}
Logger::Error("GEO", 171, "Unable to map layer geometry to material index");
Logger::Root().Error("GEO", 171, "Unable to map layer geometry to material index");
return false;
}
}
@@ -234,7 +234,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
if (s.ShapeType() == TopAbs_SHELL) {
shells.Append(TopoDS::Shell(s));
} else {
Logger::Error("GEO", 172, "Expected shell type in layerset processing");
Logger::Root().Error("GEO", 172, "Expected shell type in layerset processing");
return false;
}
}
@@ -433,12 +433,12 @@ bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS
}
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 173, e.GetMessageString());
Logger::Root().Error("GEO", 173, e.GetMessageString());
} else {
Logger::Error("GEO", 174, "Unknown error performing fixes");
Logger::Root().Error("GEO", 174, "Unknown error performing fixes");
}
} catch (...) {
Logger::Error("GEO", 175, "Unknown error performing fixes");
Logger::Root().Error("GEO", 175, "Unknown error performing fixes");
}
BRepCheck_Analyzer analyser(shape);
bool is_valid = analyser.IsValid() != 0;
@@ -448,7 +448,7 @@ bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS
}
if (is_null[0] || is_null[1]) {
Logger::Message(Logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing");
if (is_null[0] && is_null[1]) {
return false;
}
+3 -3
View File
@@ -83,7 +83,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
if (non_polygonal) {
if (loft->children.size() < 2) {
Logger::Error("GEO", 177, "Not enough sections to loft");
Logger::Root().Error("GEO", 177, "Not enough sections to loft");
return false;
}
@@ -124,7 +124,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
auto first_wire_count = sections.front().size();
for (auto& section : sections) {
if (section.size() != first_wire_count) {
Logger::Error("GEO", 178, "Inconsistent number of wires in sections");
Logger::Root().Error("GEO", 178, "Inconsistent number of wires in sections");
return false;
}
}
@@ -261,7 +261,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
*/
if (shps.size() < 2) {
Logger::Error("GEO", 179, "Not enough sections to loft");
Logger::Root().Error("GEO", 179, "Not enough sections to loft");
return false;
}
+3 -3
View File
@@ -129,7 +129,7 @@ namespace {
} else {
// @todo
const double precision_ = 1.e-5;
Logger::Warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance);
Logger::Root().Warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance);
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
#if OCC_VERSION_HEX < 0x70600
BRepAdaptor_CompCurve cc(w, true);
@@ -266,7 +266,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
}
if (converted_segments.Extent() == 0) {
Logger::Message(Logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance);
return false;
}
@@ -331,7 +331,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
if (ang < 0.0314) {
edges_to_tesselate.Add(crv1->DynamicType() == STANDARD_TYPE(Geom_Circle) ? edges.First() : edges.Last());
Logger::Notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation");
Logger::Root().Notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation");
}
}
}
+7 -7
View File
@@ -46,19 +46,19 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap
try {
success = convert(face, occ_face);
} catch (const std::exception& e) {
Logger::Error("GEO", 194, e);
Logger::Root().Error("GEO", 194, e);
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 195, e.GetMessageString());
Logger::Root().Error("GEO", 195, e.GetMessageString());
} else {
Logger::Error("GEO", 196, "Unknown error creating face");
Logger::Root().Error("GEO", 196, "Unknown error creating face");
}
} catch (...) {
Logger::Error("GEO", 197, "Unknown error creating face");
Logger::Root().Error("GEO", 197, "Unknown error creating face");
}
if (!success) {
Logger::Message(Logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance);
continue;
}
@@ -71,7 +71,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap
if (face_area(triangle) > min_face_area) {
face_list.Append(triangle);
} else {
Logger::Message(Logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance);
}
}
}
@@ -79,7 +79,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap
if (face_area(occ_face) > min_face_area) {
face_list.Append(occ_face);
} else {
Logger::Message(Logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance);
}
}
}
+1 -1
View File
@@ -92,7 +92,7 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape&
throw std::runtime_error("Unexpected configuration of subshapes");
}
} else {
Logger::Warning("GEO", 201, "Ignored shell", s->instance);
Logger::Root().Warning("GEO", 201, "Ignored shell", s->instance);
}
}
if (!S.IsNull()) {
@@ -130,7 +130,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
auto w = convert_curve(scs->curve);
if (w.which() != 2) {
Logger::Error("UNS", 9, "Unsupported directrix");
Logger::Root().Error("UNS", 9, "Unsupported directrix");
return false;
}
TopoDS_Shape face_;
@@ -178,7 +178,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) {
if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) {
directrix_on_plane = false;
Logger::Message(Logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance);
break;
}
}
@@ -97,7 +97,7 @@ bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) {
Handle(Geom_Curve) crv = BRep_Tool::Curve(edge, u0, u1);
crv->D1(u0, directrix_origin, directrix_tangent);
} else {
Logger::Error("GEO", 203, "Unable to locate first edge");
Logger::Root().Error("GEO", 203, "Unable to locate first edge");
return false;
}
@@ -187,7 +187,7 @@ void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector<TopoDS_Edge
for (int i = 1; i <= map.Extent(); ++i) {
if (map.FindFromIndex(i).Extent() > 2) {
Logger::Warning("GEO", 204, "Self-intersecting Directrix");
Logger::Root().Warning("GEO", 204, "Self-intersecting Directrix");
}
}
@@ -116,12 +116,12 @@ bool IfcGeom::util::create_edge_over_curve_with_log_messages(const Handle_Geom_C
}
}
if (dmin == std::numeric_limits<double>::infinity()) {
Logger::Error("GEO", 205, "No extrema for point");
Logger::Root().Error("GEO", 205, "No extrema for point");
} else if (dmin > eps2) {
Logger::Error("GEO", 206, "Distance of " + boost::lexical_cast<std::string>(std::sqrt(dmin)) + " exceeds tolerance");
Logger::Root().Error("GEO", 206, "Distance of " + boost::lexical_cast<std::string>(std::sqrt(dmin)) + " exceeds tolerance");
}
} else {
Logger::Error("GEO", 207, "Failed to calculate extrema for point");
Logger::Root().Error("GEO", 207, "Failed to calculate extrema for point");
}
}
}
@@ -171,7 +171,7 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS
if (dist > 1000. * p_) {
mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
Logger::Warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
Logger::Root().Warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
goto check;
}
@@ -199,28 +199,28 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS
// Preferably adjust the segment that is linear
if (is_line1 || (is_circle1 && !is_line2)) {
mw_.Add(adjust(w1, w12, p2));
Logger::Notice("GEO", 209, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
Logger::Root().Notice("GEO", 209, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
} else if ((is_line2 || is_circle2) && !last) {
mw_.Add(w1);
override_next_ = true;
next_override_ = p1;
Logger::Notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
Logger::Root().Notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
} else {
// In all other cases an edge is added
mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
Logger::Warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
Logger::Root().Warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
}
} else {
Logger::Error("GEO", 212, "Internal error, inconsistent wire segments", inst_);
Logger::Root().Error("GEO", 212, "Internal error, inconsistent wire segments", inst_);
mw_.Add(w1);
}
}
check:
if (mw_.Error() == BRepBuilderAPI_NonManifoldWire) {
Logger::Error("GEO", 213, "Non-manifold curve segments:", inst_);
Logger::Root().Error("GEO", 213, "Non-manifold curve segments:", inst_);
} else if (mw_.Error() == BRepBuilderAPI_DisconnectedWire) {
Logger::Error("GEO", 214, "Failed to join curve segments:", inst_);
Logger::Root().Error("GEO", 214, "Failed to join curve segments:", inst_);
}
}
+17 -17
View File
@@ -86,7 +86,7 @@ bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_P
// obtaining a 2d points for the Delaunay, infinity is passed here, so this
// can't for assessing degenerativeness.
if (v.Magnitude() < 1.e-7) {
Logger::Warning("GEO", 215, "Degenerate face boundary in normal estimation");
Logger::Root().Warning("GEO", 215, "Degenerate face boundary in normal estimation");
return false;
}
@@ -233,7 +233,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
auto it = mapping.find(uvnodes[k]);
if (it == mapping.end()) {
Logger::Error("GEO", 216, "Internal error: unable to unproject uv-mesh");
Logger::Root().Error("GEO", 216, "Internal error: unable to unproject uv-mesh");
return TRIANGULATE_WIRE_FAIL;
}
@@ -277,7 +277,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
}
faces.Append(triangle_face);
} else {
Logger::Error("GEO", 217, "Internal error: missing face");
Logger::Root().Error("GEO", 217, "Internal error: missing face");
return TRIANGULATE_WIRE_FAIL;
}
}
@@ -308,7 +308,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
if (!contains) {
#endif
// All existing edges need to exist in the new faces
Logger::Error("GEO", 218, "Internal error, missing edge from triangulation");
Logger::Root().Error("GEO", 218, "Internal error, missing edge from triangulation");
non_manifold = true;
}
}
@@ -319,7 +319,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
// Existing edges are boundaries with use 1
// New edges are internal with use 2
if (n != (mape.Contains(v) ? 1 : 2)) {
Logger::Error("GEO", 219, "Internal error, non-manifold result from triangulation");
Logger::Root().Error("GEO", 219, "Internal error, non-manifold result from triangulation");
non_manifold = true;
}
}
@@ -790,12 +790,12 @@ bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape
shape = solid.SolidFromShell(TopoDS::Shell(shape));
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 220, e.GetMessageString());
Logger::Root().Error("GEO", 220, e.GetMessageString());
} else {
Logger::Error("GEO", 221, "Unknown error creating solid");
Logger::Root().Error("GEO", 221, "Unknown error creating solid");
}
} catch (...) {
Logger::Error("GEO", 222, "Unknown error creating solid");
Logger::Root().Error("GEO", 222, "Unknown error creating solid");
}
return true;
@@ -808,12 +808,12 @@ bool IfcGeom::util::convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoD
return true;
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 223, e.GetMessageString());
Logger::Root().Error("GEO", 223, e.GetMessageString());
} else {
Logger::Error("GEO", 224, "Unknown error converting curve to wire");
Logger::Root().Error("GEO", 224, "Unknown error converting curve to wire");
}
} catch (...) {
Logger::Error("GEO", 225, "Unknown error converting curve to wire");
Logger::Root().Error("GEO", 225, "Unknown error converting curve to wire");
}
return false;
}
@@ -834,7 +834,7 @@ void IfcGeom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) {
wire = mw.Wire();
}
Logger::Warning("GEO", 226, "Wire not closed");
Logger::Root().Warning("GEO", 226, "Wire not closed");
}
}
@@ -844,7 +844,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face
TopTools_ListOfShape results;
if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) {
Logger::Warning("GEO", 227, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 227, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
util::select_largest(results, wire);
}
@@ -875,7 +875,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face
BRepBuilderAPI_FaceError er = mf.Error();
if (er != BRepBuilderAPI_FaceDone) {
Logger::Error("GEO", 228, "Failed to create face.");
Logger::Root().Error("GEO", 228, "Failed to create face.");
return false;
}
face = mf.Face();
@@ -902,7 +902,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound&
TopTools_ListOfShape results;
if (settings.use_wire_intersection_check && util::wire_intersections(w, results, settings)) {
Logger::Warning("GEO", 229, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 229, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
} else {
results.Clear();
results.Append(w);
@@ -928,7 +928,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound&
BRepBuilderAPI_FaceError er = mf.Error();
if (er != BRepBuilderAPI_FaceDone) {
Logger::Error("GEO", 230, "Failed to create face.");
Logger::Root().Error("GEO", 230, "Failed to create face.");
continue;
}
@@ -945,7 +945,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound&
if (p.first >= max_area / 10.) {
B.Add(faces, p.second);
} else {
Logger::Warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast<std::string>(p.first));
Logger::Root().Warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast<std::string>(p.first));
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
P = *v->components_;
} catch (const std::exception&) {
Logger::Warning("GEO", 232, "Placement with invalid Location:", inst);
logger_.Warning("GEO", 232, "Placement with invalid Location:", inst);
}
const bool hasAxis = inst->Axis();
if (hasAxis) {
+1 -1
View File
@@ -29,7 +29,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement2D* inst) {
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
P = *v->components_;
} catch (const std::exception&) {
Logger::Warning("GEO", 233, "Placement with invalid Location:", inst);
logger_.Warning("GEO", 233, "Placement with invalid Location:", inst);
}
const bool hasRef = !!inst->RefDirection();
if (hasRef) {
+2 -2
View File
@@ -29,13 +29,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
o = *v->components_;
} catch (const std::exception&) {
Logger::Warning("GEO", 234, "Placement with invalid Location:", inst);
logger_.Warning("GEO", 234, "Placement with invalid Location:", inst);
}
const bool hasAxis = !!inst->Axis();
const bool hasRef = !!inst->RefDirection();
if (hasAxis != hasRef) {
Logger::Warning("GEO", 235, "Axis and RefDirection should be specified together", inst);
logger_.Warning("GEO", 235, "Axis and RefDirection should be specified together", inst);
}
if (hasAxis) {
@@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst) {
if (!inst->Location()->as<IfcSchema::IfcPointByDistanceExpression>()) {
Logger::Error("GEO", 236, std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear"));
logger_.Error("GEO", 236, std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear"));
}
Eigen::Vector3d o, axis(0, 0, 1), refDirection;
+1 -1
View File
@@ -43,7 +43,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if ( x < tol || y < tol || d1 < tol || d2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle* inst) {
const double r = inst->Radius() * length_unit_;
if (r < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst);
return nullptr;
}
+3 -3
View File
@@ -34,11 +34,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
for (auto& segment : *segments) {
if (segment->as<IfcSchema::IfcCompositeCurveSegment>() && segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve()->as<IfcSchema::IfcLine>()) {
Logger::Notice("GEO", 238, "Infinite IfcLine used as ParentCurve of segment, treating as a segment", segment);
logger_.Notice("GEO", 238, "Infinite IfcLine used as ParentCurve of segment, treating as a segment", segment);
double u0 = 0.0;
double u1 = segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve()->as<IfcSchema::IfcLine>()->Dir()->Magnitude() * length_unit_;
if (u1 < settings_.get<settings::Precision>().get()) {
Logger::Warning("GEO", 239, "Segment length below tolerance", segment);
logger_.Warning("GEO", 239, "Segment length below tolerance", segment);
}
auto e = taxonomy::make<taxonomy::edge>();
@@ -70,7 +70,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
e->end = 2.0 * boost::math::constants::pi<double>();
loop->children.push_back(e);
} else {
Logger::Warning("GEO", 240, "Unexpected segment type", segment);
logger_.Warning("GEO", 240, "Unexpected segment type", segment);
return nullptr;
}
}
+17 -17
View File
@@ -260,7 +260,7 @@ class curve_segment_evaluator {
}
}
} else {
Logger::Warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment.");
logger_.Warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment.");
}
}
@@ -283,7 +283,7 @@ class curve_segment_evaluator {
if ((is_horizontal + is_vertical + is_cant) != 1) {
// We have to choose the correct functor based on usage. We can't
// support multiple, because we don't know the caller at this point.
Logger::Error("UNS", 10, std::runtime_error("multiple uses of IfcSegmentCurve not supported"), inst_);
logger_.Error("UNS", 10, std::runtime_error("multiple uses of IfcSegmentCurve not supported"), inst_);
}
segment_type_ = is_horizontal ? ST_HORIZONTAL : is_vertical ? ST_VERTICAL : is_cant ? ST_CANT : ST_HORIZONTAL;
@@ -321,7 +321,7 @@ class curve_segment_evaluator {
end_point = segmented_reference_curve->EndPoint();
}
} else {
Logger::Warning("GEO", 243, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the end point.");
logger_.Warning("GEO", 243, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the end point.");
}
if (end_point) {
next_segment_placement_ = taxonomy::cast<taxonomy::matrix4>(mapping_->map(end_point))->ccomponents();
@@ -343,7 +343,7 @@ class curve_segment_evaluator {
taxonomy::ptr get_segment_curve_function() {
if (!parent_curve_fn_ || !parent_curve_start_point_) {
Logger::Error("UNS", 11, std::runtime_error(inst_->ParentCurve()->declaration().name() + " not implemented"), inst_);
logger_.Error("UNS", 11, std::runtime_error(inst_->ParentCurve()->declaration().name() + " not implemented"), inst_);
}
auto length = fabs(this->length());
@@ -476,13 +476,13 @@ class curve_segment_evaluator {
projected_length_ = length_;
}
} else if (segment_type_ == ST_CANT) {
Logger::Error("GEO", 244, std::runtime_error("Unexpected segment type encountered - cant is handled in set_cant_spiral_function - should never get here"));
logger_.Error("GEO", 244, std::runtime_error("Unexpected segment type encountered - cant is handled in set_cant_spiral_function - should never get here"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
);
} else {
Logger::Error("GEO", 245, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 245, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
@@ -643,13 +643,13 @@ class curve_segment_evaluator {
set_cant_spiral_function(*super, *slope, cant);
} else if (segment_type_ == ST_VERTICAL) {
Logger::Error("GEO", 246, std::runtime_error("IfcCosineSpiral cannot be used for vertical alignment"));
logger_.Error("GEO", 246, std::runtime_error("IfcCosineSpiral cannot be used for vertical alignment"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
);
} else {
Logger::Error("GEO", 247, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 247, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
@@ -712,12 +712,12 @@ class curve_segment_evaluator {
set_cant_spiral_function(*super, *slope, cant);
} else if (segment_type_ == ST_VERTICAL) {
Logger::Error("GEO", 248, std::runtime_error("IfcSineSpiral cannot be used for vertical alignment"));
logger_.Error("GEO", 248, std::runtime_error("IfcSineSpiral cannot be used for vertical alignment"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
} else {
Logger::Error("GEO", 249, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 249, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
@@ -976,12 +976,12 @@ class curve_segment_evaluator {
}
} else if (segment_type_ == ST_CANT) {
Logger::Warning("UNS", 12, std::runtime_error("Use of IfcCircle for cant is not supported"));
logger_.Warning("UNS", 12, std::runtime_error("Use of IfcCircle for cant is not supported"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
} else {
Logger::Error("GEO", 250, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 250, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
@@ -1067,7 +1067,7 @@ class curve_segment_evaluator {
parent_curve_start_point_ = (*parent_curve_fn_)(start_);
} else {
Logger::Warning("GEO", 251, std::runtime_error("Unexpected segment type encountered"));
logger_.Warning("GEO", 251, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
@@ -1081,7 +1081,7 @@ class curve_segment_evaluator {
auto coeffY = pc->CoefficientsY().get_value_or(std::vector<double>());
auto coeffZ = pc->CoefficientsZ().get_value_or(std::vector<double>());
if (!coeffZ.empty()) {
Logger::Warning("GEO", 252, "Expected IfcPolynomialCurve.CoefficientsZ to be undefined for alignment geometry. Coefficients ignored.", pc);
logger_.Warning("GEO", 252, "Expected IfcPolynomialCurve.CoefficientsZ to be undefined for alignment geometry. Coefficients ignored.", pc);
}
if (segment_type_ == ST_HORIZONTAL || segment_type_ == ST_VERTICAL) {
@@ -1147,7 +1147,7 @@ class curve_segment_evaluator {
auto result = boost::math::tools::bracket_and_solve_root(f, x, 2.0, true, tol, max_iter);
x = result.first;
} catch (...) {
Logger::Warning("GEO", 253, "root solver failed");
logger_.Warning("GEO", 253, "root solver failed");
}
return x;
};
@@ -1208,12 +1208,12 @@ class curve_segment_evaluator {
parent_curve_start_point_ = (*parent_curve_fn_)(0.0); // start is added to u in parent_curve_fn_, so use 0.0 here
} else if (segment_type_ == ST_CANT) {
Logger::Warning("UNS", 13, std::runtime_error("Use of IfcPolynomialCurve for cant is not supported"));
logger_.Warning("UNS", 13, std::runtime_error("Use of IfcPolynomialCurve for cant is not supported"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
} else {
Logger::Error("GEO", 254, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 254, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
+2 -2
View File
@@ -23,14 +23,14 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge* inst) {
if (!inst->EdgeStart()->declaration().is(IfcSchema::IfcVertexPoint::Class()) || !inst->EdgeEnd()->declaration().is(IfcSchema::IfcVertexPoint::Class())) {
Logger::Message(Logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst);
return nullptr;
}
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) inst->EdgeStart())->VertexGeometry();
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) inst->EdgeEnd())->VertexGeometry();
if (!pnt1->declaration().is(IfcSchema::IfcCartesianPoint::Class()) || !pnt2->declaration().is(IfcSchema::IfcCartesianPoint::Class())) {
Logger::Message(Logger::LOG_ERROR, "GEO", 256, "Only IfcCartesianPoints are supported for VertexGeometry", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 256, "Only IfcCartesianPoints are supported for VertexGeometry", inst);
return nullptr;
}
+1 -1
View File
@@ -26,7 +26,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
double y = inst->SemiAxis2() * length_unit_;
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst);
return nullptr;
}
+1 -1
View File
@@ -26,7 +26,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
double ry = inst->SemiAxis2() * length_unit_;
const double tol = settings_.get<settings::Precision>().get();
if (rx < tol || ry < tol) {
Logger::Message(Logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst);
return nullptr;
}
+1 -1
View File
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
const double height = inst->Depth() * length_unit_;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 259, "Non-positive extrusion height encountered for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst);
#ifndef PERMISSIVE_EXTRUSION
return nullptr;
#endif
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered* inst) {
const double height = inst->Depth() * length_unit_;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 260, "Non-positive extrusion height encountered for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst);
return nullptr;
}
+4 -4
View File
@@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
if (!inst->BaseCurve()->as<IfcSchema::IfcCompositeCurve>())
Logger::Warning("GEO", 261, "Expected IfcGradientCurve.BaseCurve to be IfcCompositeCurve", inst); // CT 4.1.7.1.1.2
logger_.Warning("GEO", 261, "Expected IfcGradientCurve.BaseCurve to be IfcCompositeCurve", inst); // CT 4.1.7.1.1.2
auto segments = inst->Segments();
@@ -41,11 +41,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
// for this reason, a dynamic cast is used and if crv is a function_item it is added to the span
spans.push_back(fi);
} else {
Logger::Error("UNS", 14, "Unsupported");
logger_.Error("UNS", 14, "Unsupported");
return nullptr;
}
} else {
Logger::Error("UNS", 15, "Unsupported");
logger_.Error("UNS", 15, "Unsupported");
return nullptr;
}
}
@@ -73,7 +73,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
// check to see if there is valid overlap of the horizontal and vertical domains
if (!(0 < gradient_function->length())) {
Logger::Error("GEO", 262, "IfcGradientCurve does not have a common domain with BaseCurve");
logger_.Error("GEO", 262, "IfcGradientCurve does not have a common domain with BaseCurve");
gradient_function = nullptr; // not valid
}
+1 -1
View File
@@ -24,7 +24,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
IfcSchema::IfcSurface* surface = inst->BaseSurface();
if (!surface->declaration().is(IfcSchema::IfcPlane::Class())) {
Logger::Message(Logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface);
logger_.Message(Logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface);
return nullptr;
}
auto p = taxonomy::make<taxonomy::plane>();
+1 -1
View File
@@ -81,7 +81,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x1 < tol || x2 < tol || y < tol || d1 < tol || ft1 < tol || ft2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -90,7 +90,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
e->basis = circ;
loop->children.push_back(e);
} else {
Logger::Warning("GEO", 263, "Ignoring segment on", inst);
logger_.Warning("GEO", 263, "Ignoring segment on", inst);
}
} else {
throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + segment->as<IfcUtil::IfcBaseClass>()->declaration().name());
+2 -2
View File
@@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if ( x < tol || y < tol || d < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -77,7 +77,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
const double det = a1*b2 - a2*b1;
if (std::fabs(det) < 1.e-5) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst);
return nullptr;
}
+3 -3
View File
@@ -54,7 +54,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
}
}
#else
Logger::Warning("GEO", 267, "Using --site-local-placement or --building-local-placement on IFC4.2 might have issues");
logger_.Warning("GEO", 267, "Using --site-local-placement or --building-local-placement on IFC4.2 might have issues");
#endif
}
}
@@ -127,7 +127,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
if (fallback) {
auto mapped_fallback = taxonomy::cast<taxonomy::matrix4>(map(fallback));
if (!result->ccomponents().isApprox(mapped_fallback->ccomponents())) {
Logger::Warning("GEO", 268, "Computed placement differs from fallback", inst);
logger_.Warning("GEO", 268, "Computed placement differs from fallback", inst);
}
}
@@ -135,7 +135,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
auto abs_det = std::abs(result->ccomponents().determinant());
if (abs_det < 1.e-7) {
Logger::Warning("GEO", 269, "Ignoring singular matrix:", inst);
logger_.Warning("GEO", 269, "Ignoring singular matrix:", inst);
return nullptr;
}
@@ -33,7 +33,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst) {
auto offset_values = inst->OffsetValues();
if (offset_values->size() == 0) {
Logger::Error("GEO", 270, "IfcOffsetCurveByDistances must have at least one offset value");
logger_.Error("GEO", 270, "IfcOffsetCurveByDistances must have at least one offset value");
}
auto first_offset_value = *(offset_values->begin());
@@ -56,7 +56,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
auto basis_curve_fn = taxonomy::dcast<taxonomy::function_item>(map(basis_curve));
if (!basis_curve_fn) {
// Only implement on alignment curves
Logger::Warning("GEO", 271, "IfcOffsetCurveByDistances is only implemented for BasisCurves curves based on taxonomy::function_item", inst);
logger_.Warning("GEO", 271, "IfcOffsetCurveByDistances is only implemented for BasisCurves curves based on taxonomy::function_item", inst);
return nullptr;
}
@@ -73,7 +73,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
first_distance *= length_unit_;
if (first_distance < 0.0) {
Logger::Warning("GEO", 272, "IfcOffsetCurveByDistance first offset value is before the start of the curve.");
logger_.Warning("GEO", 272, "IfcOffsetCurveByDistance first offset value is before the start of the curve.");
}
if(0.0 < first_distance)
@@ -110,7 +110,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
if (dn < dp) // next is before previous
{
Logger::Warning("GEO", 273, "IfcOffsetCurveByDistance offset value is out of bounds.");
logger_.Warning("GEO", 273, "IfcOffsetCurveByDistance offset value is out of bounds.");
continue;
}
@@ -32,7 +32,7 @@ const double PI = boost::math::constants::pi<double>();
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOpenCrossProfileDef* inst) {
if (inst->ProfileType() != IfcSchema::IfcProfileTypeEnum::IfcProfileType_CURVE) {
Logger::Warning("GEO", 274, "Expected IfcOpenCrossProfileDef.ProfileType to be CURVE", inst);
logger_.Warning("GEO", 274, "Expected IfcOpenCrossProfileDef.ProfileType to be CURVE", inst);
return nullptr;
}
@@ -55,7 +55,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOpenCrossProfileDef* inst) {
auto angles = inst->Slopes(); // these are actually angles, but the attribute is called Slopes
if (widths.size() != angles.size()) {
Logger::Warning("GEO", 275, "Expected Widths and Slopes to be equal length, but got " + std::to_string(widths.size()) + " and " + std::to_string(angles.size()) + " respectively", inst);
logger_.Warning("GEO", 275, "Expected Widths and Slopes to be equal length, but got " + std::to_string(widths.size()) + " and " + std::to_string(angles.size()) + " respectively", inst);
return nullptr;
}
+4 -4
View File
@@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
// A loop should consist of at least three vertices
int original_count = polygon.size();
if (original_count < 3) {
Logger::Message(Logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst);
return nullptr;
}
@@ -45,17 +45,17 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
auto previous_size = polygon.size();
remove_duplicate_points_from_loop(polygon, true, eps);
if (polygon.size() != previous_size) {
Logger::Warning("GEO", 279, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
logger_.Warning("GEO", 279, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
}
int count = polygon.size();
if (original_count - count != 0) {
std::stringstream ss; ss << (original_count - count) << " edges removed for:";
Logger::Message(Logger::LOG_WARNING, "GEO", 280, ss.str(), inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 280, ss.str(), inst);
}
if (count < 3) {
Logger::Message(Logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst);
return nullptr;
}
+2 -2
View File
@@ -44,12 +44,12 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyline* inst) {
auto previous_size = polygon.size();
remove_duplicate_points_from_loop(polygon, closed_by_proximity, eps);
if (polygon.size() != previous_size) {
Logger::Warning("GEO", 276, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
logger_.Warning("GEO", 276, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
}
if (polygon.size() < 2) {
// We somehow need to signal we fail this curve on purpose not to trigger an error.
Logger::Warning("GEO", 277, "Invalid polyline with " + std::to_string(polygon.size()) + " points:", inst);
logger_.Warning("GEO", 277, "Invalid polyline with " + std::to_string(polygon.size()) + " points:", inst);
return nullptr;
}
@@ -37,7 +37,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef* i
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -30,7 +30,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -31,7 +31,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef*
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -34,7 +34,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal* in
auto fn = taxonomy::dcast<taxonomy::function_item>(dir);
if (!fn) {
// Only implement on alignment curves
Logger::Warning("GEO", 285, "IfcSectionedSolidHorizontal is only implemented for Directrix curves based on taxonomy::function_item", inst);
logger_.Warning("GEO", 285, "IfcSectionedSolidHorizontal is only implemented for Directrix curves based on taxonomy::function_item", inst);
return nullptr;
}
@@ -74,11 +74,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal* in
profile_rotations.push_back(rot);
}
if (faces.size() != profile_offsets.size()) {
Logger::Warning("GEO", 286, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
logger_.Warning("GEO", 286, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
return nullptr;
}
if (faces.size() < 2) {
Logger::Warning("GEO", 287, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
logger_.Warning("GEO", 287, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
return nullptr;
}
+3 -3
View File
@@ -34,7 +34,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSurface* inst) {
auto fn = taxonomy::dcast<taxonomy::function_item>(dir);
if (!fn) {
// Only implement on alignment curves
Logger::Warning("GEO", 288, "IfcSectionedSurface is only implemented for Directrix curves based on taxonomy::function_item", inst);
logger_.Warning("GEO", 288, "IfcSectionedSurface is only implemented for Directrix curves based on taxonomy::function_item", inst);
return nullptr;
}
@@ -79,11 +79,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSurface* inst) {
return nullptr;
#endif
if (faces.size() != profile_offsets.size()) {
Logger::Warning("GEO", 289, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
logger_.Warning("GEO", 289, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
return nullptr;
}
if (faces.size() < 2) {
Logger::Warning("GEO", 290, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
logger_.Warning("GEO", 290, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
return nullptr;
}
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* inst) {
if (!inst->BaseCurve()->as<IfcSchema::IfcGradientCurve>())
Logger::Warning("GEO", 291, "Expected IfcSegmentedReferenceCurve.BaseCurve to be IfcGradient", inst); // CT 4.1.7.1.1.3
logger_.Warning("GEO", 291, "Expected IfcSegmentedReferenceCurve.BaseCurve to be IfcGradient", inst); // CT 4.1.7.1.1.3
auto segments = inst->Segments();
@@ -41,11 +41,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* ins
// for this reason, a dynamic cast is used and if crv is a function_item it is added to the span
spans.push_back(fi);
} else {
Logger::Error("UNS", 17, "Unsupported");
logger_.Error("UNS", 17, "Unsupported");
return nullptr;
}
} else {
Logger::Error("UNS", 18, "Unsupported");
logger_.Error("UNS", 18, "Unsupported");
return nullptr;
}
}
@@ -67,7 +67,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* ins
auto cant_function = taxonomy::make<taxonomy::cant_function>(gradient, cant, inst);
if (!(0 < cant_function->length())) {
Logger::Error("GEO", 292, "IfcSegmentedReferenceCurve does not have a common domain with BaseCurve");
logger_.Error("GEO", 292, "IfcSegmentedReferenceCurve does not have a common domain with BaseCurve");
cant_function = nullptr;
}
return cant_function;
+2 -2
View File
@@ -1,4 +1,4 @@
/********************************************************************************
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
@@ -62,7 +62,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
sp = inst->StartParam();
ep = inst->EndParam();
} catch (const IfcParse::IfcException& e) {
Logger::Warning("GEO", 293, e);
logger_.Warning("GEO", 293, e);
}
#endif
+2 -2
View File
@@ -40,7 +40,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || d1 < tol || d2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -88,7 +88,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) {
const double det = a1*b2 - a2*b1;
if (std::fabs(det) < 1.e-5) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst);
return nullptr;
}
@@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x1 < tol || w < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -76,7 +76,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
bool trim_cartesian_failed = !trim_cartesian;
if (trim_cartesian) {
if ((pnts[0]->ccomponents() - pnts[1]->ccomponents()).norm() < (2 * tol)) {
Logger::Message(Logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst);
return nullptr;
}
tc->start = pnts[0];
+1 -1
View File
@@ -54,7 +54,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcUShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || d1 < tol || d2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcZShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || dx < tol || dy < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst);
return nullptr;
}
+32 -32
View File
@@ -1,4 +1,4 @@
/********************************************************************************
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
@@ -32,8 +32,8 @@ using namespace IfcGeom;
namespace {
struct POSTFIX_SCHEMA(factory_t) {
abstract_mapping* operator()(IfcParse::IfcFile* file, Settings& settings) const {
ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file, settings);
abstract_mapping* operator()(IfcParse::IfcFile* file, Settings& settings, Logger& logger) const {
ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file, settings, logger);
return m;
}
};
@@ -83,7 +83,7 @@ IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchem
try {
target = taxonomy::cast<taxonomy::matrix4>(map(item->MappingTarget()));
} catch (const std::exception& e) {
Logger::Error("GEO", 300, e);
logger_.Error("GEO", 300, e);
continue;
}
if (!target->is_identity()) {
@@ -332,7 +332,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
try {
associated_material = (*associated_materials->begin())->RelatingMaterial();
} catch(IfcParse::IfcException& e) {
Logger::Error("GEO", 301, e.what());
logger_.Error("GEO", 301, e.what());
}
if (associated_material) {
@@ -344,7 +344,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
IfcSchema::IfcMaterialLayerSet* layerset;
if (auto *m = associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>()) {
if (m->get("ForLayerSet").isNull()) {
Logger::Warning("GEO", 302, "Missing ForLayerSet for:", m);
logger_.Warning("GEO", 302, "Missing ForLayerSet for:", m);
return nullptr;
}
layerset = m->ForLayerSet();
@@ -363,7 +363,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
IfcSchema::IfcMaterialProfileSet* profileset;
if (auto* m = associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>()) {
if (m->get("ForProfileSet").isNull()) {
Logger::Warning("GEO", 303, "Missing ForProfileSet for:", m);
logger_.Warning("GEO", 303, "Missing ForProfileSet for:", m);
return nullptr;
}
profileset = m->ForProfileSet();
@@ -408,7 +408,7 @@ IfcSchema::IfcRepresentation* mapping::representation_mapped_to(const IfcSchema:
try {
target = taxonomy::cast<taxonomy::matrix4>(map(mapped_item->MappingTarget()));
} catch (const std::exception& e) {
Logger::Error("GEO", 304, e);
logger_.Error("GEO", 304, e);
}
if (target && target->is_identity()) {
IfcSchema::IfcRepresentationMap* rmap = mapped_item->MappingSource();
@@ -571,7 +571,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) {
failed_on_purpose_.insert(material);
return nullptr;
}
Logger::Warning("UNS", 19, "Skipping unsupported material style for material: ", material);
logger_.Warning("UNS", 19, "Skipping unsupported material style for material: ", material);
}
}
@@ -605,7 +605,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
if (style == nullptr) {
// E.g. IfcCurveStyle is skipped as unsupported.
Logger::Warning("GEO", 305, "Only IfcSurfaceStyle is supported, couldn't find it in IfcStyledItem: ", inst);
logger_.Warning("GEO", 305, "Only IfcSurfaceStyle is supported, couldn't find it in IfcStyledItem: ", inst);
failed_on_purpose_.insert(inst);
return nullptr;
}
@@ -700,7 +700,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle* style) {
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
if (inst == nullptr) {
Logger::Error("GEO", 306, "Warning nullptr passed to map() function");
logger_.Error("GEO", 306, "Warning nullptr passed to map() function");
return nullptr;
}
auto iden = inst->as<IfcUtil::IfcBaseClass>()->identity();
@@ -727,7 +727,7 @@ taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
cache_.insert({iden, item});
}
} else if (!matched) {
Logger::Message(Logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst);
}
return item;
}
@@ -833,10 +833,10 @@ void mapping::initialize_units_() {
auto* project = *projects->begin();
unit_assignment = project->UnitsInContext();
} else {
Logger::Warning("GEO", 308, "Not a single project or context in file");
logger_.Warning("GEO", 308, "Not a single project or context in file");
}
if (unit_assignment == nullptr) {
Logger::Warning("GEO", 309, "Unable to detect unit information");
logger_.Warning("GEO", 309, "Unable to detect unit information");
return;
}
@@ -845,7 +845,7 @@ void mapping::initialize_units_() {
try {
auto units = unit_assignment->Units();
if (!units || !units->size()) {
Logger::Warning("GEO", 310, "No unit information found");
logger_.Warning("GEO", 310, "No unit information found");
} else {
for (auto it = units->begin(); it != units->end(); ++it) {
IfcSchema::IfcUnit* base = *it;
@@ -882,15 +882,15 @@ void mapping::initialize_units_() {
} catch (const IfcParse::IfcException& ex) {
std::stringstream ss;
ss << "Failed to determine unit information '" << ex.what() << "'";
Logger::Message(Logger::LOG_ERROR, "GEO", 311, ss.str());
logger_.Message(Logger::LOG_ERROR, "GEO", 311, ss.str());
}
if (!length_unit_encountered) {
Logger::Warning("GEO", 312, "No length unit encountered");
logger_.Warning("GEO", 312, "No length unit encountered");
}
if (!angle_unit_encountered) {
Logger::Warning("GEO", 313, "No plane angle unit encountered");
logger_.Warning("GEO", 313, "No plane angle unit encountered");
}
// @todo move to a more descriptive function
@@ -907,7 +907,7 @@ void mapping::initialize_units_() {
if (vs.size() == 3) {
offset_and_rotation_ *= Eigen::Affine3d(Eigen::Translation3d(vs[0], vs[1], vs[2])).matrix();
} else {
Logger::Error("SYS", 31, "Expected 3 values for model-offset setting");
logger_.Error("SYS", 31, "Expected 3 values for model-offset setting");
}
}
@@ -920,7 +920,7 @@ void mapping::initialize_units_() {
m4 << m3;
offset_and_rotation_ *= m4;
} else {
Logger::Error("SYS", 32, "Expected 4 values for model-rotation setting");
logger_.Error("SYS", 32, "Expected 4 values for model-rotation setting");
}
}
}
@@ -970,7 +970,7 @@ void mapping::initialize_settings() {
if (any_precision_encountered) {
if (lowest_precision_encountered < 1.e-7) {
Logger::Message(Logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced");
logger_.Message(Logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced");
precision_to_set = 1.e-7;
} else {
precision_to_set = lowest_precision_encountered;
@@ -1007,7 +1007,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
IfcSchema::IfcRepresentation* body_representation = find_representation(product, "Body");
if (!body_representation) {
Logger::Warning("GEO", 314, "No body representation for product", product);
logger_.Warning("GEO", 314, "No body representation for product", product);
return false;
}
@@ -1021,7 +1021,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
IfcSchema::IfcRepresentation* axis_representation = find_representation(product, "Axis");
if (!axis_representation) {
Logger::Message(Logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product);
logger_.Message(Logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product);
return false;
}
@@ -1090,7 +1090,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
IfcSchema::IfcExtrudedAreaSolid::list::ptr extrusions = IfcParse::traverse(body_representation)->as<IfcSchema::IfcExtrudedAreaSolid>();
if (extrusions->size() != 1) {
Logger::Message(Logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product);
logger_.Message(Logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product);
return false;
}
@@ -1105,7 +1105,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
if (has_position) {
auto m4 = taxonomy::cast<taxonomy::matrix4>(map(extrusion->Position()));
if (!m4) {
Logger::Message(Logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product);
return false;
} else {
extrusion_position = m4;
@@ -1115,7 +1115,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
taxonomy::direction3::ptr extrusion_direction = taxonomy::cast<taxonomy::direction3>(map(extrusion->ExtrudedDirection()));
if (!extrusion_direction) {
Logger::Message(Logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product);
return false;
}
@@ -1189,12 +1189,12 @@ void mapping::addRepresentationsFromContextIds(IfcSchema::IfcRepresentation::lis
try {
context = file_->instance_by_id(context_id)->as<IfcSchema::IfcGeometricRepresentationContext>();
} catch (IfcParse::IfcException& e) {
Logger::Error("GEO", 319, e);
logger_.Error("GEO", 319, e);
continue;
}
if (!context) {
Logger::Error("GEO", 320, "Failed to process context ID " + std::to_string(context_id));
logger_.Error("GEO", 320, "Failed to process context ID " + std::to_string(context_id));
continue;
}
@@ -1243,14 +1243,14 @@ void mapping::addRepresentationsFromDefaultContexts(IfcSchema::IfcRepresentation
boost::to_lower(context_type);
if (allowed_context_types.find(context_type) == allowed_context_types.end()) {
Logger::Warning("GEO", 321, std::string("ContextType '") + *context->ContextType() + "' not allowed:", context);
logger_.Warning("GEO", 321, std::string("ContextType '") + *context->ContextType() + "' not allowed:", context);
}
if (context_types.find(context_type) != context_types.end()) {
filtered_contexts->push(context);
}
}
} catch (const std::exception& e) {
Logger::Error("GEO", 322, e);
logger_.Error("GEO", 322, e);
}
}
@@ -1280,7 +1280,7 @@ void mapping::addRepresentationsFromDefaultContexts(IfcSchema::IfcRepresentation
}
if (representations->size() == 0) {
Logger::Warning("GEO", 323, "No representations encountered in relevant contexts, using all");
logger_.Warning("GEO", 323, "No representations encountered in relevant contexts, using all");
representations->push(file_->instances_by_type<IfcSchema::IfcRepresentation>());
}
}
@@ -1326,7 +1326,7 @@ IfcUtil::IfcBaseEntity* mapping::representation_of(const IfcUtil::IfcBaseEntity*
intersection_no_box->push(r);
}
if (intersection_no_box->size() > 1) {
Logger::Warning("GEO", 324, "Multiple applicable representations found for element, selecting arbitrary");
logger_.Warning("GEO", 324, "Multiple applicable representations found for element, selecting arbitrary");
}
if (intersection_no_box->size()) {
return (*intersection_no_box->begin())->as<IfcUtil::IfcBaseEntity>();
+5 -5
View File
@@ -67,19 +67,19 @@ namespace geometry {
}
}
} catch (const std::exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst);
}
} else if (failed_on_purpose_.find(inst) == failed_on_purpose_.end()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst);
}
} catch (const std::exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst);
}
}
}
const IfcSchema::IfcStyledItem* find_style(const IfcSchema::IfcRepresentationItem*);
public:
POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file, Settings& settings) : abstract_mapping(settings), file_(file), placement_rel_to_type_(0), placement_rel_to_instance_(0) {
POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file, Settings& settings, Logger& logger = Logger::Root()) : abstract_mapping(settings, logger), file_(file), placement_rel_to_type_(0), placement_rel_to_instance_(0) {
initialize_units_();
}
virtual ifcopenshell::geometry::taxonomy::ptr map(const IfcUtil::IfcBaseInterface*);
@@ -153,4 +153,4 @@ namespace geometry {
}
#endif
#endif
+2 -2
View File
@@ -861,7 +861,7 @@ boost::optional<function_item::ptr> ifcopenshell::geometry::taxonomy::loop_to_fu
spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn));
} else if (edge_->start.which() == 1 && edge_->end.which() == 1) {
if (edge_->basis && edge_->basis->kind() != LINE) {
Logger::Message(Logger::Severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge");
Logger::Root().Message(Logger::Severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge");
}
const auto& s = boost::get<point3::ptr>(edge_->start)->ccomponents();
const auto& e = boost::get<point3::ptr>(edge_->end)->ccomponents();
@@ -876,7 +876,7 @@ boost::optional<function_item::ptr> ifcopenshell::geometry::taxonomy::loop_to_fu
};
spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn));
} else {
Logger::Message(Logger::Severity::LOG_ERROR, "UNS", 21, "Basis curve not supported");
Logger::Root().Message(Logger::Severity::LOG_ERROR, "UNS", 21, "Basis curve not supported");
return boost::none;
}
}
+1 -1
View File
@@ -641,7 +641,7 @@ int main () {
}
case GET_LOG: {
GetLog gl; gl.read(std::cin);
WriteLog(Logger::GetLog()).write(std::cout);
WriteLog(Logger::Root().GetLog()).write(std::cout);
continue;
}
case BYE: {
@@ -95,6 +95,7 @@ from .entity_instance import entity_instance, register_schema_attributes
from .file import file, rocksdb_lazy_instance
from .file import file as _file
from .sql import sqlite, sqlite_entity
from .ifcopenshell_wrapper import get_log, logger
# explicitly specify available imported symbols
# (it's a requirement for a typed library)
@@ -389,4 +390,3 @@ def convert_path_to_rocksdb(ifcspf_path: Union[Path, str], rocksdb_path: Union[P
version_core = ifcopenshell_wrapper.version()
__version__ = version = "0.0.0"
get_log = ifcopenshell_wrapper.get_log
@@ -461,6 +461,7 @@ def create_shape(
inst: entity_instance,
repr: Optional[entity_instance] = None,
geometry_library: GEOMETRY_LIBRARY = "opencascade",
logger: Optional[ifcopenshell.logger] = None,
) -> Union[ShapeType, ShapeElementType, ifcopenshell_wrapper.Transformation, utils.shape_tuple, TopoDS.TopoDS_Shape]:
"""
Returns a geometric interpretation of the IFC entity instance
@@ -507,7 +508,7 @@ def create_shape(
return wrap_shape_creation(
settings,
ifcopenshell_wrapper.create_shape(
settings, inst.wrapped_data, repr.wrapped_data if repr is not None else None, geometry_library
settings, inst.wrapped_data, repr.wrapped_data if repr is not None else None, geometry_library, *(filter(None, (logger,)))
),
)
@@ -2,7 +2,7 @@ ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]','RevitIdentifiers [ContentGUID: a0df3484-2dab-42c5-b806-8c10d313bee0, VersionGUID: 658c1394-f3a4-43d1-9b3c-eee44a0cd67a, NumberOfSaves: 2]','CoordinateReference [CoordinateBase: Shared Coordinates]'),'2;1');
FILE_NAME('Column_4x3.ifc','2025-03-12T13:53:30+00:00',(''),(''),'ODA SDAI 24.12','Autodesk Revit 25.4.0.32 (ENG) - IFC 25.4.0.32','');
FILE_SCHEMA(('IFC4X3_ADD2'));
FILE_SCHEMA(('IFC2X3'));
ENDSEC;
DATA;
#1=IFCORGANIZATION($,'Autodesk Revit 2025 (ENG)',$,$,$);
@@ -216,6 +216,26 @@ def test_iterator():
assert iterator.initialize()
def test_logging():
logger = ifcopenshell.logger()
logger.OutputFormat(logger.FMT_INMEMORY)
settings = ifcopenshell.geom.settings()
f = ifcopenshell.open(fn)
col = f.by_type("IfcColumn")[0]
_ = ifcopenshell.geom.create_shape(settings, col, logger=logger)
num_log_items = len(list(logger))
col.Representation.Representations[0].Items[0].MappingSource.MappedRepresentation.Items[0].Depth *= -1.0
with pytest.raises(RuntimeError):
_ = ifcopenshell.geom.create_shape(settings, col, logger=logger)
new_items = list(logger)[num_log_items:]
assert ("GEO089", "Non-positive extrusion height encountered for:") in [
(msg.code, msg.message) for msg in new_items
]
if __name__ == "__main__":
import pytest
+13 -13
View File
@@ -412,7 +412,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
} else if (cant) {
result = mapAlignmentCantSegment(cant);
} else {
Logger::Error("VAL", 8, std::string("Unexpected IfcAlignmentSegment subtype encountered"));
Logger::Root().Error("VAL", 8, std::string("Unexpected IfcAlignmentSegment subtype encountered"));
}
return result;
}
@@ -661,9 +661,9 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
result.first = curve_segment;
} else if (type == Ifc4x3_add2::IfcAlignmentHorizontalSegmentTypeEnum::IfcAlignmentHorizontalSegmentType_VIENNESEBEND) {
Logger::Warning("UNS", 22, std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported"));
Logger::Root().Warning("UNS", 22, std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported"));
} else {
Logger::Error("VAL", 9, std::string("unexpected AlignmentHorizontalSegmentType encountered"));
Logger::Root().Error("VAL", 9, std::string("unexpected AlignmentHorizontalSegmentType encountered"));
}
return result;
@@ -732,7 +732,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
result.first = curve_segment;
} else if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CLOTHOID) {
Logger::Warning("UNS", 23, std::string("mapping of AlignmentVerticalSegmentType CLOTHOID not supported"));
Logger::Root().Warning("UNS", 23, std::string("mapping of AlignmentVerticalSegmentType CLOTHOID not supported"));
} else if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CIRCULARARC) {
auto start_angle = atan(start_gradient);
auto end_angle = atan(end_gradient);
@@ -760,7 +760,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
result.first = curve_segment;
} else {
Logger::Error("VAL", 10, std::string("unexpected AlignmentVerticalSegmentType encountered"));
Logger::Root().Error("VAL", 10, std::string("unexpected AlignmentVerticalSegmentType encountered"));
}
return result;
@@ -770,21 +770,21 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> result(nullptr, nullptr);
auto type = segment->PredefinedType();
if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) {
Logger::Warning("UNS", 24, std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported"));
Logger::Root().Warning("UNS", 24, std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported"));
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_CONSTANTCANT) {
Logger::Warning("UNS", 25, std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported"));
Logger::Root().Warning("UNS", 25, std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported"));
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_COSINECURVE) {
Logger::Warning("UNS", 26, std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported"));
Logger::Root().Warning("UNS", 26, std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported"));
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_HELMERTCURVE) {
Logger::Warning("UNS", 27, std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported"));
Logger::Root().Warning("UNS", 27, std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported"));
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_LINEARTRANSITION) {
Logger::Warning("UNS", 28, std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported"));
Logger::Root().Warning("UNS", 28, std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported"));
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_SINECURVE) {
Logger::Warning("UNS", 29, std::string("mapping of AlignmentCantSegmentType SINECURVE not supported"));
Logger::Root().Warning("UNS", 29, std::string("mapping of AlignmentCantSegmentType SINECURVE not supported"));
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_VIENNESEBEND) {
Logger::Warning("UNS", 30, std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported"));
Logger::Root().Warning("UNS", 30, std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported"));
} else {
Logger::Error("VAL", 11, std::string("unexpected AlignmentCantSegmentType encountered"));
Logger::Root().Error("VAL", 11, std::string("unexpected AlignmentCantSegmentType encountered"));
}
return result;
}
+1 -1
View File
@@ -137,7 +137,7 @@ namespace {
parse_state += PAGE;
} else if (IS_HEXADECIMAL(current_char) && EXPECTS_HEX(parse_state)) {
if (IS_LOWERCASE_HEX(current_char)) {
Logger::Warning("SYN", 2, "Lowercase hexadecimal character '" + std::string(1, current_char) +
Logger::Root().Warning("SYN", 2, "Lowercase hexadecimal character '" + std::string(1, current_char) +
"' found at offset " + std::to_string(stream_.tell()) +
". It is recommended to use uppercase for hexadecimal.");
}
+12 -12
View File
@@ -72,10 +72,10 @@ namespace {
try {
fn(EnumerationReference(decl->as_enumeration_type(), decl->as_enumeration_type()->lookup_enum_offset(s)));
} catch (IfcParse::IfcException& e) {
Logger::Error("VAL", 12, "An enumeration literal '" + s + "' is not valid for type '" + decl->name() + "' at offset " + std::to_string(t.startPos));
Logger::Root().Error("VAL", 12, "An enumeration literal '" + s + "' is not valid for type '" + decl->name() + "' at offset " + std::to_string(t.startPos));
}
} else {
Logger::Error("VAL", 13, "An enumeration literal '" + s + "' is not expected at attribute index '" + std::to_string(attribute_id) + "' at offset " + std::to_string(t.startPos));
Logger::Root().Error("VAL", 13, "An enumeration literal '" + s + "' is not expected at attribute index '" + std::to_string(attribute_id) + "' at offset " + std::to_string(t.startPos));
}
} else if (t.type == IfcParse::Token_FLOAT) {
fn(IfcParse::TokenFunc::asFloat(t));
@@ -194,7 +194,7 @@ namespace {
}
}, aggregate_storage);
Logger::Error("VAL", 14, "Inconsistent aggregate valuation while attempting to append " + std::string(typeid(decltype(v)).name()) + " to an aggregate of " + current);
Logger::Root().Error("VAL", 14, "Inconsistent aggregate valuation while attempting to append " + std::string(typeid(decltype(v)).name()) + " to an aggregate of " + current);
// @todo boolean -> logical upgrade
// wait a second... there are no aggregate of bool / logical in the schema..
@@ -213,7 +213,7 @@ namespace {
}
} else {
// @todo would be cool if we can trace this back to file offset
Logger::Error("UNS", 31, std::string("Aggregates of ") + typeid(decltype(v)).name() + " are not supported in the IfcOpenShell parser");
Logger::Root().Error("UNS", 31, std::string("Aggregates of ") + typeid(decltype(v)).name() + " are not supported in the IfcOpenShell parser");
}
};
@@ -263,9 +263,9 @@ IfcEntityInstanceData IfcParse::parse_context::construct(boost::optional<size_t>
{
size_t expected = expected_size ? *expected_size : parameter_types.size();
if (decl != nullptr && decl->schema() == &Header_section_schema::get_schema()) {
Logger::Warning("VAL", 15, "Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + " for header entity " + decl->name());
Logger::Root().Warning("VAL", 15, "Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + " for header entity " + decl->name());
} else {
Logger::Warning("VAL", 16, "Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + (name ? std::string(" for instance #" + std::to_string(*name)) : std::string("")));
Logger::Root().Warning("VAL", 16, "Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + (name ? std::string(" for instance #" + std::to_string(*name)) : std::string("")));
}
}
@@ -719,13 +719,13 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
try {
entity_type = schema_->declaration_by_name(TokenFunc::asStringRef(token_stream_[2]));
} catch (const IfcException& ex) {
Logger::Message(Logger::LOG_ERROR, "SYN", 3, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].startPos));
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 3, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].startPos));
current_id = 0;
goto advance;
}
if (entity_type->as_entity() == nullptr) {
Logger::Message(Logger::LOG_ERROR, "SYN", 4, "Non entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].startPos));
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 4, "Non entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].startPos));
goto advance;
}
@@ -744,7 +744,7 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
storage_.load(current_id, entity_type->as_entity(), ps, -1);
} catch (const IfcInvalidTokenException& e) {
good_ = file_open_status::INVALID_SYNTAX;
Logger::Error("SYN", 5, e);
Logger::Root().Error("SYN", 5, e);
break;
}
@@ -753,7 +753,7 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
if (((++progress_) % 1000) == 0) {
std::stringstream ss;
ss << "\r#" << current_id;
Logger::Status(ss.str(), false);
Logger::Root().Status(ss.str(), false);
}
auto data = ps.construct(current_id, references_to_resolve_, entity_type, boost::none, -1, coerce_attribute_count);
@@ -769,9 +769,9 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
try {
next_token = lexer_->Next();
} catch (const IfcException& e) {
Logger::Message(Logger::LOG_ERROR, "SYN", 6, std::string(e.what()) + ". Parsing terminated");
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 6, std::string(e.what()) + ". Parsing terminated");
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "SYN", 7, "Parsing terminated");
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 7, "Parsing terminated");
}
if (!lexer_->stream->eof() && next_token.type == Token_NONE) {
+2 -2
View File
@@ -111,7 +111,7 @@ IfcParse::IfcGlobalId::IfcGlobalId() {
boost::uuids::uuid test_uuid;
std::copy(test_vector.begin(), test_vector.end(), test_uuid.begin());
if (uuid_data_ != test_uuid) {
Logger::Message(Logger::LOG_ERROR, "SYS", 34, "Internal error generating GlobalId");
Logger::Root().Message(Logger::LOG_ERROR, "SYS", 34, "Internal error generating GlobalId");
}
#endif
}
@@ -130,7 +130,7 @@ IfcParse::IfcGlobalId::IfcGlobalId(const std::string& string)
#ifndef NDEBUG
const std::string test_string = compress(&uuid_data_.data[0]);
if (string_data_ != test_string) {
Logger::Message(Logger::LOG_ERROR, "SYS", 35, "Internal error generating GlobalId");
Logger::Root().Message(Logger::LOG_ERROR, "SYS", 35, "Internal error generating GlobalId");
}
#endif
}
+1 -1
View File
@@ -159,7 +159,7 @@ void IfcHierarchyHelper<Schema>::relatePlacements(typename Schema::IfcProduct* p
if (local_place != parent->ObjectPlacement()) {
local_place->setPlacementRelTo(parent->ObjectPlacement());
} else {
Logger::Notice("SYN", 8, "Placement cannot be relative to self");
Logger::Root().Notice("SYN", 8, "Placement cannot be relative to self");
}
}
}
+2 -2
View File
@@ -454,9 +454,9 @@ class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile {
break;
}
} catch (std::exception& e) {
Logger::Error("SYN", 9, e);
Logger::Root().Error("SYN", 9, e);
} catch (...) {
Logger::Error("SYN", 10, "Unknown error in addRelatedObject()");
Logger::Root().Error("SYN", 10, "Unknown error in addRelatedObject()");
}
}
if (!found) {
+32 -26
View File
@@ -31,9 +31,8 @@
#include <ctime>
#include <iomanip>
#include <iostream>
#include <mutex>
static my_thread_local const IfcUtil::IfcBaseClass* current_product_;
static my_thread_local std::map<const Logger*, const IfcUtil::IfcBaseClass*> current_products_;
namespace {
@@ -134,6 +133,24 @@ void json_message(T& out, const IfcUtil::IfcBaseClass* current_product, Logger::
}
} // namespace
Logger& Logger::Root() {
static Logger logger;
return logger;
}
const IfcUtil::IfcBaseClass* Logger::current_product() const {
auto it = current_products_.find(this);
return it == current_products_.end() ? nullptr : it->second;
}
void Logger::current_product(const IfcUtil::IfcBaseClass* product) {
if (product) {
current_products_[this] = product;
} else {
current_products_.erase(this);
}
}
void Logger::SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product) {
if (verbosity_ <= LOG_DEBUG && product) {
Message(LOG_DEBUG, "SYS", 3, "Begin processing", *product);
@@ -142,7 +159,7 @@ void Logger::SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product) {
PrintPerformanceStats();
performance_statistics_.clear();
}
current_product_ = product.get_value_or(nullptr);
current_product(product.get_value_or(nullptr));
}
void Logger::SetOutput(std::ostream* stream1, std::ostream* stream2) {
@@ -168,8 +185,7 @@ void Logger::Message(Logger::Severity type, const char (&code_prefix)[4], uint16
return;
}
static std::mutex mtx;
std::lock_guard<std::mutex> lock(mtx);
std::lock_guard<std::mutex> lock(mutex_);
const std::string code = format_code(code_prefix, code_number);
if (type == LOG_PERF) {
@@ -188,18 +204,21 @@ void Logger::Message(Logger::Severity type, const char (&code_prefix)[4], uint16
if (type > max_severity_) {
max_severity_ = type;
}
if (((log2_ != nullptr) || (wlog2_ != nullptr))) {
if (format_ == FMT_INMEMORY) {
log_messages_.emplace_back(type, code_prefix, code_number, message, instance);
} else if (((log2_ != nullptr) || (wlog2_ != nullptr))) {
if (format_ == FMT_PLAIN) {
if (log2_ != nullptr) {
plain_text_message(*log2_, current_product_, type, code, message, instance);
plain_text_message(*log2_, current_product(), type, code, message, instance);
} else if (wlog2_ != nullptr) {
plain_text_message(*wlog2_, current_product_, type, code, message, instance);
plain_text_message(*wlog2_, current_product(), type, code, message, instance);
}
} else if (format_ == FMT_JSON) {
if (log2_ != nullptr) {
json_message(*log2_, current_product_, type, code, message, instance);
json_message(*log2_, current_product(), type, code, message, instance);
} else if (wlog2_ != nullptr) {
json_message(*wlog2_, current_product_, type, code, message, instance);
json_message(*wlog2_, current_product(), type, code, message, instance);
}
}
}
@@ -258,22 +277,9 @@ void Logger::PrintPerformanceStats() {
}
void Logger::Verbosity(Logger::Severity severity) { verbosity_ = severity; }
Logger::Severity Logger::Verbosity() { return verbosity_; }
Logger::Severity Logger::Verbosity() const { return verbosity_; }
Logger::Severity Logger::MaxSeverity() { return max_severity_; }
Logger::Severity Logger::MaxSeverity() const { return max_severity_; }
void Logger::OutputFormat(Format format) { format_ = format; }
Logger::Format Logger::OutputFormat() { return format_; }
std::ostream* Logger::log1_ = 0;
std::ostream* Logger::log2_ = 0;
std::wostream* Logger::wlog1_ = 0;
std::wostream* Logger::wlog2_ = 0;
std::stringstream Logger::log_stream_;
Logger::Severity Logger::verbosity_ = Logger::LOG_NOTICE;
Logger::Severity Logger::max_severity_ = Logger::LOG_NOTICE;
Logger::Format Logger::format_ = Logger::FMT_PLAIN;
boost::optional<long long> Logger::first_timepoint_;
std::map<std::string, double> Logger::performance_statistics_;
std::map<std::string, double> Logger::performance_signal_start_;
bool Logger::print_perf_stats_on_element_ = false;
Logger::Format Logger::OutputFormat() const { return format_; }
+72 -36
View File
@@ -28,9 +28,29 @@
#include <cstdint>
#include <exception>
#include <map>
#include <mutex>
#include <sstream>
#include <string>
class IFC_PARSE_API log_message {
public:
char code[7];
int severity;
std::string message, instance;
log_message(int severity, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* inst = 0)
: severity(severity)
, message(message)
{
snprintf(code, 7, "%s%03u", code_prefix, code_number);
if (inst) {
std::ostringstream oss;
inst->data().toString(nullptr, nullptr, 0, oss, true);
instance = oss.str();
}
}
};
class IFC_PARSE_API Logger {
public:
typedef enum {
@@ -40,76 +60,92 @@ class IFC_PARSE_API Logger {
LOG_WARNING,
LOG_ERROR
} Severity;
typedef enum {
FMT_PLAIN,
FMT_JSON
FMT_JSON,
FMT_INMEMORY
} Format;
private:
std::vector<log_message> log_messages_;
// To both stream variants need to exist at runtime or should this be a
// template argument of Logger or controlled using preprocessor directives?
static std::ostream* log1_;
static std::ostream* log2_;
std::ostream* log1_ = nullptr;
std::ostream* log2_ = nullptr;
static std::wostream* wlog1_;
static std::wostream* wlog2_;
std::wostream* wlog1_ = nullptr;
std::wostream* wlog2_ = nullptr;
static std::stringstream log_stream_;
std::stringstream log_stream_;
static Severity verbosity_;
static Format format_;
static Severity max_severity_;
Severity verbosity_ = LOG_NOTICE;
Format format_ = FMT_PLAIN;
Severity max_severity_ = LOG_NOTICE;
static boost::optional<long long> first_timepoint_;
static std::map<std::string, double> performance_statistics_;
static std::map<std::string, double> performance_signal_start_;
boost::optional<long long> first_timepoint_;
std::map<std::string, double> performance_statistics_;
std::map<std::string, double> performance_signal_start_;
static bool print_perf_stats_on_element_;
bool print_perf_stats_on_element_ = false;
std::mutex mutex_;
const IfcUtil::IfcBaseClass* current_product() const;
void current_product(const IfcUtil::IfcBaseClass* product);
public:
static void SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product);
Logger() = default;
Logger(const Logger&) = delete;
Logger& operator=(const Logger&) = delete;
static Logger& Root();
void SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product);
/// Determines to what stream respectively progress and errors are logged
static void SetOutput(std::wostream* stream1, std::wostream* stream2);
void SetOutput(std::wostream* stream1, std::wostream* stream2);
/// Determines to what stream respectively progress and errors are logged
static void SetOutput(std::ostream* stream1, std::ostream* stream2);
void SetOutput(std::ostream* stream1, std::ostream* stream2);
/// Determines the types of log messages to get logged
static void Verbosity(Severity severity);
static Severity Verbosity();
static Severity MaxSeverity();
void Verbosity(Severity severity);
Severity Verbosity() const;
Severity MaxSeverity() const;
/// Determines output format: plain text or sequence of JSON objects
static void OutputFormat(Format format);
static Format OutputFormat();
void OutputFormat(Format format);
Format OutputFormat() const;
/// Log a message to the output stream
static void Message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0);
static void Message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0);
void Message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0);
void Message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0);
static void Notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, message, instance); }
static void Warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, message, instance); }
static void Error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, message, instance); }
void Notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, message, instance); }
void Warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, message, instance); }
void Error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, message, instance); }
static void Notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, exception, instance); }
static void Warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, exception, instance); }
static void Error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, exception, instance); }
void Notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, exception, instance); }
void Warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, exception, instance); }
void Error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, exception, instance); }
static void Status(const std::string& message, bool new_line = true);
void Status(const std::string& message, bool new_line = true);
static void ProgressBar(int progress);
static std::string GetLog();
static void PrintPerformanceStats();
static void PrintPerformanceStatsOnElement(bool b) { print_perf_stats_on_element_ = b; }
void ProgressBar(int progress);
std::string GetLog();
void PrintPerformanceStats();
void PrintPerformanceStatsOnElement(bool b) { print_perf_stats_on_element_ = b; }
const std::vector<log_message>& log_messages() const { return log_messages_; }
};
#define PERF(x) \
\
Logger::Message(Logger::LOG_PERF, "SYS", 1, x); \
Logger::Root().Message(Logger::LOG_PERF, "SYS", 1, x); \
\
BOOST_SCOPE_EXIT(void) { \
Logger::Message(Logger::LOG_PERF, "SYS", 2, "done " + std::string(x)); \
Logger::Root().Message(Logger::LOG_PERF, "SYS", 2, "done " + std::string(x)); \
} \
BOOST_SCOPE_EXIT_END
+24 -24
View File
@@ -320,7 +320,7 @@ Token IfcParse::GeneralTokenPtr(IfcSpfLexer* lexer, size_t start, const std::str
if (first == '#') {
token.type = Token_IDENTIFIER;
if (!ParseInt(tokenStr.c_str() + 1, token.value_int)) {
Logger::Message(Logger::LOG_ERROR, "SYN", 11, "Token '" + tokenStr + "' at offset " + std::to_string(token.startPos) + " is not valid");
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 11, "Token '" + tokenStr + "' at offset " + std::to_string(token.startPos) + " is not valid");
token.type = Token_OPERATOR;
token.value_char = '$';
}
@@ -568,7 +568,7 @@ void IfcParse::impl::in_memory_file_storage::load(boost::optional<size_t> entity
context.push(simple_type_instance);
simple_type_instance->file_ = file;
} catch (IfcException& e) {
Logger::Message(Logger::LOG_ERROR, "SYN", 12, std::string(e.what()) + " at offset " + std::to_string(next.startPos));
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 12, std::string(e.what()) + " at offset " + std::to_string(next.startPos));
// #4070 We didn't actually capture an aggregate entry, undo length increment.
return_value--;
}
@@ -663,7 +663,7 @@ void IfcParse::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from,
if (it != vals.end()) {
vals.erase(it);
} else {
Logger::Error("VAL", 17, "Unregistering non-existant inverse #" + std::to_string(id_from) + " on instance #" + std::to_string(inst_id) + " at attribute " + std::to_string(attribute_index));
Logger::Root().Error("VAL", 17, "Unregistering non-existant inverse #" + std::to_string(id_from) + " on instance #" + std::to_string(inst_id) + " at attribute " + std::to_string(attribute_index));
}
s.resize(vals.size() * sizeof(uint32_t));
memcpy(s.data(), vals.data(), s.size());
@@ -1122,7 +1122,7 @@ IfcUtil::IfcBaseClass::set_attribute_value(size_t i, const T& t) {
}
}
} catch (IfcParse::IfcException& e) {
Logger::Error("SYN", 13, e);
Logger::Root().Error("SYN", 13, e);
}
}
@@ -1159,11 +1159,11 @@ IfcUtil::IfcBaseClass::set_attribute_value(size_t i, const T& t) {
auto guid = (std::string) new_attribute;
auto it = file_->internal_guid_map().find(guid);
if (it != file_->internal_guid_map().end()) {
Logger::Warning("VAL", 18, "Duplicate guid " + guid);
Logger::Root().Warning("VAL", 18, "Duplicate guid " + guid);
}
file_->internal_guid_map().insert({ guid, this });
} catch (IfcParse::IfcException& e) {
Logger::Error("SYN", 14, e);
Logger::Root().Error("SYN", 14, e);
}
}
}
@@ -1531,12 +1531,12 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
schema = IfcParse::schema_by_name(schemas.front());
} catch (const IfcParse::IfcException& e) {
good_ = file_open_status::UNSUPPORTED_SCHEMA;
Logger::Error("SYN", 15, e);
Logger::Root().Error("SYN", 15, e);
}
}
if (schema == nullptr) {
Logger::Message(Logger::LOG_ERROR, "UNS", 32, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
Logger::Root().Message(Logger::LOG_ERROR, "UNS", 32, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
return;
}
@@ -1545,7 +1545,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
InstanceStreamer streamer(schema, tokens);
streamer.bypassTypes(typed_to_bypass);
Logger::Status("Scanning file...");
Logger::Root().Status("Scanning file...");
while (streamer) {
@@ -1569,11 +1569,11 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
if (byguid_.find(guid) != byguid_.end()) {
std::stringstream ss;
ss << "Instance encountered with non-unique GlobalId " << guid;
Logger::Message(Logger::LOG_WARNING, "SYN", 16, ss.str());
Logger::Root().Message(Logger::LOG_WARNING, "SYN", 16, ss.str());
}
byguid_[guid] = instance;
} catch (const IfcException& ex) {
Logger::Message(Logger::LOG_ERROR, "SYN", 17, ex.what());
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 17, ex.what());
}
}
@@ -1589,7 +1589,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
if (byid_.find(current_id) != byid_.end()) {
std::stringstream ss;
ss << "Overwriting instance with name #" << current_id;
Logger::Message(Logger::LOG_WARNING, "SYN", 18, ss.str());
Logger::Root().Message(Logger::LOG_WARNING, "SYN", 18, ss.str());
}
// byidentity_[instance->identity()] = instance;
@@ -1612,7 +1612,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
inst->file_ = file;
}
Logger::Status("\rDone scanning file ");
Logger::Root().Status("\rDone scanning file ");
delete tokens;
@@ -1632,7 +1632,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
}
auto it = byid_.find(*name);
if (it == byid_.end()) {
Logger::Error("SYN", 19, "Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
Logger::Root().Error("SYN", 19, "Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
} else {
auto* storage = &byid_[p.first.name_]->data();
auto attr_index = p.first.index_;
@@ -1649,7 +1649,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
if (storage->has_attribute_value<Blank>(nullptr, nullptr, 0, attr_index)) {
storage->set_attribute_value(nullptr, nullptr, 0, attr_index, it->second);
} else {
Logger::Error("SYN", 20, "Duplicate definition for instance reference");
Logger::Root().Error("SYN", 20, "Duplicate definition for instance reference");
}
}
} else if (auto* inst = std::get_if<IfcUtil::IfcBaseClass*>(v)) {
@@ -1665,7 +1665,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
}
auto it = byid_.find(*name);
if (it == byid_.end()) {
Logger::Error("SYN", 21, "Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
Logger::Root().Error("SYN", 21, "Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
} else {
instances->push(it->second);
}
@@ -1689,7 +1689,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
if (storage->has_attribute_value<Blank>(nullptr, nullptr, 0, attr_index)) {
storage->set_attribute_value(nullptr, nullptr, 0, attr_index, instances);
} else {
Logger::Error("SYN", 22, "Duplicate definition for instance reference");
Logger::Root().Error("SYN", 22, "Duplicate definition for instance reference");
}
} else if (auto* vvv = std::get_if<std::vector<std::vector<reference_or_simple_type>>>(&p.second)) {
aggregate_of_aggregate_of_instance::ptr instances(new aggregate_of_aggregate_of_instance);
@@ -1702,7 +1702,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
}
auto it = byid_.find(*name);
if (it == byid_.end()) {
Logger::Error("SYN", 23, "Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
Logger::Root().Error("SYN", 23, "Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
} else {
inner.push_back(it->second);
}
@@ -1728,12 +1728,12 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
if (storage->has_attribute_value<Blank>(nullptr, nullptr, 0, attr_index)) {
storage->set_attribute_value(nullptr, nullptr, 0, attr_index, instances);
} else {
Logger::Error("SYN", 24, "Duplicate definition for instance reference");
Logger::Root().Error("SYN", 24, "Duplicate definition for instance reference");
}
}
}
Logger::Status("Done resolving references");
Logger::Root().Status("Done resolving references");
}
void IfcFile::recalculate_id_counter() {
@@ -1893,7 +1893,7 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
}
}
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "SYN", 25, "Failed to visit forward references of", entity);
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 25, "Failed to visit forward references of", entity);
}
// See whether the instance is already part of a file
@@ -2066,11 +2066,11 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
if (byguid_.find(guid) != byguid_.end()) {
std::stringstream ss;
ss << "Overwriting entity with guid " << guid;
Logger::Message(Logger::LOG_WARNING, "SYN", 26, ss.str());
Logger::Root().Message(Logger::LOG_WARNING, "SYN", 26, ss.str());
}
byguid_.insert({ guid, new_entity });
} catch (const std::exception& ex) {
Logger::Message(Logger::LOG_ERROR, "SYN", 27, ex.what());
Logger::Root().Message(Logger::LOG_ERROR, "SYN", 27, ex.what());
}
}
@@ -2243,7 +2243,7 @@ void IfcFile::process_deletion_(IfcUtil::IfcBaseClass* entity) {
if (it != byguid_.end()) {
byguid_.erase(it);
} else {
Logger::Warning("VAL", 19, "GlobalId on rooted instance not encountered in map");
Logger::Root().Warning("VAL", 19, "GlobalId on rooted instance not encountered in map");
}
}
+1 -1
View File
@@ -175,7 +175,7 @@ bool IfcSpfHeader::tryRead() {
read();
return true;
} catch (const std::exception& e) {
Logger::Error("SYN", 28, e);
Logger::Root().Error("SYN", 28, e);
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More