MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
TopologyOperator.hpp
Go to the documentation of this file.
1#pragma once
4
6
7class MAYAFLUX_API TopologyOperator : public GraphicsOperator {
8public:
9 explicit TopologyOperator(
10 Kinesis::ProximityMode mode = Kinesis::ProximityMode::K_NEAREST);
11
12 ~TopologyOperator() override { m_shutdown.store(true, std::memory_order_release); }
13
14 /**
15 * @brief Initialize a single topology with single set of vertices
16 */
17 void initialize(const std::vector<LineVertex>& vertices);
18
19 /**
20 * @brief Initialize multiple topologies with given positions and properties.
21 * @param topologies Vector of position vectors, one per topology.
22 * @param mode Proximity mode for all topologies.
23 */
24 void initialize_topologies(
25 const std::vector<std::vector<LineVertex>>& topologies,
27
28 /**
29 * @brief Add a single topology with full per-vertex control.
30 * @param vertices Vector of LineVertex defining the topology's points and attributes.
31 * @param mode Proximity mode for this topology.
32 */
33 void add_topology(
34 const std::vector<LineVertex>& vertices,
36
37 void process(float dt) override;
38
39 [[nodiscard]] std::span<const uint8_t> get_vertex_data() const override;
40 [[nodiscard]] std::span<const uint8_t> get_vertex_data_for_collection(uint32_t idx) const override;
41 [[nodiscard]] Kakshya::VertexLayout get_vertex_layout() const override;
42 [[nodiscard]] size_t get_vertex_count() const override;
43 [[nodiscard]] bool is_vertex_data_dirty() const override;
44 void mark_vertex_data_clean() override;
45
46 /**
47 * @brief Extract current vertex data as LineVertex array
48 * @return Vector of LineVertex with current positions, colors, thicknesses
49 */
50 [[nodiscard]] std::vector<LineVertex> extract_vertices() const;
51
52 void set_parameter(std::string_view param, double value) override;
53 [[nodiscard]] std::optional<double> query_state(std::string_view query) const override;
54 [[nodiscard]] std::string_view get_type_name() const override { return "Topology"; }
55 [[nodiscard]] size_t get_point_count() const override;
56
57 /**
58 * @brief Access a specific topology node directly.
59 * @param i Collection index.
60 * @return Shared pointer to the TopologyGeneratorNode, or nullptr if out of range.
61 */
62 [[nodiscard]] std::shared_ptr<GpuSync::TopologyGeneratorNode> get_topology(size_t i) const
63 {
64 if (i >= m_topologies.size()) {
65 return nullptr;
66 }
67 return m_topologies[i];
68 }
69
70 /**
71 * @brief Set the connection radius for topology generation.
72 * @param radius Connection radius.
73 */
74 void set_connection_radius(float radius);
75
76 /**
77 * @brief Set the number of neighbors (k) for K-Nearest topology mode.
78 * @param k Number of neighbors.
79 */
80 void set_global_line_thickness(float thickness);
81
82 /**
83 * @brief Set the line color for all topologies.
84 * @param color RGB color.
85 */
86 void set_global_line_color(const glm::vec3& color);
87
88 /**
89 * @brief Set number of samples per segment for interpolation for all topologies.
90 * @param samples Number of samples to generate per connection segment
91 *
92 * Higher values produce smoother curves but increase vertex count.
93 */
94 void set_samples_per_segment(size_t samples);
95
96 /**
97 * @brief Get number of topologies currently stored
98 * @return Topology count
99 */
100 [[nodiscard]] size_t get_topology_count() const { return m_topologies.size(); }
101
102 const char* get_vertex_type_name() const override { return "PathVertex"; }
103
104protected:
105 void* get_data_at(size_t global_index) override;
106
107private:
108 std::vector<std::shared_ptr<GpuSync::TopologyGeneratorNode>> m_topologies;
109
110 mutable std::vector<uint8_t> m_vertex_data_aggregate;
111
113 float m_default_thickness { 2.0F };
114
115 mutable std::atomic<uint32_t> m_access_token { 0 };
116 std::atomic<bool> m_shutdown { false };
117};
118
119} // namespace MayaFlux::Nodes::Network
Operator that produces GPU-renderable geometry.
size_t get_topology_count() const
Get number of topologies currently stored.
std::string_view get_type_name() const override
Type name for introspection.
const char * get_vertex_type_name() const override
Get human-readable vertex type name (for validation/debugging)
std::vector< std::shared_ptr< GpuSync::TopologyGeneratorNode > > m_topologies
std::shared_ptr< GpuSync::TopologyGeneratorNode > get_topology(size_t i) const
Access a specific topology node directly.
void initialize()
Definition main.cpp:11
Complete description of vertex data layout in a buffer.