Wrap more classes into ifcopenshell:: namespace

This commit is contained in:
Thomas Krijnen
2026-08-08 13:58:39 +02:00
parent 2c47c9d4fa
commit 02481b3247
149 changed files with 678 additions and 627 deletions
+2 -2
View File
@@ -685,7 +685,7 @@ void convertIfcToDatabase(SessionState& session, QWidget& host) {
throw ifcopenshell::exception("RDB serializer does not support streaming from an input filename"); throw ifcopenshell::exception("RDB serializer does not support streaming from an input filename");
} }
boost::shared_ptr<serializer> serializer = registry.create("rdb", context); boost::shared_ptr<ifcopenshell::geom::serializer> serializer = registry.create("rdb", context);
serializer->finalize(); serializer->finalize();
} catch (const std::exception& e) { } catch (const std::exception& e) {
*error_message = QString::fromUtf8(e.what()); *error_message = QString::fromUtf8(e.what());
@@ -791,7 +791,7 @@ void exportGeometryDatabase(SessionState& session, QWidget& host) {
throw ifcopenshell::exception("RDB serializer does not support streaming from an input filename"); throw ifcopenshell::exception("RDB serializer does not support streaming from an input filename");
} }
boost::shared_ptr<serializer> serializer = registry.create("rdb", context); boost::shared_ptr<ifcopenshell::geom::serializer> serializer = registry.create("rdb", context);
serializer->finalize(); serializer->finalize();
serializer.reset(); serializer.reset();
@@ -75,10 +75,10 @@ QString formatCachedUnitScale(double meters_per_unit) {
return QString("Cached scale: 1 unit = %1 m").arg(formatNumber(meters_per_unit)); return QString("Cached scale: 1 unit = %1 m").arg(formatNumber(meters_per_unit));
} }
std::string enumString(const attribute_value& av) { std::string enumString(const ifcopenshell::attribute_value& av) {
if (av.isNull()) return {}; if (av.isNull()) return {};
if (av.type() != ifcopenshell::Argument_ENUMERATION) return {}; if (av.type() != ifcopenshell::Argument_ENUMERATION) return {};
enumeration_reference enumeration = av; ifcopenshell::enumeration_reference enumeration = av;
return std::string(enumeration.value() ? enumeration.value() : ""); return std::string(enumeration.value() ? enumeration.value() : "");
} }
+2 -2
View File
@@ -70,7 +70,7 @@ typedef IfcSchema::IfcBuildingElement element_t;
typedef IfcSchema::IfcBuiltElement element_t; typedef IfcSchema::IfcBuiltElement element_t;
#endif #endif
std::string format_string(const attribute_value& argument) { std::string format_string(const ifcopenshell::attribute_value& argument) {
// Argument is a runtime tagged variant for the various data types in a IFC model, // Argument is a runtime tagged variant for the various data types in a IFC model,
// in this particular case we only care about flattening it to a string. // in this particular case we only care about flattening it to a string.
// @todo mostly duplicated from XmlSerializer.cpp // @todo mostly duplicated from XmlSerializer.cpp
@@ -213,7 +213,7 @@ int main(int argc, char** argv) {
#endif #endif
// Redirect the output (both progress and log) to stdout // Redirect the output (both progress and log) to stdout
::logger::root().set_output(&std::cout, &std::cout); ifcopenshell::logger::root().set_output(&std::cout, &std::cout);
// Parse the IFC file provided in argv[1] // Parse the IFC file provided in argv[1]
ifcopenshell::file file(argv[1]); ifcopenshell::file file(argv[1]);
+4 -4
View File
@@ -52,7 +52,7 @@ std::string schema_name(const express::base& instance) {
// A primitive scalar attribute value formatted for display, or std::nullopt for // A primitive scalar attribute value formatted for display, or std::nullopt for
// IFC null and for non-primitive values (entity references, aggregates/lists, // IFC null and for non-primitive values (entity references, aggregates/lists,
// binary) — which the properties UI omits. // binary) — which the properties UI omits.
std::optional<std::string> format_scalar(const attribute_value& value) { std::optional<std::string> format_scalar(const ifcopenshell::attribute_value& value) {
if (value.isNull()) { if (value.isNull()) {
return std::nullopt; return std::nullopt;
} }
@@ -60,7 +60,7 @@ std::optional<std::string> format_scalar(const attribute_value& value) {
case ifcopenshell::Argument_STRING: case ifcopenshell::Argument_STRING:
return static_cast<std::string>(value); return static_cast<std::string>(value);
case ifcopenshell::Argument_ENUMERATION: { case ifcopenshell::Argument_ENUMERATION: {
const enumeration_reference enumeration = value; const ifcopenshell::enumeration_reference enumeration = value;
return enumeration.value() ? std::string(enumeration.value()) : std::string(); return enumeration.value() ? std::string(enumeration.value()) : std::string();
} }
case ifcopenshell::Argument_INT: case ifcopenshell::Argument_INT:
@@ -288,13 +288,13 @@ std::optional<std::string> get_string_attribute(const express::base& element,
if (index < 0) { if (index < 0) {
return std::nullopt; return std::nullopt;
} }
const attribute_value value = element.get_attribute_value(static_cast<std::size_t>(index)); const ifcopenshell::attribute_value value = element.get_attribute_value(static_cast<std::size_t>(index));
if (value.isNull()) { if (value.isNull()) {
return std::nullopt; return std::nullopt;
} }
switch (value.type()) { switch (value.type()) {
case ifcopenshell::Argument_ENUMERATION: { case ifcopenshell::Argument_ENUMERATION: {
const enumeration_reference enumeration = value; const ifcopenshell::enumeration_reference enumeration = value;
return enumeration.value() ? std::string(enumeration.value()) : std::string(); return enumeration.value() ? std::string(enumeration.value()) : std::string();
} }
case ifcopenshell::Argument_STRING: case ifcopenshell::Argument_STRING:
+1 -1
View File
@@ -144,7 +144,7 @@ double get_storey_elevation_s(const express::base& storey) {
if (declaration != nullptr) { if (declaration != nullptr) {
const std::ptrdiff_t index = declaration->attribute_index("Elevation"); const std::ptrdiff_t index = declaration->attribute_index("Elevation");
if (index >= 0) { if (index >= 0) {
const attribute_value value = storey.get_attribute_value(static_cast<std::size_t>(index)); const ifcopenshell::attribute_value value = storey.get_attribute_value(static_cast<std::size_t>(index));
if (!value.isNull() && value.type() == ifcopenshell::Argument_DOUBLE) { if (!value.isNull() && value.type() == ifcopenshell::Argument_DOUBLE) {
return static_cast<double>(value); return static_cast<double>(value);
} }
+3 -3
View File
@@ -69,7 +69,7 @@ std::string schema_name(const express::base& instance) {
throw ifcopenshell::exception("No helper implementation was built for schema " + name); throw ifcopenshell::exception("No helper implementation was built for schema " + name);
} }
property_value from_attribute(const attribute_value& value); property_value from_attribute(const ifcopenshell::attribute_value& value);
template <typename T> template <typename T>
property_list scalar_list(const std::vector<T>& values) { property_list scalar_list(const std::vector<T>& values) {
@@ -81,7 +81,7 @@ property_list scalar_list(const std::vector<T>& values) {
return result; return result;
} }
property_value from_attribute(const attribute_value& value) { property_value from_attribute(const ifcopenshell::attribute_value& value) {
if (value.isNull()) { if (value.isNull()) {
return {}; return {};
} }
@@ -103,7 +103,7 @@ property_value from_attribute(const attribute_value& value) {
case ifcopenshell::Argument_STRING: case ifcopenshell::Argument_STRING:
return static_cast<std::string>(value); return static_cast<std::string>(value);
case ifcopenshell::Argument_ENUMERATION: { case ifcopenshell::Argument_ENUMERATION: {
const enumeration_reference enumeration = value; const ifcopenshell::enumeration_reference enumeration = value;
return enumeration.value() ? enumeration.value() : ""; return enumeration.value() ? enumeration.value() : "";
} }
case ifcopenshell::Argument_BINARY: { case ifcopenshell::Argument_BINARY: {
+22 -22
View File
@@ -219,7 +219,7 @@ bool file_exists(const std::string& filename) {
static std::basic_stringstream<path_t::value_type> log_stream; static std::basic_stringstream<path_t::value_type> log_stream;
void write_log(bool); void write_log(bool);
void fix_quantities(ifcopenshell::file&, bool, bool, bool, logger& logger = ::logger::root()); void fix_quantities(ifcopenshell::file&, bool, bool, bool, ifcopenshell::logger& logger = ifcopenshell::logger::root());
std::string format_duration(time_t start, time_t end); std::string format_duration(time_t start, time_t end);
/// @todo make the filters non-global /// @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>&); void parse_filter(geom_filter &, const std::vector<std::string>&);
std::vector<ifcopenshell::geom::filter_t> setup_filters(const std::vector<geom_filter>&, const std::string&); std::vector<ifcopenshell::geom::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, logger& logger = ::logger::root()); bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties=false, ifcopenshell::logger& logger = ifcopenshell::logger::root());
// from https://stackoverflow.com/questions/31696328/boost-program-options-using-zero-parameter-options-multiple-times // from https://stackoverflow.com/questions/31696328/boost-program-options-using-zero-parameter-options-multiple-times
struct verbosity_counter { struct verbosity_counter {
@@ -271,7 +271,7 @@ int main(int argc, char** argv) {
typedef po::command_line_parser command_line_parser; typedef po::command_line_parser command_line_parser;
typedef char char_t; typedef char char_t;
#endif #endif
logger logger; ifcopenshell::logger logger;
inclusion_filter include_filter; inclusion_filter include_filter;
inclusion_traverse_filter include_traverse_filter; inclusion_traverse_filter include_traverse_filter;
@@ -471,9 +471,9 @@ int main(int argc, char** argv) {
if (vmap.count("log-format") == 1) { if (vmap.count("log-format") == 1) {
boost::to_lower(log_format); boost::to_lower(log_format);
if (log_format == "plain") { if (log_format == "plain") {
logger.output_format(::logger::FMT_PLAIN); logger.output_format(ifcopenshell::logger::FMT_PLAIN);
} else if (log_format == "json") { } else if (log_format == "json") {
logger.output_format(::logger::FMT_JSON); logger.output_format(ifcopenshell::logger::FMT_JSON);
} else { } else {
cerr_ << "[error] --log-format should be either plain or json" << std::endl; cerr_ << "[error] --log-format should be either plain or json" << std::endl;
print_usage(); print_usage();
@@ -555,19 +555,19 @@ int main(int argc, char** argv) {
switch (vcounter.count) { switch (vcounter.count) {
case 0: case 0:
logger.verbosity(::logger::LOG_ERROR); logger.verbosity(ifcopenshell::logger::LOG_ERROR);
break; break;
case 1: case 1:
logger.verbosity(::logger::LOG_NOTICE); logger.verbosity(ifcopenshell::logger::LOG_NOTICE);
break; break;
case 2: case 2:
logger.verbosity(::logger::LOG_DEBUG); logger.verbosity(ifcopenshell::logger::LOG_DEBUG);
break; break;
case 3: case 3:
logger.verbosity(::logger::LOG_PERF); logger.verbosity(ifcopenshell::logger::LOG_PERF);
break; break;
case 4: case 4:
logger.verbosity(::logger::LOG_PERF); logger.verbosity(ifcopenshell::logger::LOG_PERF);
logger.print_performance_stats_on_element(true); logger.print_performance_stats_on_element(true);
break; break;
} }
@@ -618,7 +618,7 @@ int main(int argc, char** argv) {
context.schema_name = ifc_file ? ifc_file->schema()->name() : document_serializer_info->schema_name; context.schema_name = ifc_file ? ifc_file->schema()->name() : document_serializer_info->schema_name;
context.stream = use_input_filename; context.stream = use_input_filename;
boost::shared_ptr<serializer> serializer = document_serializer_registry.create(output_extension_utf8, context); boost::shared_ptr<ifcopenshell::geom::serializer> serializer = document_serializer_registry.create(output_extension_utf8, context);
if (serializer->is_streaming() != use_input_filename) { if (serializer->is_streaming() != use_input_filename) {
throw ifcopenshell::exception("Selected document serializer streaming mode does not match its registry metadata"); throw ifcopenshell::exception("Selected document serializer streaming mode does not match its registry metadata");
} }
@@ -752,7 +752,7 @@ int main(int argc, char** argv) {
settings settings
}; };
boost::shared_ptr<geometry_serializer> serializer; /**< @todo use std::unique_ptr when possible */ boost::shared_ptr<ifcopenshell::geom::geometry_serializer> serializer; /**< @todo use std::unique_ptr when possible */
try { try {
geometry_serializer_registry.configure(output_extension_utf8, serializer_context); geometry_serializer_registry.configure(output_extension_utf8, serializer_context);
serializer = geometry_serializer_registry.create(output_extension_utf8, serializer_context); serializer = geometry_serializer_registry.create(output_extension_utf8, serializer_context);
@@ -895,7 +895,7 @@ int main(int argc, char** argv) {
context_iterator.reset(new ifcopenshell::geom::iterator(ifcopenshell::geom::kernels::construct(ifc_file, geometry_kernel, settings), settings, ifc_file, filter_funcs, num_threads, logger)); context_iterator.reset(new ifcopenshell::geom::iterator(ifcopenshell::geom::kernels::construct(ifc_file, geometry_kernel, settings), settings, ifc_file, filter_funcs, num_threads, logger));
} }
logger.message(::logger::LOG_PERF, "file geometry conversion"); logger.message(ifcopenshell::logger::LOG_PERF, "file geometry conversion");
if (context_iterator && !context_iterator->initialize()) { 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 /// @todo It would be nice to know and print separate error prints for a case where we found no entities
@@ -965,7 +965,7 @@ int main(int argc, char** argv) {
if (stderr_progress) if (stderr_progress)
cerr_ << std::flush; cerr_ << std::flush;
} else if (vcounter.count == 2) { } else if (vcounter.count == 2) {
logger.message(::logger::LOG_DEBUG, "SYS", 23, "Progress " + boost::lexical_cast<std::string>(progress)); logger.message(ifcopenshell::logger::LOG_DEBUG, "SYS", 23, "Progress " + boost::lexical_cast<std::string>(progress));
} else { } else {
progress = progress / 2; progress = progress / 2;
if (old_progress != progress) logger.progress_bar(progress); if (old_progress != progress) logger.progress_bar(progress);
@@ -1005,7 +1005,7 @@ int main(int argc, char** argv) {
// Make sure the dtor is explicitly run here (e.g. output files are closed before renaming them). // Make sure the dtor is explicitly run here (e.g. output files are closed before renaming them).
serializer.reset(); serializer.reset();
logger.message(::logger::LOG_PERF, "GEO", 26, "done file geometry conversion"); logger.message(ifcopenshell::logger::LOG_PERF, "GEO", 26, "done file geometry conversion");
bool successful; bool successful;
if (geometry_serializer_info->writes_final_output) { if (geometry_serializer_info->writes_final_output) {
@@ -1023,17 +1023,17 @@ int main(int argc, char** argv) {
output_temp_filename << "' for the conversion result."; output_temp_filename << "' for the conversion result.";
} }
if (settings.get<ifcopenshell::geom::settings::ValidateQuantities>().get() && logger.max_severity() >= ::logger::LOG_ERROR) { if (settings.get<ifcopenshell::geom::settings::ValidateQuantities>().get() && logger.max_severity() >= ifcopenshell::logger::LOG_ERROR) {
logger.error("SYS", 24, "Errors encountered during processing."); logger.error("SYS", 24, "Errors encountered during processing.");
successful = false; successful = false;
} }
if (fail_on_error && logger.max_severity() >= ::logger::LOG_ERROR) { if (fail_on_error && logger.max_severity() >= ifcopenshell::logger::LOG_ERROR) {
logger.error("SYS", 26, "Errors encountered during processing, failing due to --fail-on-error."); logger.error("SYS", 26, "Errors encountered during processing, failing due to --fail-on-error.");
successful = false; successful = false;
} }
if (logger.verbosity() == ::logger::LOG_PERF) { if (logger.verbosity() == ifcopenshell::logger::LOG_PERF) {
logger.print_performance_stats(); logger.print_performance_stats();
} }
@@ -1080,7 +1080,7 @@ void write_log(bool header) {
#include <boost/algorithm/string/predicate.hpp> #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, logger& logger) { bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties, ifcopenshell::logger& logger) {
time_t start, end; time_t start, end;
// Prevent file::Init() prints by setting output to null temporarily // Prevent file::Init() prints by setting output to null temporarily
@@ -1314,7 +1314,7 @@ namespace latebound_access {
enum_type->enumeration_items().end(), enum_type->enumeration_items().end(),
t); t);
return set(inst, attr, enumeration_reference(enum_type, it - enum_type->enumeration_items().begin())); return set(inst, attr, ifcopenshell::enumeration_reference(enum_type, it - enum_type->enumeration_items().begin()));
} }
template <typename T> template <typename T>
@@ -1323,7 +1323,7 @@ namespace latebound_access {
auto i = decl->attribute_index(attr); auto i = decl->attribute_index(attr);
auto attr_type = decl->attribute_by_index(i)->type_of_attribute(); auto attr_type = decl->attribute_by_index(i)->type_of_attribute();
if (attr_type->as_named_type() && attr_type->as_named_type()->declared_type()->as_enumeration_type() && !std::is_same<T, enumeration_reference>::value) { if (attr_type->as_named_type() && attr_type->as_named_type()->declared_type()->as_enumeration_type() && !std::is_same<T, ifcopenshell::enumeration_reference>::value) {
set_enumeration(inst, attr, attr_type->as_named_type()->declared_type()->as_enumeration_type(), t); set_enumeration(inst, attr, attr_type->as_named_type()->declared_type()->as_enumeration_type(), t);
} else { } else {
inst.set_attribute_value(i, t); inst.set_attribute_value(i, t);
@@ -1336,7 +1336,7 @@ namespace latebound_access {
} }
} }
void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger) { void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, ifcopenshell::logger& logger) {
{ {
auto delete_reversed = [&f](const std::vector<express::base>& insts) { auto delete_reversed = [&f](const std::vector<express::base>& insts) {
// Lists are traversed back to front as the list may be mutated when // Lists are traversed back to front as the list may be mutated when
+1 -1
View File
@@ -18,7 +18,7 @@ typedef CGAL::AABB_traits<Kernel_, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree; typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id; typedef Tree::Point_and_primitive_id Point_and_primitive_id;
void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, ifcopenshell::logger& logger = ifcopenshell::logger::root()) {
intersection_validator v(f, { "IfcWall", "IfcSpace", "IfcSlab", "IfcCovering" }, 1.e-5, no_progress, quiet, stderr_progress, logger); intersection_validator v(f, { "IfcWall", "IfcSpace", "IfcSlab", "IfcCovering" }, 1.e-5, no_progress, quiet, stderr_progress, logger);
auto rels = f.instances_by_type("IfcRelSpaceBoundary"); auto rels = f.instances_by_type("IfcRelSpaceBoundary");
@@ -9,7 +9,7 @@
#include <algorithm> #include <algorithm>
void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, ifcopenshell::logger& logger = ifcopenshell::logger::root()) {
ifcopenshell::geom::settings settings; ifcopenshell::geom::settings settings;
settings.get<ifcopenshell::geom::settings::UseWorldCoords>().value = false; settings.get<ifcopenshell::geom::settings::UseWorldCoords>().value = false;
@@ -9,7 +9,7 @@
using namespace ifcopenshell::geom; using namespace ifcopenshell::geom;
void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, ifcopenshell::logger& logger = ifcopenshell::logger::root()) {
intersection_validator v(f, { "IfcWall" }, 1.e-3, no_progress, quiet, stderr_progress, logger); intersection_validator v(f, { "IfcWall" }, 1.e-3, no_progress, quiet, stderr_progress, logger);
ifcopenshell::geom::settings settings; ifcopenshell::geom::settings settings;
+1 -1
View File
@@ -446,7 +446,7 @@ struct intersection_validator {
std::set<const ifcopenshell::IfcBaseEntity*> successfully_processed; 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, logger& logger = ::logger::root()) { intersection_validator(ifcopenshell::file& f, std::initializer_list<std::string> entities, double eps, bool no_progress, bool quiet, bool stderr_progress, ifcopenshell::logger& logger = ifcopenshell::logger::root()) {
ifcopenshell::geom::settings settings; ifcopenshell::geom::settings settings;
settings.get<ifcopenshell::geom::settings::UseWorldCoords>().value = false; settings.get<ifcopenshell::geom::settings::UseWorldCoords>().value = false;
+6 -6
View File
@@ -66,12 +66,12 @@ namespace ifcopenshell {
protected: protected:
std::string geometry_library_; std::string geometry_library_;
ifcopenshell::geom::settings settings_; ifcopenshell::geom::settings settings_;
::logger& logger_; ifcopenshell::logger& logger_;
public: public:
bool propagate_exceptions = false; bool propagate_exceptions = false;
bool partial_success_is_success = true; bool partial_success_is_success = true;
abstract_kernel(const std::string& geometry_library, const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) abstract_kernel(const std::string& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: geometry_library_(geometry_library) : geometry_library_(geometry_library)
, settings_(settings) , settings_(settings)
, logger_(logger) {} , logger_(logger) {}
@@ -89,7 +89,7 @@ namespace ifcopenshell {
virtual bool accepts(const ifcopenshell::geom::conversion_result_shape& shape) const { virtual bool accepts(const ifcopenshell::geom::conversion_result_shape& shape) const {
return shape.backend_id() == backend_id(); return shape.backend_id() == backend_id();
} }
::logger& logger() const { return logger_; } ifcopenshell::logger& logger() const { return logger_; }
virtual bool supports_boolean_operations() const = 0; virtual bool supports_boolean_operations() const = 0;
@@ -137,7 +137,7 @@ namespace ifcopenshell {
const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes) = 0; const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes) = 0;
virtual bool unify_shapes(const ifcopenshell::geom::conversion_results&, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } virtual bool unify_shapes(const ifcopenshell::geom::conversion_results&, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); }
virtual abstract_kernel* clone(::logger& logger) const = 0; virtual abstract_kernel* clone(ifcopenshell::logger& logger) const = 0;
}; };
} }
} }
@@ -229,7 +229,7 @@ namespace {
template <typename T> template <typename T>
struct dispatch_curve_creation<T, ifcopenshell::geom::taxonomy::curves::max> { struct dispatch_curve_creation<T, ifcopenshell::geom::taxonomy::curves::max> {
static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T&) { static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T&) {
::logger::root().error("GEO", 28, "No conversion for " + std::to_string(item->kind())); ifcopenshell::logger::root().error("GEO", 28, "No conversion for " + std::to_string(item->kind()));
return false; return false;
} }
}; };
@@ -251,7 +251,7 @@ namespace {
template <typename T> template <typename T>
struct dispatch_surface_creation<T, ifcopenshell::geom::taxonomy::surfaces::max> { struct dispatch_surface_creation<T, ifcopenshell::geom::taxonomy::surfaces::max> {
static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T&) { static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T&) {
::logger::root().error("GEO", 29, "No conversion for " + std::to_string(item->kind())); ifcopenshell::logger::root().error("GEO", 29, "No conversion for " + std::to_string(item->kind()));
return false; return false;
} }
}; };
+1 -1
View File
@@ -1,7 +1,7 @@
#include "ConversionResult.h" #include "ConversionResult.h"
#include "IfcGeomRepresentation.h" #include "IfcGeomRepresentation.h"
ifcopenshell::geom::Representation::triangulation* ifcopenshell::geom::conversion_result_shape::Triangulate(const ifcopenshell::geom::settings& settings, ::logger& logger) const ifcopenshell::geom::Representation::triangulation* ifcopenshell::geom::conversion_result_shape::Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger) const
{ {
auto t = ifcopenshell::geom::Representation::triangulation::empty(settings); auto t = ifcopenshell::geom::Representation::triangulation::empty(settings);
static ifcopenshell::geom::taxonomy::matrix4 iden; static ifcopenshell::geom::taxonomy::matrix4 iden;
+2 -2
View File
@@ -509,8 +509,8 @@ namespace ifcopenshell::geom {
#else #else
virtual std::string_view backend_id() const = 0; virtual std::string_view backend_id() const = 0;
#endif #endif
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const = 0; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const = 0;
ifcopenshell::geom::Representation::triangulation* Triangulate(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) const; ifcopenshell::geom::Representation::triangulation* Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const = 0; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const = 0;
virtual int surface_genus() const = 0; virtual int surface_genus() const = 0;
+13 -13
View File
@@ -4,7 +4,7 @@
using namespace ifcopenshell::geom; using namespace ifcopenshell::geom;
ifcopenshell::geom::converter::converter(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger) ifcopenshell::geom::converter::converter(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger)
: kernel_(std::move(geometry_library)) : kernel_(std::move(geometry_library))
, logger_(logger) , logger_(logger)
{ {
@@ -18,7 +18,7 @@ ifcopenshell::geom::converter::~converter() {
} }
namespace { namespace {
void substitute_with_box_based_on_density(::logger& logger, ifcopenshell::geom::conversion_results& items, double& density) { void substitute_with_box_based_on_density(ifcopenshell::logger& logger, ifcopenshell::geom::conversion_results& items, double& density) {
int nv = 0; int nv = 0;
void* box = nullptr; void* box = nullptr;
double volume = 0.; double volume = 0.;
@@ -102,7 +102,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
} }
if (!success) { if (!success) {
::logger::root().error("Failed processing layerset"); ifcopenshell::logger::root().error("Failed processing layerset");
} }
} }
} }
@@ -219,10 +219,10 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
kernel_->convert_openings(product, opening_items, shapes, *place, opened_shapes); kernel_->convert_openings(product, opening_items, shapes, *place, opened_shapes);
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
logger_.message(::logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product);
caught_error = true; caught_error = true;
} catch (...) { } catch (...) {
logger_.message(::logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product);
} }
if (!(caught_error && opened_shapes.size() < shapes.size())) { if (!(caught_error && opened_shapes.size() < shapes.size())) {
@@ -306,12 +306,12 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
if (elem->geometry().calculate_surface_area(a_calc)) { if (elem->geometry().calculate_surface_area(a_calc)) {
double diff = std::abs(a_calc - a_file); double diff = std::abs(a_calc - a_file);
if (diff / std::sqrt(a_file) > getValue(GV_PRECISION)) { if (diff / std::sqrt(a_file) > getValue(GV_PRECISION)) {
::logger::root().error("Validation of surface area failed for:", product); ifcopenshell::logger::root().error("Validation of surface area failed for:", product);
} else { } else {
::logger::root().notice("Validation of surface area succeeded for:", product); ifcopenshell::logger::root().notice("Validation of surface area succeeded for:", product);
} }
} else { } else {
::logger::root().error("Validation of surface area failed for:", product); ifcopenshell::logger::root().error("Validation of surface area failed for:", product);
} }
} else if (q->as<IfcSchema::IfcQuantityVolume>() && q->Name() == "Volume") { } else if (q->as<IfcSchema::IfcQuantityVolume>() && q->Name() == "Volume") {
double v_calc; double v_calc;
@@ -319,12 +319,12 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
if (elem->geometry().calculate_volume(v_calc)) { if (elem->geometry().calculate_volume(v_calc)) {
double diff = std::abs(v_calc - v_file); double diff = std::abs(v_calc - v_file);
if (diff / std::sqrt(v_file) > getValue(GV_PRECISION)) { if (diff / std::sqrt(v_file) > getValue(GV_PRECISION)) {
::logger::root().error("Validation of volume failed for:", product); ifcopenshell::logger::root().error("Validation of volume failed for:", product);
} else { } else {
::logger::root().notice("Validation of volume succeeded for:", product); ifcopenshell::logger::root().notice("Validation of volume succeeded for:", product);
} }
} else { } else {
::logger::root().error("Validation of volume failed for:", product); ifcopenshell::logger::root().error("Validation of volume failed for:", product);
} }
} else if (q->as<IfcSchema::IfcPhysicalComplexQuantity>() && q->Name() == "Shape Validation Properties") { } else if (q->as<IfcSchema::IfcPhysicalComplexQuantity>() && q->Name() == "Shape Validation Properties") {
auto qs2 = q->as<IfcSchema::IfcPhysicalComplexQuantity>()->HasQuantities(); auto qs2 = q->as<IfcSchema::IfcPhysicalComplexQuantity>()->HasQuantities();
@@ -343,9 +343,9 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
} }
} }
if (!all_succeeded) { if (!all_succeeded) {
::logger::root().error("Validation of surface genus failed for:", product); ifcopenshell::logger::root().error("Validation of surface genus failed for:", product);
} else { } else {
::logger::root().notice("Validation of surface genus succeeded for:", product); ifcopenshell::logger::root().notice("Validation of surface genus succeeded for:", product);
} }
} }
} }
+3 -3
View File
@@ -21,17 +21,17 @@ namespace ifcopenshell { namespace geom {
std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel> kernel_; std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel> kernel_;
ifcopenshell::geom::settings settings_; ifcopenshell::geom::settings settings_;
std::map<ifcopenshell::geom::taxonomy::ptr, brep_ptr, ifcopenshell::geom::taxonomy::less_functor> cache_; std::map<ifcopenshell::geom::taxonomy::ptr, brep_ptr, ifcopenshell::geom::taxonomy::less_functor> cache_;
::logger& logger_; ifcopenshell::logger& logger_;
public: public:
ifcopenshell::geom::kernels::abstract_kernel* kernel() { return &*kernel_; } ifcopenshell::geom::kernels::abstract_kernel* kernel() { return &*kernel_; }
converter(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()); converter(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root());
~converter(); ~converter();
ifcopenshell::geom::abstract_mapping* mapping() const { return mapping_; } ifcopenshell::geom::abstract_mapping* mapping() const { return mapping_; }
::logger& logger() const { return logger_; } ifcopenshell::logger& logger() const { return logger_; }
/* /*
virtual NativeElement<double, double>* convert( virtual NativeElement<double, double>* convert(
+7 -3
View File
@@ -62,12 +62,14 @@ public:
} }
}; };
namespace ifcopenshell::geom {
class IFC_GEOM_API geometry_serializer : public serializer { class IFC_GEOM_API geometry_serializer : public serializer {
public: public:
enum read_type { READ_BREP, READ_TRIANGULATION }; enum read_type { READ_BREP, READ_TRIANGULATION };
geometry_serializer(const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr) geometry_serializer(const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr)
: serializer(logger_or_root(logger)) : serializer(ifcopenshell::logger_or_root(logger))
, settings_(settings) , settings_(settings)
{} {}
virtual ~geometry_serializer() {} virtual ~geometry_serializer() {}
@@ -96,11 +98,13 @@ protected:
class IFC_GEOM_API write_only_geometry_serializer : public geometry_serializer { class IFC_GEOM_API write_only_geometry_serializer : public geometry_serializer {
public: public:
write_only_geometry_serializer(const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr) : geometry_serializer(settings, logger) {} write_only_geometry_serializer(const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr) : geometry_serializer(settings, logger) {}
virtual ifcopenshell::geom::element* read(ifcopenshell::file&, const std::string&, const std::string&, read_type = READ_BREP) { virtual ifcopenshell::geom::element* read(ifcopenshell::file&, const std::string&, const std::string&, read_type = READ_BREP) {
throw std::runtime_error("Not supported"); throw std::runtime_error("Not supported");
}; };
}; };
} // namespace ifcopenshell::geom
#endif #endif
+1 -1
View File
@@ -126,7 +126,7 @@ namespace ifcopenshell::geom {
oss << "product-" << ifcopenshell::global_id(guid).formatted(); oss << "product-" << ifcopenshell::global_id(guid).formatted();
} catch (const std::exception& e) { } catch (const std::exception& e) {
oss << "product"; oss << "product";
::logger::root().error("GEO", 39, e); ifcopenshell::logger::root().error("GEO", 39, e);
} }
} }
+6 -6
View File
@@ -204,11 +204,11 @@ void ifcopenshell::geom::iterator::process_concurrently() {
worker_loggers_.reserve(conc_threads); worker_loggers_.reserve(conc_threads);
for (unsigned i = 0; i < conc_threads; ++i) { for (unsigned i = 0; i < conc_threads; ++i) {
worker_loggers_.emplace_back(std::make_unique<logger>()); worker_loggers_.emplace_back(std::make_unique<logger>());
::logger& worker_logger = *worker_loggers_.back(); ifcopenshell::logger& worker_logger = *worker_loggers_.back();
worker_logger.verbosity(logger_.verbosity()); worker_logger.verbosity(logger_.verbosity());
worker_logger.output_format(logger_.output_format()); worker_logger.output_format(logger_.output_format());
worker_logger.print_performance_stats_on_element(logger_.print_performance_stats_on_element()); worker_logger.print_performance_stats_on_element(logger_.print_performance_stats_on_element());
if (worker_logger.output_format() != ::logger::FMT_INMEMORY) { if (worker_logger.output_format() != ifcopenshell::logger::FMT_INMEMORY) {
worker_logger.set_output(static_cast<std::ostream*>(nullptr), static_cast<std::ostream*>(nullptr)); worker_logger.set_output(static_cast<std::ostream*>(nullptr), static_cast<std::ostream*>(nullptr));
} }
kernel_pool.push_back(new ifcopenshell::geom::converter(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>(converter_->kernel()->clone(worker_logger)), ifc_file, settings_, worker_logger)); kernel_pool.push_back(new ifcopenshell::geom::converter(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>(converter_->kernel()->clone(worker_logger)), ifc_file, settings_, worker_logger));
@@ -362,7 +362,7 @@ express::base ifcopenshell::geom::iterator::create_shape_model_for_next_entity()
void ifcopenshell::geom::iterator::create_element_(ifcopenshell::geom::converter* kernel, ifcopenshell::geom::settings settings, geometry_conversion_result* rep) void ifcopenshell::geom::iterator::create_element_(ifcopenshell::geom::converter* kernel, ifcopenshell::geom::settings settings, geometry_conversion_result* rep)
{ {
::logger& kernel_logger = kernel->logger(); ifcopenshell::logger& kernel_logger = kernel->logger();
if (!settings_.get<ifcopenshell::geom::settings::NoParallelMapping>().get()) { if (!settings_.get<ifcopenshell::geom::settings::NoParallelMapping>().get()) {
rep->item = kernel->mapping()->map(rep->representation); rep->item = kernel->mapping()->map(rep->representation);
@@ -422,13 +422,13 @@ void ifcopenshell::geom::iterator::create_element_(ifcopenshell::geom::converter
kernel_logger.set_product(std::optional<express::base>{}); kernel_logger.set_product(std::optional<express::base>{});
} }
ifcopenshell::geom::element* ifcopenshell::geom::iterator::process_based_on_settings(ifcopenshell::geom::settings settings, ifcopenshell::geom::brep_element* elem, ::logger& logger, ifcopenshell::geom::triangulation_element* previous) ifcopenshell::geom::element* ifcopenshell::geom::iterator::process_based_on_settings(ifcopenshell::geom::settings settings, ifcopenshell::geom::brep_element* elem, ifcopenshell::logger& logger, ifcopenshell::geom::triangulation_element* previous)
{ {
if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::SERIALIZED) { if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::SERIALIZED) {
try { try {
return new ifcopenshell::geom::serialized_element(*elem); return new ifcopenshell::geom::serialized_element(*elem);
} catch (...) { } catch (...) {
logger.message(::logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed."); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed.");
return nullptr; return nullptr;
} }
} else if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::TRIANGULATED) { } else if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::TRIANGULATED) {
@@ -440,7 +440,7 @@ ifcopenshell::geom::element* ifcopenshell::geom::iterator::process_based_on_sett
return new triangulation_element(*elem, previous->geometry_pointer()); return new triangulation_element(*elem, previous->geometry_pointer());
} }
} catch (...) { } catch (...) {
logger.message(::logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed."); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed.");
} }
return (triangulation_element*)nullptr; return (triangulation_element*)nullptr;
}); });
+6 -6
View File
@@ -128,14 +128,14 @@ namespace ifcopenshell::geom {
std::vector<ifcopenshell::geom::filter_t> filters_; std::vector<ifcopenshell::geom::filter_t> filters_;
int num_threads_; int num_threads_;
std::string geometry_library_; std::string geometry_library_;
::logger& logger_; ifcopenshell::logger& logger_;
// When single-threaded // When single-threaded
ifcopenshell::geom::converter* converter_; ifcopenshell::geom::converter* converter_;
// When multi-threaded // When multi-threaded
std::vector<ifcopenshell::geom::converter*> kernel_pool; std::vector<ifcopenshell::geom::converter*> kernel_pool;
std::vector<std::unique_ptr<::logger>> worker_loggers_; std::vector<std::unique_ptr<ifcopenshell::logger>> worker_loggers_;
// The object is fetched beforehand to be sure that get() returns a valid element // The object is fetched beforehand to be sure that get() returns a valid element
triangulation_element* current_triangulation; triangulation_element* current_triangulation;
@@ -170,7 +170,7 @@ namespace ifcopenshell::geom {
ifcopenshell::geom::element* process_based_on_settings( ifcopenshell::geom::element* process_based_on_settings(
ifcopenshell::geom::settings settings, ifcopenshell::geom::settings settings,
ifcopenshell::geom::brep_element* elem, ifcopenshell::geom::brep_element* elem,
::logger& logger, ifcopenshell::logger& logger,
ifcopenshell::geom::triangulation_element* previous = nullptr); ifcopenshell::geom::triangulation_element* previous = nullptr);
void flush_worker_log(ifcopenshell::geom::converter* kernel); void flush_worker_log(ifcopenshell::geom::converter* kernel);
@@ -183,7 +183,7 @@ namespace ifcopenshell::geom {
ifcopenshell::geom::taxonomy::direction3::ptr remove_offset_(); ifcopenshell::geom::taxonomy::direction3::ptr remove_offset_();
public: public:
iterator(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, const std::vector<ifcopenshell::geom::filter_t>& filters, int num_threads, ::logger& logger = ::logger::root()) iterator(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, const std::vector<ifcopenshell::geom::filter_t>& filters, int num_threads, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: settings_(settings) : settings_(settings)
, ifc_file(file) , ifc_file(file)
, filters_(filters) , filters_(filters)
@@ -195,7 +195,7 @@ namespace ifcopenshell::geom {
{ {
} }
iterator(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, ::logger& logger = ::logger::root()) iterator(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: settings_(settings) : settings_(settings)
, ifc_file(file) , ifc_file(file)
, num_threads_(1) , num_threads_(1)
@@ -205,7 +205,7 @@ namespace ifcopenshell::geom {
{ {
} }
iterator(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, int num_threads, ::logger& logger = ::logger::root()) iterator(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, int num_threads, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: settings_(settings) : settings_(settings)
, ifc_file(file) , ifc_file(file)
, num_threads_(num_threads) , num_threads_(num_threads)
+7 -3
View File
@@ -23,13 +23,15 @@
#include "ifc_geom_api.h" #include "ifc_geom_api.h"
#include "../ifcparse/file.h" #include "../ifcparse/file.h"
namespace ifcopenshell::geom {
class IFC_GEOM_API serializer { class IFC_GEOM_API serializer {
::logger& logger_; ifcopenshell::logger& logger_;
public: public:
explicit serializer(::logger& logger = ::logger::root()) : logger_(logger) {} explicit serializer(ifcopenshell::logger& logger = ifcopenshell::logger::root()) : logger_(logger) {}
virtual ~serializer() {} virtual ~serializer() {}
::logger& logger() const { return logger_; } ifcopenshell::logger& logger() const { return logger_; }
virtual bool ready() = 0; virtual bool ready() = 0;
virtual bool is_streaming() const { return false; } virtual bool is_streaming() const { return false; }
@@ -38,4 +40,6 @@ public:
virtual void setFile(ifcopenshell::file&) = 0; virtual void setFile(ifcopenshell::file&) = 0;
}; };
} // namespace ifcopenshell::geom
#endif #endif
+2 -2
View File
@@ -23,7 +23,7 @@ void ifcopenshell::geom::impl::mapping_registry::bind(const std::string& schema_
entry.module_ = module.meta().id.empty() ? plugin::module(mapping_plugin_metadata(schema_name)) : module; entry.module_ = module.meta().id.empty() ? plugin::module(mapping_plugin_metadata(schema_name)) : module;
} }
ifcopenshell::geom::abstract_mapping* ifcopenshell::geom::impl::mapping_registry::construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& log) { ifcopenshell::geom::abstract_mapping* ifcopenshell::geom::impl::mapping_registry::construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& log) {
const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name()); const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name());
auto it = entries_.find(schema_name_lower); auto it = entries_.find(schema_name_lower);
if (it == entries_.end()) { if (it == entries_.end()) {
@@ -56,6 +56,6 @@ void ifcopenshell::geom::impl::mapping_factory_implementation::bind(const std::s
mapping_registry_instance().bind(schema_name, fn, plugin::module(mapping_plugin_metadata(schema_name))); mapping_registry_instance().bind(schema_name, fn, plugin::module(mapping_plugin_metadata(schema_name)));
} }
ifcopenshell::geom::abstract_mapping* ifcopenshell::geom::impl::mapping_factory_implementation::construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& log) { ifcopenshell::geom::abstract_mapping* ifcopenshell::geom::impl::mapping_factory_implementation::construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& log) {
return mapping_registry_instance().construct(file, settings, log); return mapping_registry_instance().construct(file, settings, log);
} }
+6 -6
View File
@@ -49,12 +49,12 @@ namespace geom {
class IFC_GEOM_API abstract_mapping { class IFC_GEOM_API abstract_mapping {
protected: protected:
ifcopenshell::geom::settings settings_; ifcopenshell::geom::settings settings_;
::logger& logger_; ifcopenshell::logger& logger_;
bool use_caching_ = true; bool use_caching_ = true;
public: public:
abstract_mapping(ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) : settings_(settings), logger_(logger) {} abstract_mapping(ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) : settings_(settings), logger_(logger) {}
virtual ~abstract_mapping() {} virtual ~abstract_mapping() {}
virtual ifcopenshell::geom::taxonomy::ptr map(const express::base&) = 0; virtual ifcopenshell::geom::taxonomy::ptr map(const express::base&) = 0;
@@ -73,19 +73,19 @@ namespace geom {
const ifcopenshell::geom::settings& settings() const { return settings_; } const ifcopenshell::geom::settings& settings() const { return settings_; }
ifcopenshell::geom::settings& settings() { return settings_; } ifcopenshell::geom::settings& settings() { return settings_; }
::logger& logger() const { return logger_; } ifcopenshell::logger& logger() const { return logger_; }
bool use_caching() const { return use_caching_; } bool use_caching() const { return use_caching_; }
bool& use_caching() { return use_caching_; } bool& use_caching() { return use_caching_; }
}; };
namespace impl { namespace impl {
typedef boost::function3<abstract_mapping*, ifcopenshell::file*, ifcopenshell::geom::settings&, ::logger&> mapping_fn; typedef boost::function3<abstract_mapping*, ifcopenshell::file*, ifcopenshell::geom::settings&, ifcopenshell::logger&> mapping_fn;
class IFC_GEOM_API mapping_registry { class IFC_GEOM_API mapping_registry {
public: public:
void bind(const std::string& schema_name, mapping_fn fn, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module()); void bind(const std::string& schema_name, mapping_fn fn, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module());
abstract_mapping* construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()); abstract_mapping* construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root());
private: private:
struct entry { struct entry {
@@ -102,7 +102,7 @@ namespace geom {
public: public:
mapping_factory_implementation(); mapping_factory_implementation();
void bind(const std::string& schema_name, mapping_fn); void bind(const std::string& schema_name, mapping_fn);
abstract_mapping* construct(ifcopenshell::file*, ifcopenshell::geom::settings&, ::logger& logger = ::logger::root()); abstract_mapping* construct(ifcopenshell::file*, ifcopenshell::geom::settings&, ifcopenshell::logger& logger = ifcopenshell::logger::root());
}; };
IFC_GEOM_API mapping_factory_implementation& mapping_implementations(); IFC_GEOM_API mapping_factory_implementation& mapping_implementations();
+2 -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. /// @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 { struct IFC_GEOM_API fn_evaluator {
fn_evaluator(const ifcopenshell::geom::settings& settings, logger& logger = ::logger::root()) : settings_(settings), logger_(logger) { fn_evaluator(const ifcopenshell::geom::settings& settings, logger& logger = ifcopenshell::logger::root()) : settings_(settings), logger_(logger) {
} }
fn_evaluator(const fn_evaluator& other) = default; fn_evaluator(const fn_evaluator& other) = default;
virtual ~fn_evaluator() = default; virtual ~fn_evaluator() = default;
@@ -44,7 +44,7 @@ struct IFC_GEOM_API fn_evaluator {
/// @brief utility class to evaluate function_item objects. /// @brief utility class to evaluate function_item objects.
class IFC_GEOM_API function_item_evaluator { class IFC_GEOM_API function_item_evaluator {
public: public:
function_item_evaluator(const ifcopenshell::geom::settings& settings, taxonomy::function_item::const_ptr fn, logger& logger = ::logger::root()); function_item_evaluator(const ifcopenshell::geom::settings& settings, taxonomy::function_item::const_ptr fn, logger& logger = ifcopenshell::logger::root());
function_item_evaluator(const function_item_evaluator& other); function_item_evaluator(const function_item_evaluator& other);
~function_item_evaluator(); ~function_item_evaluator();
+2 -2
View File
@@ -32,7 +32,7 @@ namespace ifcopenshell {
ifcopenshell::geom::abstract_mapping* mapping_; ifcopenshell::geom::abstract_mapping* mapping_;
ifcopenshell::file* file_; ifcopenshell::file* file_;
public: public:
hybrid_kernel(const std::string& name, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, std::vector<std::unique_ptr<abstract_kernel>>&& kernels, ::logger& logger = ::logger::root()) hybrid_kernel(const std::string& name, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, std::vector<std::unique_ptr<abstract_kernel>>&& kernels, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: abstract_kernel(name, settings, logger) : abstract_kernel(name, settings, logger)
, kernels_(std::move(kernels)) , kernels_(std::move(kernels))
, mapping_(ifcopenshell::geom::impl::mapping_implementations().construct(file, settings, logger)) , mapping_(ifcopenshell::geom::impl::mapping_implementations().construct(file, settings, logger))
@@ -127,7 +127,7 @@ namespace ifcopenshell {
} }
return false; return false;
} }
virtual abstract_kernel* clone(::logger& logger) const virtual abstract_kernel* clone(ifcopenshell::logger& logger) const
{ {
std::vector<std::unique_ptr<abstract_kernel>> ks; std::vector<std::unique_ptr<abstract_kernel>> ks;
for (auto& k : kernels_) { for (auto& k : kernels_) {
+1 -1
View File
@@ -21,7 +21,7 @@ namespace ifcopenshell {
} }
}; };
IFC_GEOM_API taxonomy::loft::ptr make_loft(const ifcopenshell::geom::settings& settings, const express::base inst, const taxonomy::function_item::ptr& directrix, std::vector<cross_section>& cross_sections, logger& logger = ::logger::root()); IFC_GEOM_API taxonomy::loft::ptr make_loft(const ifcopenshell::geom::settings& settings, const express::base inst, const taxonomy::function_item::ptr& directrix, std::vector<cross_section>& cross_sections, logger& logger = ifcopenshell::logger::root());
} }
} }
@@ -12,6 +12,8 @@
using ifcopenshell::geom::opaque_number; using ifcopenshell::geom::opaque_number;
using ifcopenshell::geom::opaque_coordinate; using ifcopenshell::geom::opaque_coordinate;
using ifcopenshell::geom::conversion_result_shape; using ifcopenshell::geom::conversion_result_shape;
using ifcopenshell::geom::normalized_plane_for_map;
using ifcopenshell::geom::plane_map;
#ifdef IFOPSH_SIMPLE_KERNEL #ifdef IFOPSH_SIMPLE_KERNEL
#define NumberType opaque_number #define NumberType opaque_number
@@ -266,7 +268,7 @@ namespace {
} }
} }
ifcopenshell::geom::cgal_shape::cgal_shape(const cgal_shape_t& shape, bool convex, ::logger& logger) { ifcopenshell::geom::cgal_shape::cgal_shape(const cgal_shape_t& shape, bool convex, ifcopenshell::logger& logger) {
shape_ = shape; shape_ = shape;
convex_tag_ = convex; convex_tag_ = convex;
auto& poly = std::get<cgal_shape_t>(*shape_); auto& poly = std::get<cgal_shape_t>(*shape_);
@@ -362,7 +364,7 @@ void ifcopenshell::geom::cgal_shape::to_nef() const {
} }
#endif #endif
void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
if (is_point() || is_wire()) { if (is_point() || is_wire()) {
return; return;
} }
@@ -415,7 +417,7 @@ void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings se
if (!all_triangles) { if (!all_triangles) {
if (!shape_to_use->is_valid()) { if (!shape_to_use->is_valid()) {
logger.message(::logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)");
return; return;
} }
@@ -423,19 +425,19 @@ void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings se
try { try {
success = CGAL::Polygon_mesh_processing::triangulate_faces(*shape_to_use); success = CGAL::Polygon_mesh_processing::triangulate_faces(*shape_to_use);
} catch (...) { } catch (...) {
logger.message(::logger::LOG_ERROR, "GEO", 65, "Triangulation crashed"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 65, "Triangulation crashed");
return; return;
} }
CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_to_use); CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_to_use);
if (!success) { if (!success) {
logger.message(::logger::LOG_ERROR, "GEO", 66, "Triangulation failed"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 66, "Triangulation failed");
return; return;
} }
if (!shape_to_use->is_valid()) { if (!shape_to_use->is_valid()) {
logger.message(::logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)");
return; return;
} }
} }
@@ -464,7 +466,7 @@ void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings se
try { try {
CGAL::Polygon_mesh_processing::compute_face_normals(*shape_to_use, face_normals_map); CGAL::Polygon_mesh_processing::compute_face_normals(*shape_to_use, face_normals_map);
} catch (...) { } catch (...) {
logger.message(::logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed");
return; return;
} }
@@ -1033,7 +1035,7 @@ bool ifcopenshell::geom::cgal_shape::surface_area_along_direction(double tol, co
#ifndef IFOPSH_SIMPLE_KERNEL #ifndef IFOPSH_SIMPLE_KERNEL
void ifcopenshell::geom::cgal_shape_half_space_decomposition::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { void ifcopenshell::geom::cgal_shape_half_space_decomposition::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
throw std::runtime_error("Not implemented"); throw std::runtime_error("Not implemented");
} }
@@ -188,7 +188,7 @@ namespace ifcopenshell { namespace geom {
#endif #endif
public: public:
cgal_shape(const cgal_shape_t& shape, bool convex = false, ::logger& logger = ::logger::root()); cgal_shape(const cgal_shape_t& shape, bool convex = false, ifcopenshell::logger& logger = ifcopenshell::logger::root());
cgal_shape(const cgal_point_t& point, bool convex = false); cgal_shape(const cgal_point_t& point, bool convex = false);
cgal_shape(const cgal_wire_t& wire, bool convex = false); cgal_shape(const cgal_wire_t& wire, bool convex = false);
@@ -226,7 +226,7 @@ namespace ifcopenshell { namespace geom {
const cgal_point_t& point() const { return std::get<cgal_point_t>(*shape_); } const cgal_point_t& point() const { return std::get<cgal_point_t>(*shape_); }
const cgal_wire_t& wire() const { return std::get<cgal_wire_t>(*shape_); } const cgal_wire_t& wire() const { return std::get<cgal_wire_t>(*shape_); }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual ifcopenshell::geom::conversion_result_shape* clone() const { virtual ifcopenshell::geom::conversion_result_shape* clone() const {
@@ -319,7 +319,7 @@ namespace ifcopenshell { namespace geom {
#endif #endif
} }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const; virtual int surface_genus() const;
+33 -32
View File
@@ -40,6 +40,7 @@
using namespace ifcopenshell::geom; using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels; using namespace ifcopenshell::geom::kernels;
using ifcopenshell::logger;
namespace { namespace {
struct polyhedron_builder : public CGAL::Modifier_base<CGAL::Polyhedron_3<kernel_>::HalfedgeDS> { struct polyhedron_builder : public CGAL::Modifier_base<CGAL::Polyhedron_3<kernel_>::HalfedgeDS> {
@@ -48,7 +49,7 @@ namespace {
logger& logger_; logger& logger_;
public: public:
std::optional<cgal_shape_t> from_soup; std::optional<cgal_shape_t> from_soup;
polyhedron_builder(std::list<cgal_face_t> *face_list, logger& logger = ::logger::root()); polyhedron_builder(std::list<cgal_face_t> *face_list, logger& logger = ifcopenshell::logger::root());
void operator()(CGAL::Polyhedron_3<kernel_>::HalfedgeDS &hds); void operator()(CGAL::Polyhedron_3<kernel_>::HalfedgeDS &hds);
}; };
} }
@@ -76,7 +77,7 @@ CGAL::Polyhedron_3<kernel_> ifcopenshell::geom::utils::create_polyhedron(std::li
polyhedron.normalize_border(); polyhedron.normalize_border();
if (!polyhedron.is_valid(false, 1)) { if (!polyhedron.is_valid(false, 1)) {
logger.message(::logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!");
// std::ofstream fresult; // std::ofstream fresult;
// fresult.open("/Users/ken/Desktop/invalid.off"); // fresult.open("/Users/ken/Desktop/invalid.off");
// fresult << polyhedron << std::endl; // fresult << polyhedron << std::endl;
@@ -97,11 +98,11 @@ CGAL::Polyhedron_3<kernel_> ifcopenshell::geom::utils::create_polyhedron(const C
nef_polyhedron.convert_to_polyhedron(polyhedron); nef_polyhedron.convert_to_polyhedron(polyhedron);
return polyhedron; return polyhedron;
} catch (...) { } catch (...) {
logger.message(::logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!");
return CGAL::Polyhedron_3<kernel_>(); return CGAL::Polyhedron_3<kernel_>();
} }
} else { } else {
logger.message(::logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!");
return CGAL::Polyhedron_3<kernel_>(); return CGAL::Polyhedron_3<kernel_>();
} }
} }
@@ -114,7 +115,7 @@ CGAL::Nef_polyhedron_3<kernel_> ifcopenshell::geom::utils::create_nef_polyhedron
CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron); CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron);
} }
} catch (CGAL::Failure_exception& e) { } catch (CGAL::Failure_exception& e) {
logger.message(::logger::LOG_ERROR, "GEO", 72, e); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 72, e);
} }
} }
CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron); CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron);
@@ -122,7 +123,7 @@ CGAL::Nef_polyhedron_3<kernel_> ifcopenshell::geom::utils::create_nef_polyhedron
try { try {
nef_polyhedron = CGAL::Nef_polyhedron_3<kernel_>(polyhedron); nef_polyhedron = CGAL::Nef_polyhedron_3<kernel_>(polyhedron);
} catch (...) { } catch (...) {
logger.message(::logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!");
} }
return nef_polyhedron; return nef_polyhedron;
} }
@@ -137,7 +138,7 @@ CGAL::Nef_polyhedron_3<kernel_> ifcopenshell::geom::utils::create_nef_polyhedron
CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron); CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron);
} }
} catch (CGAL::Failure_exception& e) { } catch (CGAL::Failure_exception& e) {
logger.message(::logger::LOG_ERROR, "GEO", 74, e); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 74, e);
} }
} }
@@ -148,11 +149,11 @@ CGAL::Nef_polyhedron_3<kernel_> ifcopenshell::geom::utils::create_nef_polyhedron
try { try {
nef_polyhedron = CGAL::Nef_polyhedron_3<kernel_>(polyhedron); nef_polyhedron = CGAL::Nef_polyhedron_3<kernel_>(polyhedron);
} catch (...) { } catch (...) {
logger.message(::logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!");
} }
return nef_polyhedron; return nef_polyhedron;
} else { } else {
logger.message(::logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!"); logger.message(ifcopenshell::logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!");
return CGAL::Nef_polyhedron_3<kernel_>(); return CGAL::Nef_polyhedron_3<kernel_>();
} }
} }
@@ -215,10 +216,10 @@ bool cgal_kernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
if (!success) { if (!success) {
if (this->partial_success_is_success) { if (this->partial_success_is_success) {
logger().message(::logger::LOG_WARNING, "Failed to convert face, skipping:", f->instance); logger().message(ifcopenshell::logger::LOG_WARNING, "Failed to convert face, skipping:", f->instance);
continue; continue;
} else { } else {
logger().message(::logger::LOG_ERROR, "Failed to convert face:", f->instance); logger().message(ifcopenshell::logger::LOG_ERROR, "Failed to convert face:", f->instance);
return false; return false;
} }
} }
@@ -241,7 +242,7 @@ bool cgal_kernel::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) { 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(ifcopenshell::logger::LOG_ERROR, "GEO", 80, "Invalid configuration of boundaries for:", face->instance);
return false; return false;
} }
@@ -254,7 +255,7 @@ bool cgal_kernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>
cgal_wire_t wire; cgal_wire_t wire;
if (!convert(bound, wire)) { if (!convert(bound, wire)) {
logger().message(::logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance);
return false; return false;
} }
@@ -796,7 +797,7 @@ bool cgal_kernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
} }
if (do_segments_intersect(segments)) { if (do_segments_intersect(segments)) {
logger().message(::logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance); logger().message(ifcopenshell::logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance);
return false; return false;
} }
@@ -824,7 +825,7 @@ bool cgal_kernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
*/ */
if (count < 3) { if (count < 3) {
logger().message(::logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance);
return false; return false;
} }
@@ -1003,7 +1004,7 @@ bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::b
try { try {
a.convert_to_polyhedron(a_poly); a.convert_to_polyhedron(a_poly);
} catch (...) { } catch (...) {
logger().message(::logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity);
return false; return false;
} }
@@ -1202,7 +1203,7 @@ bool cgal_kernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::di
try { try {
nef_shape -= utils::create_nef_polyhedron(face_list); nef_shape -= utils::create_nef_polyhedron(face_list);
} catch (...) { } catch (...) {
::logger::root().message(::logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot subtract opening for:"); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot subtract opening for:");
return false; return false;
} }
} }
@@ -1219,7 +1220,7 @@ bool cgal_kernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::di
nef_shape.convert_to_polyhedron(shape); nef_shape.convert_to_polyhedron(shape);
return true; return true;
} catch (...) { } catch (...) {
::logger::root().message(::logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot convert Nef to polyhedron for:"); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "IfcExtrudedAreaSolid: cannot convert Nef to polyhedron for:");
return false; return false;
} }
*/ */
@@ -1228,7 +1229,7 @@ bool cgal_kernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::di
bool cgal_kernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) { bool cgal_kernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) {
const double& height = extrusion->depth; const double& height = extrusion->depth;
if (height < settings_.get<settings::Precision>().get()) { if (height < settings_.get<settings::Precision>().get()) {
logger().message(::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
return false; return false;
} }
@@ -1364,13 +1365,13 @@ bool cgal_kernel::preprocess_boolean_operand(const express::base& log_reference,
cgal_shape_t shape = shape_const; cgal_shape_t shape = shape_const;
if (!shape.is_valid()) { if (!shape.is_valid()) {
logger().message(::logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference);
return false; return false;
} }
if (!shape.is_closed()) { 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... // 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(ifcopenshell::logger::LOG_ERROR, "UNS", 6, "Subtraction of openings not supported for non-closed geometry:", log_reference);
return false; return false;
} }
@@ -1380,17 +1381,17 @@ bool cgal_kernel::preprocess_boolean_operand(const express::base& log_reference,
success = CGAL::Polygon_mesh_processing::triangulate_faces(shape); success = CGAL::Polygon_mesh_processing::triangulate_faces(shape);
} catch (CGAL::Failure_exception& e) { } catch (CGAL::Failure_exception& e) {
logger().notice("GEO", 91, e); logger().notice("GEO", 91, e);
logger().message(::logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference);
return false; return false;
} }
if (!success) { if (!success) {
logger().message(::logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference);
return false; return false;
} }
if (CGAL::Polygon_mesh_processing::does_self_intersect(shape)) { 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(ifcopenshell::logger::LOG_ERROR, "GEO", 94, "Conversion to Nef will fail. Self-intersecting geometry:", log_reference);
return false; return false;
} }
@@ -1463,7 +1464,7 @@ bool cgal_kernel::preprocess_boolean_operand(const express::base& log_reference,
result = CGAL::Nef_polyhedron_3<kernel_>(shape); result = CGAL::Nef_polyhedron_3<kernel_>(shape);
} catch (CGAL::Failure_exception& e) { } catch (CGAL::Failure_exception& e) {
logger().notice("GEO", 95, e); logger().notice("GEO", 95, e);
logger().message(::logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference);
return false; return false;
} }
@@ -1536,7 +1537,7 @@ bool cgal_kernel::preprocess_boolean_operand(const express::base& log_reference,
result = CGAL::minkowski_sum_3(result, precision_cube_); result = CGAL::minkowski_sum_3(result, precision_cube_);
} catch (CGAL::Failure_exception& e) { } catch (CGAL::Failure_exception& e) {
logger().notice("GEO", 97, e); logger().notice("GEO", 97, e);
logger().message(::logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference);
return false; return false;
} }
} }
@@ -1562,7 +1563,7 @@ bool cgal_kernel::preprocess_boolean_operand(const express::base& log_reference,
result.convert_to_polyhedron(convert_back); result.convert_to_polyhedron(convert_back);
} catch (CGAL::Failure_exception& e) { } catch (CGAL::Failure_exception& e) {
logger().notice("GEO", 99, 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().message(ifcopenshell::logger::LOG_WARNING, "GEO", 100, "Final conversion will likely fail. Could not convert geometry from Nef:", log_reference);
} }
return true; return true;
@@ -2169,7 +2170,7 @@ bool cgal_kernel::convert_impl(const taxonomy::boolean_result::ptr br, conversio
try { try {
a.convert_to_polyhedron(a_poly); a.convert_to_polyhedron(a_poly);
} catch (...) { } catch (...) {
logger().message(::logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance); logger().message(ifcopenshell::logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance);
return false; return false;
} }
@@ -2260,7 +2261,7 @@ void polyhedron_builder::operator()(CGAL::Polyhedron_3<kernel_>::HalfedgeDS &hds
// For now let's just skip over the triangle. We can also use // For now let's just skip over the triangle. We can also use
// the Aff_transformation_3 stored in place to convert the 2d // the Aff_transformation_3 stored in place to convert the 2d
// coords back to 3d. // coords back to 3d.
::logger::root().warning("Ignoring triangulated facet with novel point likely due to self-intersections"); ifcopenshell::logger::root().warning("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"); logger_.warning("GEO", 105, "Ignoring triangulated facet with novel point likely due to self-intersections");
facet_vertices.erase(facet_vertices.end() - 1); facet_vertices.erase(facet_vertices.end() - 1);
break; break;
@@ -2301,7 +2302,7 @@ void polyhedron_builder::operator()(CGAL::Polyhedron_3<kernel_>::HalfedgeDS &hds
if (!CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(facet_vertices)) { if (!CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(facet_vertices)) {
// @todo seems to return false now, almost always? // @todo seems to return false now, almost always?
// ::logger::root().warning("Reoriented polygonal surface"); // ifcopenshell::logger::root().warning("Reoriented polygonal surface");
CGAL::Polygon_mesh_processing::orient_polygon_soup(unique_points_as_vector, facet_vertices); CGAL::Polygon_mesh_processing::orient_polygon_soup(unique_points_as_vector, facet_vertices);
} }
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(unique_points_as_vector, facet_vertices, *from_soup); CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(unique_points_as_vector, facet_vertices, *from_soup);
@@ -2321,12 +2322,12 @@ void polyhedron_builder::operator()(CGAL::Polyhedron_3<kernel_>::HalfedgeDS &hds
if (added_edges.find(p) != added_edges.end()) { if (added_edges.find(p) != added_edges.end()) {
if (reoriented) { if (reoriented) {
facet_indices_to_delete.push_back(fi); facet_indices_to_delete.push_back(fi);
::logger::root().notice("Removed facet"); ifcopenshell::logger::root().notice("Removed facet");
valid = false; valid = false;
break; break;
} else { } else {
std::reverse(f.begin(), f.end()); std::reverse(f.begin(), f.end());
::logger::root().notice("Reversed facet"); ifcopenshell::logger::root().notice("Reversed facet");
reoriented = true; reoriented = true;
goto check_edge_existence; goto check_edge_existence;
} }
+6 -6
View File
@@ -60,12 +60,12 @@ namespace ifcopenshell {
namespace utils { namespace utils {
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<kernel_> create_cube(double d); 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_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, logger& logger = ::logger::root()); IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<kernel_> create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders = false, logger& logger = ifcopenshell::logger::root());
#ifndef IFOPSH_SIMPLE_KERNEL #ifndef IFOPSH_SIMPLE_KERNEL
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::Polyhedron_3<kernel_> create_polyhedron(const CGAL::Nef_polyhedron_3<kernel_> &nef_polyhedron, logger& logger = ifcopenshell::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(std::list<cgal_face_t> &face_list, logger& logger = ifcopenshell::logger::root());
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<kernel_> &polyhedron, logger& logger = ::logger::root()); IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<kernel_> &polyhedron, logger& logger = ifcopenshell::logger::root());
#endif #endif
} }
@@ -93,11 +93,11 @@ namespace ifcopenshell {
#endif #endif
public: public:
cgal_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) cgal_kernel(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: abstract_kernel("cgal", settings, logger) : abstract_kernel("cgal", settings, logger)
{} {}
virtual abstract_kernel* clone(::logger& logger) const { virtual abstract_kernel* clone(ifcopenshell::logger& logger) const {
return new cgal_kernel(settings(), logger); return new cgal_kernel(settings(), logger);
} }
@@ -52,6 +52,8 @@
#include <memory> #include <memory>
#include <functional> #include <functional>
namespace ifcopenshell::geom {
// Functor to lexicographically sort Plane_3 // Functor to lexicographically sort Plane_3
template <typename Kernel> template <typename Kernel>
struct plane_less { struct plane_less {
@@ -1378,4 +1380,6 @@ bool write_to_obj(const CGAL::Nef_polyhedron_3<Kernel>& a, std::ostream& ofs, si
return volume_index == std::numeric_limits<size_t>::max(); return volume_index == std::numeric_limits<size_t>::max();
} }
} // namespace ifcopenshell::geom
#endif #endif
@@ -215,7 +215,7 @@ std::optional<manifold::Manifold> ifcopenshell::geom::manifold_shape::as_manifol
return manifold::Manifold::BatchBoolean(solids, manifold::OpType::Add); return manifold::Manifold::BatchBoolean(solids, manifold::OpType::Add);
} }
void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger&) const { void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
for (const auto& part : parts_) { for (const auto& part : parts_) {
auto mesh = transform_mesh(part.mesh, place); auto mesh = transform_mesh(part.mesh, place);
std::vector<int> indices(mesh.NumVert()); std::vector<int> indices(mesh.NumVert());
@@ -40,7 +40,7 @@ public:
std::optional<manifold::Manifold> as_manifold() const; std::optional<manifold::Manifold> as_manifold() const;
virtual std::string_view backend_id() const { return "manifold"; } virtual std::string_view backend_id() const { return "manifold"; }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const; virtual int surface_genus() const;
+23 -23
View File
@@ -769,16 +769,16 @@ namespace {
const auto shell_info = diagnose_shell(shell); const auto shell_info = diagnose_shell(shell);
const auto before = diagnose_mesh(before_part.mesh, precision); const auto before = diagnose_mesh(before_part.mesh, precision);
const auto after = diagnose_mesh(after_mesh, precision); const auto after = diagnose_mesh(after_mesh, precision);
::logger::root().warning( ifcopenshell::logger::root().warning(
"Manifold kernel: solid shell manifold validation failed; before_transform=" + "Manifold kernel: solid shell manifold validation failed; before_transform=" +
std::string(before_part.solid ? "solid" : "mesh-only") + std::string(before_part.solid ? "solid" : "mesh-only") +
" (" + manifold_error_string(before_status) + "), after_transform=(" + manifold_error_string(after_status) + ")", " (" + manifold_error_string(before_status) + "), after_transform=(" + manifold_error_string(after_status) + ")",
shell->instance); shell->instance);
::logger::root().warning("Manifold kernel: solid shell diagnosis: " + solid_shell_failure_diagnosis(before_part, before, after, before_status, after_status), shell->instance); ifcopenshell::logger::root().warning("Manifold kernel: solid shell diagnosis: " + solid_shell_failure_diagnosis(before_part, before, after, before_status, after_status), shell->instance);
::logger::root().warning("Manifold kernel: solid shell input: " + shell_diagnostics_string(shell_info), shell->instance); ifcopenshell::logger::root().warning("Manifold kernel: solid shell input: " + shell_diagnostics_string(shell_info), shell->instance);
::logger::root().warning("Manifold kernel: solid shell mesh before transform: " + mesh_diagnostics_string(before), shell->instance); ifcopenshell::logger::root().warning("Manifold kernel: solid shell mesh before transform: " + mesh_diagnostics_string(before), shell->instance);
::logger::root().warning("Manifold kernel: solid shell transform: " + matrix_diagnostics_string(place), shell->instance); ifcopenshell::logger::root().warning("Manifold kernel: solid shell transform: " + matrix_diagnostics_string(place), shell->instance);
::logger::root().warning("Manifold kernel: solid shell mesh after transform: " + mesh_diagnostics_string(after), shell->instance); ifcopenshell::logger::root().warning("Manifold kernel: solid shell mesh after transform: " + mesh_diagnostics_string(after), shell->instance);
} }
double signed_area(const manifold::SimplePolygon& polygon) { double signed_area(const manifold::SimplePolygon& polygon) {
@@ -1492,7 +1492,7 @@ namespace {
bool manifold_kernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ifcopenshell::geom::conversion_results& results) { bool manifold_kernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ifcopenshell::geom::conversion_results& results) {
auto part = part_from_extrusion(extrusion, settings_.get<settings::Precision>().get(), dilation_hack, settings_.get<settings::CircleSegments>().get()); auto part = part_from_extrusion(extrusion, settings_.get<settings::Precision>().get(), dilation_hack, settings_.get<settings::CircleSegments>().get());
if (!part) { if (!part) {
::logger::root().warning("Manifold kernel: failed to convert extrusion, requires planar bounds with line, circle or ellipse edges", extrusion->instance); ifcopenshell::logger::root().warning("Manifold kernel: failed to convert extrusion, requires planar bounds with line, circle or ellipse edges", extrusion->instance);
return false; return false;
} }
results.emplace_back(ifcopenshell::geom::conversion_result( results.emplace_back(ifcopenshell::geom::conversion_result(
@@ -1507,11 +1507,11 @@ bool manifold_kernel::convert_impl(const taxonomy::shell::ptr shell, ifcopenshel
manifold::Manifold::Error status = manifold::Manifold::Error::NoError; manifold::Manifold::Error status = manifold::Manifold::Error::NoError;
auto part = part_from_shell(shell, settings_.get<settings::Precision>().get(), dilation_hack, &status); auto part = part_from_shell(shell, settings_.get<settings::Precision>().get(), dilation_hack, &status);
if (!part) { if (!part) {
::logger::root().warning("Manifold kernel: failed to convert shell, requires planar polygonal faces with explicit vertices", shell->instance); ifcopenshell::logger::root().warning("Manifold kernel: failed to convert shell, requires planar polygonal faces with explicit vertices", shell->instance);
return false; return false;
} }
if (!part->solid) { if (!part->solid) {
::logger::root().notice("Manifold kernel: shell converted as mesh only (" + manifold_error_string(status) + ")", shell->instance); ifcopenshell::logger::root().notice("Manifold kernel: shell converted as mesh only (" + manifold_error_string(status) + ")", shell->instance);
} }
results.emplace_back(ifcopenshell::geom::conversion_result( results.emplace_back(ifcopenshell::geom::conversion_result(
shell->instance.id(), shell->instance.id(),
@@ -1528,7 +1528,7 @@ bool manifold_kernel::convert_impl(const taxonomy::solid::ptr solid, ifcopenshel
manifold::Manifold::Error before_status = manifold::Manifold::Error::NoError; manifold::Manifold::Error before_status = manifold::Manifold::Error::NoError;
auto part = part_from_shell(shell, precision, dilation_hack, &before_status); auto part = part_from_shell(shell, precision, dilation_hack, &before_status);
if (!part) { if (!part) {
::logger::root().warning("Manifold kernel: failed to convert solid shell, requires planar polygonal faces with explicit vertices", shell->instance); ifcopenshell::logger::root().warning("Manifold kernel: failed to convert solid shell, requires planar polygonal faces with explicit vertices", shell->instance);
return false; return false;
} }
auto place = shell->matrix ? shell->matrix : taxonomy::make<taxonomy::matrix4>(); auto place = shell->matrix ? shell->matrix : taxonomy::make<taxonomy::matrix4>();
@@ -1570,21 +1570,21 @@ bool manifold_kernel::convert_impl(const taxonomy::boolean_result::ptr br, ifcop
dilation_hack = first ? 0. : precision * 10.; dilation_hack = first ? 0. : precision * 10.;
if (!first && br->operation == taxonomy::boolean_result::SUBTRACTION && face) { if (!first && br->operation == taxonomy::boolean_result::SUBTRACTION && face) {
if (!first_bbox) { if (!first_bbox) {
::logger::root().warning("Manifold kernel: cannot fit halfspace operand without a valid first operand bounds", child->instance); ifcopenshell::logger::root().warning("Manifold kernel: cannot fit halfspace operand without a valid first operand bounds", child->instance);
return false; return false;
} }
halfspace_build_state state; halfspace_build_state state;
auto part = part_from_halfspace_solid(state, solid, face, *first_bbox, precision, dilation_hack); auto part = part_from_halfspace_solid(state, solid, face, *first_bbox, precision, dilation_hack);
if (!part) { if (!part) {
if (state.unchanged && br->operation == taxonomy::boolean_result::SUBTRACTION) { if (state.unchanged && br->operation == taxonomy::boolean_result::SUBTRACTION) {
::logger::root().warning("Manifold kernel: halfspace subtraction yields unchanged volume", child->instance); ifcopenshell::logger::root().warning("Manifold kernel: halfspace subtraction yields unchanged volume", child->instance);
continue; continue;
} }
::logger::root().warning("Manifold kernel: failed to fit halfspace boolean operand to first operand bounds", child->instance); ifcopenshell::logger::root().warning("Manifold kernel: failed to fit halfspace boolean operand to first operand bounds", child->instance);
return false; return false;
} }
if (!part->solid) { if (!part->solid) {
::logger::root().warning("Manifold kernel: fitted halfspace operand is not a valid manifold solid", child->instance); ifcopenshell::logger::root().warning("Manifold kernel: fitted halfspace operand is not a valid manifold solid", child->instance);
return false; return false;
} }
operand = *part->solid; operand = *part->solid;
@@ -1594,12 +1594,12 @@ bool manifold_kernel::convert_impl(const taxonomy::boolean_result::ptr br, ifcop
} else { } else {
ifcopenshell::geom::conversion_results converted; ifcopenshell::geom::conversion_results converted;
if (!abstract_kernel::convert(child, converted)) { if (!abstract_kernel::convert(child, converted)) {
::logger::root().warning("Manifold kernel: failed to convert boolean operand", child->instance); ifcopenshell::logger::root().warning("Manifold kernel: failed to convert boolean operand", child->instance);
return false; return false;
} }
operand = results_to_operand(converted); operand = results_to_operand(converted);
if (!operand) { if (!operand) {
::logger::root().warning("Manifold kernel: boolean operand is not a valid manifold solid", child->instance); ifcopenshell::logger::root().warning("Manifold kernel: boolean operand is not a valid manifold solid", child->instance);
return false; return false;
} }
if (!style) { if (!style) {
@@ -1612,7 +1612,7 @@ bool manifold_kernel::convert_impl(const taxonomy::boolean_result::ptr br, ifcop
if (first) { if (first) {
auto bbox = operand->BoundingBox(); auto bbox = operand->BoundingBox();
if (!bbox.IsFinite()) { if (!bbox.IsFinite()) {
::logger::root().warning("Manifold kernel: first boolean operand has no valid bounds", child->instance); ifcopenshell::logger::root().warning("Manifold kernel: first boolean operand has no valid bounds", child->instance);
return false; return false;
} }
first_bbox = bbox; first_bbox = bbox;
@@ -1623,7 +1623,7 @@ bool manifold_kernel::convert_impl(const taxonomy::boolean_result::ptr br, ifcop
dilation_hack = 0.; dilation_hack = 0.;
auto result = boolean_result_from_operands(operands, br->operation); auto result = boolean_result_from_operands(operands, br->operation);
if (!result || result->IsEmpty()) { if (!result || result->IsEmpty()) {
::logger::root().warning("Manifold kernel: boolean operation produced no result", br->instance); ifcopenshell::logger::root().warning("Manifold kernel: boolean operation produced no result", br->instance);
return false; return false;
} }
results.emplace_back(ifcopenshell::geom::conversion_result( results.emplace_back(ifcopenshell::geom::conversion_result(
@@ -1638,7 +1638,7 @@ bool manifold_kernel::convert_openings(const express::base&, const std::vector<s
std::vector<manifold::Manifold> opening_operands; std::vector<manifold::Manifold> opening_operands;
auto entity_bbox = results_bbox(entity_shapes); auto entity_bbox = results_bbox(entity_shapes);
if (!entity_bbox) { if (!entity_bbox) {
::logger::root().warning("Manifold kernel: host shape has no valid bounds for halfspace fitting"); ifcopenshell::logger::root().warning("Manifold kernel: host shape has no valid bounds for halfspace fitting");
return false; return false;
} }
dilation_hack = settings_.get<settings::Precision>().get() * 10.; dilation_hack = settings_.get<settings::Precision>().get() * 10.;
@@ -1646,19 +1646,19 @@ bool manifold_kernel::convert_openings(const express::base&, const std::vector<s
const auto relative = taxonomy::make<taxonomy::matrix4>(entity_trsf.ccomponents().inverse() * opening.second.ccomponents()); const auto relative = taxonomy::make<taxonomy::matrix4>(entity_trsf.ccomponents().inverse() * opening.second.ccomponents());
ifcopenshell::geom::conversion_results converted; ifcopenshell::geom::conversion_results converted;
if (!abstract_kernel::convert(opening.first, converted)) { if (!abstract_kernel::convert(opening.first, converted)) {
::logger::root().warning("Manifold kernel: failed to convert opening operand", opening.first->instance); ifcopenshell::logger::root().warning("Manifold kernel: failed to convert opening operand", opening.first->instance);
return false; return false;
} }
for (const auto& result : converted) { for (const auto& result : converted) {
auto moved = std::unique_ptr<ifcopenshell::geom::conversion_result_shape>(result.Shape()->moved(taxonomy::make<taxonomy::matrix4>(relative->ccomponents() * result.Placement()->ccomponents()))); auto moved = std::unique_ptr<ifcopenshell::geom::conversion_result_shape>(result.Shape()->moved(taxonomy::make<taxonomy::matrix4>(relative->ccomponents() * result.Placement()->ccomponents())));
auto* shape = dynamic_cast<ifcopenshell::geom::manifold_shape*>(moved.get()); auto* shape = dynamic_cast<ifcopenshell::geom::manifold_shape*>(moved.get());
if (!shape) { if (!shape) {
::logger::root().warning("Manifold kernel: opening result is not a manifold shape"); ifcopenshell::logger::root().warning("Manifold kernel: opening result is not a manifold shape");
return false; return false;
} }
auto operand = shape->as_manifold(); auto operand = shape->as_manifold();
if (!operand) { if (!operand) {
::logger::root().warning("Manifold kernel: opening result is not a valid manifold solid", opening.first->instance); ifcopenshell::logger::root().warning("Manifold kernel: opening result is not a valid manifold solid", opening.first->instance);
return false; return false;
} }
opening_operands.push_back(*operand); opening_operands.push_back(*operand);
@@ -1672,7 +1672,7 @@ bool manifold_kernel::convert_openings(const express::base&, const std::vector<s
for (const auto& entity_shape : entity_shapes) { for (const auto& entity_shape : entity_shapes) {
auto operand = result_to_manifold(entity_shape); auto operand = result_to_manifold(entity_shape);
if (!operand) { if (!operand) {
::logger::root().warning("Manifold kernel: host shape is not a valid manifold solid"); ifcopenshell::logger::root().warning("Manifold kernel: host shape is not a valid manifold solid");
return false; return false;
} }
auto result = *operand - opening_union; auto result = *operand - opening_union;
@@ -13,10 +13,10 @@ namespace kernels {
class IFC_GEOMLIBRARY_API manifold_kernel : public abstract_kernel { class IFC_GEOMLIBRARY_API manifold_kernel : public abstract_kernel {
public: public:
manifold_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) manifold_kernel(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: abstract_kernel("manifold", settings, logger) {} : abstract_kernel("manifold", settings, logger) {}
virtual abstract_kernel* clone(::logger& logger) const { virtual abstract_kernel* clone(ifcopenshell::logger& logger) const {
return new manifold_kernel(settings(), logger); return new manifold_kernel(settings(), logger);
} }
@@ -68,7 +68,7 @@ ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::open_cascade_sh
return new open_cascade_shape(shape_); return new open_cascade_shape(shape_);
} }
void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
// @todo remove duplication with open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf); // @todo remove duplication with open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// above can be static? // above can be static?
@@ -108,7 +108,7 @@ void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::set
try { try {
BRepMesh_IncrementalMesh(shape_, settings.get<settings::MesherLinearDeflection>().get(), false, settings.get<settings::MesherAngularDeflection>().get()); BRepMesh_IncrementalMesh(shape_, settings.get<settings::MesherLinearDeflection>().get(), false, settings.get<settings::MesherAngularDeflection>().get());
} catch (...) { } catch (...) {
::logger::root().message(::logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape"); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape");
return; return;
} }
} }
@@ -134,7 +134,7 @@ void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::set
opencascade::handle<Poly_Triangulation> tri = BRep_Tool::Triangulation(face, loc); opencascade::handle<Poly_Triangulation> tri = BRep_Tool::Triangulation(face, loc);
if (tri.IsNull()) { if (tri.IsNull()) {
::logger::root().message(::logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face"); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face");
} else { } else {
// Keep track of the number of times an edge is used // Keep track of the number of times an edge is used
// Manifold edges (i.e. edges used twice) are deemed invisible // Manifold edges (i.e. edges used twice) are deemed invisible
@@ -640,7 +640,7 @@ namespace {
try { try {
BRepMesh_IncrementalMesh(s, tol); BRepMesh_IncrementalMesh(s, tol);
} catch (...) { } catch (...) {
::logger::root().message(::logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape"); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape");
return; return;
} }
meshed = true; meshed = true;
@@ -49,7 +49,7 @@ namespace ifcopenshell {
operator const TopoDS_Shape& (); operator const TopoDS_Shape& ();
virtual std::string_view backend_id() const; virtual std::string_view backend_id() const;
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual ifcopenshell::geom::conversion_result_shape* clone() const; virtual ifcopenshell::geom::conversion_result_shape* clone() const;
@@ -190,7 +190,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba
const auto& m = it3->Placement()->ccomponents(); const auto& m = it3->Placement()->ccomponents();
// @todo // @todo
// if (entity_shape_gtrsf.Form() == gp_Other) { // if (entity_shape_gtrsf.Form() == gp_Other) {
// ::logger::root().message(::logger::LOG_WARNING, "Applying non uniform transformation to:", entity); // ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "Applying non uniform transformation to:", entity);
// } // }
gp_Trsf entity_shape_gtrsf; gp_Trsf entity_shape_gtrsf;
entity_shape_gtrsf.SetValues( entity_shape_gtrsf.SetValues(
@@ -217,7 +217,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba
if (util::boolean_operation(bst, result, opening_list, BOPAlgo_CUT, intermediate_result)) { if (util::boolean_operation(bst, result, opening_list, BOPAlgo_CUT, intermediate_result)) {
result = intermediate_result; result = intermediate_result;
} else { } else {
logger_.message(::logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast<std::string>(std::distance(jt, it)) + " openings", entity); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast<std::string>(std::distance(jt, it)) + " openings", entity);
} }
jt = it; jt = it;
@@ -417,7 +417,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// } // }
// //
// if (!success) { // if (!success) {
// ::logger::root().error("Failed processing layerset"); // ifcopenshell::logger::root().error("Failed processing layerset");
// } // }
// } // }
// } // }
@@ -445,7 +445,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// } // }
// } // }
// if (some_items_without_style) { // if (some_items_without_style) {
// ::logger::root().warning("No material and surface styles for:", product); // ifcopenshell::logger::root().warning("No material and surface styles for:", product);
// } // }
// } // }
// //
@@ -472,7 +472,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// parent_id = parent_object->data().id(); // parent_id = parent_object->data().id();
// } // }
// } catch (const std::exception& e) { // } catch (const std::exception& e) {
// ::logger::root().error(e); // ifcopenshell::logger::root().error(e);
// } // }
// //
// const std::string name = product->Name().value_or(""); // const std::string name = product->Name().value_or("");
@@ -484,9 +484,9 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// convert(product->ObjectPlacement(), trsf); // convert(product->ObjectPlacement(), trsf);
// } // }
// } catch (const std::exception& e) { // } catch (const std::exception& e) {
// ::logger::root().error(e); // ifcopenshell::logger::root().error(e);
// } catch (...) { // } catch (...) {
// ::logger::root().error("Failed to construct placement"); // ifcopenshell::logger::root().error("Failed to construct placement");
// } // }
// //
// // Does the IfcElement have any IfcOpenings? // // Does the IfcElement have any IfcOpenings?
@@ -507,10 +507,10 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// try { // try {
// convert_openings(product, openings, shapes, trsf, opened_shapes); // convert_openings(product, openings, shapes, trsf, opened_shapes);
// } catch (const std::exception& e) { // } catch (const std::exception& e) {
// ::logger::root().message(::logger::LOG_ERROR, std::string("error processing openings for: ") + e.what() + ":", product); // ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, std::string("error processing openings for: ") + e.what() + ":", product);
// caught_error = true; // caught_error = true;
// } catch (...) { // } catch (...) {
// ::logger::root().message(::logger::LOG_ERROR, "error processing openings for:", product); // ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "error processing openings for:", product);
// } // }
// //
// if (caught_error && opened_shapes.size() < shapes.size()) { // if (caught_error && opened_shapes.size() < shapes.size()) {
@@ -575,12 +575,12 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// if (elem->geometry().calculate_surface_area(a_calc)) { // if (elem->geometry().calculate_surface_area(a_calc)) {
// double diff = std::abs(a_calc - a_file); // double diff = std::abs(a_calc - a_file);
// if (diff / std::sqrt(a_file) > getValue(GV_PRECISION)) { // if (diff / std::sqrt(a_file) > getValue(GV_PRECISION)) {
// ::logger::root().error("Validation of surface area failed for:", product); // ifcopenshell::logger::root().error("Validation of surface area failed for:", product);
// } else { // } else {
// ::logger::root().notice("Validation of surface area succeeded for:", product); // ifcopenshell::logger::root().notice("Validation of surface area succeeded for:", product);
// } // }
// } else { // } else {
// ::logger::root().error("Validation of surface area failed for:", product); // ifcopenshell::logger::root().error("Validation of surface area failed for:", product);
// } // }
// } else if (q->as<IfcSchema::IfcQuantityVolume>() && q->Name() == "Volume") { // } else if (q->as<IfcSchema::IfcQuantityVolume>() && q->Name() == "Volume") {
// double v_calc; // double v_calc;
@@ -588,12 +588,12 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// if (elem->geometry().calculate_volume(v_calc)) { // if (elem->geometry().calculate_volume(v_calc)) {
// double diff = std::abs(v_calc - v_file); // double diff = std::abs(v_calc - v_file);
// if (diff / std::sqrt(v_file) > getValue(GV_PRECISION)) { // if (diff / std::sqrt(v_file) > getValue(GV_PRECISION)) {
// ::logger::root().error("Validation of volume failed for:", product); // ifcopenshell::logger::root().error("Validation of volume failed for:", product);
// } else { // } else {
// ::logger::root().notice("Validation of volume succeeded for:", product); // ifcopenshell::logger::root().notice("Validation of volume succeeded for:", product);
// } // }
// } else { // } else {
// ::logger::root().error("Validation of volume failed for:", product); // ifcopenshell::logger::root().error("Validation of volume failed for:", product);
// } // }
// } else if (q->as<IfcSchema::IfcPhysicalComplexQuantity>() && q->Name() == "Shape Validation Properties") { // } else if (q->as<IfcSchema::IfcPhysicalComplexQuantity>() && q->Name() == "Shape Validation Properties") {
// auto qs2 = q->as<IfcSchema::IfcPhysicalComplexQuantity>()->HasQuantities(); // auto qs2 = q->as<IfcSchema::IfcPhysicalComplexQuantity>()->HasQuantities();
@@ -612,9 +612,9 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// } // }
// } // }
// if (!all_succeeded) { // if (!all_succeeded) {
// ::logger::root().error("Validation of surface genus failed for:", product); // ifcopenshell::logger::root().error("Validation of surface genus failed for:", product);
// } else { // } else {
// ::logger::root().notice("Validation of surface genus succeeded for:", product); // ifcopenshell::logger::root().notice("Validation of surface genus succeeded for:", product);
// } // }
// } // }
// } // }
@@ -646,7 +646,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// } // }
// } // }
// } catch (const ifcopenshell::exception& e) { // } catch (const ifcopenshell::exception& e) {
// ::logger::root().error(e); // ifcopenshell::logger::root().error(e);
// // @todo reset representation_mapped_to to zero? // // @todo reset representation_mapped_to to zero?
// } // }
// return representation_mapped_to; // return representation_mapped_to;
@@ -670,15 +670,15 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap(); // IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap();
// //
// if (products->size() && maps->size()) { // if (products->size() && maps->size()) {
// ::logger::root().warning("Representation used by IfcRepresentationMap and IfcProductDefinitionShape", representation); // ifcopenshell::logger::root().warning("Representation used by IfcRepresentationMap and IfcProductDefinitionShape", representation);
// } // }
// //
// if (prodreps->size() > 1) { // if (prodreps->size() > 1) {
// ::logger::root().warning("Multiple IfcProductDefinitionShapes for representation", representation); // ifcopenshell::logger::root().warning("Multiple IfcProductDefinitionShapes for representation", representation);
// } // }
// //
// if (maps->size() > 1) { // if (maps->size() > 1) {
// ::logger::root().warning("Multiple IfcRepresentationMaps for representation", representation); // ifcopenshell::logger::root().warning("Multiple IfcRepresentationMaps for representation", representation);
// } // }
// //
// if (maps->size() == 1) { // if (maps->size() == 1) {
@@ -721,7 +721,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// parent_id = parent_object->data().id(); // parent_id = parent_object->data().id();
// } // }
// } catch (const std::exception& e) { // } catch (const std::exception& e) {
// ::logger::root().error(e); // ifcopenshell::logger::root().error(e);
// } // }
// //
// const std::string name = product->Name().value_or(""); // const std::string name = product->Name().value_or("");
@@ -733,9 +733,9 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// convert(product->ObjectPlacement(), trsf); // convert(product->ObjectPlacement(), trsf);
// } // }
// } catch (const std::exception& e) { // } catch (const std::exception& e) {
// ::logger::root().error(e); // ifcopenshell::logger::root().error(e);
// } catch (...) { // } catch (...) {
// ::logger::root().error("Failed to construct placement"); // ifcopenshell::logger::root().error("Failed to construct placement");
// } // }
// //
// std::string context_string = ""; // std::string context_string = "";
@@ -937,7 +937,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// // range. It's only a safeguard though, so can probably be approximated. // // range. It's only a safeguard though, so can probably be approximated.
// const double axis_length = own_axis_start.Distance(own_axis_end); // const double axis_length = own_axis_start.Distance(own_axis_end);
// if (length_required > axis_length) { // if (length_required > axis_length) {
// ::logger::root().warning("The wall axis is not long enough to accommodate the fold points"); // ifcopenshell::logger::root().warning("The wall axis is not long enough to accommodate the fold points");
// return false; // return false;
// } // }
// //
@@ -957,7 +957,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// gp_Trsf other; // gp_Trsf other;
// if (other_wall->ObjectPlacement()) { // if (other_wall->ObjectPlacement()) {
// if (!convert(other_wall->ObjectPlacement(), other)) { // if (!convert(other_wall->ObjectPlacement(), other)) {
// ::logger::root().error("Failed to convert placement", other_wall); // ifcopenshell::logger::root().error("Failed to convert placement", other_wall);
// continue; // continue;
// } // }
// } // }
@@ -965,7 +965,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// IfcSchema::IfcRepresentation* axis_representation = find_representation(other_wall, "Axis"); // IfcSchema::IfcRepresentation* axis_representation = find_representation(other_wall, "Axis");
// //
// if (!axis_representation) { // if (!axis_representation) {
// ::logger::root().warning("Joined wall has no axis representation", other_wall); // ifcopenshell::logger::root().warning("Joined wall has no axis representation", other_wall);
// continue; // continue;
// } // }
// //
@@ -1059,7 +1059,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// Vs1.Cross(Vs2); // Vs1.Cross(Vs2);
// //
// if (Vs1.IsNormal(Vc, 1.e-5)) { // if (Vs1.IsNormal(Vc, 1.e-5)) {
// ::logger::root().warning("Connected walls are parallel"); // ifcopenshell::logger::root().warning("Connected walls are parallel");
// parallel = true; // parallel = true;
// } else if (w < axis_u1 || w > axis_u2) { // } else if (w < axis_u1 || w > axis_u2) {
// point_outside_param_range = p; // point_outside_param_range = p;
@@ -1394,7 +1394,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// Handle_Geom_Circle axis_line = Handle_Geom_Circle::DownCast(axis_curve); // Handle_Geom_Circle axis_line = Handle_Geom_Circle::DownCast(axis_curve);
// reference_surface = new Geom_CylindricalSurface(axis_li->Position(), axis_line->Radius()); // reference_surface = new Geom_CylindricalSurface(axis_li->Position(), axis_line->Radius());
// } else { // } else {
// ::logger::root().message(::logger::LOG_ERROR, "Unsupported underlying curve of Axis representation:", product); // ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "Unsupported underlying curve of Axis representation:", product);
// return false; // return false;
// } // }
// //
@@ -110,13 +110,13 @@ private:
double precision_; double precision_;
public: public:
open_cascade_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) open_cascade_kernel(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: abstract_kernel("opencascade", settings, logger) : abstract_kernel("opencascade", settings, logger)
, faceset_helper_(nullptr) , faceset_helper_(nullptr)
, precision_(settings.get<ifcopenshell::geom::settings::Precision>().get()) , precision_(settings.get<ifcopenshell::geom::settings::Precision>().get())
{} {}
virtual abstract_kernel* clone(::logger& logger) const { virtual abstract_kernel* clone(ifcopenshell::logger& logger) const {
return new open_cascade_kernel(settings(), logger); return new open_cascade_kernel(settings(), logger);
} }
+13 -13
View File
@@ -714,12 +714,12 @@ bool ifcopenshell::geom::util::create_solid_from_faces(const NCollection_List<To
valid_shell &= util::count(shape, TopAbs_SHELL) > 0; valid_shell &= util::count(shape, TopAbs_SHELL) > 0;
} catch (const Standard_Failure& e) { } catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) { if (e.GetMessageString() && strlen(e.GetMessageString())) {
::logger::root().error("GEO", 106, e.GetMessageString()); ifcopenshell::logger::root().error("GEO", 106, e.GetMessageString());
} else { } else {
::logger::root().error("GEO", 107, "Unknown error sewing shell"); ifcopenshell::logger::root().error("GEO", 107, "Unknown error sewing shell");
} }
} catch (...) { } catch (...) {
::logger::root().error("GEO", 108, "Unknown error sewing shell"); ifcopenshell::logger::root().error("GEO", 108, "Unknown error sewing shell");
} }
if (valid_shell) { if (valid_shell) {
@@ -747,22 +747,22 @@ bool ifcopenshell::geom::util::create_solid_from_faces(const NCollection_List<To
} }
} catch (const Standard_Failure& e) { } catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) { if (e.GetMessageString() && strlen(e.GetMessageString())) {
::logger::root().error("GEO", 109, e.GetMessageString()); ifcopenshell::logger::root().error("GEO", 109, e.GetMessageString());
} else { } else {
::logger::root().error("GEO", 110, "Unknown error classifying solid"); ifcopenshell::logger::root().error("GEO", 110, "Unknown error classifying solid");
} }
} catch (...) { } catch (...) {
::logger::root().error("GEO", 111, "Unknown error classifying solid"); ifcopenshell::logger::root().error("GEO", 111, "Unknown error classifying solid");
} }
} }
} catch (const Standard_Failure& e) { } catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) { if (e.GetMessageString() && strlen(e.GetMessageString())) {
::logger::root().error("GEO", 112, e.GetMessageString()); ifcopenshell::logger::root().error("GEO", 112, e.GetMessageString());
} else { } else {
::logger::root().error("GEO", 113, "Unknown error creating solid"); ifcopenshell::logger::root().error("GEO", 113, "Unknown error creating solid");
} }
} catch (...) { } catch (...) {
::logger::root().error("GEO", 114, "Unknown error creating solid"); ifcopenshell::logger::root().error("GEO", 114, "Unknown error creating solid");
} }
if (complete_shape.IsNull()) { if (complete_shape.IsNull()) {
@@ -774,7 +774,7 @@ bool ifcopenshell::geom::util::create_solid_from_faces(const NCollection_List<To
B.MakeCompound(C); B.MakeCompound(C);
B.Add(C, complete_shape); B.Add(C, complete_shape);
complete_shape = C; complete_shape = C;
::logger::root().warning("GEO", 115, "Multiple components in IfcConnectedFaceSet"); ifcopenshell::logger::root().warning("GEO", 115, "Multiple components in IfcConnectedFaceSet");
} }
B.Add(complete_shape, result_shape); B.Add(complete_shape, result_shape);
} }
@@ -789,7 +789,7 @@ bool ifcopenshell::geom::util::create_solid_from_faces(const NCollection_List<To
B.MakeCompound(C); B.MakeCompound(C);
B.Add(C, complete_shape); B.Add(C, complete_shape);
complete_shape = C; complete_shape = C;
::logger::root().warning("GEO", 116, "Loose faces in IfcConnectedFaceSet"); ifcopenshell::logger::root().warning("GEO", 116, "Loose faces in IfcConnectedFaceSet");
} }
B.Add(complete_shape, loose_faces.Current()); B.Add(complete_shape, loose_faces.Current());
} }
@@ -797,7 +797,7 @@ bool ifcopenshell::geom::util::create_solid_from_faces(const NCollection_List<To
shape = complete_shape; shape = complete_shape;
} else { } else {
::logger::root().error("GEO", 117, "Failed to sew faceset"); ifcopenshell::logger::root().error("GEO", 117, "Failed to sew faceset");
} }
return valid_shell; return valid_shell;
@@ -901,7 +901,7 @@ bool ifcopenshell::geom::util::validate_shape(const TopoDS_Shape& s) {
dump(s); dump(s);
::logger::root().warning("GEO", 118, str.str()); ifcopenshell::logger::root().warning("GEO", 118, str.str());
return false; return false;
} }
@@ -117,7 +117,7 @@ bool open_cascade_kernel::convert_impl(const taxonomy::boolean_result::ptr br, c
const double first_operand_volume = util::shape_volume(a); const double first_operand_volume = util::shape_volume(a);
if (first_operand_volume <= ALMOST_ZERO) { if (first_operand_volume <= ALMOST_ZERO) {
logger_.message(::logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance);
} }
} else { } else {
@@ -139,7 +139,7 @@ bool open_cascade_kernel::convert_impl(const taxonomy::boolean_result::ptr br, c
// #2665 we also set a precision-independent threshold, because in the boolean op routine // #2665 we also set a precision-independent threshold, because in the boolean op routine
// the working fuzziness might still be increased. // the working fuzziness might still be increased.
if (d < tol * 20. || d < 0.00002) { if (d < tol * 20. || d < 0.00002) {
logger_.message(::logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance);
continue; continue;
} else { } else {
S = result; S = result;
@@ -405,7 +405,7 @@ bool ifcopenshell::geom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape
return true; return true;
} }
int ifcopenshell::geom::util::eliminate_narrow_operands(double prec, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape> & c, ::logger& logger) { int ifcopenshell::geom::util::eliminate_narrow_operands(double prec, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape> & c, ifcopenshell::logger& logger) {
int N = 0; int N = 0;
NCollection_List<TopoDS_Shape>::Iterator it(bs); NCollection_List<TopoDS_Shape>::Iterator it(bs);
for (; it.More(); it.Next()) { for (; it.More(); it.Next()) {
@@ -573,7 +573,7 @@ int ifcopenshell::geom::util::eliminate_touching_operands(double prec, const Top
return N; return N;
} }
bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const NCollection_List<TopoDS_Shape> & b_input, TopoDS_Shape & result, double eps, ::logger& logger) { bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const NCollection_List<TopoDS_Shape> & b_input, TopoDS_Shape & result, double eps, ifcopenshell::logger& logger) {
ifcopenshell::geom::impl::tree<int> edge_tree; ifcopenshell::geom::impl::tree<int> edge_tree;
NCollection_List<TopoDS_Shape> ab_input = b_input; NCollection_List<TopoDS_Shape> ab_input = b_input;
@@ -885,7 +885,7 @@ bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& setting
a = unify(a_input, fuzziness * 1000.); a = unify(a_input, fuzziness * 1000.);
settings.log().message( settings.log().message(
::logger::LOG_DEBUG, "GEO", 127, ifcopenshell::logger::LOG_DEBUG, "GEO", 127,
"Simplified operand A from "s + "Simplified operand A from "s +
std::to_string(count(a_input, TopAbs_FACE)) + std::to_string(count(a_input, TopAbs_FACE)) +
" to "s + " to "s +
@@ -897,7 +897,7 @@ bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& setting
for (; it.More(); it.Next()) { for (; it.More(); it.Next()) {
b.Append(unify(it.Value(), fuzziness)); b.Append(unify(it.Value(), fuzziness));
settings.log().message( settings.log().message(
::logger::LOG_DEBUG, "GEO", 128, ifcopenshell::logger::LOG_DEBUG, "GEO", 128,
"Simplified operand B from "s + "Simplified operand B from "s +
std::to_string(count(it.Value(), TopAbs_FACE)) + std::to_string(count(it.Value(), TopAbs_FACE)) +
" to "s + " to "s +
@@ -965,7 +965,7 @@ bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& setting
return true; return true;
} }
if (!is_2d && ::logger::LOG_NOTICE >= settings.log().verbosity()) { if (!is_2d && ifcopenshell::logger::LOG_NOTICE >= settings.log().verbosity()) {
PERF("preliminary manifoldness check"); PERF("preliminary manifoldness check");
if (!a.IsNull()) { if (!a.IsNull()) {
@@ -89,17 +89,17 @@ namespace ifcopenshell::geom {
IFC_GEOMLIBRARY_API int eliminate_touching_operands(double prec, const TopoDS_Shape& a, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape>& c); IFC_GEOMLIBRARY_API int eliminate_touching_operands(double prec, const TopoDS_Shape& a, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape>& c);
IFC_GEOMLIBRARY_API int eliminate_narrow_operands(double prec, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape> & c, ::logger& logger = ::logger::root()); IFC_GEOMLIBRARY_API int eliminate_narrow_operands(double prec, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape> & c, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_GEOMLIBRARY_API bool boolean_subtraction_2d_using_builder(const TopoDS_Shape& a_input, const NCollection_List<TopoDS_Shape>& b_input, TopoDS_Shape& result, double eps, ::logger& logger = ::logger::root()); IFC_GEOMLIBRARY_API bool boolean_subtraction_2d_using_builder(const TopoDS_Shape& a_input, const NCollection_List<TopoDS_Shape>& b_input, TopoDS_Shape& result, double eps, ifcopenshell::logger& logger = ifcopenshell::logger::root());
struct boolean_settings { struct boolean_settings {
bool debug, attempt_2d; bool debug, attempt_2d;
double precision; double precision;
// Set by callers that carry a per-conversion logger (e.g. kernels deriving // Set by callers that carry a per-conversion logger (e.g. kernels deriving
// from abstract_kernel). Falls back to the global ::logger::root() singleton. // from abstract_kernel). Falls back to the global ifcopenshell::logger::root() singleton.
::logger* logger = nullptr; ifcopenshell::logger* logger = nullptr;
::logger& log() const { return logger ? *logger : ::logger::root(); } ifcopenshell::logger& log() const { return logger ? *logger : ifcopenshell::logger::root(); }
}; };
IFC_GEOMLIBRARY_API bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const NCollection_List<TopoDS_Shape>&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.); IFC_GEOMLIBRARY_API bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const NCollection_List<TopoDS_Shape>&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
@@ -6,6 +6,8 @@
#define GU_CULLING_EPSILON_RAY_TRIANGLE FLT_EPSILON*FLT_EPSILON #define GU_CULLING_EPSILON_RAY_TRIANGLE FLT_EPSILON*FLT_EPSILON
#define PX_MAX_F32 3.4028234663852885981170418348452e+38F #define PX_MAX_F32 3.4028234663852885981170418348452e+38F
namespace ifcopenshell::geom {
typedef uint32_t px_u32; typedef uint32_t px_u32;
// Why can't I use std::clamp? // Why can't I use std::clamp?
@@ -588,3 +590,5 @@ bool trianglesIntersect(const gp_Vec& a1, const gp_Vec& b1, const gp_Vec& c1, co
} }
return false; return false;
} }
} // namespace ifcopenshell::geom
@@ -5,6 +5,8 @@
#include "../ifc_geomlibrary_api.h" #include "../ifc_geomlibrary_api.h"
namespace ifcopenshell::geom {
struct IFC_GEOMLIBRARY_API ray { struct IFC_GEOMLIBRARY_API ray {
float origin[3]; float origin[3];
float dir[3]; float dir[3];
@@ -29,3 +31,5 @@ IFC_GEOMLIBRARY_API void edgeEdgeDist(gp_Vec& x, gp_Vec& y, // closest points
IFC_GEOMLIBRARY_API double distanceTriangleTriangleSquared(gp_Vec& cp, gp_Vec& cq, const std::array<gp_Vec, 3> p, const std::array<gp_Vec, 3> q); IFC_GEOMLIBRARY_API double distanceTriangleTriangleSquared(gp_Vec& cp, gp_Vec& cq, const std::array<gp_Vec, 3> p, const std::array<gp_Vec, 3> q);
IFC_GEOMLIBRARY_API bool trianglesIntersect(const gp_Vec& a1, const gp_Vec& b1, const gp_Vec& c1, const gp_Vec& a2, const gp_Vec& b2, const gp_Vec& c2/*, Segment* intersection*/, gp_Vec& int1, gp_Vec& int2, bool ignoreCoplanar); IFC_GEOMLIBRARY_API bool trianglesIntersect(const gp_Vec& a1, const gp_Vec& b1, const gp_Vec& c1, const gp_Vec& a2, const gp_Vec& b2, const gp_Vec& c2/*, Segment* intersection*/, gp_Vec& int1, gp_Vec& int2, bool ignoreCoplanar);
} // namespace ifcopenshell::geom
@@ -9,7 +9,7 @@ bool open_cascade_kernel::convert(const taxonomy::extrusion::ptr extrusion, Topo
const double& height = extrusion->depth; const double& height = extrusion->depth;
if (height < settings_.get<settings::Precision>().get()) { if (height < settings_.get<settings::Precision>().get()) {
::logger::root().error("GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance); ifcopenshell::logger::root().error("GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
return false; return false;
} }
@@ -23,7 +23,7 @@ bool open_cascade_kernel::convert(const taxonomy::extrusion::ptr extrusion, Topo
// move the TopoDS_Shape, but obviously not both. // move the TopoDS_Shape, but obviously not both.
gp_GTrsf gtrsf; gp_GTrsf gtrsf;
if (!convert(&extrusion->matrix, gtrsf)) { if (!convert(&extrusion->matrix, gtrsf)) {
::logger::root().error("Unable to move extrusion"); ifcopenshell::logger::root().error("Unable to move extrusion");
} }
auto trsf = gtrsf.Trsf(); auto trsf = gtrsf.Trsf();
*/ */
+14 -14
View File
@@ -174,7 +174,7 @@ namespace {
} else if (crv_or_wire.index() == 2) { } else if (crv_or_wire.index() == 2) {
// @todo // @todo
const double precision_ = 1.e-5; const double precision_ = 1.e-5;
::logger::root().warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance); ifcopenshell::logger::root().warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance);
const auto& w = std::get<TopoDS_Wire>(crv_or_wire); const auto& w = std::get<TopoDS_Wire>(crv_or_wire);
#if OCC_VERSION_HEX < 0x70600 #if OCC_VERSION_HEX < 0x70600
BRepAdaptor_CompCurve cc(w, true); BRepAdaptor_CompCurve cc(w, true);
@@ -294,12 +294,12 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
// the face will still be processed as long as there are no holes. A compound of faces // the face will still be processed as long as there are no holes. A compound of faces
// is returned in that case. // is returned in that case.
if (num_bounds > 1 && num_outer_bounds > 1 && num_bounds != num_outer_bounds) { if (num_bounds > 1 && num_outer_bounds > 1 && num_bounds != num_outer_bounds) {
::logger::root().message(::logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance);
return false; return false;
} }
if (num_outer_bounds > 1) { if (num_outer_bounds > 1) {
::logger::root().message(::logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance);
fd.all_outer() = true; fd.all_outer() = true;
} }
@@ -320,11 +320,11 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
TopoDS_Wire wire; TopoDS_Wire wire;
if (faceset_helper_ && bound->is_polyhedron()) { if (faceset_helper_ && bound->is_polyhedron()) {
if (!faceset_helper_->wire(bound, wire)) { if (!faceset_helper_->wire(bound, wire)) {
::logger::root().message(::logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance);
continue; continue;
} }
} else if (!convert(bound, wire)) { } else if (!convert(bound, wire)) {
::logger::root().message(::logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance);
return false; return false;
} }
@@ -341,7 +341,7 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
}; };
NCollection_List<TopoDS_Shape> results; NCollection_List<TopoDS_Shape> results;
if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) { if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) {
::logger::root().warning("GEO", 161, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected"); ifcopenshell::logger::root().warning("GEO", 161, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
util::select_largest(results, wire); util::select_largest(results, wire);
} }
@@ -352,7 +352,7 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
} }
if (fd.wires().empty()) { if (fd.wires().empty()) {
::logger::root().warning("GEO", 162, "Face with no boundaries", face->instance); ifcopenshell::logger::root().warning("GEO", 162, "Face with no boundaries", face->instance);
return false; return false;
} }
@@ -430,7 +430,7 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
if (fd.surface().IsNull()) { if (fd.surface().IsNull()) {
// The set of wires is triangulated in case no surface can be found // The set of wires is triangulated in case no surface can be found
::logger::root().message(::logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance);
if (fd.all_outer()) { if (fd.all_outer()) {
for (const auto& w : fd.wires()) { for (const auto& w : fd.wires()) {
@@ -483,7 +483,7 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
kt.Value().Original().ToUTF8CString(c); kt.Value().Original().ToUTF8CString(c);
std::string message = c; std::string message = c;
delete[] c; delete[] c;
::logger::root().warning("GEO", 164, message, face->instance); ifcopenshell::logger::root().warning("GEO", 164, message, face->instance);
} }
} }
@@ -495,17 +495,17 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
if (it.Value().ShapeType() == TopAbs_FACE) { if (it.Value().ShapeType() == TopAbs_FACE) {
face_list.Append(it.Value()); face_list.Append(it.Value());
} else { } else {
::logger::root().error("UNS", 7, "Unsupported output from face healing"); ifcopenshell::logger::root().error("UNS", 7, "Unsupported output from face healing");
} }
} }
} else { } else {
::logger::root().error("UNS", 8, "Unsupported output from face healing"); ifcopenshell::logger::root().error("UNS", 8, "Unsupported output from face healing");
} }
} else { } else {
face_list.Append(f); face_list.Append(f);
} }
} else { } else {
::logger::root().error("GEO", 165, "Internal error in face creation"); ifcopenshell::logger::root().error("GEO", 165, "Internal error in face creation");
return false; return false;
} }
} else { } else {
@@ -546,14 +546,14 @@ bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape&
delete[] c; delete[] c;
#if OCC_VERSION_MAJOR==7 && OCC_VERSION_MINOR >= 7 #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") { if (!reversed_surface && !fd.surface().IsNull() && fd.surface()->IsUPeriodic() && message == "Unknown message invoked with the keyword FixAdvFace.FixOrientation.MSG0") {
::logger::root().notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface"); ifcopenshell::logger::root().notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface");
TopoDS_Face reversed_result; TopoDS_Face reversed_result;
convert(face, reversed_result, true); convert(face, reversed_result, true);
result = reversed_result; result = reversed_result;
return true; return true;
} else } else
#endif #endif
::logger::root().warning("GEO", 167, message, face->instance); ifcopenshell::logger::root().warning("GEO", 167, message, face->instance);
} }
} }
} }
@@ -149,7 +149,7 @@ ifcopenshell::geom::open_cascade_kernel::faceset_helper::faceset_helper(
auto num_retained = std::count(retained.begin(), retained.end(), true); auto num_retained = std::count(retained.begin(), retained.end(), true);
if (unique.size() != num_retained) { if (unique.size() != 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)); ifcopenshell::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; typedef std::array<int, 2> edge_t;
@@ -206,7 +206,7 @@ ifcopenshell::geom::open_cascade_kernel::faceset_helper::faceset_helper(
} }
if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.value_or(false))) { if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.value_or(false))) {
::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"); ifcopenshell::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");
} }
} }
@@ -277,7 +277,7 @@ bool ifcopenshell::geom::open_cascade_kernel::faceset_helper::wires(const ifcope
!kernel_->settings().get<ifcopenshell::geom::settings::NoWireIntersectionTolerance>().get(), 0., !kernel_->settings().get<ifcopenshell::geom::settings::NoWireIntersectionTolerance>().get(), 0.,
kernel_->settings().get<ifcopenshell::geom::settings::Precision>().get()})) kernel_->settings().get<ifcopenshell::geom::settings::Precision>().get()}))
{ {
::logger::root().warning("GEO", 170, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected"); ifcopenshell::logger::root().warning("GEO", 170, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
non_manifold_ = true; non_manifold_ = true;
wires = results; wires = results;
} else { } else {
+6 -6
View File
@@ -132,7 +132,7 @@ namespace {
} }
} }
::logger::root().error("GEO", 171, "Unable to map layer geometry to material index"); ifcopenshell::logger::root().error("GEO", 171, "Unable to map layer geometry to material index");
return false; return false;
} }
} }
@@ -237,7 +237,7 @@ bool ifcopenshell::geom::util::apply_folded_layerset(const conversion_results& i
if (s.ShapeType() == TopAbs_SHELL) { if (s.ShapeType() == TopAbs_SHELL) {
shells.Append(TopoDS::Shell(s)); shells.Append(TopoDS::Shell(s));
} else { } else {
::logger::root().error("GEO", 172, "Expected shell type in layerset processing"); ifcopenshell::logger::root().error("GEO", 172, "Expected shell type in layerset processing");
return false; return false;
} }
} }
@@ -436,12 +436,12 @@ bool ifcopenshell::geom::util::split_solid_by_shell(const TopoDS_Shape& input, c
} }
} catch (const Standard_Failure& e) { } catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) { if (e.GetMessageString() && strlen(e.GetMessageString())) {
::logger::root().error("GEO", 173, e.GetMessageString()); ifcopenshell::logger::root().error("GEO", 173, e.GetMessageString());
} else { } else {
::logger::root().error("GEO", 174, "Unknown error performing fixes"); ifcopenshell::logger::root().error("GEO", 174, "Unknown error performing fixes");
} }
} catch (...) { } catch (...) {
::logger::root().error("GEO", 175, "Unknown error performing fixes"); ifcopenshell::logger::root().error("GEO", 175, "Unknown error performing fixes");
} }
BRepCheck_Analyzer analyser(shape); BRepCheck_Analyzer analyser(shape);
bool is_valid = analyser.IsValid() != 0; bool is_valid = analyser.IsValid() != 0;
@@ -451,7 +451,7 @@ bool ifcopenshell::geom::util::split_solid_by_shell(const TopoDS_Shape& input, c
} }
if (is_null[0] || is_null[1]) { if (is_null[0] || is_null[1]) {
::logger::root().message(::logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing"); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing");
if (is_null[0] && is_null[1]) { if (is_null[0] && is_null[1]) {
return false; return false;
} }
+4 -4
View File
@@ -82,7 +82,7 @@ bool open_cascade_kernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape&
if (non_polygonal) { if (non_polygonal) {
if (loft->children.size() < 2) { if (loft->children.size() < 2) {
::logger::root().error("GEO", 177, "Not enough sections to loft"); ifcopenshell::logger::root().error("GEO", 177, "Not enough sections to loft");
return false; return false;
} }
@@ -122,7 +122,7 @@ bool open_cascade_kernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape&
auto first_wire_count = sections.front().size(); auto first_wire_count = sections.front().size();
for (auto& section : sections) { for (auto& section : sections) {
if (section.size() != first_wire_count) { if (section.size() != first_wire_count) {
::logger::root().error("GEO", 178, "Inconsistent number of wires in sections"); ifcopenshell::logger::root().error("GEO", 178, "Inconsistent number of wires in sections");
return false; return false;
} }
} }
@@ -159,7 +159,7 @@ bool open_cascade_kernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape&
return true; return true;
} else { } else {
::logger::root().error("Lofting more than two sections is not supported"); ifcopenshell::logger::root().error("Lofting more than two sections is not supported");
return false; return false;
} }
} }
@@ -275,7 +275,7 @@ bool open_cascade_kernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape&
*/ */
if (shps.size() < 2) { if (shps.size() < 2) {
::logger::root().error("GEO", 179, "Not enough sections to loft"); ifcopenshell::logger::root().error("GEO", 179, "Not enough sections to loft");
return false; return false;
} }
+3 -3
View File
@@ -129,7 +129,7 @@ namespace {
} else { } else {
// @todo // @todo
const double precision_ = 1.e-5; const double precision_ = 1.e-5;
::logger::root().warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance); ifcopenshell::logger::root().warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance);
const auto& w = std::get<TopoDS_Wire>(crv_or_wire); const auto& w = std::get<TopoDS_Wire>(crv_or_wire);
#if OCC_VERSION_HEX < 0x70600 #if OCC_VERSION_HEX < 0x70600
BRepAdaptor_CompCurve cc(w, true); BRepAdaptor_CompCurve cc(w, true);
@@ -283,7 +283,7 @@ bool open_cascade_kernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& w
} }
if (converted_segments.Extent() == 0) { if (converted_segments.Extent() == 0) {
::logger::root().message(::logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance);
return false; return false;
} }
@@ -348,7 +348,7 @@ bool open_cascade_kernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& w
if (ang < 0.0314) { if (ang < 0.0314) {
edges_to_tesselate.Add(crv1->DynamicType() == STANDARD_TYPE(Geom_Circle) ? edges.First() : edges.Last()); edges_to_tesselate.Add(crv1->DynamicType() == STANDARD_TYPE(Geom_Circle) ? edges.First() : edges.Last());
::logger::root().notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation"); ifcopenshell::logger::root().notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation");
} }
} }
} }
+3 -3
View File
@@ -57,7 +57,7 @@ bool open_cascade_kernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& sh
} }
if (!success) { if (!success) {
logger_.message(::logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance);
continue; continue;
} }
@@ -70,7 +70,7 @@ bool open_cascade_kernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& sh
if (face_area(triangle) > min_face_area) { if (face_area(triangle) > min_face_area) {
face_list.Append(triangle); face_list.Append(triangle);
} else { } else {
logger_.message(::logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance);
} }
} }
} }
@@ -78,7 +78,7 @@ bool open_cascade_kernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& sh
if (face_area(occ_face) > min_face_area) { if (face_area(occ_face) > min_face_area) {
face_list.Append(occ_face); face_list.Append(occ_face);
} else { } else {
logger_.message(::logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance);
} }
} }
} }
@@ -182,7 +182,7 @@ bool open_cascade_kernel::convert(const taxonomy::sweep_along_curve::ptr scs, To
for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) { for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) {
if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) { if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) {
directrix_on_plane = false; directrix_on_plane = false;
logger_.message(::logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance);
break; break;
} }
} }
@@ -97,7 +97,7 @@ bool ifcopenshell::geom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & dir
Handle(Geom_Curve) crv = BRep_Tool::Curve(edge, u0, u1); Handle(Geom_Curve) crv = BRep_Tool::Curve(edge, u0, u1);
crv->D1(u0, directrix_origin, directrix_tangent); crv->D1(u0, directrix_origin, directrix_tangent);
} else { } else {
::logger::root().error("GEO", 203, "Unable to locate first edge"); ifcopenshell::logger::root().error("GEO", 203, "Unable to locate first edge");
return false; return false;
} }
@@ -187,7 +187,7 @@ void ifcopenshell::geom::util::sort_edges(const TopoDS_Wire & wire, std::vector<
for (int i = 1; i <= map.Extent(); ++i) { for (int i = 1; i <= map.Extent(); ++i) {
if (map.FindFromIndex(i).Extent() > 2) { if (map.FindFromIndex(i).Extent() > 2) {
::logger::root().warning("GEO", 204, "Self-intersecting Directrix"); ifcopenshell::logger::root().warning("GEO", 204, "Self-intersecting Directrix");
} }
} }
@@ -117,12 +117,12 @@ bool ifcopenshell::geom::util::create_edge_over_curve_with_log_messages(const op
} }
} }
if (dmin == std::numeric_limits<double>::infinity()) { if (dmin == std::numeric_limits<double>::infinity()) {
::logger::root().error("GEO", 205, "No extrema for point"); ifcopenshell::logger::root().error("GEO", 205, "No extrema for point");
} else if (dmin > eps2) { } else if (dmin > eps2) {
::logger::root().error("GEO", 206, "Distance of " + boost::lexical_cast<std::string>(std::sqrt(dmin)) + " exceeds tolerance"); ifcopenshell::logger::root().error("GEO", 206, "Distance of " + boost::lexical_cast<std::string>(std::sqrt(dmin)) + " exceeds tolerance");
} }
} else { } else {
::logger::root().error("GEO", 207, "Failed to calculate extrema for point"); ifcopenshell::logger::root().error("GEO", 207, "Failed to calculate extrema for point");
} }
} }
} }
@@ -172,7 +172,7 @@ void ifcopenshell::geom::util::wire_builder::operator()(const TopoDS_Shape& a, c
if (dist > 1000. * p_) { if (dist > 1000. * p_) {
mw_.Add(w1); mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2)); mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
::logger::root().warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_); ifcopenshell::logger::root().warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
goto check; goto check;
} }
@@ -200,28 +200,28 @@ void ifcopenshell::geom::util::wire_builder::operator()(const TopoDS_Shape& a, c
// Preferably adjust the segment that is linear // Preferably adjust the segment that is linear
if (is_line1 || (is_circle1 && !is_line2)) { if (is_line1 || (is_circle1 && !is_line2)) {
mw_.Add(adjust(w1, w12, p2)); mw_.Add(adjust(w1, w12, p2));
::logger::root().notice("GEO", 209, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_); ifcopenshell::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) { } else if ((is_line2 || is_circle2) && !last) {
mw_.Add(w1); mw_.Add(w1);
override_next_ = true; override_next_ = true;
next_override_ = p1; next_override_ = p1;
::logger::root().notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_); ifcopenshell::logger::root().notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
} else { } else {
// In all other cases an edge is added // In all other cases an edge is added
mw_.Add(w1); mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2)); mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
::logger::root().warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_); ifcopenshell::logger::root().warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
} }
} else { } else {
::logger::root().error("GEO", 212, "Internal error, inconsistent wire segments", inst_); ifcopenshell::logger::root().error("GEO", 212, "Internal error, inconsistent wire segments", inst_);
mw_.Add(w1); mw_.Add(w1);
} }
} }
check: check:
if (mw_.Error() == BRepBuilderAPI_NonManifoldWire) { if (mw_.Error() == BRepBuilderAPI_NonManifoldWire) {
::logger::root().error("GEO", 213, "Non-manifold curve segments:", inst_); ifcopenshell::logger::root().error("GEO", 213, "Non-manifold curve segments:", inst_);
} else if (mw_.Error() == BRepBuilderAPI_DisconnectedWire) { } else if (mw_.Error() == BRepBuilderAPI_DisconnectedWire) {
::logger::root().error("GEO", 214, "Failed to join curve segments:", inst_); ifcopenshell::logger::root().error("GEO", 214, "Failed to join curve segments:", inst_);
} }
} }
+17 -17
View File
@@ -90,7 +90,7 @@ bool ifcopenshell::geom::util::approximate_plane_through_wire(const TopoDS_Wire&
// obtaining a 2d points for the Delaunay, infinity is passed here, so this // obtaining a 2d points for the Delaunay, infinity is passed here, so this
// can't for assessing degenerativeness. // can't for assessing degenerativeness.
if (v.Magnitude() < 1.e-7) { if (v.Magnitude() < 1.e-7) {
::logger::root().warning("GEO", 215, "Degenerate face boundary in normal estimation"); ifcopenshell::logger::root().warning("GEO", 215, "Degenerate face boundary in normal estimation");
return false; return false;
} }
@@ -237,7 +237,7 @@ ifcopenshell::geom::util::triangulate_wire_result ifcopenshell::geom::util::tria
auto it = mapping.find(uvnodes[k]); auto it = mapping.find(uvnodes[k]);
if (it == mapping.end()) { if (it == mapping.end()) {
::logger::root().error("GEO", 216, "Internal error: unable to unproject uv-mesh"); ifcopenshell::logger::root().error("GEO", 216, "Internal error: unable to unproject uv-mesh");
return TRIANGULATE_WIRE_FAIL; return TRIANGULATE_WIRE_FAIL;
} }
@@ -281,7 +281,7 @@ ifcopenshell::geom::util::triangulate_wire_result ifcopenshell::geom::util::tria
} }
faces.Append(triangle_face); faces.Append(triangle_face);
} else { } else {
::logger::root().error("GEO", 217, "Internal error: missing face"); ifcopenshell::logger::root().error("GEO", 217, "Internal error: missing face");
return TRIANGULATE_WIRE_FAIL; return TRIANGULATE_WIRE_FAIL;
} }
} }
@@ -312,7 +312,7 @@ ifcopenshell::geom::util::triangulate_wire_result ifcopenshell::geom::util::tria
if (!contains) { if (!contains) {
#endif #endif
// All existing edges need to exist in the new faces // All existing edges need to exist in the new faces
::logger::root().error("GEO", 218, "Internal error, missing edge from triangulation"); ifcopenshell::logger::root().error("GEO", 218, "Internal error, missing edge from triangulation");
non_manifold = true; non_manifold = true;
} }
} }
@@ -323,7 +323,7 @@ ifcopenshell::geom::util::triangulate_wire_result ifcopenshell::geom::util::tria
// Existing edges are boundaries with use 1 // Existing edges are boundaries with use 1
// New edges are internal with use 2 // New edges are internal with use 2
if (n != (mape.Contains(v) ? 1 : 2)) { if (n != (mape.Contains(v) ? 1 : 2)) {
::logger::root().error("GEO", 219, "Internal error, non-manifold result from triangulation"); ifcopenshell::logger::root().error("GEO", 219, "Internal error, non-manifold result from triangulation");
non_manifold = true; non_manifold = true;
} }
} }
@@ -794,12 +794,12 @@ bool ifcopenshell::geom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_S
shape = solid.SolidFromShell(TopoDS::Shell(shape)); shape = solid.SolidFromShell(TopoDS::Shell(shape));
} catch (const Standard_Failure& e) { } catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) { if (e.GetMessageString() && strlen(e.GetMessageString())) {
::logger::root().error("GEO", 220, e.GetMessageString()); ifcopenshell::logger::root().error("GEO", 220, e.GetMessageString());
} else { } else {
::logger::root().error("GEO", 221, "Unknown error creating solid"); ifcopenshell::logger::root().error("GEO", 221, "Unknown error creating solid");
} }
} catch (...) { } catch (...) {
::logger::root().error("GEO", 222, "Unknown error creating solid"); ifcopenshell::logger::root().error("GEO", 222, "Unknown error creating solid");
} }
return true; return true;
@@ -812,12 +812,12 @@ bool ifcopenshell::geom::util::convert_curve_to_wire(const opencascade::handle<G
return true; return true;
} catch (const Standard_Failure& e) { } catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) { if (e.GetMessageString() && strlen(e.GetMessageString())) {
::logger::root().error("GEO", 223, e.GetMessageString()); ifcopenshell::logger::root().error("GEO", 223, e.GetMessageString());
} else { } else {
::logger::root().error("GEO", 224, "Unknown error converting curve to wire"); ifcopenshell::logger::root().error("GEO", 224, "Unknown error converting curve to wire");
} }
} catch (...) { } catch (...) {
::logger::root().error("GEO", 225, "Unknown error converting curve to wire"); ifcopenshell::logger::root().error("GEO", 225, "Unknown error converting curve to wire");
} }
return false; return false;
} }
@@ -838,7 +838,7 @@ void ifcopenshell::geom::util::assert_closed_wire(TopoDS_Wire& wire, double tol)
wire = mw.Wire(); wire = mw.Wire();
} }
::logger::root().warning("GEO", 226, "Wire not closed"); ifcopenshell::logger::root().warning("GEO", 226, "Wire not closed");
} }
} }
@@ -848,7 +848,7 @@ bool ifcopenshell::geom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS
NCollection_List<TopoDS_Shape> results; NCollection_List<TopoDS_Shape> results;
if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) { if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) {
::logger::root().warning("GEO", 227, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected"); ifcopenshell::logger::root().warning("GEO", 227, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
util::select_largest(results, wire); util::select_largest(results, wire);
} }
@@ -879,7 +879,7 @@ bool ifcopenshell::geom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS
BRepBuilderAPI_FaceError er = mf.Error(); BRepBuilderAPI_FaceError er = mf.Error();
if (er != BRepBuilderAPI_FaceDone) { if (er != BRepBuilderAPI_FaceDone) {
::logger::root().error("GEO", 228, "Failed to create face."); ifcopenshell::logger::root().error("GEO", 228, "Failed to create face.");
return false; return false;
} }
face = mf.Face(); face = mf.Face();
@@ -906,7 +906,7 @@ bool ifcopenshell::geom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoD
NCollection_List<TopoDS_Shape> results; NCollection_List<TopoDS_Shape> results;
if (settings.use_wire_intersection_check && util::wire_intersections(w, results, settings)) { if (settings.use_wire_intersection_check && util::wire_intersections(w, results, settings)) {
::logger::root().warning("GEO", 229, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected"); ifcopenshell::logger::root().warning("GEO", 229, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
} else { } else {
results.Clear(); results.Clear();
results.Append(w); results.Append(w);
@@ -932,7 +932,7 @@ bool ifcopenshell::geom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoD
BRepBuilderAPI_FaceError er = mf.Error(); BRepBuilderAPI_FaceError er = mf.Error();
if (er != BRepBuilderAPI_FaceDone) { if (er != BRepBuilderAPI_FaceDone) {
::logger::root().error("GEO", 230, "Failed to create face."); ifcopenshell::logger::root().error("GEO", 230, "Failed to create face.");
continue; continue;
} }
@@ -949,7 +949,7 @@ bool ifcopenshell::geom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoD
if (p.first >= max_area / 10.) { if (p.first >= max_area / 10.) {
B.Add(faces, p.second); B.Add(faces, p.second);
} else { } else {
::logger::root().warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast<std::string>(p.first)); ifcopenshell::logger::root().warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast<std::string>(p.first));
} }
} }
@@ -286,7 +286,7 @@ ifcopenshell::geom::passthrough_shape::passthrough_shape(const std::vector<passt
ifcopenshell::geom::passthrough_shape::passthrough_shape(std::vector<passthrough_part>&& parts) ifcopenshell::geom::passthrough_shape::passthrough_shape(std::vector<passthrough_part>&& parts)
: parts_(normalize_parts(parts)) {} : parts_(normalize_parts(parts)) {}
void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger&) const { void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
auto mesh = build_mesh(parts_, &place); auto mesh = build_mesh(parts_, &place);
std::vector<int> indices(mesh.vertices.size()); std::vector<int> indices(mesh.vertices.size());
for (size_t i = 0; i < mesh.vertices.size(); ++i) { for (size_t i = 0; i < mesh.vertices.size(); ++i) {
@@ -24,7 +24,7 @@ public:
const std::vector<passthrough_part>& parts() const { return parts_; } const std::vector<passthrough_part>& parts() const { return parts_; }
virtual std::string_view backend_id() const { return "passthrough"; } virtual std::string_view backend_id() const { return "passthrough"; }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const; virtual int surface_genus() const;
@@ -11,10 +11,10 @@ namespace kernels {
class IFC_GEOMLIBRARY_API passthrough_kernel : public abstract_kernel { class IFC_GEOMLIBRARY_API passthrough_kernel : public abstract_kernel {
public: public:
passthrough_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) passthrough_kernel(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: abstract_kernel("passthrough", settings, logger) {} : abstract_kernel("passthrough", settings, logger) {}
virtual abstract_kernel* clone(::logger& logger) const { virtual abstract_kernel* clone(ifcopenshell::logger& logger) const {
return new passthrough_kernel(settings(), logger); return new passthrough_kernel(settings(), logger);
} }
@@ -58,7 +58,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAsymmetricIShapeProfileDef&
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (xb < tol || xt < tol || y < tol || d1 < tol || ftb < tol || ftt < tol) { if (xb < tol || xt < tol || y < tol || d1 < tol || ftb < tol || ftt < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
@@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear& inst)
/* /*
if (hasAxis != hasRef) { if (hasAxis != hasRef) {
::logger::root().warning("Axis and RefDirection should be specified together", inst); ifcopenshell::logger::root().warning("Axis and RefDirection should be specified together", inst);
} }
*/ */
+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(); const double tol = settings_.get<settings::Precision>().get();
if ( x < tol || y < tol || d1 < tol || d2 < tol) { if ( x < tol || y < tol || d1 < tol || d2 < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
+1 -1
View File
@@ -24,7 +24,7 @@ using namespace ifcopenshell::geom;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle& inst) { taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle& inst) {
const double r = inst.Radius() * length_unit_; const double r = inst.Radius() * length_unit_;
if (r < settings_.get<settings::Precision>().get()) { if (r < settings_.get<settings::Precision>().get()) {
logger_.message(::logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst);
return nullptr; return nullptr;
} }
+5 -5
View File
@@ -128,7 +128,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi
for (auto it = segments->begin(); it != segments->end(); ++it) { for (auto it = segments->begin(); it != segments->end(); ++it) {
if (!(*it)->declaration().is(IfcSchema::IfcCompositeCurveSegment::Class())) { if (!(*it)->declaration().is(IfcSchema::IfcCompositeCurveSegment::Class())) {
::logger::root().error("Not implemented", *it); ifcopenshell::logger::root().error("Not implemented", *it);
return false; return false;
} }
@@ -141,13 +141,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi
TopoDS_Wire segment; TopoDS_Wire segment;
if (curve->as<IfcSchema::IfcLine>()) { if (curve->as<IfcSchema::IfcLine>()) {
::logger::root().notice("Infinite IfcLine used as ParentCurve of segment, treating as a segment", *it); ifcopenshell::logger::root().notice("Infinite IfcLine used as ParentCurve of segment, treating as a segment", *it);
Handle_Geom_Curve handle; Handle_Geom_Curve handle;
convert_curve(curve, handle); convert_curve(curve, handle);
double u0 = 0.0; double u0 = 0.0;
double u1 = curve->as<IfcSchema::IfcLine>()->Dir()->Magnitude() * length_unit_; double u1 = curve->as<IfcSchema::IfcLine>()->Dir()->Magnitude() * length_unit_;
if (u1 < getValue(GV_PRECISION)) { if (u1 < getValue(GV_PRECISION)) {
::logger::root().warning("Segment length below tolerance", *it); ifcopenshell::logger::root().warning("Segment length below tolerance", *it);
} }
BRepBuilderAPI_MakeEdge me(handle, u0, u1); BRepBuilderAPI_MakeEdge me(handle, u0, u1);
if (me.IsDone()) { if (me.IsDone()) {
@@ -157,7 +157,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi
} }
} else if (!convert_wire(curve, segment)) { } else if (!convert_wire(curve, segment)) {
const bool failed_on_purpose = curve->as<IfcSchema::IfcPolyline>() && !segment.IsNull(); const bool failed_on_purpose = curve->as<IfcSchema::IfcPolyline>() && !segment.IsNull();
::logger::root().message(failed_on_purpose ? ::logger::LOG_WARNING : ::logger::LOG_ERROR, "Failed to convert curve:", curve); ifcopenshell::logger::root().message(failed_on_purpose ? ifcopenshell::logger::LOG_WARNING : ifcopenshell::logger::LOG_ERROR, "Failed to convert curve:", curve);
continue; continue;
} }
@@ -173,7 +173,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi
} }
if (converted_segments.Extent() == 0) { if (converted_segments.Extent() == 0) {
::logger::root().message(::logger::LOG_ERROR, "No segment successfully converted:", l); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "No segment successfully converted:", l);
return false; return false;
} }
+2 -2
View File
@@ -25,14 +25,14 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge& inst) {
auto v1 = inst.EdgeStart().as<IfcSchema::IfcVertexPoint>(); auto v1 = inst.EdgeStart().as<IfcSchema::IfcVertexPoint>();
auto v2 = inst.EdgeEnd().as<IfcSchema::IfcVertexPoint>(); auto v2 = inst.EdgeEnd().as<IfcSchema::IfcVertexPoint>();
if (!v1 || !v2) { if (!v1 || !v2) {
logger_.message(::logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst);
return nullptr; return nullptr;
} }
auto pnt1 = v1.VertexGeometry(); auto pnt1 = v1.VertexGeometry();
auto pnt2 = v2.VertexGeometry(); auto pnt2 = v2.VertexGeometry();
if (!pnt1.declaration().is(IfcSchema::IfcCartesianPoint::Class()) || !pnt2.declaration().is(IfcSchema::IfcCartesianPoint::Class())) { 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(ifcopenshell::logger::LOG_ERROR, "GEO", 256, "Only IfcCartesianPoints are supported for VertexGeometry", inst);
return nullptr; 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_; double y = inst.SemiAxis2() * length_unit_;
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) { if (x < tol || y < tol) {
logger_.message(::logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst);
return nullptr; 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_; double ry = inst.SemiAxis2() * length_unit_;
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (rx < tol || ry < tol) { if (rx < tol || ry < tol) {
logger_.message(::logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst);
return nullptr; return nullptr;
} }
+1 -1
View File
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geom;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid& inst) { taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid& inst) {
const double height = inst.Depth() * length_unit_; const double height = inst.Depth() * length_unit_;
if (height < settings_.get<settings::Precision>().get()) { if (height < settings_.get<settings::Precision>().get()) {
logger_.message(::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst);
#ifndef PERMISSIVE_EXTRUSION #ifndef PERMISSIVE_EXTRUSION
return nullptr; return nullptr;
#endif #endif
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geom;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered& inst) { taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered& inst) {
const double height = inst.Depth() * length_unit_; const double height = inst.Depth() * length_unit_;
if (height < settings_.get<settings::Precision>().get()) { if (height < settings_.get<settings::Precision>().get()) {
logger_.message(::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst);
return nullptr; return nullptr;
} }
@@ -98,7 +98,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFixedReferenceSweptAreaSolid
auto condition_number = svd.singularValues()(0) auto condition_number = svd.singularValues()(0)
/ svd.singularValues()(svd.singularValues().size() - 1); / svd.singularValues()(svd.singularValues().size() - 1);
if (condition_number > 1.e10) { if (condition_number > 1.e10) {
::logger::root().error("Non-invertible matrix at " + std::to_string(distalong) + " conversion will likely fail."); ifcopenshell::logger::root().error("Non-invertible matrix at " + std::to_string(distalong) + " conversion will likely fail.");
} }
*/ */
} }
+1 -1
View File
@@ -25,7 +25,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid& inst) {
auto surface = inst.BaseSurface(); auto surface = inst.BaseSurface();
auto plane = surface.as<IfcSchema::IfcPlane>(); auto plane = surface.as<IfcSchema::IfcPlane>();
if (!plane) { if (!plane) {
logger_.message(::logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface); logger_.message(ifcopenshell::logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface);
return nullptr; return nullptr;
} }
auto p = taxonomy::make<taxonomy::plane>(); auto p = taxonomy::make<taxonomy::plane>();
+1 -1
View File
@@ -80,7 +80,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIShapeProfileDef& inst) {
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (x1 < tol || x2 < tol || y < tol || d1 < tol || ft1 < tol || ft2 < tol) { 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(ifcopenshell::logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
+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(); const double tol = settings_.get<settings::Precision>().get();
if ( x < tol || y < tol || d < tol) { if ( x < tol || y < tol || d < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
@@ -77,7 +77,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef& inst) {
const double det = a1*b2 - a2*b1; const double det = a1*b2 - a2*b1;
if (std::fabs(det) < 1.e-5) { if (std::fabs(det) < 1.e-5) {
logger_.message(::logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst);
return nullptr; return nullptr;
} }
+3 -3
View File
@@ -53,7 +53,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) {
} }
} }
#else #else
::logger::root().warning("Using --site-local-placement or --building-local-placement on IFC4.2 might have issues"); ifcopenshell::logger::root().warning("Using --site-local-placement or --building-local-placement on IFC4.2 might have issues");
#endif #endif
} }
} }
@@ -126,7 +126,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) {
if (fallback) { if (fallback) {
auto mapped_fallback = taxonomy::cast<taxonomy::matrix4>(map(fallback)); auto mapped_fallback = taxonomy::cast<taxonomy::matrix4>(map(fallback));
if (!result->ccomponents().isApprox(mapped_fallback->ccomponents())) { if (!result->ccomponents().isApprox(mapped_fallback->ccomponents())) {
::logger::root().warning("Computed placement differs from fallback", inst); ifcopenshell::logger::root().warning("Computed placement differs from fallback", inst);
} }
} }
@@ -134,7 +134,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) {
auto abs_det = std::abs(result->ccomponents().determinant()); auto abs_det = std::abs(result->ccomponents().determinant());
if (abs_det < 1.e-7) { if (abs_det < 1.e-7) {
::logger::root().warning("Ignoring singular matrix:", inst); ifcopenshell::logger::root().warning("Ignoring singular matrix:", inst);
return nullptr; return nullptr;
} }
+3 -3
View File
@@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop& inst) {
// A loop should consist of at least three vertices // A loop should consist of at least three vertices
int original_count = polygon.size(); int original_count = polygon.size();
if (original_count < 3) { if (original_count < 3) {
logger_.message(::logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst);
return nullptr; return nullptr;
} }
@@ -51,11 +51,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop& inst) {
int count = polygon.size(); int count = polygon.size();
if (original_count - count != 0) { if (original_count - count != 0) {
std::stringstream ss; ss << (original_count - count) << " edges removed for:"; std::stringstream ss; ss << (original_count - count) << " edges removed for:";
logger_.message(::logger::LOG_WARNING, "GEO", 280, ss.str(), inst); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 280, ss.str(), inst);
} }
if (count < 3) { if (count < 3) {
logger_.message(::logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst);
return nullptr; return nullptr;
} }
@@ -37,7 +37,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef& i
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) { if (x < tol || y < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
@@ -30,7 +30,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleProfileDef& inst) {
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) { if (x < tol || y < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
@@ -27,7 +27,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface& i
/* /*
if (!inst.BasisSurface()->declaration().is(IfcSchema::IfcPlane::Class())) { if (!inst.BasisSurface()->declaration().is(IfcSchema::IfcPlane::Class())) {
::logger::root().message(::logger::LOG_ERROR, "Unsupported BasisSurface:", inst.BasisSurface()); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_ERROR, "Unsupported BasisSurface:", inst.BasisSurface());
return false; return false;
} }
gp_Pln pln; gp_Pln pln;
+1 -1
View File
@@ -86,7 +86,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid& inst) {
} }
if (intersecting) { if (intersecting) {
::logger::root().warning("Warning Axis and SweptArea intersecting", l); ifcopenshell::logger::root().warning("Warning Axis and SweptArea intersecting", l);
} }
} }
*/ */
@@ -31,7 +31,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef&
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) { if (x < tol || y < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
@@ -49,11 +49,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid&
if (!is_plane) { if (!is_plane) {
TopoDS_Shape surface_shell; TopoDS_Shape surface_shell;
if (!convert_shape(inst.ReferenceSurface(), surface_shell)) { if (!convert_shape(inst.ReferenceSurface(), surface_shell)) {
::logger::root().error("Failed to convert reference surface", l); ifcopenshell::logger::root().error("Failed to convert reference surface", l);
return false; return false;
} }
if (util::count(surface_shell, TopAbs_FACE) != 1) { if (util::count(surface_shell, TopAbs_FACE) != 1) {
::logger::root().error("Non-continuous reference surface", l); ifcopenshell::logger::root().error("Non-continuous reference surface", l);
return false; return false;
} }
surface_face = TopoDS::Face(TopExp_Explorer(surface_shell, TopAbs_FACE).Current()); surface_face = TopoDS::Face(TopExp_Explorer(surface_shell, TopAbs_FACE).Current());
@@ -76,7 +76,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid&
for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) { for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) {
if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) { if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) {
directrix_on_plane = false; directrix_on_plane = false;
::logger::root().message(::logger::LOG_WARNING, "The Directrix does not lie on the ReferenceSurface", l); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "The Directrix does not lie on the ReferenceSurface", l);
break; break;
} }
} }
+6 -6
View File
@@ -241,19 +241,19 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) {
i += 1; i += 1;
j += 1; j += 1;
} else { } else {
::logger::root().error("Unexpected amount of fillet edges generated"); ifcopenshell::logger::root().error("Unexpected amount of fillet edges generated");
} }
} else { } else {
::logger::root().error("Unable to build fillet, probably edge too short"); ifcopenshell::logger::root().error("Unable to build fillet, probably edge too short");
} }
} else { } else {
::logger::root().error("Colinear edges, not applying fillet"); ifcopenshell::logger::root().error("Colinear edges, not applying fillet");
} }
i++; i++;
j++; j++;
} }
} else { } else {
::logger::root().error("Not enough edges for applying fillet"); ifcopenshell::logger::root().error("Not enough edges for applying fillet");
} }
TopoDS_Wire new_wire; TopoDS_Wire new_wire;
@@ -266,7 +266,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) {
wire = new_wire; wire = new_wire;
} else { } else {
::logger::root().error("Directrix is not polyhedral, ignoring FilletRadius"); ifcopenshell::logger::root().error("Directrix is not polyhedral, ignoring FilletRadius");
} }
} }
@@ -317,7 +317,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid& inst) {
} }
if (!is_valid) { if (!is_valid) {
::logger::root().message(::logger::LOG_WARNING, "Failed to subtract inner radius void for:", l); ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "Failed to subtract inner radius void for:", l);
} }
} }
+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(); const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || d1 < tol || d2 < tol) { if (x < tol || y < tol || d1 < tol || d2 < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
@@ -88,7 +88,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef& inst) {
const double det = a1*b2 - a2*b1; const double det = a1*b2 - a2*b1;
if (std::fabs(det) < 1.e-5) { if (std::fabs(det) < 1.e-5) {
logger_.message(::logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst);
return nullptr; return nullptr;
} }
@@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef& inst) {
const double tol = settings_.get<settings::Precision>().get(); const double tol = settings_.get<settings::Precision>().get();
if (x1 < tol || w < tol || y < tol) { if (x1 < tol || w < tol || y < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
+3 -3
View File
@@ -76,7 +76,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve& inst) {
bool trim_cartesian_failed = !trim_cartesian; bool trim_cartesian_failed = !trim_cartesian;
if (trim_cartesian) { if (trim_cartesian) {
if ((pnts[0]->ccomponents() - pnts[1]->ccomponents()).norm() < (2 * tol)) { 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(ifcopenshell::logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst);
return nullptr; return nullptr;
} }
tc->start = pnts[0]; tc->start = pnts[0];
@@ -140,7 +140,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve& inst) {
TopoDS_Vertex v0, v1; TopoDS_Vertex v0, v1;
TopExp::Vertices(e, v0, v1); TopExp::Vertices(e, v0, v1);
if (v0.IsSame(v1)) { if (v0.IsSame(v1)) {
::logger::root().warning("Skipping degenerate segment", l); ifcopenshell::logger::root().warning("Skipping degenerate segment", l);
return false; return false;
} }
} }
@@ -168,7 +168,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve& inst) {
TopoDS_Vertex v0, v1; TopoDS_Vertex v0, v1;
TopExp::Vertices(e, v0, v1); TopExp::Vertices(e, v0, v1);
e = TopoDS::Edge(BRepBuilderAPI_MakeEdge(v0, v1).Edge().Oriented(e.Orientation())); e = TopoDS::Edge(BRepBuilderAPI_MakeEdge(v0, v1).Edge().Oriented(e.Orientation()));
::logger::root().warning("Substituted edge with linear approximation", l); ifcopenshell::logger::root().warning("Substituted edge with linear approximation", l);
} }
} }
+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(); const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || d1 < tol || d2 < tol) { if (x < tol || y < tol || d1 < tol || d2 < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst);
return nullptr; 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(); const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || dx < tol || dy < tol) { if (x < tol || y < tol || dx < tol || dy < tol) {
logger_.message(::logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst); logger_.message(ifcopenshell::logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst);
return nullptr; return nullptr;
} }
+8 -8
View File
@@ -40,7 +40,7 @@ using namespace ifcopenshell::geom;
namespace { namespace {
struct POSTFIX_SCHEMA(factory_t) { struct POSTFIX_SCHEMA(factory_t) {
abstract_mapping* operator()(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger) const { abstract_mapping* operator()(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger) const {
ifcopenshell::geom::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geom::POSTFIX_SCHEMA(mapping)(file, settings, logger); ifcopenshell::geom::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geom::POSTFIX_SCHEMA(mapping)(file, settings, logger);
return m; return m;
} }
@@ -774,7 +774,7 @@ taxonomy::ptr mapping::map(const express::base& inst) {
cache_.insert({iden, item}); cache_.insert({iden, item});
} }
} else if (!matched) { } else if (!matched) {
logger_.message(::logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst);
} }
return item; return item;
} }
@@ -927,7 +927,7 @@ void mapping::initialize_units_() {
} catch (const ifcopenshell::exception& ex) { } catch (const ifcopenshell::exception& ex) {
std::stringstream ss; std::stringstream ss;
ss << "Failed to determine unit information '" << ex.what() << "'"; ss << "Failed to determine unit information '" << ex.what() << "'";
logger_.message(::logger::LOG_ERROR, "GEO", 311, ss.str()); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 311, ss.str());
} }
if (!length_unit_encountered) { if (!length_unit_encountered) {
@@ -1012,7 +1012,7 @@ void mapping::initialize_settings() {
if (any_precision_encountered) { if (any_precision_encountered) {
if (lowest_precision_encountered < 1.e-7) { if (lowest_precision_encountered < 1.e-7) {
logger_.message(::logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced"); logger_.message(ifcopenshell::logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced");
precision_to_set = 1.e-7; precision_to_set = 1.e-7;
} else { } else {
precision_to_set = lowest_precision_encountered; precision_to_set = lowest_precision_encountered;
@@ -1063,7 +1063,7 @@ bool mapping::get_layerset_information(const express::base& p, layerset_informat
IfcSchema::IfcRepresentation axis_representation = find_representation(product, "Axis"); IfcSchema::IfcRepresentation axis_representation = find_representation(product, "Axis");
if (!axis_representation) { if (!axis_representation) {
logger_.message(::logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product);
return false; return false;
} }
@@ -1138,7 +1138,7 @@ bool mapping::get_layerset_information(const express::base& p, layerset_informat
} }
if (extrusions.size() != 1) { if (extrusions.size() != 1) {
logger_.message(::logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product); logger_.message(ifcopenshell::logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product);
return false; return false;
} }
@@ -1153,7 +1153,7 @@ bool mapping::get_layerset_information(const express::base& p, layerset_informat
if (has_position) { if (has_position) {
auto m4 = taxonomy::cast<taxonomy::matrix4>(map(extrusion.Position())); auto m4 = taxonomy::cast<taxonomy::matrix4>(map(extrusion.Position()));
if (!m4) { if (!m4) {
logger_.message(::logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product);
return false; return false;
} else { } else {
extrusion_position = m4; extrusion_position = m4;
@@ -1163,7 +1163,7 @@ bool mapping::get_layerset_information(const express::base& p, layerset_informat
taxonomy::direction3::ptr extrusion_direction = taxonomy::cast<taxonomy::direction3>(map(extrusion.ExtrudedDirection())); taxonomy::direction3::ptr extrusion_direction = taxonomy::cast<taxonomy::direction3>(map(extrusion.ExtrudedDirection()));
if (!extrusion_direction) { if (!extrusion_direction) {
logger_.message(::logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product);
return false; return false;
} }
+4 -4
View File
@@ -75,19 +75,19 @@ namespace geom {
} }
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
logger_.message(::logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst);
} }
} else if (failed_on_purpose_.find(inst) == failed_on_purpose_.end()) { } else if (failed_on_purpose_.find(inst) == failed_on_purpose_.end()) {
logger_.message(::logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst);
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
logger_.message(::logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst); logger_.message(ifcopenshell::logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst);
} }
} }
} }
IfcSchema::IfcStyledItem find_style(const IfcSchema::IfcRepresentationItem&); IfcSchema::IfcStyledItem find_style(const IfcSchema::IfcRepresentationItem&);
public: public:
POSTFIX_SCHEMA(mapping)(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) : abstract_mapping(settings, logger), file_(file), placement_rel_to_type_(nullptr) { POSTFIX_SCHEMA(mapping)(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) : abstract_mapping(settings, logger), file_(file), placement_rel_to_type_(nullptr) {
initialize_units_(); initialize_units_();
} }
virtual ifcopenshell::geom::taxonomy::ptr map(const express::base&); virtual ifcopenshell::geom::taxonomy::ptr map(const express::base&);
+1 -1
View File
@@ -29,7 +29,7 @@ namespace ifcopenshell {
namespace { namespace {
struct POSTFIX_SCHEMA(factory_t) { struct POSTFIX_SCHEMA(factory_t) {
abstract_mapping* operator()(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger) const { abstract_mapping* operator()(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger) const {
return new POSTFIX_SCHEMA(mapping)(file, settings, logger); return new POSTFIX_SCHEMA(mapping)(file, settings, logger);
} }
}; };
+1 -1
View File
@@ -120,7 +120,7 @@ taxonomy::loop::ptr ifcopenshell::geom::profile_helper(const taxonomy::matrix4::
if (fillet.IsDone()) { if (fillet.IsDone()) {
face = TopoDS::Face(fillet.Shape()); face = TopoDS::Face(fillet.Shape());
} else { } else {
::logger::root().error("Failed to process profile fillets"); ifcopenshell::logger::root().error("Failed to process profile fillets");
} }
} }
*/ */
+2 -2
View File
@@ -861,7 +861,7 @@ std::optional<function_item::ptr> ifcopenshell::geom::taxonomy::loop_to_function
spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn)); spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn));
} else if (edge_->start.index() == 1 && edge_->end.index() == 1) { } else if (edge_->start.index() == 1 && edge_->end.index() == 1) {
if (edge_->basis && edge_->basis->kind() != LINE) { if (edge_->basis && edge_->basis->kind() != LINE) {
::logger::root().message(::logger::severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge"); ifcopenshell::logger::root().message(ifcopenshell::logger::severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge");
} }
const auto& s = std::get<point3::ptr>(edge_->start)->ccomponents(); const auto& s = std::get<point3::ptr>(edge_->start)->ccomponents();
const auto& e = std::get<point3::ptr>(edge_->end)->ccomponents(); const auto& e = std::get<point3::ptr>(edge_->end)->ccomponents();
@@ -876,7 +876,7 @@ std::optional<function_item::ptr> ifcopenshell::geom::taxonomy::loop_to_function
}; };
spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn)); spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn));
} else { } else {
::logger::root().message(::logger::severity::LOG_ERROR, "UNS", 21, "Basis curve not supported"); ifcopenshell::logger::root().message(ifcopenshell::logger::severity::LOG_ERROR, "UNS", 21, "Basis curve not supported");
return std::nullopt; return std::nullopt;
} }
} }
+1 -1
View File
@@ -37,7 +37,7 @@
// @todo don't do std::less but use hashing and cache hash values. // @todo don't do std::less but use hashing and cache hash values.
namespace boost { inline std::size_t hash_value(const blank&) { return 0; } } namespace boost { inline std::size_t hash_value(const boost::blank&) { return 0; } }
namespace ifcopenshell { namespace ifcopenshell {
+4 -4
View File
@@ -488,7 +488,7 @@ Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper<Ifc4x3_add2>& file, cons
return alignment; return alignment;
} }
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentSegment& segment, logger& logger) { std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result; std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto design_parameters = segment.DesignParameters(); auto design_parameters = segment.DesignParameters();
auto horizontal = design_parameters.as<Ifc4x3_add2::IfcAlignmentHorizontalSegment>(); auto horizontal = design_parameters.as<Ifc4x3_add2::IfcAlignmentHorizontalSegment>();
@@ -514,7 +514,7 @@ Ifc4x3_add2::IfcLengthMeasure create_length(hierarchy_helper<Ifc4x3_add2>& file,
} }
} }
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, logger& logger) { std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result; std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto start_point = segment.StartPoint(); auto start_point = segment.StartPoint();
auto start_direction = segment.StartDirection(); auto start_direction = segment.StartDirection();
@@ -770,7 +770,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignme
return result; return result;
} }
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, logger& logger) { std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result; std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto start_distance_along = segment.StartDistAlong(); auto start_distance_along = segment.StartDistAlong();
auto horizontal_length = segment.HorizontalLength(); auto horizontal_length = segment.HorizontalLength();
@@ -862,7 +862,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignme
return result; return result;
} }
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, logger& logger) { std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result; std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto type = segment.PredefinedType(); auto type = segment.PredefinedType();
if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) { if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) {
+4 -4
View File
@@ -45,10 +45,10 @@ IFC_SCHEMA_API Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper<Ifc4x3_ad
// Maps horizontal alignment business logic to geometry. // Maps horizontal alignment business logic to geometry.
// Bloss curves have two geometry elements for one horizontal alignment segment. That is the reason for returning a pair. // Bloss curves have two geometry elements for one horizontal alignment segment. That is the reason for returning a pair.
// Typically the first element of the pair will have the geometry and the second element will be nullptr // Typically the first element of the pair will have the geometry and the second element will be nullptr
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentSegment& segment, logger& logger = ::logger::root()); IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, logger& logger = ::logger::root()); IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, logger& logger = ::logger::root()); IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, logger& logger = ::logger::root()); IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
#endif #endif
+1 -1
View File
@@ -57,7 +57,7 @@ class IFC_PARSE_API character_decoder {
inline static ConversionMode mode = UTF8; inline static ConversionMode mode = UTF8;
inline static char substitution_character = '_'; inline static char substitution_character = '_';
character_decoder(Reader* stream, logger& logger = ::logger::root()); character_decoder(Reader* stream, logger& logger = ifcopenshell::logger::root());
~character_decoder(); ~character_decoder();
// Gets a decoded string representation at the token stream // Gets a decoded string representation at the token stream
// read pointer and advances the underlying token stream. // read pointer and advances the underlying token stream.
+19 -17
View File
@@ -3,6 +3,8 @@
#include "exception.h" #include "exception.h"
#include "file.h" #include "file.h"
using namespace ifcopenshell;
// @todo is size() still needed? // @todo is size() still needed?
class size_visitor { class size_visitor {
public: public:
@@ -37,7 +39,7 @@ namespace {
if (storage_model_ == 0) { if (storage_model_ == 0) {
try { try {
return array_.storage_ptr->get<T>(index_); return array_.storage_ptr->get<T>(index_);
} catch (const impl::storage_type_mismatch& e) { } catch (const ::impl::storage_type_mismatch& e) {
throw ifcopenshell::exception( throw ifcopenshell::exception(
// entity_or_type not passed, but in v0.9 this is beginning to make sense // entity_or_type not passed, but in v0.9 this is beginning to make sense
(entity_or_type (entity_or_type
@@ -66,7 +68,7 @@ namespace {
(is_header ? "h|" : (entity_or_type->as_entity() ? "i|" : "t|")) + (is_header ? "h|" : (entity_or_type->as_entity() ? "i|" : "t|")) +
(is_header ? entity_or_type->name() : std::to_string(instance_name_)) + "|" + (is_header ? entity_or_type->name() : std::to_string(instance_name_)) + "|" +
std::to_string(index_), &str); std::to_string(index_), &str);
impl::deserialize(array_.db_ptr, str, val); ::impl::deserialize(array_.db_ptr, str, val);
} else { } else {
static_assert( static_assert(
std::is_same_v<T, enumeration_reference> || std::is_same_v<T, enumeration_reference> ||
@@ -287,7 +289,7 @@ ifcopenshell::argument_type attribute_value::type() const
#ifdef IFOPSH_WITH_ROCKSDB #ifdef IFOPSH_WITH_ROCKSDB
bool impl::serialize(std::string& val, const express::base& t) bool ::impl::serialize(std::string& val, const express::base& t)
{ {
auto s = sizeof(size_t); auto s = sizeof(size_t);
val.resize(s + 2); val.resize(s + 2);
@@ -300,7 +302,7 @@ bool impl::serialize(std::string& val, const express::base& t)
return true; return true;
} }
bool impl::serialize(std::string& val, const enumeration_reference& v) bool ::impl::serialize(std::string& val, const enumeration_reference& v)
{ {
auto s = sizeof(size_t); auto s = sizeof(size_t);
val.resize(s * 2 + 1); val.resize(s * 2 + 1);
@@ -312,7 +314,7 @@ bool impl::serialize(std::string& val, const enumeration_reference& v)
return true; return true;
} }
bool impl::serialize(std::string& val, const std::vector<express::base>& t) bool ::impl::serialize(std::string& val, const std::vector<express::base>& t)
{ {
// no attempt at alignment // no attempt at alignment
val.resize(t.size() * (sizeof(size_t) + 1) + 1); val.resize(t.size() * (sizeof(size_t) + 1) + 1);
@@ -328,7 +330,7 @@ bool impl::serialize(std::string& val, const std::vector<express::base>& t)
return true; return true;
} }
bool impl::serialize(std::string& val, const std::vector<std::vector<express::base>>& t) bool ::impl::serialize(std::string& val, const std::vector<std::vector<express::base>>& t)
{ {
std::ostringstream oss; std::ostringstream oss;
oss.put(type_encoder::encode_type<std::vector<std::vector<express::base>>>()); oss.put(type_encoder::encode_type<std::vector<std::vector<express::base>>>());
@@ -363,35 +365,35 @@ bool impl::serialize(std::string& val, const std::vector<std::vector<express::ba
return true; return true;
} }
bool impl::serialize(std::string& val, const blank&) bool ::impl::serialize(std::string& val, const blank&)
{ {
val.resize(1); val.resize(1);
val[0] = type_encoder::encode_type<blank>(); val[0] = type_encoder::encode_type<blank>();
return true; return true;
} }
bool impl::serialize(std::string& val, const derived&) bool ::impl::serialize(std::string& val, const derived&)
{ {
val.resize(1); val.resize(1);
val[0] = type_encoder::encode_type<derived>(); val[0] = type_encoder::encode_type<derived>();
return true; return true;
} }
bool impl::serialize(std::string& val, const empty_aggregate_t&) bool ::impl::serialize(std::string& val, const empty_aggregate_t&)
{ {
val.resize(1); val.resize(1);
val[0] = type_encoder::encode_type<empty_aggregate_t>(); val[0] = type_encoder::encode_type<empty_aggregate_t>();
return true; return true;
} }
bool impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t&) bool ::impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t&)
{ {
val.resize(1); val.resize(1);
val[0] = type_encoder::encode_type<empty_aggregate_of_aggregate_t>(); val[0] = type_encoder::encode_type<empty_aggregate_of_aggregate_t>();
return true; return true;
} }
bool impl::serialize(std::string& val, const boost::logic::tribool& t) bool ::impl::serialize(std::string& val, const boost::logic::tribool& t)
{ {
char tt = t == boost::logic::indeterminate ? 2 : t ? 1 : 0; char tt = t == boost::logic::indeterminate ? 2 : t ? 1 : 0;
val.resize(sizeof(char) + 1); val.resize(sizeof(char) + 1);
@@ -400,7 +402,7 @@ bool impl::serialize(std::string& val, const boost::logic::tribool& t)
return true; return true;
} }
bool impl::serialize(std::string& val, const boost::dynamic_bitset<>& t) bool ::impl::serialize(std::string& val, const boost::dynamic_bitset<>& t)
{ {
std::string tmp; std::string tmp;
boost::to_string(t, tmp); boost::to_string(t, tmp);
@@ -408,7 +410,7 @@ bool impl::serialize(std::string& val, const boost::dynamic_bitset<>& t)
return true; return true;
} }
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::logic::tribool& t) { bool ::impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::logic::tribool& t) {
if (val[0] != type_encoder::encode_type<boost::logic::tribool>()) { if (val[0] != type_encoder::encode_type<boost::logic::tribool>()) {
return false; return false;
} }
@@ -424,7 +426,7 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::st
return true; return true;
} }
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::dynamic_bitset<>& t) { bool ::impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::dynamic_bitset<>& t) {
if (val[0] != type_encoder::encode_type<boost::dynamic_bitset<>>()) { if (val[0] != type_encoder::encode_type<boost::dynamic_bitset<>>()) {
return false; return false;
} }
@@ -432,7 +434,7 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::st
return true; return true;
} }
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<express::base>& t) { bool ::impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<express::base>& t) {
auto n = (val.size() - 1) / (sizeof(size_t) + 1); auto n = (val.size() - 1) / (sizeof(size_t) + 1);
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
auto ptr = val.data() + 1 + (sizeof(size_t) + 1) * i; auto ptr = val.data() + 1 + (sizeof(size_t) + 1) * i;
@@ -451,7 +453,7 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const
return true; return true;
} }
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<std::vector<express::base>>& t) { bool ::impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<std::vector<express::base>>& t) {
char const* ptr = val.data() + 1; char const* ptr = val.data() + 1;
// size_t outer_size; // size_t outer_size;
@@ -514,7 +516,7 @@ void rocks_db_attribute_storage::set(void* storage, const ifcopenshell::declarat
const bool is_header = decl->schema() == &Header_section_schema::get_schema(); const bool is_header = decl->schema() == &Header_section_schema::get_schema();
ifcopenshell::impl::rocks_db_file_storage* rdb_storage = (ifcopenshell::impl::rocks_db_file_storage*)storage; ifcopenshell::impl::rocks_db_file_storage* rdb_storage = (ifcopenshell::impl::rocks_db_file_storage*)storage;
std::string v; std::string v;
impl::serialize(v, value); ::impl::serialize(v, value);
rdb_storage->db->Put( rdb_storage->db->Put(
rdb_storage->wopts, rdb_storage->wopts,
(is_header ? "h|" : (decl->as_entity() ? "i|" : "t|")) + (is_header ? "h|" : (decl->as_entity() ? "i|" : "t|")) +
+2 -2
View File
@@ -8,7 +8,7 @@ uint32_t express::base::identity() const { return data()->identity(); }
uint32_t express::base::id() const { return data()->id(); } uint32_t express::base::id() const { return data()->id(); }
const instance_data* express::base::data() const { const ifcopenshell::instance_data* express::base::data() const {
#ifdef IFOPSH_SAFE_INSTANCE #ifdef IFOPSH_SAFE_INSTANCE
auto sp = data_.lock(); auto sp = data_.lock();
if (sp) { if (sp) {
@@ -21,7 +21,7 @@ const instance_data* express::base::data() const {
#endif #endif
} }
instance_data* express::base::data() { ifcopenshell::instance_data* express::base::data() {
#ifdef IFOPSH_SAFE_INSTANCE #ifdef IFOPSH_SAFE_INSTANCE
auto sp = data_.lock(); auto sp = data_.lock();
if (sp) { if (sp) {
+6 -4
View File
@@ -54,8 +54,10 @@ struct in_memory_file_storage;
} }
} // namespace ifcopenshell } // namespace ifcopenshell
namespace ifcopenshell {
class instance_data; class instance_data;
class attribute_value; class attribute_value;
}
namespace express { namespace express {
@@ -67,8 +69,8 @@ class declared_type;
class IFC_PARSE_API base { class IFC_PARSE_API base {
protected: protected:
ifcopenshell::pointer_type data_; ifcopenshell::pointer_type data_;
const instance_data* data() const; const ifcopenshell::instance_data* data() const;
instance_data* data(); ifcopenshell::instance_data* data();
public: public:
operator bool() const { operator bool() const {
#ifdef IFOPSH_SAFE_INSTANCE #ifdef IFOPSH_SAFE_INSTANCE
@@ -120,7 +122,7 @@ class IFC_PARSE_API base {
void unset_attribute_value(size_t attribute_index); void unset_attribute_value(size_t attribute_index);
attribute_value get_attribute_value(size_t attribute_index) const; ifcopenshell::attribute_value get_attribute_value(size_t attribute_index) const;
uint32_t identity() const; uint32_t identity() const;
@@ -160,7 +162,7 @@ class IFC_PARSE_API entity : public base {
public: public:
using base::base; using base::base;
attribute_value get(const std::string& attribute_name) const; ifcopenshell::attribute_value get(const std::string& attribute_name) const;
template <typename T> template <typename T>
T get_value(const std::string& attribute_name) const; T get_value(const std::string& attribute_name) const;
+13 -13
View File
@@ -102,7 +102,7 @@ private:
const ifcopenshell::schema_definition* schema_; const ifcopenshell::schema_definition* schema_;
ifcopenshell::impl::in_memory_file_storage storage_; ifcopenshell::impl::in_memory_file_storage storage_;
ifcopenshell::file_open_status good_ = ifcopenshell::file_open_status::SUCCESS; ifcopenshell::file_open_status good_ = ifcopenshell::file_open_status::SUCCESS;
std::reference_wrapper<::logger> logger_; std::reference_wrapper<ifcopenshell::logger> logger_;
int progress_; int progress_;
ifcopenshell::unresolved_references references_to_resolve_; ifcopenshell::unresolved_references references_to_resolve_;
int yielded_header_instances_ = 0; int yielded_header_instances_ = 0;
@@ -156,13 +156,13 @@ private:
void push_page(const std::string& page_data); void push_page(const std::string& page_data);
instance_streamer(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); instance_streamer(ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
instance_streamer(const std::string& path, bool use_mmap = false, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); instance_streamer(const std::string& path, bool use_mmap = false, ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
instance_streamer(void* data, int data_size, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); instance_streamer(void* data, int data_size, ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
instance_streamer(Reader* stream, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()); instance_streamer(Reader* stream, ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
void bypass_types(const std::set<std::string>& type_names); void bypass_types(const std::set<std::string>& type_names);
@@ -210,7 +210,7 @@ public:
private: private:
file_open_status good_ = file_open_status::SUCCESS; file_open_status good_ = file_open_status::SUCCESS;
std::reference_wrapper<::logger> logger_; std::reference_wrapper<ifcopenshell::logger> logger_;
const ifcopenshell::schema_definition* schema_; const ifcopenshell::schema_definition* schema_;
const ifcopenshell::declaration* ifcroot_type_; const ifcopenshell::declaration* ifcroot_type_;
@@ -241,7 +241,7 @@ public:
/// </summary> /// </summary>
/// <param name="path">UTF-8 file path to an IFC-SPF file</param> /// <param name="path">UTF-8 file path to an IFC-SPF file</param>
/// <param name="mmap">Whether to use memory-mapped I/O</param> /// <param name="mmap">Whether to use memory-mapped I/O</param>
file(const std::string& path, bool use_mmap, ::logger& logger = ::logger::root()); file(const std::string& path, bool use_mmap, ifcopenshell::logger& logger = ifcopenshell::logger::root());
#endif #endif
/// <summary> /// <summary>
/// Constructs an file object from a file path, supports IFC-SPF and the IfcOpenShell-specific RocksDB format. /// Constructs an file object from a file path, supports IFC-SPF and the IfcOpenShell-specific RocksDB format.
@@ -250,17 +250,17 @@ public:
/// <param name="type">File type of the path</param> /// <param name="type">File type of the path</param>
/// <param name="read_only">Whether to open in read-only mode, only supported on RocksDB databases</param> /// <param name="read_only">Whether to open in read-only mode, only supported on RocksDB databases</param>
/// <param name="logger">Logger used while opening the file</param> /// <param name="logger">Logger used while opening the file</param>
file(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false, ::logger& logger = ::logger::root()); file(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false, ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary> /// <summary>
/// Constructs an file object from a stream containing IFC-SPF data. /// Constructs an file object from a stream containing IFC-SPF data.
/// </summary> /// </summary>
file(std::istream& stream, int data_size, ::logger& logger = ::logger::root()); file(std::istream& stream, int data_size, ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary> /// <summary>
/// Constructs an file object from a memory buffer containing IFC-SPF data. /// Constructs an file object from a memory buffer containing IFC-SPF data.
/// </summary> /// </summary>
file(void* data, int data_size, ::logger& logger = ::logger::root()); file(void* data, int data_size, ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary> /// <summary>
/// Constructs an file object with the specified schema, file type, and file path. /// Constructs an file object with the specified schema, file type, and file path.
@@ -270,12 +270,12 @@ public:
/// <param name="type">The file type to use for the file. Defaults to FT_AUTODETECT.</param> /// <param name="type">The file type to use for the file. Defaults to FT_AUTODETECT.</param>
/// <param name="path">The file system path to the IFC file. Defaults to an empty string.</param> /// <param name="path">The file system path to the IFC file. Defaults to an empty string.</param>
/// <param name="logger">Logger used while creating the file.</param> /// <param name="logger">Logger used while creating the file.</param>
file(const ifcopenshell::schema_definition* schema = ifcopenshell::schema_by_name("IFC4"), filetype type = FT_AUTODETECT, const std::string& path = "", ::logger& logger = ::logger::root()); file(const ifcopenshell::schema_definition* schema = ifcopenshell::schema_by_name("IFC4"), filetype type = FT_AUTODETECT, const std::string& path = "", ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary> /// <summary>
/// Constructs an unitialized file object. Call initialize() later on. Allows to specify which types to bypass during load. /// Constructs an unitialized file object. Call initialize() later on. Allows to specify which types to bypass during load.
/// </summary> /// </summary>
file(const uninitialized_tag& tag, ::logger& logger = ::logger::root()); file(const uninitialized_tag& tag, ifcopenshell::logger& logger = ifcopenshell::logger::root());
bool initialize(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false); bool initialize(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false);
#ifdef USE_MMAP #ifdef USE_MMAP
@@ -289,7 +289,7 @@ public:
~file(); ~file();
ifcopenshell::file_open_status good() const { return good_; } ifcopenshell::file_open_status good() const { return good_; }
::logger& logger() const { return logger_.get(); } ifcopenshell::logger& logger() const { return logger_.get(); }
/// Returns the first entity in the range of instances contained in the model, /// Returns the first entity in the range of instances contained in the model,
/// in arbitrary order /// in arbitrary order

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