Moves implementation of piecewise_function::evaluate(u) from h to cpp to prevent massive rebuilds everytime the function is changed.

This commit is contained in:
Richard Brice
2023-10-25 11:44:19 -07:00
parent dd915736f5
commit 0aa69a6ebf
2 changed files with 11 additions and 9 deletions
+10
View File
@@ -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<taxonomy::collection>();
ifcopenshell::geometry::visit<taxonomy::collection>(deep, [&flat](taxonomy::ptr i) {
+1 -9
View File
@@ -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