The 3D Figure class

Main author: Maël Godard

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.

For online visualization, the free website 3dviewer can be used.

The constructor takes one arguments: the name of the object file.

fig = Figure3D("my_object") # for the object file my_object.obj

Drawing functions

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

Geometric shapes
  • Box

  • Parallelepiped

Paving
  • PavingOut (Paving with contractors)

  • PavingInOut (Paving with separators)

  • Subpaving

In addition, a function draw_axes is available to draw the three axes of the 3D space.

void codac2::Figure3D::draw_axes(double size = 1.0)

Draws the (x,y,z) axes on the figure in red, green and blue.

Parameters:

size – Size of the axes

Note that only the stroke color is used in all of the supported drawing functions.

Geometric shapes

void codac2::Figure3D::draw_box(const IntervalVector &x, const StyleProperties &s = {Color::dark_gray(0.5)})

Draws a box on the figure.

Parameters:
  • x – Box to draw

  • s – Style of the box (edge color)

void codac2::Figure3D::draw_parallelepiped(const Vector &z, const Matrix &A, const StyleProperties &s = {Color::dark_gray(0.5)})

Draws a parallelepiped z+A*[-1,1]^3 on the figure.

Parameters:
  • z – Coordinates of the center of the parallelepiped

  • A – Matrix of the parallelepiped

  • s – Style of the parallelepiped (edge color)

Paving

void codac2::Figure3D::draw_paving(const PavingOut &p, const StyleProperties &bound_s = {Color::yellow(0.5)})

Draws a paving on the figure (Only the boundary is drawn).

Parameters:
  • p – PavingOut to draw (result of a paving with contractors).

  • bound_s – Style of the boundary of the paving

void codac2::Figure3D::draw_paving(const PavingInOut &p, const StyleProperties &bound_s = {Color::yellow(0.3)}, const StyleProperties &in_s = {Color::green(0.5)})

Draws a paving on the figure (Only the boundary and the inside is drawn).

Parameters:
  • p – PavingInOut to draw (result of a paving with separators).

  • bound_s – Style of the boundary of the paving

  • in_s – Style of the inside of the paving

template<typename P>
inline void codac2::Figure3D::draw_subpaving(const Subpaving<P> &p, const StyleProperties &s = StyleProperties())

Draws a subpaving on the figure.

Parameters:
  • p – Subpaving to draw

  • s – Style of the subpaving