128 Colormap() : cmapsize(0), minval(0.0f), maxval(1.0f) {};
130 Colormap(
const std::vector<helios::RGBcolor> &ctable,
const std::vector<float> &clocs,
int size,
float minval_,
float maxval_) : cmapsize(size), minval(minval_), maxval(maxval_) {
131 set(ctable, clocs, size, minval_, maxval_);
134 void set(
const std::vector<helios::RGBcolor> &ctable,
const std::vector<float> &clocs,
int size,
float a_minval,
float a_maxval) {
139 size_t Ncolors = ctable.size();
141 assert(clocs.size() == Ncolors && minval < maxval);
143 cmap.resize(Ncolors);
145 std::vector<float> cinds;
146 cinds.resize(Ncolors);
148 for (
uint i = 0; i < Ncolors; i++) {
149 cinds.at(i) = clocs.at(i) *
static_cast<float>(cmapsize - 1);
152 cmap.resize(cmapsize);
153 for (
uint c = 0; c < Ncolors - 1; c++) {
154 float cmin = cinds.at(c);
155 float cmax = cinds.at(c + 1);
157 for (
uint i = 0; i < cmapsize; i++) {
158 auto i_f =
static_cast<float>(i);
160 if (i_f >= cmin && i_f <= cmax) {
161 cmap.at(i).r = ctable.at(c).r + (i_f - cmin) / (cmax - cmin) * (ctable.at(c + 1).r - ctable.at(c).r);
162 cmap.at(i).g = ctable.at(c).g + (i_f - cmin) / (cmax - cmin) * (ctable.at(c + 1).g - ctable.at(c).g);
163 cmap.at(i).b = ctable.at(c).b + (i_f - cmin) / (cmax - cmin) * (ctable.at(c + 1).b - ctable.at(c).b);
170 assert(cmapsize > 0 && !cmap.empty());
175 if (minval == maxval) {
178 float normalized_pos = (x - minval) / (maxval - minval) * float(cmapsize - 1);
181 if (normalized_pos < 0) {
185 else if (normalized_pos >
float(cmapsize - 1)) {
186 color_ind = cmapsize - 1;
190 color_ind = std::round(normalized_pos);
194 color.
r = cmap.at(color_ind).r;
195 color.
g = cmap.at(color_ind).g;
196 color.
b = cmap.at(color_ind).b;
201 void setRange(
float min,
float max) {
207 return {minval, maxval};
210 [[nodiscard]]
float getLowerLimit()
const {
214 [[nodiscard]]
float getUpperLimit()
const {
219 std::vector<helios::RGBcolor> cmap;
220 unsigned int cmapsize;
221 float minval, maxval;
315 Visualizer(
uint Wdisplay,
uint Hdisplay,
int aliasing_samples,
bool window_decorations,
bool headless);
321 static int selfTest(
int argc = 0,
char **argv =
nullptr);
794 void setColormap(
const std::vector<helios::RGBcolor> &colors,
const std::vector<float> &divisions);
929 void displayImage(
const std::vector<unsigned char> &pixel_data,
uint width_pixels,
uint height_pixels);
953 void getDepthMap(std::vector<float> &depth_pixels,
uint &width_pixels,
uint &height_pixels);
1050 [[nodiscard]] std::vector<uint> getFrameBufferSize()
const;
1058 void setFrameBufferSize(
int width,
int height);
1065 [[nodiscard]]
Shader getPrimaryShader()
const;
1072 [[nodiscard]] glm::mat4 getViewMatrix()
const;
1079 [[nodiscard]] std::vector<LightingModel> getPrimaryLightingModel();
1086 [[nodiscard]]
uint getDepthTexture()
const;
1091 static void framebufferResizeCallback(GLFWwindow *window,
int width,
int height);
1100 static void windowResizeCallback(GLFWwindow *window,
int width,
int height);
1111 void initialize(
uint window_width_pixels,
uint window_height_pixels,
int aliasing_samples,
bool window_decorations,
bool headless_mode);
1118 void render(
bool shadow)
const;
1126 void transferBufferData();
1129 void transferTextureData();
1137 [[nodiscard]]
uint registerTextureImage(
const std::string &texture_file);
1147 [[nodiscard]]
uint registerTextureImage(
const std::vector<unsigned char> &texture_data,
const helios::uint2 &image_resolution);
1155 [[nodiscard]]
uint registerTextureTransparencyMask(
const std::string &texture_file);
1163 [[nodiscard]]
uint registerTextureGlyph(
const Glyph *glyph);
1175 std::string colorPrimitivesByObjectData, colorPrimitivesByData;
1176 std::map<uint, uint> colorPrimitives_UUIDs, colorPrimitives_objIDs;
1178 std::vector<uint> contextUUIDs_build;
1180 std::vector<float> depth_buffer_data;
1196 void updateDepthBuffer();
1223 float minimum_view_radius;
1237 std::vector<LightingModel> primaryLightingModel;
1239 float lightintensity = 1.f;
1241 bool isWatermarkVisible;
1244 size_t watermark_ID;
1253 std::vector<size_t> coordinate_axes_IDs;
1261 std::string colorbar_title;
1264 uint colorbar_fontsize;
1270 bool point_culling_enabled;
1271 size_t point_culling_threshold;
1272 float point_max_render_distance;
1273 float point_lod_factor;
1276 mutable size_t points_total_count;
1277 mutable size_t points_rendered_count;
1278 mutable float last_culling_time_ms;
1290 std::vector<size_t> colorbar_IDs;
1293 std::vector<GLuint> face_index_buffer, vertex_buffer, uv_buffer;
1295 std::vector<GLuint> color_buffer, normal_buffer, texture_flag_buffer, texture_ID_buffer, coordinate_flag_buffer, hidden_flag_buffer;
1297 std::vector<GLuint> color_texture_object, normal_texture_object, texture_flag_texture_object, texture_ID_texture_object, coordinate_flag_texture_object, hidden_flag_texture_object;
1300 GLuint uv_rescale_buffer;
1301 GLuint uv_rescale_texture_object;
1304 std::vector<GLint> rectangle_vertex_group_firsts;
1305 std::vector<GLint> rectangle_vertex_group_counts;
1312 [[nodiscard]] glm::mat4 computeShadowDepthMVP()
const;
1314 void updatePerspectiveTransformation(
bool shadow);
1317 void cullPointsByFrustum();
1318 void cullPointsByDistance(
float maxDistance,
float lodFactor);
1319 void updatePointCulling();
1320 std::vector<glm::vec4> extractFrustumPlanes()
const;
1322 glm::mat4 perspectiveTransformationMatrix;
1324 glm::mat4 cameraViewMatrix;
1325 glm::mat4 cameraProjectionMatrix;
1327 void updateCustomTransformation(
const glm::mat4 &matrix);
1329 glm::mat4 customTransformationMatrix;
1334 bool build_all_context_geometry =
false;
1336 bool primitiveColorsNeedUpdate;
1341 void buildContextGeometry_private();
1345 std::vector<float> colorbar_ticks;
1376 size_t texture_array_layers;
1377 bool textures_dirty;
1381 const glm::mat4 biasMatrix = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0};
1401 explicit Texture(
const std::string &texture_file,
uint textureID,
const helios::uint2 &maximum_texture_size,
bool loadalphaonly =
false);
1428 explicit Texture(
const std::vector<unsigned char> &pixel_data,
uint textureID,
const helios::uint2 &image_resolution,
const helios::uint2 &maximum_texture_size);
1431 std::string texture_file;
1439 std::vector<unsigned char> texture_data;
1441 unsigned char num_channels;
1451 void resizeTexture(
const helios::uint2 &new_image_resolution);
1459 std::unordered_map<uint, Texture> texture_manager;
1462 friend struct Texture;