[vtkusers] How to refresh the screnn

Wenlong Wang scc.wwl at gmail.com
Sat Oct 15 10:07:41 EDT 2011


Sorry I attached wrong code. Here is the function
void CVTKDialogDlg::ShowLandmarks(double current_mode[][3])
{
 CRect rect;
 CWnd* p = GetDlgItem(IDC_SHOW_FACE);
 p->GetClientRect(&rect);

 int index;
 double x, y, z;
 for (int i = 0; i < sizeof(landmarks)/sizeof(double); i++)
 {
  index = landmarks[i];
  x = current_mode[index][0];
  y = current_mode[index][1];
  z = current_mode[index][2];
  //newpoints->InsertPoint(vtkIdType(i), current_mode[index][0],
current_mode[index][1], (current_mode[index][2])+0.2);
  newpoints->InsertPoint(vtkIdType(i), x, y, z+0.2);
 }
 newpolydata->SetPoints(newpoints);
 gf = vtkVertexGlyphFilter::New();
 gf->AddInput(newpolydata);
 gf->Update();
 newarray = vtkFloatArray::New();
 for (int j = 0; j < sizeof(landmarks)/sizeof(double); j++)
 {
  newarray->InsertTuple1(vtkIdType(j), double(j));
 }
 newpolydata = vtkPolyData::New();
 newpolydata->GetPointData()->SetScalars(newarray);
 newmapper = vtkPolyDataMapper::New();
 newmapper->SetInputConnection(gf->GetOutputPort());
 newmapper->SetScalarRange(0, 7);
 newmapper->SetScalarVisibility(0);
 newactor = vtkActor::New();
 newactor->SetMapper(newmapper);
 newactor->GetProperty()->SetColor(0.0, 1.0, 0.0);
 newactor->GetProperty()->SetPointSize(10);
 ren->AddActor(newactor);
 renWin->AddRenderer(ren);
 renWin->SetParentId(p->m_hWnd);
 renWin->SetSize(rect.right-rect.left, rect.bottom-rect.top);
 ren->Render();
 renWin->Render();
}

Yes, I checked it and am sure that it is called as the slider moved.

It looks like the points moving without refreshing the screen.

Thank you very much

Long

2011/10/13 David Doria <daviddoria at gmail.com>

>  On Thu, Oct 13, 2011 at 12:14 PM, Wenlong Wang <scc.wwl at gmail.com> wrote:
> > Yes, I put the refresh operations into a indepedent function, the source
> > code is followed.
> >
> > vtkPoints* np = vtkPoints::New();
> >  float sd[5] = {166.58736074271718, 140.66998311271823,
> 95.52088334400537,
> > 65.09632977166221, 59.0649201078395};
> >  for (int i = 0; i < 5090; i++)
> >  {
> >   for (int j = 0; j<3; j++)
> >   {
> >    mode[i][j] = 0.0;
> >    mode[i][j] = mode1[i][j] * x1 * sd[0] + mode2[i][j] * x2 * sd[1] +
> > mode3[i][j] * x3 * sd[2] + mode4[i][j] * x4 * sd[3] + mode5[i][j] * x5 *
> > sd[4] + meanface[i][j];
> >   }
> >  }
> >  for (int k = 0; k< 5090; k++)
> >  {
> >   np->InsertPoint(k, mode[k]);
> >  }
> >
> >  points->DeepCopy(np);
> >
> >  face->SetPoints(points);
> >  face->SetPolys(poly);
> >  face->GetPointData()->SetScalars(scalars);
> >
> >  faceMapper->SetInput(face);
> >  faceMapper->SetScalarRange(0, 7);
> >  faceMapper->SetScalarVisibility(0);
> >
> >  faceActor->SetMapper(faceMapper);
> >  faceActor->GetProperty()->SetColor(0.9, 0.9, 0.9);
> >
> >  ren->SetBackground(0.1, 0.2, 0.4);
> >  ren->AddActor(faceActor);
> >  ren->SetActiveCamera(cam);
> >  ren->ResetCamera();
> >  renWin->AddRenderer(ren);
> >  renWin->SetParentId(p->m_hWnd);
> >  renWin->SetSize(rect.right-rect.left, rect.bottom-rect.top);
> >  iren->SetRenderWindow(renWin);
> >  renWin->Render();
> >
>
> Please keep the conversation on the mailing list. You have not shown
> there when that function is called - are you sure it is called as the
> slider is being moved?
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111015/87773b31/attachment.htm>


More information about the vtkusers mailing list