1#ifndef TATOOINE_DETAIL_LINE_VTL_WRITER_H
2#define TATOOINE_DETAIL_LINE_VTL_WRITER_H
7#include <boost/range/algorithm_ext/iota.hpp>
14template <
typename Line, unsigned_integral HeaderType = std::uint64_t,
15 integral ConnectivityInt = std::int64_t,
16 integral OffsetInt = std::int64_t>
27 auto write(filesystem::path
const& path, std::string
const& title)
const {
28 auto file = std::ofstream{path};
29 if (!file.is_open()) {
30 throw std::runtime_error{
"Could open file " + path.string() +
34 if (writer.is_open()) {
35 writer.set_title(title);
36 writer.write_header();
39 auto ps = std::vector<std::array<typename Line::real_type, 3>>{};
40 ps.reserve(m_line.
vertices().size());
41 for (
auto const& v : m_line.
vertices()) {
42 auto const& p = m_line[v];
43 if constexpr (num_dimensions() == 3) {
46 ps.push_back({p(0), p(1), 0});
49 writer.write_points(ps);
52 auto line_seq = std::vector<std::vector<std::size_t>>(
53 1, std::vector<std::size_t>(m_line.
vertices().size()));
54 boost::iota(line_seq.front(), 0);
56 line_seq.front().push_back(0);
58 writer.write_lines(line_seq);
60 writer.write_point_data(m_line.
vertices().size());
64 auto const& type = prop->type();
65 if (type ==
typeid(
float)) {
66 write_prop<float>(writer, name, prop);
68 write_prop<vec<float, 2>>(writer, name, prop);
70 write_prop<vec<float, 3>>(writer, name, prop);
72 write_prop<vec<float, 4>>(writer, name, prop);
74 }
else if (type ==
typeid(
double)) {
75 write_prop<double>(writer, name, prop);
77 write_prop<vec<double, 2>>(writer, name, prop);
79 write_prop<vec<double, 3>>(writer, name, prop);
81 write_prop<vec<double, 4>>(writer, name, prop);
91 std::unique_ptr<vertex_property_type>
const& prop) ->
void {
93 ->internal_container();
95 writer.write_scalars(name, std::vector<T>(
begin(deque),
end(deque)));
Definition: vtk_legacy.h:448
auto end(vertex_container< Real, NumDimensions, Handle > const &it)
Definition: vertex_container.h:46
auto begin(vertex_container< Real, NumDimensions, Handle > const &it)
Definition: vertex_container.h:41
line< real_number, NumDimensions > Line
Definition: line.h:857
Definition: vtk_writer.h:18
auto write(filesystem::path const &path, std::string const &title) const
Definition: vtk_writer.h:27
typename Line::vertex_property_type vertex_property_type
Definition: vtk_writer.h:20
Line const & m_line
Definition: vtk_writer.h:25
typename Line::template typed_vertex_property_type< T > typed_vertex_property_type
Definition: vtk_writer.h:23
static auto write_prop(vtk::legacy_file_writer &writer, std::string const &name, std::unique_ptr< vertex_property_type > const &prop) -> void
Definition: vtk_writer.h:89
static auto constexpr num_dimensions()
Definition: vtk_writer.h:19
auto vertices() const
Definition: line.h:250
auto push_back(arithmetic auto const ... components)
Definition: line.h:176
static constexpr auto num_dimensions() -> std::size_t
Definition: line.h:72
deque_property< vertex_handle > vertex_property_type
Definition: line.h:55
auto is_closed() const
Definition: line.h:305
auto vertex_properties() const -> auto const &
Definition: line.h:450