From a89f67410683bd7aeb65abec5fc7c0fe7acafa1e Mon Sep 17 00:00:00 2001 From: Thomas Spenke Date: Tue, 25 Aug 2026 14:20:03 +0200 Subject: [PATCH] Bugfix: Make t8_vtk_writer.h C-safe --- src/t8_vtk/t8_vtk_writer.cxx | 4 ++-- src/t8_vtk/t8_vtk_writer.h | 30 ------------------------------ src/t8_vtk/t8_vtk_writer.hxx | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 8d7e0b71d4..474127e18c 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -156,6 +156,8 @@ t8_cmesh_vtk_write_file (const t8_cmesh_t cmesh, const char *fileprefix) return writer.write_ASCII (cmesh); } +T8_EXTERN_C_END (); + #if T8_ENABLE_VTK void t8_forest_to_vtkUnstructuredGrid (const t8_forest_t forest, vtkSmartPointer unstructuredGrid, @@ -168,5 +170,3 @@ t8_forest_to_vtkUnstructuredGrid (const t8_forest_t forest, vtkSmartPointer #include -#if T8_ENABLE_VTK -#include -#endif - T8_EXTERN_C_BEGIN (); -#if T8_ENABLE_VTK -/** - * Translate a forest into a vtkUnstructuredGrid with respect to the given flags. - * This function uses the vtk library. t8code must be configured with - * "-DT8CODE_ENABLE_VTK=ON" in order to use it. - * \param [in] forest The forest. - * \param[in, out] unstructuredGrid - * \param [in] write_treeid If true, the global tree id is written for each element. - * \param [in] write_mpirank If true, the mpirank is written for each element. - * \param [in] write_level If true, the refinement level is written for each element. - * \param [in] write_element_id If true, the global element id is written for each element. - * \param [in] curved_flag If true, write the elements as curved element types from vtk. - * \param [in] write_ghosts If true, write out ghost elements as well. - * \param [in] num_data Number of user defined double valued data fields to write. - * \param [in] data Array of t8_vtk_data_field_t of length \a num_data - * providing the user defined per element data. - * If scalar and vector fields are used, all scalar fields - * must come first in the array. - */ -void -t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, - const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int write_ghosts, const int curved_flag, - const int num_data, t8_vtk_data_field_t *data); -#endif - /** Write the forest in .pvtu file format. Writes one .vtu file per * process and a meta .pvtu file. * This function uses the vtk library. t8code must be configured with diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index d4c3355a4e..6cb500f2ee 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -586,4 +586,30 @@ struct vtk_writer bool merge_points = true; }; +#if T8_ENABLE_VTK +/** + * Translate a forest into a vtkUnstructuredGrid with respect to the given flags. + * This function uses the vtk library. t8code must be configured with + * "-DT8CODE_ENABLE_VTK=ON" in order to use it. + * \param [in] forest The forest. + * \param[in, out] unstructuredGrid + * \param [in] write_treeid If true, the global tree id is written for each element. + * \param [in] write_mpirank If true, the mpirank is written for each element. + * \param [in] write_level If true, the refinement level is written for each element. + * \param [in] write_element_id If true, the global element id is written for each element. + * \param [in] curved_flag If true, write the elements as curved element types from vtk. + * \param [in] write_ghosts If true, write out ghost elements as well. + * \param [in] num_data Number of user defined double valued data fields to write. + * \param [in] data Array of t8_vtk_data_field_t of length \a num_data + * providing the user defined per element data. + * If scalar and vector fields are used, all scalar fields + * must come first in the array. + */ +void +t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, + const int write_treeid, const int write_mpirank, const int write_level, + const int write_element_id, const int write_ghosts, const int curved_flag, + const int num_data, t8_vtk_data_field_t *data); +#endif + #endif /* T8_VTK_WRITER_HXX */