[cig-commits] r11732 - cs/benchmark/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Apr 2 11:01:58 PDT 2008


Author: luis
Date: 2008-04-02 11:01:58 -0700 (Wed, 02 Apr 2008)
New Revision: 11732

Modified:
   cs/benchmark/cigma/trunk/src/PointField.cpp
Log:
Fixes for PointField::eval()


Modified: cs/benchmark/cigma/trunk/src/PointField.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/PointField.cpp	2008-04-02 18:01:56 UTC (rev 11731)
+++ cs/benchmark/cigma/trunk/src/PointField.cpp	2008-04-02 18:01:58 UTC (rev 11732)
@@ -1,6 +1,8 @@
+#include <iostream>
 #include <cassert>
 #include "PointField.h"
 
+using namespace std;
 using namespace cigma;
 
 // ---------------------------------------------------------------------------
@@ -34,26 +36,47 @@
 
 bool PointField::eval(double *point, double *value)
 {
-    /* XXX: quick sanity check
-    static int checked = 0;
-    if (!checked)
-    {
-        assert(points->n_points() != 0);
-        assert(values->n_points() != 0);
-        assert(points->n_points() == values->n_points());
-        assert(points->n_dim() == values->n_dim());
-        checked = 1;
-    } // */
+    const bool debug = false;
 
+    // XXX: sanity check
+    //static int checked = 0;
+    //if (!checked)
+    //{
+    //    assert(points->n_points() != 0);
+    //    assert(values->n_points() != 0);
+    //    assert(points->n_points() == values->n_points());
+    //    assert(points->n_dim() == values->n_dim());
+    //    checked = 1;
+    //}
 
     // Find index of closest point
     int n;
     bool found = points->find_ann_index(point, &n);
+    if (!found) { return false; }
 
-    if (found && (0 <= n) && (n < points->n_points()))
+    if ((0 <= n) && (n < points->n_points()))
     {
+        int i;
+
+        // Show ANN point
+        if (debug)
+        {
+            double *p = (*points)[n];
+
+            cerr << "ANNPT( ";
+            for (i = 0; i < points->n_dim(); i++)
+            {
+                cerr << p[i] << " ";
+            }
+            cerr << ")" << endl;
+        }
+
         // Retrieve corresponding value
-        value = (*values)[n];
+        double *v = (*values)[n];
+        for (i = 0; i < values->n_dim(); i++)
+        {
+            value[i] = v[i];
+        }
         return true;
     }
 



More information about the cig-commits mailing list