Program: gdcm
Module: $RCSfile: gdcmSegmentedPalette.h,v $
Language: C++
- Date: $Date: 2007/10/03 12:02:55 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2007/10/08 15:20:17 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// * replace all dcmtk code with equivalent gdcm code
// * Add extra parameter to ReadPaletteInto to save extracted info
+// MM: Over 50000 DICOM files I only found two that had a Segmented Palette LUT
+// And both were coming from a ALOKA SSD-4000 station
#include <assert.h>
#include <algorithm>
#include <deque>
#include <vector>
#include <iterator>
+// Hack for VS6
+#if defined(_MSC_VER) && (_MSC_VER < 1310)
+#define GDCM_TYPENAME class
+#else
+#define GDCM_TYPENAME typename
+#endif
+
namespace GDCM_NAME_SPACE
{
// abstract class for segment.
- template <typename EntryType>
+ template <GDCM_TYPENAME EntryType>
class Segment {
public:
typedef std::map<const EntryType*, const Segment*> SegmentMap;
};
// discrete segment (opcode = 0)
- template <typename EntryType>
+ template <GDCM_TYPENAME EntryType>
class DiscreteSegment : public Segment<EntryType> {
public:
typedef typename Segment<EntryType>::SegmentMap SegmentMap;
};
// linear segment (opcode = 1)
- template <typename EntryType>
+ template <GDCM_TYPENAME EntryType>
class LinearSegment : public Segment<EntryType> {
public:
typedef typename Segment<EntryType>::SegmentMap SegmentMap;
};
// indirect segment (opcode = 2)
- template <typename EntryType>
+ template <GDCM_TYPENAME EntryType>
class IndirectSegment : public Segment<EntryType> {
public:
typedef typename Segment<EntryType>::SegmentMap SegmentMap;
}
};
- template <typename EntryType>
+ template <GDCM_TYPENAME EntryType>
void ExpandPalette(const EntryType* raw_values, uint32_t length,
std::vector<EntryType>& palette)
{
//DcmElement* pe = NULL;
GDCM_NAME_SPACE::DataEntry* pe = NULL;
- pe = pds->GetDataEntry(segment.GetGroup(), segment.GetElement() ); {
+ pe = pds->GetDataEntry(segment.GetGroup(), segment.GetElement() );
+ {
//if ( pds->findAndGetElement(segment, pe).good() )
unsigned long length = pe->GetLength();
- if ( entry_size == 8 ) {
+ if ( entry_size == 8 )
+ {
uint8_t* segment_values = NULL;
//if ( pe->getUint8Array(segment_values).good() )
- segment_values = (uint8_t*)pe->GetBinArea(); {
+ segment_values = (uint8_t*)pe->GetBinArea();
+ {
std::vector<uint8_t> palette;
palette.reserve(num_entries);
ExpandPalette(segment_values, length, palette);
memcpy(lut, &palette[0], palette.size() );
- }
- } else if ( entry_size == 16 ) {
+ }
+ }
+ else if ( entry_size == 16 )
+ {
uint16_t* segment_values = NULL;
- segment_values = (uint16_t*)pe->GetBinArea(); {
+ segment_values = (uint16_t*)pe->GetBinArea();
+ {
//if ( pe->getUint16Array(segment_values).good() )
std::vector<uint16_t> palette;
palette.reserve(num_entries);
ExpandPalette(segment_values, length, palette);
memcpy(lut, &palette[0], palette.size()*2 );
-// std::copy(palette.begin(), palette.end(),
-// std::ostream_iterator<uint16_t>(std::cout, "\n"));
+ }
}
}
}
- }
}
} // end namespace gdcm
+// do not pollute namespace:
+#undef GDCM_TYPENAME
+
#endif