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 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/*=========================================================================
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 "gdcmItem.h"
//#include "gdcmStringStream.h"
#include "gdcmVR.h"
#include "gdcmExplicitDataElement.h"
#include "gdcmSwapper.h"
void CreateDataElement(gdcm::ExplicitDataElement &de, int offset)
{
std::stringstream ss;
gdcm::Tag tag(0x1234, (uint16_t)(0x5678+offset));
gdcm::VR vr = gdcm::VR::UN;
const char str[] = "GDCM";
uint32_t len = (uint32_t)strlen(str);
assert( sizeof(uint32_t) == 4 );
gdcm::ByteValue val(str, len);
tag.Write<gdcm::SwapperNoOp>(ss);
vr.Write(ss);
const char *slen = reinterpret_cast<char*>(&len);
ss.write( slen, 4);
val.Write<gdcm::SwapperNoOp>(ss);
#ifdef GDCM_WORDS_BIGENDIAN
de.Read<gdcm::SwapperDoOp>( ss );
#else
de.Read<gdcm::SwapperNoOp>( ss );
#endif
std::cout << de << std::endl;
}
int TestItem(int , char *[])
{
gdcm::Item item;
std::cout << item << std::endl;
gdcm::Item it1;
gdcm::Item it2;
gdcm::DataSet ds;
gdcm::ExplicitDataElement xde;
CreateDataElement(xde,0);
ds.Insert( xde );
CreateDataElement(xde,1);
ds.Insert( xde );
CreateDataElement(xde,2);
ds.Insert( xde );
CreateDataElement(xde,3);
ds.Insert( xde );
std::cout << ds << std::endl;
// undefined by default:
gdcm::Item it3;
gdcm::VL vl = it3.GetVL();
if( !vl.IsUndefined() )
{
return 1;
}
if( !it3.IsUndefinedLength() )
{
return 1;
}
return 0;
}
|