80 vertices[
val+1] = s.y;
81 vertices[
val+2] = s.z;
82 vertices[
val+3] = n.x;
83 vertices[
val+4] = n.y;
84 vertices[
val+5] = n.z;
103 vec3_t edge_a = v3_sub(v3, v1);
104 vec3_t edge_b = v3_sub(v2, v1);
105 vec3_t normal = v3_norm (v3_cross(edge_a, edge_b));
106 vec3_t plane = v3_add (v1, v3_add(v2, v3));
107 plane = v3_divs (plane, 3.0);
109 if (v3_dot (v3_sub(plane,
centroid), normal) < 0)
113 return v3_muls (normal, sign);
154 int i, j, k, l, n, o, p, q, r;
158 for (n=0; n<
plot -> extra_cell[0]+1;n++)
160 for (o=0; o<
plot -> extra_cell[1]+1; o++)
162 for (p=0; p<
plot -> extra_cell[2]+1; p++)
169 for (r=0; r<3; r++) xyz[q][r] +=
shift[r];
173 for (i=0; i<s-2; i++)
175 for (j=i+1; j<s-1; j++)
177 for (k=j+1; k<s; k++)
181 a = vec3 (xyz[i][0], xyz[i][1], xyz[i][2]);
182 b = vec3 (xyz[j][0], xyz[j][1], xyz[j][2]);
183 c = vec3 (xyz[k][0], xyz[k][1], xyz[k][2]);
193 for (r=0; r<3; r++) xyz[q][r] -=
shift[r];
232 for (n=0; n<
plot -> extra_cell[0]+1;n++)
234 for (o=0; o<
plot -> extra_cell[1]+1; o++)
236 for (p=0; p<
plot -> extra_cell[2]+1; p++)
243 for (r=0; r<3; r++) xyz[q][r] +=
shift[r];
245 setup_tetra (vertices, vec3(xyz[0][0], xyz[0][1], xyz[0][2]),
246 vec3(xyz[1][0], xyz[1][1], xyz[1][2]),
247 vec3(xyz[2][0], xyz[2][1], xyz[2][2]),
248 vec3(xyz[3][0], xyz[3][1], xyz[3][2]));
252 for (r=0; r<3; r++) xyz[q][r] -=
shift[r];
291 if (p.x > mi[0] && p.x < ma[0])
293 if (p.y > mi[1] && p.y < ma[1])
295 if (p.z > mi[2] && p.z < ma[2])
316 float area = 0.5 * v3_length(v3_cross(v3_sub(
a,
b), v3_sub(
a,
c)));
317 float alpha = v3_length(v3_cross(v3_sub(p,
b), v3_sub(p,
c))) / (2.0*area);
318 float beta = v3_length(v3_cross(v3_sub(p,
c), v3_sub(p,
a))) / (2.0*area);
319 float gamma = 1 - alpha - beta;
320 if ((alpha >= 0.0 && alpha <= 1.0) && (beta >= 0.0 && beta <= 1.0) && (gamma >= 0.0 && gamma <= 1.0))
342 if (l != i && l != j && l != k)
362 int h, i, j, k, l, m, n;
365 vec3_t vi, vj, vk, vl, vm;
368 float min_c[3], min_p[3];
369 float max_c[3], max_p[3];
376 min_c[i] = max_c[i] = xyz[0][i];
382 min_c[j] =
min (min_c[j], xyz[i][j]);
383 max_c[j] =
max (max_c[j], xyz[i][j]);
436 for (i=0; i<s-2; i++)
438 for (j=i+1; j<s-1; j++)
440 for (k=j+1; k<s; k++)
447 vi = vec3(xyz[i][0], xyz[i][1], xyz[i][2]);
448 vj = vec3(xyz[j][0], xyz[j][1], xyz[j][2]);
449 vk = vec3(xyz[k][0], xyz[k][1], xyz[k][2]);
454 d = - v3_dot (p, vi);
457 for (l=0; l<s-1; l++)
461 vl = vec3(xyz[l][0], xyz[l][1], xyz[l][2]);
462 for (m=l+1; m<s; m++)
466 vm = vec3(xyz[m][0], xyz[m][1], xyz[m][2]);
468 vd = - (v3_dot (p, vm) +
d);
476 pt = v3_add (v3_muls(w, r), vm);
481 min_p[n] =
min(xyz[l][n], xyz[m][n]);
482 max_p[n] =
max(xyz[l][n], xyz[m][n]);
497 if (!
do_gl[h])
break;
523 for (l=0; l < at.
numv; l++)
527 xyz[l][0] = at.
x -
d.x;
528 xyz[l][1] = at.
y -
d.y;
529 xyz[l][2] = at.
z -
d.z;
530 if (
d.pbc) clones = TRUE;
566 k = fmol ->
mol -> natoms;
637 int h, i, j, k, l, m, n, o, p, q;
639 g_debug (
"Poly LIST");
647 for (j=0; j<
coord_gl -> totcoord[i]; j++)
649 if (
plot -> show_poly[i])
651 if (
plot -> show_poly[i][j])
665 for (j=0; j<
coord_gl -> totcoord[i]; j++)
675 if (n == j &&
plot -> show_poly[i] &&
plot -> show_poly[i][n])
682 o +=
coord_gl -> partial_geo[n][m][p];
687 q = (o == 3) ? o+1: o;
689 npoly[i][j] += p*(q*(q-1)*(q-2)/6);
692 ptot += npoly[i][j]*3;
699 object_3d * poly = g_malloc0 (
sizeof*poly);
701 poly -> num_vertices = ptot * (
plot -> extra_cell[0]+1)*(
plot -> extra_cell[1]+1)*(
plot -> extra_cell[2]+1);
702 poly -> vertices =
allocfloat (poly -> vert_buffer_size*poly -> num_vertices);
706 for (j=0; j<
coord_gl -> totcoord[i]; j++)
Structure definitions for color management Function declarations for color management.
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
void setup_summit(float *vertices, vec3_t s, vec3_t n)
prepare the polygon summit to render
void check_triangles(int s, GLfloat **xyz)
check triangle intersection
gboolean check_it(int i, int j, int k, int l)
test this atom id ?
void get_centroid(GLfloat **xyz, int id)
find the barycenter of a polyhedron
gboolean is_inside(vec3_t p, float *mi, float *ma)
is this point inside the polyhedron ?
void setup_tetra(float *vertices, vec3_t a, vec3_t b, vec3_t c, vec3_t d)
fill the OpenGL data buffer for a tetrahedra to render
void prepare_poly_gl(float *vertices, atom at, int c)
prepare the OpenGL rendering of a polyhedron
void create_poly_lists()
prepare coordination polyhedra(s) OpenGL rendering
vec3_t get_triangle_normal(vec3_t v1, vec3_t v2, vec3_t v3)
compute triangle normal vector
int is_atom_cloned(int at)
does this atom have clone(s) ?
gboolean is_in_triangle(vec3_t p, vec3_t a, vec3_t b, vec3_t c)
is this point inside a triangle ?
void setup_tetrahedron(float *vertices, GLfloat **xyz)
fill the OpenGL data buffer for a tetrahedra to render
void setup_triangles(float *vertices, vec3_t sa, vec3_t sb, vec3_t sc)
setup triangle veertices
void setup_polyhedron(float *vertices, GLfloat **xyz, int s)
fill the OpenGL data buffer for a polyhedron to render
field_molecule * get_active_field_molecule_from_model_id(project *this_proj, int aid)
retrieve field molecule from overall atom id in the model
Variable declarations for the creation of the DL_POLY input file(s)
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
float ** allocdfloat(int xal, int yal)
allocate a float ** pointer
gboolean * allocbool(int val)
allocate a gboolean * pointer
int * allocint(int val)
allocate an int * pointer
float * allocfloat(int val)
allocate a float * pointer
Global variable declarations Global convenience function declarations Global data structure defin...
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
void cleaning_shaders(glwin *view, int shader)
re-initialize an OpenGL shader
glsl_program * init_shader_program(int object, int object_id, const GLchar *vertex, const GLchar *geometry, const GLchar *fragment, GLenum type_of_vertices, int narray, int nunif, gboolean lightning, object_3d *obj)
create an OpenGL shader program
G_MODULE_EXPORT void cloned_poly(GtkWidget *widg, gpointer data)
cloned polyehdra callback - GTK3
const GLchar * full_color
const GLchar * full_vertex