10 #include <vtkSmartPointer.h> 11 #include <vtkPolyData.h> 12 #include <vtkCellArray.h> 13 #include <vtkPolyDataMapper.h> 14 #include <vtkPoints.h> 16 #include <vtkTriangle.h> 17 #include <vtkProperty.h> 18 #include <vtkImageData.h> 19 #include <vtkTexture.h> 20 #include <vtkFloatArray.h> 21 #include <vtkPointData.h> 22 #include <vtkCellData.h> 24 #include <QApplication> 28 moveToThread(QApplication::instance()->thread());
29 cout <<
"CREATE" << endl;
35 static size_t verts_size = 0;
36 static size_t faces_size = 0;
44 vtkSmartPointer<vtkPolyData>
mesh = vtkSmartPointer<vtkPolyData>::New();
48 size_t slice_size = meshbuffer->getVertices().size() - verts_size;
49 size_t slice_face_size = meshbuffer->getFaces().size() - faces_size;
51 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
52 vtkSmartPointer<vtkCellArray> triangles = vtkSmartPointer<vtkCellArray>::New();
54 vtkSmartPointer<vtkUnsignedCharArray> scalars = vtkSmartPointer<vtkUnsignedCharArray>::New();
55 scalars->SetNumberOfComponents(3);
56 scalars->SetName(
"Colors");
59 for(
size_t k = 0; k < slice_size; k++)
61 auto vertex = meshbuffer->getVertices()[k + verts_size];
63 points->InsertNextPoint(
64 vertex->m_position[0],
65 vertex->m_position[1],
66 vertex->m_position[2]);
74 unsigned char color[3] = {0, 255, 0};
75 scalars->InsertNextTupleValue(color);
82 mesh->GetPointData()->SetScalars(scalars);
83 cout <<
"2 " << slice_face_size << endl;
84 for(
size_t k = 0; k < slice_face_size; k++)
86 auto face = meshbuffer->getFaces()[k + faces_size];
88 vtkSmartPointer<vtkTriangle> t = vtkSmartPointer<vtkTriangle>::New();
89 t->GetPointIds()->SetId(0,
m_indexMap[face->m_edge->end()]);
90 t->GetPointIds()->SetId(1,
m_indexMap[face->m_edge->next()->end()]);
91 t->GetPointIds()->SetId(2,
m_indexMap[face->m_edge->next()->next()->end()]);
92 triangles->InsertNextCell(t);
100 int b =
m_indexMap[face->m_edge->next()->end()];
101 int c =
m_indexMap[face->m_edge->next()->next()->end()];
103 cout << a <<
" " << b <<
" " << c <<
" " <<
m_indexMap.size() <<
" " <<
m_vertices.size() / 3 << endl;
110 verts_size = meshbuffer->getVertices().size();
111 faces_size = meshbuffer->getFaces().size();
113 mesh->SetPoints(points);
114 mesh->SetPolys(triangles);
117 vtkSmartPointer<vtkPolyDataMapper> mesh_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
120 mesh_mapper->SetInput(mesh);
122 mesh_mapper->SetInputData(mesh);
129 vtkSmartPointer<vtkProperty>
p = vtkSmartPointer<vtkProperty>::New();
130 p->SetColor(1.0, 1.0, 1.0);
unordered_map< VertexPtr, size_t > m_indexMap
HalfEdgeKinFuMesh< cVertex, lvr::Normal< float > > HMesh
MeshUpdateThread(kfusion::KinFu::Ptr kinfu)
void computeMeshActor(HMesh *meshbuffer)
kfusion::KinFu::Ptr m_kinfu
virtual ~MeshUpdateThread()
vector< float > m_vertices