Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
f711a19
A little re-arranging to begin with
sebsjames Jan 30, 2026
241e278
half edge structs. Thinking about what to replace in existing code
sebsjames Jan 31, 2026
93cfc4f
Now stored vertex in the he_vertex scheme
sebsjames Feb 1, 2026
6daa861
WIP converting to use of mesh::face<>
sebsjames Feb 1, 2026
038bad3
compute nvc, nvd
sebsjames Feb 1, 2026
5edf3cc
A couple of example programs that have to change along with updates t…
sebsjames Feb 1, 2026
2d41d53
Removes normal from mesh::face<>, but now programs crash (see model_c…
sebsjames Feb 1, 2026
f78370a
These ifdeffed out sections are important
sebsjames Feb 1, 2026
c499b34
Semantics for the ifdeffed out bits
sebsjames Feb 2, 2026
b442b32
Completes the removal of normal as a member of mesh::face.
sebsjames Feb 2, 2026
5e36d8c
Minor changes to ensure compilation. Need to check draw_triangles_int…
sebsjames Feb 2, 2026
850d98e
WIP. Lots of changes to convert to using halfedges
sebsjames Feb 2, 2026
efa9bf9
More debug WIP
sebsjames Feb 2, 2026
a9163bb
Committing, so I can go back and try non-pointer version again.
sebsjames Feb 2, 2026
387ff85
Plain indices seem to be working sensibly
sebsjames Feb 2, 2026
3642dab
Refactor halfedge index variable name
sebsjames Feb 3, 2026
d2f3aa2
First draft conversion to halfedges. Next up: find the twin halfedges
sebsjames Feb 3, 2026
eaa7a03
A basic twin finding algo
sebsjames Feb 3, 2026
6cc054c
Re-instate the triangle swapping. Improve the twin-finding
sebsjames Feb 3, 2026
6de328c
Removes some cruft
sebsjames Feb 3, 2026
b9c7f5a
Fixes to ensure everything compiles on my PC
sebsjames Feb 3, 2026
060e339
Use latest maths
sebsjames Feb 3, 2026
25edca4
A skeleton structure for NavMesh save/load
sebsjames Feb 3, 2026
17450ef
Adds a visualmodel hash function and navmesh load/save skeletons
sebsjames Feb 3, 2026
eb84deb
Removes stabilised a) it doesn't work as planned b) it should be an a…
sebsjames Feb 3, 2026
1127b70
Adds hdfsave to NavMesh
sebsjames Feb 3, 2026
2ce8264
Uses new binary_read/write to save data
sebsjames Feb 4, 2026
043bd2c
has the geometry only
sebsjames Feb 4, 2026
c21d1dd
Refactoring mostly
sebsjames Feb 4, 2026
07b107d
Minor - be sure to show expected filename on stdout. Some debug messages
sebsjames Feb 4, 2026
b0b06d0
Change NavException. Debug output change. Realised I need to fill hal…
sebsjames Feb 4, 2026
f179f5b
Better hash combindation
sebsjames Feb 5, 2026
927908b
Corrects ordering of triangles in GridVIsual, triangle mode
sebsjames Feb 5, 2026
e5141c0
Corrects clockwiseness of triangles in computeFlatQuad
sebsjames Feb 5, 2026
0de1c8f
Thursday work on NavMesh boundary halfedges
sebsjames Feb 5, 2026
bcff8cc
More flexibility in NormalsVisual
sebsjames Feb 6, 2026
06fc4e7
cout changes in NormalsVisual
sebsjames Feb 6, 2026
3c34f88
Make some messages debug only
sebsjames Feb 6, 2026
d17caad
Current progress. Seem to be correctly creating the navmesh. Found a …
sebsjames Feb 6, 2026
f30baaa
Tidy up
sebsjames Feb 6, 2026
6af97b6
Now we are off-edge tolerant (well as long as client code catches off…
sebsjames Feb 6, 2026
fb83545
Tail end of Friday's debugging
sebsjames Feb 9, 2026
5afcb44
Avoid inf loop in find_neighbours. Break out of one-neighbour do-whil…
sebsjames Feb 9, 2026
b07f7e7
Removes NavException
sebsjames Feb 9, 2026
f87c065
Because I removed NavException
sebsjames Feb 9, 2026
4e0e274
More debugging. Also add teh ability to pass in a navmesh directory f…
sebsjames Feb 9, 2026
8c320e1
Monday debugging
sebsjames Feb 9, 2026
7823310
next/prev visualization options
sebsjames Feb 10, 2026
e62940a
next/prev visualization options
sebsjames Feb 10, 2026
6cb126b
Starting to write navmesh test code, but more importantly fixes for n…
sebsjames Feb 10, 2026
24c8ac1
Final fix on prev/next and boundaries
sebsjames Feb 10, 2026
cbf6214
Progress. Still have a problem in ground_smaller2.gltf, but boundarie…
sebsjames Feb 10, 2026
cf269d3
Ok, got code to know if a navmesh built from a model is good or not.
sebsjames Feb 11, 2026
7cf7aa3
Make a test_neighbours function and a leaner find_neighbours function…
sebsjames Feb 11, 2026
7f3b1a8
Up to date maths
sebsjames Feb 11, 2026
e40e68c
Revert optimization flag
sebsjames Feb 11, 2026
543d25a
Showing anomaly locations
sebsjames Feb 12, 2026
fbdb02c
Show rogue position (in Blender coords)
sebsjames Feb 12, 2026
4d59fc3
Adds mat<> returning blender_transform_mat
sebsjames Feb 12, 2026
943f50b
Use openmp in navmesh computation
sebsjames Feb 12, 2026
aabbd9d
twin is not a tri should include off-edge: in its message
sebsjames Feb 12, 2026
1c93653
Avoid need for mplot/compoundray/interop.h
sebsjames Feb 12, 2026
4baac6c
Test and save in each case here.
sebsjames Feb 12, 2026
d2659ba
Brings in a fix in geometry
sebsjames Feb 13, 2026
e243f10
Updated maths geometry PR branch
sebsjames Feb 13, 2026
9b94a21
Debugging code, chasing movements that land on triangle edge/borders
sebsjames Feb 13, 2026
c22dfe4
Updates to model crawler and some improvements on what to do when lan…
sebsjames Feb 15, 2026
0a6c5cc
Comment out an unused variable for now
sebsjames Feb 16, 2026
14b2573
A start at splitting compute_mesh_movement up a bit
sebsjames Feb 16, 2026
fca514e
WIP re-writing the mesh movement
sebsjames Feb 16, 2026
bad1860
Progress
sebsjames Feb 16, 2026
61238e6
Update the examples readme, which still referred to morph
sebsjames Feb 16, 2026
f9ca73a
Some code to deal with colinear movements. Also chasing down zero-len…
sebsjames Feb 17, 2026
1d19b56
Merge branch 'dev/navmesh_neighbours_halfedges_functionalize_mesh_mov…
sebsjames Feb 17, 2026
2626790
Dealing with a case going through a vertex
sebsjames Feb 18, 2026
120549a
WIP. Unfinished work to do in find_nearest_boundary_crossing
sebsjames Feb 18, 2026
48329c0
WIP from the office
sebsjames Feb 19, 2026
9686a88
Sorts the 'over the vertex' problem file antpov_find_nearest_boundary…
sebsjames Feb 20, 2026
20e3b95
Seems pretty stable now!
sebsjames Feb 20, 2026
367211a
Turning debug messages off
sebsjames Feb 20, 2026
cc7d7bc
More debug message hiding
sebsjames Feb 20, 2026
9b30c53
Improved first-hit code
sebsjames Feb 23, 2026
d8ea26b
Mostly code comments. One function changed a bit (the need for distan…
sebsjames Feb 23, 2026
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
6 changes: 3 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ if(NOT APPLE)
target_link_libraries(scatter_instanced OpenGL::GL glfw Freetype::Freetype)
add_executable(breadcrumbs breadcrumbs.cpp)
target_link_libraries(breadcrumbs OpenGL::GL glfw Freetype::Freetype)

add_executable(model_crawler model_crawler.cpp)
target_link_libraries(model_crawler OpenGL::GL glfw Freetype::Freetype)
endif()

add_executable(scatter_dynamic scatter_dynamic.cpp)
Expand Down Expand Up @@ -393,9 +396,6 @@ if(NOT APPLE)
target_link_libraries(geodesic_ce OpenGL::GL glfw Freetype::Freetype)
endif()

add_executable(model_crawler model_crawler.cpp)
target_link_libraries(model_crawler OpenGL::GL glfw Freetype::Freetype)

add_executable(tri tri.cpp)
target_link_libraries(tri OpenGL::GL glfw Freetype::Freetype)

Expand Down
157 changes: 7 additions & 150 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Example programs

This folder contains a set of example morphologica programs to help
This folder contains a set of example mathplot programs to help
new users to get started using the library.

These examples will build alongside the unit tests when you do a
morphologica build like this:
mathplot build like this:

```bash
# Clone morphologica if you didn't already
git clone git@github.com/ABRG-Models/morphologica
cd morphologica
# Clone mathplot if you didn't already
git clone git@github.com/sebsjames/mathplot --recurse-submodules
cd mathplot
mkdir build
cd build
cmake ..
Expand All @@ -18,153 +18,10 @@ cd ..
```
You'll find the example program binaries in `build/examples`.

The examples are almost all built on the morph::Visual environment,
The examples are almost all built on the mplot::Visual environment,
which means you can interact with the mouse. Right-button down allows
you to drag, Left-button down allows you to rotate. Press 't' to
change the axis of rotations. Press 'h' and have a look at stdout to
see some other key presses. 'x' exits. 'a' Resets the view.

## Computational and scientific model examples

These are examples of models that we've re-implemented from the
literature. These examples make use of most of the basic facilities in
morphologic; morph::Config, morph::HdfData and morph::Visual.

### convolve.cpp

An example demonstrating the use of morph::HexGrid, its
HexGrid::convolve function, the morph::Random class and a
visualization of the input, the convolution kernel and the resulting
output.

![Screenshot of the convolve program](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/convolve.png?raw=true)

### logisticmap.cpp

Computes the logistic map and displays with a morph::GraphVisual, using diamond shaped markers.

![Screenshot of the logisticmap program](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/logisticmap.png?raw=true)

### rosenbrock.cpp

This program find the minimum of the Rosenbrock banana function using
the Nelder-Mead simplex optimization method (coded as the class
morph::NMSimplex). The walk of the simplex down the function surface
is animated. Note that the scaling of the colour map is set so that
only the lowest part of the surface is resolved in the green to blue
part of the map (which is Inferno)

![Screenshot of Rosenbrock banana function with Nelder-Mead triangle](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/rosenbrock.png?raw=true)

### Ermentrout2009

Contains an implementation of a Keller-Segel reaction diffusion system.

**From the base of morphologica**, run like this (the program needs to access the file ./boundaries/whiskerbarrels.svg):

```bash
/build/examples/Ermentrout2009/erm ./examples/Ermentrout2009/configs/erm.json
```

![Screenshot of the erm.cpp program, showing a bullseye mode](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/erm.png?raw=true)

### LotkaVolterra

Contains an implementation of the Lotka-Volterra population model cast as a reaction diffusion system.

![Shows two surfaces for two population variables, u and v](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/lotkavolterra.png?raw=true)

### SimpsonGoodhill

Contains an implementation of the model described in the paper 'A
simple model can unify a broad range of phenomena in retinotectal map
development', Biological Cybernetics, 2011, by Hugh Simpson and Geoffrey Goodhill. This one is notable because it is an **agent based model**, rather than a reaction diffusion model. Proof that morphologica is useful for many different types of model! The image shows results for the wildtype model, Figs 2B to 2D in the paper, with parameters exactly as given in the paper.

**From the base of morphologica**, run like this:

```bash
/build/examples/SimpsonGoodhill/sg ./examples/SimpsonGoodhill/sg.json
```
![Screenshot of the sg.cpp program, showing the wildtype model (cf. Figs 2B-2D)](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/sg.png?raw=true)

## morph::Visual examples

These simple examples showcase the features in morphologica's
morph::Visual code. They're a useful place to see what the code can do
for data visualization.

### visual.cpp

An example morph::Visual program which shows a morph::HexGrid and some
text labels.

![Screenshot of a morph::Visual scene](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/visual.png?raw=true)

### fps.cpp

A dynamic HexGrid program showing an animated surface

![Screenshot of the animated hexgrid program, fps.cpp](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/fps.png?raw=true)

### hexgrid.cpp

Example HexGridVisual

![Screenshot of hexgrid.cpp showing a sinusoidal landscape in the jet colour map](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/hexgrid.png?raw=true)

### hexgrid_image

Creates a HexGrid, then uses `HexGrid::resampleImage` to load a picture.

![Screenshot of hexgrid_image.cpp showing a resampled image of a touring bicycle](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/hexgrid_image.png?raw=true)

### cartgrid.cpp

Example Cartesian grid (CartGridVisual)

![Screenshot of cartgrid.cpp showing a sinusoidal landscape in the jet colour map](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/cartgrid.png?raw=true)

### quiver.cpp

An example quiver plot using morph::QuiverVisual.

![Screenshot of a 3D quiver plot](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/quiver.png?raw=true)

### scatter.cpp

An example three dimensional scatter plot of spheres using
morph::ScatterVisual. Note that in this example, the coordinate arrows
are set within the scene (and so move with the model).

![Screenshot of a 3D scatter plot](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/scatter.png?raw=true)

### graph1.cpp to graph4.cpp

Various examples of the use of morph::GraphVisual.

![Screenshot of graph3.cpp, showing some example graphs](https://github.com/ABRG-Models/morphologica/blob/main/examples/screenshots/graph3.png?raw=true)

### twowindows.cpp

An example to show how to create two morph::Visuals, and hence two
windows, in your program.

### rods.cpp

An example of the very simple VisualModel, morph::RodVisual, which
simply draws a polygonal rod. You can specify how many sides, so this
can be used to draw rods of square section, or rods which appear to be
cylindrical.

### quads.cpp

An example of morph::QuadsVisual.

### pointrows.cpp

An example of morph::PointRowsVisual, which is used to render a
surface made of adjacent rows of points.

This program is also conditially compiled into the exectuable
pointrows_mesh, which renders the same points as a ball-and-stick
mesh.
There's also a [gallery of the example programs](https://sebsjames.github.io/mathplot/) on the reference site.
18 changes: 9 additions & 9 deletions examples/draw_triangles_intersections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ int main()

auto start_wr = (vmi * start).less_one_dim(); // wr to tvp
std::cout << "start_wr = " << start_wr << std::endl;
auto [hit, ti, tn] = tvp->navmesh->find_triangle_crossing (start_wr, dirn);
if (ti[0] == std::numeric_limits<uint32_t>::max()) {
auto [hit, ti] = tvp->navmesh->find_triangle_crossing (start_wr, dirn, vm);
if (ti == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti[0] << "," << ti[1] << "," << ti[2] << std::endl;
std::cout << "Indices: " << ti << std::endl;
std::cout << "Contains hit " << hit << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit, 0.07, mplot::colour::springgreen2);
Expand All @@ -346,11 +346,11 @@ int main()
}

auto start_wr_fr2 = (vmi * start_fr2).less_one_dim(); // wr to tvp
auto [hit_fr2, ti_fr2, tn_fr2] = tvp->navmesh->find_triangle_crossing (start_wr_fr2, dirn_fr2);
if (ti[0] == std::numeric_limits<uint32_t>::max()) {
auto [hit_fr2, ti_fr2] = tvp->navmesh->find_triangle_crossing (start_wr_fr2, dirn_fr2, vm);
if (ti_fr2 == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti_fr2[0] << "," << ti_fr2[1] << "," << ti_fr2[2] << std::endl;
std::cout << "Indices: " << ti_fr2 << std::endl;
std::cout << "Contains hit " << hit_fr2 << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit_fr2, 0.07, mplot::colour::springgreen2);
Expand All @@ -361,11 +361,11 @@ int main()

auto start_wr_bh = (vmi * start_bh).less_one_dim(); // wr to tvp
std::cout << "start_wr = " << start_wr << std::endl;
auto [hit_bh, ti_bh, tn_bh] = tvp->navmesh->find_triangle_crossing (start_wr_bh, dirn_bh);
if (ti_bh[0] == std::numeric_limits<uint32_t>::max()) {
auto [hit_bh, ti_bh] = tvp->navmesh->find_triangle_crossing (start_wr_bh, dirn_bh, vm);
if (ti_bh == std::numeric_limits<uint32_t>::max()) {
std::cout << "NO HIT\n";
} else {
std::cout << "Indices: " << ti_bh[0] << "," << ti_bh[1] << "," << ti_bh[2] << std::endl;
std::cout << "Indices: " << ti_bh << std::endl;
std::cout << "Contains hit " << hit_bh << std::endl;

sv = std::make_unique<mplot::SphereVisual<>>(hit_bh, 0.07, mplot::colour::springgreen2);
Expand Down
31 changes: 31 additions & 0 deletions examples/grid_border2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
#include <mplot/Visual.h>
#include <mplot/VisualDataModel.h>
#include <mplot/GridVisual.h>
#include <mplot/NormalsVisual.h>

int main()
{
mplot::Visual v(1600, 1000, "Flat GridVisual grids with borders");
v.lightingEffects();
v.rotateAboutNearest (true);

// Create a grid to show in the scene
constexpr unsigned int Nside = 4; // You can change this
Expand Down Expand Up @@ -172,6 +174,35 @@ int main()
gv->addLabel ("Triangles, border (smaller is as expected)", lblpos, mplot::TextFeatures(0.08f));
gv->finalize();
v.addVisualModel (gv);

offset[0] += grid.width_of_pixels() * 1.2f;
gv = std::make_unique<mplot::GridVisual<float>>(&grid, offset);
v.bindmodel (gv);
gv->gridVisMode = mplot::GridVisMode::Triangles;
gv->setScalarData (&data);
gv->cm.setType (mplot::ColourMapType::Cork);
gv->zScale.do_autoscale = false;
gv->zScale.null_scaling();
gv->colourScale.do_autoscale = false;
gv->colourScale.compute_scaling (-1, 1);
// Border specific parameters
gv->showborder (false);
gv->addLabel ("Triangles, no border, showing halfedges", lblpos, mplot::TextFeatures(0.08f));
gv->finalize();
auto gvp = v.addVisualModel (gv);

// Make a navmesh for this last one
gvp->make_navmesh();

// Add a Normals visual for the last one, too
auto nrm = std::make_unique<mplot::NormalsVisual<>> (gvp);
v.bindmodel (nrm);
nrm->options.set (mplot::normalsvisual_flags::show_halfedges);
nrm->options.set (mplot::normalsvisual_flags::show_boundary_next);
nrm->options.set (mplot::normalsvisual_flags::show_boundary_prev);
nrm->finalize();
v.addVisualModel (nrm);

v.keepOpen();

return 0;
Expand Down
Loading