@@ -54,8 +54,9 @@ namespace ifcopenshell { namespace geometry { namespace kernels {
5454 virtual bool convert_impl (const taxonomy::bspline_surface::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
5555 virtual bool convert_impl (const taxonomy::cylinder::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
5656 virtual bool convert_impl (const taxonomy::sphere::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
57+ virtual bool convert_impl (const taxonomy::torus::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
5758 virtual bool convert_impl (const taxonomy::solid::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
58- virtual bool convert_impl (const taxonomy::surface_curve_sweep ::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
59+ virtual bool convert_impl (const taxonomy::sweep_along_curve ::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
5960 virtual bool convert_impl (const taxonomy::loft::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error (" Not implemented" ); }
6061 virtual bool convert_impl (const taxonomy::collection::ptr, IfcGeom::ConversionResults&);
6162 virtual bool convert_impl (const taxonomy::piecewise_function::ptr item, IfcGeom::ConversionResults& cs);
@@ -107,7 +108,7 @@ namespace {
107108 static bool dispatch (const ifcopenshell::geometry::taxonomy::ptr item, T& visitor) {
108109 // @todo it should be possible to eliminate this dynamic_cast when there is a static equivalent to kind()
109110 auto v = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::curves::type<N>>(item);
110- if (v) {
111+ if (v && item-> kind () == v-> kind () ) {
111112 visitor (v);
112113 return true ;
113114 } else {
@@ -123,6 +124,28 @@ namespace {
123124 return false ;
124125 }
125126 };
127+
128+ /* A compile-time for loop over the curve kinds */
129+ template <typename T, size_t N = 0 >
130+ struct dispatch_surface_creation {
131+ static bool dispatch (const ifcopenshell::geometry::taxonomy::ptr item, T& visitor) {
132+ auto v = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::surfaces::type<N>>(item);
133+ if (v && item->kind () == v->kind ()) {
134+ visitor (v);
135+ return true ;
136+ } else {
137+ return dispatch_surface_creation<T, N + 1 >::dispatch (item, visitor);
138+ }
139+ }
140+ };
141+
142+ template <typename T>
143+ struct dispatch_surface_creation <T, ifcopenshell::geometry::taxonomy::surfaces::max> {
144+ static bool dispatch (const ifcopenshell::geometry::taxonomy::ptr item, T&) {
145+ Logger::Error (" No conversion for " + std::to_string (item->kind ()));
146+ return false ;
147+ }
148+ };
126149}
127150
128151#endif
0 commit comments