Commit 99c5d0b0 authored by Ruben Jesus Garcia Hernandez's avatar Ruben Jesus Garcia Hernandez
Browse files

Removed files which are now in the nomad vr lib

parent 15f4da94
This repository contains the demos for GearVR using Oculus Mobile version 1.0.0.0
https://developer3.oculus.com/documentation/mobilesdk/latest/
Clone that repository and add the content of this one inside the VrSamples\Native directory.
Copy the content of the ../libs directory (rply, happyhttp, rapidjson) into NOMADGearvrT\Src
List of directories
NOMADGearvrT:
This program can load prepared molecular dynamics simulations, and is
compatible with the TimestepData OpenVR demo.
Ply support is not yet implemented
\ No newline at end of file
#include "TessShaders.h"
/*rgh: for now default tesselation control, using
glPatchParameterfv(GL_PATCH_DEFAULT_OUTER_LEVEL, {3,3,3,3});
glPatchParameterfv(GL_PATCH_DEFAULT_INNER_LEVEL, {3,3});
*/
const char * const AtomShaders [] = {
"Atom Renderer",
// vertex shader
"#version 410\n"
"uniform sampler2D atomData;\n"
"layout(location = 0) in vec3 center;\n"
"layout(location = 1) in float atomIn;\n"
"out vec4 vcolor;\n" //color , radius
"out vec3 vcen;"
"void main()\n"
"{\n"
//"gl_Position = matrix * vec4(position+center, 1);\n"
"float coord=atomIn/118.0+0.5/118.0;\n"
"vcolor=vec4(texture(atomData, vec2(coord, 0)));\n"
"vcen=center;\n"
//"color.a=1;\n"
"}\n",
//fragment shader
"#version 410 core\n"
"in vec4 color;\n"
"in vec3 vertex;"
"in vec3 normal;"
"out vec4 outputColor;\n"
"void main()\n"
"{\n"
//"vec3 U = dFdx(vertex); "
//"vec3 V = dFdy(vertex); "
"vec3 nn = normalize(normal);"
//"vec3 nn = normalize(cross(U,V));"
"lowp float a=abs(dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));\n"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));\n"
"highp vec4 res=color;\n"
" outputColor = vec4 ((res.rgb) * (0.1 + 0.2*a), color.a);\n"
"}\n",
//tess eval
"#version 400\n"
//"layout(triangles, equal_spacing, cw) in;\n"
"layout(quads, equal_spacing, cw) in;\n"
"#define pi 3.1415926535897932384626433832795\n"
"uniform mat4 matrix;\n"
//"uniform mat4 mv;\n"
"in vec4 vcolor[];\n" //color , radius
"in vec3 vcen[];"
"out vec4 color;\n" //color
"out vec3 normal;\n"
"out vec3 vertex;"
"uniform mat4 Projection;\n"
"uniform mat4 Modelview;\n"
"void main()\n"
"{\n"
"normal=vec3(sin(gl_TessCoord.x*2*pi)*cos((gl_TessCoord.y-0.5)*pi), "
"cos(gl_TessCoord.x*2*pi)*cos((gl_TessCoord.y-0.5)*pi), "
"sin((gl_TessCoord.y-0.5)*pi));"
" vertex = normal * vcolor[0].w + vcen[0];\n"
"color=vec4(vcolor[0].xyz, 1);"
"gl_Position = matrix * vec4(vertex, 1);\n"
"}\n"
};
\ No newline at end of file
#define SHADERNAME 0
#define SHADERVERTEX 1
#define SHADERFRAGMENT 2
#define SHADERTESSEVAL 3
extern const char * const AtomShaders[];
\ No newline at end of file
#include "UnitCellShaders.h"
const char * const UnitCellShaders [] = {"Unit Cell Renderer",
//vertex
"#version 410\n"
"uniform mat4 matrix;\n"
"layout(location = 0) in vec3 pos;\n"
"void main()\n"
"{\n"
"gl_Position = matrix * vec4(pos, 1);\n"
"}\n"
,
//fragment
"#version 410 core\n"
"uniform vec4 color;\n"
"out vec4 outputColor;\n"
"void main()\n"
"{\n"
" outputColor = color;\n"
"}\n"
,
//tess
nullptr
};
extern const char * const UnitCellShaders[];
\ No newline at end of file
#define NOMINMAX
#include <stdio.h>
#include <string.h>
#include <vector>
#include <winsock2.h>
#include "atoms.hpp"
#include "rapidjson/document.h"
#include "rapidjson/filereadstream.h"
#include "happyhttp.h"
const char * const atomNames[] =
{
"H", "He",
"Li", "Be", "B", "C", "N", "O", "F", "Ne",
"Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar",
"K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr",
"Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe",
"Cs", "Ba",
"La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu",
"Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn",
"Fr", "Ra",
"Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr",
"Rf", "Ha", "Sg", "Ns", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"
};
//rgb radius for easy transfer to texture. In AAngstrom
//not const as users may want to scale the radius
float atomColours[][4] =
{
{1.000000f, 1.000000f, 1.000000f, 0.310000f},//H
{0.851000f, 1.000000f, 1.000000f, 0.280000f},//He
{0.800000f, 0.502000f, 1.000000f, 1.280000f},//Li
{0.761000f, 1.000000f, 0.000000f, 0.960000f},//Be
{1.000000f, 0.710000f, 0.710000f, 0.840000f},//B
{0.565000f, 0.565000f, 0.565000f, 0.760000f},//C
{0.188000f, 0.314000f, 0.973000f, 0.710000f},//N
{1.000000f, 0.051000f, 0.051000f, 0.660000f},//O
{0.565000f, 0.878000f, 0.314000f, 0.570000f},//F
{0.702000f, 0.890000f, 0.961000f, 0.580000f},//Ne
{0.671000f, 0.361000f, 0.949000f, 1.660000f},//Na
{0.541000f, 1.000000f, 0.000000f, 1.410000f},//Mg
{0.749000f, 0.651000f, 0.651000f, 1.210000f},//Al
{0.941000f, 0.784000f, 0.627000f, 1.110000f},//Si
{1.000000f, 0.502000f, 0.000000f, 1.070000f},//P
{1.000000f, 1.000000f, 0.188000f, 1.050000f},//S
{0.122000f, 0.941000f, 0.122000f, 1.020000f},//Cl
{0.502000f, 0.820000f, 0.890000f, 1.060000f},//Ar
{0.561000f, 0.251000f, 0.831000f, 2.030000f},//K
{0.239000f, 1.000000f, 0.000000f, 1.760000f},//Ca
{0.902000f, 0.902000f, 0.902000f, 1.700000f},//Sc
{0.749000f, 0.761000f, 0.780000f, 1.600000f},//Ti
{0.651000f, 0.651000f, 0.671000f, 1.530000f},//V
{0.541000f, 0.600000f, 0.780000f, 1.390000f},//Cr
{0.612000f, 0.478000f, 0.780000f, 1.390000f},//Mn
{0.878000f, 0.400000f, 0.200000f, 1.320000f},//Fe
{0.941000f, 0.565000f, 0.627000f, 1.260000f},//Co
{0.314000f, 0.816000f, 0.314000f, 1.240000f},//Ni
{0.784000f, 0.502000f, 0.200000f, 1.320000f},//Cu
{0.490000f, 0.502000f, 0.690000f, 1.220000f},//Zn
{0.761000f, 0.561000f, 0.561000f, 1.220000f},//Ga
{0.400000f, 0.561000f, 0.561000f, 1.200000f},//Ge
{0.741000f, 0.502000f, 0.890000f, 1.190000f},//As
{1.000000f, 0.631000f, 0.000000f, 1.200000f},//Se
{0.651000f, 0.161000f, 0.161000f, 1.200000f},//Br
{0.361000f, 0.722000f, 0.820000f, 1.160000f},//Kr
{0.439000f, 0.180000f, 0.690000f, 2.200000f},//Rb
{0.000000f, 1.000000f, 0.000000f, 1.950000f},//Sr
{0.580000f, 1.000000f, 1.000000f, 1.900000f},//Y
{0.580000f, 0.878000f, 0.878000f, 1.750000f},//Zr
{0.451000f, 0.761000f, 0.788000f, 1.640000f},//Nb
{0.329000f, 0.710000f, 0.710000f, 1.540000f},//Mo
{0.231000f, 0.620000f, 0.620000f, 1.470000f},//Tc
{0.141000f, 0.561000f, 0.561000f, 1.460000f},//Ru
{0.039000f, 0.490000f, 0.549000f, 1.420000f},//Rh
{0.000000f, 0.412000f, 0.522000f, 1.390000f},//Pd
{0.753000f, 0.753000f, 0.753000f, 1.450000f},//Ag
{1.000000f, 0.851000f, 0.561000f, 1.440000f},//Cd
{0.651000f, 0.459000f, 0.451000f, 1.420000f},//In
{0.400000f, 0.502000f, 0.502000f, 1.390000f},//Sn
{0.620000f, 0.388000f, 0.710000f, 1.390000f},//Sb
{0.831000f, 0.478000f, 0.000000f, 1.380000f},//Te
{0.580000f, 0.000000f, 0.580000f, 1.390000f},//I
{0.259000f, 0.620000f, 0.690000f, 1.400000f},//Xe
{0.341000f, 0.090000f, 0.561000f, 2.440000f},//Cs
{0.000000f, 0.788000f, 0.000000f, 2.150000f},//Ba
{0.439000f, 0.831000f, 1.000000f, 2.070000f},//La
{1.000000f, 1.000000f, 0.780000f, 2.040000f},//Ce
{0.851000f, 1.000000f, 0.780000f, 2.030000f},//Pr
{0.780000f, 1.000000f, 0.780000f, 2.010000f},//Nd
{0.639000f, 1.000000f, 0.780000f, 1.990000f},//Pm
{0.561000f, 1.000000f, 0.780000f, 1.980000f},//Sm
{0.380000f, 1.000000f, 0.780000f, 1.980000f},//Eu
{0.271000f, 1.000000f, 0.780000f, 1.960000f},//Gd
{0.188000f, 1.000000f, 0.780000f, 1.940000f},//Tb
{0.122000f, 1.000000f, 0.780000f, 1.920000f},//Dy
{0.000000f, 1.000000f, 0.612000f, 1.920000f},//Ho
{0.000000f, 0.902000f, 0.459000f, 1.890000f},//Er
{0.000000f, 0.831000f, 0.322000f, 1.900000f},//Tm
{0.000000f, 0.749000f, 0.220000f, 1.870000f},//Yb
{0.000000f, 0.671000f, 0.141000f, 1.870000f},//Lu
{0.302000f, 0.761000f, 1.000000f, 1.750000f},//Hf
{0.302000f, 0.651000f, 1.000000f, 1.700000f},//Ta
{0.129000f, 0.580000f, 0.839000f, 1.620000f},//W
{0.149000f, 0.490000f, 0.671000f, 1.510000f},//Re
{0.149000f, 0.400000f, 0.588000f, 1.440000f},//Os
{0.090000f, 0.329000f, 0.529000f, 1.410000f},//Ir
{0.816000f, 0.816000f, 0.878000f, 1.360000f},//Pt
{1.000000f, 0.820000f, 0.137000f, 1.360000f},//Au
{0.722000f, 0.722000f, 0.816000f, 1.320000f},//Hg
{0.651000f, 0.329000f, 0.302000f, 1.450000f},//Tl
{0.341000f, 0.349000f, 0.380000f, 1.460000f},//Pb
{0.620000f, 0.310000f, 0.710000f, 1.480000f},//Bi
{0.671000f, 0.361000f, 0.000000f, 1.400000f},//Po
{0.459000f, 0.310000f, 0.271000f, 1.500000f},//At
{0.259000f, 0.510000f, 0.588000f, 1.500000f},//Rn
{0.259000f, 0.000000f, 0.400000f, 2.600000f},//Fr
{0.000000f, 0.490000f, 0.000000f, 2.210000f},//Ra
{0.439000f, 0.671000f, 0.980000f, 2.150000f},//Ac
{0.000000f, 0.729000f, 1.000000f, 2.060000f},//Th
{0.000000f, 0.631000f, 1.000000f, 2.000000f},//Pa
{0.000000f, 0.561000f, 1.000000f, 1.960000f},//U
{0.000000f, 0.502000f, 1.000000f, 1.900000f},//Np
{0.000000f, 0.420000f, 1.000000f, 1.870000f},//Pu
{0.329000f, 0.361000f, 0.949000f, 1.800000f},//Am
{0.471000f, 0.361000f, 0.890000f, 1.690000f},//Cm
{0.541000f, 0.310000f, 0.890000f, MISSINGRADIUS},//Bk
{0.631000f, 0.212000f, 0.831000f, MISSINGRADIUS},//Cf
{0.702000f, 0.122000f, 0.831000f, MISSINGRADIUS},//Es
{0.702000f, 0.122000f, 0.729000f, MISSINGRADIUS},//Fm
{0.702000f, 0.051000f, 0.651000f, MISSINGRADIUS},//Md
{0.741000f, 0.051000f, 0.529000f, MISSINGRADIUS},//No
{0.780000f, 0.000000f, 0.400000f, MISSINGRADIUS},//Lr
{0.800000f, 0.000000f, 0.349000f, MISSINGRADIUS},//Rf
{0.820000f, 0.000000f, 0.310000f, MISSINGRADIUS},//Ha
{0.851000f, 0.000000f, 0.271000f, MISSINGRADIUS},//Sg
{0.878000f, 0.000000f, 0.220000f, MISSINGRADIUS},//Ns
{0.902000f, 0.000000f, 0.180000f, MISSINGRADIUS},//Hs
{0.922000f, 0.000000f, 0.149000f, MISSINGRADIUS},//Mt
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Ds
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Rg
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Cn
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Nh
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Fl
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Mc
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Lv
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Ts
{MISSINGR, MISSINGG, MISSINGB, MISSINGRADIUS},//Og
};
void discardline (FILE *F)
{
int c;
do {
c = fgetc(F);
} while (c != EOF && c != '\n');
}
int findAtom(const char *const s)
{
//rgh FIXME, add caching
for (int i=0;i<sizeof(atomNames)/sizeof(const char *);i++)
if (!strcmp(s, atomNames[i]))
return i;
return -1;
}
char * readAtomsXYZErrors[] = {
"All Ok",//0
"could not open file", //-1
"error loading atom type and position line", //-2
"atom type unknown", //-3
};
int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float ***pos)
{
int mynumatoms;
std::vector<float*> mypos;
std::vector<int> mynum;
FILE *f=fopen (file, "r");
int r;
char s[100];
if (f==0)
return -1;
*timesteps=0;
while (!feof(f)) {
r=fscanf(f, "%d", &mynumatoms);
if (r<1)
continue; //there may be a blank line at the end of the file
(*timesteps)++;
discardline (f);
mypos.push_back(new float[mynumatoms*4]);
mynum.push_back(mynumatoms);
discardline (f); //comment
for (int i=0;i<mynumatoms;i++) {
r=fscanf (f, "%s %f %f %f", s, mypos.back()+4*i+0, mypos.back()+4*i+1,mypos.back()+4*i+2);
if (r<4)
return -2;
int a=findAtom(s);
if (a==-1)
return -3;
(mypos.back())[4*i+3]=a;
}
}
*pos=new float*[*timesteps];
*numatoms=new int[*timesteps];
for (int i=0;i<*timesteps;i++) {
(*pos)[i]=mypos[i];
(*numatoms)[i]=mynum[i];
}
return 0;
}
char * readAtomsCubeErrors [] ={
"All Ok", //0
"could not open file", //-1
"could not read number of atoms or translation", //-2
"could not read voxel size or unit cell", //-3
"error loading atom type and position line", //-4
};
//We will use Angstrom, convert from bohr if needed
//rgh FIXME, untested code
int readAtomsCube(const char *const file, int **numatoms, int *timesteps, float ***pos)
{
float isoTrans[3];
int voxelSize[3];
float abc[9];
FILE *f = fopen(file, "r");
int r;
if (f == 0)
return -1;
*timesteps = 1;
*pos = new float*[*timesteps];
*numatoms = new int[*timesteps];
discardline(f); //two comments
discardline(f);
r = fscanf(f, "%d %f %f %f", *numatoms, isoTrans + 0, isoTrans + 1, isoTrans + 2);
if (r < 4)
return -2;
**pos = new float[4 * **numatoms];
for (int i = 0; i < 3; i++) {
r = fscanf(f, "%d %f %f %f", voxelSize+i, abc + 0 + 3 * i, abc + 1 + 3 * i, abc + 2 + 3 * i);
if (r < 4)
return -3;
//positive then the units are Bohr, if negative then Angstroms.
if (voxelSize[i] < 0)
voxelSize[i] = -voxelSize[i];
else {
for (int j = 0; j < 3; j++)
abc[j + 3 * i] *= 0.52918;
}
}
for (int i = 0; i < **numatoms; i++) {
int a;
float unused;
r = fscanf(f, "%d %f %f %f %f", &a, &unused, &((**pos)[4 * i + 0]), &((**pos)[4 * i + 1]), &((**pos)[4 * i + 2]));
if (r < 5)
return -4;
(**pos)[4 * i + 3] = a - 1;
}
//rgh FIXME, discard the volumetric data for now
fclose(f);
return 0;
}
FILE *out;
void OnData( const happyhttp::Response* r, void* userdata, const unsigned char* data, int n )
{
fwrite( data,1,n, out );
}
char * readAtomsJsonErrors[] = {
"All Ok",//0
"could not open file", //-1
"error parsing json", //-2
"error downloading json", //-3
};
int readAtomsJsonURL (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3],
std::vector<float>** clonedAtoms)
{
try {
char host[2048], page[2048], url[2048];
int port=80;
int r;
//http://stackoverflow.com/questions/726122/best-ways-of-parsing-a-url-using-c
r=sscanf (f, "http://%2047[^/:]:%d%2047[^\n]", host, &port, page);
if (r==1)
r=sscanf (f, "http://%2047[^/]%2047[^\n]", host, page);
if (r<2) { //possibly https or other unsupported protocol, fall back to wget
return readAtomsJsonURLwget (f, numatoms, timesteps, pos, abc, clonedAtoms);
}
sprintf (url, "%s%s", page, "/cells");
out=fopen("material_cells.json", "w");
happyhttp::Connection conn( host, port );
conn.setcallbacks( nullptr, OnData, nullptr, 0 );
conn.request( "GET", url, 0, 0,0 );
while( conn.outstanding() )
conn.pump();
fclose(out);
conn.close();
sprintf (url, "%s%s", page, "/elements");
out=fopen("material_elements.json", "w");
conn.request( "GET", url, 0, 0,0 );
while( conn.outstanding() )
conn.pump();
fclose(out);
} catch (const happyhttp::Wobbly& w) {
int e= WSAGetLastError();
fprintf (stderr, "error %d\n", e);
return -3;
}
fclose(out);
//sprintf (cmd, "wget %s/cells -O material_cells.json", f);
//system(cmd);
//sprintf (cmd, "wget %s/elements -O material_elements.json", f);
//system(cmd);
return readAtomsJson ("material", numatoms, timesteps, pos, abc, clonedAtoms);
}
int readAtomsJsonURLwget (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3],
std::vector<float>** clonedAtoms)
{
char cmd[2048];
int ret;
sprintf (cmd, "wget %s/cells -O material_cells.json", f);
ret=system(cmd);
if (ret!=0)
return (-3);
sprintf (cmd, "wget %s/elements -O material_elements.json", f);
ret=system(cmd);
return(-3);
return readAtomsJson ("material", numatoms, timesteps, pos, abc, clonedAtoms);
}
bool isAlmostZero(float coordinate)
{
return (coordinate < 1E-5);
}
void add (std::vector<float> *v, float x, float y, float z, float a)
{
v->push_back(x);
v->push_back(y);
v->push_back(z);
v->push_back(a);
}
int readAtomsJson (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3],
std::vector<float>** clonedAtoms)
{
char file[512];
int r;
sprintf (file, "%s_cells.json", f);
FILE *fcells=fopen (file, "r");
if (fcells==0)
return -1;
char readBuffer[65536];
rapidjson::FileReadStream is(fcells, readBuffer, sizeof(readBuffer));
rapidjson::Document json;
json.ParseStream(is);
fclose(fcells);
int total_results=json["total_results"].GetInt();
const rapidjson::GenericValue<rapidjson::UTF8<> > &results=json["results"];
for (int i=0;i<total_results;i++) {
const rapidjson::GenericValue<rapidjson::UTF8<> > &result=results[i];
if (result["is_primitive"].GetBool()==false)
continue;
const char *myabc[3]={result["a"].GetString(), result["b"].GetString(), result["c"].GetString()};
for (int j=0;j<3;j++) {
r=sscanf(myabc[j], "(%f,%f,%f)", &(abc[j][0]), &(abc[j][1]), &(abc[j][2]));
for (int k=0;k<3;k++)
abc[j][k]*=1e10; //using angstrom internally
}
}
sprintf (file, "%s_elements.json", f);
FILE *felements=fopen (file, "r");
if (felements==0)
return -1;
rapidjson::FileReadStream is2(felements, readBuffer, sizeof(readBuffer));
json.ParseStream(is2);
fclose(felements);
*timesteps=1;
*pos = new float*[*timesteps];
*numatoms = new int[*timesteps];
**numatoms=json["total_results"].GetInt();
**pos=new float[4* **numatoms];
*clonedAtoms=new std::vector<float>[*timesteps];
const rapidjson::GenericValue<rapidjson::UTF8<> >& a = json["results"];
float tmppos[3];
for (int i=0;i< **numatoms;i++)
{
const rapidjson::GenericValue<rapidjson::UTF8<> > &result=a[i];
const rapidjson::GenericValue<rapidjson::UTF8<> > &label=result["label"];
if (!label.IsInt())
return -2;
int k=label.GetInt();
(**pos)[4*i + 3]=k;
const char *stringpos=result["position"].GetString();
r=sscanf(stringpos, "(%f,%f,%f)", tmppos+0, tmppos+1, tmppos+2);
//clone
//https://gitlab.mpcdf.mpg.de/nomad-lab/encyclopedia-gui/blob/lauri_viz/viztools/structure/src/typescript/structureviewer.ts
Clone (tmppos, k, *clonedAtoms);
//atom positions in the abc domain, must multiply.
for (int s=0;s<3;s++)
(**pos)[4*i+s]=tmppos[0]*abc[0][s]+tmppos[1]*abc[1][s]+tmppos[2]*abc[2][s];
}
TransformAtoms(*clonedAtoms, abc);
return 0;
}
void TransformAtoms(std::vector<float>* clonedAtoms, const float abc[3][3])
{
float tmppos[3];
for (int o=0;o<clonedAtoms->size()/4;o++) {
for (int s=0;s<3;s++)
tmppos[s]=(*clonedAtoms)[o*4+s];
for (int s=0;s<3;s++)
(*clonedAtoms)[o*4+s]=tmppos[0]*abc[0][s]+tmppos[1]*abc[1][s]+tmppos[2]*abc[2][s];
}
}
void Clone (float tmppos[3], float k, std::vector<float>* clonedAtoms)
{
bool iaz[3];
for (int q=0;q<3;q++)
iaz[q]=isAlmostZero(tmppos[q]);
if (iaz[0] && iaz[1] &&iaz[2]){
add(clonedAtoms, 0,0,1, k);
add(clonedAtoms, 0,1,0, k);