sandbox/huet/src/lagrangian_caps/view-ft.h
View front-tracking
This file provides functions to display the Lagrangian mesh.
#include "view.h"
macro draw_vertices (bview * view, float color[3], float ps)
{
(GL_PROJECTION);
glMatrixMode ();
glPushMatrix(0., 0., view->lc*view->fov/24.);
glTranslatef (color[0], color[1], color[2]);
glColor3f (GL_POINTS);
glEnable(view->samples*(ps > 0. ? ps : 8.));
glPointSize bool _reversed = view->reversed;
view->reversed = false;
{...}
(GL_PROJECTION);
glMatrixMode ();
glPopMatrixview->reversed = _reversed;
}
The function draw_lag
displays a triangulation in the
current view. It does not include shading effects, so displaying the
edges of the triangles is necessary to get a three-dimensional
perspective.
The arguments are:
mesh
: the Lagrangian mesh, aka the triangulation to displaynodes
: a boolean which sets whether to display Lagrangian nodes or not. It is false by default.edges
: a boolean which sets whether to display Lagrangian edges or not. It is false by default.facets
: a boolean which sets whether to display triangles or not. It is false by default.nc
: the nodes color, an array of three doubles (RGB color convention).ec
: the edges color, an array of three doubles (RGB color convention).fc
: the facets color, an array of three doubles (RGB color convention).ns
: a double setting the nodes size. If different than 0, it setsnodes
to true.lw
: a double setting the line width of the edges. If different than 0, it setsnodes
to true.
struct _draw_lag {
* mesh; // Compulsory
lagMesh bool nodes;
bool edges;
bool facets;
float fc[3], lc[3], nc[3], lw, ns;
};
void draw_lag (struct _draw_lag p)
{
if (pid() == 0) {
bool edges = p.edges;
if (p.lw > 0 || (p.lc[0] > 0 || p.lc[1] > 0 || p.lc[2] > 0))
= true;
edges bool nodes = p.nodes;
if (p.ns > 0)
= true;
nodes float my_color[3] = {0};
bview * view = draw();
if (edges) {
.lw = p.lw ? p.lw : 2.;
pif (p.lc[0])
[0] = p.lc[0], my_color[1] = p.lc[1], my_color[2] = p.lc[2];
my_colordraw_lines (view, my_color, p.lw) {
for (int i = 0; i < p.mesh->nle; i++) {
int v1, v2;
= p.mesh->edges[i].node_ids[0];
v1 = p.mesh->edges[i].node_ids[1];
v2 = correct_periodic_node_pos(p.mesh->nodes[v1].pos,
coord node1 .mesh->centroid);
p= correct_periodic_node_pos(p.mesh->nodes[v2].pos,
coord node2 .mesh->centroid);
p(GL_LINES);
glBegin#if dimension < 3
glvertex2d(view, p.mesh->nodes[v1].pos.x,
.mesh->nodes[v1].pos.y);
pglvertex2d(view, p.mesh->nodes[v2].pos.x,
.mesh->nodes[v2].pos.y);
p#else
glvertex3d(view, node1.x, node1.y, node1.z);
glvertex3d(view, node2.x, node2.y, node2.z);
#endif
();
glEndview->ni++;
}
}
}
if (nodes) {
.ns = p.ns ? p.ns : 8.;
pif (p.nc[0])
[0] = p.nc[0], my_color[1] = p.nc[1], my_color[2] = p.nc[2];
my_colordraw_vertices(view, my_color, p.ns) {
(GL_POINTS);
glBeginfor (int i = 0; i < p.mesh->nln; i++)
#if dimension < 3
glvertex2d(view, p.mesh->nodes[i].pos.x,
.mesh->nodes[i].pos.y);
p#else
glvertex3d(view, p.mesh->nodes[i].pos.x,
.mesh->nodes[i].pos.y, p.mesh->nodes[i].pos.z);
p#endif
();
glEndview->ni++;
}
}
#if dimension > 2
bool facets = p.facets;
if (facets) {
if (p.fc[0])
[0] = p.fc[0], my_color[1] = p.fc[1], my_color[2] = p.fc[2];
my_color
else[0] = 1., my_color[1] = 1., my_color[2] = 1.;
my_colorfor (int i = 0; i < p.mesh->nlt; i++) {
[3];
coord nodesfor(int j = 0; j < 3; j++)
[j] = correct_periodic_node_pos(p.mesh->nodes[p.mesh->triangles[i].node_ids[j]].pos, p.mesh->centroid);
nodes(GL_TRIANGLE_FAN);
glBegin for(int j=0; j<3; j++) {
(my_color[0], my_color[1], my_color[2]);
glColor3f (
glVertex3d[j].x,
nodes[j].y,
nodes[j].z);
nodes}
();
glEnd view->ni++;
}
}
#endif
}
}
The function below display all active capsules. Its optional
arguments are the same as the draw_lag
function.