MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ apply_one_to_one()

void MayaFlux::Nodes::Network::GraphicsOperator::apply_one_to_one ( std::string_view  param,
const std::shared_ptr< NodeNetwork > &  source 
)
overridevirtual

Apply ONE_TO_ONE parameter mapping.

Default implementation handles common graphics properties:

  • "color": Per-point color
  • "size": Per-point size (for point rendering)

Reimplemented from MayaFlux::Nodes::Network::NetworkOperator.

Reimplemented in MayaFlux::Nodes::Network::PhysicsOperator.

Definition at line 8 of file GraphicsOperator.cpp.

11{
12 size_t point_count = get_point_count();
13
14 if (source->get_node_count() != point_count) {
15 return;
16 }
17
18 if (param == "color") {
19 for (size_t i = 0; i < point_count; ++i) {
20 auto val = source->get_node_output(i);
21 if (!val)
22 continue;
23
24 auto* point = static_cast<PointVertex*>(get_data_at(i));
25 if (point) {
26 float normalized = glm::clamp(static_cast<float>(*val), 0.0F, 1.0F);
27 point->color = glm::vec3(normalized, 0.5F, 1.0F - normalized);
28 }
29 }
30 } else if (param == "size") {
31 for (size_t i = 0; i < point_count; ++i) {
32 auto val = source->get_node_output(i);
33 if (!val)
34 continue;
35
36 auto* point = static_cast<PointVertex*>(get_data_at(i));
37 if (point) {
38 point->size = glm::clamp(static_cast<float>(*val) * 10.0F, 1.0F, 50.0F);
39 }
40 }
41 }
42}
virtual void * get_data_at(size_t global_index)=0
Get mutable access to point at global index.
virtual size_t get_point_count() const =0
Get source point count (before topology expansion)
std::vector< double > normalized(const std::vector< double > &data, double target_peak)
Normalize single-channel data (non-destructive)
Definition Yantra.cpp:593

References get_data_at(), get_point_count(), MayaFlux::normalized(), and MayaFlux::Nodes::PointVertex::size.

Referenced by MayaFlux::Nodes::Network::PhysicsOperator::apply_one_to_one().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: