Skip to content

Commit

Permalink
support VTK 5
Browse files Browse the repository at this point in the history
  • Loading branch information
jasjuang committed Apr 29, 2018
1 parent dc0ee1e commit dd41edd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions visualization/src/pcl_visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@
#include <vtkTIFFReader.h>
#include <vtkLookupTable.h>
#include <vtkTextureUnitManager.h>

#if VTK_MAJOR_VERSION > 5
#include <vtkTexture.h>
#endif

#include <pcl/visualization/common/shapes.h>
#include <pcl/visualization/pcl_visualizer.h>
Expand Down Expand Up @@ -3520,6 +3523,9 @@ pcl::visualization::PCLVisualizer::addTextureMesh (const pcl::TextureMesh &mesh,
texture_units, mesh.tex_materials.size ());
// Load textures
std::size_t last_tex_id = std::min (static_cast<int> (mesh.tex_materials.size ()), texture_units);
#if VTK_MAJOR_VERSION <= 5
int tu = vtkProperty::VTK_TEXTURE_UNIT_0;
#endif
std::size_t tex_id = 0;
while (tex_id < last_tex_id)
{
Expand Down Expand Up @@ -3551,12 +3557,25 @@ pcl::visualization::PCLVisualizer::addTextureMesh (const pcl::TextureMesh &mesh,
for (std::size_t tc = 0; tc < mesh.tex_coordinates[t].size (); ++tc)
coordinates->InsertNextTuple2 (-1.0, -1.0);

#if VTK_MAJOR_VERSION > 5
mapper->MapDataArrayToMultiTextureAttribute(mesh.tex_materials[tex_id].tex_name.c_str (),
this_coordinates_name.c_str (),
vtkDataObject::FIELD_ASSOCIATION_POINTS);
#else
mapper->MapDataArrayToMultiTextureAttribute(tu,
this_coordinates_name.c_str (),
vtkDataObject::FIELD_ASSOCIATION_POINTS);
#endif
polydata->GetPointData ()->AddArray (coordinates);
#if VTK_MAJOR_VERSION > 5
actor->GetProperty ()->SetTexture (mesh.tex_materials[tex_id].tex_name.c_str (), texture);
#else
actor->GetProperty ()->SetTexture (tu, texture);
#endif
++tex_id;
#if VTK_MAJOR_VERSION <= 5
++tu;
#endif
}
} // end of multi texturing
else
Expand Down

0 comments on commit dd41edd

Please sign in to comment.