libigl v2.5.0
Loading...
Searching...
No Matches
igl::opengl::ViewerData Class Reference

Object being drawn (i.e., mesh and its accessories) by the ViewerCore. More...

#include <ViewerData.h>

Public Member Functions

 ViewerData ()
 
void clear ()
 Empty all fields.
 
void set_face_based (bool newvalue)
 Change whether drawing per-vertex or per-face; invalidating cache if necessary.
 
void set_mesh (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
 Set the current mesh.
 
void set_vertices (const Eigen::MatrixXd &V)
 Set just the vertices.
 
void set_normals (const Eigen::MatrixXd &N)
 Set the normals of a mesh.
 
void set_visible (bool value, unsigned int core_id=1)
 Set whether this object is visible.
 
void set_colors (const Eigen::MatrixXd &C)
 Set the diffuse color of the mesh.
 
void set_uv (const Eigen::MatrixXd &UV)
 Set per-vertex UV coordinates.
 
void set_uv (const Eigen::MatrixXd &UV_V, const Eigen::MatrixXi &UV_F)
 Set per-corner UV coordinates.
 
void set_texture (const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &R, const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &G, const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &B, const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &A)
 Set the texture associated with the mesh.
 
void set_texture (const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &R, const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &G, const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &B)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void set_data (const Eigen::VectorXd &D, double caxis_min, double caxis_max, igl::ColorMapType cmap=igl::COLOR_MAP_TYPE_VIRIDIS, int num_steps=21)
 Set pseudo-color-able scalar data associated with the mesh.
 
void set_data (const Eigen::VectorXd &D, igl::ColorMapType cmap=igl::COLOR_MAP_TYPE_VIRIDIS, int num_steps=21)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void set_colormap (const Eigen::MatrixXd &CM)
 Not to be confused with set_colors, this creates a texture that will be referenced to pseudocolor according to the scalar field passed to set_data.
 
void set_points (const Eigen::MatrixXd &P, const Eigen::MatrixXd &C)
 Sets points given a list of point vertices.
 
void add_points (const Eigen::MatrixXd &P, const Eigen::MatrixXd &C)
 Add points given a list of point vertices.
 
void clear_points ()
 Clear the point data.
 
void set_edges (const Eigen::MatrixXd &P, const Eigen::MatrixXi &E, const Eigen::MatrixXd &C)
 Sets edges given a list of edge vertices and edge indices.
 
void add_edges (const Eigen::MatrixXd &P1, const Eigen::MatrixXd &P2, const Eigen::MatrixXd &C)
 Add edges given a list of edge start and end positions and colors.
 
void set_edges_from_vector_field (const Eigen::MatrixXd &P, const Eigen::MatrixXd &V, const Eigen::MatrixXd &C)
 Sets edges given a list of points and eminating vectors.
 
void clear_edges ()
 Clear the edge data.
 
void set_labels (const Eigen::MatrixXd &P, const std::vector< std::string > &str)
 Sets / Adds text labels at the given positions in 3D.
 
void add_label (const Eigen::VectorXd &P, const std::string &str)
 Sets / Adds text labels at the given positions in 3D.
 
void clear_labels ()
 Clear the label data.
 
void compute_normals ()
 Computes the normals of the mesh.
 
void uniform_colors (const Eigen::Vector3d &ambient, const Eigen::Vector3d &diffuse, const Eigen::Vector3d &specular)
 Assigns uniform colors to all faces/vertices.
 
void uniform_colors (const Eigen::Vector4d &ambient, const Eigen::Vector4d &diffuse, const Eigen::Vector4d &specular)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void normal_matcap ()
 Generate a normal image matcap.
 
void grid_texture ()
 Generates a default grid texture (without uvs)
 
void copy_options (const ViewerCore &from, const ViewerCore &to)
 Copy visualization options from one viewport to another.
 
void update_labels (igl::opengl::MeshGL::TextGL &GL_labels, const Eigen::MatrixXd &positions, const std::vector< std::string > &strings)
 Update contents from a 'Data' instance.
 
void updateGL (const igl::opengl::ViewerData &data, const bool invert_normals, igl::opengl::MeshGL &meshgl)
 Update the meshgl object.
 

Public Attributes

Eigen::MatrixXd V
 Vertices of the current mesh (V x 3)
 
Eigen::MatrixXi F
 Faces of the mesh (F x 3)
 
Eigen::MatrixXd F_normals
 One normal per face.
 
Eigen::MatrixXd F_material_ambient
 Per face ambient color.
 
Eigen::MatrixXd F_material_diffuse
 Per face diffuse color.
 
Eigen::MatrixXd F_material_specular
 Per face specular color.
 
Eigen::MatrixXd V_normals
 One normal per vertex.
 
Eigen::MatrixXd V_material_ambient
 Per vertex ambient color.
 
Eigen::MatrixXd V_material_diffuse
 Per vertex diffuse color.
 
Eigen::MatrixXd V_material_specular
 Per vertex specular color.
 
Eigen::MatrixXd V_uv
 UV vertices.
 
Eigen::MatrixXi F_uv
 optional faces for UVs
 
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > texture_R
 Texture red colors.
 
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > texture_G
 Texture green colors.
 
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > texture_B
 Texture blue colors.
 
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > texture_A
 Texture alpha values.
 
Eigen::MatrixXd lines
 Lines plotted over the scene (Every row contains 9 doubles in the following format S_x, S_y, S_z, T_x, T_y, T_z, C_r, C_g, C_b),.
 
Eigen::MatrixXd points
 Points plotted over the scene (Every row contains 6 doubles in the following format P_x, P_y, P_z, C_r, C_g, C_b), with P the position in global coordinates of the center of the point, and C the color in floating point rgb format.
 
Eigen::MatrixXd vertex_labels_positions
 Text positions of vertices.
 
Eigen::MatrixXd face_labels_positions
 Text positions of faces.
 
Eigen::MatrixXd labels_positions
 Text positions of labels.
 
std::vector< std::string > vertex_labels_strings
 Text strings of labels at vertices.
 
std::vector< std::string > face_labels_strings
 Text strings of labels at faces.
 
std::vector< std::string > labels_strings
 Text strings of labels.
 
uint32_t dirty
 Marks dirty buffers that need to be uploaded to OpenGL.
 
bool face_based
 Enable per-face or per-vertex properties.
 
bool double_sided
 Enable double-sided lighting on faces.
 
bool invert_normals
 Invert mesh normals.
 
unsigned int is_visible
 Visualization options Each option is a binary mask specifying on which viewport each option is set.
 
unsigned int show_custom_labels
 
unsigned int show_face_labels
 
unsigned int show_faces
 
unsigned int show_lines
 
unsigned int show_overlay
 
unsigned int show_overlay_depth
 
unsigned int show_texture
 
unsigned int show_vertex_labels
 
unsigned int use_matcap
 
float point_size
 Point size / line width.
 
float line_width
 line_width is NOT SUPPORTED on Mac OS and Windows
 
float label_size
 Size of lables.
 
Eigen::Matrix< float, 4, 1, Eigen::DontAlign > line_color
 Color of lines.
 
Eigen::Matrix< float, 4, 1, Eigen::DontAlign > label_color
 Color of labels.
 
float shininess
 Shape material shininess.
 
int id
 Unique identifier.
 
igl::opengl::MeshGL meshgl
 OpenGL representation of the mesh.
 

Detailed Description

Object being drawn (i.e., mesh and its accessories) by the ViewerCore.

Warning
Eigen data members (such as Eigen::Vector4f) should explicitly disable alignment (e.g. use Eigen::Matrix<float, 4, 1, Eigen::DontAlign>), in order to avoid alignment issues further down the line (esp. if the structure are stored in a std::vector).

See this thread for a more detailed discussion: https://github.com/libigl/libigl/pull/1029

Constructor & Destructor Documentation

◆ ViewerData()

igl::opengl::ViewerData::ViewerData ( )

Member Function Documentation

◆ clear()

void igl::opengl::ViewerData::clear ( )

Empty all fields.

◆ set_face_based()

void igl::opengl::ViewerData::set_face_based ( bool  newvalue)

Change whether drawing per-vertex or per-face; invalidating cache if necessary.

Parameters
[in]newvaluewhether face based

◆ set_mesh()

void igl::opengl::ViewerData::set_mesh ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F 
)

Set the current mesh.

Call this once at the beginning and whenever both the vertices and faces are changing.

Parameters
[in]VV by 3 list of mesh vertex positions
[in]FF by 3/4 list of mesh faces (triangles/tets)

◆ set_vertices()

void igl::opengl::ViewerData::set_vertices ( const Eigen::MatrixXd &  V)

Set just the vertices.

Call this if just the vertices are changing. You may need to call compute_normals to update the lighting correctly.

Parameters
[in]VV by 3 list of mesh vertex positions

◆ set_normals()

void igl::opengl::ViewerData::set_normals ( const Eigen::MatrixXd &  N)

Set the normals of a mesh.

Parameters
[in]NV|F|3F by 3 list of mesh normals
See also
compute_normals

◆ set_visible()

void igl::opengl::ViewerData::set_visible ( bool  value,
unsigned int  core_id = 1 
)

Set whether this object is visible.

Parameters
[in]valuetrue iff this object is visible
[in]core_idIndex of the core to set (default is 0)

◆ set_colors()

void igl::opengl::ViewerData::set_colors ( const Eigen::MatrixXd &  C)

Set the diffuse color of the mesh.

The ambient color will be set to 0.1*C and the specular color will be set to 0.3+0.1*(C-0.3).

Parameters
[in]CV|F|1 by 3 list of diffuse colors

◆ set_uv() [1/2]

void igl::opengl::ViewerData::set_uv ( const Eigen::MatrixXd &  UV)

Set per-vertex UV coordinates.

Parameters
[in]UVV by 2 list of UV coordinates (indexed by F)

◆ set_uv() [2/2]

void igl::opengl::ViewerData::set_uv ( const Eigen::MatrixXd &  UV_V,
const Eigen::MatrixXi &  UV_F 
)

Set per-corner UV coordinates.

Parameters
[in]UV_V#UV by 2 list of UV coordinates
[in]UV_FF by 3 list of UV indices into UV_V

◆ set_texture() [1/2]

void igl::opengl::ViewerData::set_texture ( const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  R,
const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  G,
const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  B,
const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  A 
)

Set the texture associated with the mesh.

Parameters
[in]Rwidth by height image matrix of red channel
[in]Gwidth by height image matrix of green channel
[in]Bwidth by height image matrix of blue channel
[in]Awidth by height image matrix of alpha channel

◆ set_texture() [2/2]

void igl::opengl::ViewerData::set_texture ( const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  R,
const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  G,
const Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  B 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ set_data() [1/2]

void igl::opengl::ViewerData::set_data ( const Eigen::VectorXd &  D,
double  caxis_min,
double  caxis_max,
igl::ColorMapType  cmap = igl::COLOR_MAP_TYPE_VIRIDIS,
int  num_steps = 21 
)

Set pseudo-color-able scalar data associated with the mesh.

Parameters
[in]caxis_mincaxis minimum bound
[in]caxis_maxcaxis maximum bound
[in]DV|F by 1 list of scalar values
[in]cmapcolormap type
[in]num_stepsnumber of intervals to discretize the colormap

◆ set_data() [2/2]

void igl::opengl::ViewerData::set_data ( const Eigen::VectorXd &  D,
igl::ColorMapType  cmap = igl::COLOR_MAP_TYPE_VIRIDIS,
int  num_steps = 21 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Use min(D) and max(D) to set caxis.

◆ set_colormap()

void igl::opengl::ViewerData::set_colormap ( const Eigen::MatrixXd &  CM)

Not to be confused with set_colors, this creates a texture that will be referenced to pseudocolor according to the scalar field passed to set_data.

Parameters
[in]CM#CM by 3 list of colors

◆ set_points()

void igl::opengl::ViewerData::set_points ( const Eigen::MatrixXd &  P,
const Eigen::MatrixXd &  C 
)

Sets points given a list of point vertices.

In constrast to add_points this will (purposefully) clober existing points.

Parameters
[in]P#P by 3 list of vertex positions
[in]C#P|1 by 3 color(s)

◆ add_points()

void igl::opengl::ViewerData::add_points ( const Eigen::MatrixXd &  P,
const Eigen::MatrixXd &  C 
)

Add points given a list of point vertices.

Parameters
[in]P#P by 3 list of vertex positions
[in]C#P|1 by 3 color(s)

◆ clear_points()

void igl::opengl::ViewerData::clear_points ( )

Clear the point data.

◆ set_edges()

void igl::opengl::ViewerData::set_edges ( const Eigen::MatrixXd &  P,
const Eigen::MatrixXi &  E,
const Eigen::MatrixXd &  C 
)

Sets edges given a list of edge vertices and edge indices.

In constrast to add_edges this will (purposefully) clober existing edges.

Parameters
[in]P#P by 3 list of vertex positions
[in]E#E by 2 list of edge indices into P
[in]C#E|1 by 3 color(s)

◆ add_edges()

void igl::opengl::ViewerData::add_edges ( const Eigen::MatrixXd &  P1,
const Eigen::MatrixXd &  P2,
const Eigen::MatrixXd &  C 
)

Add edges given a list of edge start and end positions and colors.

Parameters
[in]P1#P by 3 list of edge start positions
[in]P2#P by 3 list of edge end positions
[in]C#P|1 by 3 color(s)
Note
This is very confusing. Why does add_edges have a different API from set_edges?

◆ set_edges_from_vector_field()

void igl::opengl::ViewerData::set_edges_from_vector_field ( const Eigen::MatrixXd &  P,
const Eigen::MatrixXd &  V,
const Eigen::MatrixXd &  C 
)

Sets edges given a list of points and eminating vectors.

Parameters
[in]P#P by 3 list of vertex positions
[in]V#P by 3 list of eminating vectors
[in]C#P|1 by 3 color(s)

◆ clear_edges()

void igl::opengl::ViewerData::clear_edges ( )

Clear the edge data.

◆ set_labels()

void igl::opengl::ViewerData::set_labels ( const Eigen::MatrixXd &  P,
const std::vector< std::string > &  str 
)

Sets / Adds text labels at the given positions in 3D.

Parameters
[in]P#P by 3 list of vertex positions
[in]str#P list of text labels
Note
This requires the ImGui viewer plugin to display text labels.

◆ add_label()

void igl::opengl::ViewerData::add_label ( const Eigen::VectorXd &  P,
const std::string &  str 
)

Sets / Adds text labels at the given positions in 3D.

Parameters
[in]P3D position of the label
[in]strtext label

◆ clear_labels()

void igl::opengl::ViewerData::clear_labels ( )

Clear the label data.

◆ compute_normals()

void igl::opengl::ViewerData::compute_normals ( )

Computes the normals of the mesh.

◆ uniform_colors() [1/2]

void igl::opengl::ViewerData::uniform_colors ( const Eigen::Vector3d &  ambient,
const Eigen::Vector3d &  diffuse,
const Eigen::Vector3d &  specular 
)

Assigns uniform colors to all faces/vertices.

Parameters
[in]ambientambient color
[in]diffusediffuse color
[in]specularspecular color

◆ uniform_colors() [2/2]

void igl::opengl::ViewerData::uniform_colors ( const Eigen::Vector4d &  ambient,
const Eigen::Vector4d &  diffuse,
const Eigen::Vector4d &  specular 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ normal_matcap()

void igl::opengl::ViewerData::normal_matcap ( )

Generate a normal image matcap.

◆ grid_texture()

void igl::opengl::ViewerData::grid_texture ( )

Generates a default grid texture (without uvs)

◆ copy_options()

void igl::opengl::ViewerData::copy_options ( const ViewerCore from,
const ViewerCore to 
)

Copy visualization options from one viewport to another.

Parameters
[in]fromsource viewport
[in]todestination viewport

◆ update_labels()

void igl::opengl::ViewerData::update_labels ( igl::opengl::MeshGL::TextGL GL_labels,
const Eigen::MatrixXd &  positions,
const std::vector< std::string > &  strings 
)

Update contents from a 'Data' instance.

Parameters
[in,out]GL_labelslabels to be updated
[in]positionspositions of the labels
[in]stringsstrings of the labels

◆ updateGL()

void igl::opengl::ViewerData::updateGL ( const igl::opengl::ViewerData data,
const bool  invert_normals,
igl::opengl::MeshGL meshgl 
)

Update the meshgl object.

Parameters
[in]datadata to be used for the update
[in]invert_normalswhether to invert normals
[in,out]meshglmesh to be updated

Member Data Documentation

◆ V

Eigen::MatrixXd igl::opengl::ViewerData::V

Vertices of the current mesh (V x 3)

◆ F

Eigen::MatrixXi igl::opengl::ViewerData::F

Faces of the mesh (F x 3)

◆ F_normals

Eigen::MatrixXd igl::opengl::ViewerData::F_normals

One normal per face.

◆ F_material_ambient

Eigen::MatrixXd igl::opengl::ViewerData::F_material_ambient

Per face ambient color.

◆ F_material_diffuse

Eigen::MatrixXd igl::opengl::ViewerData::F_material_diffuse

Per face diffuse color.

◆ F_material_specular

Eigen::MatrixXd igl::opengl::ViewerData::F_material_specular

Per face specular color.

◆ V_normals

Eigen::MatrixXd igl::opengl::ViewerData::V_normals

One normal per vertex.

◆ V_material_ambient

Eigen::MatrixXd igl::opengl::ViewerData::V_material_ambient

Per vertex ambient color.

◆ V_material_diffuse

Eigen::MatrixXd igl::opengl::ViewerData::V_material_diffuse

Per vertex diffuse color.

◆ V_material_specular

Eigen::MatrixXd igl::opengl::ViewerData::V_material_specular

Per vertex specular color.

◆ V_uv

Eigen::MatrixXd igl::opengl::ViewerData::V_uv

UV vertices.

◆ F_uv

Eigen::MatrixXi igl::opengl::ViewerData::F_uv

optional faces for UVs

◆ texture_R

Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> igl::opengl::ViewerData::texture_R

Texture red colors.

◆ texture_G

Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> igl::opengl::ViewerData::texture_G

Texture green colors.

◆ texture_B

Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> igl::opengl::ViewerData::texture_B

Texture blue colors.

◆ texture_A

Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> igl::opengl::ViewerData::texture_A

Texture alpha values.

◆ lines

Eigen::MatrixXd igl::opengl::ViewerData::lines

Lines plotted over the scene (Every row contains 9 doubles in the following format S_x, S_y, S_z, T_x, T_y, T_z, C_r, C_g, C_b),.

◆ points

Eigen::MatrixXd igl::opengl::ViewerData::points

Points plotted over the scene (Every row contains 6 doubles in the following format P_x, P_y, P_z, C_r, C_g, C_b), with P the position in global coordinates of the center of the point, and C the color in floating point rgb format.

◆ vertex_labels_positions

Eigen::MatrixXd igl::opengl::ViewerData::vertex_labels_positions

Text positions of vertices.

◆ face_labels_positions

Eigen::MatrixXd igl::opengl::ViewerData::face_labels_positions

Text positions of faces.

◆ labels_positions

Eigen::MatrixXd igl::opengl::ViewerData::labels_positions

Text positions of labels.

◆ vertex_labels_strings

std::vector<std::string> igl::opengl::ViewerData::vertex_labels_strings

Text strings of labels at vertices.

◆ face_labels_strings

std::vector<std::string> igl::opengl::ViewerData::face_labels_strings

Text strings of labels at faces.

◆ labels_strings

std::vector<std::string> igl::opengl::ViewerData::labels_strings

Text strings of labels.

◆ dirty

uint32_t igl::opengl::ViewerData::dirty

Marks dirty buffers that need to be uploaded to OpenGL.

◆ face_based

bool igl::opengl::ViewerData::face_based

Enable per-face or per-vertex properties.

◆ double_sided

bool igl::opengl::ViewerData::double_sided

Enable double-sided lighting on faces.

◆ invert_normals

bool igl::opengl::ViewerData::invert_normals

Invert mesh normals.

◆ is_visible

unsigned int igl::opengl::ViewerData::is_visible

Visualization options Each option is a binary mask specifying on which viewport each option is set.

When using a single viewport, standard boolean can still be used for simplicity.

◆ show_custom_labels

unsigned int igl::opengl::ViewerData::show_custom_labels

◆ show_face_labels

unsigned int igl::opengl::ViewerData::show_face_labels

◆ show_faces

unsigned int igl::opengl::ViewerData::show_faces

◆ show_lines

unsigned int igl::opengl::ViewerData::show_lines

◆ show_overlay

unsigned int igl::opengl::ViewerData::show_overlay

◆ show_overlay_depth

unsigned int igl::opengl::ViewerData::show_overlay_depth

◆ show_texture

unsigned int igl::opengl::ViewerData::show_texture

◆ show_vertex_labels

unsigned int igl::opengl::ViewerData::show_vertex_labels

◆ use_matcap

unsigned int igl::opengl::ViewerData::use_matcap

◆ point_size

float igl::opengl::ViewerData::point_size

Point size / line width.

◆ line_width

float igl::opengl::ViewerData::line_width

line_width is NOT SUPPORTED on Mac OS and Windows

◆ label_size

float igl::opengl::ViewerData::label_size

Size of lables.

◆ line_color

Eigen::Matrix<float, 4, 1, Eigen::DontAlign> igl::opengl::ViewerData::line_color

Color of lines.

◆ label_color

Eigen::Matrix<float, 4, 1, Eigen::DontAlign> igl::opengl::ViewerData::label_color

Color of labels.

◆ shininess

float igl::opengl::ViewerData::shininess

Shape material shininess.

◆ id

int igl::opengl::ViewerData::id

Unique identifier.

◆ meshgl

igl::opengl::MeshGL igl::opengl::ViewerData::meshgl

OpenGL representation of the mesh.


The documentation for this class was generated from the following file: