Skip to content

Commit 25d28c0

Browse files
authored
Mesh_2: Fixes of write_VTU() (#8774)
## Summary of Changes Add warning that the stream must be opened with `std::ios::binary`. Deal with a potentially empty vector of faces. ## Release Management * Affected package(s): Mesh_2 * License and copyright ownership: unchanged
2 parents 2f511f0 + 1cecefe commit 25d28c0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Mesh_2/doc/Mesh_2/CGAL/IO/write_VTU.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace IO {
66
//!
77
//! The faces output are those for which `DelaunayMeshFaceBase_2::is_in_domain()` returns `true`,
88
//! the edges are those for which `ConstrainedTriangulationFaceBase_2::is_constrained()` returns `true`.
9+
//!\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of `os`.
10+
//!
911
//! \tparam CDT a `Constrained_Delaunay_triangulation_2` with face type model of `DelaunayMeshFaceBase_2`.
1012
//!
1113
//! \param os the stream used for writing.
@@ -23,9 +25,12 @@ void write_VTU(std::ostream& os,
2325
//! \brief writes the faces of a domain and its constrained edges embedded in
2426
//! a 2D constrained Delaunay triangulation using the `PolyData` XML
2527
//! format.
26-
//! The faces output are those for which `get(ipm, f)` returns
27-
//! `true` where `f` is a `CDT::Face_handle`,
28+
//! The faces output are those for which `get(ipm, f)` returns
29+
//! `true` where `f` is a `CDT::Face_handle`,
2830
//! the edges are those for which `ConstrainedTriangulationFaceBase_2::is_constrained()` returns `true`.
31+
//!
32+
//!\attention To read a binary file, the flag `std::ios::binary` must be set during the creation of `os`.
33+
//!
2934
//! \tparam CDT a `Constrained_Delaunay_triangulation_2` with face
3035
//! type model of `DelaunayMeshFaceBase_2`.
3136
//! \tparam InDomainPmap a class model of `ReadWritePropertyMap` with

Stream_support/include/CGAL/IO/VTK/VTK_writer.h

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ template <class FT>
2525
void write_vector(std::ostream& os,
2626
const std::vector<FT>& vect)
2727
{
28+
if(vect.empty())
29+
return;
2830
const char* buffer = reinterpret_cast<const char*>(&(vect[0]));
2931
std::size_t size = vect.size()*sizeof(FT);
3032

0 commit comments

Comments
 (0)