Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ examples/**/*.png
examples/**/*.jpg
examples/**/*.svg
*.ipe
*.rrd
*.obj

# Matlab files
*.asv
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@
find_package(CAPD REQUIRED)
endif()

################################################################################
# Looking for Rerun (if needed)
################################################################################

option(WITH_RERUN "Build with Rerun graphics support" ON)

if(WITH_RERUN)
find_package(rerun_sdk QUIET)
if(NOT rerun_sdk_FOUND)
FetchContent_Declare(
rerun_sdk
URL https://github.com/rerun-io/rerun/releases/download/0.38.1/rerun_cpp_sdk.zip
)
FetchContent_MakeAvailable(rerun_sdk)
endif()
add_compile_definitions(CODAC_WITH_RERUN)
endif()

################################################################################
# Compile sources
################################################################################
Expand Down Expand Up @@ -189,7 +207,7 @@
if(BUILD_TESTS)
include(CTest)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure $(ARGS)
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS ${PROJECT_NAME} COMMENT "Running the tests")

add_subdirectory(tests)
Expand Down
8 changes: 1 addition & 7 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@
file(COPY ${static_file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/manual/tmp/)
endforeach()

# todo: the SPHINX_EXECUTABLE is already set by FindSphinx.cmake:
# check that it works without the following overload for Win and Linux:
if(WIN32)
set(SPHINX_EXECUTABLE "sphinx-build")
else()
set(SPHINX_EXECUTABLE "python3" "-msphinx")
endif()


add_custom_target(manual
COMMAND
Expand Down
76 changes: 74 additions & 2 deletions doc/manual/manual/visualization/3d_visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,52 @@
The 3D Figure class
===================

Main author: `Maël Godard <https://godardma.github.io>`_, `Damien Massé <https://labsticc.fr/fr/annuaire/masse-damien>`_
Main author: `Maël Godard <https://godardma.github.io>`_, `Damien Massé <https://labsticc.fr/fr/annuaire/masse-damien>`_, `Quentin Brateau <https://teusner.github.io>`_

This page describes the class used in Codac for 3D visualization.

Figure3D
--------

The basic class for 3D visualization is Figure3D. It is used to generate a ``.obj`` file that can be imported in any 3D visualization software.
The basic class for 3D visualization is Figure3D. It can be used to generate a ``.obj`` file that can be imported in any 3D visualization software, or streamed live to the :ref:`Rerun visualizer <sec-graphics-rerun>` (``.rrd``).

For online visualization, the free website `3dviewer <https://3dviewer.net/>`_ can be used.
For online OBJ visualization, the free website `3dviewer <https://3dviewer.net/>`_ can be used.

The constructor takes one arguments: the name of the object file.
The constructor takes the name of the figure and optionnaly the graphic output backend (defaulting to ``GraphicOutput::OBJ | GraphicOutput::RERUN``).

.. tabs::

.. code-tab:: py

fig = Figure3D("my_object") # for the object file my_object.obj
fig = Figure3D("my_object", GraphicOutput.OBJ | GraphicOutput.RERUN)

.. code-tab:: c++

Figure3D fig ("my_object"); // for the object file my_object.obj
Figure3D fig("my_object", GraphicOutput::OBJ | GraphicOutput::RERUN);

.. code-tab:: matlab

fig = Figure3D("my_object") % for the object file my_object.obj
fig = Figure3D("my_object", GraphicOutput().OBJ.union(GraphicOutput().RERUN));

Drawing functions
-----------------

Below are the detailled available drawing functions. The shapes that can be drawn are:
Below are the detailed available drawing functions. The shapes that can be drawn are:

Geometric shapes
- Point
- Line
- Polyline
- Box
- Sphere
- Ellipsoid
- Arrow
- Zonotope
- Parallelepiped
Expand All @@ -49,43 +60,74 @@ Geometric shapes
Vehicles
- Car
- Plane
- AUV

Paving
- PavingOut (Paving with contractors)
- PavingInOut (Paving with separators)
- Subpaving

Trajectories & Tubes
- Sampled and Analytic Trajectories
- Sliced Tubes

Note that stroke and fill colors can be specified via :ref:`StyleProperties <subsec-graphics-colors-style-properties>`.

Note that only the stroke color is used in all of the supported drawing functions.
In addition, a function ``draw_axes`` is available to draw the three axes of the 3D space. It can take two arguments:

In addition, a function ``draw_axes`` is available to draw the three axes of the 3D space. It can take two arguments :

- float : the size of the axes
- double : the size of the axes
- Vector : the origin of the axes


Geometric shapes
----------------

All the drawable geometric objects can take a last optionnal argument to set up their stroke color.
All the drawable geometric objects can take a last optional argument to set up their style properties (color, line width, layer).
For further details, refer to :ref:`subsec-graphics-colors-style-properties`.

The geometric shapes that can be drawn and their arguments are listed below :
The geometric shapes that can be drawn and their arguments are listed below:

- draw_point

- Vector : coordinates of the 3D point

- draw_line

- Vector : start of the line
- Vector : end of the line

- draw_polyline

- vector<Vector> : sequence of 3D points forming the polyline

- draw_box

- IntervalVector : the box to draw
- IntervalVector : the 3D box to draw

- draw_sphere


- Vector : the center of the sphere
- Matrix : the scaling matrix
- Matrix : the scaling and rotation matrix

- draw_ellipsoid

- Ellipsoid : the ellipsoid object to draw

- draw_arrow

- Vector : start of the arrow
- Matrix : orientation of the arrow (first column)
- Vector : start origin of the arrow
- Matrix : orientation matrix (first column is the direction)

- draw_zonotope

Expand Down Expand Up @@ -118,6 +160,7 @@ The geometric shapes that can be drawn and their arguments are listed below :
- Vector : third point

The ``draw_polygon`` can be used to draw a `star-shaped polygon <https://en.wikipedia.org/wiki/Star-shaped_polygon>`_ when the vectors are coplanar, and more
The ``draw_polygon`` function can be used to draw a `star-shaped polygon <https://en.wikipedia.org/wiki/Star-shaped_polygon>`_ when the vectors are coplanar, and more
generally a sequence of adjacent triangles sharing a same vertex.

- draw_polygon
Expand All @@ -135,40 +178,69 @@ generally a sequence of adjacent triangles sharing a same vertex.
- Interval : bounds of p2
- double : incrementation for p2
- function<double, double> -\> Vector : the function of the surface, linking each (p1,p2) to a 3D point
- function<Vector(double, double)> : the parametric surface function linking (p1, p2) to a 3D point

Vehicles
--------

All the drawable vehicles can take a last optionnal argument to set up their stroke color.
All the drawable vehicles can take a last optional argument to set up their style properties.
For further details, refer to :ref:`subsec-graphics-colors-style-properties`.

The vehicles that can be drawn and their arguments are listed below :
The vehicles that can be drawn and their arguments are listed below:

- draw_car

- Vector : center of the car
- Matrix : orientation of the car
- Vector : center position of the car
- Matrix : orientation matrix of the car

- draw_plane

- Vector : center of the plane
- Matrix : orientation of the plane
- bool : (optionnal) defines if the yaw axis is up, default to true
- Vector : center position of the plane
- Matrix : orientation matrix of the plane
- bool : (optional) defines if the yaw axis is pointing upwards, default to true

- draw_AUV

- Vector : center position of the AUV
- Matrix : orientation matrix of the AUV

Paving
------

When a paving is drawn, only the inside and boundary boxes are drawn. This is done to avoid outside boxes masking them.
When a paving is drawn, only the inside and boundary boxes are drawn to avoid outside boxes masking them.

If only one type of paving is drawn (for example a paving with contractors), only one :ref:`subsec-graphics-colors-style-properties` can be defined to choose its edge color.
If only one type of paving is drawn (for example a paving with contractors), only one :ref:`subsec-graphics-colors-style-properties` can be defined to choose its color.
If two types are drawn (boundary and inside), two :ref:`subsec-graphics-colors-style-properties` can be passed to select both colors.

The paving that can be drawn and their arguments are listed below :
The paving that can be drawn and their arguments are listed below:

- draw_paving

- PavingOut | PavingInOut : the paving to draw

- draw_subpaving

- Subpaving : the subpaving to draw
- Subpaving : the subpaving to draw

Trajectories & Tubes
--------------------

3D trajectories and tubes can also be drawn on 3D figures:

- draw_trajectory

- SampledTraj<Vector> | AnalyticTraj<VectorType> : the 3D trajectory to draw

- draw_tube

- SlicedTube<IntervalVector> : the 3D tube of interval vectors to draw
20 changes: 16 additions & 4 deletions doc/manual/manual/visualization/figures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The 2D Figure classes
=====================

Main author: `Maël Godard <https://godardma.github.io>`_
Main author: `Maël Godard <https://godardma.github.io>`_, `Quentin Brateau <https://teusner.github.io>`_

This page describes the classes used in Codac for 2D visualization.

Expand All @@ -14,6 +14,8 @@ Graphical outputs

Two graphical outputs are currently supported in Codac: :ref:`VIBes <sec-graphics-vibes>` and :ref:`IPE <sec-graphics-ipe>`. VIBes is used for real-time
visualization while IPE creates a file that can be edited by the IPE editor. These outputs are referenced by the enumeration GraphicOutput:
Three graphical outputs are currently supported in Codac: :ref:`VIBes <sec-graphics-vibes>`, :ref:`IPE <sec-graphics-ipe>`, and :ref:`Rerun <sec-graphics-rerun>`. VIBes is used for real-time
visualization, IPE creates a file that can be edited by the IPE editor, and Rerun generates an interactive recording (`.rrd`). These outputs are referenced by the enumeration GraphicOutput:

.. tabs::

Expand All @@ -22,18 +24,24 @@ visualization while IPE creates a file that can be edited by the IPE editor. The
GraphicOutput.VIBES # for VIBes
GraphicOutput.IPE # for IPE
GraphicOutput.VIBES | GraphicOutput.IPE # for both
GraphicOutput.RERUN # for Rerun
GraphicOutput.VIBES | GraphicOutput.IPE | GraphicOutput.RERUN # for all

.. code-tab:: c++

GraphicOutput::VIBES // for VIBes
GraphicOutput::IPE // for IPE
GraphicOutput::VIBES | GraphicOutput::IPE // for both
GraphicOutput::RERUN // for Rerun
GraphicOutput::VIBES | GraphicOutput::IPE | GraphicOutput::RERUN // for all

.. code-tab:: matlab

GraphicOutput().VIBES % for VIBes
GraphicOutput().IPE % for IPE
GraphicOutput().VIBES.union(GraphicOutput().IPE) % for both
GraphicOutput().RERUN % for Rerun
GraphicOutput().VIBES.union(GraphicOutput().IPE).union(GraphicOutput().RERUN) % for all

Note that for the VIBes output to work, the VIBes viewer must be launched before the program is run.

Expand All @@ -43,6 +51,7 @@ Figure2D
--------

The basic class for 2D visualization is Figure2D. It is used to create a figure that can be displayed in VIBes or saved in an xml file for IPE.
The basic class for 2D visualization is Figure2D. It is used to create a figure that can be displayed in VIBes, saved in an xml file for IPE, or exported to Rerun (.rrd).
The constructor takes two arguments: the name of the figure and the graphical output. A boolean can be added to specify if the figure is to be used
DefaultFigure (see :ref:`subsec-graphics-2d-figures-defaultfigure`).

Expand All @@ -51,14 +60,17 @@ DefaultFigure (see :ref:`subsec-graphics-2d-figures-defaultfigure`).
.. code-tab:: py

fig = Figure2D("My figure", GraphicOutput.VIBES | GraphicOutput.IPE)
fig = Figure2D("My figure", GraphicOutput.VIBES | GraphicOutput.IPE | GraphicOutput.RERUN)

.. code-tab:: c++

Figure2D fig ("My Figure",GraphicOutput::VIBES|GraphicOutput::IPE);
Figure2D fig ("My Figure", GraphicOutput::VIBES | GraphicOutput::IPE | GraphicOutput::RERUN);

.. code-tab:: matlab

fig = Figure2D("My figure 1", GraphicOutput().VIBES.union(GraphicOutput().IPE));
fig = Figure2D("My figure 1", GraphicOutput().VIBES.union(GraphicOutput().IPE).union(GraphicOutput().RERUN));

.. _subsec-graphics-2d-figures-defaultfigure:

Expand All @@ -72,21 +84,21 @@ Any Figure2D object can be used as DefaultFigure with the set method:

.. code-tab:: py

fig = Figure2D("My figure", GraphicOutput.VIBES | GraphicOutput.IPE)
fig = Figure2D("My figure", GraphicOutput.VIBES | GraphicOutput.IPE | GraphicOutput.RERUN)
fig.is_default() # is False
DefaultFigure.set(fig)
fig.is_default() # is True

.. code-tab:: c++

std::shared_ptr<codac2::Figure2D> fig = std::make_shared<Figure2D>("My Figure",GraphicOutput::VIBES|GraphicOutput::IPE);
std::shared_ptr<codac2::Figure2D> fig = std::make_shared<Figure2D>("My Figure",GraphicOutput::VIBES|GraphicOutput::IPE|GraphicOutput::RERUN);
fig->is_default(); // is false
DefaultFigure::set(fig);
fig->is_default(); // is true

.. code-tab:: matlab

fig = Figure2D("My figure", GraphicOutput().VIBES.union(GraphicOutput().IPE));
fig = Figure2D("My figure", GraphicOutput().VIBES.union(GraphicOutput().IPE.union(GraphicOutput().RERUN)));
fig.is_default() % is False
DefaultFigure().set(fig);
fig.is_default() % is True
Expand Down
1 change: 1 addition & 0 deletions doc/manual/manual/visualization/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Visualization
colors.rst
vibes.rst
ipe.rst
rerun.rst
2d_example.rst
3d_visualization.rst
3d_example.rst
Loading
Loading