Index: VTK/Filtering/vtkConvexPointSet.cxx
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Filtering/vtkConvexPointSet.cxx,v
retrieving revision 1.6
diff -u -r1.6 vtkConvexPointSet.cxx
--- VTK/Filtering/vtkConvexPointSet.cxx	4 Aug 2009 16:57:05 -0000	1.6
+++ VTK/Filtering/vtkConvexPointSet.cxx	16 Sep 2009 11:25:11 -0000
@@ -201,58 +201,15 @@
 int vtkConvexPointSet::CellBoundary(int subId, double pcoords[3],
                                     vtkIdList *pts)
 {
-  int i, status, returnStatus=(-1);
-  double p[3], x[3], dist2, minDist2=VTK_DOUBLE_MAX, pMin[3];
-  double closest[3], pc[3];
-  double weights[4];
-
-  // Get the current global coordinate
-  this->EvaluateLocation(subId, pcoords, p, weights);
+  vtkIdType ptId;
 
-  // Find the closest point
-  vtkIdType numPts = this->PointIds->GetNumberOfIds();
-  for (i=0; i < numPts; i++)
+  for (int j=0; j<4; j++)
     {
-    this->Points->GetPoint(i, x);
-    dist2 = vtkMath::Distance2BetweenPoints(x,p);
-    if ( dist2 < minDist2 )
-      {
-      pMin[0] = x[0];
-      pMin[1] = x[1];
-      pMin[2] = x[2];
-      minDist2 = dist2;
-      }
-    }
-
-  // Get the faces connected to the point, find the closest face
-  this->BoundaryTris->Reset();
-  this->Triangulator->AddTriangles(this->BoundaryTris);
-
-  vtkIdType npts, *tpts=0;
-  for ( minDist2=VTK_DOUBLE_MAX, this->BoundaryTris->InitTraversal();
-        this->BoundaryTris->GetNextCell(npts,tpts); )
-    {
-    this->Triangle->PointIds->SetId(0,tpts[0]);
-    this->Triangle->PointIds->SetId(1,tpts[1]);
-    this->Triangle->PointIds->SetId(2,tpts[2]);
-    this->Triangle->Points->SetPoint(0,this->Points->GetPoint(tpts[0]));
-    this->Triangle->Points->SetPoint(1,this->Points->GetPoint(tpts[1]));
-    this->Triangle->Points->SetPoint(2,this->Points->GetPoint(tpts[2]));
-    status = this->Triangle->
-      EvaluatePosition(pMin, closest, subId, pc, dist2, weights);
-
-    if ( status != -1 && dist2 < minDist2)
-      {
-      returnStatus = 1;
-      pts->SetNumberOfIds(3);
-      pts->SetId(0,this->PointIds->GetId(tpts[0]));
-      pts->SetId(1,this->PointIds->GetId(tpts[1]));
-      pts->SetId(2,this->PointIds->GetId(tpts[2]));
-      minDist2 = dist2;
-      }
+    ptId = this->PointIds->GetId(this->TetraIds->GetId(4*subId+j));
+    this->Tetra->PointIds->SetId(j,ptId);
+    this->Tetra->Points->SetPoint(j,this->TetraPoints->GetPoint(4*subId+j));
     }
-
-  return returnStatus;
+  return this->Tetra->CellBoundary(subId, pcoords, pts);
 }
 
 //----------------------------------------------------------------------------
@@ -262,12 +219,12 @@
                                         double& minDist2, double *weights)
 {
   double pc[3], dist2;
-  int ignoreId, i, j, returnStatus=0, status;
+  int ignoreId, i, j, k, returnStatus=0, status;
   double tempWeights[4];
   double closest[3];
   vtkIdType ptId;
   int numTets = this->TetraIds->GetNumberOfIds() / 4;
-
+  int numPoints = this->GetNumberOfPoints();
 
   for (minDist2=VTK_DOUBLE_MAX, i=0; i<numTets; i++)
     {
@@ -280,18 +237,24 @@
 
     status = this->Tetra->EvaluatePosition(x,closest,ignoreId,pc,dist2,
                                            tempWeights);
+
     if ( status != -1 && dist2 < minDist2 )
       {
+      // initialize weights, since only the weights for the found tetrahedron are set below
+      for(k = 0; k < numPoints; ++k)
+        {
+         weights[k] = 0.0;
+        }
       returnStatus = status;
       minDist2 = dist2;
       subId = i;
       pcoords[0] = pc[0];
       pcoords[1] = pc[1];
       pcoords[2] = pc[2];
-      weights[0] = tempWeights[0];
-      weights[1] = tempWeights[1];
-      weights[2] = tempWeights[2];
-      weights[3] = tempWeights[3];
+      weights[this->TetraIds->GetId(4*i)] = tempWeights[0];
+      weights[this->TetraIds->GetId(4*i+1)] = tempWeights[1];
+      weights[this->TetraIds->GetId(4*i+2)] = tempWeights[2];
+      weights[this->TetraIds->GetId(4*i+3)] = tempWeights[3];
       }
     }
 
