[vtkusers] Problems with custom filter, points, cells, triangles strips
Kim Rosenbohm
kim.rosenbohm at posteo.de
Tue Aug 19 08:48:15 EDT 2014
Hi List.
I'm writing an algorithm similar to
vtkImageDataGeometryFilter that converts scalar image data to a 3D
surface. It does "kindof" work though I get crashes releated to
ComputeBounds() which are mentioned also here:
http://vtk.1045678.n5.nabble.com/Handling-invalid-vtp-files-td1252488.html
[1]
I suspect the culprit to be how I handle the points and triangles
strips. A sketch of what I do is:
Pre-allocate some point and cell data
to write to:
vtkImageData * input =
vtkImageData::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkPolyData
* output =
vtkPolyData::SafeDownCast(outputInfo->Get(vtkDataObject::DATA_OBJECT()));
const
int * inputDims = input->GetDimensions();
vtkSmartPointer<vtkPoints>
newPoints =
vtkSmartPointer<vtkPoints>::New();
newPoints->Allocate(16*inputDims[0]);
vtkSmartPointer<vtkCellArray>
newCells =
vtkSmartPointer<vtkCellArray>::New();
newCells->Allocate(inputDims[1]);
vtkSmartPointer<vtkTriangleStrip>
newStrip =
vtkSmartPointer<vtkTriangleStrip>::New();
newStrip->GetPointIds()->Allocate(16*inputDims[0]);
vtkIdList
* newStripIds = newStrip->GetPointIds();
Add points to the point
data:
double point[3];
input->GetPoint(inputIndex, point);
newIds[i] =
newPoints->InsertNextPoint(point);
Add point indices to the
cells:
//---loop
newStripIds->Reset();
newStripIds->InsertNextId(newIds[i]);
newStripIds->InsertNextId(newIds[i+1]);
...
//strip
finished, add it to cells
newCells->InsertNextCell(newStrip); //DOES
THIS TAKE OWNERSHIP OR DOES IT COPY?! Is using a vtkSmartPointer
ok?
//clear ids, proceed with next
strip
newStripIds->Reset();
//---loop
Set the values in the
ouput:
output->SetPoints(newPoints); //DOES THIS TAKE OWNERSHIP OR DOES
IT COPY?! Is using a vtkSmartPointer
ok?
output->SetStrips(newCells);
return 1;
Any hints on if this should
work, or where the problem is would be great...
Best Regards,
Kim
Links:
------
[1]
http://vtk.1045678.n5.nabble.com/Handling-invalid-vtp-files-td1252488.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140819/320263cd/attachment.html>
More information about the vtkusers
mailing list