mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
Merge remote-tracking branch 'origin/v0.8.0' into ifcviewer-wgpu
This commit is contained in:
@@ -219,7 +219,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(ifcopenshell::file&, bool, bool, bool);
|
||||
void fix_quantities(ifcopenshell::file&, bool, bool, bool, Logger& logger = Logger::Root());
|
||||
std::string format_duration(time_t start, time_t end);
|
||||
|
||||
/// @todo make the filters non-global
|
||||
@@ -249,7 +249,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<ifcopenshell::geometry::filter_t> setup_filters(const std::vector<geom_filter>&, const std::string&);
|
||||
|
||||
bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties=false);
|
||||
bool init_input_file(const std::string& filename, ifcopenshell::file*& 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 {
|
||||
@@ -271,6 +271,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;
|
||||
@@ -463,15 +464,15 @@ int main(int argc, char** argv) {
|
||||
|
||||
if (num_threads <= 0) {
|
||||
num_threads = std::thread::hardware_concurrency();
|
||||
logger::notice("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::output_format(logger::FMT_PLAIN);
|
||||
logger.OutputFormat(Logger::FMT_PLAIN);
|
||||
} else if (log_format == "json") {
|
||||
logger::output_format(logger::FMT_JSON);
|
||||
logger.OutputFormat(Logger::FMT_JSON);
|
||||
} else {
|
||||
cerr_ << "[error] --log-format should be either plain or json" << std::endl;
|
||||
print_usage();
|
||||
@@ -482,7 +483,7 @@ int main(int argc, char** argv) {
|
||||
if (!filter_filename.empty()) {
|
||||
size_t num_filters = read_filters_from_file(ifcopenshell::path::to_utf8(filter_filename), include_filter, include_traverse_filter, exclude_filter, exclude_traverse_filter);
|
||||
if (num_filters) {
|
||||
logger::notice(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;
|
||||
@@ -546,27 +547,27 @@ int main(int argc, char** argv) {
|
||||
|
||||
if (vmap.count("log-file")) {
|
||||
log_fs.open(log_file.c_str(), std::ios::app);
|
||||
logger::set_output(quiet ? nullptr : &cout_, &log_fs);
|
||||
logger.SetOutput(quiet ? nullptr : &cout_, &log_fs);
|
||||
} else {
|
||||
logger::set_output(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::print_performance_stats_on_element(true);
|
||||
logger.Verbosity(Logger::LOG_PERF);
|
||||
logger.PrintPerformanceStatsOnElement(true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -620,12 +621,12 @@ int main(int argc, char** argv) {
|
||||
if (serializer->is_streaming() != use_input_filename) {
|
||||
throw ifcopenshell::exception("Selected document serializer streaming mode does not match its registry metadata");
|
||||
}
|
||||
logger::status("Writing " + boost::to_upper_copy(document_serializer_info->format) + " output...");
|
||||
logger.status("Writing " + boost::to_upper_copy(document_serializer_info->format) + " output...");
|
||||
serializer->finalize();
|
||||
serializer.reset();
|
||||
|
||||
time(&end);
|
||||
logger::status("Done! Conversion took " + format_duration(start, end));
|
||||
logger.status("Done! Conversion took " + format_duration(start, end));
|
||||
|
||||
if (!document_serializer_info->writes_final_output &&
|
||||
!ifcopenshell::path::rename_file(ifcopenshell::path::to_utf8(output_temp_filename), ifcopenshell::path::to_utf8(output_filename))) {
|
||||
@@ -636,7 +637,7 @@ int main(int argc, char** argv) {
|
||||
exit_code = EXIT_SUCCESS;
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
logger::error(e);
|
||||
logger.Error("SYS", 9, e);
|
||||
}
|
||||
write_log(!quiet);
|
||||
return exit_code;
|
||||
@@ -648,24 +649,24 @@ int main(int argc, char** argv) {
|
||||
} else if (output_extension == IFC) {
|
||||
int exit_code = EXIT_FAILURE;
|
||||
try {
|
||||
if (init_input_file(ifcopenshell::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap)) {
|
||||
if (init_input_file(ifcopenshell::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("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(e);
|
||||
logger.Error("SYS", 11, e);
|
||||
}
|
||||
write_log(!quiet);
|
||||
return exit_code;
|
||||
@@ -698,9 +699,9 @@ int main(int argc, char** argv) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!entity_filter.entity_names.empty()) { entity_filter.update_description(); logger::notice(entity_filter.description); }
|
||||
if (!layer_filter.values.empty()) { layer_filter.update_description(); logger::notice(layer_filter.description); }
|
||||
if (!attribute_filter.attribute_name.empty()) { attribute_filter.update_description(); logger::notice(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); }
|
||||
|
||||
if (geometry_serializer_info && geometry_serializer_info->requires_ascii_temp_file) {
|
||||
// These serializers do not support opening unicode paths. Therefore
|
||||
@@ -766,13 +767,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("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("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("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;
|
||||
@@ -790,7 +791,7 @@ int main(int argc, char** argv) {
|
||||
// @nb last argument true -> bypass_properties which are not read by any of the geometry serializers
|
||||
// Document serializers and IFC are already special-cased above
|
||||
// SVG requires properties for IfcAnnotation/DRAWING properties
|
||||
if (!init_input_file(ifcopenshell::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap, geometry_serializer_info->bypass_properties)) {
|
||||
if (!init_input_file(ifcopenshell::path::to_utf8(input_filename), ifc_file, no_progress || quiet, mmap, geometry_serializer_info->bypass_properties, logger)) {
|
||||
write_log(!quiet);
|
||||
serializer.reset();
|
||||
ifcopenshell::path::delete_file(ifcopenshell::path::to_utf8(output_temp_filename)); /**< @todo Windows Unicode support */
|
||||
@@ -798,9 +799,9 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (vmap.count("log-file")) {
|
||||
logger::set_output(quiet ? nullptr : &cout_, &log_fs);
|
||||
logger.SetOutput(quiet ? nullptr : &cout_, &log_fs);
|
||||
} else {
|
||||
logger::set_output(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
|
||||
logger.SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
|
||||
}
|
||||
|
||||
if (model_rotation) {
|
||||
@@ -815,13 +816,13 @@ int main(int argc, char** argv) {
|
||||
|
||||
std::stringstream msg;
|
||||
msg << "Using model rotation (" << rotation[0] << "," << rotation[1] << "," << rotation[2] << "," << rotation[3] << ")";
|
||||
logger::notice(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("--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)) {
|
||||
@@ -836,7 +837,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(msg.str());
|
||||
logger.Notice("SYS", 20, msg.str());
|
||||
|
||||
geometry_settings.get<ifcopenshell::geometry::settings::ModelOffset>().value = offset;
|
||||
}
|
||||
@@ -844,17 +845,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("No geometrical elements found or none successfully converted");
|
||||
logger.Notice("GEO", 23, "No geometrical elements found or none successfully converted");
|
||||
serializer.reset();
|
||||
ifcopenshell::path::delete_file(ifcopenshell::path::to_utf8(output_temp_filename));
|
||||
write_log(!quiet);
|
||||
@@ -865,7 +866,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);
|
||||
@@ -874,7 +875,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(msg.str());
|
||||
logger.Notice("SYS", 21, msg.str());
|
||||
|
||||
geometry_settings.get<ifcopenshell::geometry::settings::ModelOffset>().value = offset;
|
||||
}
|
||||
@@ -890,15 +891,15 @@ 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));
|
||||
}
|
||||
|
||||
logger::message(logger::LOG_PERF, "file geometry conversion");
|
||||
logger.message(logger::LOG_PERF, "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("No geometrical elements found or none successfully converted");
|
||||
logger.Notice("GEO", 25, "No geometrical elements found or none successfully converted");
|
||||
serializer.reset();
|
||||
ifcopenshell::path::delete_file(ifcopenshell::path::to_utf8(output_temp_filename));
|
||||
write_log(!quiet);
|
||||
@@ -918,7 +919,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()
|
||||
@@ -963,10 +964,10 @@ int main(int argc, char** argv) {
|
||||
if (stderr_progress)
|
||||
cerr_ << std::flush;
|
||||
} else if (vcounter.count == 2) {
|
||||
logger::message(logger::LOG_DEBUG, "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::progress_bar(progress);
|
||||
if (old_progress != progress) logger.ProgressBar(progress);
|
||||
old_progress = progress;
|
||||
}
|
||||
}
|
||||
@@ -995,7 +996,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) ");
|
||||
}
|
||||
|
||||
@@ -1003,7 +1004,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, "done file geometry conversion");
|
||||
logger.Message(Logger::LOG_PERF, "GEO", 26, "done file geometry conversion");
|
||||
|
||||
bool successful;
|
||||
if (geometry_serializer_info->writes_final_output) {
|
||||
@@ -1021,13 +1022,13 @@ int main(int argc, char** argv) {
|
||||
output_temp_filename << "' for the conversion result.";
|
||||
}
|
||||
|
||||
if (geometry_settings.get<ifcopenshell::geometry::settings::ValidateQuantities>().get() && logger::max_severity() >= logger::LOG_ERROR) {
|
||||
logger::error("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::print_performance_stats();
|
||||
if (logger.Verbosity() == Logger::LOG_PERF) {
|
||||
logger.PrintPerformanceStats();
|
||||
}
|
||||
|
||||
write_log(!quiet);
|
||||
@@ -1035,7 +1036,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;
|
||||
@@ -1073,18 +1074,18 @@ void write_log(bool header) {
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties) {
|
||||
bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties, Logger& logger) {
|
||||
time_t start, end;
|
||||
|
||||
// Prevent file::Init() prints by setting output to null temporarily
|
||||
if (no_progress) { logger::set_output(NULL, &log_stream); }
|
||||
if (no_progress) { logger.set_output(NULL, &log_stream); }
|
||||
|
||||
time(&start);
|
||||
|
||||
bool requires_init = false;
|
||||
|
||||
{
|
||||
ifc_file = new ifcopenshell::file(ifcopenshell::uninitialized_tag{});
|
||||
ifc_file = new ifcopenshell::file(ifcopenshell::uninitialized_tag{}, logger);
|
||||
requires_init = true;
|
||||
}
|
||||
|
||||
@@ -1110,13 +1111,13 @@ bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file,
|
||||
}
|
||||
|
||||
if (!ifc_file || !ifc_file->good()) {
|
||||
logger::error("Unable to parse input file '" + filename + "'");
|
||||
logger.Error("SYN", 1, "Unable to parse input file '" + filename + "'");
|
||||
return false;
|
||||
}
|
||||
time(&end);
|
||||
|
||||
if (no_progress) { logger::set_output(&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;
|
||||
|
||||
@@ -1329,7 +1330,7 @@ namespace latebound_access {
|
||||
}
|
||||
}
|
||||
|
||||
void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress) {
|
||||
void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, Logger& logger) {
|
||||
{
|
||||
auto delete_reversed = [&f](const std::vector<express::Base>& insts) {
|
||||
// Lists are traversed back to front as the list may be mutated when
|
||||
@@ -1380,7 +1381,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st
|
||||
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;
|
||||
@@ -1507,7 +1508,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st
|
||||
cerr_ << std::flush;
|
||||
} else {
|
||||
const int progress = context_iterator.progress() / 2;
|
||||
if (old_progress != progress) logger::progress_bar(progress);
|
||||
if (old_progress != progress) logger.ProgressBar(progress);
|
||||
old_progress = progress;
|
||||
}
|
||||
}
|
||||
@@ -1523,7 +1524,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st
|
||||
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 ");
|
||||
}
|
||||
|
||||
|
||||
@@ -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(ifcopenshell::file& 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(ifcopenshell::file& 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(ifcopenshell::file& f, bool no_progress, bool quiet, bo
|
||||
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(ifcopenshell::file& f, bool no_progress, bool quiet, bo
|
||||
|
||||
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().to_string() << "x" << id_map[b.id()]->first->data().to_string() << std::endl;
|
||||
// auto x = id_map[a.id()]->second * id_map[b.id()]->second;
|
||||
@@ -128,7 +128,7 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo
|
||||
auto itelem = elem_to_space_boundary_coords.find({ Aguid, Bguid });
|
||||
|
||||
if (itelem == elem_to_space_boundary_coords.end()) {
|
||||
logger::error("Missing space boundary relationship " + Aguid + " " + Bguid);
|
||||
logger.Error("VAL", 1, "Missing space boundary relationship " + Aguid + " " + Bguid);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo
|
||||
bool valid = *std::max_element(distances.begin(), distances.end()) < 0.4;
|
||||
|
||||
if (!valid) {
|
||||
logger::error("Wrong connection geometry " + Aguid + " " + Bguid);
|
||||
logger.Error("VAL", 2, "Wrong connection geometry " + Aguid + " " + Bguid);
|
||||
}
|
||||
|
||||
/*{
|
||||
@@ -178,7 +178,7 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo
|
||||
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("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(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress) {
|
||||
void fix_storeycontainment(ifcopenshell::file& 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(ifcopenshell::file& f, bool no_progress, bool quiet,
|
||||
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 ifcopenshell::IfcBaseClass* a) {
|
||||
return ((const ifcopenshell::IfcBaseEntity*)a)->get_value<double>("Elevation", 0.);
|
||||
@@ -196,9 +196,9 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet,
|
||||
auto assigned_overlap = intersection_volumes[assigned_idx];
|
||||
if (calc_overlap > 0 && assigned_overlap < calc_overlap * 0.9) {
|
||||
auto s = geom_object->product()->get_value<std::string>("GlobalId");
|
||||
auto s1 = ((ifcopenshell::IfcBaseEntity*)storeys_sorted[calc_idx])->get_value<std::string>("GlobalId");
|
||||
auto s2 = ((ifcopenshell::IfcBaseEntity*)elem_to_storey[geom_object->product()])->get_value<std::string>("GlobalId");
|
||||
logger::error("Element " + s + " contained in " + s2 + " located on " + s1);
|
||||
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);
|
||||
}
|
||||
|
||||
if (!no_progress) {
|
||||
@@ -214,7 +214,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet,
|
||||
std::cerr << std::flush;
|
||||
} else {
|
||||
const int progress = context_iterator.progress() / 2;
|
||||
if (old_progress != progress) logger::progress_bar(progress);
|
||||
if (old_progress != progress) logger.ProgressBar(progress);
|
||||
old_progress = progress;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet,
|
||||
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(ifcopenshell::file& 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(ifcopenshell::file& 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(ifcopenshell::file& f, bool no_progress, bool quiet, b
|
||||
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 ifcopenshell::IfcBaseClass*>, const ifcopenshell::IfcBaseClass*> rel_by_elem;
|
||||
@@ -39,7 +39,7 @@ void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, b
|
||||
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(ifcopenshell::file& f, bool no_progress, bool quiet, b
|
||||
|
||||
if (a_type != atype_computed || b_type != btype_computed) {
|
||||
if (rel) {
|
||||
logger::error(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("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 ifcopenshell::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 = (ifcopenshell::IfcBaseEntity*)((ifcopenshell::IfcBaseEntity*)rel)->get_value<ifcopenshell::IfcBaseClass*>("RelatingElement");
|
||||
auto y = (ifcopenshell::IfcBaseEntity*)((ifcopenshell::IfcBaseEntity*)rel)->get_value<ifcopenshell::IfcBaseClass*>("RelatedElement");
|
||||
if (v.successfully_processed.find(x) != v.successfully_processed.end() && v.successfully_processed.find(y) != v.successfully_processed.end()) {
|
||||
logger::error("Connection for non-adjacent walls", rel);
|
||||
logger.Error("VAL", 7, "Connection for non-adjacent walls", rel);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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 ifcopenshell::IfcBaseEntity*> successfully_processed;
|
||||
|
||||
intersection_validator(ifcopenshell::file& f, std::initializer_list<std::string> entities, double eps, bool no_progress, bool quiet, bool stderr_progress) {
|
||||
intersection_validator(ifcopenshell::file& 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::progress_bar(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
|
||||
|
||||
Reference in New Issue
Block a user