[vtkusers] Voxelization
Daniel Soares
adaptchart.info at gmail.com
Wed Mar 10 18:12:08 EST 2010
I suppose you are saying that I use the following pipeline:
vtkSphereSource -> vtkVoxelModeller -> vtkDelaunay3D
The problem is that the input of vtkDelaunay3D is a vtkPointSet and the
output of vtkVoxelModeller is a vtkImageData. How could I convert a
vtkImageData to a vtkPointSet?
Anyway, it looks like the solution involves vtkMarchingCubes, as it's input
is a vtkImageData. The problem is that vtkMarchingCubes is not displaying
any result when used in my source code.
Any ideas?
Daniel Soares
2010/3/10 KS Jothybasu <jothybasu at gmail.com>
> What about creating a mesh with vtkDelaunay3D?
>
> Jothy
>
> On Wed, Mar 10, 2010 at 1:30 AM, Daniel Soares <adaptchart.info at gmail.com>wrote:
>
>> Hi!
>>
>> I have a problem with voxelization in VTK. My purpose is to create a
>> sphere using vtkSphereSource, then voxelize it using vtkVoxelModeller, then
>> draw a surface that is similar to the original sphere. The only way I
>> managed to draw a surface, was using vtkContourFilter. The problem is that
>> some artifacts are produced, looking like holes in the voxelized sphere.
>> I saw at this site (
>> http://www.evl.uic.edu/aspale/cs526/final/3-5-2-0.htm ), that the results
>> with vtkMarchingCubes are much better than the ones with vtkContourFilter.
>> So I tryied to use it, but I couldn't obtain any result at all (blank
>> screen). The same happened when I used vtkDiscreteMarchingCubes and
>> vtkImageMarchingCubes.
>>
>> Does anyone have any idea why the marching cubes are not producing results
>> or why the contour filter produces holes on the surface? Is there other way
>> to achive what I want?
>>
>> Here's the source code of my experiment:
>>
>> //===============================================
>>
>> vtkSphereSource* sphereModel = vtkSphereSource::New();
>> sphereModel->SetThetaResolution(10);
>> sphereModel->SetPhiResolution(10);
>>
>> vtkVoxelModeller* voxeller = vtkVoxelModeller::New();
>> voxeller->SetSampleDimensions(17, 17, 17);
>> voxeller->SetModelBounds(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);
>> voxeller->SetInputConnection(sphereModel->GetOutputPort());
>> voxeller->Update();
>> vtkImageData* imageData = voxeller->GetOutput();
>> imageData->SetScalarTypeToFloat();
>>
>> vtkLookupTable* lut = vtkLookupTable::New();
>> lut->SetNumberOfColors(3);
>> lut->SetTableRange(0, 1);
>> lut->SetScaleToLinear();
>> lut->Build();
>> lut->SetTableValue(0, 0, 0, 0, 1);
>> lut->SetTableValue(0.5, 1, 0, 0, 1);
>> lut->SetTableValue(1, 1, 1, 1, 1);
>>
>> //vtkContourFilter* surface = vtkContourFilter::New();
>> vtkMarchingCubes* surface = vtkMarchingCubes::New();
>> surface->SetInput(imageData);
>> surface->ComputeScalarsOn();
>> surface->ComputeGradientsOn();
>> surface->ComputeNormalsOn();
>> surface->SetValue(0, 0.5);
>>
>> vtkPolyDataMapper* voxelMapper = vtkPolyDataMapper::New();
>> voxelMapper->SetInputConnection(discrete->GetOutputPort());
>> voxelMapper->SetLookupTable(lut);
>> voxelMapper->SetScalarRange(0, lut->GetNumberOfColors());
>>
>> vtkActor* voxelActor = vtkActor::New();
>> voxelActor->SetMapper(voxelMapper);
>>
>> ren1->AddActor(voxelActor);
>>
>> //==============================================
>>
>> Thanks in advance.
>>
>> Daniel Soares
>>
>> _______________________________________________
>> 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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100310/17575eb9/attachment.htm>
More information about the vtkusers
mailing list