diff --git a/NOMADVRLib/atoms.cpp b/NOMADVRLib/atoms.cpp index 679f588d476d7b49655886fcaf425188f7a0a8fc..25baead3f3ebb1959151e4032d515ba375833101 100644 --- a/NOMADVRLib/atoms.cpp +++ b/NOMADVRLib/atoms.cpp @@ -279,6 +279,7 @@ int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float * { const char *myfile=nullptr; const char *webdownload="material.xyz"; +#if !defined(OCULUSMOBILE) && !defined(__ANDROID__) //add http support if (!strncmp(file, "http:", 5) || !strncmp(file, "https:", 6)) { char cmd[2048]; @@ -294,6 +295,9 @@ int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float * } else { myfile = file; } +#else + myfile=file; +#endif int mynumatoms; std::vector mypos; std::vector mynum; diff --git a/webserver/Readme.md b/webserver/Readme.md new file mode 100644 index 0000000000000000000000000000000000000000..5da7a58896b387d612d96bf6ece6deb68f93e419 --- /dev/null +++ b/webserver/Readme.md @@ -0,0 +1,38 @@ +This directory contains the support files for the CGI backend to obtain +NOMAD VR files from the Encyclopedia and Archive. + +Directories: + htdocs: Example files related to NOMAD VR + cgi-bin: CGI-backend + +Files: + Readme.md: This document + pass: Information on the NOMAD user under which the data is accessed. + + cgi-bin/NOMAD/material: + + Entry point for NOMAD Encyclopedia. + See also the VR tutorial at + https://www.nomad-coe.eu/the-project/graphics/vrtutorial6 + In the Encyclopedia webpage for a given material: + https://encyclopedia.nomad-coe.eu/gui/#/material/ + the link "Virtual Reality files" -> "Get VR file" points to + http://nomad.srv.lrz.de/cgi-bin/NOMAD/material? + This entry point creates a zip file with a the crystal structure of mat_id. + + cgi-bin/NOMAD/materialAnalytics: + + Entry point for NOMAD Archive / Analytics. + See also the VR tutorial at + https://www.nomad-coe.eu/the-project/graphics/vrtutorial5 + In the analytics toolkit tutorial webpage, the tutorial + "Querying and visualizing the content of the NOMAD Archive" at + https://analytics-toolkit.nomad-coe.eu/notebook-edit/data/shared/tutorialsNew/nomad-query/nomad-query.bkr + The results of the queries have the form: + nmd:// + with the link "Virtual Reality" pointing to + http://nomad.srv.lrz.de/cgi-bin/NOMAD/materialAnalytics? + This entry point creates a zip file with the structure or molecular dynamics + for . + + \ No newline at end of file diff --git a/webserver/cgi-bin/NOMAD/materialAnalytics b/webserver/cgi-bin/NOMAD/materialAnalytics new file mode 100644 index 0000000000000000000000000000000000000000..fdeabc6eb3beec0c1f001da7fa52dbb253e064a5 --- /dev/null +++ b/webserver/cgi-bin/NOMAD/materialAnalytics @@ -0,0 +1,78 @@ +#!/bin/bash + +export DATASOURCE=https://analytics-toolkit.nomad-coe.eu/api/resolve + +if [[ "$QUERY_STRING" = "" ]] +then + #echo Location: /NOMAD/ + echo Location:https://www.nomad-coe.eu/the-project/graphics/VR-prototype + echo '' +else +#rgh: text/plain works in pc but android chrome saves it as .txt, removing the extension + +# export TOKEN=`cat t.b64` + export RAND=$RANDOM +#rgh: before end of september 2017, use /var/tmp, after, use /tmp (apache update) + cd /tmp + /usr/bin/mkdir $RAND + cd $RAND + + export MAT=`echo $QUERY_STRING|cut -f 2 -d/` + + mkdir $MAT + cd $MAT +#Some systems have atomic positions in section_system:0 +#Others don't; they start at section_system:1 +#Better to download all and test this in NOMADVR. +# wget --no-check-certificate https://analytics-toolkit.nomad-coe.eu/api/resolve/$QUERY_STRING/section_run/0c/section_system/0c?format=recursiveJson -O material.json + + if [[ $QUERY_STRING = *"section_run"* ]] + then + QS=$QUERY_STRING + else + QS=$QUERY_STRING/section_run/0c + fi + + wget --no-check-certificate $DATASOURCE/$QS?format=recursiveJson -O \ + materialtmp.json + + if [[ $QUERY_STRING = *"section_run"* ]] + then + echo "{ "section_system" : [" >>material.json + cat materialtmp.json >> material.json + echo "] }" >> material.json + rm materialtmp.json + else + mv materialtmp.json material.json + fi + + export FORMULA=`grep system_composition material.json|head -n 1 |cut -f 4 -d\"` + + if [[ "$FORMULA" = "" ]] + then + echo "Content-type: text/html" + echo '' + echo "" + echo "No system_composition found in json: no information to display in VR" + echo "" + else + + echo \# Material $QUERY_STRING >> $FORMULA.ncfg + echo background 0 0 0 >> $FORMULA.ncfg + echo atomscaling 0.5 >> $FORMULA.ncfg + echo analyticsjson material.json >> $FORMULA.ncfg + echo displaybonds >> $FORMULA.ncfg + echo displayunitcell >> $FORMULA.ncfg + echo showcontrollers >> $FORMULA.ncfg + cd .. + + zip -r $MAT $MAT >/dev/null 2>&1 + + echo "Content-type: application/octet-stream" + echo "Content-disposition: attachment; filename=${QUERY_STRING}.zip" + echo '' + cat $MAT.zip + fi + cd .. +# \rm -r $RAND +fi