+void SMDS_CellLinks::BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity, vtkUnsignedCharArray* types)
+{
+ // build links taking into account removed cells
+
+ vtkIdType numPts = data->GetNumberOfPoints();
+ vtkIdType j, cellId = 0;
+ unsigned short *linkLoc;
+ vtkIdType npts=0;
+ vtkIdType *pts=0;
+ vtkIdType loc = Connectivity->GetTraversalLocation();
+
+ // traverse data to determine number of uses of each point
+ cellId = 0;
+ for (Connectivity->InitTraversal();
+ Connectivity->GetNextCell(npts,pts); cellId++)
+ {
+ if ( types->GetValue( cellId ) != VTK_EMPTY_CELL )
+ for (j=0; j < npts; j++)
+ {
+ this->IncrementLinkCount(pts[j]);
+ }
+ }
+
+ // now allocate storage for the links
+ this->AllocateLinks(numPts);
+ this->MaxId = numPts - 1;
+
+ // fill out lists with references to cells
+ linkLoc = new unsigned short[numPts];
+ memset(linkLoc, 0, numPts*sizeof(unsigned short));
+
+ cellId = 0;
+ for (Connectivity->InitTraversal();
+ Connectivity->GetNextCell(npts,pts); cellId++)
+ {
+ if ( types->GetValue( cellId ) != VTK_EMPTY_CELL )
+ for (j=0; j < npts; j++)
+ {
+ this->InsertCellReference(pts[j], (linkLoc[pts[j]])++, cellId);
+ }
+ }
+ delete [] linkLoc;
+ Connectivity->SetTraversalLocation(loc);
+}
+