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 renderers_reffed = false;
37 bool outofdate;
39
42
43 std::vector<vec3> nml_gradient_geometry;
44 std::vector<vec3> nml_mesh_geometry;
45
46protected: //@<
47 //@>
48 unsigned int res;
49 dbox3 box;
50 F* func_ptr;
51 //@>
52 ContouringType contouring_type;
53 //@>
54 double normal_threshold;
55 //@>
56 double consistency_threshold;
57 //@>
58 unsigned int max_nr_iters;
59 //@>
60 NormalComputationType normal_computation_type;
61 //@>
62 unsigned int ix;
63 //@>
64 unsigned int iy;
65 //@>
66 unsigned int iz;
67 //@>
68 bool show_vertices;
69 bool show_wireframe;
70 bool show_surface;
71 //@>
72 bool show_sampling_locations;
73 //@>
74 bool show_sampling_grid;
75 float sampling_grid_alpha;
76 //@>
77 bool show_box;
78 //@>
79 bool show_mini_box;
80 //@>
81 bool show_gradient_normals;
82 //@>
83 bool show_mesh_normals;
84
89
90 //@>
91 double epsilon;
92 //@>
93 double grid_epsilon;
94
95 //@>
96 int nr_faces;
97 //@>
98 int nr_vertices;
101
102 void add_normal(const dvec3& p, const dvec3& n, std::vector<vec3>& nml_gradient_geometry) const;
103
105 void new_vertex(unsigned int vi);
107 void new_polygon(const std::vector<unsigned int>& vertex_indices);
109 void before_drop_vertex(unsigned int vertex_index);
111 bool triangulate;
113 std::ostream* obj_out;
115 unsigned normal_index;
117 bool save(const std::string& file_name);
119 virtual void surface_extraction();
121 dvec3 compute_face_normal(const std::vector<unsigned int> &vis, dvec3* c = 0) const;
123 virtual void extract_mesh();
125 void draw_implicit_surface(context& ctx);
126 dvec3 compute_corner_normal(const dvec3& pk, const dvec3& pi, const dvec3& pj, const dvec3& ni);
127public:
130
131 void set_function(F* _func_ptr);
132 F* get_function() const;
133
134 void set_resolution(unsigned int _res);
135 unsigned int get_resolution() const;
136
137 void enable_wireframe(bool do_enable = true);
138 bool is_wireframe_enabled() const;
139
140 void enable_sampling_grid(bool do_enable = true);
141 bool is_sampling_grid_enabled() const;
142
143 void enable_sampling_locations(bool do_enable = true);
144 bool is_sampling_locations_enabled() const;
145
146 void enable_box(bool do_enable = true);
147 bool is_box_enabled() const;
148
149 void enable_normals(bool do_enable = true);
150 bool are_normals_enabled() const;
151
152 void set_epsilon(double _epsilon);
153 double get_epsilon() const;
154
155 void set_grid_epsilon(double _grid_epsilon);
156 double get_grid_epsilon() const;
157
158 void set_box(const dbox3& _box);
159 const dbox3& get_box() const;
160
161 unsigned int get_nr_triangles_of_last_extraction() const;
162 unsigned int get_nr_vertices_of_last_extraction() const;
163
165 void post_rebuild();
166 bool init(context& ctx);
167 void clear(context& ctx);
168 void draw(context& ctx);
169 void finish_frame(context& ctx);
170
171}; // @<
172
173 } // @<
174 } // @<
175} // @<
176
177#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:626
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