17 #include "itkBarrier.h"
26 #include <itkMultiThreader.h>
27 #include <itksys/SystemTools.hxx>
45 struct itk::MultiThreader::ThreadInfoStruct *pInfo = (
struct itk::MultiThreader::ThreadInfoStruct *)data;
50 return ITK_THREAD_RETURN_VALUE;
52 if (pInfo->UserData == NULL)
54 return ITK_THREAD_RETURN_VALUE;
58 ThreadData *threadData = (ThreadData *)pInfo->UserData;
60 srand(pInfo->ThreadID);
64 int nrSlices = im->GetDimension(2);
80 if ((im->GetPixelType().GetComponentTypeAsString() ==
"short") && (im->GetDimension() == 3))
84 int xlength = im->GetDimension(0);
85 int ylength = im->GetDimension(1);
90 for (
int i = 0; i < xlength; ++i)
92 for (
int j = 0; j < ylength; ++j)
116 if ((im->GetPixelType().GetComponentTypeAsString() ==
"short") && (im->GetDimension() == 3))
120 int xlength = im->GetDimension(0);
121 int ylength = im->GetDimension(1);
126 for (
int i = 0; i < xlength; ++i)
128 for (
int j = 0; j < ylength; ++j)
132 short newVal = rand() % 16000;
137 threadData->m_Successful =
false;
147 *((
char *)pointer) = 0;
153 threadData->m_Successful =
false;
158 threadData->m_Successful =
false;
163 threadData->m_Barrier->Wait();
164 return ITK_THREAD_RETURN_VALUE;
171 std::cout <<
"Loading file: ";
174 std::cout <<
"no file specified [FAILED]" << std::endl;
187 catch (itk::ExceptionObject &ex)
195 MITK_TEST_OUTPUT(<<
"Testing a recursive mutex lock attempt, should end in an exception ...");
216 image->GetGeometry()->Initialize();
219 unsigned int noOfThreads = 100;
223 barrier->Initialize(noOfThreads + 1);
225 ThreadData *threadData =
new ThreadData;
226 threadData->m_Barrier = barrier;
227 threadData->m_NoOfThreads = noOfThreads;
228 threadData->data = image;
229 threadData->m_Successful =
true;
232 for (
unsigned int i = 0; i < noOfThreads; ++i)
240 for (
unsigned int j = 0; j < noOfThreads; ++j)
242 threader->TerminateThread(j);
245 bool TestSuccessful = threadData->m_Successful;
Gives locked and index-based write access for a particular image part. The class provides several set...
itk::SimpleFastMutexLock testMutex
itk::SmartPointer< Self > Pointer
const TPixel & GetPixelByIndexSafe(const itk::Index< VDimension > &idx) const
#define MITK_TEST_FOR_EXCEPTION_END(EXCEPTIONCLASS)
Gives locked and index-based read access for a particular image part. The class provides several set-...
const TPixel & GetPixelByIndexSafe(const itk::Index< VDimension > &idx) const
void SetPixelByIndexSafe(const itk::Index< VDimension > &idx, const TPixel &value)
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
ITK_THREAD_RETURN_TYPE ThreadMethod(void *data)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
void * GetData()
Gives full data access.
#define MITK_TEST_OUTPUT(x)
Output some text.
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
#define MITK_TEST_FAILED_MSG(MSG)
Fail and finish test with message MSG.
#define MITK_TEST_FOR_EXCEPTION_BEGIN(EXCEPTIONCLASS)
Begin block which should be checked for exceptions.
int mitkImageAccessorTest(int argc, char *argv[])
ImageWriteAccessor class to get locked write-access for a particular image part.
Internal class for managing references on sub-images.
ImageReadAccessor class to get locked read access for a particular image part.
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.