7 #include "fwTest/generator/Image.hpp" 9 #include <fwDataTools/helper/Array.hpp> 11 #include <fwTools/NumericRoundCast.hxx> 12 #include <fwTools/Type.hpp> 26 std::srand(::fwTools::numericRoundCast< unsigned int >(std::time(NULL)));
33 std::vector<double> spacing,
34 std::vector<double> origin,
37 image->setSpacing(spacing);
38 image->setOrigin(origin);
44 ::fwData::Array::sptr array = image->getDataArray();
46 std::fill(helper.
begin(), helper.end(), 0);
56 size[0] = rand()%100 + 2;
57 size[1] = rand()%100 + 2;
58 size[2] = rand()%100 + 2;
61 std::vector< double > spacing(3);
62 spacing[0] = (rand()%200 +1) / 100.;
63 spacing[1] = (rand()%200 +1) / 100.;
64 spacing[2] = (rand()%200 +1) / 100.;
65 image->setSpacing(spacing);
67 std::vector< double > origin(3);
68 origin[0] = (rand()%200 - 100) / 10.;
69 origin[1] = (rand()%200 - 100) / 10.;
70 origin[2] = (rand()%200 - 100) / 10.;
71 image->setOrigin(origin);
75 ::fwData::Array::sptr array = image->getDataArray();
78 image->setWindowWidth( (rand()%200) / 10. + 1);
79 image->setWindowCenter((rand()%200 - 100) / 10.);
87 char* iter = helper.
begin<
char >();
89 for (; iter != helper.end<
char >(); ++iter)
99 ::fwData::Array::sptr array = ::fwData::Array::New();
101 array->resize( ::fwTools::Type::create(type), sizes, 1,
true );
std::vector< size_t > SizeType
Array size type.
static FWTEST_API void generateRandomImage(::fwData::Image::sptr image,::fwTools::Type type)
Generate an image with random information (size, spacing, ...). Buffer is filled with random values...
static FWTEST_API void randomizeArray(::fwData::Array::sptr array)
Fill array with random value.
static FWTEST_API void initRand()
Initialize 'rand' seed.
static FWTEST_API void generateImage(::fwData::Image::sptr image,::fwData::Image::SizeType size, std::vector< double > spacing, std::vector< double > origin,::fwTools::Type type)
Generate an image with the given informations. Buffer is filled with 0.
static FWTEST_API::fwData::Array::sptr createRandomizedArray(const std::string &type,::fwData::Array::SizeType sizes)
Creates an Array with the given type and size and fills buffer with random values.
::fwData::Array::SizeType SizeType
Image size type.