cgv
Loading...
Searching...
No Matches
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/cone_renderer.h>
14
15#include "lib_begin.h" // @<
16
17namespace cgv { // @<
18 namespace render { // @<
19 namespace gl { // @<
20
22enum ContouringType { MARCHING_CUBES, DUAL_CONTOURING };
24enum NormalComputationType { GRADIENT_NORMALS, FACE_NORMALS, CORNER_NORMALS, CORNER_GRADIENTS };
25
29 public drawable,
31{
32public: //@<
35private:
36 bool outofdate;
38
41
42 std::vector<vec3> nml_gradient_geometry;
43 std::vector<vec3> nml_mesh_geometry;
44
45protected: //@<
46 //@>
47 unsigned int res;
48 dbox3 box;
49 F* func_ptr;
50 //@>
51 ContouringType contouring_type;
52 //@>
53 double normal_threshold;
54 //@>
55 double consistency_threshold;
56 //@>
57 unsigned int max_nr_iters;
58 //@>
59 NormalComputationType normal_computation_type;
60 //@>
61 unsigned int ix;
62 //@>
63 unsigned int iy;
64 //@>
65 unsigned int iz;
66 //@>
67 bool show_vertices;
68 bool show_wireframe;
69 bool show_surface;
70 //@>
71 bool show_sampling_locations;
72 //@>
73 bool show_sampling_grid;
74 float sampling_grid_alpha;
75 //@>
76 bool show_box;
77 //@>
78 bool show_mini_box;
79 //@>
80 bool show_gradient_normals;
81 //@>
82 bool show_mesh_normals;
83
88
89 //@>
90 double epsilon;
91 //@>
92 double grid_epsilon;
93
94 //@>
95 int nr_faces;
96 //@>
97 int nr_vertices;
100
101 void add_normal(const dvec3& p, const dvec3& n, std::vector<vec3>& nml_gradient_geometry) const;
102
104 void new_vertex(unsigned int vi);
106 void new_polygon(const std::vector<unsigned int>& vertex_indices);
108 void before_drop_vertex(unsigned int vertex_index);
110 bool triangulate;
112 std::ostream* obj_out;
114 unsigned normal_index;
116 bool save(const std::string& file_name);
118 virtual void surface_extraction();
120 dvec3 compute_face_normal(const std::vector<unsigned int> &vis, dvec3* c = 0) const;
122 virtual void extract_mesh();
124 void draw_implicit_surface(context& ctx);
125 dvec3 compute_corner_normal(const dvec3& pk, const dvec3& pi, const dvec3& pj, const dvec3& ni);
126public:
129
130 void set_function(F* _func_ptr);
131 F* get_function() const;
132
133 void set_resolution(unsigned int _res);
134 unsigned int get_resolution() const;
135
136 void enable_wireframe(bool do_enable = true);
137 bool is_wireframe_enabled() const;
138
139 void enable_sampling_grid(bool do_enable = true);
140 bool is_sampling_grid_enabled() const;
141
142 void enable_sampling_locations(bool do_enable = true);
143 bool is_sampling_locations_enabled() const;
144
145 void enable_box(bool do_enable = true);
146 bool is_box_enabled() const;
147
148 void enable_normals(bool do_enable = true);
149 bool are_normals_enabled() const;
150
151 void set_epsilon(double _epsilon);
152 double get_epsilon() const;
153
154 void set_grid_epsilon(double _grid_epsilon);
155 double get_grid_epsilon() const;
156
157 void set_box(const dbox3& _box);
158 const dbox3& get_box() const;
159
160 unsigned int get_nr_triangles_of_last_extraction() const;
161 unsigned int get_nr_vertices_of_last_extraction() const;
162
164 void post_rebuild();
165 bool init(context& ctx);
166 void clear(context& ctx);
167 void draw(context& ctx);
168 void finish_frame(context& ctx);
169
170}; // @<
171
172 } // @<
173 } // @<
174} // @<
175
176#include <cgv/config/lib_end.h> // @<
specialization of a multivariate function to three independent variables, which only reimplements the...
Definition mfunc.h:63
simple class to hold the material properties of a phong material
the simple_mesh class is templated over the coordinate type that defaults to float
class used to perform the marching cubes algorithm
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
base class for all drawables, which is independent of the used rendering API.
Definition drawable.h:15
drawable that visualizes implicit surfaces by contouring them with marching cubes or dual contouring.
std::ostream * obj_out
of this output stream is defined, use it to write currently extracted surface to it
cgv::math::v3_func< double, double > F
type of the function describing the implicit surface
the mesh_render_info structure manages vertex buffer objects for attribute and element buffers as wel...
ContouringType
type of contouring method >
NormalComputationType
normal computation type >
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
the cgv namespace
Definition print.h:11
pure abstract interface to handle callbacks of a streaming mesh
boxes use surface render styles
render style for sphere rendere