[vtkusers] converting vtkPolyLines to vtkLines
Dr. Roman Grothausmann
grothausmann.roman at mh-hannover.de
Wed Oct 10 07:57:16 EDT 2012
Dear mailing list members,
Since there seems no filter in VTK to convert vtkPolyLines to vtkLines I
tried to do this manually. The code I use for that is below. Am I doing
it appropriately or would there be a better way?
Thanks
Roman
////vtkPolyLine2vtkLine(mesh);
vtkCell *cell;
vtkCell *edge;
vtkPolyData *new_mesh= vtkPolyData::New();
vtkPoints *points= vtkPoints::New();
vtkCellArray *lines= vtkCellArray::New();
points= mesh->GetPoints(); //GetVerts()
for (vtkIdType i= 0; i < N; i++){
cell= mesh->GetCell(i);
if (cell->GetCellType() == VTK_POLY_LINE) {
std::cerr << "Cell " << i << " is of type " <<
vtkCellTypes::GetClassNameFromTypeId(mesh->GetCell(i)->GetCellType()) <<
std::endl;
vtkIdType noe= cell->GetNumberOfEdges(); //vtkPolyLine does not
consist of edges!!!
//vtkIdType noe= cell->GetNumberOfLines(); vtkCell has no member
named GetNumberOfLines
vtkIdType nop= cell->GetNumberOfPoints();
std::cerr << "Cell contains " << noe << " edges and " << nop << "
points." << std::endl;
for (vtkIdType j= 1; j < nop; j++){ //start at 1 since a polyline
has nop-1 lines!
vtkIdType pi= cell->GetPointId(j);
vtkLine *line= vtkLine::New();
line->GetPointIds()->SetId(0,cell->GetPointId(j - 1));
line->GetPointIds()->SetId(1,cell->GetPointId(j));
//line->GetPointIds()->InsertNextId(edge->GetPointIds()->GetId(0));
//line->GetPointIds()->InsertNextId(edge->GetPointIds()->GetId(1));
lines->InsertNextCell(line);
}
}
}
new_mesh->SetPoints(points);
new_mesh->SetLines(lines);
On 14/09/12 21:21, Dr. Roman Grothausmann wrote:
> Hello Darshan Pai,
>
>
> Thanks for Your reply. Isn't vtkStripper for conversion of vtkLines to
> vtkPolyLines? I would need a filter for doing the opposite.
> I tried vtkStripper with SetMaximumLength(1) and SetMaximumLength(0) but
> the output was still vtkPolyLines. Would I have to convert these
> vtkPolyLines with just two vertices into vtkLines manually?
>
> Many thanks for Your help
> Roman
>
> On 14/09/12 17:27, Darshan Pai wrote:
>> You can try using vtkStripper.
>>
>> Regards
>>
>>
>> On Fri, Sep 14, 2012 at 5:53 AM, Dr. Roman Grothausmann
>> <grothausmann.roman at mh-hannover.de
>> <mailto:grothausmann.roman at mh-hannover.de>> wrote:
>>
>> Dear mailing list members,
>>
>>
>> How to convert vtkPolyLines to vtkLines? vtkTriangleFilter does the
>> corresponding conversion of triangles-strips, but what filter to use
>> for vtkPolyLines? vtkCleanPolyData only does it for degenerate cells.
>>
>> Many thanks for any help or hints
>> Roman
>>
>>
>> --
>> Dr. Roman Grothausmann
>>
>> Tomographie und Digitale Bildverarbeitung
>> Tomography and Digital Image Analysis
>>
>> Institut für Funktionelle und Angewandte Anatomie, OE 4120
>> Medizinische Hochschule Hannover
>> Carl-Neuberg-Str. 1
>> 30625 Hannover
>>
>> Tel. +49 511 532-9574 <tel:%2B49%20511%20532-9574>
>> _________________________________________________
>> Powered by www.kitware.com <http://www.kitware.com>
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/__opensource/opensource.html
>> <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 <http://www.vtk.org/Wiki/VTK_FAQ>
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/__listinfo/vtkusers
>> <http://www.vtk.org/mailman/listinfo/vtkusers>
>>
>>
>
--
Dr. Roman Grothausmann
Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis
Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
30625 Hannover
Tel. +49 511 532-9574
More information about the vtkusers
mailing list