[vtkusers] vtkOBJReader incorrect number of points

Paul Melis paul.melis at surfsara.nl
Thu Sep 22 04:02:26 EDT 2016


Hi,

On 20-09-16 11:23, user192048 wrote:
> I'm having trouble with some basic wavefront obj file manipulation. I can
> read in and display a textured model correctly seemingly, but when I query
> the number of points I get a strange number (let me explain).
>
> The file has vertices (v), texture coords (vt) and triangle faces (f)
> specified v/vt v/vt v/vt. There are 17460 vertex points specified in the
> file, and 34357. When I query the obj reader, it tells me "34537 cells, 0
> verts, 0 lines, 34537 polys, 0 strips, 103611 points". The number of points
> here is exactly 3*34357.
>
> I had a quick look in the source for the reader and numPts is only
> incremented on scanning a line starting with v, so I'm unsure why this is
> happening. The major issue with this is that ultimately I want to write out
> an object file that is a modified version of the original, but if the
> original is wrong it won't work.
>
> Any ideas?

Probably what is happening (haven't checked the code) is that points are 
duplicated during read, because there is a texture coordinate per vertex 
per face. When a vertex is used in more than one face its 3D position 
can be shared (it's the same for all faces using the vertex), but its 
texture coordinate per face can differ (as that is what .obj allows) and 
hence needs to be stored for each face the vertex occurs in. The easiest 
way for VTK to do this is to create vertices (points) used only in a 
single face, having the texture coordinates within that face. If your 
model contains only triangles it makes sense that the number of points 
after read is 3 times the number of triangles.

Regards,
Paul

-- 

Paul Melis
| Visualization group leader & developer | SURFsara |
| Science Park 140 | 1098 XG Amsterdam |
| T 020 800 1312 | paul.melis at surfsara.nl | www.surfsara.nl |


More information about the vtkusers mailing list