⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 meshrender.cc

📁 MatlabVisualization Package
💻 CC
字号:
#include "meshrender.h"#include <GL/glu.h>#include <iostream>#include <math.h>MeshRender::MeshRender(int w, int h, int rank, double *data, int nrows, 		       int ncols, DistLayout *data_layout, double angleX, 		       double angleZ, double camera_zoom) :   TDRender(w, h, rank, data, nrows, ncols, data_layout, 	   angleX, angleZ, camera_zoom) {}bool MeshRender::draw_help(int offset) {  offset = offset * 6;  lx = blocks_data[offset + 0];  ly = blocks_data[offset + 1];  data_nr = blocks_data[offset + 2] - lx + 1;  data_nc = blocks_data[offset + 3] - ly + 1;  if (data_nr <= 1 &&      data_nc <= 1)    return true;  int rOffset = blocks_data[offset + 4];  int cOffset = blocks_data[offset + 5];  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);  draw_surface(rOffset, cOffset);  return false; }void MeshRender::draw_surface(int rOffset, int cOffset) {  double x_const = (double) axes_length / (double) (nc + 1);  double y_const = (double) axes_length / (double) (nr + 1);  double z_interval = maxZ - minZ;  double z_const;  if (z_interval != 0)     z_const = 0.8 * (double) axes_length / z_interval;  else     z_const = 0.;  double color_offset = (NUM_COLORS - 1)/ z_interval;  double z1, z2, z3, z4;  int row, col, color_index;    glBegin(GL_QUAD_STRIP);  row = rOffset;  col = cOffset;    z1 = data_buffer[col * lRows + row];  z2 = data_buffer[(col + data_nc - 1) * lRows + row];  z3 = data_buffer[col * lRows + row + data_nr - 1];  z4 = data_buffer[(col + data_nc - 1) * lRows + row + data_nr - 1];        color_index = FIRST_COLOR + (int) ((z1 - minZ) * color_offset);  assert(color_index < FIRST_COLOR + NUM_COLORS);  glColor3ub(color_index, 0, 0);	    glVertex3f((ly + 1) * x_const, (lx + 1) * y_const, 	     (z1 - minZ) * z_const);  glVertex3f((ly + data_nc + 1) * x_const, (lx + 1) * y_const, 	     (z2 - minZ) * z_const);  glVertex3f((ly + 1) * x_const, (lx + data_nr + 1) * y_const,	     (z3 - minZ) * z_const);  glVertex3f((ly + data_nc + 1) * x_const, (lx + data_nr + 1) * y_const,	     (z4 - minZ) * z_const);    glEnd();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -