Index: Damkjer/PointProcessing/SpatialAnalyzer/spanalyze.m
===================================================================
--- Damkjer/PointProcessing/SpatialAnalyzer/spanalyze.m	(revision 3)
+++ Damkjer/PointProcessing/SpatialAnalyzer/spanalyze.m	(revision 5)
@@ -1,8 +1,17 @@
-function [ CLASSES ] = spanalyze( QUERIES, DATABASE, varargin )
 %%
 % [CLASSES] = SPANALYZE(QUERIES, DATABASE, ...)
 %
 % Attribute points by eigen analysis.
-
+%
+%   Copyright 2012 Kristian L. Damkjer
+%
+%   Software History:
+%      2013-JAN-28   K. Damkjer
+%         Initial Coding.
+%      2013-FEB-04   K. Damkjer
+%         Change output to a struct for easier referencing.
+%
+
+function [ CLASSES ] = spanalyze( QUERIES, DATABASE, varargin )
 % Parse Inputs
 userParams = parseInputs(varargin{:});
@@ -118,5 +127,17 @@
 
 % Populate feature classes
-CLASSES=[feats;norms;dims;iso;ani;fa;entropy;structure;omnivar;embed;biases;ints];
+%CLASSES=[feats;norms;dims;iso;ani;fa;entropy;structure;omnivar;embed;biases;ints];
+CLASSES.features=feats;
+CLASSES.normals=norms;
+CLASSES.dimensionality=dims;
+CLASSES.isotropy=iso;
+CLASSES.anisotropy=ani;
+CLASSES.FA=fa;
+CLASSES.entropy=entropy;
+CLASSES.structure=structure;
+CLASSES.omnivariance=omnivar;
+CLASSES.embedding=embed;
+CLASSES.biases=biases;
+CLASSES.intensity=ints;
 
 % st=zeros(size(QUERIES));
Index: Damkjer/Util/SpatialIndexing/VpTree/kannVpTree.cpp
===================================================================
--- Damkjer/Util/SpatialIndexing/VpTree/kannVpTree.cpp	(revision 0)
+++ Damkjer/Util/SpatialIndexing/VpTree/kannVpTree.cpp	(revision 5)
@@ -23,4 +23,7 @@
 //> 2012-SEP-11  K. Damkjer
 //               Initial Coding.
+//  2013-FEB-04  K. Damkjer
+//               Restructure parallel sections to see if any performance
+//               gain is realized.
 //<
 //=========================================================================
@@ -123,4 +126,6 @@
 #endif
 
+   std::vector<std::pair<std::deque<mwIndex>, std::deque<double> > > results(pointData.size());
+   
    #pragma omp parallel for
    for (int p = 0; p < pointData.size(); ++p)
@@ -128,14 +133,18 @@
       std::vector<double> q=pointData[p];
 
-      std::pair<std::deque<mwIndex>, std::deque<double> > results;
+//      std::pair<std::deque<mwIndex>, std::deque<double> > results;
 
-      results = tree.knn(q, k, radius);
+      results[p] = tree.knn(q, k, radius);
+   }
+   
+   #pragma omp parallel for
+   for (int p = 0; p < pointData.size(); ++p)
+   {  
+      mwSize neighbors = results[p].first.size();
 
-      mwSize neighbors = results.first.size();
-
-	  mxArray* neighbor_idxs = 0;
-	  mwIndex* idxs = 0;
-	  mxArray* neighbor_dists = 0;
-	  double* dists = 0;
+	   mxArray* neighbor_idxs = 0;
+	   mwIndex* idxs = 0;
+	   mxArray* neighbor_dists = 0;
+	   double* dists = 0;
 
       #pragma omp critical //(VPSB_KNN_CREATE_IDXS)
@@ -147,13 +156,13 @@
 
          idxs = (mwIndex*)mxGetData(neighbor_idxs);
-	  }
+	   }
 
       for (mwIndex idx = neighbors; idx --> 0;)
       {
-         idxs[idx]=results.first[idx]+1;
+         idxs[idx]=results[p].first[idx]+1;
       }
 
       #pragma omp critical //(VPSB_KNN_SET_CELL_IDX)
-	  {
+	   {
          mxSetCell(plhs[0], p, neighbor_idxs);
       }
@@ -169,13 +178,13 @@
 
             dists = mxGetPr(neighbor_dists);
-		 }
+		   }
 
          for (mwIndex idx = neighbors; idx --> 0;)
          {
-            dists[idx]=results.second[idx];
+            dists[idx]=results[p].second[idx];
          }
 
          #pragma omp critical //(VPSB_KNN_SET_CELL_DISTS)
-		 {
+		   {
             mxSetCell(plhs[1], p, neighbor_dists);
          }
