<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span>Thanks David!</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>This seems to solve the crash.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>Maarten<br></span></div> <div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div
style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Tuesday, May 27, 2014 4:57:25 PM, David Gobbi <david.gobbi@gmail.com> wrote:<br> </font> </div> <br><br> <div class="y_msg_container">Calling GetRange() can actually cause the range to be computed (i.e.<br clear="none">iterating over all elements in the array), so it's generally not a<br clear="none">good thing to call from the multi-threaded part of your image filter.<br clear="none">As for whether it is thread safe, I've looked at the code, and I would<br clear="none">say "no, it's not".<br clear="none"><br clear="none">The documentation for vtkDataSet::GetScalarRange(double range[2])<br clear="none">gives a bit more info:<br clear="none"><br clear="none"> //
THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND<br clear="none"> // THE DATASET IS NOT MODIFIED<br clear="none"> virtual void GetScalarRange(double range[2]);<br clear="none"><br clear="none">The above advice applies to GetRange() as well: if you call GetRange()<br clear="none">once before you split the threads, then it's fine to call it again<br clear="none">after you split the threads, because there is a timestamp to make sure<br clear="none">that the internal ComputerRange() code will not be re-executed.<br clear="none"><br clear="none"> - David<br clear="none"><br clear="none"><br clear="none"><div class="yqt2361938923" id="yqtfd07820"><br clear="none">On Tue, May 27, 2014 at 2:31 PM, Maarten Beek <<a shape="rect" ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>> wrote:<br clear="none">> Hi all,<br clear="none">><br clear="none">> I have been
struggling with the following:<br clear="none">><br clear="none">> I have derived an image algorithm form vtkThreadedImageAlgorithm in which I<br clear="none">> need to know the range of the scalars of the input image.<br clear="none">><br clear="none">> inData->GetPointData()->GetScalars()->GetRange(rng);<br clear="none">> inData->GetPointData()->GetScalars()->GetInformation()->Get(vtkDataArray::COMPONENT_RANGE(),<br clear="none">> rng));<br clear="none">> both crash in the template execute function (I used vtkImageHSVToRGB as<br clear="none">> example).<br clear="none">> The crash only seems to be happening in Release build.<br clear="none">><br clear="none">> When I use SetNumberOfThreads(1), the algorithm works fine.<br clear="none">> When I hard-code the range (double rng[2] = { 0.0, 808000}; ), the algorithm<br clear="none">> works fine.<br clear="none">><br clear="none">> Is
GetRange() not thread-safe? Should I get the range from the input before<br clear="none">> it is spread across threads?<br clear="none">><br clear="none">> Thanks - Maarten<br clear="none"></div><br><br></div> </div> </div> </div> </div></body></html>