[vtkusers] Mark specific points on a poldata object

David E DeMarle dave.demarle at kitware.com
Tue Oct 11 10:16:23 EDT 2011


In my quick scan of your code I didn't notice that you are already
taking approach #2. Sorry about that.

VTK won't draw points without cells. Add one VTK_VERTEX cell for every
landmark point and I think you will see the result. One way to do that
is feed newpolydata into the glyph filter.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909



2011/10/11 Wenlong Wang <scc.wwl at gmail.com>:
> Hi, David,
>
> Thank you for your reply.
>
> Yes, the code clip I attached is building a polydata object for the
> landmarks only and there is another polydata object for the surface.
>
> What I want to make is the landmarks are drawn on the screen while another
> surface is show. However, when the application runs, only the surface is
> shown, the landmarks are never appreared. I tried to change the z-coordinate
> by hand, but they still don't appear.
>
> Could it be anything wrong with the visualization pipeline? I think I've
> accomplish the basic operation to visualize actors in the code clip.
>
> Thank you for your kind help。
>
> Wenlong
>
> 2011/10/11 David E DeMarle <dave.demarle at kitware.com>
>>
>> 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