]> Pileus Git - ~andy/rsl/blobdiff - prune.c
Changes from Bart (2009-10-28)
[~andy/rsl] / prune.c
diff --git a/prune.c b/prune.c
index 6ee04594f1f18b32f67442a304c33ff043bd6936..1a239138ee438d08250cfe2f0852a32d8add4f63 100644 (file)
--- a/prune.c
+++ b/prune.c
 #include "rsl.h"
 extern int radar_verbose_flag;
 
+/* Define global variable for pruning and the functions to set or unset it.
+ * Added by Bart Kelley, SSAI, August 26, 2009
+ */
+int prune_radar = 1;
+
+void RSL_prune_radar_on()
+{
+  prune_radar = 1;
+}
+
+void RSL_prune_radar_off()
+{
+  prune_radar = 0;
+}
+
 Ray *RSL_prune_ray(Ray *ray)
 {
   if (ray == NULL) return NULL;
@@ -50,20 +65,20 @@ Sweep *RSL_prune_sweep(Sweep *s)
 
   if (s == NULL) return NULL;
   if (s->h.nrays == 0) {
-       RSL_free_sweep(s);
-       return NULL;
+    RSL_free_sweep(s);
+    return NULL;
   }
 /*
  * Squash out all dataless rays.  'j' is the index for the squashed (pruned)
  * rays.
  */
   for (i=0,j=0; i<s->h.nrays; i++)
-       if ((s->ray[i] = RSL_prune_ray(s->ray[i])))
-         s->ray[j++] = s->ray[i]; /* Keep this ray. */
+    if ((s->ray[i] = RSL_prune_ray(s->ray[i])))
+      s->ray[j++] = s->ray[i]; /* Keep this ray. */
 
   if (j==0) {
-       RSL_free_sweep(s);
-       return NULL; /* All rays were pruned. */
+    RSL_free_sweep(s);
+    return NULL; /* All rays were pruned. */
   }
   for (i=j; i<s->h.nrays; i++) s->ray[i] = NULL;
   s->h.nrays = j;
@@ -76,19 +91,19 @@ Volume *RSL_prune_volume(Volume *v)
 
   if (v == NULL) return NULL;
   if (v->h.nsweeps == 0) {
-       RSL_free_volume(v);
-       return NULL;
+    RSL_free_volume(v);
+    return NULL;
   }
 /*
  * Squash out all dataless sweeps.  'j' is the index for sweep containing data.
  */
   for (i=0,j=0; i<v->h.nsweeps; i++)
-       if ((v->sweep[i] = RSL_prune_sweep(v->sweep[i])))
-         v->sweep[j++] = v->sweep[i]; /* Keep this sweep. */
+    if ((v->sweep[i] = RSL_prune_sweep(v->sweep[i])))
+      v->sweep[j++] = v->sweep[i]; /* Keep this sweep. */
 
   if (j==0) {
-       RSL_free_volume(v);
-       return NULL; /* All sweeps were pruned. */
+    RSL_free_volume(v);
+    return NULL; /* All sweeps were pruned. */
   }
   for (i=j; i<v->h.nsweeps; i++) v->sweep[i] = NULL;
   v->h.nsweeps = j;
@@ -100,8 +115,11 @@ Radar *RSL_prune_radar(Radar *radar)
   int i;
   /* Volume indexes are fixed so we just prune the substructures. */
   if (radar == NULL) return NULL;
-  for (i=0; i<radar->h.nvolumes; i++)
-       radar->v[i] = RSL_prune_volume(radar->v[i]);
+  if (prune_radar)
+    for (i=0; i<radar->h.nvolumes; i++)
+      radar->v[i] = RSL_prune_volume(radar->v[i]);
+  else if (radar_verbose_flag) fprintf(stderr,
+    "RSL_prune_radar: No pruning done. prune_radar = %d\n", prune_radar);
 
   return radar;
 }