[vtkusers] Please help about multithread problem on vtkPolyData->CopySctructure method

Peter F Bradshaw pfb at exadios.com
Sun Sep 14 09:38:07 EDT 2008


Hi Hiroshi;

Looking at your program it seems to me that what you essentially want
is a thread safe version of vtkPolyData::CopyStrucuture(). This first
thing I would try is to make CopyStrucuture execute atomically. Using
mutex barriers (vtkMutexLock) should help with this.

What I would do is write a "wrapper" class, in C++,  that is derived
from vtkPolyData and oveloads vtkPolyData::CopyStrucuture(). This
overloading function would manage the barrier setup so that it must
proceed to completion before it came execute again (from another thread).

After the C++ class is written it will be necessary to run it through
VTK's C++ to Tcl conversion method to make it visible to your Tcl
program.

But, depending on your program design, the lack of a thread safe
CopyStrucuture may not be the full extent of your problems.

On Sun, 14 Sep 2008, BAN, Hiroshi wrote:

> Dear VTK developers/users:
>
> Hi, I am now analysing medical image (MRI) data using VTK on 64-bit Sun
> Spark Solaris 10.
> The version of VTK is 3.2 and compiled with multi-thread option for some
> lab's specific reasons.
> I am now facing the problem for this multi-thread option.
>
> By using wrapped Tcl/Tk, I have created unstructured grid data (saved as
> ascii *.vtk file format) from some brain tissue, and now trying to
> overlap them on the 3D anatomical images. However, in the pipeline from
> vtkUnstructuredGridReader to vtkPolyData, the mothod 'CopyStrucuture'
> breaks or miss-copy the target unstructure grid data.
> I recently read in Kitware web site and know that the 'CopyStructure' is
> not thread safe. However, for some specific reason
> of our labs, I can not use a single thread version of VTK.
>
> So, if there are some alternative ways of 'CopyStructure' methods,
> please please teach me.
> I will paste a part of my source code below.
> Thank you for your kindness in advance.
>
> ***** a part of my source code (Tcl/Tk) *****
>
> vtkUnstructuredGridReader ugr   # for reading the brain tissue
> (unstructured grid data)
> vtkPolyDataReader pdr # for converting ugr as poly data
>
> # for standard volume
> set pdfile [lindex $goipd_files $t] # unstructured grid data file name
> pdr SetFileName $pdfile
> pdr Update
>
> vtkPolyData sSOIMesh$t
> sSOIMesh$t CopyStructure [pdr GetOutput]  *** !!! the problem is HERE
> !!! ***
> [sSOIMesh$t GetPointData] PassData [[pdr GetOutput] GetPointData]
>
> ***** a part of my source code (Tcl/Tk) *****
>
> Sincerely,
> Hiroshi Ban
>

Cheers

-- 
Peter F Bradshaw: http://www.exadios.com (public keys avaliable there).
Personal site: http://personal.exadios.com
"I love truth, and the way the government still uses it occasionally to
 keep us guessing." - Sam Kekovich.



More information about the vtkusers mailing list