Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Version 4.2.1 (development)

- Significantly improved memory usage.

- Add support to visualize solutions on 1D elements embedded in 2D and 3D.


Version 4.2 released on May 23, 2022
====================================
Expand Down
4 changes: 2 additions & 2 deletions glvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ int main (int argc, char *argv[])
const char *font_name = string_default;
int portnum = 19916;
int multisample = GetMultisample();
double line_width = 1.0;
double ms_line_width = gl3::LINE_WIDTH_AA;
double line_width = GetLineWidth();
double ms_line_width = GetLineWidthMS();
Comment on lines +1151 to +1152
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these make any difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If your question is regarding the change itself, then this change just introduces a call to the internal API to keep the defaults consistent. If your question is regarding whether multisampling makes a difference, then it depends on the system. Not all systems support the respective OpenGL calls for multisampling of lines, which is part of the reason why I wanted to merge the line rendering PR before this. However, this PR is also functional without the line rendering PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example pressing A on my workstation during interactive visualization removes stair-casing though antialiasing.

int geom_ref_type = Quadrature1D::ClosedUniform;
bool legacy_gl_ctx = false;
bool enable_hidpi = true;
Expand Down
85 changes: 64 additions & 21 deletions lib/openglvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,25 @@ ::DrawQuad(gl3::GlDrawable& buff,
{fpts[3], fnorm, texcoord[3]});
}


void VisualizationScene
::DrawLine(gl3::GlDrawable& buff,
const double (&pts)[4][3], const double (&cv)[4],
const double minv, const double maxv)
{
float texcoord[2];
std::array<float, 3> fpts[2];
for (int i = 0; i < 2; i++)
{
texcoord[i] = palette.GetColorCoord(cv[i], minv, maxv);
fpts[i] = {(float) pts[i][0], (float) pts[i][1], (float) pts[i][2]};
}
buff.addLine<gl3::VertexTex>(
{fpts[0], texcoord[0]},
{fpts[1], texcoord[1]}
);
}

void VisualizationScene
::DrawPatch(gl3::GlDrawable& drawable, const DenseMatrix &pts, Vector &vals,
DenseMatrix &normals,
Expand Down Expand Up @@ -376,41 +395,65 @@ ::DrawPatch(gl3::GlDrawable& drawable, const DenseMatrix &pts, Vector &vals,
}
else
{
if (n == 3)
if (n == 2)
{
poly.glBegin(GL_LINES);
}
else if (n == 3)
{
poly.glBegin(GL_TRIANGLES);
}
else
else if (n == 4)
{
poly.glBegin(GL_QUADS);
}
else // We should never hit this case
{
mfem_error("VisualizationScene::DrawPatch() : unknown input geometry.");
}
for (int i = 0; i < ind.Size(); i += n)
{
int j;
if (n == 3)
j = Compute3DUnitNormal(&pts(0, ind[i]), &pts(0, ind[i+1]),
&pts(0, ind[i+2]), na);
else
j = Compute3DUnitNormal(&pts(0, ind[i]), &pts(0, ind[i+1]),
&pts(0, ind[i+2]), &pts(0, ind[i+3]), na);
if (j == 0)
if (n == 2) // Lines
{
if (normals_opt == 0)
// Draw solution line
for (int j=0; j<2; j++)
{
poly.glNormal3dv(na);
for ( ; j < n; j++)
{
MySetColor(poly, vals(ind[i+j]), minv, maxv);
poly.glVertex3dv(&pts(0, ind[i+j]));
}
MySetColor(poly, vals(ind[i+j]), minv, maxv);
poly.glVertex3d(pts(0, ind[i+j]), pts(1, ind[i+j]), pts(2, ind[i+j]));
}
}
else // Quads and triangles
{
int j;
if (n == 3)
{
j = Compute3DUnitNormal(&pts(0, ind[i]), &pts(0, ind[i+1]),
&pts(0, ind[i+2]), na);
}
else
{
poly.glNormal3d(-na[0], -na[1], -na[2]);
for (j = n-1; j >= 0; j--)
j = Compute3DUnitNormal(&pts(0, ind[i]), &pts(0, ind[i+1]),
&pts(0, ind[i+2]), &pts(0, ind[i+3]), na);
}
if (j == 0)
{
if (normals_opt == 0)
{
poly.glNormal3dv(na);
for ( ; j < n; j++)
{
MySetColor(poly, vals(ind[i+j]), minv, maxv);
poly.glVertex3dv(&pts(0, ind[i+j]));
}
}
else
{
MySetColor(poly, vals(ind[i+j]), minv, maxv);
poly.glVertex3dv(&pts(0, ind[i+j]));
poly.glNormal3d(-na[0], -na[1], -na[2]);
for (j = n-1; j >= 0; j--)
{
MySetColor(poly, vals(ind[i+j]), minv, maxv);
poly.glVertex3dv(&pts(0, ind[i+j]));
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/openglvis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class VisualizationScene
const double (&pts)[4][3], const double (&cv)[4],
const double minv, const double maxv);

void DrawLine(gl3::GlDrawable& buff,
const double (&pts)[4][3], const double (&cv)[4],
const double minv, const double maxv);

/// Draw a 3D triangle in physical space with a central triangle removed. The
/// cut is controlled by value of cut_lambda. See keys Ctrl+F3/F4. Similar to
/// CutReferenceTriangle in lib/vssolution3d.cpp.
Expand Down
Loading