7#include "utility/example_shared.h"
11 const std::vector< mi::math::Vector_struct< mi::Float32, 3 > >& vertex_vec,
12 const std::vector< mi::Float32 >& attibute_vec,
13 nv::index::IPoint_set::Point_style point_style)
15 m_vertex_vec(vertex_vec),
16 m_per_vertex_color_values(),
18 m_point_style(point_style),
19 m_rendering_enabled(true),
21 m_meta_data(mi::neuraylib:
:NULL_TAG)
31 m_per_vertex_color_values.clear();
32 m_per_vertex_radii.clear();
34 mi::Size
const attrib_count = attribute_vec.size();
37 for(mi::Size i = 0; i < attrib_count; ++i)
39 const mi::Float32 attrib = attribute_vec.at(i);
48 if(!(m_vertex_vec.empty()))
50 return &m_vertex_vec[0];
60 if(!(m_vertex_vec.empty()))
62 return &m_vertex_vec[0];
72 if(!(m_per_vertex_color_values.empty()))
74 return &m_per_vertex_color_values[0];
84 if(!(m_per_vertex_radii.empty()))
86 return &m_per_vertex_radii[0];
97 other->m_vertex_vec = this->m_vertex_vec;
98 other->m_per_vertex_color_values = this->m_per_vertex_color_values;
99 other->m_per_vertex_radii = this->m_per_vertex_radii;
100 other->m_point_style = this->m_point_style;
101 other->m_rendering_enabled = this->m_rendering_enabled;
102 other->m_pickable = this->m_pickable;
103 other->m_meta_data = this->m_meta_data;
110 return "Attribute_point_set";
115 mi::neuraylib::ISerializer *serializer)
const
117 const mi::Size nb_elements = m_vertex_vec.size();
118 serializer->write(&nb_elements, 1);
121 serializer->write(&m_vertex_vec[0].x, nb_elements * 3);
122 serializer->write(&m_per_vertex_color_values[0].r, nb_elements * 4);
123 serializer->write(&m_per_vertex_radii[0], nb_elements);
126 const mi::Uint32 style =
static_cast<mi::Uint32
>(m_point_style);
127 serializer->write(&style, 1);
129 serializer->write(&m_rendering_enabled, 1);
130 serializer->write(&m_pickable, 1);
131 serializer->write(&m_meta_data.id, 1);
136 mi::neuraylib::IDeserializer* deserializer)
138 mi::Size nb_elements = 0;
139 deserializer->read(&nb_elements, 1);
141 m_vertex_vec. resize(nb_elements);
142 m_per_vertex_color_values.resize(nb_elements);
143 m_per_vertex_radii. resize(nb_elements);
147 deserializer->read(&m_vertex_vec[0].x, nb_elements * 3);
148 deserializer->read(&m_per_vertex_color_values[0].r, nb_elements * 4);
149 deserializer->read(&m_per_vertex_radii[0], nb_elements);
152 mi::Uint32 style = 0;
153 deserializer->read(&style, 1);
154 m_point_style =
static_cast<Point_style
>(style);
156 deserializer->read(&m_rendering_enabled, 1);
157 deserializer->read(&m_pickable, 1);
158 deserializer->read(&m_meta_data.id, 1);
164 mi::Sint32
const intval =
static_cast< mi::Sint32
>(fabs(attrib));
165 mi::math::Color_struct col;
166 const mi::Float32 coef = 1.0f / 15.0f;
167 col.r = coef *
static_cast< mi::Float32
>(intval & 15);
168 col.g = coef *
static_cast< mi::Float32
>((intval >> 4) & 15);
169 col.b = coef *
static_cast< mi::Float32
>((intval >> 8) & 15);
178 const mi::Float32 rad =
179 static_cast< mi::Float32
>(
static_cast< mi::Sint32
>(fabs(attrib)) % 12);
attribute point set as an example implementation
An example simple point set shape implementation of IPoint_set.
void set_attribute(std::vector< mi::Float32 > const &attribute_vec)
set point attribute
virtual void serialize(mi::neuraylib::ISerializer *serializer) const
mi::Float32 get_radius_from_attribute(mi::Float32 attrib)
attribute to radius map example
virtual const mi::math::Vector_struct< mi::Float32, 3 > * get_vertices() const
Get the pointer to the array of vertices (points).
virtual const char * get_class_name() const
mi::math::Color_struct get_color_from_attribute(mi::Float32 attrib)
attribute to color map example
virtual mi::neuraylib::IElement * copy() const
Attribute_point_set()
Constructing the point set shape for serialization.
mi::math::Vector_struct< mi::Float32, 3 > * peek_vertices()
peek the vertex position for change.
virtual void deserialize(mi::neuraylib::IDeserializer *deserializer)
virtual const mi::Float32 * get_radii() const
Get the pointer to the array of per-vertex radii.
virtual const mi::math::Color_struct * get_colors() const
Get the pointer to the array of per-vertex color values.
#define check_success(expr)