[vtkusers] Surface from contours
Yogish Mallya
mallyayogish at yahoo.co.in
Wed Aug 12 05:31:57 EDT 2009
Karthik,
It is working now. I had to create vtkPolydata structure per contour and
vtkAppendPolyData to combine them.
Best Wishes
Yogish
--- On Wed, 12/8/09, Yogish Mallya <mallyayogish at yahoo.co.in> wrote:
From: Yogish Mallya <mallyayogish at yahoo.co.in>
Subject: Re: [vtkusers] Surface from contours
To: "Karthik Krishnan" <karthik.krishnan at kitware.com>
Cc: vtkusers at vtk.org, "itk" <insight-users at itk.org>
Date: Wednesday, 12 August, 2009, 11:33 AM
Thank you Karthik for the quick response.
I wrote following code to convert the contour points to surface. But the vtk ouput file is blank. i.e no vertices and cells. What might me the reason ?
FILE *datei = fopen("C:/inputpoints.txt","rt");
vtkPolyData *data = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
vtkCellArray *Lines = vtkCellArray ::New();
int iCounter = 0;
while (!feof(datei))
{
fprintf(stdout,"reading points: %i\r", iCounter);
float x, y, z;
fscanf(datei,"%f %f %f\n", &x, &y, &z);
points->InsertPoint(iCounter++, x, y, z);
Lines->InsertCellPoint( iCounter );
}
data->SetPoints(points);
data->SetLines(Lines);
fclose(datei);
fprintf(stdout,"\n\n");
vtkRuledSurfaceFilter *ruledSurfaceFilter = vtkRuledSurfaceFilter::New();
ruledSurfaceFilter->SetInput(data);
ruledSurfaceFilter->SetRuledModeToResample();
ruledSurfaceFilter->CloseSurfaceOn();
ruledSurfaceFilter->Update();
vtkDataSetWriter *dsw = vtkDataSetWriter::New();
dsw->SetInput((vtkPolyData*)ruledSurfaceFilter->GetOutput());
dsw->SetFileName("c:/RuledSurface.vtk");
dsw->Write();
Rgds,
Yogish
--- On Wed, 12/8/09, Karthik Krishnan <karthik.krishnan at kitware.com> wrote:
From: Karthik Krishnan <karthik.krishnan at kitware.com>
Subject: Re: [vtkusers] Surface from contours
To: "Yogish Mallya" <mallyayogish at yahoo.co.in>
Cc: vtkusers at vtk.org, "itk" <insight-users at itk.org>
Date: Wednesday, 12 August, 2009, 11:05 AM
Graphics/Testing/Tcl/TestRuledSurface*.tcl
The difference from the tests is that you need to set "ClosedSurfaceOn()".
Also, if the number of points in each of the contours is different or not in correspondance, you'll want to resample the contours by setting "SetRuledModeToResample()".
And there are ways to do this without using vtkRuledSurfaceFilter as well...
You could rasterize the contours (vtkPolygon::PointInPolygon), treat the result as an image, run an AntiAlias filter (ITK) and then triangulate by generating an isosurface with marching cubes.
On Tue, Aug 11, 2009 at 10:05 PM, Yogish Mallya <mallyayogish at yahoo.co.in> wrote:
Hi All,
I have a text file containing a set of points representing three parallel contours in Z-direction (text file is attached in the mail). The point set in the file is ordered. I want to generate a triangular surface mesh from these contours. vtkRuledSurfaceFilter seems to be the correct solution. It would be great if somebody can share a c++ example or steps on how to use this filter ?
Regards,
Yogish
Yahoo! recommends that you upgrade to the new and safer Internet Explorer 8.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at 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
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
--
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: 518 881 4919
Fax: 518 371 4573
Yahoo! recommends that you upgrade to the new and safer Internet Explorer 8.
See the Web's breaking stories, chosen by people like you. Check out Yahoo! Buzz. http://in.buzz.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090812/e7d39faf/attachment.htm>
More information about the vtkusers
mailing list