dispatch_with_upgrade to use only upgrade types for optimization

This commit is contained in:
Andrej730
2024-09-11 18:24:24 +05:00
parent 858e57351e
commit 005c17084b
2 changed files with 10 additions and 2 deletions
+2 -2
View File
@@ -105,7 +105,7 @@ namespace {
template <size_t N>
struct dispatch_with_upgrade {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults& results) {
auto concrete_item = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::type_by_kind::type<N>>(item);
auto concrete_item = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::upgrades::type<N>>(item);
if (concrete_item) {
return kernel->convert_impl(concrete_item, results);
} else {
@@ -115,7 +115,7 @@ namespace {
};
template <>
struct dispatch_with_upgrade<ifcopenshell::geometry::taxonomy::type_by_kind::max> {
struct dispatch_with_upgrade<ifcopenshell::geometry::taxonomy::upgrades::max> {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults&) {
Logger::Error("No conversion with upgrade for " + std::to_string(item->kind()));
return false;
+8
View File
@@ -1066,6 +1066,7 @@ typedef item const* ptr;
typedef std::tuple<matrix4, point3, direction3, line, circle, ellipse, bspline_curve, offset_curve, plane, cylinder, sphere, torus, bspline_surface, edge, loop, face, shell, solid, loft, extrusion, revolve, sweep_along_curve, node, collection, boolean_result, piecewise_function> KindsTuple;
typedef std::tuple<line, circle, ellipse, bspline_curve, offset_curve, loop, edge> CurvesTuple;
typedef std::tuple<plane, cylinder, sphere, torus, bspline_surface, extrusion, revolve> SurfacesTuple;
typedef std::tuple<edge, loop, face, piecewise_function> UpgradesTuple;
}
struct type_by_kind {
@@ -1089,6 +1090,13 @@ typedef item const* ptr;
static const size_t max = std::tuple_size<impl::SurfacesTuple>::value;
};
struct upgrades {
template <std::size_t N>
using type = typename std::tuple_element<N, impl::UpgradesTuple>::type;
static const size_t max = std::tuple_size<impl::UpgradesTuple>::value;
};
boost::optional<face::ptr> loop_to_face_upgrade_impl(ptr item);
template <typename T>
class loop_to_face_upgrade {