[vtkusers] Mark specific points on a poldata object

Wenlong Wang scc.wwl at gmail.com
Tue Oct 11 09:17:18 EDT 2011


Dear all,

Is there anyone know how to change the color of points with specific point
ID?

I do it like this, but the surface appeared but none of these point is
shown.

Here is the code,

    vtkPoints* newpoints = vtkPoints::New();
    for (int i = 0; i < sizeof(landmarks)/sizeof(double); i++)
    {
        double temp_point[3];
        points->GetPoint(vtkIdType(landmarks[i]), temp_point);
        newpoints->InsertPoint(vtkIdType(i), temp_point[0], temp_point[1],
temp_point[2]);
    }

    vtkPolyData* newpolydata = vtkPolyData::New();
    newpolydata->SetPoints(newpoints);

    vtkFloatArray* newarray = vtkFloatArray::New();
    for (int i = 0; i < sizeof(landmarks)/sizeof(double); i++)
    {
        newarray->InsertTuple1(vtkIdType(i), double(i));
    }

    newpolydata->GetPointData()->SetScalars(newarray);

    vtkPolyDataMapper* newmapper = vtkPolyDataMapper::New();
    newmapper->SetInput(newpolydata);
    newmapper->SetScalarRange(0, 7);
    newmapper->SetScalarVisibility(0);

    vtkActor* newactor = vtkActor::New();
    newactor->SetMapper(newmapper);
    newactor->GetProperty()->SetColor(0.0, 1.0, 0.0);
    newactor->GetProperty()->SetPointSize(3);

    ren->AddActor(newactor);
    renWin->AddRenderer(ren);

    ren->Render();
    renWin->Render();

where 'ren' is a vtkRenderer object, ‘renWin’ is a vtkRenderWindow object,
and 'landmarks' is an array stores vtk point IDs.

Can anybody help me with this? I'll be very grateful.

Thank you all so much.

Bests
Wenlong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111011/21fc2a11/attachment.htm>


More information about the vtkusers mailing list