Adds caching of loop upgraded to pwf to loop class

This commit is contained in:
Richard Brice
2024-01-15 15:52:26 -08:00
parent a8b88b8ae1
commit f12c3aae09
+6
View File
@@ -759,6 +759,7 @@ typedef item const* ptr;
DECLARE_PTR(loop) DECLARE_PTR(loop)
boost::optional<bool> external, closed; boost::optional<bool> external, closed;
boost::optional<taxonomy::piecewise_function::ptr> pwf;
bool is_polyhedron() const { bool is_polyhedron() const {
for (auto& e : children) { for (auto& e : children) {
@@ -1130,6 +1131,9 @@ typedef item const* ptr;
loop_to_piecewise_function_upgrade(taxonomy::ptr item) { loop_to_piecewise_function_upgrade(taxonomy::ptr item) {
auto loop = taxonomy::dcast<taxonomy::loop>(item); auto loop = taxonomy::dcast<taxonomy::loop>(item);
if (loop) { if (loop) {
if (loop->pwf.is_initialized()) {
pwf_ = loop->pwf;
} else {
pwf_ = taxonomy::make<taxonomy::piecewise_function>(); pwf_ = taxonomy::make<taxonomy::piecewise_function>();
for (auto& edge : loop->children) { for (auto& edge : loop->children) {
// the edge could be an arc or trimmed circle in the case of IfcIndexPolyCurve - support for this isn't implemented yet // the edge could be an arc or trimmed circle in the case of IfcIndexPolyCurve - support for this isn't implemented yet
@@ -1150,6 +1154,8 @@ typedef item const* ptr;
}; };
(*pwf_)->spans.emplace_back(l, fn); (*pwf_)->spans.emplace_back(l, fn);
} }
loop->pwf = pwf_;
}
} }
} }