<div dir="ltr">SphereSource--GetPolydata--CreateMesh--Subdivide should work I think. Let me know, if you find any solution as I too need to do this at some point of time.<br><br>Thanks<br><br>Jothy<br><br><div class="gmail_quote">
On Thu, Mar 11, 2010 at 1:16 AM, Daniel Soares <span dir="ltr"><<a href="http://adaptchart.info">adaptchart.info</a>@<a href="http://gmail.com">gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Here's the code of my experiment. You can easily change it to switch between vtkContourFilter and vtkMarchingCubes. As I said, vtkContourFilter displays holes on the voxelized sphere and vtkMarchingCubes doesn't display anything.</div>
<div><br></div><div><div>#include "vtkActor.h"</div><div>#include "vtkPolyDataMapper.h"</div><div>#include "vtkPolyData.h"</div><div>#include "vtkRenderWindowInteractor.h"</div><div>
#include "vtkRenderWindow.h"</div><div>#include "vtkRenderer.h"</div><div><br></div><div>#include "vtkImageData.h"</div><div>#include "vtkVoxelModeller.h"</div><div>#include "vtkMarchingCubes.h"</div>
<div>#include "vtkContourFilter.h"</div><div>#include "vtkSphereSource.h"</div><div><br></div><div>int main(int argc, char *argv[]) {</div><div><br></div><div> vtkRenderer* ren1 = vtkRenderer::New();</div>
<div> ren1->SetBackground(1, 1, 1); // Background color white</div><div><br></div><div> vtkRenderWindow* renWin = vtkRenderWindow::New();</div><div> renWin->AddRenderer(ren1);</div><div> vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();</div>
<div> iren->SetRenderWindow(renWin);</div><div class="im"><div><br></div><div> vtkSphereSource* sphereModel = vtkSphereSource::New();</div><div> sphereModel->SetThetaResolution(10);</div><div> sphereModel->SetPhiResolution(10);</div>
<div><br></div><div> vtkVoxelModeller* voxeller = vtkVoxelModeller::New();</div><div> voxeller->SetSampleDimensions(17, 17, 17);</div><div> voxeller->SetModelBounds(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);</div><div>
voxeller->SetInputConnection(sphereModel->GetOutputPort());</div><div><br></div></div><div class="im"><div> vtkContourFilter* surface = vtkContourFilter::New();</div><div> //vtkMarchingCubes* surface = vtkMarchingCubes::New();</div>
<div><br></div></div><div> surface->SetInputConnection(voxeller->GetOutputPort());</div><div> surface->SetNumberOfContours(1);</div><div class="im"><div> surface->ComputeScalarsOn();</div><div> surface->ComputeGradientsOn();</div>
<div> surface->ComputeNormalsOn();</div><div> surface->SetValue(0, 0.5);</div><div><br></div><div> vtkPolyDataMapper* voxelMapper = vtkPolyDataMapper::New();</div></div><div> voxelMapper->SetInputConnection(surface->GetOutputPort());</div>
<div class="im">
<div><br></div><div> vtkActor* voxelActor = vtkActor::New();</div><div> voxelActor->SetMapper(voxelMapper);</div><div><br></div></div><div> vtkPolyDataMapper* sphereMapper = vtkPolyDataMapper::New();</div><div>
sphereMapper->SetInputConnection(sphereModel->GetOutputPort());</div>
<div><br></div><div> vtkActor* sphereActor = vtkActor::New();</div><div> sphereActor->SetMapper(sphereMapper);</div><div><br></div><div> //ren1->AddActor(sphereActor);</div><div> ren1->AddActor(voxelActor);</div>
<div><br></div><div> renWin->Render();</div><div> iren->Start();</div><div>}</div><div><br></div><br><div class="gmail_quote">2010/3/10 David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com" target="_blank">daviddoria+vtk@gmail.com</a>></span><div>
<div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div>On Wed, Mar 10, 2010 at 6:12 PM, Daniel Soares <span dir="ltr"><<a href="http://adaptchart.info" target="_blank">adaptchart.info</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I suppose you are saying that I use the following pipeline:<div><br></div><div>vtkSphereSource -> vtkVoxelModeller -> vtkDelaunay3D</div><div><br></div><div>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?</div>
<div><br></div><div>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.</div><div>
<br></div><div>Any ideas?</div><div><br></div><div>Daniel Soares<br></div><div><br></div></blockquote><div class="gmail_quote"><br></div></div>To convert an ImageData to a PointSet, I don't think there is a better way than to do:</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">vtkPolyData* pd = vtkPolyData::New();</div><div class="gmail_quote">for(unsigned int i = 0; i < image->GetNumberOfPoints(); i++</div><div class="gmail_quote">
{</div><div class="gmail_quote"> double p[3];</div><div class="gmail_quote"> image->GetPoint(i, p);</div><div class="gmail_quote"> pd->InsertNextPoint(p);</div><div class="gmail_quote">}</div><div class="gmail_quote">
<br></div><div class="gmail_quote">As for why marching cubes doesn't display anything - maybe you can make the simplest example that will compile - make a sphere source, convert it to an ImageData, then run MarchingCubes. Post this compilable code to the list and we'll check it out.</div>
<div class="gmail_quote"><br clear="all">Thanks,<br><font color="#888888"><br>David</font></div>
</blockquote></div></div></div><br></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>