<div class="gmail_quote">---------- Forwarded message ----------<br>From: "Daniel Coelho" <<a href="mailto:1danielcoelho@gmail.com">1danielcoelho@gmail.com</a>><br>Date: Jan 18, 2015 2:03 PM<br>Subject: Re: [vtkusers] Extract isosurfaces from a point cloud polydata with contourfilter<br>To: "Bill Lorensen" <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>Cc: <br><br type="attribution"><p dir="ltr">Thanks for the quick reply! </p>
<p dir="ltr">I use some polydata algorithms on this data, so it wouldn't be efficient to keep switching back and forth all the time. </p>
<p dir="ltr">How could I make my cells then? Would it suffice to make them cubes, where the vertices are the vertices of each cube? I've never really understood how cells work. Even the VTK books don't really help, sadly</p>
<div class="gmail_quote">On Jan 18, 2015 1:47 PM, "Bill Lorensen" <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">VertexGlyphFilter generates vertex  cells. These cells are points. You<br>
cannot contour vertices. You need to create cells that have area or<br>
volume. In your case, it your points are defined on a uniform lattice,<br>
you can create an ImageData that you can contour.<br>
<br>
<br>
On Sun, Jan 18, 2015 at 7:01 AM, Daniel Coelho <<a href="mailto:1danielcoelho@gmail.com" target="_blank">1danielcoelho@gmail.com</a>> wrote:<br>
> Hello everyone!<br>
><br>
> I have a point cloud in the form of a polydata, where I build vertices with<br>
> vtkVertexGlyphFilter.<br>
><br>
> That polydata has pointdata with scalars ranging from 0 to 255, and I'm<br>
> trying to use vtkContourFilter to extract 5 planes, that ideally should cut<br>
> through the data at the values corresponding to each plane.<br>
><br>
> Just to make it clearer: The expected output should be 5 parallel planes,<br>
> equidistant to each other, where each is an isosurface of a certain value,<br>
> with respect to the scalars of the pointcloud.<br>
><br>
> The problem is: I get absolutely no output. No points, no cell, nada. I've<br>
> looked at every example I could find and the mailing list archive, but<br>
> couldn't pinpoint the problem.<br>
><br>
> Here is a short compilable example that shows this problem. You can also see<br>
> outputs from print statements as comments:<br>
> OBS: I use VTK 5.8 for some reasons, this is non-negotiable<br>
><br>
> #include <vtkSmartPointer.h><br>
><br>
> #include <vtkContourFilter.h><br>
><br>
> #include <vtkTypeUInt8Array.h><br>
><br>
> #include <vtkVertexGlyphFilter.h><br>
><br>
> #include <vtkPolyDataMapper.h><br>
><br>
> #include <vtkActor.h><br>
><br>
> #include <vtkRenderer.h><br>
><br>
> #include <vtkRenderWindow.h><br>
><br>
> #include <vtkRenderWindowInteractor.h><br>
><br>
><br>
> #define VTK_NEW(type, instance) \<br>
><br>
>   ;                             \<br>
><br>
>   vtkSmartPointer<type> instance = vtkSmartPointer<type>::New();<br>
><br>
><br>
> int main(int argc, char *argv[]) {<br>
><br>
><br>
>   VTK_NEW(vtkPoints, points);<br>
><br>
>   points->Allocate(100 * 100 * 100);<br>
><br>
><br>
>   VTK_NEW(vtkTypeUInt8Array, data_array);<br>
><br>
>   data_array->Allocate(100 * 100 * 100);<br>
><br>
><br>
>   for (int x = 0; x < 100; x++) {<br>
><br>
>     for (int y = 0; y < 100; ++y) {<br>
><br>
>       for (int z = 0; z < 100; ++z) {<br>
><br>
>         points->InsertNextPoint(x, y, z);<br>
><br>
>         data_array->InsertNextValue(z % 256);<br>
><br>
>       }<br>
><br>
>     }<br>
><br>
>   }<br>
><br>
><br>
>   VTK_NEW(vtkPolyData, polydata);<br>
><br>
>   polydata->SetPoints(points);<br>
><br>
>   polydata->GetPointData()->SetScalars(data_array);<br>
><br>
><br>
>   VTK_NEW(vtkVertexGlyphFilter, glyph_filter);<br>
><br>
>   glyph_filter->SetInput(polydata);<br>
><br>
>   glyph_filter->Update();<br>
><br>
>   glyph_filter->GetOutput()->Print(std::cout << "Glyph filter: \n");<br>
><br>
>   //Output here:<br>
><br>
>   //Number Of Points: 1000000<br>
><br>
>   //Number Of Cells: 1000000<br>
><br>
>   //Bounds look good, all good<br>
><br>
><br>
>   VTK_NEW(vtkContourFilter, cont_filt);<br>
><br>
>   cont_filt->SetInputConnection(glyph_filter->GetOutputPort());<br>
><br>
>   double scalarRange[2];<br>
><br>
>   polydata->GetPointData()->GetScalars()->GetRange(scalarRange);<br>
><br>
>   cont_filt->GenerateValues(5, scalarRange[0], scalarRange[1]);<br>
><br>
>   cont_filt->Update();<br>
><br>
><br>
>   // Print the contours<br>
><br>
>   int num_contours = cont_filt->GetNumberOfContours();<br>
><br>
>   double cont_values[num_contours];<br>
><br>
>   cont_filt->GetValues(cont_values);<br>
><br>
>   std::cout << "Contours: ";<br>
><br>
>   for (int var = 0; var < num_contours; ++var) {<br>
><br>
>     std::cout << cont_values[var] << " ";<br>
><br>
>   }<br>
><br>
>   std::cout << std::endl;<br>
><br>
>   //Output here:<br>
><br>
>   //Contours: 0 24.75 49.5 74.25 99<br>
><br>
><br>
>   cont_filt->GetOutput()->Print(std::cout << "Contour filter: \n");<br>
><br>
>   //Output here:<br>
><br>
>   //No points, no cells, default bounds, no nothing<br>
><br>
><br>
>   VTK_NEW(vtkPolyDataMapper, mapper);<br>
><br>
>   mapper->SetInputConnection(cont_filt->GetOutputPort());<br>
><br>
>   mapper->SetScalarVisibility(1);<br>
><br>
><br>
>   VTK_NEW(vtkActor, actor);<br>
><br>
>   actor->SetMapper(mapper);<br>
><br>
><br>
>   VTK_NEW(vtkRenderer, renderer);<br>
><br>
>   renderer->AddActor(actor);<br>
><br>
><br>
>   VTK_NEW(vtkRenderWindow, render_window)<br>
><br>
>   render_window->AddRenderer(renderer);<br>
><br>
>   render_window->SetSize(600, 600);<br>
><br>
><br>
>   VTK_NEW(vtkRenderWindowInteractor, interactor);<br>
><br>
>   interactor->SetRenderWindow(render_window);<br>
><br>
><br>
>   renderer->ResetCamera();<br>
><br>
>   render_window->Render();<br>
><br>
>   interactor->Start();<br>
><br>
> }<br>
><br>
><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<br>
> <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:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
><br>
<br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
</blockquote></div>
</div>