[vtkusers] rendring problem

medamine miladimedamine at yahoo.fr
Thu Jun 21 14:47:04 EDT 2007


Hi;
i'm trying to create a mesh from .txt file in witch i have only points.after
creation i get a mesh with 1024 pts but nothing appear in the screan when
rendring.
Thanks

FILE *fp; 
float x=0;
float y=0;
float z=0;
const float p[3]={0,0,0};
char *c; 
int i=0;
vtkPolyData *m_polydata=vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
float pts[3]={10,10,10};
if((fp=fopen(resfile,"r"))==NULL) 
{ printf("Le fichier FILES ne veut pas s'ouvrire! \n"); exit(1);} 
while(!feof(fp))
{ fscanf(fp,"%c %f %f %f",&c,&x,&y,&z);
pts[0]=x;pts[1]=y;pts[2]=z;
points->InsertPoint(i,pts);
i++;
}
   m_polydata->SetPoints(points);
  m_polydata->Update();

 vtkPolyDataWriter *writer=vtkPolyDataWriter::New();
 writer->SetFileName(plyfile);
 writer->SetInput(m_polydata);
 writer->Update();

/////////test visualisation
 vtkPolyDataMapper *m_polydataMapper = vtkPolyDataMapper::New();
 m_polydataMapper->SetInput(m_polydata);
// m_polydataMapper->SetScalarRange(0,256);
 vtkActor *m_Actor = vtkActor::New();
 m_Actor->SetMapper(m_polydataMapper);
 //m_Actor->GetProperty()->SetRepresentationToPoints();
 m_Actor->GetProperty()->SetColor(1, 0, 0);
// m_Actor->GetProperty()->SetDiffuseColor(1,1,1);
 vtkRenderer *m_renderer = vtkRenderer::New();
 vtkRenderWindow *m_renWin = vtkRenderWindow::New();
 m_renWin->AddRenderer(m_renderer);
 vtkRenderWindowInteractor *m_iren = vtkRenderWindowInteractor::New();
 m_iren->SetRenderWindow(m_renWin);
 vtkInteractorStyleTrackballCamera *m_style =
vtkInteractorStyleTrackballCamera::New();
 m_iren->SetInteractorStyle(m_style);
 m_renderer->AddActor(m_Actor);
 m_renderer->SetBackground(0, 0, 0);
 m_renWin->SetSize(300,300);
 m_renWin->Render();
 m_iren->Start();
 //Free 
 m_polydata->Delete();
 m_polydataMapper->Delete();
 m_Actor->Delete();
 m_renderer->Delete();
 m_renWin->Delete();
 m_iren->Delete();
-- 
View this message in context: http://www.nabble.com/rendring-problem-tf3960601.html#a11239214
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list