[vtkusers] Accessing p-skeleton
Sensei
senseiwa at gmail.com
Thu Apr 18 04:58:42 EDT 2013
Hi everybody!
I am writing a fairly simple program to try things. I'd like to store
the entire topology of a cell complex, and as far as I understand I
should use the vtkCellArray class.
So what I wrote is simple: create a triangle. I started from the
example, so I added cell by cell, just to be sure. (see the code below) I
Now it works, and I correctly get the number of cells as 7 (1 2-cell, 3
1-cells, and 3 0-cells).
How can I access them, collectively? For example "give me the
0-skeleton" (all the points).
I have the impression I am misusing VTK here, and there is a kosher way
of achieving this. In the future, I'll need this facility to pick cells
of a certain dimension with the mouse.
Any hints?
Thanks & Cheers!
PS. By the way, after adding a new actor, how can I force an update? It
doesn't appear until I manipulate the window (for example panning or
rotating the view).
double pts[3][3] =
{
{ 0.0, 0.0, 0.0 },
{ 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 }
};
vtkIdType k_0[3][1] =
{
{ 0 },
{ 1 },
{ 2 }
};
vtkIdType k_1[3][2] =
{
{ 0, 1 },
{ 1, 2 },
{ 2, 0 }
};
vtkIdType k_2[1][3] =
{
{ 0, 1, 2 }
};
vtkSmartPointer<vtkPolyData> poly =
vtkSmartPointer<vtkPolyData>::New();
// K_0
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
points->InsertPoint(0, pts[0]);
points->InsertPoint(1, pts[1]);
points->InsertPoint(2, pts[2]);
poly->SetPoints(points);
vtkSmartPointer<vtkCellArray> cells =
vtkSmartPointer<vtkCellArray>::New();
// K_0
cells->InsertNextCell(1, k_0[0]);
cells->InsertNextCell(1, k_0[1]);
cells->InsertNextCell(1, k_0[2]);
// K_1
cells->InsertNextCell(2, k_1[0]);
cells->InsertNextCell(2, k_1[1]);
cells->InsertNextCell(2, k_1[2]);
// K_2
cells->InsertNextCell(3, k_2[0]);
poly->SetPolys(cells);
vtkSmartPointer<vtkPolyDataMapper> map =
vtkSmartPointer<vtkPolyDataMapper>::New();
map->SetInput(poly);
map->Update();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(map);
renderer3d_->AddActor(actor);
qWarning("> adding poly: %lld", cells->GetNumberOfCells());
More information about the vtkusers
mailing list