cgv
|
drawable that visualizes implicit surfaces by contouring them with marching cubes or dual contouring. More...
#include <gl_implicit_surface_drawable_base.h>
Public Types | |
typedef cgv::math::v3_func< double, double > | F |
type of the function describing the implicit surface | |
Public Member Functions | |
gl_implicit_surface_drawable_base () | |
standard constructor does not initialize the function pointer such that nothing is drawn | |
void | set_function (F *_func_ptr) |
F * | get_function () const |
void | set_resolution (unsigned int _res) |
unsigned int | get_resolution () const |
void | enable_wireframe (bool do_enable=true) |
bool | is_wireframe_enabled () const |
void | enable_sampling_grid (bool do_enable=true) |
bool | is_sampling_grid_enabled () const |
void | enable_sampling_locations (bool do_enable=true) |
bool | is_sampling_locations_enabled () const |
void | enable_box (bool do_enable=true) |
bool | is_box_enabled () const |
void | enable_normals (bool do_enable=true) |
bool | are_normals_enabled () const |
void | set_epsilon (double _epsilon) |
double | get_epsilon () const |
void | set_grid_epsilon (double _grid_epsilon) |
double | get_grid_epsilon () const |
void | set_box (const dbox3 &_box) |
const dbox3 & | get_box () const |
unsigned int | get_nr_triangles_of_last_extraction () const |
unsigned int | get_nr_vertices_of_last_extraction () const |
void | post_rebuild () |
use this as callback to ask for a re-tesselation of the implicit surface | |
bool | init (context &ctx) |
this method is called after creation or recreation of the context, return whether all necessary functionality is supported | |
void | clear (context &ctx) |
clear all objects living in the context like textures or display lists | |
void | draw (context &ctx) |
overload to draw the content of this drawable | |
void | finish_frame (context &ctx) |
this method is called in one pass over all drawables after drawing | |
![]() | |
drawable () | |
default construction | |
void | hide () |
hide the drawable | |
void | show () |
show the drawable | |
bool | is_visible () const |
check whether the drawable is visible | |
context * | get_context () const |
access the current context. The context will be available latestly in the init method but not in the contructor. | |
void | set_context (context *_ctx) |
set the current focus context, this should only be called by the context itself | |
view * | find_view_as_node (size_t view_idx=0) const |
convenience function to find the view control in the current hierarchy | |
bool | get_world_location (int x, int y, const view &V, dvec3 &world_location, double *window_z_ptr=0) const |
use given view together with depth buffer of context in order to compute the world location of the point at mouse pointer location (x,y) | |
void | post_redraw () |
posts a redraw event to the current context if one is available | |
void | force_redraw () |
forces a redraw right now. This cannot be called from init, init_frame, draw, finish_draw, finish_frame and clear | |
virtual void | resize (unsigned int w, unsigned int h) |
callback to announce resizing of the output window | |
virtual void | init_frame (context &) |
this method is called in one pass over all drawables before the draw method | |
virtual void | finish_draw (context &) |
this method is called when the current drawable is left in a tree traversal that calls the draw method | |
virtual void | after_finish (context &) |
this method is called in one pass over all drawables after finish frame | |
![]() | |
traverse_policy (int _policy=TP_ALL+TP_STOP_ON_SUCCESS, bool _active=true, int _focus=-1) | |
construct default traverse policy that visits everything | |
int | get_policy () const |
return the policy without the stop on success flag | |
bool | stop_on_success () const |
return whether to stop on success | |
bool | stop_on_failure () const |
return whether to stop on failure | |
void | set_policy (int _policy) |
set a new policy, always add stop on success flag if needed | |
int | get_focused_child () const |
return the focused child or -1 if none is focused | |
void | set_focused_child (int _focused_child) |
set the focused child | |
bool | get_active () const |
return whether the current node is active | |
void | set_active (bool _active) |
set the active flag of the current node | |
Protected Member Functions | |
void | add_normal (const dvec3 &p, const dvec3 &n, std::vector< vec3 > &nml_gradient_geometry) const |
void | new_vertex (unsigned int vi) |
allows to augment a newly computed vertex by additional data | |
void | new_polygon (const std::vector< unsigned int > &vertex_indices) |
announces a new quad | |
void | before_drop_vertex (unsigned int vertex_index) |
drop the currently first vertex that has the given global vertex index | |
bool | save (const std::string &file_name) |
function used to save to obj file | |
virtual void | surface_extraction () |
call the selected surface extraction method | |
dvec3 | compute_face_normal (const std::vector< unsigned int > &vis, dvec3 *c=0) const |
compute the normal of a face | |
virtual void | extract_mesh () |
helper function to extract mesh from implicit surface | |
void | draw_implicit_surface (context &ctx) |
helper function to tesselate the implicit surface | |
dvec3 | compute_corner_normal (const dvec3 &pk, const dvec3 &pi, const dvec3 &pj, const dvec3 &ni) |
Protected Attributes | |
unsigned int | res |
dbox3 | box |
F * | func_ptr |
ContouringType | contouring_type |
double | normal_threshold |
double | consistency_threshold |
unsigned int | max_nr_iters |
NormalComputationType | normal_computation_type |
unsigned int | ix |
unsigned int | iy |
unsigned int | iz |
bool | show_vertices |
bool | show_wireframe |
bool | show_surface |
bool | show_sampling_locations |
bool | show_sampling_grid |
float | sampling_grid_alpha |
bool | show_box |
bool | show_mini_box |
bool | show_gradient_normals |
bool | show_mesh_normals |
box_render_style | brs |
sphere_render_style | srs |
cone_render_style | crs |
arrow_render_style | ars |
double | epsilon |
double | grid_epsilon |
int | nr_faces |
int | nr_vertices |
cgv::media::illum::surface_material | material |
bool | triangulate |
std::ostream * | obj_out |
of this output stream is defined, use it to write currently extracted surface to it | |
unsigned | normal_index |
normal index for face normals | |
![]() | |
TraversePolicy | policy |
bool | active |
int | focus |
drawable that visualizes implicit surfaces by contouring them with marching cubes or dual contouring.
>
Definition at line 28 of file gl_implicit_surface_drawable_base.h.
typedef cgv::math::v3_func<double,double> cgv::render::gl::gl_implicit_surface_drawable_base::F |
type of the function describing the implicit surface
Definition at line 34 of file gl_implicit_surface_drawable_base.h.
cgv::render::gl::gl_implicit_surface_drawable_base::gl_implicit_surface_drawable_base | ( | ) |
standard constructor does not initialize the function pointer such that nothing is drawn
Definition at line 20 of file gl_implicit_surface_drawable_base.cxx.
References cgv::render::surface_render_style::culling_mode, cgv::render::surface_render_style::illumination_mode, cgv::render::surface_render_style::map_color_to_material, obj_out, cgv::render::cone_render_style::radius, cgv::render::sphere_render_style::radius, and cgv::render::surface_render_style::surface_color.
|
protected |
Definition at line 216 of file gl_implicit_surface_drawable_base.cxx.
bool cgv::render::gl::gl_implicit_surface_drawable_base::are_normals_enabled | ( | ) | const |
Definition at line 158 of file gl_implicit_surface_drawable_base.cxx.
|
protectedvirtual |
drop the currently first vertex that has the given global vertex index
Implements cgv::media::mesh::streaming_mesh_callback_handler.
Definition at line 345 of file gl_implicit_surface_drawable_base.cxx.
|
virtual |
clear all objects living in the context like textures or display lists
Reimplemented from cgv::render::drawable.
Definition at line 434 of file gl_implicit_surface_drawable_base.cxx.
References cgv::render::ref_arrow_renderer(), cgv::render::ref_box_renderer(), cgv::render::ref_cone_renderer(), and cgv::render::ref_sphere_renderer().
|
protected |
Definition at line 349 of file gl_implicit_surface_drawable_base.cxx.
|
protected |
compute the normal of a face
Definition at line 326 of file gl_implicit_surface_drawable_base.cxx.
References cgv::math::fvec< T, N >::normalize(), cgv::math::fvec< T, N >::size(), and cgv::media::mesh::streaming_mesh< T >::vertex_location().
Referenced by new_polygon().
|
virtual |
overload to draw the content of this drawable
Reimplemented from cgv::render::drawable.
Definition at line 443 of file gl_implicit_surface_drawable_base.cxx.
References cgv::render::mesh_render_info::bind(), cgv::render::mesh_render_info::bind_wireframe(), cgv::render::mesh_render_info::construct(), cgv::render::mesh_render_info::destruct(), draw_implicit_surface(), cgv::math::mfunc< X, T >::evaluate(), extract_mesh(), cgv::media::axis_aligned_box< T, N >::get_corner(), cgv::media::axis_aligned_box< T, N >::get_extent(), cgv::media::mesh::simple_mesh_base::get_nr_faces(), cgv::render::ref_arrow_renderer(), cgv::render::ref_box_renderer(), cgv::render::ref_cone_renderer(), cgv::render::ref_sphere_renderer(), cgv::render::context::ref_surface_shader_program(), cgv::render::context::set_color(), and cgv::math::fvec< T, N >::to_vec().
|
protected |
helper function to tesselate the implicit surface
Definition at line 568 of file gl_implicit_surface_drawable_base.cxx.
References cgv::render::cone_renderer::disable(), cgv::render::render_info::draw_all(), cgv::render::mesh_render_info::draw_wireframe(), cgv::render::shader_program::enable(), cgv::render::cone_renderer::enable(), cgv::media::mesh::simple_mesh_base::get_nr_faces(), cgv::media::mesh::simple_mesh< T >::get_nr_positions(), cgv::render::ref_cone_renderer(), cgv::render::ref_sphere_renderer(), cgv::render::context::ref_surface_shader_program(), cgv::render::renderer::render(), cgv::render::context::set_material(), cgv::render::renderer::set_position_array(), and cgv::render::renderer::set_render_style().
Referenced by draw().
void cgv::render::gl::gl_implicit_surface_drawable_base::enable_box | ( | bool | do_enable = true | ) |
Definition at line 136 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::enable_normals | ( | bool | do_enable = true | ) |
Definition at line 149 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::enable_sampling_grid | ( | bool | do_enable = true | ) |
Definition at line 110 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::enable_sampling_locations | ( | bool | do_enable = true | ) |
Definition at line 123 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::enable_wireframe | ( | bool | do_enable = true | ) |
Definition at line 102 of file gl_implicit_surface_drawable_base.cxx.
|
protectedvirtual |
helper function to extract mesh from implicit surface
Definition at line 411 of file gl_implicit_surface_drawable_base.cxx.
References cgv::media::mesh::simple_mesh< T >::clear(), cgv::media::axis_aligned_box< T, N >::get_extent(), cgv::math::fvec< T, N >::length(), cgv::render::cone_render_style::radius_scale, cgv::render::sphere_render_style::radius_scale, and surface_extraction().
Referenced by draw().
|
virtual |
this method is called in one pass over all drawables after drawing
Reimplemented from cgv::render::drawable.
Definition at line 536 of file gl_implicit_surface_drawable_base.cxx.
References cgv::media::axis_aligned_box< T, N >::get_corner(), cgv::media::axis_aligned_box< T, N >::get_extent(), cgv::render::ref_cone_renderer(), and cgv::render::context::set_color().
const dbox3 & cgv::render::gl::gl_implicit_surface_drawable_base::get_box | ( | ) | const |
Definition at line 200 of file gl_implicit_surface_drawable_base.cxx.
double cgv::render::gl::gl_implicit_surface_drawable_base::get_epsilon | ( | ) | const |
Definition at line 177 of file gl_implicit_surface_drawable_base.cxx.
gl_implicit_surface_drawable_base::F * cgv::render::gl::gl_implicit_surface_drawable_base::get_function | ( | ) | const |
Definition at line 86 of file gl_implicit_surface_drawable_base.cxx.
double cgv::render::gl::gl_implicit_surface_drawable_base::get_grid_epsilon | ( | ) | const |
Definition at line 188 of file gl_implicit_surface_drawable_base.cxx.
unsigned int cgv::render::gl::gl_implicit_surface_drawable_base::get_nr_triangles_of_last_extraction | ( | ) | const |
Definition at line 205 of file gl_implicit_surface_drawable_base.cxx.
unsigned int cgv::render::gl::gl_implicit_surface_drawable_base::get_nr_vertices_of_last_extraction | ( | ) | const |
Definition at line 210 of file gl_implicit_surface_drawable_base.cxx.
unsigned int cgv::render::gl::gl_implicit_surface_drawable_base::get_resolution | ( | ) | const |
Definition at line 97 of file gl_implicit_surface_drawable_base.cxx.
|
virtual |
this method is called after creation or recreation of the context, return whether all necessary functionality is supported
Reimplemented from cgv::render::drawable.
Definition at line 425 of file gl_implicit_surface_drawable_base.cxx.
References cgv::render::ref_arrow_renderer(), cgv::render::ref_box_renderer(), cgv::render::ref_cone_renderer(), and cgv::render::ref_sphere_renderer().
bool cgv::render::gl::gl_implicit_surface_drawable_base::is_box_enabled | ( | ) | const |
Definition at line 144 of file gl_implicit_surface_drawable_base.cxx.
bool cgv::render::gl::gl_implicit_surface_drawable_base::is_sampling_grid_enabled | ( | ) | const |
Definition at line 118 of file gl_implicit_surface_drawable_base.cxx.
bool cgv::render::gl::gl_implicit_surface_drawable_base::is_sampling_locations_enabled | ( | ) | const |
Definition at line 131 of file gl_implicit_surface_drawable_base.cxx.
bool cgv::render::gl::gl_implicit_surface_drawable_base::is_wireframe_enabled | ( | ) | const |
Definition at line 165 of file gl_implicit_surface_drawable_base.cxx.
|
protectedvirtual |
announces a new quad
Implements cgv::media::mesh::streaming_mesh_callback_handler.
Definition at line 223 of file gl_implicit_surface_drawable_base.cxx.
References compute_face_normal(), cgv::media::mesh::simple_mesh_base::new_corner(), cgv::media::mesh::simple_mesh< T >::new_normal(), normal_index, obj_out, cgv::math::fvec< T, N >::size(), cgv::media::mesh::simple_mesh_base::start_face(), cgv::media::mesh::streaming_mesh< T >::vertex_location(), and cgv::media::mesh::streaming_mesh< T >::vertex_normal().
|
protectedvirtual |
allows to augment a newly computed vertex by additional data
Implements cgv::media::mesh::streaming_mesh_callback_handler.
Definition at line 302 of file gl_implicit_surface_drawable_base.cxx.
References cgv::math::vec< T >::data(), cgv::math::mfunc< X, T >::evaluate_gradient(), cgv::media::mesh::simple_mesh< T >::new_position(), cgv::math::fvec< T, N >::normalize(), obj_out, cgv::math::vec< T >::size(), cgv::math::fvec< T, N >::to_vec(), cgv::media::mesh::streaming_mesh< T >::vertex_location(), and cgv::media::mesh::streaming_mesh< T >::vertex_normal().
void cgv::render::gl::gl_implicit_surface_drawable_base::post_rebuild | ( | ) |
use this as callback to ask for a re-tesselation of the implicit surface
Definition at line 379 of file gl_implicit_surface_drawable_base.cxx.
References cgv::render::drawable::post_redraw().
|
protected |
function used to save to obj file
callback used to save to obj file
Definition at line 67 of file gl_implicit_surface_drawable_base.cxx.
References normal_index, obj_out, and surface_extraction().
void cgv::render::gl::gl_implicit_surface_drawable_base::set_box | ( | const dbox3 & | _box | ) |
Definition at line 194 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::set_epsilon | ( | double | _epsilon | ) |
Definition at line 171 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::set_function | ( | F * | _func_ptr | ) |
Definition at line 79 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::set_grid_epsilon | ( | double | _grid_epsilon | ) |
Definition at line 182 of file gl_implicit_surface_drawable_base.cxx.
void cgv::render::gl::gl_implicit_surface_drawable_base::set_resolution | ( | unsigned int | _res | ) |
Definition at line 91 of file gl_implicit_surface_drawable_base.cxx.
|
protectedvirtual |
call the selected surface extraction method
Definition at line 385 of file gl_implicit_surface_drawable_base.cxx.
References cgv::media::mesh::dual_contouring< X, T >::extract(), cgv::media::mesh::streaming_mesh< T >::get_nr_faces(), and cgv::media::mesh::streaming_mesh< T >::get_nr_vertices().
Referenced by extract_mesh(), and save().
|
protected |
Definition at line 87 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 48 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 84 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 55 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 51 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 86 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 90 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 49 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 92 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 61 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 63 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 65 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 99 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 57 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 59 of file gl_implicit_surface_drawable_base.h.
|
protected |
normal index for face normals
Definition at line 114 of file gl_implicit_surface_drawable_base.h.
Referenced by new_polygon(), and save().
|
protected |
Definition at line 53 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 95 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 97 of file gl_implicit_surface_drawable_base.h.
|
protected |
of this output stream is defined, use it to write currently extracted surface to it
Definition at line 112 of file gl_implicit_surface_drawable_base.h.
Referenced by gl_implicit_surface_drawable_base(), new_polygon(), new_vertex(), and save().
|
protected |
Definition at line 47 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 74 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 76 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 80 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 82 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 78 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 73 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 71 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 69 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 67 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 68 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 85 of file gl_implicit_surface_drawable_base.h.
|
protected |
Definition at line 110 of file gl_implicit_surface_drawable_base.h.