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

This commit is contained in:
Thomas Krijnen
2026-06-10 18:30:54 +02:00
parent a751fb956d
commit a7738eeb64
132 changed files with 1029 additions and 884 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt
auto it = cache_.find(item);
if (it != cache_.end()) {
results = it->second;
Logger::Notice("SYS", 25, "Cache hit #" + std::to_string(item->instance->as<IfcUtil::IfcBaseEntity>()->id()) +
logger_.Notice("SYS", 25, "Cache hit #" + std::to_string(item->instance->as<IfcUtil::IfcBaseEntity>()->id()) +
" -> #" + std::to_string(it->first->instance->as<IfcUtil::IfcBaseEntity>()->id()));
return true;
}
@@ -30,7 +30,7 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt
try {
return fn();
} catch (std::exception& e) {
Logger::Error("GEO", 27, e, item->instance);
logger_.Error("GEO", 27, e, item->instance);
return false;
} catch (...) {
// @todo we can't log OCCT exceptions here, can we do some reraising to solve this?
+10 -7
View File
@@ -64,13 +64,15 @@ namespace ifcopenshell {
protected:
std::string geometry_library_;
Settings settings_;
Logger& logger_;
public:
bool propagate_exceptions = false;
bool partial_success_is_success = true;
AbstractKernel(const std::string& geometry_library, const Settings& settings)
AbstractKernel(const std::string& geometry_library, const Settings& settings, Logger& logger = Logger::Root())
: geometry_library_(geometry_library)
, settings_(settings) {}
, settings_(settings)
, logger_(logger) {}
virtual ~AbstractKernel() = default;
@@ -79,6 +81,7 @@ namespace ifcopenshell {
const std::string& geometry_library() const {
return geometry_library_;
}
Logger& logger() const { return logger_; }
virtual bool supports_boolean_operations() const = 0;
@@ -154,7 +157,7 @@ namespace {
if (item->instance) {
created_from = " (created from " + item->instance->declaration().name() + ")";
}
Logger::Error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
kernel->logger().Error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
return false;
}
};
@@ -178,7 +181,7 @@ namespace {
if (item->instance) {
created_from = " (created from " + item->instance->declaration().name() + ")";
}
Logger::Error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
kernel->logger().Error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
return false;
}
};
@@ -214,7 +217,7 @@ namespace {
template <typename T>
struct dispatch_curve_creation<T, ifcopenshell::geometry::taxonomy::curves::max> {
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
Logger::Error("GEO", 28, "No conversion for " + std::to_string(item->kind()));
Logger::Root().Error("GEO", 28, "No conversion for " + std::to_string(item->kind()));
return false;
}
};
@@ -236,10 +239,10 @@ namespace {
template <typename T>
struct dispatch_surface_creation<T, ifcopenshell::geometry::taxonomy::surfaces::max> {
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
Logger::Error("GEO", 29, "No conversion for " + std::to_string(item->kind()));
Logger::Root().Error("GEO", 29, "No conversion for " + std::to_string(item->kind()));
return false;
}
};
}
#endif
#endif
+2 -2
View File
@@ -3,11 +3,11 @@
#include <iomanip>
IfcGeom::Representation::Triangulation * IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings) const
IfcGeom::Representation::Triangulation* IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings, Logger& logger) const
{
auto t = IfcGeom::Representation::Triangulation::empty(settings);
static ifcopenshell::geometry::taxonomy::matrix4 iden;
Triangulate(settings, iden, t, -1, -1);
Triangulate(settings, iden, t, -1, -1, logger);
return t;
}
+2 -2
View File
@@ -253,8 +253,8 @@ namespace IfcGeom {
class IFC_GEOM_API ConversionResultShape {
public:
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id) const = 0;
IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const = 0;
IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const = 0;
virtual int surface_genus() const = 0;
+11 -10
View File
@@ -4,10 +4,11 @@
using namespace ifcopenshell::geometry;
ifcopenshell::geometry::Converter::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& s)
ifcopenshell::geometry::Converter::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& s, Logger& logger)
: kernel_(std::move(geometry_library))
, logger_(logger)
{
mapping_ = impl::mapping_implementations().construct(file, s);
mapping_ = impl::mapping_implementations().construct(file, s, logger_);
// Mapping reads unit information and applies to settings
settings_ = mapping_->settings();
}
@@ -17,7 +18,7 @@ ifcopenshell::geometry::Converter::~Converter() {
}
namespace {
void substitute_with_box_based_on_density(IfcGeom::ConversionResults& items, double& density) {
void substitute_with_box_based_on_density(Logger& logger, IfcGeom::ConversionResults& items, double& density) {
int nv = 0;
void* box = nullptr;
double volume = 0.;
@@ -29,7 +30,7 @@ namespace {
if (density > 1e5) {
items[0].Shape()->set_box(box);
items.erase(items.begin() + 1, items.end());
Logger::Notice("GEO", 30, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
logger.Notice("GEO", 30, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
}
}
}
@@ -138,7 +139,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
}
}
if (some_items_without_style) {
Logger::Warning("GEO", 31, "No material and surface styles for:", product);
logger_.Warning("GEO", 31, "No material and surface styles for:", product);
}
}
@@ -162,7 +163,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
parent_id = parent_object->id();
}
} catch (const std::exception& e) {
Logger::Error("GEO", 32, e);
logger_.Error("GEO", 32, e);
}
const std::string name = product->get_value<std::string>("Name", "");
@@ -208,10 +209,10 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
kernel_->convert_openings(product, opening_items, shapes, *place, opened_shapes);
}
} catch (const std::exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 33, std::string("Error processing openings for: ") + e.what() + ":", product);
caught_error = true;
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 34, "Error processing openings for:", product);
}
if (!(caught_error && opened_shapes.size() < shapes.size())) {
@@ -239,7 +240,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
std::swap(shapes, unified_shapes);
}
} catch (std::exception& e) {
Logger::Error("GEO", 35, e);
logger_.Error("GEO", 35, e);
}
}
@@ -357,7 +358,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process
parent_id = parent_object->id();
}
} catch (const std::exception& e) {
Logger::Error("GEO", 36, e);
logger_.Error("GEO", 36, e);
}
const std::string guid = product->get_value<std::string>("GlobalId");
+4 -2
View File
@@ -21,15 +21,17 @@ namespace ifcopenshell { namespace geometry {
std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel> kernel_;
ifcopenshell::geometry::Settings settings_;
std::map<ifcopenshell::geometry::taxonomy::ptr, brep_ptr, ifcopenshell::geometry::taxonomy::less_functor> cache_;
Logger& logger_;
public:
ifcopenshell::geometry::kernels::AbstractKernel* kernel() { return &*kernel_; }
Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& settings);
Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, IfcParse::IfcFile* file, ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root());
~Converter();
ifcopenshell::geometry::abstract_mapping* mapping() const { return mapping_; }
Logger& logger() const { return logger_; }
/*
virtual NativeElement<double, double>* convert(
@@ -55,4 +57,4 @@ namespace ifcopenshell { namespace geometry {
};
}}
#endif
#endif
+4 -3
View File
@@ -143,8 +143,9 @@ class GeometrySerializer : public Serializer {
public:
enum read_type { READ_BREP, READ_TRIANGULATION };
GeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings)
: geometry_settings_(geometry_settings)
GeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root())
: Serializer(logger)
, geometry_settings_(geometry_settings)
, settings_(settings)
{}
virtual ~GeometrySerializer() {}
@@ -177,7 +178,7 @@ protected:
class WriteOnlyGeometrySerializer : public GeometrySerializer {
public:
WriteOnlyGeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings) : GeometrySerializer(geometry_settings, settings) {}
WriteOnlyGeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger& logger = Logger::Root()) : GeometrySerializer(geometry_settings, settings, logger) {}
virtual IfcGeom::Element* read(IfcParse::IfcFile&, const std::string&, const std::string&, read_type = READ_BREP) {
throw std::runtime_error("Not supported");
+1 -1
View File
@@ -125,7 +125,7 @@ namespace IfcGeom {
oss << "product-" << IfcParse::IfcGlobalId(guid).formatted();
} catch (const std::exception& e) {
oss << "product";
Logger::Error("GEO", 39, e);
Logger::Root().Error("GEO", 39, e);
}
}
+27 -27
View File
@@ -31,7 +31,7 @@ bool IfcGeom::Iterator::initialize() {
try {
converter_->mapping()->get_representations(reps, filters_);
} catch (const std::exception& e) {
Logger::Error("GEO", 50, e);
logger_.Error("GEO", 50, e);
}
time_points[1] = high_resolution_clock::now();
@@ -94,7 +94,7 @@ bool IfcGeom::Iterator::initialize() {
tasks_.back().item = p.first;
tasks_.back().products = p.second;
}
Logger::Notice("SYS", 26, "Merged " + std::to_string(old_size) + " tasks into " + std::to_string(tasks_.size()) + " tasks due to permissive shape reuse");
logger_.Notice("SYS", 26, "Merged " + std::to_string(old_size) + " tasks into " + std::to_string(tasks_.size()) + " tasks due to permissive shape reuse");
}
}
@@ -139,10 +139,10 @@ bool IfcGeom::Iterator::initialize() {
}
*/
Logger::Notice("SYS", 27, "Created " + boost::lexical_cast<std::string>(tasks_.size()) + " tasks for " + boost::lexical_cast<std::string>(num_products) + " products");
logger_.Notice("SYS", 27, "Created " + boost::lexical_cast<std::string>(tasks_.size()) + " tasks for " + boost::lexical_cast<std::string>(num_products) + " products");
if (tasks_.size() == 0) {
Logger::Warning("GEO", 51, "No representations encountered, aborting");
logger_.Warning("GEO", 51, "No representations encountered, aborting");
initialization_outcome_.reset(false);
} else if (!settings_.get<ifcopenshell::geometry::settings::DeferProcessingFirstElement>().get()) {
@@ -194,7 +194,7 @@ void IfcGeom::Iterator::process_concurrently() {
kernel_pool.reserve(conc_threads);
for (unsigned i = 0; i < conc_threads; ++i) {
kernel_pool.push_back(new ifcopenshell::geometry::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>(converter_->kernel()->clone()), ifc_file, settings_));
kernel_pool.push_back(new ifcopenshell::geometry::Converter(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>(converter_->kernel()->clone()), ifc_file, settings_, logger_));
}
std::vector<std::future<geometry_conversion_result*>> threadpool;
@@ -231,14 +231,14 @@ void IfcGeom::Iterator::process_concurrently() {
try {
this->create_element_(kernel, settings, rep);
} catch (const std::exception& e) {
Logger::Error("GEO", 52,
logger_.Error("GEO", 52,
std::string("Exception '") + e.what() +
std::string("' occurred while iterator was creating a shape: "),
rep->item->instance
);
had_error_processing_elements_ = true;
} catch (...) {
Logger::Error("GEO", 53,
logger_.Error("GEO", 53,
"Unknown exception occurred while iteartor was creating a shape: ",
rep->item->instance
);
@@ -263,10 +263,10 @@ void IfcGeom::Iterator::process_concurrently() {
finished_ = true;
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
if (!terminating_) {
Logger::Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(all_processed_elements_.size()) +
logger_.Status("\rDone creating geometry (" + boost::lexical_cast<std::string>(all_processed_elements_.size()) +
" objects) ");
}
}
@@ -360,20 +360,20 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne
const IfcUtil::IfcBaseEntity* product = product_node.first;
const auto& place = product_node.second;
Logger::SetProduct(product);
logger_.SetProduct(product);
IfcGeom::BRepElement* brep = static_cast<IfcGeom::BRepElement*>(decorate_with_cache_(GeometrySerializer::READ_BREP, (std::string)product->get("GlobalId"), std::to_string(rep->item->instance->as<IfcUtil::IfcBaseEntity>()->id()), [kernel, settings, product, place, rep]() {
return kernel->create_brep_for_representation_and_product(rep->item, product, place);
}));
if (!brep) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
return;
}
auto elem = process_based_on_settings(settings, brep);
if (!elem) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
return;
}
@@ -397,7 +397,7 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne
}
}
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
}
IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geometry::Settings settings, IfcGeom::BRepElement* elem, IfcGeom::TriangulationElement* previous)
@@ -406,7 +406,7 @@ IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geo
try {
return new IfcGeom::SerializedElement(*elem);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed.");
logger_.Message(Logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed.");
return nullptr;
}
} else if (settings.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::TRIANGULATED) {
@@ -417,7 +417,7 @@ IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geo
gid2 = gid2.substr(0, hyphen);
}
return decorate_with_cache_(GeometrySerializer::READ_TRIANGULATION, elem->guid(), gid2, [elem, previous]() {
return decorate_with_cache_(GeometrySerializer::READ_TRIANGULATION, elem->guid(), gid2, [this, elem, previous]() {
try {
if (!previous) {
return new TriangulationElement(*elem);
@@ -425,7 +425,7 @@ IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geo
return new TriangulationElement(*elem, previous->geometry_pointer());
}
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed.");
logger_.Message(Logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed.");
}
return (TriangulationElement*)nullptr;
});
@@ -466,7 +466,7 @@ void IfcGeom::Iterator::log_timepoints() const {
for (auto it = time_points.begin() + 1; it != time_points.end(); ++it) {
auto jt = it - 1;
duration<double, std::milli> ms_double = (*it) - (*jt);
Logger::Notice("SYS", 28, labels[std::distance(time_points.begin(), jt)] + " took " + std::to_string(ms_double.count()) + "ms");
logger_.Notice("SYS", 28, labels[std::distance(time_points.begin(), jt)] + " took " + std::to_string(ms_double.count()) + "ms");
}
}
@@ -501,7 +501,7 @@ const IfcUtil::IfcBaseClass* IfcGeom::Iterator::next() {
if (num_threads_ != 1) {
if (!wait_for_element()) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
time_points[3] = high_resolution_clock::now();
log_timepoints();
task_result_ptr_exhausted = true;
@@ -517,7 +517,7 @@ const IfcUtil::IfcBaseClass* IfcGeom::Iterator::next() {
// shape representation
if (task_result_iterator_ == --all_processed_elements_.end()) {
if (!create()) {
Logger::SetProduct(boost::none);
logger_.SetProduct(boost::none);
time_points[3] = high_resolution_clock::now();
log_timepoints();
task_result_ptr_exhausted = true;
@@ -554,7 +554,7 @@ IfcGeom::Element* IfcGeom::Iterator::get()
try {
parent_object = get_object(ret->parent_id());
} catch (const std::exception& e) {
Logger::Error("GEO", 56, e);
logger_.Error("GEO", 56, e);
hasParent = false;
}
@@ -572,7 +572,7 @@ IfcGeom::Element* IfcGeom::Iterator::get()
try {
parent_object = get_object(pid);
} catch (const std::exception& e) {
Logger::Error("GEO", 57, e);
logger_.Error("GEO", 57, e);
hasParent = false;
}
}
@@ -619,9 +619,9 @@ const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) {
m4 = casted->matrix;
}
} catch (const std::exception& e) {
Logger::Error("GEO", 58, e);
logger_.Error("GEO", 58, e);
} catch (...) {
Logger::Error("GEO", 59, "Unknown error returning product");
logger_.Error("GEO", 59, "Unknown error returning product");
}
Element* ifc_object = new Element(settings_, id, parent_id, product_name, instance_type, product_guid, "", m4, ifc_product);
@@ -633,10 +633,10 @@ const IfcUtil::IfcBaseClass* IfcGeom::Iterator::create() {
try {
product = create_shape_model_for_next_entity();
} catch (const std::exception& e) {
Logger::Error("GEO", 60, e);
logger_.Error("GEO", 60, e);
had_error_processing_elements_ = true;
} catch (...) {
Logger::Error("GEO", 61, "Unknown error creating geometry");
logger_.Error("GEO", 61, "Unknown error creating geometry");
had_error_processing_elements_ = true;
}
return product;
@@ -808,8 +808,8 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs
}
}
Logger::Notice("SYS", 29, "Removed large offsets within " + std::to_string(num_offset_applied) + " products");
Logger::Notice("SYS", 30, "Offset applied (" + std::to_string(vec(0)) + "," + std::to_string(vec(1)) + "," + std::to_string(vec(2)) + ")");
logger_.Notice("SYS", 29, "Removed large offsets within " + std::to_string(num_offset_applied) + " products");
logger_.Notice("SYS", 30, "Offset applied (" + std::to_string(vec(0)) + "," + std::to_string(vec(1)) + "," + std::to_string(vec(2)) + ")");
return make<direction3>(vec);
}
+11 -7
View File
@@ -126,6 +126,7 @@ namespace IfcGeom {
std::vector<filter_t> filters_;
int num_threads_;
std::string geometry_library_;
Logger& logger_;
// When single-threaded
ifcopenshell::geometry::Converter* converter_;
@@ -209,32 +210,35 @@ namespace IfcGeom {
ifcopenshell::geometry::taxonomy::direction3::ptr remove_offset_();
public:
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads)
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, const std::vector<IfcGeom::filter_t>& filters, int num_threads, Logger& logger = Logger::Root())
: settings_(settings)
, ifc_file(file)
, filters_(filters)
, num_threads_(num_threads)
, geometry_library_(geometry_library->geometry_library())
, logger_(logger)
// @todo verify whether settings are correctly passed on
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_))
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_))
{
}
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file)
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, Logger& logger = Logger::Root())
: settings_(settings)
, ifc_file(file)
, num_threads_(1)
, geometry_library_(geometry_library->geometry_library())
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_))
, logger_(logger)
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_))
{
}
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, int num_threads)
Iterator(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>&& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, int num_threads, Logger& logger = Logger::Root())
: settings_(settings)
, ifc_file(file)
, num_threads_(num_threads)
, geometry_library_(geometry_library->geometry_library())
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_))
, logger_(logger)
, converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_))
{
}
@@ -301,7 +305,7 @@ namespace IfcGeom {
return progress_;
}
std::string getLog() const { return Logger::GetLog(); }
std::string getLog() const { return logger_.GetLog(); }
IfcParse::IfcFile* file() const { return ifc_file; }
+8 -1
View File
@@ -21,15 +21,22 @@
#define SERIALIZER_H
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcLogger.h"
class Serializer {
protected:
Logger& logger_;
public:
explicit Serializer(Logger& logger = Logger::Root()) : logger_(logger) {}
virtual ~Serializer() {}
Logger& logger() const { return logger_; }
virtual bool ready() = 0;
virtual void writeHeader() = 0;
virtual void finalize() = 0;
virtual void setFile(IfcParse::IfcFile*) = 0;
};
#endif
#endif
+2 -2
View File
@@ -37,14 +37,14 @@ void ifcopenshell::geometry::impl::MappingFactoryImplementation::bind(const std:
this->insert(std::make_pair(schema_name_lower, fn));
}
ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(IfcParse::IfcFile* file, Settings& s) {
ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(IfcParse::IfcFile* file, Settings& s, Logger& logger) {
const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name());
std::map<std::string, ifcopenshell::geometry::impl::mapping_fn>::const_iterator it;
it = this->find(schema_name_lower);
if (it == end()) {
throw IfcParse::IfcException("No geometry mapping registered for " + schema_name_lower);
}
auto new_mapping = it->second(file, s);
auto new_mapping = it->second(file, s, logger);
new_mapping->initialize_settings();
return new_mapping;
}
+7 -4
View File
@@ -21,6 +21,7 @@
#define ABSTRACT_MAPPING_H
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/IfcLogger.h"
#include "../ifcparse/aggregate_of_instance.h"
#include "../ifcgeom/taxonomy.h"
#include "../ifcgeom/ConversionSettings.h"
@@ -43,14 +44,15 @@ namespace geometry {
typedef boost::function<bool(IfcUtil::IfcBaseEntity*)> filter_t;
class IFC_GEOM_API abstract_mapping {
class IFC_GEOM_API abstract_mapping {
protected:
Settings settings_;
Logger& logger_;
bool use_caching_ = true;
public:
abstract_mapping(Settings& s) : settings_(s) {}
abstract_mapping(Settings& s, Logger& logger = Logger::Root()) : settings_(s), logger_(logger) {}
virtual ~abstract_mapping() {}
virtual ifcopenshell::geometry::taxonomy::ptr map(const IfcUtil::IfcBaseInterface*) = 0;
@@ -69,19 +71,20 @@ namespace geometry {
const Settings& settings() const { return settings_; }
Settings& settings() { return settings_; }
Logger& logger() const { return logger_; }
bool use_caching() const { return use_caching_; }
bool& use_caching() { return use_caching_; }
};
namespace impl {
typedef boost::function2<abstract_mapping*, IfcParse::IfcFile*, Settings&> mapping_fn;
typedef boost::function3<abstract_mapping*, IfcParse::IfcFile*, Settings&, Logger&> mapping_fn;
class IFC_GEOM_API MappingFactoryImplementation : public std::map<std::string, mapping_fn> {
public:
MappingFactoryImplementation();
void bind(const std::string& schema_name, mapping_fn);
abstract_mapping* construct(IfcParse::IfcFile*, Settings&);
abstract_mapping* construct(IfcParse::IfcFile*, Settings&, Logger& logger = Logger::Root());
};
IFC_GEOM_API MappingFactoryImplementation& mapping_implementations();
+4 -4
View File
@@ -76,7 +76,7 @@ struct piecewise_fn_evaluator : public fn_evaluator {
span_start += fn->length();
}
Logger::Error("GEO", 37, "piecewise span not found.");
logger_.Error("GEO", 37, "piecewise span not found.");
return {0, 0, nullptr};
}
@@ -208,7 +208,7 @@ struct offset_fn_evaluator : public fn_evaluator {
function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn) {
function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn, Logger& logger) : logger_(logger) {
auto kind = fn->kind();
if (kind == taxonomy::FUNCTOR_ITEM) {
fn_evaluator_ = new functor_fn_evaluator(std::dynamic_pointer_cast<const taxonomy::functor_item>(fn),settings);
@@ -221,11 +221,11 @@ function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::S
} else if (kind == taxonomy::OFFSET_FUNCTION) {
fn_evaluator_ = new offset_fn_evaluator(std::dynamic_pointer_cast<const taxonomy::offset_function>(fn), settings);
} else {
Logger::Error("GEO", 38, "Unexpected function type");
logger_.Error("GEO", 38, "Unexpected function type");
}
}
function_item_evaluator::function_item_evaluator(const function_item_evaluator& other) {
function_item_evaluator::function_item_evaluator(const function_item_evaluator& other) : logger_(other.logger_) {
fn_evaluator_ = other.fn_evaluator_->clone();
eval_points_ = other.eval_points_;
}
+6 -2
View File
@@ -23,7 +23,7 @@ static taxonomy::function_item::ptr convert_loop_to_function_item(taxonomy::loop
/// @brief Abstract class for evaluating a function_item. This class is specialized for each of the function_item types.
struct IFC_GEOM_API fn_evaluator {
fn_evaluator(const ifcopenshell::geometry::Settings& settings) : settings_(settings) {
fn_evaluator(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root()) : settings_(settings), logger_(logger) {
}
fn_evaluator(const fn_evaluator& other) = default;
virtual ~fn_evaluator() = default;
@@ -36,12 +36,15 @@ struct IFC_GEOM_API fn_evaluator {
double length() const { return end() - start(); }
ifcopenshell::geometry::Settings settings_;
protected:
Logger& logger_;
};
/// @brief utility class to evaluate function_item objects.
class IFC_GEOM_API function_item_evaluator {
public:
function_item_evaluator(const ifcopenshell::geometry::Settings& settings, taxonomy::function_item::const_ptr fn);
function_item_evaluator(const ifcopenshell::geometry::Settings& settings, taxonomy::function_item::const_ptr fn, Logger& logger = Logger::Root());
function_item_evaluator(const function_item_evaluator& other);
~function_item_evaluator();
@@ -77,6 +80,7 @@ class IFC_GEOM_API function_item_evaluator {
fn_evaluator* fn_evaluator_ = nullptr;
mutable boost::optional<std::vector<double>> eval_points_; // cache evaluation points
Logger& logger_;
};
}}
+13 -13
View File
@@ -64,10 +64,10 @@ namespace ifcopenshell {
ifcopenshell::geometry::abstract_mapping* mapping_;
IfcParse::IfcFile* file_;
public:
HybridKernel(const std::string& name, IfcParse::IfcFile* file, Settings& settings, std::vector<std::unique_ptr<AbstractKernel>>&& kernels)
: AbstractKernel(name, settings)
HybridKernel(const std::string& name, IfcParse::IfcFile* file, Settings& settings, std::vector<std::unique_ptr<AbstractKernel>>&& kernels, Logger& logger = Logger::Root())
: AbstractKernel(name, settings, logger)
, kernels_(std::move(kernels))
, mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings))
, mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings, logger))
, file_(file)
{
}
@@ -163,26 +163,26 @@ namespace ifcopenshell {
ks.emplace_back(k->clone());
}
// @todo ugly
return new HybridKernel(geometry_library(), file_, const_cast<Settings&>(settings()), std::move(ks));
return new HybridKernel(geometry_library(), file_, const_cast<Settings&>(settings()), std::move(ks), logger());
}
};
inline std::unique_ptr<AbstractKernel> construct(IfcParse::IfcFile* file, const std::string& geometry_library, Settings& conv_settings) {
inline std::unique_ptr<AbstractKernel> construct(IfcParse::IfcFile* file, const std::string& geometry_library, Settings& conv_settings, Logger& logger = Logger::Root()) {
std::string geometry_library_lower = boost::to_lower_copy(geometry_library);
#ifdef IFOPSH_WITH_OPENCASCADE
if (geometry_library_lower == "opencascade") {
return std::make_unique<IfcGeom::OpenCascadeKernel>(conv_settings);
return std::make_unique<IfcGeom::OpenCascadeKernel>(conv_settings, logger);
}
#endif
#ifdef IFOPSH_WITH_CGAL
if (geometry_library_lower == "cgal") {
return std::make_unique<CgalKernel>(conv_settings);
return std::make_unique<CgalKernel>(conv_settings, logger);
}
if (geometry_library_lower == "cgal-simple") {
return std::make_unique<SimpleCgalKernel>(conv_settings);
return std::make_unique<SimpleCgalKernel>(conv_settings, logger);
}
#endif
@@ -198,19 +198,19 @@ namespace ifcopenshell {
auto n = kernels.size();
#ifdef IFOPSH_WITH_OPENCASCADE
if (geometry_library_lower.find("opencascade", 0) == 0) {
kernels.emplace_back(new IfcGeom::OpenCascadeKernel(conv_settings));
kernels.emplace_back(new IfcGeom::OpenCascadeKernel(conv_settings, logger));
geometry_library_lower = geometry_library_lower.substr(strlen("opencascade"));
}
#endif
#ifdef IFOPSH_WITH_CGAL
if (geometry_library_lower.find("cgal-simple", 0) == 0) {
kernels.emplace_back(new SimpleCgalKernel(conv_settings));
kernels.emplace_back(new SimpleCgalKernel(conv_settings, logger));
geometry_library_lower = geometry_library_lower.substr(strlen("cgal-simple"));
}
if (geometry_library_lower.find("cgal", 0) == 0) {
kernels.emplace_back(new CgalKernel(conv_settings));
kernels.emplace_back(new CgalKernel(conv_settings, logger));
geometry_library_lower = geometry_library_lower.substr(strlen("cgal"));
}
#endif
@@ -225,7 +225,7 @@ namespace ifcopenshell {
}
if (!kernels.empty()) {
return std::make_unique<HybridKernel>(geometry_library, file, conv_settings, std::move(kernels));
return std::make_unique<HybridKernel>(geometry_library, file, conv_settings, std::move(kernels), logger);
}
}
@@ -236,4 +236,4 @@ namespace ifcopenshell {
}
}
#endif
#endif
+11 -11
View File
@@ -35,7 +35,7 @@ bool has_intersection(const std::set<T, Cmp>& A,
}
taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& fn, std::vector<cross_section>& cross_sections)
taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& fn, std::vector<cross_section>& cross_sections, Logger& logger)
{
std::sort(cross_sections.begin(), cross_sections.end());
@@ -51,7 +51,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
double end = std::min(fn->length(), cross_sections.back().dist_along);
if (end - start < 1.e-9) {
Logger::Warning("GEO", 40, "Empty sweep domain with start at " + std::to_string(cross_sections.front().dist_along) + " end at " + std::to_string(cross_sections.back().dist_along) + " and curve domain length " + std::to_string(fn->length()), inst);
Logger::Root().Warning("GEO", 40, "Empty sweep domain with start at " + std::to_string(cross_sections.front().dist_along) + " end at " + std::to_string(cross_sections.back().dist_along) + " and curve domain length " + std::to_string(fn->length()), inst);
return nullptr;
}
@@ -130,7 +130,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
auto profile_b_f = std::static_pointer_cast<taxonomy::face>(profile_b);
if (profile_a_f->children.size() != profile_b_f->children.size()) {
Logger::Warning("GEO", 41, "Mismatching number of face boundaries: " +
Logger::Root().Warning("GEO", 41, "Mismatching number of face boundaries: " +
std::to_string(profile_a_f->children.size()) + " vs " +
std::to_string(profile_b_f->children.size()),
inst
@@ -165,7 +165,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
// in which case we would need to lerp with the rotation component below in m4b.
interpolated_rotation = lerp(*rotation_a, *rotation_b, relative_dist_along);
} else if (rotation_a != rotation_b) {
Logger::Error("GEO", 42, "Direction vectors on cross section placements only supported when used consistently");
logger.Error("GEO", 42, "Direction vectors on cross section placements only supported when used consistently");
}
taxonomy::loop::ptr w1, w2;
@@ -176,12 +176,12 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
boost::tie(w1, w2) = tmp_;
if (w1->closed != w2->closed) {
Logger::Warning("GEO", 43, "Mismatching closed property on loops", inst);
logger.Warning("GEO", 43, "Mismatching closed property on loops", inst);
return nullptr;
}
if (w1->tags.is_initialized() != w2->tags.is_initialized()) {
Logger::Warning("GEO", 44, "Mismatching availability tags on loops", inst);
logger.Warning("GEO", 44, "Mismatching availability tags on loops", inst);
return nullptr;
}
@@ -190,7 +190,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
std::set<std::string> tags_seen;
for (const auto& t : *w1->tags) {
if (tags_seen.find(t) != tags_seen.end()) {
Logger::Warning("GEO", 45, "Duplicate tag '" + t + "' on loft profile", inst);
logger.Warning("GEO", 45, "Duplicate tag '" + t + "' on loft profile", inst);
return nullptr;
}
tags_seen.insert(t);
@@ -202,7 +202,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
std::set<std::string> tags_seen;
for (const auto& t : *w2->tags) {
if (tags_seen.find(t) != tags_seen.end()) {
Logger::Warning("GEO", 46, "Duplicate tag '" + t + "' on loft profile", inst);
logger.Warning("GEO", 46, "Duplicate tag '" + t + "' on loft profile", inst);
return nullptr;
}
tags_seen.insert(t);
@@ -303,20 +303,20 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_,
for (auto& p1_tags : w1_tags) {
if (!has_intersection(p1_tags, w2_tags_combined)) {
Logger::Warning("GEO", 47, "No matching tags found on loft profiles: " + join_tags(p1_tags) + " not in " + join_tags(w2_tags_combined), inst);
logger.Warning("GEO", 47, "No matching tags found on loft profiles: " + join_tags(p1_tags) + " not in " + join_tags(w2_tags_combined), inst);
return nullptr;
}
}
for (auto& p2_tags : w2_tags) {
if (!has_intersection(p2_tags, w1_tags_combined)) {
Logger::Warning("GEO", 48, "No matching tags found on loft profiles: " + join_tags(p2_tags) + " not in " + join_tags(w1_tags_combined), inst);
logger.Warning("GEO", 48, "No matching tags found on loft profiles: " + join_tags(p2_tags) + " not in " + join_tags(w1_tags_combined), inst);
return nullptr;
}
}
} else {
if (w1->children.size() != w2->children.size()) {
Logger::Warning("GEO", 49, "Mismatching number of edges: " +
logger.Warning("GEO", 49, "Mismatching number of edges: " +
std::to_string(w1->children.size()) + " vs " +
std::to_string(w2->children.size()),
inst);
+1 -1
View File
@@ -21,7 +21,7 @@ namespace ifcopenshell {
}
};
IFC_GEOM_API taxonomy::loft::ptr make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& directrix, std::vector<cross_section>& cross_sections);
IFC_GEOM_API taxonomy::loft::ptr make_loft(const Settings& settings_, const IfcUtil::IfcBaseClass* inst, const taxonomy::function_item::ptr& directrix, std::vector<cross_section>& cross_sections, Logger& logger = Logger::Root());
}
}
@@ -99,7 +99,7 @@ namespace {
}
}
ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool convex) {
ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool convex, Logger& logger) {
shape_ = shape;
convex_tag_ = convex;
@@ -112,7 +112,7 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con
auto b2 = plane.base2();
if (V.squared_length() == 0) {
Logger::Warning("GEO", 62, "Removed face due to self-intersections");
logger.Warning("GEO", 62, "Removed face due to self-intersections");
faces_to_remove.insert(face);
continue;
}
@@ -133,7 +133,7 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con
}
if (!CGAL::Polygon_2<Kernel_>(ps.begin(), ps.end()).is_simple()) {
Logger::Warning("GEO", 63, "Removed face due to self-intersections");
logger.Warning("GEO", 63, "Removed face due to self-intersections");
faces_to_remove.insert(face);
}
}
@@ -184,7 +184,7 @@ void ifcopenshell::geometry::CgalShape::to_nef() const {
}
#endif
void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const {
void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const {
const bool all_triangles = std::all_of(shape_->facets_begin(), shape_->facets_end(), [](auto f) { return f.is_triangle(); });
const bool has_iden_transform = place.is_identity();
@@ -233,7 +233,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
if (!all_triangles) {
if (!shape_to_use->is_valid()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)");
logger.Message(Logger::LOG_ERROR, "GEO", 64, "Invalid Polyhedron_3 in object (before triangulation)");
return;
}
@@ -241,19 +241,19 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
try {
success = CGAL::Polygon_mesh_processing::triangulate_faces(*shape_to_use);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 65, "Triangulation crashed");
logger.Message(Logger::LOG_ERROR, "GEO", 65, "Triangulation crashed");
return;
}
CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_to_use);
if (!success) {
Logger::Message(Logger::LOG_ERROR, "GEO", 66, "Triangulation failed");
logger.Message(Logger::LOG_ERROR, "GEO", 66, "Triangulation failed");
return;
}
if (!shape_to_use->is_valid()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)");
logger.Message(Logger::LOG_ERROR, "GEO", 67, "Invalid Polyhedron_3 in object (after triangulation)");
return;
}
}
@@ -282,7 +282,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
try {
CGAL::Polygon_mesh_processing::compute_face_normals(*shape_to_use, face_normals_map);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed");
logger.Message(Logger::LOG_ERROR, "GEO", 68, "Face normal calculation failed");
return;
}
@@ -791,7 +791,7 @@ bool ifcopenshell::geometry::CgalShape::surface_area_along_direction(double tol,
#ifndef IFOPSH_SIMPLE_KERNEL
void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const {
void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const {
throw std::runtime_error("Not implemented");
}
@@ -185,7 +185,7 @@ namespace ifcopenshell { namespace geometry {
mutable boost::optional<CGAL::Nef_polyhedron_3<Kernel_>> nef_;
#endif
public:
CgalShape(const cgal_shape_t& shape, bool convex = false);
CgalShape(const cgal_shape_t& shape, bool convex = false, Logger& logger = Logger::Root());
#ifndef IFOPSH_SIMPLE_KERNEL
CgalShape(const CGAL::Nef_polyhedron_3<Kernel_>& shape, bool convex = false) {
@@ -209,7 +209,7 @@ namespace ifcopenshell { namespace geometry {
operator const cgal_shape_t& () const { to_poly(); return *shape_; }
const cgal_shape_t& poly() const { to_poly(); return *shape_; }
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
virtual IfcGeom::ConversionResultShape* clone() const {
@@ -285,7 +285,7 @@ namespace ifcopenshell { namespace geometry {
planes_.push_back(shape);
}
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const;
+50 -50
View File
@@ -46,18 +46,19 @@ namespace {
struct PolyhedronBuilder : public CGAL::Modifier_base<CGAL::Polyhedron_3<Kernel_>::HalfedgeDS> {
private:
std::list<cgal_face_t> *face_list;
Logger& logger_;
public:
boost::optional<cgal_shape_t> from_soup;
PolyhedronBuilder(std::list<cgal_face_t> *face_list);
PolyhedronBuilder(std::list<cgal_face_t> *face_list, Logger& logger = Logger::Root());
void operator()(CGAL::Polyhedron_3<Kernel_>::HalfedgeDS &hds);
};
}
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders) {
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders, Logger& logger) {
// Naive creation
CGAL::Polyhedron_3<Kernel_> polyhedron;
PolyhedronBuilder builder(&face_list);
PolyhedronBuilder builder(&face_list, logger);
polyhedron.delegate(builder);
if (builder.from_soup) {
polyhedron = *builder.from_soup;
@@ -76,7 +77,7 @@ CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std
polyhedron.normalize_border();
if (!polyhedron.is_valid(false, 1)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!");
logger.Message(Logger::LOG_ERROR, "GEO", 69, "create_polyhedron: Polyhedron not valid!");
// std::ofstream fresult;
// fresult.open("/Users/ken/Desktop/invalid.off");
// fresult << polyhedron << std::endl;
@@ -90,31 +91,31 @@ CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(std
}
#ifndef IFOPSH_SIMPLE_KERNEL
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_>& nef_polyhedron) {
CGAL::Polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_>& nef_polyhedron, Logger& logger) {
if (nef_polyhedron.is_simple()) {
try {
CGAL::Polyhedron_3<Kernel_> polyhedron;
nef_polyhedron.convert_to_polyhedron(polyhedron);
return polyhedron;
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!");
logger.Message(Logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!");
return CGAL::Polyhedron_3<Kernel_>();
}
} else {
Logger::Message(Logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!");
logger.Message(Logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!");
return CGAL::Polyhedron_3<Kernel_>();
}
}
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(std::list<cgal_face_t> &face_list) {
CGAL::Polyhedron_3<Kernel_> polyhedron = create_polyhedron(face_list);
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(std::list<cgal_face_t> &face_list, Logger& logger) {
CGAL::Polyhedron_3<Kernel_> polyhedron = create_polyhedron(face_list, true, logger);
if (polyhedron.is_closed()) {
try {
if (!CGAL::Polygon_mesh_processing::is_outward_oriented(polyhedron)) {
CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron);
}
} catch (CGAL::Failure_exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 72, e);
logger.Message(Logger::LOG_ERROR, "GEO", 72, e);
}
}
CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron);
@@ -122,12 +123,12 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
try {
nef_polyhedron = CGAL::Nef_polyhedron_3<Kernel_>(polyhedron);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!");
logger.Message(Logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!");
}
return nef_polyhedron;
}
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron) {
CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron, Logger& logger) {
// @todo needed?
polyhedron.normalize_border();
@@ -137,7 +138,7 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
CGAL::Polygon_mesh_processing::reverse_face_orientations(polyhedron);
}
} catch (CGAL::Failure_exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 74, e);
logger.Message(Logger::LOG_ERROR, "GEO", 74, e);
}
}
@@ -148,11 +149,11 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
try {
nef_polyhedron = CGAL::Nef_polyhedron_3<Kernel_>(polyhedron);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!");
logger.Message(Logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!");
}
return nef_polyhedron;
} else {
Logger::Message(Logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!");
logger.Message(Logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!");
return CGAL::Nef_polyhedron_3<Kernel_>();
}
}
@@ -161,13 +162,13 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
for (auto& f : l->children) {
if (f->basis && f->basis->kind() != taxonomy::PLANE) {
Logger::Error("UNS", 3, "CGAL Kernel: Non-planar faces not supported at the moment");
logger_.Error("UNS", 3, "CGAL Kernel: Non-planar faces not supported at the moment");
throw not_supported_error();
}
for (auto& w : f->children) {
for (auto& e : w->children) {
if (e->basis && e->basis->kind() == taxonomy::BSPLINE_CURVE) {
Logger::Error("UNS", 4, "CGAL Kernel: B-spline edge curves not supported at the moment");
logger_.Error("UNS", 4, "CGAL Kernel: B-spline edge curves not supported at the moment");
throw not_supported_error();
}
}
@@ -196,9 +197,9 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
double volume = diag(0) * diag(1) * diag(2);
// @todo volume van be zero also..
double density = num_points / volume;
Logger::Notice("GEO", 77, "Density " + boost::lexical_cast<std::string>(density), l->instance);
logger_.Notice("GEO", 77, "Density " + boost::lexical_cast<std::string>(density), l->instance);
if (density > 5000) {
Logger::Notice("GEO", 78, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
logger_.Notice("GEO", 78, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
CGAL::Point_3<Kernel_> lower(minmax.first(0), minmax.first(1), minmax.first(2));
CGAL::Point_3<Kernel_> upper(minmax.second(0), minmax.second(1), minmax.second(2));
shape = utils::create_cube(lower, upper);
@@ -214,7 +215,7 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
} catch (...) {}
if (!success) {
Logger::Message(Logger::LOG_WARNING, "GEO", 79, "Failed to convert face:", f->instance);
logger_.Message(Logger::LOG_WARNING, "GEO", 79, "Failed to convert face:", f->instance);
continue;
}
@@ -236,7 +237,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
}
if (face->children.size() > 1 && num_outer_bounds > 1 && face->children.size() != num_outer_bounds) {
Logger::Message(Logger::LOG_ERROR, "GEO", 80, "Invalid configuration of boundaries for:", face->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 80, "Invalid configuration of boundaries for:", face->instance);
return false;
}
@@ -249,7 +250,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
cgal_wire_t wire;
if (!convert(bound, wire)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 81, "Failed to process face boundary loop", bound->instance);
return false;
}
@@ -703,7 +704,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
if (d < 1.e-5) {
points.erase(points.end() - 1);
} else {
Logger::Warning("GEO", 82, "Loop not closed", loop->instance);
logger_.Warning("GEO", 82, "Loop not closed", loop->instance);
}
}
@@ -717,7 +718,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
// A loop should consist of at least three vertices
std::size_t original_count = polygon.size();
if (original_count < 3) {
Logger::Warning("GEO", 83, "Not enough edges for:", loop->instance);
logger_.Warning("GEO", 83, "Not enough edges for:", loop->instance);
return false;
}
@@ -728,14 +729,14 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
std::size_t count = polygon.size();
if (original_count - count != 0) {
std::stringstream ss; ss << (original_count - count) << " edges removed for:";
Logger::Warning("GEO", 84, ss.str(), loop->instance);
logger_.Warning("GEO", 84, ss.str(), loop->instance);
}
{
std::set<cgal_point_t> visited_points;
for (auto& p : polygon) {
if (visited_points.find(p) != visited_points.end()) {
Logger::Error("GEO", 85, "Skipping self-intersecting loop", loop->instance);
logger_.Error("GEO", 85, "Skipping self-intersecting loop", loop->instance);
// @todo signal somehow that occt kernel might be able to solve this
// @todo implement cycle detection using Arrangement_2, but that only works in exact kernel
return false;
@@ -757,7 +758,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
}
if (do_segments_intersect(segments)) {
Logger::Message(Logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance);
logger_.Message(Logger::LOG_WARNING, "GEO", 86, "Skipping self-intersecting loop", loop->instance);
return false;
}
@@ -785,7 +786,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
*/
if (count < 3) {
Logger::Message(Logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 87, "Not enough edges for:", loop->instance);
return false;
}
@@ -819,7 +820,7 @@ bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResult
bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResults& results) {
if (solid->children.size() > 1) {
Logger::Error("UNS", 5, "Multiple shells in solid not supported at the moment");
logger_.Error("UNS", 5, "Multiple shells in solid not supported at the moment");
return false;
}
cgal_shape_t shape;
@@ -964,7 +965,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
try {
a.convert_to_polyhedron(a_poly);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity);
logger_.Message(Logger::LOG_ERROR, "GEO", 88, "Could not convert from Nef:", entity);
return false;
}
@@ -1189,7 +1190,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir
bool CgalKernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) {
const double& height = extrusion->depth;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
return false;
}
@@ -1325,13 +1326,13 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
cgal_shape_t shape = shape_const;
if (!shape.is_valid()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference);
logger_.Message(Logger::LOG_ERROR, "GEO", 90, "Conversion to Nef will fail. Invalid geometry:", log_reference);
return false;
}
if (!shape.is_closed()) {
// TODO: There can be substractions to remove parts of non-volumetric objects. Maybe iterate over all faces of an entity and put them in a Nef_polyhedron_3 through Boolean union? Highly inefficient but maybe desirable...
Logger::Message(Logger::LOG_ERROR, "UNS", 6, "Subtraction of openings not supported for non-closed geometry:", log_reference);
logger_.Message(Logger::LOG_ERROR, "UNS", 6, "Subtraction of openings not supported for non-closed geometry:", log_reference);
return false;
}
@@ -1340,18 +1341,18 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
try {
success = CGAL::Polygon_mesh_processing::triangulate_faces(shape);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 91, e);
Logger::Message(Logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference);
logger_.Notice("GEO", 91, e);
logger_.Message(Logger::LOG_ERROR, "GEO", 92, "Triangulation of geometry crashed:", log_reference);
return false;
}
if (!success) {
Logger::Message(Logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference);
logger_.Message(Logger::LOG_ERROR, "GEO", 93, "Triangulation of geometry failed:", log_reference);
return false;
}
if (CGAL::Polygon_mesh_processing::does_self_intersect(shape)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 94, "Conversion to Nef will fail. Self-intersecting geometry:", log_reference);
logger_.Message(Logger::LOG_ERROR, "GEO", 94, "Conversion to Nef will fail. Self-intersecting geometry:", log_reference);
return false;
}
@@ -1423,8 +1424,8 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
try {
result = CGAL::Nef_polyhedron_3<Kernel_>(shape);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 95, e);
Logger::Message(Logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference);
logger_.Notice("GEO", 95, e);
logger_.Message(Logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference);
return false;
}
@@ -1496,8 +1497,8 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
// @todo don't dilate in 3 dimensions but only in the XY plane, orthogonal to wall axis.
result = CGAL::minkowski_sum_3(result, precision_cube_);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 97, e);
Logger::Message(Logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference);
logger_.Notice("GEO", 97, e);
logger_.Message(Logger::LOG_ERROR, "GEO", 98, "Could not dilate boolean operand", log_reference);
return false;
}
}
@@ -1522,8 +1523,8 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
cgal_shape_t convert_back;
result.convert_to_polyhedron(convert_back);
} catch (CGAL::Failure_exception& e) {
Logger::Notice("GEO", 99, e);
Logger::Message(Logger::LOG_WARNING, "GEO", 100, "Final conversion will likely fail. Could not convert geometry from Nef:", log_reference);
logger_.Notice("GEO", 99, e);
logger_.Message(Logger::LOG_WARNING, "GEO", 100, "Final conversion will likely fail. Could not convert geometry from Nef:", log_reference);
}
return true;
@@ -1845,7 +1846,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
// even-odd fill rule will result in incorrect results.
// See for example the Duplex model roof.
Logger::Notice("GEO", 101, "Holes are not disjoint");
logger_.Notice("GEO", 101, "Holes are not disjoint");
CGAL::Polygon_set_2<Kernel_> result;
auto it = loops.begin();
@@ -1898,7 +1899,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
);
});
Logger::Notice("GEO", 102, "Processed boolean operation as 2d arrangement");
logger_.Notice("GEO", 102, "Processed boolean operation as 2d arrangement");
return true;
@@ -1984,7 +1985,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
ps.push_back({ p.x(), p.y() });
}
if (!ps.is_simple()) {
Logger::Warning("GEO", 103, "Polygonal boundary not simple", face->children[0]->instance);
logger_.Warning("GEO", 103, "Polygonal boundary not simple", face->children[0]->instance);
continue;
}
@@ -2130,7 +2131,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
try {
a.convert_to_polyhedron(a_poly);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance);
logger_.Message(Logger::LOG_ERROR, "GEO", 104, "Could not convert geometry with openings from Nef:", br->instance);
return false;
}
@@ -2145,8 +2146,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
#endif
}
PolyhedronBuilder::PolyhedronBuilder(std::list<cgal_face_t>* face_list) {
this->face_list = face_list;
PolyhedronBuilder::PolyhedronBuilder(std::list<cgal_face_t>* face_list, Logger& logger) : face_list(face_list), logger_(logger) {
}
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
@@ -2222,7 +2222,7 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3<Kernel_>::HalfedgeDS &hds)
// For now let's just skip over the triangle. We can also use
// the Aff_transformation_3 stored in place to convert the 2d
// coords back to 3d.
Logger::Warning("GEO", 105, "Ignoring triangulated facet with novel point likely due to self-intersections");
logger_.Warning("GEO", 105, "Ignoring triangulated facet with novel point likely due to self-intersections");
facet_vertices.erase(facet_vertices.end() - 1);
break;
}
+10 -8
View File
@@ -20,6 +20,8 @@
#ifndef CGAL_KERNEL_H
#define CGAL_KERNEL_H
#include "../../../ifcparse/IfcLogger.h"
/*
#ifdef NO_CACHE
@@ -58,12 +60,12 @@ namespace ifcopenshell {
namespace utils {
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_cube(double d);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_cube(const Kernel_::Point_3& lower, const Kernel_::Point_3& upper);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders = false);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders = false, Logger& logger = Logger::Root());
#ifndef IFOPSH_SIMPLE_KERNEL
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_> &nef_polyhedron);
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(std::list<cgal_face_t> &face_list);
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron);
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_> &nef_polyhedron, Logger& logger = Logger::Root());
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(std::list<cgal_face_t> &face_list, Logger& logger = Logger::Root());
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron, Logger& logger = Logger::Root());
#endif
}
@@ -91,12 +93,12 @@ namespace ifcopenshell {
#endif
public:
CgalKernel(const Settings& settings)
: AbstractKernel("cgal", settings)
CgalKernel(const Settings& settings, Logger& logger = Logger::Root())
: AbstractKernel("cgal", settings, logger)
{}
virtual AbstractKernel* clone() const {
return new CgalKernel(settings());
return new CgalKernel(settings(), logger());
}
virtual bool supports_boolean_operations() const {
@@ -133,4 +135,4 @@ namespace ifcopenshell {
}
}
}
#endif
#endif
@@ -47,7 +47,7 @@ namespace {
}
}
void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const {
void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger) const {
// @todo remove duplication with OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// above can be static?
@@ -87,7 +87,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
try {
BRepMesh_IncrementalMesh(shape_, settings.get<settings::MesherLinearDeflection>().get(), false, settings.get<settings::MesherAngularDeflection>().get());
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 183, "Failed to triangulate shape");
return;
}
}
@@ -113,7 +113,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
Handle_Poly_Triangulation tri = BRep_Tool::Triangulation(face, loc);
if (tri.IsNull()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face");
} else {
// Keep track of the number of times an edge is used
// Manifold edges (i.e. edges used twice) are deemed invisible
@@ -174,7 +174,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
else triangles(i).Get(n1, n2, n3);
if (dict[n1] == dict[n2] || dict[n2] == dict[n3] || dict[n3] == dict[n1]) {
Logger::Warning("GEO", 185, "Mesher generated a degenerate triangle, ignoring");
logger.Warning("GEO", 185, "Mesher generated a degenerate triangle, ignoring");
continue;
}
@@ -619,7 +619,7 @@ namespace {
try {
BRepMesh_IncrementalMesh(s, tol);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 186, "Failed to triangulate shape");
return;
}
meshed = true;
@@ -53,7 +53,7 @@ namespace ifcopenshell {
const TopoDS_Shape& shape() const { return shape_; }
operator const TopoDS_Shape& () { return shape_; }
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, Logger& logger = Logger::Root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
virtual IfcGeom::ConversionResultShape* clone() const {
@@ -118,7 +118,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
auto it3_shape = std::static_pointer_cast<OpenCascadeShape>(it3->Shape())->shape();
if (it3_shape.IsNull()) {
Logger::Error("GEO", 187, "Null operand");
Logger::Root().Error("GEO", 187, "Null operand");
continue;
}
@@ -143,7 +143,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
IfcGeom::util::create_solid_from_faces(list, entity_part, settings_.get<settings::Precision>().get(), true);
is_manifold = util::is_manifold(entity_part);
if (is_manifold) {
Logger::Warning("GEO", 188, "Successfully sewed non-manifold first operand");
Logger::Root().Warning("GEO", 188, "Successfully sewed non-manifold first operand");
}
}
@@ -161,17 +161,17 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(IfcGeom::util::count(entity_part, TopAbs_FACE));
} else {
is_manifold = util::is_manifold(entity_part_2);
Logger::Warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold")));
Logger::Root().Warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold")));
entity_part = entity_part_2;
}
} catch (const Standard_Failure& e) {
failure.emplace(e.GetMessageString());
}
if (failure) {
Logger::Warning("GEO", 190, "MakeVolume failed: " + *failure, entity);
Logger::Root().Warning("GEO", 190, "MakeVolume failed: " + *failure, entity);
}
} else {
Logger::Warning("GEO", 191, "Non-manifold first operand, use --make-volume to try and make manifold");
Logger::Root().Warning("GEO", 191, "Non-manifold first operand, use --make-volume to try and make manifold");
}
}
@@ -214,7 +214,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
if (util::boolean_operation(bst, result, opening_list, BOPAlgo_CUT, intermediate_result)) {
result = intermediate_result;
} else {
Logger::Message(Logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast<std::string>(std::distance(jt, it)) + " openings", entity);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 192, "Opening subtraction failed for " + boost::lexical_cast<std::string>(std::distance(jt, it)) + " openings", entity);
}
jt = it;
@@ -235,7 +235,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
// where we keep the first operand as is (a compound of faces probably,
// unless --orient-shells was activated in which case we're already lost).
if (!is_manifold) {
Logger::Warning("GEO", 193, "Retrying boolean operation on individual faces");
Logger::Root().Warning("GEO", 193, "Retrying boolean operation on individual faces");
}
continue;
}
@@ -112,14 +112,14 @@ private:
double precision_;
public:
OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings)
: AbstractKernel("opencascade", settings)
OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings, Logger& logger = Logger::Root())
: AbstractKernel("opencascade", settings, logger)
, faceset_helper_(nullptr)
, precision_(settings.get<ifcopenshell::geometry::settings::Precision>().get())
{}
virtual AbstractKernel* clone() const {
return new OpenCascadeKernel(settings());
return new OpenCascadeKernel(settings(), logger());
}
virtual bool supports_boolean_operations() const { return true; }
+13 -13
View File
@@ -711,12 +711,12 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
valid_shell &= util::count(shape, TopAbs_SHELL) > 0;
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 106, e.GetMessageString());
Logger::Root().Error("GEO", 106, e.GetMessageString());
} else {
Logger::Error("GEO", 107, "Unknown error sewing shell");
Logger::Root().Error("GEO", 107, "Unknown error sewing shell");
}
} catch (...) {
Logger::Error("GEO", 108, "Unknown error sewing shell");
Logger::Root().Error("GEO", 108, "Unknown error sewing shell");
}
if (valid_shell) {
@@ -744,22 +744,22 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
}
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 109, e.GetMessageString());
Logger::Root().Error("GEO", 109, e.GetMessageString());
} else {
Logger::Error("GEO", 110, "Unknown error classifying solid");
Logger::Root().Error("GEO", 110, "Unknown error classifying solid");
}
} catch (...) {
Logger::Error("GEO", 111, "Unknown error classifying solid");
Logger::Root().Error("GEO", 111, "Unknown error classifying solid");
}
}
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 112, e.GetMessageString());
Logger::Root().Error("GEO", 112, e.GetMessageString());
} else {
Logger::Error("GEO", 113, "Unknown error creating solid");
Logger::Root().Error("GEO", 113, "Unknown error creating solid");
}
} catch (...) {
Logger::Error("GEO", 114, "Unknown error creating solid");
Logger::Root().Error("GEO", 114, "Unknown error creating solid");
}
if (complete_shape.IsNull()) {
@@ -771,7 +771,7 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
B.MakeCompound(C);
B.Add(C, complete_shape);
complete_shape = C;
Logger::Warning("GEO", 115, "Multiple components in IfcConnectedFaceSet");
Logger::Root().Warning("GEO", 115, "Multiple components in IfcConnectedFaceSet");
}
B.Add(complete_shape, result_shape);
}
@@ -786,7 +786,7 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
B.MakeCompound(C);
B.Add(C, complete_shape);
complete_shape = C;
Logger::Warning("GEO", 116, "Loose faces in IfcConnectedFaceSet");
Logger::Root().Warning("GEO", 116, "Loose faces in IfcConnectedFaceSet");
}
B.Add(complete_shape, loose_faces.Current());
}
@@ -794,7 +794,7 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis
shape = complete_shape;
} else {
Logger::Error("GEO", 117, "Failed to sew faceset");
Logger::Root().Error("GEO", 117, "Failed to sew faceset");
}
return valid_shell;
@@ -898,7 +898,7 @@ bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) {
dump(s);
Logger::Warning("GEO", 118, str.str());
Logger::Root().Warning("GEO", 118, str.str());
return false;
}
@@ -118,14 +118,14 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
const double first_operand_volume = util::shape_volume(a);
if (first_operand_volume <= ALMOST_ZERO) {
Logger::Message(Logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 119, "Empty solid for:", c->instance);
}
} else {
for (auto& r : cr) {
auto S = std::static_pointer_cast<OpenCascadeShape>(r.Shape())->shape();
if (S.IsNull()) {
Logger::Error("GEO", 120, "Null operand");
Logger::Root().Error("GEO", 120, "Null operand");
continue;
}
gp_GTrsf trsf;
@@ -140,7 +140,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
// #2665 we also set a precision-independent threshold, because in the boolean op routine
// the working fuzziness might still be increased.
if (d < tol * 20. || d < 0.00002) {
Logger::Message(Logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 121, "Halfspace subtraction yields unchanged volume:", c->instance);
continue;
} else {
S = result;
@@ -419,7 +419,7 @@ int IfcGeom::util::eliminate_narrow_operands(double prec, const TopTools_ListOfS
bool is_narrow = min_dimension < prec;
Logger::Notice("GEO", 122, "Min OBB dimension of operand = " + std::to_string(min_dimension));
Logger::Root().Notice("GEO", 122, "Min OBB dimension of operand = " + std::to_string(min_dimension));
if (!is_narrow) {
c.Append(it.Value());
@@ -704,7 +704,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
if (u11 < U1 && U1 < u12 && u21 < U2 && U2 < u22) {
// Edge curves belonging to different operands intersect, don't process
// using builder.
Logger::Notice("GEO", 123, "Intersecting boundaries");
Logger::Root().Notice("GEO", 123, "Intersecting boundaries");
return false;
}
}
@@ -751,7 +751,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
// any effect and marked as redundant. Feeding it to the builder algo
// will likely cause problems.
redundant[std::distance(wires.begin(), it)] = true;
Logger::Notice("GEO", 124, "Subtraction operand outside of outer bound");
Logger::Root().Notice("GEO", 124, "Subtraction operand outside of outer bound");
}
}
@@ -791,7 +791,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
if (wire_clss[wire_index].Perform(p2d) == TopAbs_IN) {
// A wire is contained within another operand
redundant[other_index] = true;
Logger::Notice("GEO", 125, "Subtraction operand contained in other");
Logger::Root().Notice("GEO", 125, "Subtraction operand contained in other");
}
}
}
@@ -849,7 +849,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
std::stringstream ss;
ss << "bool-" << std::this_thread::get_id() << "-" << (operation_counter_++);
debug_identifier = ss.str();
Logger::Notice("GEO", 126, "Boolean debug identifier: " + debug_identifier);
Logger::Root().Notice("GEO", 126, "Boolean debug identifier: " + debug_identifier);
}
if (fuzziness < 0.) {
@@ -885,7 +885,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
a = unify(a_input, fuzziness * 1000.);
Logger::Message(
Logger::Root().Message(
Logger::LOG_DEBUG, "GEO", 127,
"Simplified operand A from "s +
std::to_string(count(a_input, TopAbs_FACE)) +
@@ -897,7 +897,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
TopTools_ListIteratorOfListOfShape it(b_input);
for (; it.More(); it.Next()) {
b.Append(unify(it.Value(), fuzziness));
Logger::Message(
Logger::Root().Message(
Logger::LOG_DEBUG, "GEO", 128,
"Simplified operand B from "s +
std::to_string(count(it.Value(), TopAbs_FACE)) +
@@ -925,7 +925,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
auto N = bounding_box_overlap(fuzziness, a, b, b_tmp);
if (N) {
Logger::Notice("GEO", 129, "Eliminated " + std::to_string(N) + " disjoint operands");
Logger::Root().Notice("GEO", 129, "Eliminated " + std::to_string(N) + " disjoint operands");
std::swap(b, b_tmp);
}
}
@@ -936,7 +936,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
b_tmp.Clear();
auto N = eliminate_touching_operands(fuzziness, a, b, b_tmp);
if (N) {
Logger::Notice("GEO", 130, "Eliminated " + std::to_string(N) + " touching operands");
Logger::Root().Notice("GEO", 130, "Eliminated " + std::to_string(N) + " touching operands");
std::swap(b, b_tmp);
}
}
@@ -947,7 +947,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
b_tmp.Clear();
auto N = eliminate_narrow_operands(fuzziness, b, b_tmp);
if (N) {
Logger::Notice("GEO", 131, "Eliminated " + std::to_string(N) + " narrow operands");
Logger::Root().Notice("GEO", 131, "Eliminated " + std::to_string(N) + " narrow operands");
std::swap(b, b_tmp);
}
}
@@ -961,21 +961,21 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (b.Extent() == 0) {
Logger::Warning("GEO", 132, "No other operands remaining, using first operand");
Logger::Root().Warning("GEO", 132, "No other operands remaining, using first operand");
result = a;
return true;
}
if (!is_2d && Logger::LOG_NOTICE >= Logger::Verbosity()) {
if (!is_2d && Logger::LOG_NOTICE >= Logger::Root().Verbosity()) {
PERF("preliminary manifoldness check");
if (!a.IsNull()) {
Logger::Notice("GEO", 133, "Operand A is " + (is_manifold(a) ? ""s : "non-"s) + "manifold");
Logger::Root().Notice("GEO", 133, "Operand A is " + (is_manifold(a) ? ""s : "non-"s) + "manifold");
}
TopTools_ListIteratorOfListOfShape it(b);
for (int i = 0; it.More(); it.Next(), ++i) {
Logger::Notice("GEO", 134, "Operand B " + std::to_string(i) + " is " + (is_manifold(it.Value()) ? ""s : "non-"s) + "manifold");
Logger::Root().Notice("GEO", 134, "Operand B " + std::to_string(i) + " is " + (is_manifold(it.Value()) ? ""s : "non-"s) + "manifold");
}
}
@@ -1015,7 +1015,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
const double fuzz = (std::min)(min_length_orig / 3., fuzziness);
Logger::Notice("GEO", 135, "Used fuzziness: " + std::to_string(fuzz));
Logger::Root().Notice("GEO", 135, "Used fuzziness: " + std::to_string(fuzz));
const double new_fuzziness = fuzziness * 10.;
const bool allow_retry = new_fuzziness - 1e-15 <= settings.precision * 10000. && new_fuzziness < min_length_orig;
@@ -1049,7 +1049,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (is_extrusion_a) {
Logger::Notice("GEO", 136, "Operand A 1/1 is an extrusion");
Logger::Root().Notice("GEO", 136, "Operand A 1/1 is an extrusion");
TopTools_ListIteratorOfListOfShape it(b);
for (int nb = 1; it.More(); it.Next(), ++nb) {
@@ -1065,10 +1065,10 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (is_extrusion_b) {
Logger::Notice("GEO", 137, "Operand B " + std::to_string(nb) + "/" + std::to_string(b.Extent()) + " is an extrusion");
Logger::Root().Notice("GEO", 137, "Operand B " + std::to_string(nb) + "/" + std::to_string(b.Extent()) + " is an extrusion");
if (b_interval.first < a_interval.first + (fuzz * 100.) && b_interval.second > a_interval.second - (fuzz * 100.)) {
Logger::Notice("GEO", 138, "Operand B creates a through hole");
Logger::Root().Notice("GEO", 138, "Operand B creates a through hole");
// Align b with a operand
gp_Trsf trsf;
@@ -1108,23 +1108,23 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
BRepPrimAPI_MakePrism mp(face_result, gp_Vec(gp::DY()) * (a_interval.second - a_interval.first));
if (mp.IsDone()) {
if (b_remainder_3d.Extent()) {
Logger::Notice("GEO", 139, std::to_string(b_remainder_3d.Extent()) + " operands remaining to process in 3D");
Logger::Root().Notice("GEO", 139, std::to_string(b_remainder_3d.Extent()) + " operands remaining to process in 3D");
b = b_remainder_3d;
s1s.Clear();
s1s.Append(mp.Shape());
} else {
Logger::Notice("GEO", 140, "Processed fully in 2D");
Logger::Root().Notice("GEO", 140, "Processed fully in 2D");
result = mp.Shape();
return true;
}
} else {
Logger::Notice("GEO", 141, "Failed to extrude 2D boolean result. Retrying in 3D.");
Logger::Root().Notice("GEO", 141, "Failed to extrude 2D boolean result. Retrying in 3D.");
}
} else {
Logger::Notice("GEO", 142, "Failed to perform 2D boolean operation. Retrying in 3D.");
Logger::Root().Notice("GEO", 142, "Failed to perform 2D boolean operation. Retrying in 3D.");
}
} else {
Logger::Notice("GEO", 143, "No second operands can be processed as 2D inner bounds. Retrying in 3D.");
Logger::Root().Notice("GEO", 143, "No second operands can be processed as 2D inner bounds. Retrying in 3D.");
}
}
}
@@ -1146,7 +1146,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
if (builder->IsDone()) {
if (false && builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertAcquiredSelfIntersection))) {
Logger::Notice("GEO", 144, "Builder reports self-intersection in output");
Logger::Root().Notice("GEO", 144, "Builder reports self-intersection in output");
success = false;
/*
@@ -1160,7 +1160,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
*/
} else if(builder->DSFiller()->HasWarning(STANDARD_TYPE(BOPAlgo_AlertBadPositioning)) && !TopoDS_Iterator(*builder).More()) {
Logger::Notice("GEO", 145, "Builder reports bad positioning and result is empty");
Logger::Root().Notice("GEO", 145, "Builder reports bad positioning and result is empty");
success = false;
} else {
TopoDS_Shape r = *builder;
@@ -1174,7 +1174,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
fix.Perform();
r = fix.Shape();
} catch (...) {
Logger::Error("GEO", 146, "Shape healing failed on boolean result");
Logger::Root().Error("GEO", 146, "Shape healing failed on boolean result");
}
}
@@ -1185,7 +1185,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
success = ana.IsValid() != 0;
if (!success) {
Logger::Notice("GEO", 147, "Boolean operation yields invalid result");
Logger::Root().Notice("GEO", 147, "Boolean operation yields invalid result");
std::stringstream str;
bool any_emitted = false;
@@ -1215,7 +1215,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
dump(r);
Logger::Notice("GEO", 148, str.str());
Logger::Root().Notice("GEO", 148, str.str());
}
}
@@ -1335,7 +1335,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
if (op == BOPAlgo_CUT && has_open_shells && all_faces_included_in_result && result_n_faces > first_op_n_faces) {
success = false;
Logger::Notice("GEO", 149, "Boolean result discarded because subtractions results in only the addition of faces");
Logger::Root().Notice("GEO", 149, "Boolean result discarded because subtractions results in only the addition of faces");
} else {
// when there are edges or vertex-edge distances close to the used fuzziness, the
// output is not trusted and the operation is attempted with a higher fuzziness.
@@ -1381,7 +1381,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
static const char* const reason_strings[] = { "edge length", "vertex-edge", "face-face" };
std::stringstream str;
str << "Boolean operation result failing " << reason_strings[reason] << " interference check, with fuzziness " << fuzziness << " with length " << v;
Logger::Notice("GEO", 150, str.str());
Logger::Root().Notice("GEO", 150, str.str());
}
}
@@ -1390,7 +1390,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
}
} else {
Logger::Notice("GEO", 151, "Boolean operation yields non-manifold result");
Logger::Root().Notice("GEO", 151, "Boolean operation yields non-manifold result");
}
}
}
@@ -1400,7 +1400,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
#if OCC_VERSION_HEX >= 0x70200
if (builder->HasError(STANDARD_TYPE(BOPAlgo_AlertBOPNotAllowed))) {
Logger::Error("GEO", 152, "Invalid operands. Using first operand");
Logger::Root().Error("GEO", 152, "Invalid operands. Using first operand");
result = a;
success = true;
}
@@ -1413,14 +1413,14 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
#endif
std::string str_str = str.str();
if (str_str.size()) {
Logger::Notice("GEO", 153, str_str);
Logger::Root().Notice("GEO", 153, str_str);
}
}
if (!success) {
if (allow_retry) {
return boolean_operation(settings, a, b, op, result, new_fuzziness);
} else {
Logger::Notice("GEO", 154, "No longer attempting boolean operation with higher fuzziness");
Logger::Root().Notice("GEO", 154, "No longer attempting boolean operation with higher fuzziness");
}
}
return success && !result.IsNull();
@@ -10,7 +10,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS
const double& height = extrusion->depth;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Error("GEO", 155, "Non-positive extrusion height encountered for:", extrusion->instance);
Logger::Root().Error("GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance);
return false;
}
+14 -14
View File
@@ -169,7 +169,7 @@ namespace {
} else if (crv_or_wire.which() == 2) {
// @todo
const double precision_ = 1.e-5;
Logger::Warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance);
Logger::Root().Warning("GEO", 156, "Approximating BasisCurve due to possible discontinuities", i->instance);
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
#if OCC_VERSION_HEX < 0x70600
BRepAdaptor_CompCurve cc(w, true);
@@ -289,12 +289,12 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
// the face will still be processed as long as there are no holes. A compound of faces
// is returned in that case.
if (num_bounds > 1 && num_outer_bounds > 1 && num_bounds != num_outer_bounds) {
Logger::Message(Logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 157, "Invalid configuration of boundaries for:", face->instance);
return false;
}
if (num_outer_bounds > 1) {
Logger::Message(Logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 158, "Multiple outer boundaries for:", face->instance);
fd.all_outer() = true;
}
@@ -315,11 +315,11 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
TopoDS_Wire wire;
if (faceset_helper_ && bound->is_polyhedron()) {
if (!faceset_helper_->wire(bound, wire)) {
Logger::Message(Logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 159, "Face boundary loop not included", bound->instance);
continue;
}
} else if (!convert(bound, wire)) {
Logger::Message(Logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 160, "Failed to process face boundary loop", bound->instance);
return false;
}
@@ -336,7 +336,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
};
TopTools_ListOfShape results;
if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) {
Logger::Warning("GEO", 161, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 161, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
util::select_largest(results, wire);
}
@@ -347,7 +347,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
}
if (fd.wires().empty()) {
Logger::Warning("GEO", 162, "Face with no boundaries", face->instance);
Logger::Root().Warning("GEO", 162, "Face with no boundaries", face->instance);
return false;
}
@@ -404,7 +404,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
if (fd.surface().IsNull()) {
// The set of wires is triangulated in case no surface can be found
Logger::Message(Logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 163, "Triangulating face boundaries for face", face->instance);
if (fd.all_outer()) {
for (const auto& w : fd.wires()) {
@@ -457,7 +457,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
kt.Value().Original().ToUTF8CString(c);
std::string message = c;
delete[] c;
Logger::Warning("GEO", 164, message, face->instance);
Logger::Root().Warning("GEO", 164, message, face->instance);
}
}
@@ -469,17 +469,17 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
if (it.Value().ShapeType() == TopAbs_FACE) {
face_list.Append(it.Value());
} else {
Logger::Error("UNS", 7, "Unsupported output from face healing");
Logger::Root().Error("UNS", 7, "Unsupported output from face healing");
}
}
} else {
Logger::Error("UNS", 8, "Unsupported output from face healing");
Logger::Root().Error("UNS", 8, "Unsupported output from face healing");
}
} else {
face_list.Append(f);
}
} else {
Logger::Error("GEO", 165, "Internal error in face creation");
Logger::Root().Error("GEO", 165, "Internal error in face creation");
return false;
}
} else {
@@ -520,14 +520,14 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
delete[] c;
#if OCC_VERSION_MAJOR==7 && OCC_VERSION_MINOR >= 7
if (!reversed_surface && !fd.surface().IsNull() && fd.surface()->IsUPeriodic() && message == "Unknown message invoked with the keyword FixAdvFace.FixOrientation.MSG0") {
Logger::Notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface");
Logger::Root().Notice("GEO", 166, "Detected reversed wire, reattempting with reversed basis surface");
TopoDS_Face reversed_result;
convert(face, reversed_result, true);
result = reversed_result;
return true;
} else
#endif
Logger::Warning("GEO", 167, message, face->instance);
Logger::Root().Warning("GEO", 167, message, face->instance);
}
}
}
@@ -149,7 +149,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
auto num_retained = std::count(retained.begin(), retained.end(), true);
if (unique.size() != num_retained) {
Logger::Notice("GEO", 168, "Collapsed vertices from " + std::to_string(pnts.size()) + " (" + std::to_string(unique.size()) + " unique) to " + std::to_string(num_retained));
Logger::Root().Notice("GEO", 168, "Collapsed vertices from " + std::to_string(pnts.size()) + " (" + std::to_string(unique.size()) + " unique) to " + std::to_string(num_retained));
}
typedef std::array<int, 2> edge_t;
@@ -205,7 +205,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
}
if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.get_value_or(false))) {
Logger::Warning("GEO", 169, boost::lexical_cast<std::string>(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast<std::string>(loops_removed) + " degenerate loops eliminated and " + boost::lexical_cast<std::string>(non_manifold) + " non-manifold edges");
Logger::Root().Warning("GEO", 169, boost::lexical_cast<std::string>(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast<std::string>(loops_removed) + " degenerate loops eliminated and " + boost::lexical_cast<std::string>(non_manifold) + " non-manifold edges");
}
}
@@ -276,7 +276,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geome
!kernel_->settings().get<ifcopenshell::geometry::settings::NoWireIntersectionTolerance>().get(), 0.,
kernel_->settings().get<ifcopenshell::geometry::settings::Precision>().get()}))
{
Logger::Warning("GEO", 170, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 170, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
non_manifold_ = true;
wires = results;
} else {
+6 -6
View File
@@ -129,7 +129,7 @@ namespace {
}
}
Logger::Error("GEO", 171, "Unable to map layer geometry to material index");
Logger::Root().Error("GEO", 171, "Unable to map layer geometry to material index");
return false;
}
}
@@ -234,7 +234,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
if (s.ShapeType() == TopAbs_SHELL) {
shells.Append(TopoDS::Shell(s));
} else {
Logger::Error("GEO", 172, "Expected shell type in layerset processing");
Logger::Root().Error("GEO", 172, "Expected shell type in layerset processing");
return false;
}
}
@@ -433,12 +433,12 @@ bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS
}
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 173, e.GetMessageString());
Logger::Root().Error("GEO", 173, e.GetMessageString());
} else {
Logger::Error("GEO", 174, "Unknown error performing fixes");
Logger::Root().Error("GEO", 174, "Unknown error performing fixes");
}
} catch (...) {
Logger::Error("GEO", 175, "Unknown error performing fixes");
Logger::Root().Error("GEO", 175, "Unknown error performing fixes");
}
BRepCheck_Analyzer analyser(shape);
bool is_valid = analyser.IsValid() != 0;
@@ -448,7 +448,7 @@ bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS
}
if (is_null[0] || is_null[1]) {
Logger::Message(Logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing");
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 176, "Null result obtained from layerset slicing");
if (is_null[0] && is_null[1]) {
return false;
}
+3 -3
View File
@@ -83,7 +83,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
if (non_polygonal) {
if (loft->children.size() < 2) {
Logger::Error("GEO", 177, "Not enough sections to loft");
Logger::Root().Error("GEO", 177, "Not enough sections to loft");
return false;
}
@@ -124,7 +124,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
auto first_wire_count = sections.front().size();
for (auto& section : sections) {
if (section.size() != first_wire_count) {
Logger::Error("GEO", 178, "Inconsistent number of wires in sections");
Logger::Root().Error("GEO", 178, "Inconsistent number of wires in sections");
return false;
}
}
@@ -261,7 +261,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
*/
if (shps.size() < 2) {
Logger::Error("GEO", 179, "Not enough sections to loft");
Logger::Root().Error("GEO", 179, "Not enough sections to loft");
return false;
}
+3 -3
View File
@@ -129,7 +129,7 @@ namespace {
} else {
// @todo
const double precision_ = 1.e-5;
Logger::Warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance);
Logger::Root().Warning("GEO", 180, "Approximating BasisCurve due to possible discontinuities", e->instance);
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
#if OCC_VERSION_HEX < 0x70600
BRepAdaptor_CompCurve cc(w, true);
@@ -266,7 +266,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
}
if (converted_segments.Extent() == 0) {
Logger::Message(Logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance);
Logger::Root().Message(Logger::LOG_ERROR, "GEO", 181, "No segment successfully converted:", loop->instance);
return false;
}
@@ -331,7 +331,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
if (ang < 0.0314) {
edges_to_tesselate.Add(crv1->DynamicType() == STANDARD_TYPE(Geom_Circle) ? edges.First() : edges.Last());
Logger::Notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation");
Logger::Root().Notice("GEO", 182, "Sharp circular corner detecting, substituting with linear approximation");
}
}
}
+7 -7
View File
@@ -46,19 +46,19 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap
try {
success = convert(face, occ_face);
} catch (const std::exception& e) {
Logger::Error("GEO", 194, e);
Logger::Root().Error("GEO", 194, e);
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 195, e.GetMessageString());
Logger::Root().Error("GEO", 195, e.GetMessageString());
} else {
Logger::Error("GEO", 196, "Unknown error creating face");
Logger::Root().Error("GEO", 196, "Unknown error creating face");
}
} catch (...) {
Logger::Error("GEO", 197, "Unknown error creating face");
Logger::Root().Error("GEO", 197, "Unknown error creating face");
}
if (!success) {
Logger::Message(Logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 198, "Failed to convert face:", face->instance);
continue;
}
@@ -71,7 +71,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap
if (face_area(triangle) > min_face_area) {
face_list.Append(triangle);
} else {
Logger::Message(Logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 199, "Degenerate face:", face->instance);
}
}
}
@@ -79,7 +79,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap
if (face_area(occ_face) > min_face_area) {
face_list.Append(occ_face);
} else {
Logger::Message(Logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 200, "Degenerate face:", face->instance);
}
}
}
+1 -1
View File
@@ -92,7 +92,7 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape&
throw std::runtime_error("Unexpected configuration of subshapes");
}
} else {
Logger::Warning("GEO", 201, "Ignored shell", s->instance);
Logger::Root().Warning("GEO", 201, "Ignored shell", s->instance);
}
}
if (!S.IsNull()) {
@@ -130,7 +130,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
auto w = convert_curve(scs->curve);
if (w.which() != 2) {
Logger::Error("UNS", 9, "Unsupported directrix");
Logger::Root().Error("UNS", 9, "Unsupported directrix");
return false;
}
TopoDS_Shape face_;
@@ -178,7 +178,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) {
if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) {
directrix_on_plane = false;
Logger::Message(Logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance);
Logger::Root().Message(Logger::LOG_WARNING, "GEO", 202, "The Directrix does not lie on the ReferenceSurface", scs->instance);
break;
}
}
@@ -97,7 +97,7 @@ bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) {
Handle(Geom_Curve) crv = BRep_Tool::Curve(edge, u0, u1);
crv->D1(u0, directrix_origin, directrix_tangent);
} else {
Logger::Error("GEO", 203, "Unable to locate first edge");
Logger::Root().Error("GEO", 203, "Unable to locate first edge");
return false;
}
@@ -187,7 +187,7 @@ void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector<TopoDS_Edge
for (int i = 1; i <= map.Extent(); ++i) {
if (map.FindFromIndex(i).Extent() > 2) {
Logger::Warning("GEO", 204, "Self-intersecting Directrix");
Logger::Root().Warning("GEO", 204, "Self-intersecting Directrix");
}
}
@@ -116,12 +116,12 @@ bool IfcGeom::util::create_edge_over_curve_with_log_messages(const Handle_Geom_C
}
}
if (dmin == std::numeric_limits<double>::infinity()) {
Logger::Error("GEO", 205, "No extrema for point");
Logger::Root().Error("GEO", 205, "No extrema for point");
} else if (dmin > eps2) {
Logger::Error("GEO", 206, "Distance of " + boost::lexical_cast<std::string>(std::sqrt(dmin)) + " exceeds tolerance");
Logger::Root().Error("GEO", 206, "Distance of " + boost::lexical_cast<std::string>(std::sqrt(dmin)) + " exceeds tolerance");
}
} else {
Logger::Error("GEO", 207, "Failed to calculate extrema for point");
Logger::Root().Error("GEO", 207, "Failed to calculate extrema for point");
}
}
}
@@ -171,7 +171,7 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS
if (dist > 1000. * p_) {
mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
Logger::Warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
Logger::Root().Warning("GEO", 208, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
goto check;
}
@@ -199,28 +199,28 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS
// Preferably adjust the segment that is linear
if (is_line1 || (is_circle1 && !is_line2)) {
mw_.Add(adjust(w1, w12, p2));
Logger::Notice("GEO", 209, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
Logger::Root().Notice("GEO", 209, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
} else if ((is_line2 || is_circle2) && !last) {
mw_.Add(w1);
override_next_ = true;
next_override_ = p1;
Logger::Notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
Logger::Root().Notice("GEO", 210, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_);
} else {
// In all other cases an edge is added
mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
Logger::Warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
Logger::Root().Warning("GEO", 211, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_);
}
} else {
Logger::Error("GEO", 212, "Internal error, inconsistent wire segments", inst_);
Logger::Root().Error("GEO", 212, "Internal error, inconsistent wire segments", inst_);
mw_.Add(w1);
}
}
check:
if (mw_.Error() == BRepBuilderAPI_NonManifoldWire) {
Logger::Error("GEO", 213, "Non-manifold curve segments:", inst_);
Logger::Root().Error("GEO", 213, "Non-manifold curve segments:", inst_);
} else if (mw_.Error() == BRepBuilderAPI_DisconnectedWire) {
Logger::Error("GEO", 214, "Failed to join curve segments:", inst_);
Logger::Root().Error("GEO", 214, "Failed to join curve segments:", inst_);
}
}
+17 -17
View File
@@ -86,7 +86,7 @@ bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_P
// obtaining a 2d points for the Delaunay, infinity is passed here, so this
// can't for assessing degenerativeness.
if (v.Magnitude() < 1.e-7) {
Logger::Warning("GEO", 215, "Degenerate face boundary in normal estimation");
Logger::Root().Warning("GEO", 215, "Degenerate face boundary in normal estimation");
return false;
}
@@ -233,7 +233,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
auto it = mapping.find(uvnodes[k]);
if (it == mapping.end()) {
Logger::Error("GEO", 216, "Internal error: unable to unproject uv-mesh");
Logger::Root().Error("GEO", 216, "Internal error: unable to unproject uv-mesh");
return TRIANGULATE_WIRE_FAIL;
}
@@ -277,7 +277,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
}
faces.Append(triangle_face);
} else {
Logger::Error("GEO", 217, "Internal error: missing face");
Logger::Root().Error("GEO", 217, "Internal error: missing face");
return TRIANGULATE_WIRE_FAIL;
}
}
@@ -308,7 +308,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
if (!contains) {
#endif
// All existing edges need to exist in the new faces
Logger::Error("GEO", 218, "Internal error, missing edge from triangulation");
Logger::Root().Error("GEO", 218, "Internal error, missing edge from triangulation");
non_manifold = true;
}
}
@@ -319,7 +319,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
// Existing edges are boundaries with use 1
// New edges are internal with use 2
if (n != (mape.Contains(v) ? 1 : 2)) {
Logger::Error("GEO", 219, "Internal error, non-manifold result from triangulation");
Logger::Root().Error("GEO", 219, "Internal error, non-manifold result from triangulation");
non_manifold = true;
}
}
@@ -790,12 +790,12 @@ bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape
shape = solid.SolidFromShell(TopoDS::Shell(shape));
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 220, e.GetMessageString());
Logger::Root().Error("GEO", 220, e.GetMessageString());
} else {
Logger::Error("GEO", 221, "Unknown error creating solid");
Logger::Root().Error("GEO", 221, "Unknown error creating solid");
}
} catch (...) {
Logger::Error("GEO", 222, "Unknown error creating solid");
Logger::Root().Error("GEO", 222, "Unknown error creating solid");
}
return true;
@@ -808,12 +808,12 @@ bool IfcGeom::util::convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoD
return true;
} catch (const Standard_Failure& e) {
if (e.GetMessageString() && strlen(e.GetMessageString())) {
Logger::Error("GEO", 223, e.GetMessageString());
Logger::Root().Error("GEO", 223, e.GetMessageString());
} else {
Logger::Error("GEO", 224, "Unknown error converting curve to wire");
Logger::Root().Error("GEO", 224, "Unknown error converting curve to wire");
}
} catch (...) {
Logger::Error("GEO", 225, "Unknown error converting curve to wire");
Logger::Root().Error("GEO", 225, "Unknown error converting curve to wire");
}
return false;
}
@@ -834,7 +834,7 @@ void IfcGeom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) {
wire = mw.Wire();
}
Logger::Warning("GEO", 226, "Wire not closed");
Logger::Root().Warning("GEO", 226, "Wire not closed");
}
}
@@ -844,7 +844,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face
TopTools_ListOfShape results;
if (settings.use_wire_intersection_check && util::wire_intersections(wire, results, settings)) {
Logger::Warning("GEO", 227, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 227, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
util::select_largest(results, wire);
}
@@ -875,7 +875,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face
BRepBuilderAPI_FaceError er = mf.Error();
if (er != BRepBuilderAPI_FaceDone) {
Logger::Error("GEO", 228, "Failed to create face.");
Logger::Root().Error("GEO", 228, "Failed to create face.");
return false;
}
face = mf.Face();
@@ -902,7 +902,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound&
TopTools_ListOfShape results;
if (settings.use_wire_intersection_check && util::wire_intersections(w, results, settings)) {
Logger::Warning("GEO", 229, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
Logger::Root().Warning("GEO", 229, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
} else {
results.Clear();
results.Append(w);
@@ -928,7 +928,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound&
BRepBuilderAPI_FaceError er = mf.Error();
if (er != BRepBuilderAPI_FaceDone) {
Logger::Error("GEO", 230, "Failed to create face.");
Logger::Root().Error("GEO", 230, "Failed to create face.");
continue;
}
@@ -945,7 +945,7 @@ bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound&
if (p.first >= max_area / 10.) {
B.Add(faces, p.second);
} else {
Logger::Warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast<std::string>(p.first));
Logger::Root().Warning("GEO", 231, "Ignoring self-intersection loop with area " + boost::lexical_cast<std::string>(p.first));
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
P = *v->components_;
} catch (const std::exception&) {
Logger::Warning("GEO", 232, "Placement with invalid Location:", inst);
logger_.Warning("GEO", 232, "Placement with invalid Location:", inst);
}
const bool hasAxis = inst->Axis();
if (hasAxis) {
+1 -1
View File
@@ -29,7 +29,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement2D* inst) {
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
P = *v->components_;
} catch (const std::exception&) {
Logger::Warning("GEO", 233, "Placement with invalid Location:", inst);
logger_.Warning("GEO", 233, "Placement with invalid Location:", inst);
}
const bool hasRef = !!inst->RefDirection();
if (hasRef) {
+2 -2
View File
@@ -29,13 +29,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
o = *v->components_;
} catch (const std::exception&) {
Logger::Warning("GEO", 234, "Placement with invalid Location:", inst);
logger_.Warning("GEO", 234, "Placement with invalid Location:", inst);
}
const bool hasAxis = !!inst->Axis();
const bool hasRef = !!inst->RefDirection();
if (hasAxis != hasRef) {
Logger::Warning("GEO", 235, "Axis and RefDirection should be specified together", inst);
logger_.Warning("GEO", 235, "Axis and RefDirection should be specified together", inst);
}
if (hasAxis) {
@@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst) {
if (!inst->Location()->as<IfcSchema::IfcPointByDistanceExpression>()) {
Logger::Error("GEO", 236, std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear"));
logger_.Error("GEO", 236, std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear"));
}
Eigen::Vector3d o, axis(0, 0, 1), refDirection;
+1 -1
View File
@@ -43,7 +43,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if ( x < tol || y < tol || d1 < tol || d2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 241, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle* inst) {
const double r = inst->Radius() * length_unit_;
if (r < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 237, "Radius not greater than zero for:", inst);
return nullptr;
}
+3 -3
View File
@@ -34,11 +34,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
for (auto& segment : *segments) {
if (segment->as<IfcSchema::IfcCompositeCurveSegment>() && segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve()->as<IfcSchema::IfcLine>()) {
Logger::Notice("GEO", 238, "Infinite IfcLine used as ParentCurve of segment, treating as a segment", segment);
logger_.Notice("GEO", 238, "Infinite IfcLine used as ParentCurve of segment, treating as a segment", segment);
double u0 = 0.0;
double u1 = segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve()->as<IfcSchema::IfcLine>()->Dir()->Magnitude() * length_unit_;
if (u1 < settings_.get<settings::Precision>().get()) {
Logger::Warning("GEO", 239, "Segment length below tolerance", segment);
logger_.Warning("GEO", 239, "Segment length below tolerance", segment);
}
auto e = taxonomy::make<taxonomy::edge>();
@@ -70,7 +70,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
e->end = 2.0 * boost::math::constants::pi<double>();
loop->children.push_back(e);
} else {
Logger::Warning("GEO", 240, "Unexpected segment type", segment);
logger_.Warning("GEO", 240, "Unexpected segment type", segment);
return nullptr;
}
}
+17 -17
View File
@@ -260,7 +260,7 @@ class curve_segment_evaluator {
}
}
} else {
Logger::Warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment.");
logger_.Warning("GEO", 242, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the next segment.");
}
}
@@ -283,7 +283,7 @@ class curve_segment_evaluator {
if ((is_horizontal + is_vertical + is_cant) != 1) {
// We have to choose the correct functor based on usage. We can't
// support multiple, because we don't know the caller at this point.
Logger::Error("UNS", 10, std::runtime_error("multiple uses of IfcSegmentCurve not supported"), inst_);
logger_.Error("UNS", 10, std::runtime_error("multiple uses of IfcSegmentCurve not supported"), inst_);
}
segment_type_ = is_horizontal ? ST_HORIZONTAL : is_vertical ? ST_VERTICAL : is_cant ? ST_CANT : ST_HORIZONTAL;
@@ -321,7 +321,7 @@ class curve_segment_evaluator {
end_point = segmented_reference_curve->EndPoint();
}
} else {
Logger::Warning("GEO", 243, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the end point.");
logger_.Warning("GEO", 243, "IfcCurveSegment belongs to multiple IfcCompositeCurve instances. Cannot determine the end point.");
}
if (end_point) {
next_segment_placement_ = taxonomy::cast<taxonomy::matrix4>(mapping_->map(end_point))->ccomponents();
@@ -343,7 +343,7 @@ class curve_segment_evaluator {
taxonomy::ptr get_segment_curve_function() {
if (!parent_curve_fn_ || !parent_curve_start_point_) {
Logger::Error("UNS", 11, std::runtime_error(inst_->ParentCurve()->declaration().name() + " not implemented"), inst_);
logger_.Error("UNS", 11, std::runtime_error(inst_->ParentCurve()->declaration().name() + " not implemented"), inst_);
}
auto length = fabs(this->length());
@@ -476,13 +476,13 @@ class curve_segment_evaluator {
projected_length_ = length_;
}
} else if (segment_type_ == ST_CANT) {
Logger::Error("GEO", 244, std::runtime_error("Unexpected segment type encountered - cant is handled in set_cant_spiral_function - should never get here"));
logger_.Error("GEO", 244, std::runtime_error("Unexpected segment type encountered - cant is handled in set_cant_spiral_function - should never get here"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
);
} else {
Logger::Error("GEO", 245, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 245, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
@@ -643,13 +643,13 @@ class curve_segment_evaluator {
set_cant_spiral_function(*super, *slope, cant);
} else if (segment_type_ == ST_VERTICAL) {
Logger::Error("GEO", 246, std::runtime_error("IfcCosineSpiral cannot be used for vertical alignment"));
logger_.Error("GEO", 246, std::runtime_error("IfcCosineSpiral cannot be used for vertical alignment"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
);
} else {
Logger::Error("GEO", 247, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 247, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); }
@@ -712,12 +712,12 @@ class curve_segment_evaluator {
set_cant_spiral_function(*super, *slope, cant);
} else if (segment_type_ == ST_VERTICAL) {
Logger::Error("GEO", 248, std::runtime_error("IfcSineSpiral cannot be used for vertical alignment"));
logger_.Error("GEO", 248, std::runtime_error("IfcSineSpiral cannot be used for vertical alignment"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
} else {
Logger::Error("GEO", 249, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 249, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
@@ -976,12 +976,12 @@ class curve_segment_evaluator {
}
} else if (segment_type_ == ST_CANT) {
Logger::Warning("UNS", 12, std::runtime_error("Use of IfcCircle for cant is not supported"));
logger_.Warning("UNS", 12, std::runtime_error("Use of IfcCircle for cant is not supported"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
} else {
Logger::Error("GEO", 250, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 250, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
@@ -1067,7 +1067,7 @@ class curve_segment_evaluator {
parent_curve_start_point_ = (*parent_curve_fn_)(start_);
} else {
Logger::Warning("GEO", 251, std::runtime_error("Unexpected segment type encountered"));
logger_.Warning("GEO", 251, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
@@ -1081,7 +1081,7 @@ class curve_segment_evaluator {
auto coeffY = pc->CoefficientsY().get_value_or(std::vector<double>());
auto coeffZ = pc->CoefficientsZ().get_value_or(std::vector<double>());
if (!coeffZ.empty()) {
Logger::Warning("GEO", 252, "Expected IfcPolynomialCurve.CoefficientsZ to be undefined for alignment geometry. Coefficients ignored.", pc);
logger_.Warning("GEO", 252, "Expected IfcPolynomialCurve.CoefficientsZ to be undefined for alignment geometry. Coefficients ignored.", pc);
}
if (segment_type_ == ST_HORIZONTAL || segment_type_ == ST_VERTICAL) {
@@ -1147,7 +1147,7 @@ class curve_segment_evaluator {
auto result = boost::math::tools::bracket_and_solve_root(f, x, 2.0, true, tol, max_iter);
x = result.first;
} catch (...) {
Logger::Warning("GEO", 253, "root solver failed");
logger_.Warning("GEO", 253, "root solver failed");
}
return x;
};
@@ -1208,12 +1208,12 @@ class curve_segment_evaluator {
parent_curve_start_point_ = (*parent_curve_fn_)(0.0); // start is added to u in parent_curve_fn_, so use 0.0 here
} else if (segment_type_ == ST_CANT) {
Logger::Warning("UNS", 13, std::runtime_error("Use of IfcPolynomialCurve for cant is not supported"));
logger_.Warning("UNS", 13, std::runtime_error("Use of IfcPolynomialCurve for cant is not supported"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
} else {
Logger::Error("GEO", 254, std::runtime_error("Unexpected segment type encountered"));
logger_.Error("GEO", 254, std::runtime_error("Unexpected segment type encountered"));
parent_curve_fn_ = std::make_shared<parent_curve_function>(
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); },
[](double /*u*/) -> Eigen::Matrix4d { return Eigen::Matrix4d::Identity(); });
+2 -2
View File
@@ -23,14 +23,14 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge* inst) {
if (!inst->EdgeStart()->declaration().is(IfcSchema::IfcVertexPoint::Class()) || !inst->EdgeEnd()->declaration().is(IfcSchema::IfcVertexPoint::Class())) {
Logger::Message(Logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 255, "Only IfcVertexPoints are supported for EdgeStart and -End", inst);
return nullptr;
}
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) inst->EdgeStart())->VertexGeometry();
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) inst->EdgeEnd())->VertexGeometry();
if (!pnt1->declaration().is(IfcSchema::IfcCartesianPoint::Class()) || !pnt2->declaration().is(IfcSchema::IfcCartesianPoint::Class())) {
Logger::Message(Logger::LOG_ERROR, "GEO", 256, "Only IfcCartesianPoints are supported for VertexGeometry", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 256, "Only IfcCartesianPoints are supported for VertexGeometry", inst);
return nullptr;
}
+1 -1
View File
@@ -26,7 +26,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
double y = inst->SemiAxis2() * length_unit_;
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 257, "Radius not greater than zero for:", inst);
return nullptr;
}
+1 -1
View File
@@ -26,7 +26,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
double ry = inst->SemiAxis2() * length_unit_;
const double tol = settings_.get<settings::Precision>().get();
if (rx < tol || ry < tol) {
Logger::Message(Logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 258, "Radius not greater than zero for:", inst);
return nullptr;
}
+1 -1
View File
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
const double height = inst->Depth() * length_unit_;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 259, "Non-positive extrusion height encountered for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst);
#ifndef PERMISSIVE_EXTRUSION
return nullptr;
#endif
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered* inst) {
const double height = inst->Depth() * length_unit_;
if (height < settings_.get<settings::Precision>().get()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 260, "Non-positive extrusion height encountered for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", inst);
return nullptr;
}
+4 -4
View File
@@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
if (!inst->BaseCurve()->as<IfcSchema::IfcCompositeCurve>())
Logger::Warning("GEO", 261, "Expected IfcGradientCurve.BaseCurve to be IfcCompositeCurve", inst); // CT 4.1.7.1.1.2
logger_.Warning("GEO", 261, "Expected IfcGradientCurve.BaseCurve to be IfcCompositeCurve", inst); // CT 4.1.7.1.1.2
auto segments = inst->Segments();
@@ -41,11 +41,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
// for this reason, a dynamic cast is used and if crv is a function_item it is added to the span
spans.push_back(fi);
} else {
Logger::Error("UNS", 14, "Unsupported");
logger_.Error("UNS", 14, "Unsupported");
return nullptr;
}
} else {
Logger::Error("UNS", 15, "Unsupported");
logger_.Error("UNS", 15, "Unsupported");
return nullptr;
}
}
@@ -73,7 +73,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve* inst) {
// check to see if there is valid overlap of the horizontal and vertical domains
if (!(0 < gradient_function->length())) {
Logger::Error("GEO", 262, "IfcGradientCurve does not have a common domain with BaseCurve");
logger_.Error("GEO", 262, "IfcGradientCurve does not have a common domain with BaseCurve");
gradient_function = nullptr; // not valid
}
+1 -1
View File
@@ -24,7 +24,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
IfcSchema::IfcSurface* surface = inst->BaseSurface();
if (!surface->declaration().is(IfcSchema::IfcPlane::Class())) {
Logger::Message(Logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface);
logger_.Message(Logger::LOG_ERROR, "UNS", 16, "Unsupported BaseSurface:", surface);
return nullptr;
}
auto p = taxonomy::make<taxonomy::plane>();
+1 -1
View File
@@ -81,7 +81,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x1 < tol || x2 < tol || y < tol || d1 < tol || ft1 < tol || ft2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -90,7 +90,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
e->basis = circ;
loop->children.push_back(e);
} else {
Logger::Warning("GEO", 263, "Ignoring segment on", inst);
logger_.Warning("GEO", 263, "Ignoring segment on", inst);
}
} else {
throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + segment->as<IfcUtil::IfcBaseClass>()->declaration().name());
+2 -2
View File
@@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if ( x < tol || y < tol || d < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 265, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -77,7 +77,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
const double det = a1*b2 - a2*b1;
if (std::fabs(det) < 1.e-5) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 266, "Legs do not intersect for:", inst);
return nullptr;
}
+3 -3
View File
@@ -54,7 +54,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
}
}
#else
Logger::Warning("GEO", 267, "Using --site-local-placement or --building-local-placement on IFC4.2 might have issues");
logger_.Warning("GEO", 267, "Using --site-local-placement or --building-local-placement on IFC4.2 might have issues");
#endif
}
}
@@ -127,7 +127,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
if (fallback) {
auto mapped_fallback = taxonomy::cast<taxonomy::matrix4>(map(fallback));
if (!result->ccomponents().isApprox(mapped_fallback->ccomponents())) {
Logger::Warning("GEO", 268, "Computed placement differs from fallback", inst);
logger_.Warning("GEO", 268, "Computed placement differs from fallback", inst);
}
}
@@ -135,7 +135,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
auto abs_det = std::abs(result->ccomponents().determinant());
if (abs_det < 1.e-7) {
Logger::Warning("GEO", 269, "Ignoring singular matrix:", inst);
logger_.Warning("GEO", 269, "Ignoring singular matrix:", inst);
return nullptr;
}
@@ -33,7 +33,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst) {
auto offset_values = inst->OffsetValues();
if (offset_values->size() == 0) {
Logger::Error("GEO", 270, "IfcOffsetCurveByDistances must have at least one offset value");
logger_.Error("GEO", 270, "IfcOffsetCurveByDistances must have at least one offset value");
}
auto first_offset_value = *(offset_values->begin());
@@ -56,7 +56,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
auto basis_curve_fn = taxonomy::dcast<taxonomy::function_item>(map(basis_curve));
if (!basis_curve_fn) {
// Only implement on alignment curves
Logger::Warning("GEO", 271, "IfcOffsetCurveByDistances is only implemented for BasisCurves curves based on taxonomy::function_item", inst);
logger_.Warning("GEO", 271, "IfcOffsetCurveByDistances is only implemented for BasisCurves curves based on taxonomy::function_item", inst);
return nullptr;
}
@@ -73,7 +73,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
first_distance *= length_unit_;
if (first_distance < 0.0) {
Logger::Warning("GEO", 272, "IfcOffsetCurveByDistance first offset value is before the start of the curve.");
logger_.Warning("GEO", 272, "IfcOffsetCurveByDistance first offset value is before the start of the curve.");
}
if(0.0 < first_distance)
@@ -110,7 +110,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances* inst
if (dn < dp) // next is before previous
{
Logger::Warning("GEO", 273, "IfcOffsetCurveByDistance offset value is out of bounds.");
logger_.Warning("GEO", 273, "IfcOffsetCurveByDistance offset value is out of bounds.");
continue;
}
@@ -32,7 +32,7 @@ const double PI = boost::math::constants::pi<double>();
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOpenCrossProfileDef* inst) {
if (inst->ProfileType() != IfcSchema::IfcProfileTypeEnum::IfcProfileType_CURVE) {
Logger::Warning("GEO", 274, "Expected IfcOpenCrossProfileDef.ProfileType to be CURVE", inst);
logger_.Warning("GEO", 274, "Expected IfcOpenCrossProfileDef.ProfileType to be CURVE", inst);
return nullptr;
}
@@ -55,7 +55,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOpenCrossProfileDef* inst) {
auto angles = inst->Slopes(); // these are actually angles, but the attribute is called Slopes
if (widths.size() != angles.size()) {
Logger::Warning("GEO", 275, "Expected Widths and Slopes to be equal length, but got " + std::to_string(widths.size()) + " and " + std::to_string(angles.size()) + " respectively", inst);
logger_.Warning("GEO", 275, "Expected Widths and Slopes to be equal length, but got " + std::to_string(widths.size()) + " and " + std::to_string(angles.size()) + " respectively", inst);
return nullptr;
}
+4 -4
View File
@@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
// A loop should consist of at least three vertices
int original_count = polygon.size();
if (original_count < 3) {
Logger::Message(Logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 278, "Not enough edges for:", inst);
return nullptr;
}
@@ -45,17 +45,17 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
auto previous_size = polygon.size();
remove_duplicate_points_from_loop(polygon, true, eps);
if (polygon.size() != previous_size) {
Logger::Warning("GEO", 279, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
logger_.Warning("GEO", 279, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
}
int count = polygon.size();
if (original_count - count != 0) {
std::stringstream ss; ss << (original_count - count) << " edges removed for:";
Logger::Message(Logger::LOG_WARNING, "GEO", 280, ss.str(), inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 280, ss.str(), inst);
}
if (count < 3) {
Logger::Message(Logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 281, "Not enough edges for:", inst);
return nullptr;
}
+2 -2
View File
@@ -44,12 +44,12 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyline* inst) {
auto previous_size = polygon.size();
remove_duplicate_points_from_loop(polygon, closed_by_proximity, eps);
if (polygon.size() != previous_size) {
Logger::Warning("GEO", 276, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
logger_.Warning("GEO", 276, "Removed " + std::to_string(previous_size - polygon.size()) + " (near) duplicate points from:", inst);
}
if (polygon.size() < 2) {
// We somehow need to signal we fail this curve on purpose not to trigger an error.
Logger::Warning("GEO", 277, "Invalid polyline with " + std::to_string(polygon.size()) + " points:", inst);
logger_.Warning("GEO", 277, "Invalid polyline with " + std::to_string(polygon.size()) + " points:", inst);
return nullptr;
}
@@ -37,7 +37,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef* i
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 282, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -30,7 +30,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 283, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -31,7 +31,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef*
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 284, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -34,7 +34,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal* in
auto fn = taxonomy::dcast<taxonomy::function_item>(dir);
if (!fn) {
// Only implement on alignment curves
Logger::Warning("GEO", 285, "IfcSectionedSolidHorizontal is only implemented for Directrix curves based on taxonomy::function_item", inst);
logger_.Warning("GEO", 285, "IfcSectionedSolidHorizontal is only implemented for Directrix curves based on taxonomy::function_item", inst);
return nullptr;
}
@@ -74,11 +74,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal* in
profile_rotations.push_back(rot);
}
if (faces.size() != profile_offsets.size()) {
Logger::Warning("GEO", 286, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
logger_.Warning("GEO", 286, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
return nullptr;
}
if (faces.size() < 2) {
Logger::Warning("GEO", 287, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
logger_.Warning("GEO", 287, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
return nullptr;
}
+3 -3
View File
@@ -34,7 +34,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSurface* inst) {
auto fn = taxonomy::dcast<taxonomy::function_item>(dir);
if (!fn) {
// Only implement on alignment curves
Logger::Warning("GEO", 288, "IfcSectionedSurface is only implemented for Directrix curves based on taxonomy::function_item", inst);
logger_.Warning("GEO", 288, "IfcSectionedSurface is only implemented for Directrix curves based on taxonomy::function_item", inst);
return nullptr;
}
@@ -79,11 +79,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSurface* inst) {
return nullptr;
#endif
if (faces.size() != profile_offsets.size()) {
Logger::Warning("GEO", 289, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
logger_.Warning("GEO", 289, "Expected CrossSections and CrossSectionPositions to be equal length, but got " + std::to_string(faces.size()) + " and " + std::to_string(profile_offsets.size()) + " respectively", inst);
return nullptr;
}
if (faces.size() < 2) {
Logger::Warning("GEO", 290, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
logger_.Warning("GEO", 290, "Expected at least two cross sections, but got " + std::to_string(faces.size()), inst);
return nullptr;
}
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* inst) {
if (!inst->BaseCurve()->as<IfcSchema::IfcGradientCurve>())
Logger::Warning("GEO", 291, "Expected IfcSegmentedReferenceCurve.BaseCurve to be IfcGradient", inst); // CT 4.1.7.1.1.3
logger_.Warning("GEO", 291, "Expected IfcSegmentedReferenceCurve.BaseCurve to be IfcGradient", inst); // CT 4.1.7.1.1.3
auto segments = inst->Segments();
@@ -41,11 +41,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* ins
// for this reason, a dynamic cast is used and if crv is a function_item it is added to the span
spans.push_back(fi);
} else {
Logger::Error("UNS", 17, "Unsupported");
logger_.Error("UNS", 17, "Unsupported");
return nullptr;
}
} else {
Logger::Error("UNS", 18, "Unsupported");
logger_.Error("UNS", 18, "Unsupported");
return nullptr;
}
}
@@ -67,7 +67,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve* ins
auto cant_function = taxonomy::make<taxonomy::cant_function>(gradient, cant, inst);
if (!(0 < cant_function->length())) {
Logger::Error("GEO", 292, "IfcSegmentedReferenceCurve does not have a common domain with BaseCurve");
logger_.Error("GEO", 292, "IfcSegmentedReferenceCurve does not have a common domain with BaseCurve");
cant_function = nullptr;
}
return cant_function;
+2 -2
View File
@@ -1,4 +1,4 @@
/********************************************************************************
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
@@ -62,7 +62,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
sp = inst->StartParam();
ep = inst->EndParam();
} catch (const IfcParse::IfcException& e) {
Logger::Warning("GEO", 293, e);
logger_.Warning("GEO", 293, e);
}
#endif
+2 -2
View File
@@ -40,7 +40,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || d1 < tol || d2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 296, "Skipping zero sized profile:", inst);
return nullptr;
}
@@ -88,7 +88,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) {
const double det = a1*b2 - a2*b1;
if (std::fabs(det) < 1.e-5) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 297, "Web and flange do not intersect for:", inst);
return nullptr;
}
@@ -36,7 +36,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x1 < tol || w < tol || y < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 294, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -76,7 +76,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
bool trim_cartesian_failed = !trim_cartesian;
if (trim_cartesian) {
if ((pnts[0]->ccomponents() - pnts[1]->ccomponents()).norm() < (2 * tol)) {
Logger::Message(Logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst);
logger_.Message(Logger::LOG_WARNING, "GEO", 295, "Skipping segment with length below tolerance level:", inst);
return nullptr;
}
tc->start = pnts[0];
+1 -1
View File
@@ -54,7 +54,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcUShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || d1 < tol || d2 < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 298, "Skipping zero sized profile:", inst);
return nullptr;
}
+1 -1
View File
@@ -45,7 +45,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcZShapeProfileDef* inst) {
const double tol = settings_.get<settings::Precision>().get();
if (x < tol || y < tol || dx < tol || dy < tol) {
Logger::Message(Logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst);
logger_.Message(Logger::LOG_NOTICE, "GEO", 299, "Skipping zero sized profile:", inst);
return nullptr;
}
+32 -32
View File
@@ -1,4 +1,4 @@
/********************************************************************************
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
@@ -32,8 +32,8 @@ using namespace IfcGeom;
namespace {
struct POSTFIX_SCHEMA(factory_t) {
abstract_mapping* operator()(IfcParse::IfcFile* file, Settings& settings) const {
ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file, settings);
abstract_mapping* operator()(IfcParse::IfcFile* file, Settings& settings, Logger& logger) const {
ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file, settings, logger);
return m;
}
};
@@ -83,7 +83,7 @@ IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchem
try {
target = taxonomy::cast<taxonomy::matrix4>(map(item->MappingTarget()));
} catch (const std::exception& e) {
Logger::Error("GEO", 300, e);
logger_.Error("GEO", 300, e);
continue;
}
if (!target->is_identity()) {
@@ -332,7 +332,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
try {
associated_material = (*associated_materials->begin())->RelatingMaterial();
} catch(IfcParse::IfcException& e) {
Logger::Error("GEO", 301, e.what());
logger_.Error("GEO", 301, e.what());
}
if (associated_material) {
@@ -344,7 +344,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
IfcSchema::IfcMaterialLayerSet* layerset;
if (auto *m = associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>()) {
if (m->get("ForLayerSet").isNull()) {
Logger::Warning("GEO", 302, "Missing ForLayerSet for:", m);
logger_.Warning("GEO", 302, "Missing ForLayerSet for:", m);
return nullptr;
}
layerset = m->ForLayerSet();
@@ -363,7 +363,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
IfcSchema::IfcMaterialProfileSet* profileset;
if (auto* m = associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>()) {
if (m->get("ForProfileSet").isNull()) {
Logger::Warning("GEO", 303, "Missing ForProfileSet for:", m);
logger_.Warning("GEO", 303, "Missing ForProfileSet for:", m);
return nullptr;
}
profileset = m->ForProfileSet();
@@ -408,7 +408,7 @@ IfcSchema::IfcRepresentation* mapping::representation_mapped_to(const IfcSchema:
try {
target = taxonomy::cast<taxonomy::matrix4>(map(mapped_item->MappingTarget()));
} catch (const std::exception& e) {
Logger::Error("GEO", 304, e);
logger_.Error("GEO", 304, e);
}
if (target && target->is_identity()) {
IfcSchema::IfcRepresentationMap* rmap = mapped_item->MappingSource();
@@ -571,7 +571,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) {
failed_on_purpose_.insert(material);
return nullptr;
}
Logger::Warning("UNS", 19, "Skipping unsupported material style for material: ", material);
logger_.Warning("UNS", 19, "Skipping unsupported material style for material: ", material);
}
}
@@ -605,7 +605,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
if (style == nullptr) {
// E.g. IfcCurveStyle is skipped as unsupported.
Logger::Warning("GEO", 305, "Only IfcSurfaceStyle is supported, couldn't find it in IfcStyledItem: ", inst);
logger_.Warning("GEO", 305, "Only IfcSurfaceStyle is supported, couldn't find it in IfcStyledItem: ", inst);
failed_on_purpose_.insert(inst);
return nullptr;
}
@@ -700,7 +700,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle* style) {
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
if (inst == nullptr) {
Logger::Error("GEO", 306, "Warning nullptr passed to map() function");
logger_.Error("GEO", 306, "Warning nullptr passed to map() function");
return nullptr;
}
auto iden = inst->as<IfcUtil::IfcBaseClass>()->identity();
@@ -727,7 +727,7 @@ taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
cache_.insert({iden, item});
}
} else if (!matched) {
Logger::Message(Logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 307, "No operation defined for:", inst);
}
return item;
}
@@ -833,10 +833,10 @@ void mapping::initialize_units_() {
auto* project = *projects->begin();
unit_assignment = project->UnitsInContext();
} else {
Logger::Warning("GEO", 308, "Not a single project or context in file");
logger_.Warning("GEO", 308, "Not a single project or context in file");
}
if (unit_assignment == nullptr) {
Logger::Warning("GEO", 309, "Unable to detect unit information");
logger_.Warning("GEO", 309, "Unable to detect unit information");
return;
}
@@ -845,7 +845,7 @@ void mapping::initialize_units_() {
try {
auto units = unit_assignment->Units();
if (!units || !units->size()) {
Logger::Warning("GEO", 310, "No unit information found");
logger_.Warning("GEO", 310, "No unit information found");
} else {
for (auto it = units->begin(); it != units->end(); ++it) {
IfcSchema::IfcUnit* base = *it;
@@ -882,15 +882,15 @@ void mapping::initialize_units_() {
} catch (const IfcParse::IfcException& ex) {
std::stringstream ss;
ss << "Failed to determine unit information '" << ex.what() << "'";
Logger::Message(Logger::LOG_ERROR, "GEO", 311, ss.str());
logger_.Message(Logger::LOG_ERROR, "GEO", 311, ss.str());
}
if (!length_unit_encountered) {
Logger::Warning("GEO", 312, "No length unit encountered");
logger_.Warning("GEO", 312, "No length unit encountered");
}
if (!angle_unit_encountered) {
Logger::Warning("GEO", 313, "No plane angle unit encountered");
logger_.Warning("GEO", 313, "No plane angle unit encountered");
}
// @todo move to a more descriptive function
@@ -907,7 +907,7 @@ void mapping::initialize_units_() {
if (vs.size() == 3) {
offset_and_rotation_ *= Eigen::Affine3d(Eigen::Translation3d(vs[0], vs[1], vs[2])).matrix();
} else {
Logger::Error("SYS", 31, "Expected 3 values for model-offset setting");
logger_.Error("SYS", 31, "Expected 3 values for model-offset setting");
}
}
@@ -920,7 +920,7 @@ void mapping::initialize_units_() {
m4 << m3;
offset_and_rotation_ *= m4;
} else {
Logger::Error("SYS", 32, "Expected 4 values for model-rotation setting");
logger_.Error("SYS", 32, "Expected 4 values for model-rotation setting");
}
}
}
@@ -970,7 +970,7 @@ void mapping::initialize_settings() {
if (any_precision_encountered) {
if (lowest_precision_encountered < 1.e-7) {
Logger::Message(Logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced");
logger_.Message(Logger::LOG_WARNING, "SYS", 33, "Precision lower than 0.0000001 meter not enforced");
precision_to_set = 1.e-7;
} else {
precision_to_set = lowest_precision_encountered;
@@ -1007,7 +1007,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
IfcSchema::IfcRepresentation* body_representation = find_representation(product, "Body");
if (!body_representation) {
Logger::Warning("GEO", 314, "No body representation for product", product);
logger_.Warning("GEO", 314, "No body representation for product", product);
return false;
}
@@ -1021,7 +1021,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
IfcSchema::IfcRepresentation* axis_representation = find_representation(product, "Axis");
if (!axis_representation) {
Logger::Message(Logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product);
logger_.Message(Logger::LOG_WARNING, "GEO", 315, "No axis representation for:", product);
return false;
}
@@ -1090,7 +1090,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
IfcSchema::IfcExtrudedAreaSolid::list::ptr extrusions = IfcParse::traverse(body_representation)->as<IfcSchema::IfcExtrudedAreaSolid>();
if (extrusions->size() != 1) {
Logger::Message(Logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product);
logger_.Message(Logger::LOG_WARNING, "GEO", 316, "No single extrusion found in body representation for:", product);
return false;
}
@@ -1105,7 +1105,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
if (has_position) {
auto m4 = taxonomy::cast<taxonomy::matrix4>(map(extrusion->Position()));
if (!m4) {
Logger::Message(Logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 317, "Failed to convert placement for extrusion of:", product);
return false;
} else {
extrusion_position = m4;
@@ -1115,7 +1115,7 @@ bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layer
taxonomy::direction3::ptr extrusion_direction = taxonomy::cast<taxonomy::direction3>(map(extrusion->ExtrudedDirection()));
if (!extrusion_direction) {
Logger::Message(Logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product);
logger_.Message(Logger::LOG_ERROR, "GEO", 318, "Failed to convert direction for extrusion of:", product);
return false;
}
@@ -1189,12 +1189,12 @@ void mapping::addRepresentationsFromContextIds(IfcSchema::IfcRepresentation::lis
try {
context = file_->instance_by_id(context_id)->as<IfcSchema::IfcGeometricRepresentationContext>();
} catch (IfcParse::IfcException& e) {
Logger::Error("GEO", 319, e);
logger_.Error("GEO", 319, e);
continue;
}
if (!context) {
Logger::Error("GEO", 320, "Failed to process context ID " + std::to_string(context_id));
logger_.Error("GEO", 320, "Failed to process context ID " + std::to_string(context_id));
continue;
}
@@ -1243,14 +1243,14 @@ void mapping::addRepresentationsFromDefaultContexts(IfcSchema::IfcRepresentation
boost::to_lower(context_type);
if (allowed_context_types.find(context_type) == allowed_context_types.end()) {
Logger::Warning("GEO", 321, std::string("ContextType '") + *context->ContextType() + "' not allowed:", context);
logger_.Warning("GEO", 321, std::string("ContextType '") + *context->ContextType() + "' not allowed:", context);
}
if (context_types.find(context_type) != context_types.end()) {
filtered_contexts->push(context);
}
}
} catch (const std::exception& e) {
Logger::Error("GEO", 322, e);
logger_.Error("GEO", 322, e);
}
}
@@ -1280,7 +1280,7 @@ void mapping::addRepresentationsFromDefaultContexts(IfcSchema::IfcRepresentation
}
if (representations->size() == 0) {
Logger::Warning("GEO", 323, "No representations encountered in relevant contexts, using all");
logger_.Warning("GEO", 323, "No representations encountered in relevant contexts, using all");
representations->push(file_->instances_by_type<IfcSchema::IfcRepresentation>());
}
}
@@ -1326,7 +1326,7 @@ IfcUtil::IfcBaseEntity* mapping::representation_of(const IfcUtil::IfcBaseEntity*
intersection_no_box->push(r);
}
if (intersection_no_box->size() > 1) {
Logger::Warning("GEO", 324, "Multiple applicable representations found for element, selecting arbitrary");
logger_.Warning("GEO", 324, "Multiple applicable representations found for element, selecting arbitrary");
}
if (intersection_no_box->size()) {
return (*intersection_no_box->begin())->as<IfcUtil::IfcBaseEntity>();
+5 -5
View File
@@ -67,19 +67,19 @@ namespace geometry {
}
}
} catch (const std::exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 325, std::string(e.what()) + "\nFailed to convert:", inst);
}
} else if (failed_on_purpose_.find(inst) == failed_on_purpose_.end()) {
Logger::Message(Logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 326, "Failed to convert:", inst);
}
} catch (const std::exception& e) {
Logger::Message(Logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst);
logger_.Message(Logger::LOG_ERROR, "GEO", 327, std::string(e.what()) + "\nFailed to convert:", inst);
}
}
}
const IfcSchema::IfcStyledItem* find_style(const IfcSchema::IfcRepresentationItem*);
public:
POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file, Settings& settings) : abstract_mapping(settings), file_(file), placement_rel_to_type_(0), placement_rel_to_instance_(0) {
POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file, Settings& settings, Logger& logger = Logger::Root()) : abstract_mapping(settings, logger), file_(file), placement_rel_to_type_(0), placement_rel_to_instance_(0) {
initialize_units_();
}
virtual ifcopenshell::geometry::taxonomy::ptr map(const IfcUtil::IfcBaseInterface*);
@@ -153,4 +153,4 @@ namespace geometry {
}
#endif
#endif
+2 -2
View File
@@ -861,7 +861,7 @@ boost::optional<function_item::ptr> ifcopenshell::geometry::taxonomy::loop_to_fu
spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn));
} else if (edge_->start.which() == 1 && edge_->end.which() == 1) {
if (edge_->basis && edge_->basis->kind() != LINE) {
Logger::Message(Logger::Severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge");
Logger::Root().Message(Logger::Severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge");
}
const auto& s = boost::get<point3::ptr>(edge_->start)->ccomponents();
const auto& e = boost::get<point3::ptr>(edge_->end)->ccomponents();
@@ -876,7 +876,7 @@ boost::optional<function_item::ptr> ifcopenshell::geometry::taxonomy::loop_to_fu
};
spans.emplace_back(taxonomy::make<taxonomy::functor_item>(l, fn));
} else {
Logger::Message(Logger::Severity::LOG_ERROR, "UNS", 21, "Basis curve not supported");
Logger::Root().Message(Logger::Severity::LOG_ERROR, "UNS", 21, "Basis curve not supported");
return boost::none;
}
}