]> Creatis software - gdcm.git/blobdiff - src/gdcmFile.cxx
* vtk/vtkGdcmReader[cxx|h] : makes correct code to remove conflicts
[gdcm.git] / src / gdcmFile.cxx
index 6c7914199d447796edfb0af4e1d31e4e2a94bd76..2b09d36d2aadcc76671dde736a5fadac633d794f 100644 (file)
@@ -3,6 +3,7 @@
 #include "gdcmFile.h"
 #include "gdcmUtil.h"
 #include "iddcmjpeg.h"
+using namespace std;
 
 /////////////////////////////////////////////////////////////////
 /**
@@ -34,8 +35,6 @@ gdcmFile::gdcmFile(const char * filename)
    SetPixelDataSizeFromHeader();
 }
 
-
-/////////////////////////////////////////////////////////////////
 /**
  * \ingroup   gdcmFile
  * \brief     calcule la longueur (in bytes) A ALLOUER pour recevoir les
@@ -46,7 +45,6 @@ gdcmFile::gdcmFile(const char * filename)
  *
  * @return     longueur a allouer 
  */
-
 void gdcmFile::SetPixelDataSizeFromHeader(void) {
    int nb;
    string str_nb;
@@ -63,13 +61,14 @@ void gdcmFile::SetPixelDataSizeFromHeader(void) {
 
 /**
  * \ingroup   gdcmFile
- * \brief     Accessor
+ * \brief     Returns the size (in bytes) of required memory to hold
+ *            the pixel data represented in this file.
+ * @return    The size of pixel data in bytes.
  */
 size_t gdcmFile::GetImageDataSize(void) {
    return (lgrTotale);
 }
 
-
 /**
  * \ingroup gdcmFile
  * \brief   Read pixel data from disk (optionaly decompressing) into the
@@ -91,15 +90,15 @@ bool gdcmFile::ReadPixelData(void* destination) {
         IsExplicitVRLittleEndianTransferSyntax() ||
         IsExplicitVRBigEndianTransferSyntax()    ||
         IsDeflatedExplicitVRLittleEndianTransferSyntax() ) { 
-             
-         size_t ItemRead = fread(destination, lgrTotale, 1, fp);
-         if ( ItemRead != 1 ) {
-            CloseFile();
-            return false;
-         } else {
-            CloseFile();
-            return true;
-         }
+                    
+      size_t ItemRead = fread(destination, lgrTotale, 1, fp);
+      if ( ItemRead != 1 ) {
+         CloseFile();
+         return false;
+      } else {
+         CloseFile();
+         return true;
+      }
    }
          
    if (IsJPEGLossless()) {
@@ -127,20 +126,19 @@ bool gdcmFile::ReadPixelData(void* destination) {
       _IdDcmJpegFree (jpg);
       CloseFile();
       return true;
-   }     
-
+   }
+   
     printf ("Sorry, TransfertSyntax not yet taken into account ...\n");
     CloseFile();
     return false;
 
 }   
 
-/////////////////////////////////////////////////////////////////
 /**
  * \ingroup gdcmFile
  * \brief   Allocates necessary memory, copies the pixel data
- *          (image[s]/volume[s]) to newly allocated zone and return a
- *          pointer to it:
+ *          (image[s]/volume[s]) to newly allocated zone.
+ * @return  Pointer to newly allocated pixel data. 
  */
 void * gdcmFile::GetImageData (void) {
    PixelData = (void *) malloc(lgrTotale);
@@ -148,16 +146,17 @@ void * gdcmFile::GetImageData (void) {
    return(PixelData);
 }
 
-/////////////////////////////////////////////////////////////////
 /**
- * \ingroup   gdcmFile
- * \brief amene en mémoire dans une zone précisee par l'utilisateur
- *        les Pixels d'une image 
- *
- * @param destination
- * @param MaxSize
- *
- * @return The number of bytes actually copied.
+ * \ingroup gdcmFile
+ * \brief   Copies at most MaxSize bytes of pixel data to caller's
+ *          memory space.
+ * @param   destination Address (in caller's memory space) at which the
+ *          pixel data should be copied
+ * @param   MaxSize Maximum number of bytes to be copied. When MaxSize
+ *          is not sufficient to hold the pixel data the copy is not
+ *          executed (i.e. no partial copy).
+ * @return  On success, the number of bytes actually copied. Zero on
+ *          failure e.g. MaxSize is lower than necessary.
  */
 
 size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
@@ -317,6 +316,7 @@ return;
  * \ingroup   gdcmFile
  * \brief TODO JPR
  * \warning doit-etre etre publique ?  FIXME JPR
+ * TODO : y a-t-il un inconvenient à fusioner ces 2 fonctions
  *
  * @param inData TODO JPR
  * @param ExpectedSize TODO JPR
@@ -327,6 +327,8 @@ int gdcmFile::SetImageData(void * inData, size_t ExpectedSize) {
    SetImageDataSize(ExpectedSize);
    PixelData = inData;
    lgrTotale = ExpectedSize;
+   
+   
    return(1);
 }
 
@@ -337,6 +339,7 @@ int gdcmFile::SetImageData(void * inData, size_t ExpectedSize) {
  * \brief TODO JPR
  * \
  * \warning WARNING doit-etre etre publique ? FIXME JPR
+ * TODO : y aurait il un inconvenient à fusionner ces 2 fonctions
  *
  * @param ImageDataSize TODO JPR
  *
@@ -345,15 +348,15 @@ int gdcmFile::SetImageData(void * inData, size_t ExpectedSize) {
 void gdcmFile::SetImageDataSize(size_t ImageDataSize) {
 
        string content1;
-       string content2;
        char car[20];
        
        // suppose que le ElValue (0x7fe0, 0x0010) existe ...
        
        sprintf(car,"%d",ImageDataSize);
-       content2=car;
-       SetPubElValByNumber(content2, 0x7fe0, 0x0010);
-       
+       gdcmElValue*a = GetElValueByNumber(0x7fe0, 0x0010);
+       a->SetLength(ImageDataSize);
+               
        ImageDataSize+=8;
        sprintf(car,"%d",ImageDataSize);
        content1=car;