Skip to content

Ability to plot user-provided point line #367

Merged
tzanio merged 15 commits into
masterfrom
pointline-dev
Jun 4, 2026
Merged

Ability to plot user-provided point line #367
tzanio merged 15 commits into
masterfrom
pointline-dev

Conversation

@tzanio

@tzanio tzanio commented Mar 10, 2026

Copy link
Copy Markdown
Member

Overview

This PR adds an optional point line overlay (useful e.g. for reference curves), which can be toggled with Ctrl + l.

Points can be loaded from a file with the -pts command-line option, sent via socket with the pointline command, or specified in a GLVis scripts. The points line format is: number of points, followed by x y z coordinates.

The overlay appears as a red line connecting the given points.

Screenshot 2026-03-09 at 7 21 04 PM

Testing

Stand-alone with input from file

Use this circle_points.txt points file to run

./glvis -m ../mfem/data/star-q2.mesh -pts circle_points.txt -k "Aem"

and press Ctrl + l.

Server mode with input from file

Run

./glvis -pts circle_points.txt

then send a solution via socket, e.g. from mpirun -np 4 ./ex1p and press Ctrl + l.

Server mode with input by socket

Add sample points to the solution socket output in one of the examples, e.g. in ex1.cpp:

int sdim = mesh.SpaceDimension();
Vector bb_min, bb_max;
mesh.GetBoundingBox(bb_min, bb_max);
sol_sock << "pointline\n" << 2 << "\n"
          << bb_min(0) << ' ' << bb_min(1) << ' ' << ((sdim==2) ? 0.0 : bb_min(2)) << "\n"
          << bb_max(0) << ' ' << bb_max(1) << ' ' << ((sdim==2) ? 0.0 : bb_max(2)) << "\n"
          << flush;

start a server with ./glvis and then run ./ex1 -m ../data/escher.mesh.

The point line should appear by default and can be turned off/on with Ctrl + l.

In server mode, input by socket overrides input by file. In parallel, all ranks send point lines, but only the one from rank 0 is considered.

GLVis script

Use the files in this archive: test_pointline.zip to run

./glvis -run test_pointline.glvis

Press Space and rhe point line should appear; it can be turned off/on with Ctrl + l.

Potential improvements

  • Add support for comments/blank lines in the points files
  • Support multiple point lines (in the same or multiple files)
  • Provide options to customize the style of the point line
  • Smooth the curve with NURBS interpolation

@tzanio tzanio self-assigned this Mar 10, 2026
Comment thread lib/script_controller.cpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a user-provided “point line” overlay (red polyline) that can be toggled with Ctrl+l, with coordinates loadable from a points file (-pts), from the socket protocol (pointline command), or from GLVis scripts (pointline command).

Changes:

  • Adds point-line state/storage (DataState::point_coords) and a shared parsing helper (ReadPointLine).
  • Adds rendering support for the overlay across visualization scenes and a Ctrl+l toggle.
  • Extends server/socket and script command handling to accept pointline, and adds -pts CLI option plus docs/changelog updates.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/vsvector3d.cpp Adds Ctrl+l help text and queues point line overlay in the 3D vector scene render list.
lib/vsvector.cpp Adds Ctrl+l help text and queues point line overlay in the 2D vector scene render list.
lib/vssolution3d.cpp Adds Ctrl+l help text and queues point line overlay in the 3D solution scene render list.
lib/vssolution.cpp Adds Ctrl+l help text and queues point line overlay in the 2D solution scene render list.
lib/vsdata.hpp Introduces point-line drawable/bool state and helper methods to prepare/toggle/render it.
lib/vsdata.cpp Implements Ctrl+l behavior and point-line buffer creation and scene queueing.
lib/threads.hpp Adds a new GLVis command type + storage for point line coordinates.
lib/threads.cpp Implements pointline socket command parsing and execution wiring into the renderer.
lib/script_controller.cpp Adds pointline support to the GLVis script command set.
lib/data_state.hpp Adds point_coords to shared state and declares ReadPointLine.
lib/data_state.cpp Implements ReadPointLine parsing helper and moves point_coords in move-assign.
glvis.cpp Adds -pts option, loads point coordinates from file, and forwards them into server sessions.
README.md Documents Ctrl+l toggle and references -pts.
CHANGELOG Adds an entry documenting the new point line overlay feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread glvis.cpp Outdated
Comment thread lib/data_state.cpp Outdated
Comment thread lib/vsdata.cpp
Comment thread lib/vsdata.cpp
Comment thread lib/vsdata.cpp Outdated
Comment thread glvis.cpp Outdated
Comment thread glvis.cpp Outdated
Comment thread CHANGELOG Outdated
Comment thread lib/threads.cpp Outdated
Comment thread lib/data_state.hpp Outdated
Comment thread lib/vsdata.cpp Outdated
@tzanio tzanio changed the title 🤖 Ability to plot user-provided point line Ability to plot user-provided point line May 27, 2026
tzanio and others added 5 commits June 2, 2026 10:42
Conflicts:
	glvis.cpp
	lib/vsdata.cpp
Co-authored-by: John Camier <camierjs@gmail.com>
Co-authored-by: John Camier <camierjs@gmail.com>
@tzanio

tzanio commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

@najlkin, @dylan-copeland, @v-dobrev and @camierjs -- all reviewer comments have been addressed and I tested that this works, can you take another look?

@tzanio tzanio requested a review from camierjs June 2, 2026 18:15
@tzanio

tzanio commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

One of the tests (glvis -run test_pointline.glvis) actually failed due to a bug (?) in CheckStreamIsComplex.

This was addressed in e8ce369 -- @najlkin, can you take a look?

@najlkin

najlkin commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

How about showing the overlay line by default when loaded from command line? That is expected behavior, I would say (why to load it otherwise...), and also it is better for headless rendering, so you do not need to send the Ctrl+l combination 🤔 . Actually, there seems to be no way to enter it by -k .

@najlkin

najlkin commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

One of the tests (glvis -run test_pointline.glvis) actually failed due to a bug (?) in CheckStreamIsComplex.

This was addressed in e8ce369 -- @najlkin, can you take a look?

Hmm, it has not happened to me, it is only with ZLib, I guess. Anyway, fixing it by the copy of StreamReader::CheckStreamIsComplex() is fine. Alternatively, it could be reused, but it is just a few lines, so not worth of it really.

@tzanio

tzanio commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

How about showing the overlay line by default when loaded from command line?

Done in 508df0d

it is only with ZLib

Despite the name of the class, this is not just for zlib -- the files used in the above script example are all text files (the zip file is just for easier download from GitHub).

@najlkin

najlkin commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

I know it is not just Zlib, but without MFEM compiled with Zlib, ifgzstream behaves more or less like regular fstream where you can save the position and go back and forth.

@tzanio

tzanio commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

Thanks @najlkin, @dylan-copeland, @camierjs and @v-dobrev!

@tzanio tzanio merged commit b9c2881 into master Jun 4, 2026
10 checks passed
@tzanio tzanio deleted the pointline-dev branch June 4, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants