]> Creatis software - gdcm.git/blobdiff - src/gdcmSegmentedPalette.h
COMP: Fix a bunch of warnings. Try to get template to compile on the pseudo VS6 so...
[gdcm.git] / src / gdcmSegmentedPalette.h
index b25f8010b1c17893001a0e8a54aaeff56c6196c9..2f2c57c99d9045c92f2eb58e03898207ba52c38c 100644 (file)
@@ -3,8 +3,8 @@
   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
@@ -32,6 +32,8 @@
 // * 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;
@@ -67,7 +76,7 @@ namespace GDCM_NAME_SPACE
     };
 
     // discrete segment (opcode = 0)
-    template <typename EntryType>
+    template <GDCM_TYPENAME EntryType>
     class DiscreteSegment : public Segment<EntryType> {
     public:
         typedef typename Segment<EntryType>::SegmentMap SegmentMap;
@@ -82,7 +91,7 @@ namespace GDCM_NAME_SPACE
     };
 
     // linear segment (opcode = 1)
-    template <typename EntryType>
+    template <GDCM_TYPENAME EntryType>
     class LinearSegment : public Segment<EntryType> {
     public:
         typedef typename Segment<EntryType>::SegmentMap SegmentMap;
@@ -111,7 +120,7 @@ namespace GDCM_NAME_SPACE
     };
 
     // indirect segment (opcode = 2)
-    template <typename EntryType>
+    template <GDCM_TYPENAME EntryType>
     class IndirectSegment : public Segment<EntryType> {
     public:
         typedef typename Segment<EntryType>::SegmentMap SegmentMap;
@@ -147,7 +156,7 @@ namespace GDCM_NAME_SPACE
         }
     };
 
-    template <typename EntryType>
+    template <GDCM_TYPENAME EntryType>
     void ExpandPalette(const EntryType* raw_values, uint32_t length,
         std::vector<EntryType>& palette)
     {
@@ -206,35 +215,42 @@ namespace GDCM_NAME_SPACE
         //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