[vtkusers] streaming vtkMarchingCubes?

Bill Lorensen bill.lorensen at gmail.com
Wed Jul 29 12:26:18 EDT 2009


Also, try removing all of these:
 // all below is (being continuously) called from a separate function
       // FIXME why is this required???
       vtkSmartPointer<vtkStructuredPoints> image2 =
(vtkStructuredPoints*)calculator->GetOutput();
       image2->SetScalarTypeToFloat();

       ismooth->SetInput(image2);
       ismooth->SetRadiusFactors(radius,radius,radius);
       ismooth->SetStandardDeviations(sigma,sigma,sigma);

       vtkNew(vtkXMLImageDataWriter,writer);
       writer->SetInput(ismooth->GetOutput());
       writer->SetFileName("test_smooth.vti");
       writer->Write();

       cubes->Update();
       cubes->UpdateWholeExtent();

On Wed, Jul 29, 2009 at 12:23 PM, Bill Lorensen<bill.lorensen at gmail.com> wrote:
> I can't explain it.
>
> BTW, what contour value do you set.
>
> On Wed, Jul 29, 2009 at 12:06 PM, Dominik Szczerba<dominik at itis.ethz.ch> wrote:
>> I do set the contour value in my code, only forgot to add the line to the
>> cited code.
>>
>> Removing Update and UpdateWholeExtent makes no difference.
>>
>> So you are suggesting that by some reason I keep appending the outputs.
>> Well, first off, I run it only once. But even if that may be not true by
>> some bug, how will you explain that on the other PC this does not happen and
>> I get one connected surface mesh?
>>
>> -- Dominik
>>
>>
>> Bill Lorensen wrote:
>>>
>>> The test_cubes.vtk looks like it is the output of 2 marching cubes
>>> runs that have been appended. Now I understand why you asked if
>>> MarchingCubes streamed? This is what you would expect if you ran it
>>> twice and appended the results.
>>>
>>> Try removing both the
>>> cubes->Update();
>>> and
>>> cubes->UpdateWholeExtent();
>>>
>>> On Wed, Jul 29, 2009 at 9:13 AM, Dominik Szczerba<dominik at itis.ethz.ch>
>>> wrote:
>>>>
>>>> The files are here:
>>>>
>>>> http://otoro.itis.ethz.ch/~dominik/tmp/test_smooth.vti
>>>> http://otoro.itis.ethz.ch/~dominik/tmp/test_cubes.vtk
>>>>
>>>> The pipeline is:
>>>>
>>>>       // setup (in a constructor)
>>>>       extractVOI = vtkSmartPointer<vtkExtractVOI>::New();
>>>>       extractVOI->SetInput(viewer->image);
>>>>
>>>>       calculator = vtkSmartPointer<vtkArrayCalculator>::New();
>>>>       calculator->SetInputConnection(extractVOI->GetOutputPort());
>>>>       calculator->SetResultArrayType(VTK_FLOAT);
>>>>
>>>>       ismooth = vtkSmartPointer<vtkImageGaussianSmooth>::New();
>>>>       ismooth->SetInputConnection(calculator->GetOutputPort());
>>>>       ismooth->BreakOnError();
>>>>       ismooth->SetDimensionality(3);
>>>>
>>>>       cubes = vtkSmartPointer<vtkMarchingCubes>::New();
>>>>       cubes->SetInputConnection(ismooth->GetOutputPort());
>>>>       cubes->SetNumberOfContours(1);
>>>>       cubes->SetComputeNormals(0);
>>>>       cubes->SetComputeGradients(0);
>>>>       cubes->SetComputeScalars(0);
>>>>
>>>>       // all below is (being continuously) called from a separate
>>>> function
>>>>       // FIXME why is this required???
>>>>       vtkSmartPointer<vtkStructuredPoints> image2 =
>>>> (vtkStructuredPoints*)calculator->GetOutput();
>>>>       image2->SetScalarTypeToFloat();
>>>>
>>>>       ismooth->SetInput(image2);
>>>>       ismooth->SetRadiusFactors(radius,radius,radius);
>>>>       ismooth->SetStandardDeviations(sigma,sigma,sigma);
>>>>
>>>>       vtkNew(vtkXMLImageDataWriter,writer);
>>>>       writer->SetInput(ismooth->GetOutput());
>>>>       writer->SetFileName("test_smooth.vti");
>>>>       writer->Write();
>>>>
>>>>       cubes->Update();
>>>>       cubes->UpdateWholeExtent();
>>>>
>>>>       vtkNew(vtkPolyDataWriter,poly_writer);
>>>>       poly_writer->SetInput(cubes->GetOutput());
>>>>       poly_writer->SetFileName("test_cubes.vtk");
>>>>       poly_writer->SetFileTypeToBinary();
>>>>       poly_writer->Write();
>>>>
>>>>
>>>> There is a small dirty part that I do not like (FIXME, otherwise the
>>>> output
>>>> type is somehow unsigned char) but otherwise it is rather simple and
>>>> clean.
>>>>
>>>> Looking forward some ideas about the origin of the degenerate points -
>>>> and
>>>> once again, only on one system and not the other.
>>>>
>>>> With regards,
>>>> Dominik
>>>>
>>>> Bill Lorensen wrote:
>>>>>
>>>>> MarchingCubes does not stream. Also, internally it uses vtkMergePoints
>>>>> to make sure that duplicate points are removed. I don't see how memory
>>>>> size should affect the results.
>>>>>
>>>>> What version of VTK are you using?
>>>>>
>>>>> Also, can you put the data online somewhere?
>>>>>
>>>>> Bill
>>>>>
>>>>> On Wed, Jul 29, 2009 at 3:27 AM, Dominik Szczerba<dominik at itis.ethz.ch>
>>>>> wrote:
>>>>>>
>>>>>> I am doing nothing particular, just a structured points dataset with a
>>>>>> smooth scalar field (float) that I am running vtkMarchingCubes on. I
>>>>>> get
>>>>>> my
>>>>>> polydata as cubes->GetOutput(). As mentioned, I dont know if that
>>>>>> matters
>>>>>> but the problem appears on a low mem PC and not on a bigger one (same
>>>>>> code
>>>>>> but different systems). If you strongly believe there is something
>>>>>> special
>>>>>> in my image data I can put it online for a test.
>>>>>>
>>>>>> I can not follow the vtkMarchingCubes code well enough to clearly tell
>>>>>> if
>>>>>> there is some streaming being done - looks to me like not, but where do
>>>>>> the
>>>>>> degenerate points come from?
>>>>>>
>>>>>> An interesting observation though, if I save the resulting polydata
>>>>>> using
>>>>>> vtkPolyDataWriter I get the file you saw. If I save it with the vtkSTL
>>>>>> writer I get a clean dataset, so the latter must merge coincident
>>>>>> points
>>>>>> internally (why? - this removes the chance of finding errors)
>>>>>>
>>>>>> best regards,
>>>>>> Dominik
>>>>>>
>>>>>> Bill Lorensen wrote:
>>>>>>>
>>>>>>> I looked at the vtk file and indeed it has multiple surfaces. How did
>>>>>>> you generate this polydata? Can you tell me the pipeline you used?
>>>>>>>
>>>>>>> On Sun, Jul 26, 2009 at 1:29 PM, Dominik
>>>>>>> Szczerba<dominik at itis.ethz.ch>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> On Sun, 2009-07-26 at 12:35 -0400, Bill Lorensen wrote:
>>>>>>>>>
>>>>>>>>> I am surprised at this. vtkMarchingCubes should produce manifold and
>>>>>>>>> oriented surfaces. There should be no duplicate points.
>>>>>>>>> vtkMarchingCubes can produce multiple, topologically disconnected
>>>>>>>>> surfaces. vtkDiscreteMarchingCubes can (and should) produce
>>>>>>>>> geometrically continuous but topologically disconnected surafces.
>>>>>>>>>
>>>>>>>>> Can you provide a test dataset that reproduces the problem?
>>>>>>>>>
>>>>>>>> I hanged a small sample on:
>>>>>>>>
>>>>>>>> http://otoro.itis.ethz.ch/~dominik/tmp/test.vtk
>>>>>>>>
>>>>>>>> I got this while segmenting a smooth scalar field on a (Windows
>>>>>>>> virtual)
>>>>>>>> machine with very little memory. I do not get this on a (linux real)
>>>>>>>> machine with lots of memory.
>>>>>>>>
>>>>>>>> Running connectivity filter you will notice a few disconnected
>>>>>>>> regions.
>>>>>>>> It goes away after merging coincident points (and the number of
>>>>>>>> points
>>>>>>>> is reduced indicating degenerate original points).
>>>>>>>>
>>>>>>>> I just need to get a warning when the output is in such condition to
>>>>>>>> not
>>>>>>>> have to merge points by default, which degrades performance.
>>>>>>>>
>>>>>>>> -- Dominik
>>>>>>>>
>>>>>>>>> Bill
>>>>>>>>>
>>>>>>>>> On Sun, Jul 26, 2009 at 8:27 AM, Dominik
>>>>>>>>> Szczerba<dominik at itis.ethz.ch>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> I have experimentally found out that vtkMarchingCubes can generate
>>>>>>>>>> geometrically continuous but topologically disconnected
>>>>>>>>>> isosurfaces,
>>>>>>>>>> i.e. the isosurface is cut into stripes along one axis with
>>>>>>>>>> duplicate
>>>>>>>>>> points on the edges. How do I get a control of this behavior,
>>>>>>>>>> especially, to know if there will be disconnected stripes so I
>>>>>>>>>> should
>>>>>>>>>> merge the points (I need topological consistency)?
>>>>>>>>>>
>>>>>>>>>> -- Dominik
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> 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
>>>>>>>>>>
>>>>>> --
>>>>>> d o m i n i k   s z c z e r b a ,   p h d . . . . . . . . . . .
>>>>>> c o m p u t a t i o n a l   l i f e   s c i e n c e   g r o u p
>>>>>> . . . . . . . i t ' i s   r e s e a r c h   f o u n d a t i o n
>>>>>> . . . . . . . . . . . . . . . . . . . . http://www.itis.ethz.ch
>>>>>>
>>>>>>
>>>>
>>>> --
>>>> d o m i n i k   s z c z e r b a ,   p h d . . . . . . . . . . .
>>>> c o m p u t a t i o n a l   l i f e   s c i e n c e   g r o u p
>>>> . . . . . . . i t ' i s   r e s e a r c h   f o u n d a t i o n
>>>> . . . . . . . . . . . . . . . . . . . . http://www.itis.ethz.ch
>>>>
>>>>
>>>
>>
>>
>> --
>> d o m i n i k   s z c z e r b a ,   p h d . . . . . . . . . . .
>> c o m p u t a t i o n a l   l i f e   s c i e n c e   g r o u p
>> . . . . . . . i t ' i s   r e s e a r c h   f o u n d a t i o n
>> . . . . . . . . . . . . . . . . . . . . http://www.itis.ethz.ch
>>
>>
>



More information about the vtkusers mailing list