<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Verdana,Geneva,sans-serif'>
Hi List.<br /><br />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: <a href="http://vtk.1045678.n5.nabble.com/Handling-invalid-vtp-files-td1252488.html">http://vtk.1045678.n5.nabble.com/Handling-invalid-vtp-files-td1252488.html</a><br />I suspect the culprit to be how I handle the points and triangles strips. A sketch of what I do is:<br /><br />Pre-allocate some point and cell data to write to:<br /><br />vtkImageData * input = vtkImageData::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()));<br />vtkPolyData * output = vtkPolyData::SafeDownCast(outputInfo->Get(vtkDataObject::DATA_OBJECT()));<br /><br />const int * inputDims = input->GetDimensions();<br />vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New();<br />newPoints->Allocate(16*inputDims[0]);<br />vtkSmartPointer<vtkCellArray> newCells = vtkSmartPointer<vtkCellArray>::New();<br />newCells->Allocate(inputDims[1]);<br />vtkSmartPointer<vtkTriangleStrip> newStrip = vtkSmartPointer<vtkTriangleStrip>::New();<br />newStrip->GetPointIds()->Allocate(16*inputDims[0]);<br />vtkIdList * newStripIds = newStrip->GetPointIds();<br /><br />Add points to the point data:<br /><br />double point[3];<br />input->GetPoint(inputIndex, point);<br />newIds[i] = newPoints->InsertNextPoint(point);<br /><br />Add point indices to the cells:<br /><br />//---loop<br />newStripIds->Reset();<br />newStripIds->InsertNextId(newIds[i]);<br />newStripIds->InsertNextId(newIds[i+1]);<br />...<br />//strip finished, add it to cells<br />newCells->InsertNextCell(newStrip); //DOES THIS TAKE OWNERSHIP OR DOES IT COPY?! Is using a vtkSmartPointer ok?<br />//clear ids, proceed with next strip<br />newStripIds->Reset();<br />//---loop<br /><br />Set the values in the ouput:<br /><br />output->SetPoints(newPoints); //DOES THIS TAKE OWNERSHIP OR DOES IT COPY?! Is using a vtkSmartPointer ok?<br />output->SetStrips(newCells);<br />return 1;<br />
<div>
<pre><br />Any hints on if this should work, or where the problem is would be great...<br /><br />Best Regards,<br /><br />Kim</pre>
</div>
</body></html>