Commit 213b18be authored by Ruben Jesus Garcia Hernandez's avatar Ruben Jesus Garcia Hernandez
Browse files

Remove warnings for atoms colours and sizes

Load encyclopaedia json from web
Replicate atoms in border
Replicate unitcell and atoms in space if requested
Display unit cell, trajectories, tesselated atoms
Add nonperiodic, repetition and showtrajectories paramters
parent 54db54d6
extern char * MainErrors [];
extern char * loadConfigFileErrors[];
#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[] =
......@@ -24,115 +32,115 @@ const char * const atomNames[] =
//not const as users may want to scale the radius
float atomColours[][4] =
{
{1.000000, 1.000000, 1.000000, 0.310000},//H
{0.851000, 1.000000, 1.000000, 0.280000},//He
{0.800000, 0.502000, 1.000000, 1.280000},//Li
{0.761000, 1.000000, 0.000000, 0.960000},//Be
{1.000000, 0.710000, 0.710000, 0.840000},//B
{0.565000, 0.565000, 0.565000, 0.760000},//C
{0.188000, 0.314000, 0.973000, 0.710000},//N
{1.000000, 0.051000, 0.051000, 0.660000},//O
{0.565000, 0.878000, 0.314000, 0.570000},//F
{0.702000, 0.890000, 0.961000, 0.580000},//Ne
{0.671000, 0.361000, 0.949000, 1.660000},//Na
{0.541000, 1.000000, 0.000000, 1.410000},//Mg
{0.749000, 0.651000, 0.651000, 1.210000},//Al
{0.941000, 0.784000, 0.627000, 1.110000},//Si
{1.000000, 0.502000, 0.000000, 1.070000},//P
{1.000000, 1.000000, 0.188000, 1.050000},//S
{0.122000, 0.941000, 0.122000, 1.020000},//Cl
{0.502000, 0.820000, 0.890000, 1.060000},//Ar
{0.561000, 0.251000, 0.831000, 2.030000},//K
{0.239000, 1.000000, 0.000000, 1.760000},//Ca
{0.902000, 0.902000, 0.902000, 1.700000},//Sc
{0.749000, 0.761000, 0.780000, 1.600000},//Ti
{0.651000, 0.651000, 0.671000, 1.530000},//V
{0.541000, 0.600000, 0.780000, 1.390000},//Cr
{0.612000, 0.478000, 0.780000, 1.390000},//Mn
{0.878000, 0.400000, 0.200000, 1.320000},//Fe
{0.941000, 0.565000, 0.627000, 1.260000},//Co
{0.314000, 0.816000, 0.314000, 1.240000},//Ni
{0.784000, 0.502000, 0.200000, 1.320000},//Cu
{0.490000, 0.502000, 0.690000, 1.220000},//Zn
{0.761000, 0.561000, 0.561000, 1.220000},//Ga
{0.400000, 0.561000, 0.561000, 1.200000},//Ge
{0.741000, 0.502000, 0.890000, 1.190000},//As
{1.000000, 0.631000, 0.000000, 1.200000},//Se
{0.651000, 0.161000, 0.161000, 1.200000},//Br
{0.361000, 0.722000, 0.820000, 1.160000},//Kr
{0.439000, 0.180000, 0.690000, 2.200000},//Rb
{0.000000, 1.000000, 0.000000, 1.950000},//Sr
{0.580000, 1.000000, 1.000000, 1.900000},//Y
{0.580000, 0.878000, 0.878000, 1.750000},//Zr
{0.451000, 0.761000, 0.788000, 1.640000},//Nb
{0.329000, 0.710000, 0.710000, 1.540000},//Mo
{0.231000, 0.620000, 0.620000, 1.470000},//Tc
{0.141000, 0.561000, 0.561000, 1.460000},//Ru
{0.039000, 0.490000, 0.549000, 1.420000},//Rh
{0.000000, 0.412000, 0.522000, 1.390000},//Pd
{0.753000, 0.753000, 0.753000, 1.450000},//Ag
{1.000000, 0.851000, 0.561000, 1.440000},//Cd
{0.651000, 0.459000, 0.451000, 1.420000},//In
{0.400000, 0.502000, 0.502000, 1.390000},//Sn
{0.620000, 0.388000, 0.710000, 1.390000},//Sb
{0.831000, 0.478000, 0.000000, 1.380000},//Te
{0.580000, 0.000000, 0.580000, 1.390000},//I
{0.259000, 0.620000, 0.690000, 1.400000},//Xe
{0.341000, 0.090000, 0.561000, 2.440000},//Cs
{0.000000, 0.788000, 0.000000, 2.150000},//Ba
{0.439000, 0.831000, 1.000000, 2.070000},//La
{1.000000, 1.000000, 0.780000, 2.040000},//Ce
{0.851000, 1.000000, 0.780000, 2.030000},//Pr
{0.780000, 1.000000, 0.780000, 2.010000},//Nd
{0.639000, 1.000000, 0.780000, 1.990000},//Pm
{0.561000, 1.000000, 0.780000, 1.980000},//Sm
{0.380000, 1.000000, 0.780000, 1.980000},//Eu
{0.271000, 1.000000, 0.780000, 1.960000},//Gd
{0.188000, 1.000000, 0.780000, 1.940000},//Tb
{0.122000, 1.000000, 0.780000, 1.920000},//Dy
{0.000000, 1.000000, 0.612000, 1.920000},//Ho
{0.000000, 0.902000, 0.459000, 1.890000},//Er
{0.000000, 0.831000, 0.322000, 1.900000},//Tm
{0.000000, 0.749000, 0.220000, 1.870000},//Yb
{0.000000, 0.671000, 0.141000, 1.870000},//Lu
{0.302000, 0.761000, 1.000000, 1.750000},//Hf
{0.302000, 0.651000, 1.000000, 1.700000},//Ta
{0.129000, 0.580000, 0.839000, 1.620000},//W
{0.149000, 0.490000, 0.671000, 1.510000},//Re
{0.149000, 0.400000, 0.588000, 1.440000},//Os
{0.090000, 0.329000, 0.529000, 1.410000},//Ir
{0.816000, 0.816000, 0.878000, 1.360000},//Pt
{1.000000, 0.820000, 0.137000, 1.360000},//Au
{0.722000, 0.722000, 0.816000, 1.320000},//Hg
{0.651000, 0.329000, 0.302000, 1.450000},//Tl
{0.341000, 0.349000, 0.380000, 1.460000},//Pb
{0.620000, 0.310000, 0.710000, 1.480000},//Bi
{0.671000, 0.361000, 0.000000, 1.400000},//Po
{0.459000, 0.310000, 0.271000, 1.500000},//At
{0.259000, 0.510000, 0.588000, 1.500000},//Rn
{0.259000, 0.000000, 0.400000, 2.600000},//Fr
{0.000000, 0.490000, 0.000000, 2.210000},//Ra
{0.439000, 0.671000, 0.980000, 2.150000},//Ac
{0.000000, 0.729000, 1.000000, 2.060000},//Th
{0.000000, 0.631000, 1.000000, 2.000000},//Pa
{0.000000, 0.561000, 1.000000, 1.960000},//U
{0.000000, 0.502000, 1.000000, 1.900000},//Np
{0.000000, 0.420000, 1.000000, 1.870000},//Pu
{0.329000, 0.361000, 0.949000, 1.800000},//Am
{0.471000, 0.361000, 0.890000, 1.690000},//Cm
{0.541000, 0.310000, 0.890000, MISSINGRADIUS},//Bk
{0.631000, 0.212000, 0.831000, MISSINGRADIUS},//Cf
{0.702000, 0.122000, 0.831000, MISSINGRADIUS},//Es
{0.702000, 0.122000, 0.729000, MISSINGRADIUS},//Fm
{0.702000, 0.051000, 0.651000, MISSINGRADIUS},//Md
{0.741000, 0.051000, 0.529000, MISSINGRADIUS},//No
{0.780000, 0.000000, 0.400000, MISSINGRADIUS},//Lr
{0.800000, 0.000000, 0.349000, MISSINGRADIUS},//Rf
{0.820000, 0.000000, 0.310000, MISSINGRADIUS},//Ha
{0.851000, 0.000000, 0.271000, MISSINGRADIUS},//Sg
{0.878000, 0.000000, 0.220000, MISSINGRADIUS},//Ns
{0.902000, 0.000000, 0.180000, MISSINGRADIUS},//Hs
{0.922000, 0.000000, 0.149000, MISSINGRADIUS},//Mt
{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
......@@ -266,4 +274,215 @@ int readAtomsCube(const char *const file, int **numatoms, int *timesteps, float
fclose(f);
return 0;
}
\ No newline at end of file
}
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);
add(clonedAtoms, 0,1,1, k);
add(clonedAtoms, 1,0,0, k);
add(clonedAtoms, 1,0,1, k);
add(clonedAtoms, 1,1,0, k);
add(clonedAtoms, 1,1,1, k);
} else if (iaz[0] && iaz[1]) {
add(clonedAtoms, 1,0,tmppos[2], k);
add(clonedAtoms, 0,1,tmppos[2], k);
add(clonedAtoms, 1,1,tmppos[2], k);
} else if (iaz[1] && iaz[2]) {
add(clonedAtoms, tmppos[0],0,1, k);
add(clonedAtoms, tmppos[0],1,0, k);
add(clonedAtoms, tmppos[0],1,1, k);
} else if (iaz[0] && iaz[2]) {
add(clonedAtoms, 0,tmppos[1],1, k);
add(clonedAtoms, 1,tmppos[1],0, k);
add(clonedAtoms, 1,tmppos[1],1, k);
} else if (iaz[0]) {
add(clonedAtoms, 1,tmppos[1], tmppos[2], k);
} else if (iaz[1]) {
add(clonedAtoms, tmppos[0],1,tmppos[2], k);
} else if (iaz[2]) {
add(clonedAtoms, tmppos[0],tmppos[1], 1, k);
}
}
......@@ -4,9 +4,11 @@
//RGH FIXME, add the other colour scheme when requested.
extern float atomColours[][4];
void discardline (FILE *F);
int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float ***pos);
int readAtomsCube(const char *const file, int **numatoms, int *timesteps, float ***pos);
int readAtomsJson (const char *const file, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms);
int readAtomsJsonURL (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms);
int readAtomsJsonURLwget (const char *const f, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms);
const float MISSINGRADIUS=0.2;
const float MISSINGR=1;
......@@ -15,4 +17,10 @@ const float MISSINGB=1;
extern char * readAtomsXYZErrors[];
extern char * readAtomsCubeErrors[];
extern char * readAtomsJsonErrors[];
extern char * readAtomsJsonErrors[];
//internal functions
void discardline (FILE *F);
void Clone (float tmppos[3], float k, std::vector<float>* clonedAtoms);
void TransformAtoms(std::vector<float>* clonedAtoms, const float abc[3][3]);
This diff is collapsed.
/*
* HappyHTTP - a simple HTTP library
* Version 0.1
*
* Copyright (c) 2006 Ben Campbell
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
*/
#ifndef HAPPYHTTP_H
#define HAPPYHTTP_H
#include <string>
#include <map>
#include <vector>
#include <deque>
// forward decl
struct in_addr;
namespace happyhttp
{
class Response;
// Helper Functions