From 053e3a31916fc51e2f0af52ea4936ab679174c05 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 17 Sep 2023 09:35:14 +0200 Subject: [PATCH] #3098 Move boost::type application to curve to template function --- src/ifcgeom/mapping/IfcCurveSegment.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index 65ec09bb67..61fc913c15 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -63,14 +63,10 @@ public: #ifdef SCHEMA_HAS_IfcClothoid // Then initialize Function(double) -> Vector3, by means of IfcCurve subtypes - void operator()(boost::type) { - if (!curve_->as()) { - return; - } - + void operator()(IfcSchema::IfcClothoid* c) { // @todo verify auto L = start_ + length_; - auto A = curve_->as()->ClothoidConstant(); + auto A = c->ClothoidConstant(); auto R = A * A / L; auto RL = R * L; @@ -93,13 +89,18 @@ public: #endif // Another IfcCurve subtype - void operator()(boost::type) { - if (!curve_->as()) { - return; - } + void operator()(IfcSchema::IfcLine*) { throw std::runtime_error("not implemented"); } + // Take the boost::type value from mpl::for_each and test it against our curve instance + template + void operator()(boost::type) { + if (curve_->as()) { + (*this)(curve_->as()); + } + } + // Then, with function populated based on IfcCurve subtype, we can evaluate to points Eigen::Vector3d operator()(double u) { if (eval_) {