[vtkusers] Mark specific points on a poldata object
David E DeMarle
dave.demarle at kitware.com
Tue Oct 11 09:29:31 EDT 2011
You have to have as many tuples in the scalars array as there are
points in the polydata. You have only as many tuples as there are
landmark points.
Alternatively might make another polydata that contains only the
landmark points and draw both polydata. Scale the landmark polydata up
slightly to avoid z-tearing.
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
On Tue, Oct 11, 2011 at 9:17 AM, Wenlong Wang <scc.wwl at gmail.com> wrote:
> 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
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list