Why use dynamic_cast here? You pass *table_mesh onwards without checking. Either you need to check, or use static_cast.