[vtkusers] vtkOBJReader not reading the whole mesh

Bill Lorensen bill.lorensen at gmail.com
Wed Dec 13 20:05:43 EST 2017


This problem is because in given polydata the number of tcoords or normals
does not match the number of points.  The importer silently skips the
polydata.

On Dec 13, 2017 6:28 PM, "Todd Martin" <nztoddler at yahoo.com> wrote:

> I found a problem similar to this when using  vtkPolyData->SetPoints(). If
> the point coordinates were not initialised, no polygons were produced.
>
> I didn't search the code, but it seemed to me that the coordinate values
> (floats) should be explicitly set to zero when a vtkPoint object is created
> (or any other object with real values), because I presume the compiler will
> not do it automatically (unlike integers).
>
> Todd.
>
>
> On Thursday, December 14, 2017, 10:45:17 AM GMT+13, Bill Lorensen <
> bill.lorensen at gmail.com> wrote:
>
>
> I found the problem. The OBJImporter skips any polydata that
>           // If some vertices have tcoords and not others (likewise
> normals)
>           // then we must do something else VTK will complain. (crash
> on render attempt)
>           // Easiest solution is to delete polys that don't have
> complete tcoords (if there
>           // are any tcoords in the dataset) or normals (if there are
> any normals in the dataset).
>
> If does without warning. Only report the skipping  if debug is on.
> This is bad!!!
>
> I'll try to fix the problem in a different way. At the very least I'll
> warn out loud about the skipping.
>
> I've attached a model.obj that removes the tcoords and normals.
>
> Bill
>
>
> On Wed, Dec 13, 2017 at 3:35 PM, Bill Lorensen <bill.lorensen at gmail.com>
> wrote:
> > There must be a bug in the OBJImporter. It reports 4 actors, but only
> > one has polygons. The others report 0 polygons.
> >
> > I'll take a look.
> >
> >
> > On Wed, Dec 13, 2017 at 2:07 PM, Tony Yuan <tonyuanac at gmail.com> wrote:
> >> Hi Sebastien,
> >>
> >> The js loader works fine, but I couldn’t get the same behavior in C++. I
> >> tried to see if the reader has multiple outputs, but
> >> objReader.getNumberOfOutputPorts() returns 1.
> >>
> >> I am interested in getting the mesh as a vtkPolyData, is there a way I
> can
> >> do that with OBJImporter? There seems to be no GetOutput function like
> >> OBJReader.
> >>
> >> Tony
> >>
> >> On Dec 13, 2017, at 12:25 PM, Sebastien Jourdain
> >> <sebastien.jourdain at kitware.com> wrote:
> >>
> >> The file you sent have several materials and I think that the
> vtkOBJReader
> >> just read the first one as it is focusing on the mesh only.
> >>
> >> Your file is correct and I've tried it with vtk.js with success here:
> >> https://kitware.github.io/vtk-js/examples/OBJViewer.html
> >>
> >> But you may have more luck with the importer which could also process
> the
> >> mtl file that should come along. That way all the pieces that compose
> that
> >> object will be loaded.
> >>
> >> Seb
> >>
> >> On Wed, Dec 13, 2017 at 9:40 AM, Tony Yuan <tonyuanac at gmail.com> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I have a problem reading Blender OBJ files using VTK. The vtkOBJReader
> >>> seems to only read part of the mesh. When I render the data being read
> it
> >>> looks like this:
> >>>
> >>>
> >>>
> >>> However, when I import the OBJ file in Meshlab it looks fine. Mac’s
> >>> Preview is also able to open the complete mesh.
> >>>
> >>>
> >>>
> >>> I attached the OBJ file and my code below. I am not very familiar with
> the
> >>> OBJ format and how vtkOBJReader is implemented. If someone could point
> me to
> >>> the problem and possible fixes, that would be great.
> >>>
> >>>
> >>>
> >>> Thanks,
> >>> Tony
> >>>
> >>>
> >>> _______________________________________________
> >>> Powered by www.kitware.com
> >>>
> >>> Visit other Kitware open-source projects at
> >>> http://www.kitware.com/opensource/opensource.html
> >>>
> >>> Please keep messages on-topic and check the VTK FAQ at:
> >>> http://www.vtk.org/Wiki/VTK_FAQ
> >>>
> >>> Search the list archives at: http://markmail.org/search/?q=vtkusers
> >>>
> >>> Follow this link to subscribe/unsubscribe:
> >>> http://public.kitware.com/mailman/listinfo/vtkusers
> >>>
> >>
> >>
> >>
> >> _______________________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Please keep messages on-topic and check the VTK FAQ at:
> >> http://www.vtk.org/Wiki/VTK_FAQ
> >>
> >> Search the list archives at: http://markmail.org/search/?q=vtkusers
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://public.kitware.com/mailman/listinfo/vtkusers
> >>
> >
> >
> >
> > --
> > Unpaid intern in BillsBasement at noware dot com
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171213/bd61d7bd/attachment.html>


More information about the vtkusers mailing list