void
vtkHighlightActor2D::RegenerateHighlight()
{
    // Count the number of hot points that we need to display.
    int i, numHotPoints = 0;    
    for(i = 0; i < numTools; ++i)
    {
        if(tools[i]->IsEnabled())
            numHotPoints += (int)tools[i]->HotPoints().size();
    }

    // Allocate some temporary arrays that we'll use to construct the
    // highlightData object.
    int numPts = 4 * numHotPoints;
    vtkPoints *pts = vtkPoints::New();
    pts->SetNumberOfPoints(numPts);
    vtkCellArray *lines = vtkCellArray::New();
    lines->Allocate(lines->EstimateSize(numPts, 2)); 
    vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New();
    colors->SetNumberOfComponents(3);
    colors->SetNumberOfTuples(numPts);

    // Store the colors and points in the polydata.
    if(highlightData != NULL)
        highlightData->Delete();
    highlightData = vtkPolyData::New();
    highlightData->Initialize();
    highlightData->SetPoints(pts);
    highlightData->SetLines(lines);
    highlightData->GetCellData()->SetScalars(colors);
    pts->Delete(); lines->Delete(); colors->Delete(); 

    // Add a cell to the polyData for each active hotpoint.
    int    ptIndex = 0;
    int    cellIndex = 0;
    int    winWidth = helperRenderer->GetSize()[0];
    int    winHeight = helperRenderer->GetSize()[1];
    double v[4];
    double  coord[3];
    vtkIdType    ptIds[4];

    coord[2] = 0.;
#define SQRT_OF_2 1.4142136

    for(i = 0; i < numTools; ++i)
    {
        if(tools[i]->IsEnabled() && tools[i]->ShowsHotPointHighlights())
        {
            const HotPointVector &hpts = tools[i]->HotPoints();
            for(size_t j = 0; j < hpts.size(); ++j)
            {
                // Use the background renderer to compute the normalized
                // device coordinate of the hotpoint from the world space
                // coordinate.
                helperRenderer->SetWorldPoint(hpts[j].pt.x, hpts[j].pt.y, hpts[j].pt.z, 1.0);
                helperRenderer->WorldToDisplay();
                helperRenderer->GetDisplayPoint(v);

                double dX = double((hpts[j].radius * winWidth) / SQRT_OF_2);
                double dY = double((hpts[j].radius * winHeight) / SQRT_OF_2);

                if (hpts[j].shape == 0) // square
                {
                    coord[0] = v[0] + dX;
                    coord[1] = v[1] + dY;
                    pts->SetPoint(ptIndex, coord);
                    coord[0] = v[0] + dX;
                    coord[1] = v[1] - dY;
                    pts->SetPoint(ptIndex + 1, coord);
                    coord[0] = v[0] - dX;
                    coord[1] = v[1] - dY;
                    pts->SetPoint(ptIndex + 2, coord);
                    coord[0] = v[0] - dX;
                    coord[1] = v[1] + dY;
                    pts->SetPoint(ptIndex + 3, coord);
                }
                else if (hpts[j].shape == 1) // tri up
                {
                    // Yeah, we're making it have four points.  It's easier.
                    coord[0] = v[0] + dX;
                    coord[1] = v[1] + dY;
                    pts->SetPoint(ptIndex, coord);
                    coord[0] = v[0];
                    coord[1] = v[1];
                    pts->SetPoint(ptIndex + 1, coord);
                    coord[0] = v[0] - dX;
                    coord[1] = v[1] + dY;
                    pts->SetPoint(ptIndex + 2, coord);
                    coord[0] = v[0];
                    coord[1] = v[1] + dY;
                    pts->SetPoint(ptIndex + 3, coord);
                }
                else if (hpts[j].shape == 2) // tri down
                {
                    // Yeah, we're making it have four points.  It's easier.
                    coord[0] = v[0] - dX;
                    coord[1] = v[1] - dY;
                    pts->SetPoint(ptIndex, coord);
                    coord[0] = v[0];
                    coord[1] = v[1];
                    pts->SetPoint(ptIndex + 1, coord);
                    coord[0] = v[0] + dX;
                    coord[1] = v[1] - dY;
                    pts->SetPoint(ptIndex + 2, coord);
                    coord[0] = v[0];
                    coord[1] = v[1] - dY;
                    pts->SetPoint(ptIndex + 3, coord);
                }

                for(int k = 0; k < 4; ++k)
                {
                    ptIds[0] = ptIndex + k;
                    ptIds[1] = (k < 3) ? (ptIndex + k + 1) : ptIndex;
                    lines->InsertNextCell(2, ptIds);

                    // Add the color.
                    unsigned char *rgb = colors->GetPointer(cellIndex * 3);
                    rgb[0] = 255;
                    rgb[1] = 0;
                    rgb[2] = 0;
                    ++cellIndex;
                }
                ptIndex += 4;
            }
        }
    }

    if(highlightMapper != NULL)
        highlightMapper->Delete();
    highlightMapper = vtkPolyDataMapper2D::New();
    highlightMapper->SetInputData(highlightData);

    if(highlightActor != NULL)
        highlightActor->Delete();
    highlightActor = vtkActor2D::New();
    highlightActor->GetProperty()->SetLineWidth(2.);
    highlightActor->SetMapper(highlightMapper);
    highlightActor->PickableOff();
}