minor mesh load fixes

This commit is contained in:
Anatoly Baksheev 2013-07-15 16:46:39 +04:00
parent 4c228c07f1
commit 0e20473c97

View File

@ -74,19 +74,18 @@ struct cv::viz::Mesh3d::loadMeshImpl
reader->Update(); reader->Update();
vtkSmartPointer<vtkPolyData> poly_data = reader->GetOutput (); vtkSmartPointer<vtkPolyData> poly_data = reader->GetOutput ();
typedef unsigned int uint32_t;
vtkSmartPointer<vtkPoints> mesh_points = poly_data->GetPoints (); vtkSmartPointer<vtkPoints> mesh_points = poly_data->GetPoints ();
vtkIdType nr_points = mesh_points->GetNumberOfPoints (); vtkIdType nr_points = mesh_points->GetNumberOfPoints ();
//vtkIdType nr_polygons = poly_data->GetNumberOfPolys (); //vtkIdType nr_polygons = poly_data->GetNumberOfPolys ();
mesh->cloud.create(1, nr_points, CV_32FC3); mesh->cloud.create(1, nr_points, CV_32FC3);
double point_xyz[3]; Vec3f *mesh_cloud = mesh->cloud.ptr<Vec3f>();
for (vtkIdType i = 0; i < mesh_points->GetNumberOfPoints (); i++) for (vtkIdType i = 0; i < mesh_points->GetNumberOfPoints (); i++)
{ {
mesh_points->GetPoint (i, &point_xyz[0]); Vec3d point;
mesh->cloud.ptr<cv::Point3f>()[i] = cv::Point3d(point_xyz[0], point_xyz[1], point_xyz[2]);; mesh_points->GetPoint (i, point.val);
mesh_cloud[i] = point;
} }
// Then the color information, if any // Then the color information, if any
@ -105,14 +104,15 @@ struct cv::viz::Mesh3d::loadMeshImpl
if (poly_colors && (poly_colors->GetNumberOfComponents () == 3)) if (poly_colors && (poly_colors->GetNumberOfComponents () == 3))
{ {
mesh->colors.create(1, nr_points, CV_8UC3); mesh->colors.create(1, nr_points, CV_8UC3);
unsigned char point_color[3]; Vec3b *mesh_colors = mesh->colors.ptr<cv::Vec3b>();
for (vtkIdType i = 0; i < mesh_points->GetNumberOfPoints (); i++) for (vtkIdType i = 0; i < mesh_points->GetNumberOfPoints (); i++)
{ {
poly_colors->GetTupleValue (i, &point_color[0]); Vec3b point_color;
poly_colors->GetTupleValue (i, point_color.val);
//RGB or BGR????? //RGB or BGR? should we swap channels????
mesh->colors.ptr<cv::Vec3b>()[i] = cv::Vec3b(point_color[0], point_color[1], point_color[2]); mesh_colors[i] = point_color;
} }
} }
else else