123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- #ifndef IGL_VIEWERDATA_H
- #define IGL_VIEWERDATA_H
- #include "../igl_inline.h"
- #include "MeshGL.h"
- #include <cassert>
- #include <cstdint>
- #include <Eigen/Core>
- #include <memory>
- #include <vector>
- namespace igl
- {
- namespace opengl
- {
- class ViewerCore;
- class ViewerData
- {
- public:
- ViewerData();
-
- IGL_INLINE void clear();
-
- IGL_INLINE void set_face_based(bool newvalue);
-
- IGL_INLINE void set_mesh(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F);
- IGL_INLINE void set_vertices(const Eigen::MatrixXd& V);
- IGL_INLINE void set_normals(const Eigen::MatrixXd& N);
- IGL_INLINE void set_visible(bool value, unsigned int core_id = 1);
-
-
-
-
- IGL_INLINE void set_colors(const Eigen::MatrixXd &C);
-
-
-
-
- IGL_INLINE void set_uv(const Eigen::MatrixXd& UV);
-
-
-
-
-
- IGL_INLINE void set_uv(const Eigen::MatrixXd& UV_V, const Eigen::MatrixXi& UV_F);
-
-
-
-
-
-
-
- IGL_INLINE 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);
-
-
-
-
-
-
-
-
- IGL_INLINE 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);
-
-
-
-
-
-
- IGL_INLINE void set_points(
- const Eigen::MatrixXd& P,
- const Eigen::MatrixXd& C);
- IGL_INLINE void add_points(const Eigen::MatrixXd& P, const Eigen::MatrixXd& C);
-
-
-
-
-
-
-
- IGL_INLINE void set_edges (const Eigen::MatrixXd& P, const Eigen::MatrixXi& E, const Eigen::MatrixXd& C);
-
-
- IGL_INLINE void add_edges (const Eigen::MatrixXd& P1, const Eigen::MatrixXd& P2, const Eigen::MatrixXd& C);
-
-
- IGL_INLINE void add_label (const Eigen::VectorXd& P, const std::string& str);
-
- IGL_INLINE void clear_labels ();
-
- IGL_INLINE void compute_normals();
-
- IGL_INLINE void uniform_colors(
- const Eigen::Vector3d& diffuse,
- const Eigen::Vector3d& ambient,
- const Eigen::Vector3d& specular);
-
- IGL_INLINE void uniform_colors(
- const Eigen::Vector4d& ambient,
- const Eigen::Vector4d& diffuse,
- const Eigen::Vector4d& specular);
-
- IGL_INLINE void grid_texture();
-
- IGL_INLINE void copy_options(const ViewerCore &from, const ViewerCore &to);
- Eigen::MatrixXd V;
- Eigen::MatrixXi F;
-
- Eigen::MatrixXd F_normals;
- Eigen::MatrixXd F_material_ambient;
- Eigen::MatrixXd F_material_diffuse;
- Eigen::MatrixXd F_material_specular;
-
- Eigen::MatrixXd V_normals;
- Eigen::MatrixXd V_material_ambient;
- Eigen::MatrixXd V_material_diffuse;
- Eigen::MatrixXd V_material_specular;
-
- Eigen::MatrixXd V_uv;
- Eigen::MatrixXi F_uv;
-
- Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> texture_R;
- Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> texture_G;
- Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> texture_B;
- Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> texture_A;
-
-
-
-
- Eigen::MatrixXd lines;
-
-
-
- Eigen::MatrixXd points;
-
-
-
- Eigen::MatrixXd labels_positions;
- std::vector<std::string> labels_strings;
-
- uint32_t dirty;
-
- bool face_based;
-
- bool invert_normals;
-
-
-
- unsigned int is_visible;
- unsigned int show_overlay;
- unsigned int show_overlay_depth;
- unsigned int show_texture;
- unsigned int show_faces;
- unsigned int show_lines;
- bool show_vertid;
- bool show_faceid;
-
- float point_size;
- float line_width;
- Eigen::Matrix<float, 4, 1, Eigen::DontAlign> line_color;
- Eigen::Matrix<float, 4, 1, Eigen::DontAlign> label_color;
-
- float shininess;
-
- int id;
-
- igl::opengl::MeshGL meshgl;
-
- IGL_INLINE void updateGL(
- const igl::opengl::ViewerData& data,
- const bool invert_normals,
- igl::opengl::MeshGL& meshgl);
- };
- }
- }
- #include <igl/serialize.h>
- namespace igl
- {
- namespace serialization
- {
- inline void serialization(bool s, igl::opengl::ViewerData& obj, std::vector<char>& buffer)
- {
- SERIALIZE_MEMBER(V);
- SERIALIZE_MEMBER(F);
- SERIALIZE_MEMBER(F_normals);
- SERIALIZE_MEMBER(F_material_ambient);
- SERIALIZE_MEMBER(F_material_diffuse);
- SERIALIZE_MEMBER(F_material_specular);
- SERIALIZE_MEMBER(V_normals);
- SERIALIZE_MEMBER(V_material_ambient);
- SERIALIZE_MEMBER(V_material_diffuse);
- SERIALIZE_MEMBER(V_material_specular);
- SERIALIZE_MEMBER(V_uv);
- SERIALIZE_MEMBER(F_uv);
- SERIALIZE_MEMBER(texture_R);
- SERIALIZE_MEMBER(texture_G);
- SERIALIZE_MEMBER(texture_B);
- SERIALIZE_MEMBER(texture_A);
- SERIALIZE_MEMBER(lines);
- SERIALIZE_MEMBER(points);
- SERIALIZE_MEMBER(labels_positions);
- SERIALIZE_MEMBER(labels_strings);
- SERIALIZE_MEMBER(dirty);
- SERIALIZE_MEMBER(face_based);
- SERIALIZE_MEMBER(show_faces);
- SERIALIZE_MEMBER(show_lines);
- SERIALIZE_MEMBER(invert_normals);
- SERIALIZE_MEMBER(show_overlay);
- SERIALIZE_MEMBER(show_overlay_depth);
- SERIALIZE_MEMBER(show_vertid);
- SERIALIZE_MEMBER(show_faceid);
- SERIALIZE_MEMBER(show_texture);
- SERIALIZE_MEMBER(point_size);
- SERIALIZE_MEMBER(line_width);
- SERIALIZE_MEMBER(line_color);
- SERIALIZE_MEMBER(shininess);
- SERIALIZE_MEMBER(id);
- }
- template<>
- inline void serialize(const igl::opengl::ViewerData& obj, std::vector<char>& buffer)
- {
- serialization(true, const_cast<igl::opengl::ViewerData&>(obj), buffer);
- }
- template<>
- inline void deserialize(igl::opengl::ViewerData& obj, const std::vector<char>& buffer)
- {
- serialization(false, obj, const_cast<std::vector<char>&>(buffer));
- obj.dirty = igl::opengl::MeshGL::DIRTY_ALL;
- }
- }
- }
- #ifndef IGL_STATIC_LIBRARY
- # include "ViewerData.cpp"
- #endif
- #endif
|