[vtkusers] Help: about ObjReader & PolyData
Amy Henderson
amy.henderson at kitware.com
Thu Aug 14 10:54:55 EDT 2003
Add the line:
obj->Update();
before you ask for the number of points, cells, etc. When you render the
model, this call is made for you when the visualization pipeline updates.
- Amy
At 10:36 PM 8/14/2003 +0800, #LIU QIANG# wrote:
>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
>
>
>
>N¬Ëaz⽫^U2Ç.²È¨X¬´ù^jǤyêfzËë(Ú)À¡yÉ-
á@A«a¶Úþ'$Üç(÷
>¸§þûd}ª
¢YhÂØb²X§Ú,¹»®&Þþéì¹»®&ÞÛiÿü0Âûd¢¸?¨¥©ÿ+-wèþûdºÇ«
More information about the vtkusers
mailing list