[vtkusers] Help: about ObjReader & PolyData

#LIU QIANG# liuqiang at pmail.ntu.edu.sg
Thu Aug 14 10:36:25 EDT 2003


Hi all,

I encountered a problem when using vtkObjReader to import a wavefront .obj file.

The .obj file is consist of all triangles. I read this file with vtkObjReader and it output a vtkPolyData. When I use this polydata as the input of a PolyDataMapper, the renderer can render this model perfectly. But when I try to access this polydata, I can't find any points or cells or triangles in this polydata. 

Below is the C++ code:

	vtkOBJReader *obj=vtkOBJReader::New();
	obj->SetFileName("semi-sphere.obj");
	vtkPolyData *in=obj->GetOutput();

	vtkIdType  NumC=in->GetNumberOfCells (); 
	vtkIdType  NumV=in->GetNumberOfVerts ();
	vtkIdType  NumL=in->GetNumberOfLines (); 
	vtkIdType  NumP=in->GetNumberOfPolys (); 
	vtkIdType  NumS=in->GetNumberOfStrips (); 

	vtkIdType NumOfPoints, PolyNum, StripNum;

	NumOfPoints=in->GetNumberOfPoints();

	vtkCellArray *poly, *strips;
	poly=in->GetPolys();
	strips=in->GetStrips();

	StripNum=strips->GetNumberOfCells();
	PolyNum=poly->GetNumberOfCells();
----------------------------------------------------------------------------
The result turns out that NumC, NumV, NumL, NumP, NumS, NumOfPoints, PolyNum, StripNum are all 0.

Can anyone help me to solve this problem and to access the points and cells of the polydata? Thanks in advance.

Regards,
Patrick





More information about the vtkusers mailing list