diff --git a/src/ifcgeom/kernel_agnostic/AbstractKernel.cpp b/src/ifcgeom/kernel_agnostic/AbstractKernel.cpp index 62cebcabfb..a7e5a5699b 100644 --- a/src/ifcgeom/kernel_agnostic/AbstractKernel.cpp +++ b/src/ifcgeom/kernel_agnostic/AbstractKernel.cpp @@ -7,29 +7,6 @@ #include "../../ifcgeom/kernels/cgal/CgalKernel.h" -namespace { - /* A compile-time for loop over the taxonomy kinds */ - template - struct dispatch_conversion { - static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::item* item, ifcopenshell::geometry::ConversionResults& results) { - if (N == item->kind()) { - auto concrete_item = static_cast*>(item); - return kernel->convert_impl(concrete_item, results); - } else { - return dispatch_conversion::dispatch(kernel, item, results); - } - } - }; - - template <> - struct dispatch_conversion { - static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::item* item, ifcopenshell::geometry::ConversionResults&) { - Logger::Error("No conversion for " + std::to_string(item->kind())); - return false; - } - }; -} - bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::item* item, ifcopenshell::geometry::ConversionResults& results) { try { return dispatch_conversion<0>::dispatch(this, item, results); diff --git a/src/ifcgeom/kernel_agnostic/AbstractKernel.h b/src/ifcgeom/kernel_agnostic/AbstractKernel.h index 735fbde202..5eb2172194 100644 --- a/src/ifcgeom/kernel_agnostic/AbstractKernel.h +++ b/src/ifcgeom/kernel_agnostic/AbstractKernel.h @@ -71,4 +71,51 @@ namespace ifcopenshell { namespace geometry { namespace kernels { } } + +namespace { + /* A compile-time for loop over the taxonomy kinds */ + template + struct dispatch_conversion { + static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::item* item, ifcopenshell::geometry::ConversionResults& results) { + if (N == item->kind()) { + auto concrete_item = static_cast*>(item); + return kernel->convert_impl(concrete_item, results); + } else { + return dispatch_conversion::dispatch(kernel, item, results); + } + } + }; + + template <> + struct dispatch_conversion { + static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::item* item, ifcopenshell::geometry::ConversionResults&) { + Logger::Error("No conversion for " + std::to_string(item->kind())); + return false; + } + }; + + /* A compile-time for loop over the curve kinds */ + template + struct dispatch_curve_creation { + static bool dispatch(const ifcopenshell::geometry::taxonomy::item* item, T& visitor) { + // @todo it should be possible to eliminate this dynamic_cast when there is a static equivalent to kind() + const ifcopenshell::geometry::taxonomy::curves::type* v = dynamic_cast*>(item); + if (v) { + visitor(*v); + return true; + } else { + return dispatch_curve_creation::dispatch(item, visitor); + } + } + }; + + template + struct dispatch_curve_creation { + static bool dispatch(const ifcopenshell::geometry::taxonomy::item* item, T&) { + Logger::Error("No conversion for " + std::to_string(item->kind())); + return false; + } + }; +} + #endif \ No newline at end of file