[vtkusers] Dynamic resizing

david michell davidmichell at rediffmail.com
Mon Feb 9 03:45:19 EST 2004


An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040209/b9be0d7e/attachment.htm>
-------------- next part --------------
Hello Everybody,
Iam using vtk42 and vc++7.
Iam trying to resize a polygon at runtime.
I created a polygon made of triangle strips.
The coordinate points are in a vtkdoublearray and then Iam storing the values in vtkpoints.
Then the vtkcellarray hold the cell values, and Iam using vtkpolydata to hold the points and the cells.
Iam using vtkpolydatamapper to map the data and then a vtkactor.
In a while loop after rendering for sometime (iam not using interactor), I change the coordinates of the 
polygon in the vtkdoublearray.Then I update the mapper.
BUT the polygon is not resized, I dont know why. Can someone please tell me why its not happening and correct it please.

Thank you,
David Michell










void  main( )
{
  
vtkOpenGLRenderer *rn=vtkOpenGLRenderer::New();  
vtkWin32RenderWindowInteractor *ract;

vtkWin32OpenGLRenderWindow *win=vtkWin32OpenGLRenderWindow::New();
win->AddRenderer(rn);
      
vtkPropAssembly          *m_assembly;
m_assembly=vtkPropAssembly::New();

tkDoubleArray          *m_coordinates;
vtkPoints               *m_points;
vtkCellArray          *m_cells;
vtkPolyData               *m_polys;
vtkPolyDataMapper     *m_polyMapper;
vtkActor               *m_polyActor;
  
     
     
  

m_coordinates =vtkDoubleArray::New();
m_coordinates->SetNumberOfComponents(3);
m_coordinates->SetNumberOfTuples(4);

          
m_coordinates->SetTuple3(0,0.0,0.0,0.0);     
m_coordinates->SetTuple3(1,0.0,5.0,0.0);
               
m_coordinates->SetTuple3(2,5.0,0.0,0.0);
m_coordinates->SetTuple3(3,5.0,5.0,0.0);
          
m_points =vtkPoints::New();
m_points->SetNumberOfPoints(4);
m_points->SetData(m_coordinates );
          
          

     
m_cells =vtkCellArray::New();
m_cells->InsertNextCell(4);
m_cells->InsertCellPoint(0);
m_cells->InsertCellPoint(2);
m_cells->InsertCellPoint(3);
m_cells->InsertCellPoint(1);
     
     
m_polys =vtkPolyData::New();
m_polys->SetPoints(m_points );
m_polys->SetPolys(m_cells);

m_polyMapper =vtkPolyDataMapper::New();
m_polyMapper->SetInput(m_polys );
          

          
m_polyActor =vtkActor::New();
m_polyActor->SetMapper(m_polyMapper );
m_polyActor->GetProperty()->SetColor(0.0,1.0,0.0);
m_polyActor->GetProperty()->SetOpacity(0.25);
          
m_assembly->AddPart(m_polyActor);
rn->AddActor(m_assembly);


unsigned long x;

while (true)
{
for (x=0;x<300;x++);
win->Render();
  
//here iam changing the coordiantes 
m_coordinates->SetTuple3(0,0.0,0.0,0.0);     
m_coordinates->SetTuple3(1,0.0,5.0,0.0);          
m_coordinates->SetTuple3(2,8.0,0.0,0.0);
m_coordinates->SetTuple3(3,8.0,5.0,0.0);

m_polyMapper->Update();

}
  

}





More information about the vtkusers mailing list