[vtkusers] Is vtkCutter thread-safe?

Hahn, Steven E. hahnse at ornl.gov
Wed Mar 15 08:46:41 EDT 2017


?Luca,


Yes, ParaView's vtkThreeSliceFilter does multiple cuts in different threads.


https://gitlab.kitware.com/paraview/paraview/merge_requests/1273

Steven

________________________________
From: Luca Pallozzi Lavorante <lplavorante at gmail.com>
Sent: Wednesday, March 15, 2017 7:41 AM
To: Hahn, Steven E.
Cc: vtk
Subject: Re: [vtkusers] Is vtkCutter thread-safe?

Hi Steven, thank you for your reply.
I am using VTK 7.0. Are you using vtkCutter in different threads with the same input data? This is my case.

     Thank you

        Luca

On Tue, Mar 14, 2017 at 6:08 PM, Hahn, Steven E. <hahnse at ornl.gov<mailto:hahnse at ornl.gov>> wrote:
Hi Luca,

Are you using master? Last week I added a merge request making vtkCutter thread-safe.

https://gitlab.kitware.com/vtk/vtk/merge_requests/2541

Steven

From: vtkusers <vtkusers-bounces at vtk.org<mailto:vtkusers-bounces at vtk.org>> on behalf of Luca Pallozzi Lavorante <lplavorante at gmail.com<mailto:lplavorante at gmail.com>>
Date: Tuesday, March 14, 2017 at 2:47 PM
To: vtk <vtkusers at vtk.org<mailto:vtkusers at vtk.org>>
Subject: [vtkusers] Is vtkCutter thread-safe?

Hi vtkusers,
I have tried to generate N slices from a vtkUnstructuredGrid using vtkCutter and OpenMP. The code I used is below. slicePosition and sliceNormals are arrays of planes' positions and normals, whereas polys is an array of vtkPolyData used to store each cut for a later append operation using vtkAppendPolyData.

#pragma omp parallel for
    for (size_t i = 0; i < numSlices; ++i) {
        vtkSmartPointer<vtkPlane> slice = vtkSmartPointer<vtkPlane>::New();
        slice->SetOrigin(slicePosition[i].x(), slicePosition[i].y(), slicePosition[i].z());
        slice->SetNormal(sliceNormal[i].x(), sliceNormal[i].y(), sliceNormal[i].z());
        slice->Modified();

        vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
        cutter->SetInputData(m_data);
        cutter->GenerateTrianglesOff();
        cutter->ReleaseDataFlagOn();
        cutter->SetCutFunction(slice);
        cutter->Update();

        vtkSmartPointer<vtkPolyData> poly =  vtkSmartPointer<vtkPolyData>::New();
        poly->DeepCopy(cutter->GetOutput());
        poly->Modified();
        polys[i] = poly;
    }

This code generates segmentation faults and I would like to know whether it is safe to create and deal with a different instance of vtkCutter in different threads, as I am trying to do with the macro '#pragma omp parallel for'. What I am trying to do is to slice my dataset using a set of parallel planes.

Thank you in advance for any help.
       Luca Pallozzi Lavorante


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170315/8ab9cbe5/attachment.html>


More information about the vtkusers mailing list