src/conv/vdicom/i2o_dcm.cpp
//
// scan the whole file and collect everything we need
//
scan the whole file and collect everything we need
scan the whole file and collect everything we need
void
i2o_dcm::FullScan()
{
#ifdef DEBUG
  cout << "FullScan()ning " << m_filename << endl;
#endif
  if( m_firstDcmTag ) 
    {
      m_fullScanDone = true; 
      int32_t   len   = 0;
      u_int16_t grp, element;
      char      VR[3] = { '\0', '\0', '\0' };
      char*     end   = (char*)m_mm + m_filesize;
      char* b = m_readStoppedHere;
#ifdef DEBUG
      string s_b;
#endif
      do {
	b = DcmElement( b + len, grp, element, len, VR );
#ifdef DEBUG
	cout << "i2o_dcm::FullScan():"
	  " grp=0x" << hex << grp <<
	  ", ele=0x" << element <<
	  ", len=" << dec << len << endl;
#endif
	if( len < 0 ) 
	  len = 0;
	else
	  switch(grp)
	    {
	    case  0x8:
	      Grp08( b, element, len, VR );
	      break;
	    case  0x10:
	      Grp10( b, element, len, VR );
	      break;
	    case  0x18:
	      Grp18( b, element, len, VR );
	      break;
	    case  0x19: 
	      Grp19( b, element, len, VR );
	      break;
	    case  0x20:
	      Grp20( b, element, len, VR );
	      break;
	    case  0x28:
	      Grp28( b, element, len, VR );
	      break;
	    case  0x29:
	      Grp29( b, element, len, VR );
	        break;
	    case  0x51: 
	      Grp51( b, element, len, VR );
	      break;
	    case  0x7fe0: 
	      Grp7FE0( b, element, len, VR );
	      break;
	    case  0x7fe1: 
	      Grp7FE1( b, element, len, VR );
	      break;
	    case  0x9999:
	      switch(element)
		{
		case 0x01:
		  break;
		}
	      break;
	    }
      }
      while ( b + len < end );
      FigureOutDataType();
      if( m_Slices < 2 ) 
	{   
	  m_Slices = 1;
	  m_Rows = m_TotalRows;
	  m_Cols = m_TotalCols;
#ifdef DEBUG
	  cout << "RESETTING m_Cols to " << m_Cols << " and m_Rows to " << m_Rows << ", " << endl;
#endif
	}
#ifdef DEBUG
      cout << "FullScan(): \"" << m_filename << "\", size=" << m_filesize << ", patient name=\""
	   << m_PatientName << "\", " << endl
	   << "        cols=" << m_Cols << ", rows=" << m_Rows << ", slices=" << m_Slices
	   << ", totalCols=" << m_TotalCols << ", totalRows=" << m_TotalRows << endl;
#endif
    }
  else
    cerr << "Internal error: FullScan() without prior Read()." << endl;
}
void i2o_dcm :: FullScan ( ) { #ifdef DEBUG cout << " " << m_filename << endl ; #endif if ( m_firstDcmTag ) { m_fullScanDone = true ; int32_t len = 0 ; u_int16_t grp , element ; char VR [ 3 ] = { ' \0 ' , ' \0 ' , ' \0 ' } ; char * end = ( char * ) m_mm + m_filesize ; char * b = m_readStoppedHere ; #ifdef DEBUG string s_b ; #endif do { b = DcmElement ( b + len , grp , element , len , VR ) ; #ifdef DEBUG cout << " " " " << hex << grp << " " << element << " " << dec << len << endl ; #endif if ( len < 0 ) len = 0 ; else switch ( grp ) { case 0x8 : Grp08 ( b , element , len , VR ) ; break ; case 0x10 : Grp10 ( b , element , len , VR ) ; break ; case 0x18 : Grp18 ( b , element , len , VR ) ; break ; case 0x19 : Grp19 ( b , element , len , VR ) ; break ; case 0x20 : Grp20 ( b , element , len , VR ) ; break ; case 0x28 : Grp28 ( b , element , len , VR ) ; break ; case 0x29 : Grp29 ( b , element , len , VR ) ; break ; case 0x51 : Grp51 ( b , element , len , VR ) ; break ; case 0x7fe0 : Grp7FE0 ( b , element , len , VR ) ; break ; case 0x7fe1 : Grp7FE1 ( b , element , len , VR ) ; break ; case 0x9999 : switch ( element ) { case 0x01 : break ; } break ; } } while ( b + len < end ) ; FigureOutDataType ( ) ; if ( m_Slices < 2 ) { m_Slices = 1 ; m_Rows = m_TotalRows ; m_Cols = m_TotalCols ; #ifdef DEBUG cout << " " << m_Cols << " " << m_Rows << " " << endl ; #endif } #ifdef DEBUG cout << " \" " << m_filename << " \" " << m_filesize << " \" " << m_PatientName << " \" " << endl << " " << m_Cols << " " << m_Rows << " " << m_Slices << " " << m_TotalCols << " " << m_TotalRows << endl ; #endif } else cerr << " " << endl ; }
scan the whole file and collect everything we need
scan the whole file and collect everything we need
// that means the initial Read() already happened // slightly optimistic ;) // "unknown sequence length" or delimiters or whatever ... /*GRP*/ /*GRP*/ /*GRP*/ /*GRP*/ // Siemens Private /*GRP*/ /*GRP*/ /*GRP*/ /*GRP*/ // Siemens Private /*GRP*/ // IMAGE GRAPHICS /*GRP*/ // CSA NON-IMAGE /*GRP*/ // No mosaic, adjust cols/rows to avoid confusion. // We have to trust the values for total data matrix size.