[vtkusers] Creating simple Polygon data
Ashika Umanga Umagiliya
aumanga at biggjapan.com
Mon Sep 13 22:44:13 EDT 2010
Greetings all,
Pleaser refer to image at:
http://i54.tinypic.com/qssjtv.jpg
As seen in the image,I have my own Data structure to store cellborders
(contours).
*One slice of MRC image has one RzTrunk.
*RzTrunk has many RzCurve s.
*RzCurve consists of RzNode s.
I want to create VTK Polygon for a RzTrunk.
I did sample implementation as follows,but it crash at the line
"vtkCurve->GetPointIds()->SetId(ccount,ncount);"
with the error message :
/0x00007fc701928737 in vtkIdList::SetId (this=0x2c1e660, i=0, vtkid=0)
at /usr/local/include/vtk-5.6/vtkIdList.h:53
53 void SetId(const vtkIdType i, const vtkIdType vtkid)
{this->Ids[i] = vtkid;};
(gdb) back
#0 0x00007fc701928737 in vtkIdList::SetId (this=0x2c1e660, i=0,
vtkid=0) at /usr/local/include/vtk-5.6/vtkIdList.h:53/
Any assistance would be greatly appreciated.
vtkSmartPointer<vtkCellArray>
vtkCurves=vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkPoints>
vtkCrvPoints=vtkSmartPointer<vtkPoints>::New();
//Get trunk
RzTrunk *trnk=contourStack->getTrunk(i);
//Each Curve in trunk
int ncount=0;
for(int c=0;c<1;c++)
{
//vtk stuff
vtkSmartPointer<vtkPolygon>
vtkCurve=vtkSmartPointer<vtkPolygon>::New();
RzCurve *crv=trnk->getCurves().at(c);
//Process RzNodes
RzNode *tmp,*node=crv->getHeadNode();
tmp=node;
int ccount=0;
//Process the Linked list
while(tmp->getNextNode()!=crv->getHeadNode()){
//Process Node
//VTK: to VTK points
vtkCrvPoints->InsertNextPoint(tmp->getX(),tmp->getY(),0.0);
//VTK: add vertex to vtkCurve
vtkCurve->GetPointIds()->SetId(ccount,ncount); //Crash Here!!!!!
tmp=tmp->getNextNode();
ccount++;
ncount++;
}
//VTK : Add curve to Cell Array
vtkCurves->InsertNextCell(vtkCurve);
}
//vtk PolyData object
vtkSmartPointer<vtkPolyData>
polyData=vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(vtkCrvPoints);
polyData->SetPolys(vtkCurves);
vtkSmartPointer<vtkXMLPolyDataWriter> writer =
vtkSmartPointer<vtkXMLPolyDataWriter>::New();
writer->SetFileName ( "c:\\Triangle.vtp" );
writer->SetInput ( polyData );
writer->Write();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100914/f6e51f19/attachment.htm>
More information about the vtkusers
mailing list