funkalicious 0.1

wf2pov.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <glib-2.0/glib.h>
#include <gio/gio.h>
#include <libdotcode/function_parser.h>
#include <libpostproc/lp_wavefunction.h>
Include dependency graph for wf2pov.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 34 of file wf2pov.c.

References wavefunction::charge, e, wavefunction::file, free_density(), get_density_for_list_of_wavefunctions(), load_wavefunctions(), wavefunction::storage, and write_density_povray().

                                {
  g_type_init();
  GError *e = NULL;
  struct wavefunction wf;
  GList *wfl = NULL;
  for(int fi=1; fi<argc; fi++) {
    e=NULL;
    wf.file = g_file_new_for_commandline_arg(argv[fi]);
    wf.charge = 1.0;
    wfl = g_list_append(NULL, &wf);
    GError *e = NULL;
    load_wavefunctions(wfl, &e);
    if(e != NULL) {
      fprintf(stderr, "ERROR loading wavefunction (%s): %s\n", argv[fi], e->message);
      g_list_free(wfl);
      g_object_unref(wf.file);
      continue;
    }
    struct density *d = get_density_for_list_of_wavefunctions(wfl, &e);
    if(e != NULL) {
      fprintf(stderr, "ERROR loading wavefunction into density (%s): %s\n", argv[fi], e->message);
      free(wf.storage);
      g_list_free(wfl);
      g_object_unref(wf.file);
      continue;
    }

    GString *s = g_string_new(g_file_get_uri(wf.file));
    s = g_string_append(s, ".pov");
    GFile *outfile = g_file_new_for_uri(s->str);
    write_density_povray(d, outfile, 0, &e);
    if(e != NULL) {
      fprintf(stderr, "ERROR writing density to povray file (%s): %s\n", s->str, e->message);
    }
    g_string_free(s, TRUE);

    free_density(d);
    g_list_free(wfl);
    g_object_unref(wf.file);
    free(wf.storage);
  }
  return 0;
}

Here is the call graph for this function:

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines