Basic_viewer: color faces by value (distance, cell size, and a drawer value) - #9598
Basic_viewer: color faces by value (distance, cell size, and a drawer value)#9598RajdeepKushwaha5 wants to merge 19 commits into
Conversation
|
Successfully tested in CGAL-6.3-Ic-52 |
|
@gdamiand I'm waiting for your approval to merge it. |
|
This pull-request was previously marked with the label |
… mesh aspect ratio)
…he distance legend
…ace_value, set_face_value)
… right-aligned so it fits
90b0aff to
3164f46
Compare
…ce mesh In whole-volume clipping the surface-mesh path (no volumes to keep or hide) drew every face with a plain glDrawArrays, so it ignored the drawer's per-face value: the colour stayed on distance and did not change when switching to the aspect ratio, and did not update when the plane moved. Draw that path the same way the main renderer does, per face with u_CellValue, so the drawer value applies here too.
…g the plane updates the colours distance_value_range took the min and max of the bounding-box corner distances to the current plane. Both ends then shifted with the plane exactly as the per-fragment distance did, so translating the plane left the normalised colours unchanged (they only changed on rotation). It also put the clipped-away half in the range, so the legend advertised colours no visible face showed. Anchor the range at the plane instead: 0 at the plane, growing into the kept half up to its farthest point. Moving the plane now sweeps the colours (the farthest distance changes), and the legend matches the visible faces over the full palette.
|
hi sir @sloriot |
|
Successfully tested in CGAL-6.3-Ic-58 |
|
/build:v0 |
|
The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/9598/v0/Manual/index.html |
Rename the Graphics_scene_options predicate valued_face to is_face_valued, as sloriot asked on the pull request, so the boolean predicate reads as a question while face_value and face_value_name return the data. Updated the concept documentation, the surface mesh drawer, the BGL face-graph drawer, and the changelog to match.
|
This pull-request was previously marked with the label |
|
Successfully tested in CGAL-6.3-Ic-61 |
|
colour -> color |
Co-authored-by: Sebastien Loriot <sloriot.ml@gmail.com>
|
This pull-request was previously marked with the label |
Co-authored-by: Sebastien Loriot <sloriot.ml@gmail.com>
Co-authored-by: Sebastien Loriot <sloriot.ml@gmail.com>
|
Successfully tested in CGAL-6.3-Ic-64 |
Small feature
Wiki page here
This PR adds a small feature to the public API: a drawer can attach a scalar value to each face, which the Basic_viewer maps to a colour palette, mirroring the existing colour path.
New API:
Graphics_scene_options:valued_face(does this face have a value),face_value(the value),face_value_name(the legend label).Graphics_scene:set_face_value(float),set_value_name(const std::string&).Purpose: mesh-quality visualisation. The viewer cannot compute a quality measure itself (it only has the boundary triangles); each drawer can. The surface mesh drawer uses this to expose the aspect ratio of each face.
Scope: small and additive. It mirrors
colored_face/face_color, defaults to off (no value), and changes no existing behaviour.Description
This adds an automatic colouring of the faces by a value, mapped to a colour from a palette, discussed with the mentors as a follow-up to the clipping work.
Palette (D key). D turns the colouring on and cycles the palette: off, then a heat, a jet, a grey ramp and viridis (a perceptually uniform map). The palette is evaluated in the face shader, so there is no texture.
Value (Shift+D key). Shift+D picks the value, skipping the ones that do not apply to the scene:
Distance is computed live in the shader from the clipping plane the user places with Ctrl+C. Distance and size are normalised over the range actually present in the scene, so the whole palette is used.
A value from the drawer. Following Guillaume's suggestion, the viewer does not have to compute geometric values itself. A drawer can attach a scalar value to each face, the same way it attaches a colour: the graphics-scene options gain valued_face / face_value / face_value_name, the scene stores the value next to the colour, and the viewer maps it to the palette. As the example, the surface mesh viewer exposes the aspect ratio (longest edge / shortest edge) of each face. This is the general mechanism for mesh-quality colouring (aspect ratio, Jacobian, and so on), with each drawer computing what its mesh allows.
Legend. A small legend is drawn when the colouring is on: a gradient bar in the current palette with the value range, labelled by the drawer's name (or distance / size). It uses the same range and palette as the faces, so the two match, and it is hidden when the value has no range (a uniform field).
The Basic_viewer part is contained in Basic_shaders.h and Basic_viewer.h. The value mechanism also touches Graphics_scene.h, Graphics_scene_options.h, the face-graph drawer (BGL/draw_face_graph.h), and the surface mesh drawer.
Testing: verified on grids of hexahedra (Linear_cell_complex) and on triangle meshes (Surface_mesh). The values and palettes behave as described, the per-cell and per-face modes read as flat blocks, the colours span the full palette with the legend matching the values present (including as the clipping plane is moved and rotated), the drawer-provided aspect ratio colours the surface mesh with a named legend, and the colouring holds in every clipping mode.
Note on next step (Guillaume's suggestion)
The value mechanism generalises the built-in size and enables mesh-quality colouring per data structure. The surface mesh aspect ratio is the first example; values on volumes (set_volume_val) and other measures are natural follow-ups.