Skip to content

Commit d95155e

Browse files
committed
fancier marked edges control for volume meshes
1 parent 9218bfc commit d95155e

6 files changed

Lines changed: 35 additions & 48 deletions

include/cinolib/gl/volume_mesh_controls.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,17 @@ void VolumeMeshControls<Mesh>::header_marked_edges(const bool open)
530530
{
531531
if(ImGui::Checkbox("Show##MarkedEdge", &show_marked_edges))
532532
{
533-
m->show_marked_edge(show_marked_edges);
533+
m->show_marked_edge(show_marked_edges, show_marked_fancy);
534+
m->updateGL();
535+
}
536+
if(ImGui::Checkbox("Fancy##MarkedEdge", &show_marked_fancy))
537+
{
538+
m->show_marked_edge(show_marked_edges, show_marked_fancy);
539+
m->updateGL();
534540
}
535-
if(ImGui::SliderInt("Width##2", &marked_edge_width, 1, 10))
541+
if(ImGui::SliderFloat("Width##2", &marked_edge_width, 1.f, 50.f))
536542
{
537-
m->show_marked_edge_width(float(marked_edge_width));
543+
m->show_marked_edge_width(marked_edge_width);
538544
m->updateGL();
539545
}
540546
if(ImGui::ColorEdit4("Color##markededge", marked_edge_color.rgba, color_edit_flags))

include/cinolib/gl/volume_mesh_controls.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ class VolumeMeshControls : public SideBarItem
7878
bool show_mesh = true;
7979
bool show_wireframe = true;
8080
bool show_marked_edges = true;
81+
bool show_marked_fancy = false;
8182
bool show_marked_faces = true;
8283
bool show_isosurface = false;
8384
bool show_vecfield = false;
8485
bool show_face_normals = false;
8586
bool show_vert_normals = false;
8687
int wireframe_width = 1;
87-
int marked_edge_width = 1;
88+
float marked_edge_width = 1.f;
8889
int isoline_width = 1;
8990
float wireframe_alpha = 1.f;
9091
float vecfield_size = 0.9f;

include/cinolib/meshes/abstract_drawable_polygonmesh.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ CINO_INLINE
4949
void AbstractDrawablePolygonMesh<Mesh>::init_drawable_stuff()
5050
{
5151
drawlist.draw_mode = DRAW_TRIS | DRAW_TRI_SMOOTH | DRAW_TRI_FACECOLOR | DRAW_SEGS;
52+
show_marked_edges = true;
5253
marked_edges.use_gl_lines = true;
54+
marked_edges.thickness = 3.f;
5355
updateGL();
5456
}
5557

@@ -100,10 +102,8 @@ void AbstractDrawablePolygonMesh<Mesh>::updateGL_marked()
100102
}
101103
if(hidden) continue;
102104

103-
vec3d vid0 = this->edge_vert(eid,0);
104-
vec3d vid1 = this->edge_vert(eid,1);
105-
106-
marked_edges.push_seg(vid0,vid1);
105+
marked_edges.push_seg(this->edge_vert(eid,0),
106+
this->edge_vert(eid,1));
107107
}
108108
}
109109

include/cinolib/meshes/abstract_drawable_polygonmesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class AbstractDrawablePolygonMesh : public virtual Mesh, public DrawableObject
5555
RenderData drawlist;
5656
float AO_alpha = 1.f;
5757

58-
bool show_marked_edges = true;
58+
bool show_marked_edges;
5959
DrawableSegmentSoup marked_edges;
6060

6161
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

include/cinolib/meshes/abstract_drawable_polyhedralmesh.cpp

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ void AbstractDrawablePolyhedralMesh<Mesh>::init_drawable_stuff()
5050
drawlist_in.draw_mode = DRAW_TRIS | DRAW_TRI_SMOOTH | DRAW_TRI_FACECOLOR | DRAW_SEGS;
5151
drawlist_out.draw_mode = DRAW_TRIS | DRAW_TRI_SMOOTH | DRAW_TRI_FACECOLOR | DRAW_SEGS;
5252
drawlist_marked.draw_mode = DRAW_TRIS | DRAW_SEGS;
53-
drawlist_marked.seg_width = 3;
54-
marked_edge_color = Color::RED();
5553
marked_face_color = Color::BLUE();
56-
AO_alpha = 1.0;
57-
54+
AO_alpha = 1.f;
55+
show_marked_edges = true;
56+
marked_edges.use_gl_lines = true;
57+
marked_edges.thickness = 3.f;
5858
updateGL();
5959
}
6060

@@ -70,6 +70,7 @@ void AbstractDrawablePolyhedralMesh<Mesh>::draw(const float) const
7070
render(drawlist_in );
7171
render(drawlist_out);
7272
render(drawlist_marked);
73+
if(show_marked_edges) marked_edges.draw();
7374
glPopMatrix();
7475
}
7576

@@ -94,9 +95,6 @@ void AbstractDrawablePolyhedralMesh<Mesh>::updateGL_marked()
9495
drawlist_marked.tri_coords.clear();
9596
drawlist_marked.tri_v_norms.clear();
9697
drawlist_marked.tri_v_colors.clear();
97-
drawlist_marked.segs.clear();
98-
drawlist_marked.seg_coords.clear();
99-
drawlist_marked.seg_colors.clear();
10098

10199
for(uint fid=0; fid<this->num_faces(); ++fid)
102100
{
@@ -160,28 +158,8 @@ void AbstractDrawablePolyhedralMesh<Mesh>::updateGL_marked()
160158
// This allows to hide marked elements with the slicer...
161159
//if(!this->edge_is_visible(eid)) continue;
162160

163-
vec3d vid0 = this->edge_vert(eid,0);
164-
vec3d vid1 = this->edge_vert(eid,1);
165-
166-
uint base_addr = uint(drawlist_marked.seg_coords.size()/3);
167-
drawlist_marked.segs.push_back(base_addr );
168-
drawlist_marked.segs.push_back(base_addr + 1);
169-
170-
drawlist_marked.seg_coords.push_back(float(vid0.x()));
171-
drawlist_marked.seg_coords.push_back(float(vid0.y()));
172-
drawlist_marked.seg_coords.push_back(float(vid0.z()));
173-
drawlist_marked.seg_coords.push_back(float(vid1.x()));
174-
drawlist_marked.seg_coords.push_back(float(vid1.y()));
175-
drawlist_marked.seg_coords.push_back(float(vid1.z()));
176-
177-
drawlist_marked.seg_colors.push_back(marked_edge_color.r);
178-
drawlist_marked.seg_colors.push_back(marked_edge_color.g);
179-
drawlist_marked.seg_colors.push_back(marked_edge_color.b);
180-
drawlist_marked.seg_colors.push_back(marked_edge_color.a);
181-
drawlist_marked.seg_colors.push_back(marked_edge_color.r);
182-
drawlist_marked.seg_colors.push_back(marked_edge_color.g);
183-
drawlist_marked.seg_colors.push_back(marked_edge_color.b);
184-
drawlist_marked.seg_colors.push_back(marked_edge_color.a);
161+
marked_edges.push_seg(this->edge_vert(eid,0),
162+
this->edge_vert(eid,1));
185163
}
186164
}
187165

@@ -979,10 +957,11 @@ void AbstractDrawablePolyhedralMesh<Mesh>::show_in_wireframe_transparency(const
979957

980958
template<class Mesh>
981959
CINO_INLINE
982-
void AbstractDrawablePolyhedralMesh<Mesh>::show_marked_edge(const bool b)
960+
void AbstractDrawablePolyhedralMesh<Mesh>::show_marked_edge(const bool b, const bool fancy)
983961
{
984-
if (b) drawlist_marked.draw_mode |= DRAW_SEGS;
985-
else drawlist_marked.draw_mode &= ~DRAW_SEGS;
962+
show_marked_edges = b;
963+
marked_edges.use_gl_lines = !fancy;
964+
marked_edges.draw_joint_spheres = fancy;
986965
}
987966

988967
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@@ -991,8 +970,7 @@ template<class Mesh>
991970
CINO_INLINE
992971
void AbstractDrawablePolyhedralMesh<Mesh>::show_marked_edge_color(const Color & c)
993972
{
994-
marked_edge_color = c;
995-
updateGL_marked();
973+
marked_edges.default_color = c;
996974
}
997975

998976
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@@ -1001,7 +979,7 @@ template<class Mesh>
1001979
CINO_INLINE
1002980
void AbstractDrawablePolyhedralMesh<Mesh>::show_marked_edge_width(const float width)
1003981
{
1004-
drawlist_marked.seg_width = width;
982+
marked_edges.thickness = width;
1005983
}
1006984

1007985
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@@ -1010,8 +988,7 @@ template<class Mesh>
1010988
CINO_INLINE
1011989
void AbstractDrawablePolyhedralMesh<Mesh>::show_marked_edge_transparency(const float alpha)
1012990
{
1013-
marked_edge_color.a = alpha;
1014-
updateGL_marked();
991+
marked_edges.default_color.a = alpha;
1015992
}
1016993

1017994
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

include/cinolib/meshes/abstract_drawable_polyhedralmesh.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <cinolib/drawable_object.h>
4242
#include <cinolib/meshes/mesh_slicer.h>
4343
#include <cinolib/gl/draw_lines_tris.h>
44+
#include <cinolib/drawable_segment_soup.h>
4445

4546
namespace cinolib
4647
{
@@ -54,10 +55,12 @@ class AbstractDrawablePolyhedralMesh : public virtual Mesh, public DrawableObjec
5455
RenderData drawlist_in;
5556
RenderData drawlist_out;
5657
RenderData drawlist_marked; // rendering info about marked edges (can be extended to handle marked verts/faces/poly too)
57-
Color marked_edge_color;
5858
Color marked_face_color;
5959
float AO_alpha;
6060

61+
bool show_marked_edges;
62+
DrawableSegmentSoup marked_edges;
63+
6164
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
6265

6366
// transformation matrix applied to the mesh to position it in world space
@@ -131,7 +134,7 @@ class AbstractDrawablePolyhedralMesh : public virtual Mesh, public DrawableObjec
131134
void show_in_wireframe_width(const float width);
132135
void show_in_wireframe_transparency(const float alpha);
133136

134-
void show_marked_edge(const bool b);
137+
void show_marked_edge(const bool b, const bool fancy = false);
135138
void show_marked_edge_color(const Color & c);
136139
void show_marked_edge_width(const float width);
137140
void show_marked_edge_transparency(const float alpha);

0 commit comments

Comments
 (0)