|
funkalicious 0.1
|
00001 /* 00002 ** wf2pov.c 00003 ** 00004 ** Made by (Johnny Q. Hacker) 00005 ** Login <solarion@nathan> 00006 ** 00007 00008 Copyright (C) 2010 Joseph Pingenot 00009 00010 This program is free software: you can redistribute it and/or modify 00011 it under the terms of the GNU Affero General Public License as published by 00012 the Free Software Foundation, either version 3 of the License, or 00013 (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU Affero General Public License for more details. 00019 00020 You should have received a copy of the GNU Affero General Public License 00021 along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 00023 ** Started on Sat Mar 13 10:13:21 2010 Johnny Q. Hacker 00024 ** Last update Sun May 12 01:17:25 2002 Speed Blue 00025 */ 00026 00027 #include <stdio.h> 00028 #include <stdlib.h> 00029 #include <glib-2.0/glib.h> 00030 #include <gio/gio.h> 00031 #include <libdotcode/function_parser.h> 00032 #include <libpostproc/lp_wavefunction.h> 00033 00034 int main(int argc, char** argv) { 00035 g_type_init(); 00036 GError *e = NULL; 00037 struct wavefunction wf; 00038 GList *wfl = NULL; 00039 for(int fi=1; fi<argc; fi++) { 00040 e=NULL; 00041 wf.file = g_file_new_for_commandline_arg(argv[fi]); 00042 wf.charge = 1.0; 00043 wfl = g_list_append(NULL, &wf); 00044 GError *e = NULL; 00045 load_wavefunctions(wfl, &e); 00046 if(e != NULL) { 00047 fprintf(stderr, "ERROR loading wavefunction (%s): %s\n", argv[fi], e->message); 00048 g_list_free(wfl); 00049 g_object_unref(wf.file); 00050 continue; 00051 } 00052 struct density *d = get_density_for_list_of_wavefunctions(wfl, &e); 00053 if(e != NULL) { 00054 fprintf(stderr, "ERROR loading wavefunction into density (%s): %s\n", argv[fi], e->message); 00055 free(wf.storage); 00056 g_list_free(wfl); 00057 g_object_unref(wf.file); 00058 continue; 00059 } 00060 00061 GString *s = g_string_new(g_file_get_uri(wf.file)); 00062 s = g_string_append(s, ".pov"); 00063 GFile *outfile = g_file_new_for_uri(s->str); 00064 write_density_povray(d, outfile, 0, &e); 00065 if(e != NULL) { 00066 fprintf(stderr, "ERROR writing density to povray file (%s): %s\n", s->str, e->message); 00067 } 00068 g_string_free(s, TRUE); 00069 00070 free_density(d); 00071 g_list_free(wfl); 00072 g_object_unref(wf.file); 00073 free(wf.storage); 00074 } 00075 return 0; 00076 }