Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Version 4.2.1 (development)

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

- Added two new modes for visualization of vector fields in 2D, placing the
arrows above the plotted surface and using a single color.

- Added a compilation parameter for the default font size.


Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ Key commands
- show vector field; vectors are uniformly scaled; the color varies with the
magnitude (or the current *vector-to-scalar function*, see keys <kbd>u</kbd> / <kbd>U</kbd>)
- show vector field as above, but the vectors are scaled proportionally to their magnitude
- show vector field; vectors are uniformly scaled; the color is gray; arrows are above the surface
- show vector field as above, but the vectors are scaled proportionally to their magnitude
- <kbd>V</kbd> – Change the scaling of the vectors relative to the default
- <kbd>d</kbd> – Toggle the *displaced mesh* state: (see also keys <kbd>n</kbd> / <kbd>b</kbd>). The options are:
- do not show displaced mesh
Expand Down
28 changes: 19 additions & 9 deletions lib/vsvector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void VisualizationSceneVector::ToggleDrawElems()

void VisualizationSceneVector::ToggleVectorField()
{
drawvector = (drawvector+1)%4;
drawvector = (drawvector+1)%6;
PrepareVectorField();
}

Expand Down Expand Up @@ -844,7 +844,7 @@ thread_local double new_maxlen;
void VisualizationSceneVector::DrawVector(double px, double py, double vx,
double vy, double cval)
{
double zc = 0.5*(bb.z[0]+bb.z[1]);
double zc = (drawvector > 3)?(bb.z[1]):(0.5*(bb.z[0]+bb.z[1]));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of additional options for v, maybe it is better to add an input option lambda (by default 0.5) that can adjust the zc value to (1-lambda)*bb.z[0]+ lambda*bb.z[1]?

This is similar to how we handle e.g. level lines with F5 or rules positions with ~

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do not know, I do not see much reason for an arbitrary position, I see only a reason for mid-plane and above. The second thing is that color. The other options (except the first one) use color coding, so the arrows are almost invisible (blended) when looking from above.


if (drawvector == 1)
{
Expand All @@ -860,7 +860,9 @@ void VisualizationSceneVector::DrawVector(double px, double py, double vx,
arrow_type = 1;
arrow_scaling_type = 1;

if (drawvector == 2)
if (drawvector > 3) { cval = HUGE_VAL; }

if (drawvector == 2 || drawvector == 4)
{
Arrow(vector_buf, px, py, zc, vx, vy, 0.0, h, 0.125, cval);
}
Expand Down Expand Up @@ -892,7 +894,7 @@ void VisualizationSceneVector::PrepareVectorField()
int i;

palette.SetUseLogscale(logscale);
if (drawvector == 3)
if (drawvector == 3 || drawvector == 5)
{
new_maxlen = 0.0;
}
Expand Down Expand Up @@ -939,7 +941,7 @@ void VisualizationSceneVector::PrepareVectorField()
}
}

if (drawvector == 3 && new_maxlen != maxlen)
if ((drawvector == 3 || drawvector == 5) && new_maxlen != maxlen)
{
maxlen = new_maxlen;
rerun = 1;
Expand All @@ -966,7 +968,7 @@ gl3::SceneInfo VisualizationSceneVector::GetSceneObjs()
double* cp_eqn = CuttingPlane->Equation();
params.clip_plane_eqn = {cp_eqn[0], cp_eqn[1], cp_eqn[2], cp_eqn[3]};
params.contains_translucent = false;
if (drawvector > 1)
if (drawvector == 2 || drawvector == 3)
{
scene.queue.emplace_back(params, &vector_buf);
}
Expand Down Expand Up @@ -1013,8 +1015,12 @@ gl3::SceneInfo VisualizationSceneVector::GetSceneObjs()
scene.queue.emplace_back(params, &v_nums_buf);
}

if (drawvector == 1)
if (drawvector == 1 || drawvector > 3)
{
if (drawvector > 3)
{
params.static_color = {.3f, .3f, .3f, 1.f};
}
scene.queue.emplace_back(params, &vector_buf);
}

Expand All @@ -1024,6 +1030,10 @@ gl3::SceneInfo VisualizationSceneVector::GetSceneObjs()
{
params.static_color = {1.f, 0.f, 0.f, 1.f};
}
else
{
params.static_color = GetLineColor();
}
scene.queue.emplace_back(params, &displine_buf);
}
ProcessUpdatedBufs(scene);
Expand Down Expand Up @@ -1051,13 +1061,13 @@ void VisualizationSceneVector::glTF_Export()
bld,
vec_mesh,
buf,
(drawvector == 1) ? black_mat : palette_mat,
(drawvector == 1 || drawvector > 3) ? black_mat : palette_mat,
vector_buf);
int nlines = AddLines(
bld,
vec_mesh,
buf,
(drawvector == 1) ? black_mat : pal_lines_mat,
(drawvector == 1 || drawvector > 3) ? black_mat : pal_lines_mat,
vector_buf);
if (ntria == 0 || nlines == 0)
{
Expand Down