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

luis at geodynamics.org luis at geodynamics.org
Wed Feb 13 01:51:01 PST 2008


Author: luis
Date: 2008-02-13 01:51:01 -0800 (Wed, 13 Feb 2008)
New Revision: 9285

Modified:
   cs/benchmark/cigma/trunk/src/AnnLocator.cpp
   cs/benchmark/cigma/trunk/src/AnnLocator.h
   cs/benchmark/cigma/trunk/src/Locator.h
Log:
Improved AnnLocator
 * Created two types: POINT_LOCATOR and CELL_LOCATOR

Modified: cs/benchmark/cigma/trunk/src/AnnLocator.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/AnnLocator.cpp	2008-02-13 09:50:59 UTC (rev 9284)
+++ cs/benchmark/cigma/trunk/src/AnnLocator.cpp	2008-02-13 09:51:01 UTC (rev 9285)
@@ -17,13 +17,22 @@
 
     nnIdx = 0;
     nnDists = 0;
+
+    locatorType = NULL_LOCATOR;
 }
 
 cigma::AnnLocator::~AnnLocator()
 {
     if (kdtree != 0) delete kdtree;
-    if (dataPoints != 0) annDeallocPts(dataPoints);
 
+    if (dataPoints != 0)
+    {
+        if (locatorType == CELL_LOCATOR)
+        {
+            annDeallocPts(dataPoints);
+        }
+    }
+
     if (nnIdx != 0) delete [] nnIdx;
     if (nnDists != 0) delete [] nnDists;
 }
@@ -65,11 +74,40 @@
     }
 
     kdtree = new ANNkd_tree(dataPoints, npts, dim);
+
+    locatorType = CELL_LOCATOR;
 }
 
 
 // ---------------------------------------------------------------------------
 
+void cigma::AnnLocator::initialize(Points *points)
+{
+    assert(nnk > 0);
+
+    npts = points->n_points();
+    dim  = points->n_dim();
+
+    assert(npts > 0);
+    assert(nsd > 0);
+
+    // XXX watch out for when you change the ANNpoint type to float
+    assert(sizeof(ANNpoint) == sizeof(double));
+
+    dataPoints = (ANNpointArray)(points->data);
+    queryPoint = annAllocPt(dim);
+
+    nnIdx = new ANNidx[nnk];
+    nnDists = new ANNdist[nnk];
+
+    kdtree = new ANNkd_tree(dataPoints, npts, dim);
+
+    locatorType = POINT_LOCATOR;
+}
+
+
+// ---------------------------------------------------------------------------
+
 void cigma::AnnLocator::search(double *globalPoint)
 {
     for (int i = 0; i < nsd; i++)

Modified: cs/benchmark/cigma/trunk/src/AnnLocator.h
===================================================================
--- cs/benchmark/cigma/trunk/src/AnnLocator.h	2008-02-13 09:50:59 UTC (rev 9284)
+++ cs/benchmark/cigma/trunk/src/AnnLocator.h	2008-02-13 09:51:01 UTC (rev 9285)
@@ -4,8 +4,8 @@
 #include "ANN/ANN.h"
 #include "Locator.h"
 #include "MeshPart.h"
+#include "Points.h"
 
-
 namespace cigma
 {
     class AnnLocator;
@@ -20,12 +20,16 @@
 
 public:
     void initialize(MeshPart *meshPart);
+    void initialize(Points *points);
+
+public:
     void search(double *globalPoint);
 
 public:
     int n_idx();
     int idx(int i);
 
+
 public:
     int nnk;            // number of nearest neighbors
     int npts;           // number of points (bounding boxes)
@@ -41,6 +45,16 @@
     ANNidxArray nnIdx;      // near neighbor indices
     ANNdistArray nnDists;   // near neighbor distances
 
+public:
+
+    typedef enum {
+        NULL_LOCATOR,
+        POINT_LOCATOR,
+        CELL_LOCATOR
+    } AnnLocatorType;
+
+    AnnLocatorType locatorType;
+
 };
 
 

Modified: cs/benchmark/cigma/trunk/src/Locator.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Locator.h	2008-02-13 09:50:59 UTC (rev 9284)
+++ cs/benchmark/cigma/trunk/src/Locator.h	2008-02-13 09:51:01 UTC (rev 9285)
@@ -6,6 +6,7 @@
 {
     class Locator;
     class MeshPart;
+    class Points;
 }
 
 
@@ -16,7 +17,11 @@
     virtual ~Locator();
 
 public:
+    // XXX: figure out a better scheme for initializing Locator instances
     virtual void initialize(MeshPart *meshPart) = 0;
+    virtual void initialize(Points *points) = 0;
+
+public:
     virtual void search(double *globalPoint) = 0;
 
 public:



More information about the cig-commits mailing list