1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "gdcmElement.h"
#include "gdcmVR.h"
#include <sstream>
int TestLO()
{
gdcm::Element<gdcm::VR::LO, gdcm::VM::VM1_n> el;
const char str[] = "WINDOW1\\WINDOW2\\WINDOW3";
const size_t lenstr = strlen(str);
std::stringstream ss;
ss.str( str );
size_t count = gdcm::VM::GetNumberOfElementsFromArray(str, lenstr);
gdcm::VR vr = gdcm::VR::LO;
//gdcm::VM vm = gdcm::VM::VM2;
//gdcm::VR vr = gdcm::VR::DS;
//if( len != vr.GetSizeof() * vm.GetLength() )
// {
// return 1;
// }
el.SetLength( count * vr.GetSizeof() );
el.Read( ss );
std::cout << el.GetLength() << std::endl;
std::cout << el.GetValue(0) << std::endl;
std::cout << el.GetValue(1) << std::endl;
return 1;
}
int TestElement5(int , char *[])
{
gdcm::Element<gdcm::VR::DS, gdcm::VM::VM1_n> spacing;
const char strspacing[] = "1.2345\\6.7890";
std::stringstream ss;
ss.str( strspacing );
unsigned int len = 2 * sizeof(double);
gdcm::VM vm = gdcm::VM::VM2;
gdcm::VR vr = gdcm::VR::DS;
if( len != vr.GetSizeof() * vm.GetLength() )
{
return 1;
}
spacing.SetLength( len );
spacing.Read( ss );
std::cout << spacing.GetValue() << std::endl;
std::cout << spacing.GetValue(1) << std::endl;
//int res =
TestLO();
return 0;
}
|