aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rw-r--r--src/povray.c121
-rw-r--r--src/povray.h6
-rw-r--r--src/render_hkl.c10
5 files changed, 96 insertions, 45 deletions
diff --git a/Makefile.am b/Makefile.am
index 541b02b9..bf20389d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,5 +9,5 @@ EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h \
src/povray.h src/index-priv.h src/geometry.h src/templates.h \
data/sfac/Ca.nff data/sfac/C.nff data/sfac/Fe.nff data/sfac/H.nff \
data/sfac/Mg.nff data/sfac/N.nff data/sfac/O.nff data/sfac/P.nff \
- data/sfac/S.nff data/sfac/f0_WaasKirf.dat
+ data/sfac/S.nff data/sfac/f0_WaasKirf.dat src/render_hkl.h
SUBDIRS = src data doc
diff --git a/Makefile.in b/Makefile.in
index 2bc98a35..19434a30 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -206,7 +206,7 @@ EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h \
src/povray.h src/index-priv.h src/geometry.h src/templates.h \
data/sfac/Ca.nff data/sfac/C.nff data/sfac/Fe.nff data/sfac/H.nff \
data/sfac/Mg.nff data/sfac/N.nff data/sfac/O.nff data/sfac/P.nff \
- data/sfac/S.nff data/sfac/f0_WaasKirf.dat
+ data/sfac/S.nff data/sfac/f0_WaasKirf.dat src/render_hkl.h
SUBDIRS = src data doc
all: config.h
diff --git a/src/povray.c b/src/povray.c
index d28bcdee..a4864aba 100644
--- a/src/povray.c
+++ b/src/povray.c
@@ -21,13 +21,16 @@
#include "cell.h"
#include "utils.h"
+#include "symmetry.h"
+#include "render_hkl.h"
#define MAX_PROC (256)
-int povray_render_animation(UnitCell *cell, double *ref,
- unsigned int *c, unsigned int nproc)
+int povray_render_animation(UnitCell *cell, double *ref, unsigned int *counts,
+ ReflItemList *items, unsigned int nproc,
+ const char *sym, int wght, double boost)
{
FILE *fh;
double asx, asy, asz;
@@ -36,7 +39,6 @@ int povray_render_animation(UnitCell *cell, double *ref,
pid_t pids[MAX_PROC];
float max;
int i;
- signed int h, k, l;
if ( (nproc > MAX_PROC) || (nproc < 1) ) {
ERROR("Number of processes must be a number between 1 and %i\n",
@@ -162,20 +164,68 @@ int povray_render_animation(UnitCell *cell, double *ref,
fprintf(fh, "}\n");
- max = 0.5e6;
- for ( h=-INDMAX; h<INDMAX; h++ ) {
- for ( k=-INDMAX; k<INDMAX; k++ ) {
- for ( l=-INDMAX; l<INDMAX; l++ ) {
+ max = 0.0;
+ for ( i=0; i<num_items(items); i++ ) {
- float radius, x, y, z;
+ struct refl_item *it;
+ float val;
+
+ it = get_item(items, i);
+
+ switch ( wght ) {
+ case WGHT_I :
+ val = lookup_intensity(ref, it->h, it->k, it->l);
+ break;
+ case WGHT_SQRTI :
+ val = lookup_intensity(ref, it->h, it->k, it->l);
+ val = (val>0.0) ? sqrt(val) : 0.0;
+ break;
+ case WGHT_COUNTS :
+ val = lookup_count(counts, it->h, it->k, it->l);
+ val /= (float)num_equivs(it->h, it->k, it->l, sym);
+ break;
+ case WGHT_RAWCOUNTS :
+ val = lookup_count(counts, it->h, it->k, it->l);
+ break;
+ default :
+ ERROR("Invalid weighting.\n");
+ abort();
+ }
+
+ if ( val > max ) max = val;
+
+ }
+ max /= boost;
+
+ for ( i=0; i<num_items(items); i++ ) {
+
+ struct refl_item *it;
+ float radius;
int s;
float val, p, r, g, b, trans;
+ int j;
- if ( !lookup_count(c, h, k, l) ) continue;
-
- val = lookup_intensity(ref, h, k, l);
+ it = get_item(items, i);
- val = max-val;
+ switch ( wght ) {
+ case WGHT_I :
+ val = lookup_intensity(ref, it->h, it->k, it->l);
+ break;
+ case WGHT_SQRTI :
+ val = lookup_intensity(ref, it->h, it->k, it->l);
+ val = (val>0.0) ? sqrt(val) : 0.0;
+ break;
+ case WGHT_COUNTS :
+ val = lookup_count(counts, it->h, it->k, it->l);
+ val /= (float)num_equivs(it->h, it->k, it->l, sym);
+ break;
+ case WGHT_RAWCOUNTS :
+ val = lookup_count(counts, it->h, it->k, it->l);
+ break;
+ default :
+ ERROR("Invalid weighting.\n");
+ abort();
+ }
s = val / (max/6);
p = fmod(val, max/6);
@@ -214,30 +264,33 @@ int povray_render_animation(UnitCell *cell, double *ref,
break;
}
- val = max-val;
-
if ( val <= 0.0 ) continue;
- radius = 0.1 * sqrt(sqrt(val))/1e2;
- radius -= 0.008;
- if ( radius > 0.03 ) radius = 0.03;
- if ( radius <= 0.0 ) continue;
- trans = (0.03-radius)/0.03;
- radius += 0.002;
-
- x = asx*h + bsx*k + csx*l;
- y = asy*h + bsy*k + csy*l;
- z = asz*h + bsz*k + csz*l;
-
- fprintf(fh, "sphere { <%.5f, %.5f, %.5f>, %.5f "
- "texture{pigment{color rgb <%f, %f, %f>"
- " transmit %f} "
- "finish { reflection 0.1 } } \n"
- "transform { TRANS }\n"
- "}\n",
- x/1e9, y/1e9, z/1e9, radius, r, g, b, trans);
+ radius = 0.01 * pow(val, 0.25)/pow(max, 0.25);
+ trans = 1.0-(val/max);
+
+ /* For each equivalent */
+ for ( j=0; j<num_equivs(it->h, it->k, it->l, sym); j++ ) {
+
+ signed int he, ke, le;
+ float x, y, z;
+
+ get_equiv(it->h, it->k, it->l, &he, &ke, &le, sym, j);
+
+ x = asx*he + bsx*ke + csx*le;
+ y = asy*he + bsy*ke + csy*le;
+ z = asz*he + bsz*ke + csz*le;
+
+ fprintf(fh, "sphere { <%.5f, %.5f, %.5f>, %.5f "
+ "texture{pigment{color rgb <%f, %f, %f>"
+ " transmit %f} "
+ "finish { reflection 0.1 } } \n"
+ "transform { TRANS }\n"
+ "}\n",
+ x/1e9, y/1e9, z/1e9, radius,
+ r, g, b, trans);
+
+ }
- }
- }
}
fprintf(fh, "\n");
diff --git a/src/povray.h b/src/povray.h
index f60bd566..69bf657e 100644
--- a/src/povray.h
+++ b/src/povray.h
@@ -1,5 +1,5 @@
/*
- * povray.c
+ * povray.h
*
* Invoke POV-ray
*
@@ -17,6 +17,8 @@
#define POVRAY_H
extern int povray_render_animation(UnitCell *cell, double *ref,
- unsigned int *c, unsigned int nproc);
+ unsigned int *counts, ReflItemList *items,
+ unsigned int nproc, const char *sym,
+ int wght, double boost);
#endif /* POVRAY_H */
diff --git a/src/render_hkl.c b/src/render_hkl.c
index 2cfdfb14..b6deac2b 100644
--- a/src/render_hkl.c
+++ b/src/render_hkl.c
@@ -30,13 +30,8 @@
#include "povray.h"
#include "symmetry.h"
#include "render.h"
+#include "render_hkl.h"
-enum {
- WGHT_I,
- WGHT_SQRTI,
- WGHT_COUNTS,
- WGHT_RAWCOUNTS,
-};
static void show_help(const char *s)
{
@@ -621,7 +616,8 @@ int main(int argc, char *argv[])
}
if ( config_povray ) {
- r = povray_render_animation(cell, ref, cts, nproc);
+ r = povray_render_animation(cell, ref, cts, items,
+ nproc, sym, wght, boost);
} else if ( config_zoneaxis ) {
#ifdef HAVE_CAIRO
render_za(cell, items, ref, cts, boost, sym, wght, colscale,