Hi;
I want construct a filled contour (vtkimagedata) from contour points in Slicer RT.
This is the code i have implemented :
vtkPoints* pointsSlice // the set of 3D points of the contour
int nbpoints = pointsSlice->GetNumberOfPoints()-1; // number of points
int dimSlice[3]; dimSlice[0]= dim[0]; dimSlice[1] =dim[1]; dimSlice[2]=1; // set up vtkImagedata parameters
vtkSmartPointer imgSlice = vtkSmartPointer::New();
int extent[6] = {0, dimSlice[0]-1, 0, dimSlice[1]-1, 0, 0};
imgSlice->SetExtent(extent);
imgSlice->SetOrigin(origin);
imgSlice->SetDimensions(dimSlice);
imgSlice->SetSpacing(1,1,1);
imgSlice->AllocateScalars(VTK_UNSIGNED_CHAR,1);
for(int i=0; i< nbpoints; i++) // store 3D points in double array
{
double *p = pointsSlice->GetPoint(i);
pts[i*3+0] = p[0];
pts[i*3+1] = p[1];
pts[i*3+2] = p[2];
}
double *boundSlice = pointsSlice->GetBounds(); // bounds of 3d Points
double z_coord = vtkMath::Round(pts[2]); //all 3d points of same contour have same z-coord
vtkPolygon::ComputeNormal(pointsSlice, normal); //compute normal of the contour
for(int j=0; j<dim[1];j++)
for(int i=0; i<dim[0]; i++)
{
double x[3] = {i+origin[0], j+origin[1], z_coord};
in_poly = vtkPolygon::PointInPolygon(x, nbpoints,pts,boundSlice,normal);
if(in_poly) // point belong to the contour
pixel =255;
else
pixel= 0
}
However this method display filled square instead of filled circle (contour) as shown in figure.
I think because I have used vtkPolygon:: PointInPolygon test?
How can I get a filled contour instead of filled square.
thank’s in advance for your help