[cig-commits] r11690 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Apr 1 01:40:10 PDT 2008
Author: luis
Date: 2008-04-01 01:40:09 -0700 (Tue, 01 Apr 2008)
New Revision: 11690
Modified:
cs/benchmark/cigma/trunk/src/AnnLocator.cpp
Log:
Fix problematic cast of points->data to ANNpointArray
Modified: cs/benchmark/cigma/trunk/src/AnnLocator.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/AnnLocator.cpp 2008-04-01 08:40:08 UTC (rev 11689)
+++ cs/benchmark/cigma/trunk/src/AnnLocator.cpp 2008-04-01 08:40:09 UTC (rev 11690)
@@ -28,14 +28,20 @@
if (dataPoints != 0)
{
- if (locatorType == CELL_LOCATOR)
- {
- annDeallocPts(dataPoints);
- }
+ annDeallocPts(dataPoints);
+ dataPoints = 0;
}
- if (nnIdx != 0) delete [] nnIdx;
- if (nnDists != 0) delete [] nnDists;
+ if (nnIdx != 0)
+ {
+ delete [] nnIdx;
+ nnIdx = 0;
+ }
+ if (nnDists != 0)
+ {
+ delete [] nnDists;
+ nnDists = 0;
+ }
}
@@ -92,12 +98,24 @@
assert(npts > 0);
assert(ndim > 0);
- // XXX watch out for when you change the ANNpoint type to float
- assert(sizeof(ANNpoint) == sizeof(double));
+ // XXX watch out for when you change the ANNpoint type to floaT
+ assert(sizeof(ANNcoord) == sizeof(double));
- dataPoints = (ANNpointArray)(points->data);
+ //dataPoints = (ANNpointArray)(points->data); // questionable cast..
+
+ dataPoints = annAllocPts(npts, ndim);
queryPoint = annAllocPt(ndim);
+ int i,j;
+ for (i = 0; i < npts; i++)
+ {
+ ANNpoint pt = dataPoints[i];
+ for (j = 0; j < ndim; j++)
+ {
+ pt[j] = points->data[ndim*i + j];
+ }
+ }
+
nnIdx = new ANNidx[nnk];
nnDists = new ANNdist[nnk];
More information about the cig-commits
mailing list