OGLplus  (0.59.0) a C++ wrapper for rendering APIs

voronoi2d_node.hpp
Go to the documentation of this file.
1 #ifndef OGLPLUS_TEXGEN_VORONOI2D_NODE_HPP
9 #define OGLPLUS_TEXGEN_VORONOI2D_NODE_HPP
10 
11 #include "base_node.hpp"
12 #include "fallback_input.hpp"
13 
14 namespace eagine::oglp::texgen {
15 
16 enum class voronoi_output_type {
17  distance1,
18  distance2,
19  distance3,
20  cell_coord,
21  cell_center,
22  input_cell_center
23 };
24 
25 class voronoi2d_output : public base_output {
26 private:
27  input_with_const_default<float[2]>& _input;
28  input_with_const_default<float[2]>& _cells;
29  voronoi_output_type _type;
30 
31  short order() const;
32 
33  string_view type_abbr() const;
34 
35 public:
36  voronoi2d_output(
37  node_intf& parent,
38  input_with_const_default<float[2]>&,
39  input_with_const_default<float[2]>&,
40  voronoi_output_type type);
41 
42  string_view type_name() override;
43 
44  string_view name() noexcept override;
45 
46  slot_data_type value_type() override;
47 
48  std::ostream& definitions(std::ostream& out, compile_context& ctxt) override;
49 
50  std::ostream& expression(std::ostream& out, compile_context& ctxt) override;
51 };
52 
53 class voronoi2d_node : public base_node {
54 private:
55  input_with_const_default<float[2]> _input;
56  input_with_const_default<float[2]> _cells;
57 
58  voronoi2d_output _distance1;
59  voronoi2d_output _distance2;
60  voronoi2d_output _distance3;
61  voronoi2d_output _cell_coord;
62  voronoi2d_output _cell_center;
63  voronoi2d_output _input_cell_center;
64 
65 public:
66  voronoi2d_node();
67 
68  voronoi2d_node& set_cell_count(float x, float y) {
69  _cells.fallback().set(x, y);
70  return *this;
71  }
72 
73  string_view type_name() override;
74 
75  span_size_t input_count() override;
76 
77  input_intf& input(span_size_t index) override;
78 
79  span_size_t output_count() override;
80 
81  output_intf& output(span_size_t index) override;
82 };
83 
84 } // namespace eagine::oglp::texgen
85 
86 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
87 #include <oglplus/texgen/voronoi2d_node.inl>
88 #endif
89 
90 #endif // OGLPLUS_TEXGEN_VORONOI2D_NODE_HPP
value_type
Value tree value element data type enumeration.
Definition: interface.hpp:27
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
static auto type_name(const T &) noexcept -> std::string
Returns the demangled name for type T.
Definition: type_name.hpp:24

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).