cgv
gl_implicit_surface_drawable_base.h
1 #pragma once
2 
3 #include <cgv/render/drawable.h>
4 #include "mesh_render_info.h"
5 #include <cgv/math/mfunc.h>
6 #include <cgv/media/axis_aligned_box.h>
7 #include <cgv/media/mesh/simple_mesh.h>
8 #include <cgv/media/mesh/streaming_mesh.h>
9 #include <cgv/media/illum/surface_material.h>
10 #include <cgv_gl/box_renderer.h>
11 #include <cgv_gl/sphere_renderer.h>
12 #include <cgv_gl/arrow_renderer.h>
13 #include <cgv_gl/rounded_cone_renderer.h>
14 
15 #include "lib_begin.h" // @<
16 
17 namespace cgv { // @<
18  namespace render { // @<
19  namespace gl { // @<
20 
22 enum ContouringType { MARCHING_CUBES, DUAL_CONTOURING };
24 enum NormalComputationType { GRADIENT_NORMALS, FACE_NORMALS, CORNER_NORMALS, CORNER_GRADIENTS };
25 
29  public drawable,
31 {
32 public: //@<
39 private:
40  bool outofdate;
42 
44  mesh_render_info mri;
45 
46  std::vector<vec3> nml_gradient_geometry;
47  std::vector<vec3> nml_mesh_geometry;
48 
49 protected: //@<
50  //@>
51  unsigned int res;
52  dbox3 box;
53  F* func_ptr;
54  //@>
55  ContouringType contouring_type;
56  //@>
57  double normal_threshold;
58  //@>
59  double consistency_threshold;
60  //@>
61  unsigned int max_nr_iters;
62  //@>
63  NormalComputationType normal_computation_type;
64  //@>
65  unsigned int ix;
66  //@>
67  unsigned int iy;
68  //@>
69  unsigned int iz;
70  //@>
71  bool show_vertices;
72  bool show_wireframe;
73  bool show_surface;
74  //@>
75  bool show_sampling_locations;
76  //@>
77  bool show_sampling_grid;
78  float sampling_grid_alpha;
79  //@>
80  bool show_box;
81  //@>
82  bool show_mini_box;
83  //@>
84  bool show_gradient_normals;
85  //@>
86  bool show_mesh_normals;
87 
88  box_render_style brs;
90  rounded_cone_render_style crs;
92 
93  //@>
94  double epsilon;
95  //@>
96  double grid_epsilon;
97 
98  //@>
99  int nr_faces;
100  //@>
101  int nr_vertices;
104 
105  void add_normal(const dvec3& p, const dvec3& n, std::vector<vec3>& nml_gradient_geometry) const;
106 
108  void new_vertex(unsigned int vi);
110  void new_polygon(const std::vector<unsigned int>& vertex_indices);
112  void before_drop_vertex(unsigned int vertex_index);
114  bool triangulate;
116  std::ostream* obj_out;
118  unsigned normal_index;
120  bool save(const std::string& file_name);
122  virtual void surface_extraction();
124  dvec3 compute_face_normal(const std::vector<unsigned int> &vis, dvec3* c = 0) const;
126  virtual void extract_mesh();
128  void draw_implicit_surface(context& ctx);
129  dvec3 compute_corner_normal(const dvec3& pk, const dvec3& pi, const dvec3& pj, const dvec3& ni);
130 public:
133 
134  void set_function(F* _func_ptr);
135  F* get_function() const;
136 
137  void set_resolution(unsigned int _res);
138  unsigned int get_resolution() const;
139 
140  void enable_wireframe(bool do_enable = true);
141  bool is_wireframe_enabled() const;
142 
143  void enable_sampling_grid(bool do_enable = true);
144  bool is_sampling_grid_enabled() const;
145 
146  void enable_sampling_locations(bool do_enable = true);
147  bool is_sampling_locations_enabled() const;
148 
149  void enable_box(bool do_enable = true);
150  bool is_box_enabled() const;
151 
152  void enable_normals(bool do_enable = true);
153  bool are_normals_enabled() const;
154 
155  void set_epsilon(double _epsilon);
156  double get_epsilon() const;
157 
158  void set_grid_epsilon(double _grid_epsilon);
159  double get_grid_epsilon() const;
160 
161  void set_box(const dbox3& _box);
162  const dbox3& get_box() const;
163 
164  unsigned int get_nr_triangles_of_last_extraction() const;
165  unsigned int get_nr_vertices_of_last_extraction() const;
166 
168  void post_rebuild();
169  bool init(context& ctx);
170  void clear(context& ctx);
171  void draw(context& ctx);
172  void finish_frame(context& ctx);
173 
174 }; // @<
175 
176  } // @<
177  } // @<
178 } // @<
179 
180 #include <cgv/config/lib_end.h> // @<
cgv::render::box_render_style
boxes use surface render styles
Definition: box_renderer.h:19
cgv::render::sphere_render_style
Definition: sphere_renderer.h:19
cgv::math::fvec< double, 3 >
cgv::render::gl::gl_implicit_surface_drawable_base::dbox3
cgv::media::axis_aligned_box< double, 3 > dbox3
type of axis aligned box used to define the tesselation domain
Definition: gl_implicit_surface_drawable_base.h:36
cgv::math::vec
A column vector class.
Definition: fvec.h:13
cgv::render::gl::gl_implicit_surface_drawable_base::F
cgv::math::v3_func< double, double > F
type of the function describing the implicit surface
Definition: gl_implicit_surface_drawable_base.h:34
cgv::render::gl::gl_implicit_surface_drawable_base
Definition: gl_implicit_surface_drawable_base.h:31
cgv::math::v3_func
Definition: mfunc.h:63
cgv::media::mesh::streaming_mesh_callback_handler
Definition: streaming_mesh.h:13
cgv::render::gl::NormalComputationType
NormalComputationType
normal computation type >
Definition: gl_implicit_surface_drawable_base.h:24
cgv::media::axis_aligned_box< double, 3 >
cgv::media::illum::surface_material
simple class to hold the material properties of a phong material
Definition: surface_material.h:26
cgv::media::mesh::streaming_mesh< double >
cgv::render::drawable
Definition: drawable.h:15
cgv::media::mesh::simple_mesh< float >
cgv::render::mesh_render_info
Definition: mesh_render_info.h:16
cgv::render::gl::gl_implicit_surface_drawable_base::normal_index
unsigned normal_index
normal index for face normals
Definition: gl_implicit_surface_drawable_base.h:118
cgv::render::gl::ContouringType
ContouringType
type of contouring method >
Definition: gl_implicit_surface_drawable_base.h:22
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::render::extract_mesh
void extract_mesh(const std::string &file_name, const fx::gltf::Document &doc, cgv::media::mesh::simple_mesh< float > &mesh, int mesh_index, int primitive_index)
extract simple mesh form gltf document
Definition: gltf_support.cxx:328
cgv::render::context
Definition: context.h:525
cgv::render::gl::gl_implicit_surface_drawable_base::obj_out
std::ostream * obj_out
of this output stream is defined, use it to write currently extracted surface to it
Definition: gl_implicit_surface_drawable_base.h:116
cgv::render::arrow_render_style
Definition: arrow_renderer.h:19