From cef3de4e578b38f7ef4dec05cf8baddc6581c3bf Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:44:19 -0700 Subject: [PATCH] Moves implementation of piecewise_function::evaluate(u) from h to cpp to prevent massive rebuilds everytime the function is changed. --- src/ifcgeom/taxonomy.cpp | 10 ++++++++++ src/ifcgeom/taxonomy.h | 10 +--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ifcgeom/taxonomy.cpp b/src/ifcgeom/taxonomy.cpp index bc04e9391e..45b0b1ad9d 100644 --- a/src/ifcgeom/taxonomy.cpp +++ b/src/ifcgeom/taxonomy.cpp @@ -472,6 +472,16 @@ ifcopenshell::geometry::taxonomy::item::ptr ifcopenshell::geometry::taxonomy::pi return polygon_from_points(polygon); } +Eigen::Matrix4d ifcopenshell::geometry::taxonomy::piecewise_function::evaluate(double u) const { + // @todo: rb optimize, assume monotonic evaluation and store last evaluated segment? + for (auto& [length, fn] : spans) { + if (u < length + 0.001) { // @todo: rb - need to use consistent tolerance + return fn(u); + } + u -= length; + } +} + ifcopenshell::geometry::taxonomy::collection::ptr ifcopenshell::geometry::flatten(taxonomy::collection::ptr deep) { auto flat = make(); ifcopenshell::geometry::visit(deep, [&flat](taxonomy::ptr i) { diff --git a/src/ifcgeom/taxonomy.h b/src/ifcgeom/taxonomy.h index 2fccbe760c..8d1358351c 100644 --- a/src/ifcgeom/taxonomy.h +++ b/src/ifcgeom/taxonomy.h @@ -151,15 +151,7 @@ typedef item const* ptr; virtual item::ptr evaluate() const; - Eigen::Matrix4d evaluate(double u) const { - // @todo: rb optimize, assume monotonic evaluation and store last evaluated segment? - for (auto& [length, fn] : spans) { - if (u < length+0.001) { // @todo: rb - need to use consistent tolerance - return fn(u); - } - u -= length; - } - } + Eigen::Matrix4d evaluate(double u) const; }; #ifdef TAXONOMY_USE_SHARED_PTR