[vtkusers] Volume mesh of an object with convexe and concave regions

syssboxx-vtk at yahoo.fr syssboxx-vtk at yahoo.fr
Tue Jun 14 07:51:03 EDT 2005

Hi Tim,
I downloaded your filter and converted your tcl program in c++ and it works.I tried it for 3 images and it works good but when I tried with all the slices of my volume it is extremelly slow.I'm working under XP,CPU 2.80GHz,1.00 GB RAM and my images are 832x1008 and it takes over 24 hours to process it and there's not result yet.How many time take it normally to process?Is there some way to optimize it cause like this it's a little bit of inapplicable.
Here is the code that i use:

#include <vtkPolyData.h>

#include <vtkPoints.h>

#include <vtkPolyDataMapper.h>

#include <vtkActor.h>

#include "vtkPowerCrustSurfaceReconstruction.h"

#include <vtkRenderer.h>

#include <vtkRenderWindow.h>

#include <vtkWindowToImageFilter.h>

#include <vtkPNGWriter.h>

#include <vtkProperty.h>

#include <vtkCamera.h>

#include "vtkRenderWindowInteractor.h"


int main( int argc, char *argv[] )



FILE *donnees = fopen("points.txt","r");

vtkPolyData *data = vtkPolyData::New();

vtkPoints *points = vtkPoints::New();

int iCounter = 0;

while (!feof(donnees))


fprintf(stdout,"reading points: %i\r", iCounter);

float x, y, z;

fscanf(donnees,"%f %f %f\n", &x, &y, &z);

points->InsertPoint(iCounter++, x, y, z);






// render the raw input points into the first renderer

vtkPolyDataMapper *rawpointsmapper=vtkPolyDataMapper::New();

rawpointsmapper-> SetInput(data); 

vtkActor *rawpointsactor=vtkActor::New();

rawpointsactor ->SetMapper( rawpointsmapper);

rawpointsactor ->GetProperty()-> SetColor( 0, 0, 0);

rawpointsactor ->SetScale(1.0,1.0,25);

// construct the surface and render into the second renderer

vtkPowerCrustSurfaceReconstruction *surf=vtkPowerCrustSurfaceReconstruction::New();

surf -> SetInput(data);

vtkPolyDataMapper *map=vtkPolyDataMapper::New();

map -> SetInput (surf ->GetOutput());

vtkActor *surfaceActor=vtkActor::New();

surfaceActor -> SetMapper (map);

surfaceActor ->GetProperty()-> SetDiffuseColor (1.0000, 0.3882, 0.2784);

surfaceActor ->GetProperty()-> SetSpecularColor (1, 1, 1);

surfaceActor ->GetProperty()-> SetSpecular (.4);

surfaceActor ->GetProperty()-> SetSpecularPower( 50);

surfaceActor ->SetScale(1.0,1.0,25);

// render the medial surface into a third renderer

surf-> Update(); 

// (because GetMedialSurface is not part of the normal pipeline)

vtkPolyDataMapper *medialmapper=vtkPolyDataMapper::New();

medialmapper -> SetInput (surf ->GetMedialSurface());

medialmapper ->ScalarVisibilityOff();

vtkActor *medialactor=vtkActor::New();

medialactor -> SetMapper( medialmapper);

medialactor ->GetProperty()-> SetDiffuseColor (0.1000, 0.8882, 0.2784);

medialactor ->GetProperty()-> SetSpecularColor (1 ,1, 1);

medialactor ->GetProperty()-> SetSpecular (.4);

medialactor ->GetProperty()-> SetSpecularPower (50);

medialactor ->GetProperty()-> SetRepresentationToWireframe();

medialactor ->SetScale(1.0,1.0,25);

// Render everything

vtkRenderer *ren1=vtkRenderer::New();

vtkRenderer *ren2=vtkRenderer::New();

vtkRenderer *ren3=vtkRenderer::New();

vtkRenderWindow *renWin=vtkRenderWindow::New();

renWin ->AddRenderer( ren1);

renWin ->AddRenderer (ren2);

renWin ->AddRenderer (ren3);

renWin ->SetSize (1000 ,1000);

// Add the actors to the renderer

ren1-> AddActor (rawpointsactor);

ren2 ->AddActor (surfaceActor);

ren3 ->AddActor (medialactor);

// set the properties of the renderers

ren1 ->SetBackground (1, 1, 1);

ren1 ->SetViewport (0.0 ,0.0, 0.33, 1.0);

ren1 ->GetActiveCamera() -> SetPosition (1, -1 ,0);

ren1 ->ResetCamera();

ren2 ->SetBackground (1, 1, 1);

ren2 ->SetViewport (0.33 ,0.0, 0.66, 1.0);

ren2 ->GetActiveCamera() -> SetPosition (1 ,-1, 0 ); 

ren2 ->ResetCamera();

ren3 ->SetBackground (1, 1, 1);

ren3 ->SetViewport (0.66 ,0.0 ,1.0, 1.0);

ren3 ->GetActiveCamera() ->SetPosition (1 ,-1, 0);

ren3 ->ResetCamera();

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();


//render the image

renWin ->Render();


// output the image to file (used to generate the initial regression image)

vtkWindowToImageFilter *to_image=vtkWindowToImageFilter::New();

to_image ->SetInput ( renWin);

vtkPNGWriter *to_png=vtkPNGWriter::New();

to_png-> SetFileName ("TestPowerCrust.png");

to_png ->SetInput(to_image-> GetOutput());

to_png -> Write();








Tim Hutton <tim.hutton at gmail.com> a écrit :

You could try some form of surface reconstruction. This code is
already written for VTK which should save you time:

>From the image you sent it looks like it would work. However, the best
results should be obtained from your marching cubes approach since the
original image is a volume. Maybe you need to fill the contours before
running vtkMarchingCubes?


On 6/10/05, Torsten Sadowski wrote:
> Have a look at this. Maybe it does what you need.
> Torsten
> http://www.ices.utexas.edu/~jessica/software/index.html
> On Fri, 10 Jun 2005 syssboxx-vtk at yahoo.fr wrote:
> > Hi vtk users,
> > I have to visualize a head from contours of MRI images.I tried Delaunay from a txt file with set of points with coordinates.My object has concave and convexe regions,so for the convexes it gives a good results but for the others it's terrible!! (I jointed the result) Is there a way to apply some other filter after Delaunay for improve the result in the concaves. I tried also MarchingCubes applied on the volume with the contours but results are neither good.
> > That's the best choice for this kind of object to get best result and the same time I want a mesh over the originaly points.
> >
> > Thanks for your suggestions
> >
> > Stanislava
> >
> >
> >
> >
> > ---------------------------------
> > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> > Téléchargez le ici !
> >
> >
> >
> > ---------------------------------
> > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> > Téléchargez le ici !
> >
> >
> >
> >
> > ---------------------------------
> > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> > Téléchargez le ici !
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

Tim Hutton - http://www.sq3.org.uk

 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici ! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050614/ac1c5145/attachment.htm>

More information about the vtkusers mailing list