[vtkusers] Dynamic resizing

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Mon Feb 9 04:08:00 EST 2004


For efficiency reasons, when you change the points directly in a vtkDoubleArray object, the "Modified" flag doesn't get set (otherwise when you created datasets, it would be touched millions of times for no good reason).

Call myDoubleArray->Modified()
after you have adjusted the points. This will make the dataset think it's been tweaked and when you do Mapper->Update, you should get a result.

JB

  ----- Original Message ----- 
  From: david michell 
  To: vtkusers at vtk.org 
  Sent: Monday, February 09, 2004 8:45 AM
  Subject: [vtkusers] Dynamic resizing


  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();

  }
    

  }







   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040209/4931b12e/attachment.htm>


More information about the vtkusers mailing list