Giter VIP home page Giter VIP logo

abrg-models / morphologica Goto Github PK

View Code? Open in Web Editor NEW
227.0 14.0 27.0 48.97 MB

A library of supporting code for numerical modelling (JSON config, HDF5 data, Modern OpenGL visualization)

Home Page: https://abrg-models.github.io/morphologica/

License: Apache License 2.0

C++ 94.05% CMake 0.18% MATLAB 0.01% HTML 0.42% GLSL 0.02% C 5.33% Python 0.01% Shell 0.01%
data-visualization opengl simulation visualization 2d 3d cplusplus cplusplus-17 graphics graphics-engine graphs matplotlib plotting

morphologica's Introduction

morphologica

A banner image of a hexgrid surface plot

cmake build test

Header-only library code to visualize C++ numerical simulations using fast, modern OpenGL.

Morphologica can run standalone (using GLFW for window handling) and it is also Qt and wxWidgets compatible!

NEW: Morphologica can now be used with wxWidgets! For example code, see examples/wx/

NEW: Morphologica now has OpenGL Compute Shader managers! See examples/gl_compute for details.

NEW: Now morphologica is compatible with the Raspberry Pi! See examples/pi/. These examples show how to set the OpenGL version to 3.1 ES, which is Pi compatible.

You'll find all of the library code in the morph directory and you can find example code and screenshots here.

morphologica has an (in-progress) documentation and reference website at https://abrg-models.github.io/morphologica/.

Quick Start

This quick start shows dependency installation for Linux, because on this platform, it's a single call to apt (or your favourite package manager). If you're using a Mac, see README.build.mac for help getting dependencies in place. It's README.build.windows for Windows users.

# Install dependencies for building graph1.cpp and (almost) all the other examples (assuming Debian-like OS)
sudo apt install build-essential cmake git wget  \
                 freeglut3-dev libglu1-mesa-dev libxmu-dev libxi-dev \
                 libglfw3-dev libfreetype-dev libarmadillo-dev libhdf5-dev

git clone [email protected]:ABRG-Models/morphologica   # Get your copy of the morphologica code
cd morphologica
mkdir build         # Create a build directory
cd build
cmake ..            # Call cmake to generate the makefiles
make graph1         # Compile a single one of the examples. Add VERBOSE=1 to see the compiler commands.
./examples/graph1   # Run the program. You should see a graph of a cubic function.
# After closing the graph1 program, open its source code and modify something (see examples/graph2.cpp for ideas)
gedit ../examples/graph1.cpp

The program graph1.cpp is:

// Visualize a graph. Minimal example showing how a default graph appears
#include <morph/Visual.h>
#include <morph/GraphVisual.h>
#include <morph/vvec.h>

int main()
{
    // Set up a morph::Visual 'scene environment'.
    morph::Visual v(1024, 768, "Made with morph::GraphVisual");
    // Create a new GraphVisual object with offset within the scene of 0,0,0
    auto gv = std::make_unique<morph::GraphVisual<double>> (morph::vec<float>({0,0,0}));
    // Boilerplate bindmodel function call - do this for every model you add to a Visual
    v.bindmodel (gv);
    // Data for the x axis. A vvec is like std::vector, but with built-in maths methods
    morph::vvec<double> x;
    // This works like numpy's linspace() (the 3 args are "start", "end" and "num"):
    x.linspace (-0.5, 0.8, 14);
    // Set a graph up of y = x^3
    gv->setdata (x, x.pow(3));
    // finalize() makes the GraphVisual compute the vertices of the OpenGL model
    gv->finalize();
    // Add the GraphVisual OpenGL model to the Visual scene (which takes ownership of the unique_ptr)
    v.addVisualModel (gv);
    // Render the scene on the screen until user quits with 'Ctrl-q'
    v.keepOpen();
    return 0;
}

The program generates a clean looking graph...

Screenshot of graph1.cpp output showing a cubic function

...and the code compares favourably (in terms of amount of boilerplate code) with the equivalent Python, graph1.py:

# Visualize the graph from graph1.cpp in Python
import matplotlib.pyplot as plt
import numpy as np

# Create some data for the x axis
x = np.linspace(-0.5, 0.8, 14)
# Set a graph up of y = x^3
plt.plot(x, np.power(x,3), '-o')
# Add labels
plt.title('Made with Python/numpy/matplotlib')
plt.xlabel('x')
plt.ylabel('y')
# Render the graph on the screen until user quits with 'q'
plt.show()

See the coding README for a description of some of the main classes that morphologica provides.

What is morphologica?

This header-only C++ code provides simulation support facilities for simulations of dynamical systems, agent-based models or, in fact, any program that needs dynamic, runtime visualization.

It helps with:

  • Visualizing your model while it runs. A modern OpenGL visualization scheme called morph::Visual provides the ability to visualise 2D and 3D graphs of surfaces, lines, bars, scatter plots and quiver plots with minimal processing overhead. Here's a morph::Visual helloworld and a more complete example. It's almost as easy to draw a graph in C++ with morphologica as it is to do so in Python.

  • Configuration: morphologica allows you to easily set up a simulation parameter configuration system, using the JSON reading and writing abilities of morph::Config. (morph::Config Example)

  • Saving data from your simulation. morphologica provides a set of easy-to-use convenience wrappers (morph::HdfData) around the HDF5 C API. By saving data in a standard format, it is easy to access simulation data in python, MATLAB or Octave for analysis and graphing. (HdfData Example)

It keeps out of the way of what kind of simulation you write. Our programs typically start with some kind of preamble, in which we use morph::Config to load up a JSON parameter file defining the values of the parameters for the simulation run. We might also use morph::HdfData to retrieve some data (e.g. the state) from an earlier simulation and then set up a morph::Visual object for the visualization. We then might call a function, or create a class object which defines the simulation. This may or may not access features from the morphologica headers.

As the simulation progresses, we update the data in the morph::Visual scene; save images from the scene for movie making and record data as often as we want it using morph::HdfData. At the end of the program, as well as saving any final data, we use morph::Config to save out a 'version of record' of the parameters that were used, along with git information which morph::Config can extract so that we could find the exact version of the simulation for future reproduction of the result.

Shows a variety of visualisations created with morphologica

A selection of visualisations made with morphologica. A 2D graphs. B A self-organising map simulation (orientation preference maps). C Three dimensional quiver plot. D gene driven reaction diffusion model. E Debugging a large model.

Although it need not be incorporated into your actual simulation, morphologica does also provide classes that you might find useful. Examples include:

morphologica is a way of storing our 'group knowledge' for posterity.

Some existing projects which use morphologica are:

Code documentation

See README.coding.md for a guide to the main classes.

morphologica code is enclosed in the morph namespace. If README.coding.md doesn't coverit, then the header files (They're all in morph/) contain code documentation.

You can find example programs which are compiled when you do the standard cmake-driven build of morphologica in both the tests/ subdirectory and the examples/ subdirectory. The readme in examples/ has some nice screenshots.

For full, compilable, standalone examples of the code, see the standalone_examples/ subdirectory. You can use these as templates for creating your own projects that use morphologica library code.

For more info on how to set up CMake files to build a program using morphologica (and some hints as to what you'll need to do with an alternative directed build system), see README.cmake.md.

Credits

Authorship of morphologica code is given in each file. Copyright in the software is owned by the authors.

morphologica is made possible by a number of third party projects whose source code is included in this repository. These include nlohmann::json, lodepng, rapidxml and incbin. Thanks to the authors of these projects!

morphologica is distributed under the terms of the Apache License, version 2 (see LICENSE.txt).

morphologica's People

Contributors

abrg-models avatar aljiro avatar asmwarrior avatar blenk13 avatar fabien-colonnier avatar hsaal avatar jmartinbrooke avatar optseb avatar sebjameswml avatar severindenisenko avatar stuartwilson avatar tindzk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

morphologica's Issues

Consider thread safety of Vector (and vVector) classes

@niclar writes: "The underlying data structure of the Vector class is a std::array which if misaligned is subject to write tearing.
(Further the atomic read/write assumption (guaranteed on x86/x64 for the fundamental datatypes, int, double..) should probably be asserted if the Vector was to be used in a multi threaded context)"

include\morph/VisualFace.h(198,76): error C2065: 'vf_dvsansData': undeclared identifier

Building under windows vf_dvsansData etc. is undeclared for some reason.

1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(198,76): error C2065: 'vf_dvsansData': undeclared identifier
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(198,91): error C2065: 'vf_dvsansEnd': undeclared identifier
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(204,76): error C2065: 'vf_dvsansitData': undeclared identifier
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(204,93): error C2065: 'vf_dvsansitEnd': undeclared identifier
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(210,76): error C2065: 'vf_dvsansbdData': undeclared identifier
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(210,93): error C2065: 'vf_dvsansbdEnd': undeclared identifier
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(216,76): error C2065: 'vf_dvsansbiData': undeclared identifier
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(216,93): error C2065: 'vf_dvsansbiEnd': undeclared identifier

<GL3/gl3.h>in windows

does not exist. Can the occurrences be replaced by i.e;

#ifndef USE_GLEW
#ifdef __OSX__
# include <OpenGL/gl3.h>
#elif _WIN32
# include <glad/glad.h>
# include <GLFW/glfw3.h>
#else
# include <GL3/gl3.h>
#endif
#endif

win32_opengl3_path.patch.txt

There's a bug in BezCurve::computePointsBySearch()

@jmartinbrooke found this. Sometimes, t exceeds 1, triggering the runtime error in BezCurve::checkt. I think better runtime checking is required in computePointBySearch. Perhaps somethign like:

diff --git a/morph/BezCurve.h b/morph/BezCurve.h
index d5e246d..b8c79a7 100644
--- a/morph/BezCurve.h
+++ b/morph/BezCurve.h
@@ -1086,6 +1086,14 @@ namespace morph
          */
         BezCoord<Flt> computePointBySearch (Flt t, Flt l) const
         {
+            // This may be necessary, to fix the intermittent bug discovered by John
+            if (t >= Flt{1}) {
+                BezCoord<Flt> rtn (true);
+                rtn.setRemaining (0);
+                rtn.setParam (t);
+                return rtn;
+            }
+
             // Min and max of possible range for dt to make a step of length l in posn space
             Flt dtmin = Flt{0};
             Flt dtmax = Flt{1} - t;

Also, why is this a != rather than <? (Also BezCurve.h):

            // This searches forward to try to find a point which is 'l' further on. If
            // at any point t exceeds 1.0, we have to break out.
            while (t != Flt{1} && lastnull == false) {

compilation error: use of deleted stream operator for char32_t

conformant implementations won't allow ostream << char32_t

template< class Traits >
basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os,
char32_t ch ) = delete;

C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(399,80): error C2280: 'std::basic_ostream<char,std::char_traits> &std::operator <<<std::char_traits>(std::basic_ostream<char,std::char_traits> &,char32_t)': attempting to reference a deleted function
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.32.31114\include\ostream(967): message : see declaration of 'std::operator <<'
1>C:\src\thirdparty\vcpkg\installed\x64-windows-static\include\morph/VisualFace.h(399,80): error C2088: '<<': illegal for class

Test failures

When I run ctest, a few test cases are failing:

Test project /opt/morphologica/build
      Start  1: testbez
 1/34 Test  #1: testbez ..........................   Passed    0.02 sec
      Start  2: testbez2
 2/34 Test  #2: testbez2 .........................   Passed    0.16 sec
      Start  3: testbezcurves
 3/34 Test  #3: testbezcurves ....................   Passed    0.12 sec
      Start  4: testbezmatrix
 4/34 Test  #4: testbezmatrix ....................   Passed    0.48 sec
      Start  5: testbezfit
 5/34 Test  #5: testbezfit .......................   Passed    0.01 sec
      Start  6: testbezsplit
 6/34 Test  #6: testbezsplit .....................   Passed    0.01 sec
      Start  7: testbezderiv
 7/34 Test  #7: testbezderiv .....................***Exception: Child aborted  0.65 sec
      Start  8: twocurves
 8/34 Test  #8: twocurves ........................   Passed    0.02 sec
      Start  9: testreadcurves
 9/34 Test  #9: testreadcurves ...................   Passed    0.07 sec
      Start 10: testreadcurves_circles
10/34 Test #10: testreadcurves_circles ...........   Passed    0.04 sec
      Start 11: testdisplay
11/34 Test #11: testdisplay ......................***Failed    0.04 sec
      Start 12: testhexgrid
12/34 Test #12: testhexgrid ......................   Passed    2.03 sec
      Start 13: testhexgrid2
13/34 Test #13: testhexgrid2 .....................   Passed    0.19 sec
      Start 14: testhexgrid3
14/34 Test #14: testhexgrid3 .....................***Failed    0.19 sec
      Start 15: testhexgridsave
15/34 Test #15: testhexgridsave ..................***Failed   21.67 sec
      Start 16: testdom_pgram
16/34 Test #16: testdom_pgram ....................***Failed    3.49 sec
      Start 17: testdom_rect
17/34 Test #17: testdom_rect .....................***Failed    3.54 sec
      Start 18: testdom_hex
18/34 Test #18: testdom_hex ......................***Failed    2.40 sec
      Start 19: testdom_bound
19/34 Test #19: testdom_bound ....................***Failed    0.17 sec
      Start 20: testhexbounddist
20/34 Test #20: testhexbounddist .................   Passed    0.45 sec
      Start 21: testhdfdata1
21/34 Test #21: testhdfdata1 .....................   Passed    0.03 sec
      Start 22: testhdfdata2
22/34 Test #22: testhdfdata2 .....................   Passed    0.04 sec
      Start 23: testProcess
23/34 Test #23: testProcess ......................   Passed    0.09 sec
      Start 24: testQuaternion
24/34 Test #24: testQuaternion ...................   Passed    0.00 sec
      Start 25: testVector3
25/34 Test #25: testVector3 ......................   Passed    0.00 sec
      Start 26: testTransformMatrix
26/34 Test #26: testTransformMatrix ..............   Passed    0.00 sec
      Start 27: testHexVertexPos
27/34 Test #27: testHexVertexPos .................   Passed    0.01 sec
      Start 28: testHexUserFlags
28/34 Test #28: testHexUserFlags .................   Passed    0.01 sec
      Start 29: testDirichlet
29/34 Test #29: testDirichlet ....................***Failed    0.03 sec
      Start 30: testDirichlet2
30/34 Test #30: testDirichlet2 ...................***Failed    0.03 sec
      Start 31: testDirichlet4
31/34 Test #31: testDirichlet4 ...................***Failed    0.05 sec
      Start 32: testDirichlet5
32/34 Test #32: testDirichlet5 ...................***Failed    0.04 sec
      Start 33: testMathAlgo
33/34 Test #33: testMathAlgo .....................   Passed    0.00 sec
      Start 34: testNMSimplex
34/34 Test #34: testNMSimplex ....................   Passed    0.00 sec

65% tests passed, 12 tests failed out of 34

Total Test time (real) =  36.17 sec

The following tests FAILED:
          7 - testbezderiv (Child aborted)
         11 - testdisplay (Failed)
         14 - testhexgrid3 (Failed)
         15 - testhexgridsave (Failed)
         16 - testdom_pgram (Failed)
         17 - testdom_rect (Failed)
         18 - testdom_hex (Failed)
         19 - testdom_bound (Failed)
         29 - testDirichlet (Failed)
         30 - testDirichlet2 (Failed)
         31 - testDirichlet4 (Failed)
         32 - testDirichlet5 (Failed)
Errors while running CTest

This is reproducible as follows:

docker run -i tindzk/morphologica:2020-02-18 sh
cd /opt && \
git clone https://github.com/ABRG-Models/morphologica.git && \
cd morphologica && \
mkdir build && \
cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local && \
make -j$(nproc) && ctest

There's a problem compiling the schnakenberg example on Mac

The issue lies with the inclusion of Visual.h.

@stuartwilson found that he had to include the line

#include <OpenGL/gl3.h>

BEFORE

#include <morph/Visual.h>

even though morph/Visual.h has the line

#include <GL3/gl3.h>

which is the include of the morph-installed gl3.h header; which it is my understanding is the right way to refer to the gl3.h header.

It's possible that the correct include paths have not been set up for Mac in the schnakenberg CMakeLists.txt.

Dream up a better way to store many different VisualModels in a Visual

The current scheme, with several members, each of which is a vector of pointers to the different specializations of VisualModel, is really clunky. Needs sorting. Probably just a question of having a pointer to a vector of VisualModel*s and make sure VisualModel behaves as a good interface class.

Build fails on ubuntu 16.04

make[2]:` Entering directory '/home/seb/src/morphologica/build'
[ 21%] Linking CXX executable testboundary
cd /home/seb/src/morphologica/build/src && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/testboundary.dir/link.txt --verbose=ON
/usr/bin/g++-7  -D__GLN__ -Wall -g -std=c++11 -DGL3_PROTOTYPES -DGL_GLEXT_PROTOTYPES  -rdynamic CMakeFiles/testboundary.dir/testboundary.cpp.o  -o testboundary  -Wl,-rpath,/home/seb/src/morphologica/build/src:/usr/local/lib: libmorphologica.so /usr/local/lib/libarmadillo.so /usr/lib/x86_64-linux-gnu/libopencv_videostab.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_ts.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_superres.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_stitching.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_ocl.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_gpu.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_photo.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_legacy.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_contrib.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_video.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_ml.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_features2d.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_flann.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.9 -lGL -lGLU -lglut -lXmu -lXi -lX11 /usr/local/lib/libhdf5.so.103.2.0 -ldl -lopenblas -L/usr/local/lib -ljsoncpp -lglfw3 
libmorphologica.so: undefined reference to `glCreateVertexArrays'
libmorphologica.so: undefined reference to `glCreateBuffers'
collect2: error: ld returned 1 exit status
src/CMakeFiles/testboundary.dir/build.make:111: recipe for target 'src/testboundary' failed
make[2]: *** [src/testboundary] Error 1
make[2]: Leaving directory '/home/seb/src/morphologica/build'
CMakeFiles/Makefile2:348: recipe for target 'src/CMakeFiles/testboundary.dir/all' failed
make[1]: *** [src/CMakeFiles/testboundary.dir/all] Error 2
make[1]: Leaving directory '/home/seb/src/morphologica/build'
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
seb@ubu16:~/src/morphologica/build$ 

Implement a ring of hexes feature

This is to make it possible to build models such as Lissom which require computations for sets of elements at a given distance from a target element.

Review Hex::di

Review again why I have Hex::di as well as Hex::vi. Make sure to understand when they might contain the same value and when they might contain different values.

Un-ifdef commit b2c9fac to correctly set framebuffer size

Commit b2c9fac shows the correct code to get the current framebuffer size.

BUT also as part of this ticket, make sure all the calls where I've set window_w and window_h work the right way - perhaps these should be framebuffer based as well. There may be differences in the way the mouse "feels" right now between Linux and Mac as a result of this...

CC @stuartwilson

multi threaded updates

How would one update e.g the ScatterVisual with real time data points from another thread ?

I see that the Vector class is not thread safe ...

I suspect it's to be handled by the user right ? Like pulling a thread safe queue from the render loop updating the ScatterVisual
Vector (pop_back and push_front)..

Slowdown bug with GraphVisual::update

spwilson 3:04 PM
Hi Seb - I'm finding that updating the data in a graph visual on each step of a sim leads to a massive slow down (up to a minute after about 1000 updates) at the end of a simulation. Should I be calling some kind of clear function after each update?

sebjames 3:24 PM
How are you doing the update? are you using GraphView::append?
3:25
Like the example in morphologica/examples/graph4.cpp?

spwilson 3:26 PM
no i'm not doing append, I'm overwriting the entire vector -- bad?!

sebjames 3:26 PM
So you're calling gv->update()?

spwilson 3:26 PM
yep

sebjames 3:26 PM
Ok, that's slower

spwilson 3:27 PM
seems like a cumulative thing, so longer I run it the slower the shutdown time (doesn't effect runtime speed)
3:27
I'll try append though

sebjames 3:27 PM
gv->append only appends the primitive objects required to add on to your preexisting graph. See graph4.cpp
3:28
What you're describing sounds a bit like the terrible slowdown problem updating HexGridVisuals, so there may be a bug (edited)

spwilson 3:28 PM
yes thats what i thought

sebjames 3:28 PM
in the update() method, which makes it slower than it should be
3:29
I'll check - I can remember what that problem was - it was a failure to clear out the OpenGL indices and vertices
3:29
Yes! Same bug

spwilson 3:29 PM
but that would slow at runtime, and get progressively worse. I don't notice runtime slowdown (printout of current time seems to increment about as long), just massive at the end, i.e., when cleqring the data

sebjames 3:30 PM
It's a one line fix
3:30
I'll do it now and push

spwilson 3:30 PM
ah yes, cool!
3:30
thanks

sebjames 3:36 PM
Hmm, I was mistaken. When you call GraphVisual::update, it updates the data and the scalings and then it calls VisualDataModel::reinit which DOES clear out vertexPositions, vertexNormals, vertexColors and indices. So I don't know why you're getting a slow down.

Create a 'cancelable' Visual::keepOpen() call

As it stands, keepOpen() runs until the user presses 'x' to exit. It would be nice to have a keepOpen() call that can be used to show a simulation at a certain point, the user can examine, rotate, etc, take a screenshot, then press a key to 'continue' on.

cmake doesn't rebuild on edit of vVector.h

If you edit vVector.h, then a call to make in your build directory will not trigger a re-build of tests/testvVector.h; first you have to make install, THEN the re-build will be triggered.

Linking fails

With the latest commit, I am getting the following output under Arch Linux:

$ make
make[1]: Entering directory '/home/tim/edu/morphologica/build'
make[2]: Entering directory '/home/tim/edu/morphologica/build'
Scanning dependencies of target morphstatic
make[2]: Leaving directory '/home/tim/edu/morphologica/build'
make[2]: Entering directory '/home/tim/edu/morphologica/build'
[  1%] Building CXX object src/CMakeFiles/morphstatic.dir/display.cpp.o
[  2%] Building CXX object src/CMakeFiles/morphstatic.dir/sockserve.cpp.o
[  3%] Building CXX object src/CMakeFiles/morphstatic.dir/tools.cpp.o
[  4%] Building CXX object src/CMakeFiles/morphstatic.dir/world.cpp.o
[  5%] Building CXX object src/CMakeFiles/morphstatic.dir/ReadCurves.cpp.o
[  6%] Building CXX object src/CMakeFiles/morphstatic.dir/HexGrid.cpp.o
[  7%] Building CXX object src/CMakeFiles/morphstatic.dir/HdfData.cpp.o
[  8%] Building CXX object src/CMakeFiles/morphstatic.dir/Process.cpp.o
[  9%] Building CXX object src/CMakeFiles/morphstatic.dir/Visual.cpp.o
[ 10%] Linking CXX static library libmorphologica.a
make[2]: Leaving directory '/home/tim/edu/morphologica/build'
[ 10%] Built target morphstatic
make[2]: Entering directory '/home/tim/edu/morphologica/build'
Scanning dependencies of target morphologica
make[2]: Leaving directory '/home/tim/edu/morphologica/build'
make[2]: Entering directory '/home/tim/edu/morphologica/build'
[ 11%] Building CXX object src/CMakeFiles/morphologica.dir/display.cpp.o
[ 12%] Building CXX object src/CMakeFiles/morphologica.dir/sockserve.cpp.o
[ 13%] Building CXX object src/CMakeFiles/morphologica.dir/tools.cpp.o
[ 14%] Building CXX object src/CMakeFiles/morphologica.dir/world.cpp.o
[ 15%] Building CXX object src/CMakeFiles/morphologica.dir/ReadCurves.cpp.o
[ 16%] Building CXX object src/CMakeFiles/morphologica.dir/HexGrid.cpp.o
[ 17%] Building CXX object src/CMakeFiles/morphologica.dir/HdfData.cpp.o
[ 18%] Building CXX object src/CMakeFiles/morphologica.dir/Process.cpp.o
[ 19%] Building CXX object src/CMakeFiles/morphologica.dir/Visual.cpp.o
[ 20%] Linking CXX shared library libmorphologica.so
make[2]: Leaving directory '/home/tim/edu/morphologica/build'
[ 20%] Built target morphologica
make[2]: Entering directory '/home/tim/edu/morphologica/build'
Scanning dependencies of target testboundary
make[2]: Leaving directory '/home/tim/edu/morphologica/build'
make[2]: Entering directory '/home/tim/edu/morphologica/build'
[ 21%] Building CXX object src/CMakeFiles/testboundary.dir/testboundary.cpp.o
[ 22%] Linking CXX executable testboundary
/usr/bin/ld: libmorphologica.so: undefined reference to `wrapper2_dgemv_'
/usr/bin/ld: libmorphologica.so: undefined reference to `wrapper2_sgemv_'
/usr/bin/ld: libmorphologica.so: undefined reference to `wrapper2_sgemm_'
/usr/bin/ld: libmorphologica.so: undefined reference to `wrapper2_dgemm_'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/testboundary.dir/build.make:141: src/testboundary] Error 1
make[2]: Leaving directory '/home/tim/edu/morphologica/build'
make[1]: *** [CMakeFiles/Makefile2:322: src/CMakeFiles/testboundary.dir/all] Error 2
make[1]: Leaving directory '/home/tim/edu/morphologica/build'
make: *** [Makefile:141: all] Error 2

I could not find the place where these functions are referenced. Presumably, they are wrappers around LAPACK functions.

Here are the changes I have made to the build files such that CMake could find all libraries: master...tindzk:feat/arch-linux

Docker support

The code base is incompatible with OpenGL 4 which is shipped with most recent distributions. Therefore, I have created a minimal Docker image based on Alpine Linux (Dockerfile).

All of the custom libraries compiled successfully and were installed to /usr/local/lib. However, when I try to use Morphologica in a downstream project, some of its dependencies cannot be found by cmake. This is reproducible as follows:

git clone https://github.com/stuartwilson/SelfOrganisingMaps.git
cd SelfOrganisingMaps
docker run -v $(pwd):/code -i tindzk/morphologica:2019-02-07 sh
cd /code
mkdir build
cd build
cmake ..

The output is:

-- Install prefix: /usr/local
--   (This can be changed with `cmake -DCMAKE_INSTALL_PREFIX=/some/place`
-- Operating system: Linux-5.5.3-arch1-1
-- Have pkg_config, searching for libmorphologica...
-- Checking for module 'libmorphologica'
--   Package 'hdf5', required by 'libmorphologica', not found
Package 'lapack', required by 'libmorphologica', not found
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:419 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPkgConfig.cmake:586 (_pkg_check_modules_internal)
  CMakeLists.txt:82 (pkg_check_modules)


-- Configuring incomplete, errors occurred!
See also "/code/build/CMakeFiles/CMakeOutput.log".

The following files exist in /usr/local/lib:

/usr/local/lib
/usr/local/lib/pkgconfig
/usr/local/lib/pkgconfig/opencv.pc
/usr/local/lib/pkgconfig/libmorphologica.pc
/usr/local/lib/pkgconfig/jsoncpp.pc
/usr/local/lib/pkgconfig/armadillo.pc
/usr/local/lib/pkgconfig/hdf5_cpp-1.10.6.pc
/usr/local/lib/pkgconfig/hdf5_hl_cpp-1.10.6.pc
/usr/local/lib/pkgconfig/hdf5_hl-1.10.6.pc
/usr/local/lib/pkgconfig/hdf5-1.10.6.pc
/usr/local/lib/morph
/usr/local/lib/morph/libmorphologica.a
/usr/local/lib/libmorphologica.so
/usr/local/lib/libarmadillo.so
/usr/local/lib/libjsoncpp.a
/usr/local/lib/cmake
/usr/local/lib/cmake/jsoncpp
/usr/local/lib/cmake/jsoncpp/jsoncppConfig.cmake
/usr/local/lib/cmake/jsoncpp/jsoncppConfig-release.cmake
/usr/local/lib/cmake/jsoncpp/jsoncppConfigVersion.cmake
/usr/local/lib/libarmadillo.so.9
/usr/local/lib/libarmadillo.so.9.850.1
/usr/local/lib/libhdf5.so.103.2.0
/usr/local/lib/libhdf5_hl.so
/usr/local/lib/libhdf5_hl_cpp.a
/usr/local/lib/libhdf5_hl_cpp.so
/usr/local/lib/libhdf5_cpp.so.103.2.0
/usr/local/lib/libhdf5_tools.so.100
/usr/local/lib/libhdf5.so.103
/usr/local/lib/libhdf5.settings
/usr/local/lib/libhdf5_hl.a
/usr/local/lib/libhdf5_tools.so
/usr/local/lib/libhdf5.so
/usr/local/lib/libhdf5.a
/usr/local/lib/libhdf5_hl.so.100
/usr/local/lib/libhdf5_tools.a
/usr/local/lib/libhdf5_cpp.a
/usr/local/lib/libhdf5_cpp.so
/usr/local/lib/libhdf5_hl.so.100.1.3
/usr/local/lib/libhdf5_hl_cpp.so.100.1.4
/usr/local/lib/libhdf5_hl_cpp.so.100
/usr/local/lib/libhdf5_cpp.so.103
/usr/local/lib/libhdf5_tools.so.100.1.3
/usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_shape.so
/usr/local/lib/libopencv_stitching.so.3.2
/usr/local/lib/libopencv_photo.so.3.2
/usr/local/lib/libopencv_flann.so.3.2
/usr/local/lib/libopencv_videostab.so
/usr/local/lib/libopencv_videostab.so.3.2
/usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_superres.so.3.2
/usr/local/lib/libopencv_ml.so.3.2
/usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_highgui.so.3.2.0
/usr/local/lib/libopencv_imgproc.so.3.2
/usr/local/lib/libopencv_objdetect.so.3.2.0
/usr/local/lib/libopencv_videoio.so.3.2.0
/usr/local/lib/libopencv_video.so.3.2.0
/usr/local/lib/libopencv_superres.so
/usr/local/lib/libopencv_imgcodecs.so.3.2
/usr/local/lib/libopencv_objdetect.so.3.2
/usr/local/lib/libopencv_imgcodecs.so.3.2.0
/usr/local/lib/libopencv_calib3d.so.3.2.0
/usr/local/lib/libopencv_ml.so.3.2.0
/usr/local/lib/libopencv_core.so.3.2
/usr/local/lib/libopencv_flann.so.3.2.0
/usr/local/lib/libopencv_calib3d.so.3.2
/usr/local/lib/libopencv_flann.so
/usr/local/lib/libopencv_shape.so.3.2.0
/usr/local/lib/libopencv_videoio.so.3.2
/usr/local/lib/libopencv_calib3d.so
/usr/local/lib/libopencv_video.so.3.2
/usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_highgui.so
/usr/local/lib/libopencv_shape.so.3.2
/usr/local/lib/libopencv_core.so
/usr/local/lib/libopencv_imgproc.so.3.2.0
/usr/local/lib/libopencv_stitching.so
/usr/local/lib/libopencv_photo.so.3.2.0
/usr/local/lib/libopencv_features2d.so.3.2.0
/usr/local/lib/libopencv_stitching.so.3.2.0
/usr/local/lib/libopencv_ml.so
/usr/local/lib/libopencv_features2d.so.3.2
/usr/local/lib/libopencv_superres.so.3.2.0
/usr/local/lib/libopencv_videoio.so
/usr/local/lib/libopencv_highgui.so.3.2
/usr/local/lib/libopencv_videostab.so.3.2.0
/usr/local/lib/libopencv_core.so.3.2.0
/usr/local/lib/libopencv_imgproc.so
/usr/local/lib/libopencv_imgcodecs.so

Also, the ctest command returns with a non-zero exit code because some of the test cases fail. Is this expected?

Remove debug noise from Shaders

E.g.

Monitor xscale: 1, monitor yscale: 1
Shader compiler present
Using compiled-in vertex shader
Successfully compiled vertex shader!
Using compiled-in fragment shader
Successfully compiled fragment shader!
Successfully linked shader!
Success configuring the morph::Visual object!

config.getBool() not working as expected

In using config.getBool("logicalVar",0) the default value is always selected regardless of the value in the .json file, e.g. "logicalVal" : 1 . Other variable types getInt, getDouble, getString are working as expected, i.e. the value in the .json file is selected if it exists.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.