[vtkusers] Is vtkCutter thread-safe?

Hahn, Steven E. hahnse at ornl.gov
Tue Mar 14 17:08:30 EDT 2017


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> on behalf of Luca Pallozzi Lavorante <lplavorante at gmail.com>
Date: Tuesday, March 14, 2017 at 2:47 PM
To: vtk <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/20170314/7ade5f87/attachment.html>


More information about the vtkusers mailing list