static char *RCSid="$Id: write_directory.c,v 1.1 2000/01/17 19:07:28 jwm Exp $"; /*********************************************************************** * Description: Generate the directory entries for RTOG exchange * *********************************************************************** * $Log: write_directory.c,v $ * Revision 1.1 2000/01/17 19:07:28 jwm * Remove comments originating in other development trees * * Revision 1.0 2000/01/17 19:05:16 jwm * Initial revision **********************************************************************/ /*********************************************************************** Modules included: write_comment_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a comment file. write_ct_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a CT file. write_mrus_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for MR/US files. write_struct_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a structure file. write_beam_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a beam geometry file. write_film_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a digital film file. write_dose_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a dose file. write_dvh_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a dvh file. write_seed_directory() Writes out all appropriate keyword/ keyvalue pairs for the AAPM directory entries for a Seed Geometry file. ***********************************************************************/ /* Include Files */ #include #include #include #include #include #include #include #include #include #define NOT_MAIN #include "exchkeys.h" #include "sitedata.h" #include "patexchange.h" #include "writexch.h" /* */ /***************************************************************************** write_comment_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for comment files. ***************************************************************************/ int write_comment_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing comment image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evCOMMENT], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing comment image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, (void *)&patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing comment case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, (void *)patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing comment patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* WRITER */ if ( aapm_entry( tape, ekWRITER, (void *)cur_file->image.comment.writer, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing comment writer to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* COMMENT DESCRIPTION */ if ( aapm_entry( tape, ekCOMMENTDESCRIPTION, (void *)cur_file->image.comment.description, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing comment unit number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* COMMENT FILE of ORIGIN */ if ( aapm_entry( tape, ekFILEOFORIGIN, (void *)cur_file->image.comment.fileoforigin, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing comment file of origin to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } return( SUCCESS ); } /************************** End of write_comment_directory() **************/ /* */ /***************************************************************************** write_ct_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for ct files. ***************************************************************************/ int write_ct_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evCTSCAN], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, (void *)&patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, (void *)patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SCAN TYPE orientation */ if ( aapm_entry( tape, ekSCANTYPE, (void *)key_value_words[evTRANSVERSE], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct scan type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT PIXEL VALUE OFFSET */ if ( aapm_entry( tape, ekCTOFFSET, (void *)&cur_file->image.ctscan.ct_offset, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct pixel offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT PIXEL WIDTH and LENGTH */ if ( aapm_entry( tape, ekGRID1UNITS, (void *)&cur_file->image.ctscan.pixel_width, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct pixel width to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } if ( aapm_entry( tape, ekGRID2UNITS, (void *)&cur_file->image.ctscan.pixel_length, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct pixel length to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT NUMBER TYPE */ if ( aapm_entry( tape, ekNUMBERREPRESENTATION, (void *)key_value_words[evTWOSCOMP], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct pixel number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT BYTES PER PIXEL */ if ( aapm_entry( tape, ekBYTESPERPIXEL, (void *)&cur_file->image.ctscan.bytes_per_pixel, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct pixel bytes to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF DIMENSIONS */ if ( aapm_entry( tape, ekNUMBEROFDIMENSIONS, (void *)&cur_file->image.ctscan.num_dimensions, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct num dimensions to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DIMENSION 1 COLUMNS */ if ( aapm_entry( tape, ekSIZEOFDIMENSION1, (void *)&cur_file->image.ctscan.dimension_1, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct dim 1 to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DIMENSION 2 ROWS */ if ( aapm_entry( tape, ekSIZEOFDIMENSION2, (void *)&cur_file->image.ctscan.dimension_2, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct dim 2 to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* Z COORDINATE */ if ( aapm_entry( tape, ekZVALUE, (void *)&cur_file->image.ctscan.z_value, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct z value to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* X-OFFSET */ if ( aapm_entry( tape, ekXOFFSET, (void *)&cur_file->image.ctscan.x_offset, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct x offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* Y-OFFSET */ if ( aapm_entry( tape, ekYOFFSET, (void *)&cur_file->image.ctscan.y_offset, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct y offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT VALUE OF AIR */ if ( aapm_entry( tape, ekCTAIR, (void *)&cur_file->image.ctscan.ct_air, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct air value to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT VALUE OF WATER */ if ( aapm_entry( tape, ekCTWATER, (void *)&cur_file->image.ctscan.ct_water, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct water value to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT THICKNESS */ if ( aapm_entry( tape, ekSLICETHICKNESS, (void *)&cur_file->image.ctscan.slice_thick, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct thickness to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT DISEASE SITE */ if ( aapm_entry( tape, ekSITEOFINTEREST, (void *)cur_file->image.ctscan.site, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct pixel number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CT FILE NAME */ if ( aapm_entry( tape, ekSCANFILENAME, (void *)cur_file->image.ctscan.scan_file, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing ct pixel number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } return( SUCCESS ); } /************************** End of write_ct_directory() **************/ /* */ /*********************************************************************** write_mrus_directory() ********************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for MR/US files. *********************************************************************/ int write_mrus_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if( cur_file->image_flag == eMRISCAN ) { /* MRI SCAN */ if ( aapm_entry( tape, ekIMAGETYPE, key_value_words[evMRSCAN], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } else if( cur_file->image_flag == eUSSCAN ) { /* ULTRASOUND SCAN */ if ( aapm_entry( tape, ekIMAGETYPE, key_value_words[evULTRASOUND], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing US image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } else /* UNKNOWN SCAN */ { sprintf( aapm_log_string, "Writing UNKNOWN scan type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, &patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SCAN TYPE orientation */ if ( aapm_entry( tape, ekSCANTYPE, key_value_words[evTRANSVERSE], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US scan type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PIXEL VALUE OFFSET */ if ( aapm_entry( tape, ekPIXELOFFSET, &cur_file->image.mrusscan.offset, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US pixel offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PIXEL WIDTH and LENGTH */ if ( aapm_entry( tape, ekGRID1UNITS, &cur_file->image.mrusscan.pixel_width, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US pixel width to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } if ( aapm_entry( tape, ekGRID2UNITS, &cur_file->image.mrusscan.pixel_length, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US pixel height to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER TYPE */ if ( aapm_entry( tape, ekNUMBERREPRESENTATION, key_value_words[evTWOSCOMP], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BYTES PER PIXEL */ if ( aapm_entry( tape, ekBYTESPERPIXEL, &cur_file->image.mrusscan.bytes_per_pixel, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US pixel bytes to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF DIMENSIONS */ if ( aapm_entry( tape, ekNUMBEROFDIMENSIONS, &cur_file->image.mrusscan.num_dimensions, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US num dimensions to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DIMENSION 1 COLUMNS */ if ( aapm_entry( tape, ekSIZEOFDIMENSION1, &cur_file->image.mrusscan.dimension_1, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US dim 1 to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DIMENSION 2 ROWS */ if ( aapm_entry( tape, ekSIZEOFDIMENSION2, &cur_file->image.mrusscan.dimension_2, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US dim 2 to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* Z COORDINATE */ if ( aapm_entry( tape, ekZVALUE, &cur_file->image.mrusscan.z_value, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US z value to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* X-OFFSET */ if ( aapm_entry( tape, ekXOFFSET, &cur_file->image.mrusscan.x_offset, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US x offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* Y-OFFSET */ if ( aapm_entry( tape, ekYOFFSET, &cur_file->image.mrusscan.y_offset, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing MR/US y offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } return( SUCCESS ); } /************************* End of write_mrus_directory() **************/ /* */ /***************************************************************************** write_struct_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for structure files. ***************************************************************************/ int write_struct_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evSTRUCTURE], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, (void *)&patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, (void *)patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* STRUCTURE NAME */ if ( aapm_entry( tape, ekSTRUCTURENAME, (void *)cur_file->image.structure.struct_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* STRUCTURE NUMBER TYPE */ if ( aapm_entry( tape, ekNUMBERREPRESENTATION, (void *)key_value_words[evCHARACTER], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* STRUCTURE BASIS TYPE */ if ( aapm_entry( tape, ekSTRUCTUREFORMAT, (void *)key_value_words[evSCANBASED], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct basis to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF SCANS */ if ( aapm_entry( tape, ekNUMBEROFSCANS, (void *)&cur_file->image.structure.num_scans, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct number of scans to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* MAX NUMBER OF SCANS */ if ( aapm_entry( tape, ekMAXIMUMNUMBERSCANS, (void *)&cur_file->image.structure.max_scans, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing max number of scans to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* MAXIMUM POINTS PER SEGMENT */ if ( aapm_entry( tape, ekMAXIMUMPOINTSPERSEGMENT, (void *)&cur_file->image.structure.max_pts_segment, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing max number of pts/seg to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* MAXIMUM SEGMENTS PER SCAN */ if ( aapm_entry( tape, ekMAXIMUMSEGMENTSPERSCAN, (void *)&cur_file->image.structure.max_seg_scan, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing max segments per scan to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* STRUCTURE EDITION */ if ( aapm_entry( tape, ekSTRUCTUREEDITION, (void *)cur_file->image.structure.edition, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing struct study edition to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } return( SUCCESS ); } /************************** End of write_struct_directory() **************/ /* */ /***************************************************************************** write_beam_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for beam files. ***************************************************************************/ int write_beam_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { char *string; /* TEMP POINTER */ beamgeom_t *beamdata; /* LOCAL COPY OF BEAM GEOMETRY POINTER */ /* SET LOCAL POINTER */ beamdata = &(cur_file->image.beam_geometry); /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evBEAMGEOMETRY], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, (void *)&patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, (void *)patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BEAM NUMBER */ if ( aapm_entry( tape, ekBEAMNUMBER, (void *)&beamdata->beam_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BEAM MODALITY */ switch( beamdata->modality ) { case eXRAY_BEAM: string = key_value_words[evXRAY]; break; case eELECTRON_BEAM: string = key_value_words[evELECTRON]; break; case ePROTON_BEAM: string = key_value_words[evNEUTRON]; break; case eNEUTRON_BEAM: string = key_value_words[evPROTON]; break; case eOTHER_BEAM: default: string = key_value_words[evOTHER]; break; } if ( aapm_entry( tape, ekBEAMMODALITY, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam modality to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BEAM ENERGY */ if ( aapm_entry( tape, ekBEAMENERGYMEV, (void *)&beamdata->beam_energy, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam energy to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BEAM DESCRIPTION */ if ( aapm_entry( tape, ekBEAMDESCRIPTION, (void *)beamdata->description, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam description to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* RX DOSE PER TREATMENT */ if ( aapm_entry( tape, ekRXDOSEPERTXGY, (void *)&beamdata->rx_dose_per_tx, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam dose/tx to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF TREATMENTS */ if ( aapm_entry( tape, ekNUMBEROFTX, (void *)&beamdata->number_of_treatments, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam number of tx to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* FRACTION GROUP ID */ if ( aapm_entry( tape, ekFRACTIONGROUPID, (void *)beamdata->fraction_group_id, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing fraction group id to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BEAM TYPE */ if ( beamdata->beamtype == eSTATIC ) string = key_value_words[evSTATIC]; else string = key_value_words[evARC]; if ( aapm_entry( tape, ekBEAMTYPE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PLAN ID OF ORIGIN */ if ( aapm_entry( tape, ekPLANIDOFORIGIN, (void *)beamdata->plan_id_of_origin, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing plan id of origin to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* COLLIMATOR TYPE */ switch( beamdata->collimator ) { case eSYMMETRIC: string = key_value_words[evSYMMETRIC]; break; case eASYMMETRIC: string = key_value_words[evASYMMETRIC]; break; case eASYMMETRIC_X: string = key_value_words[evASYMMETRIC_X]; break; case eASYMMETRIC_Y: string = key_value_words[evASYMMETRIC_Y]; break; case eUNDEF_COLL: default: sprintf( aapm_log_string, "Illegal collimator type" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekCOLLIMATORTYPE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing collimator type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* AePERTURE TYPE */ switch( beamdata->aperture ) { case eBLOCK_PORT: string = key_value_words[evBLOCK]; break; case eMLC_X_AXIS: string = key_value_words[evMLC_X]; break; case eMLC_Y_AXIS: string = key_value_words[evMLC_Y]; break; case eMLC_XY_AXIS: string = key_value_words[evMLC_XY]; break; case eCOLLIMATOR: string = key_value_words[evCOLLIMATOR]; break; case eUNDEF_APERTURE: default: sprintf( aapm_log_string, "Invalid aperture type" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekAPERTURETYPE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing aperture type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* APERTURE DESCRIPTION */ if ( aapm_entry( tape, ekAPERTUREDESCRIPTION, (void *)beamdata->aperture_description, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing aperture type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* COLLIMATOR ANGLE */ if ( aapm_entry( tape, ekCOLLIMATORANGLE, (void *)&beamdata->collimator_angle, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing collimator angle to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* GANTRY ANGLE */ if ( aapm_entry( tape, ekGANTRYANGLE, (void *)&beamdata->gantry_angle, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing gantry angle to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* COUCH ANGLE */ if ( aapm_entry( tape, ekCOUCHANGLE, (void *)&beamdata->couch_angle, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing couch angle to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* HEAD/FOOT ORIENTATION FLAG */ if ( beamdata->orientation != eHEAD_UNKNOWN ) { if ( aapm_entry( tape, ekHEADIN, (void *)key_value_words[beamdata->orientation==eHEAD_IN? evIN:evOUT], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam head/foot orientation to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* NOMINAL ISOCENTER DISTANCE */ if ( aapm_entry( tape, ekNOMINALISOCENTERDIST, (void *)&beamdata->nominal_isocenter_dist, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing nominal isocenter dist to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER REPRESENTATION */ switch( beamdata->number_type ) { case eTWOSCOMP: string = key_value_words[evTWOSCOMP]; break; case eCHARACTER: string = key_value_words[evCHARACTER]; break; case eUNSIGNEDBYTE: string = key_value_words[evUNSIGNEDBYTE]; break; default: sprintf( aapm_log_string, "Invalid number representation" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekNUMBERREPRESENTATION, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* APERTURE ID */ if ( beamdata->aperture_id != NULL ) { if ( aapm_entry( tape, ekAPERTUREID, (void *)beamdata->aperture_id, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing aperture id to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* WEDGE ANGLE */ if ( beamdata->wedge_angle > 0 ) { if ( aapm_entry( tape, ekWEDGEANGLE, (void *)&beamdata->wedge_angle, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing wedge angle to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* WEDGE ROTATION ANGLE */ if ( aapm_entry( tape, ekWEDGEROTATIONANGLE, (void *)&beamdata->wedge_rotation_angle, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing wedge rotation angle to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* ARC ANGLE */ if ( beamdata->beamtype != eSTATIC ) { if ( aapm_entry( tape, ekARCANGLE, (void *)&beamdata->arc_angle, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing arc angle to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* COMPENSATOR */ if ( beamdata->compensator != eNO_CF ) { switch( beamdata->compensator ) { case e1DX_CF: string = key_value_words[ev1D_X]; break; case e1DY_CF: string = key_value_words[ev1D_Y]; break; case e2D_CF: string = key_value_words[ev2D]; break; case e3D_CF: string = key_value_words[ev3D]; break; default: sprintf( aapm_log_string, "Invalid compensator type" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekCOMPENSATOR, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing compensator to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* ALL MUST HAVE GONE WELL TO GET HERE */ return( SUCCESS ); } /************************** End of write_beam_directory() **************/ /* */ /***************************************************************************** write_film_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for film files. ***************************************************************************/ int write_film_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { char *string; /* TEMP POINTER */ film_t *filmdata; /* LOCAL POINTER TO FILM DATA */ /* SET LOCAL POINTER */ filmdata = &(cur_file->image.film); /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evDIGITALFILM], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, (void *)&patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, (void *)patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BEAM NUMBER */ if ( aapm_entry( tape, ekBEAMNUMBER, (void *)&filmdata->beam_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BEAM DESCRIPTION */ if ( aapm_entry( tape, ekBEAMDESCRIPTION, (void *)filmdata->beam_description, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam description to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* FILM NUMBER */ if ( aapm_entry( tape, ekFILMNUMBER, (void *)&filmdata->film_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing beam number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* FILM DATE */ if ( aapm_entry( tape, ekFILMDATE, (void *)filmdata->film_date, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film date to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* FILM TYPE */ switch( filmdata->type ) { case eSIMULATOR: string = key_value_words[evSIMULATOR]; break; case eDRR: string = key_value_words[evDRR]; break; case exPORT: string = key_value_words[evPORT]; break; default: sprintf( aapm_log_string, "Invalid film type" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekFILMTYPE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film date to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF DIMENSIONS */ /* DOSE NUMBER OF DIMENSIONS */ if ( aapm_entry( tape, ekNUMBEROFDIMENSIONS, (void *)&filmdata->number_of_dimensions, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing number of film dims to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SIZE OF DIMENSION 1 */ if ( aapm_entry( tape, ekSIZEOFDIMENSION1, (void *)&filmdata->size_of_dimension1, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film dimension 1 size to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SIZE OF DIMENSION 2 */ if ( aapm_entry( tape, ekSIZEOFDIMENSION2, (void *)&filmdata->size_of_dimension2, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film dimension 2 size to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* GRID 1 UNITS */ if ( aapm_entry( tape, ekGRID1UNITS, (void *)&filmdata->grid_1_units, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film grid 1 units to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* GRID 2 UNITS */ if ( aapm_entry( tape, ekGRID2UNITS, (void *)&filmdata->grid_2_units, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film grid 2 units to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SOURCE IMAGE DISTANCE */ if ( aapm_entry( tape, ekSOURCEIMAGEDISTANCE, (void *)&filmdata->source_image_distance, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing source image distance to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* BYTES PER PIXEL */ if ( aapm_entry( tape, ekBYTESPERPIXEL, (void *)&filmdata->bytes_per_pixel, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film bytes per pixel to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER REPRESENTATION */ switch( filmdata->number_type ) { case eTWOSCOMP: string = key_value_words[evTWOSCOMP]; break; case eCHARACTER: string = key_value_words[evCHARACTER]; break; case eUNSIGNEDBYTE: string = key_value_words[evUNSIGNEDBYTE]; break; default: sprintf( aapm_log_string, "Invalid number representation" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekNUMBERREPRESENTATION, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* HANDLE OFFSETS IF THEY ARE LEGITIMATE */ if ( filmdata->offset_flag != 0 ) { /* X OFFSET */ if ( aapm_entry( tape, ekXOFFSET, (void *)&filmdata->x_offset, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film x offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* Y OFFSET */ if ( aapm_entry( tape, ekYOFFSET, (void *)&filmdata->y_offset, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film y offset to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* FILM DESCRIPTION */ if ( filmdata->film_description != NULL ) { if ( aapm_entry( tape, ekFILMDESCRIPTION, (void *)filmdata->film_description, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film bytes per pixel to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* FILM SOURCE */ if ( filmdata->source != eUNDEFSOURCE ) { switch( filmdata->source ) { case exFILM: string = key_value_words[evFILM]; break; case eONLINE: string = key_value_words[evONLINE]; break; case eCOMPUTED_IMAGE: string = key_value_words[evCOMPUTED]; break; default: sprintf( aapm_log_string, "Invalid film source" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekFILMSOURCE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film source to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* UNIT NUMBER */ if ( filmdata->unit_number > 0 ) { if ( aapm_entry( tape, ekUNITNUMBER, (void *)&filmdata->unit_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing unit number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* OD SCALE */ if ( filmdata->od_scale > 0.0 ) { if ( aapm_entry( tape, ekODSCALE, (void *)&filmdata->od_scale, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film od scale to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* BITS PER PIXEL */ if ( filmdata->bits_per_pixel > 0 ) { if ( aapm_entry( tape, ekBITSPERPIXEL, (void *)&filmdata->bits_per_pixel, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing film bits per pixel to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } } /* I GOT THIS FAR, SO THINGS MUST BE OK */ return( SUCCESS ); } /************************** End of write_film_directory() **************/ /* */ /***************************************************************************** write_dose_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for dose files. ***************************************************************************/ int write_dose_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { char *string; /* TEMP POINTER */ /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evDOSE], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, (void *)&patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, (void *)patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE NUMBER */ if ( aapm_entry( tape, ekDOSENUMBER, (void *)&cur_file->image.dose.dose_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE TYPE PHYSICAL, EFFECTIVE, LET, OER, ERROR */ switch( cur_file->image.dose.dose_flavor ) { case ePHYSICAL: /* PHYSICAL */ string = key_value_words[evPHYSICAL]; break; case eEFFECTIVE: /* EFFECTIVE */ string = key_value_words[evEFFECTIVE]; break; case eLET: /* LET */ string = key_value_words[evLET]; break; case eOER: /* OER */ string = key_value_words[evOER]; break; case eERROR: /* ERROR */ string = key_value_words[evERROR]; break; default: sprintf( aapm_log_string, "Illegal dose flavor" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekDOSETYPE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE UNITS RADS, GRAYS, ETC. */ switch( cur_file->image.dose.dose_units ) { case eGRAYS: /* GRAY */ string = key_value_words[evGRAYS]; break; case eRADS: /* RADS */ string = key_value_words[evRADS]; break; case eCGYS: /* CGY'S */ string = key_value_words[evCGYS]; break; case eCGE: /* COBALT GRAY EQUIV */ string = key_value_words[evCGE]; break; default: sprintf( aapm_log_string, "Illegal dose flavor" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekDOSEUNITS, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE SCALE VALUE */ if ( aapm_entry( tape, ekDOSESCALE, (void *)&cur_file->image.dose.dose_scale, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose scale to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* FRACTION GROUP ID */ if ( aapm_entry( tape, ekFRACTIONGROUPID, (void *)cur_file->image.dose.fraction_group_id, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing fraction group id to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF TIMES FRACTION TREATED */ if ( aapm_entry( tape, ekNUMBEROFTX, (void *)&cur_file->image.dose.number_of_treatments, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Number of fraction treatments to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE ORIENTATION */ if ( aapm_entry( tape, ekORIENTATIONOFDOSE, (void *)key_value_words[evTRANSVERSE], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose orientation to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE NUMBER TYPE */ if ( aapm_entry( tape, ekNUMBERREPRESENTATION, (void *)key_value_words[evCHARACTER], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE NUMBER OF DIMENSIONS */ if ( aapm_entry( tape, ekNUMBEROFDIMENSIONS, (void *)&cur_file->image.dose.num_dimensions, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing number of dose dims to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* # OF HORIZONTAL POINTS */ if ( aapm_entry( tape, ekSIZEOFDIMENSION1, (void *)&cur_file->image.dose.num_horiz_pts, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing # horizontal dose pts to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* # OF VERTICAL POINTS */ if ( aapm_entry( tape, ekSIZEOFDIMENSION2, (void *)&cur_file->image.dose.num_vert_pts, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing # vertical dose pts to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* # OF DOSE PLANES */ if ( aapm_entry( tape, ekSIZEOFDIMENSION3, (void *)&cur_file->image.dose.num_planes, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing # dose planes to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* FIRST COORD (X) */ if ( aapm_entry( tape, ekCOORD1OFFIRSTPOINT, (void *)&cur_file->image.dose.first_coord, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing first dose pt coord to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SECOND COORD (Y) */ if ( aapm_entry( tape, ekCOORD2OFFIRSTPOINT, (void *)&cur_file->image.dose.second_coord, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing second dose pt coord to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* HORIZONTAL STEP (X) */ if ( aapm_entry( tape, ekHORIZONTALGRIDINTERVAL, (void *)&cur_file->image.dose.horiz_step, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose horizontal step to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* VERTICAL STEP (Y) */ if ( aapm_entry( tape, ekVERTICALGRIDINTERVAL, (void *)&cur_file->image.dose.vert_step, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose vertical step to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE DESCRIPTION */ if ( aapm_entry( tape, ekDOSEDESCRIPTION, (void *)cur_file->image.dose.description, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose description to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE EDITION */ if ( aapm_entry( tape, ekDOSEEDITION, (void *)cur_file->image.dose.edition, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing dose edition to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } return( SUCCESS ); } /************************** End of write_dose_directory() **************/ /* */ /***************************************************************************** write_dvh_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for dvh files. ***************************************************************************/ int write_dvh_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { dvh_t *dvhdata; /* LOCAL COPY OF DVH POINTER */ char *string; /* POINTER TO KEY VALUE STRING */ /* SET THE LOCAL POINTER */ dvhdata = &(cur_file->image.dvh); /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evDOSEVOLUMEHISTOGRAM], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, (void *)&patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, (void *)patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* STRUCTURE NAME */ if ( aapm_entry( tape, ekSTRUCTURENAME, (void *)dvhdata->struct_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH struct name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PLAN ID OF ORIGIN */ if ( aapm_entry( tape, ekPLANIDOFORIGIN, (void *)dvhdata->plan_id_of_origin, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH plan id of origin to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE UNITS */ switch ( dvhdata->dose_units ) { case eGRAYS: string = key_value_words[evGRAYS]; break; case eRADS: string = key_value_words[evRADS]; break; case eCGYS: string = key_value_words[evCGYS]; break; case eCGE: string = key_value_words[evCGE]; break; default: sprintf( aapm_log_string, "Illegal dose unit in DVH" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekDOSEUNITS, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH dose units to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE TYPE */ switch ( dvhdata->dose_flavor ) { case eGRAYS: string = key_value_words[evGRAYS]; break; case eRADS: string = key_value_words[evRADS]; break; case eCGYS: string = key_value_words[evCGYS]; break; case eCGE: string = key_value_words[evCGE]; break; case eABSOLUTE: string = key_value_words[evABSOLUTE]; break; case ePERCENT: string = key_value_words[evPERCENT]; break; case eRELATIVE: string = key_value_words[evRELATIVE]; break; default: sprintf( aapm_log_string, "Illegal dose type in DVH" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekDOSETYPE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH dose type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* VOLUME TYPE */ switch ( dvhdata->dose_flavor ) { case eABSOLUTE: string = key_value_words[evABSOLUTE]; break; case ePERCENT: string = key_value_words[evPERCENT]; break; default: sprintf( aapm_log_string, "Illegal dose type in dvh" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); /* break; commented out to avoid compiler warnings */ } if ( aapm_entry( tape, ekVOLUMETYPE, (void *)string, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH volume type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF PAIRS */ if ( aapm_entry( tape, ekNUMBEROFPAIRS, (void *)&dvhdata->number_of_pairs, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH number of pairs to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* MAXIMUM NUMBER OF PAIRS */ if ( aapm_entry( tape, ekMAXIMUMNUMBERPAIRS, (void *)&dvhdata->maximum_number_of_pairs, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH max number of pairs to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER REPRESENTATION */ if ( aapm_entry( tape, ekNUMBERREPRESENTATION, (void *)key_value_words[evCHARACTER], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DOSE SCALE */ if ( aapm_entry( tape, ekDOSESCALE, (void *)&dvhdata->dose_scale, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH dose scale to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* VOLUME SCALE */ if ( aapm_entry( tape, ekVOLUMESCALE, (void *)&dvhdata->volume_scale, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH volume scale to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DATE OF DVH */ if ( aapm_entry( tape, ekDATEOFDVH, (void *)dvhdata->date, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing DVH date to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SINCE I GOT HERE, THINGS MUST BE ALL RIGHT */ return( SUCCESS ); } /************************** End of write_dvh_directory() **************/ /* */ /***************************************************************************** write_seed_directory() **************************************************************************** Functional Description: Outputs the directory entries for AAPM data exchange format for Seed Geometry files. ***************************************************************************/ int write_seed_directory ( tapedir_t *tape, /* TAPE DIRECTORY STRUCTURE */ case_t *patcase, /* PATIENT CASE POINTER */ exch_file_t *cur_file, /* EXCHANGE FORMAT FILE ENTRY */ FILE *output /* OUTPUT FILE STREAM POINTER */ ) { seeddata_t *seeddata; /* LOCAL COPY OF SEED DATA POINTER */ /* SET THE LOCAL POINTER */ seeddata = &(cur_file->image.seeddata); /* OUTPUT THE IMAGE NUMBER */ if ( aapm_entry( tape, ekIMAGENUMBER, (void *)&cur_file->image_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY image number to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* IMAGE TYPE */ if ( aapm_entry( tape, ekIMAGETYPE, (void *)key_value_words[evSEEDGEOMETRY], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY image type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* CASE NUMBER */ if ( aapm_entry( tape, ekCASENUMBER, &patcase->case_number, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY case # to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PATIENT NAME */ if ( aapm_entry( tape, ekPATIENTNAME, patcase->patient_name, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY patient name to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SEED MODEL */ if ( aapm_entry( tape, ekSEEDMODEL, seeddata->seed_model, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED MODEL to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* ISOTOPE */ if ( aapm_entry( tape, ekSEEDISOTOPE, key_value_words[seeddata->isotope], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED ISOTOPE to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SEED STRENGTH */ if ( aapm_entry( tape, ekSEEDSTRENGTH, &seeddata->strength, aFLOAT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED STRENGTH to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* STRENGTH UNITS */ if ( aapm_entry( tape, ekSEEDSTRENGTHUNITS, key_value_words[seeddata->units], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED STRENGTH UNITS to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* DATE OF IMPLANT */ if ( aapm_entry( tape, ekDATEOFIMPLANT, seeddata->date, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY DATE OF IMPLANT to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER OF SEEDS */ if ( aapm_entry( tape, ekNUMBEROFSEEDS, &seeddata->nseeds, aINT, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY seed count to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* NUMBER REPRESENTATION */ if ( aapm_entry( tape, ekNUMBERREPRESENTATION, (void *)key_value_words[evCHARACTER], aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY number type to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* PLAN ID OF ORIGIN */ if ( aapm_entry( tape, ekPLANIDOFORIGIN, seeddata->plan_id_of_origin, aSTRING, output ) != SUCCESS ) { sprintf( aapm_log_string, "Writing SEED GEOMETRY plan id of origin to directory" ); aapm_status( eAAPM_ERROR, aapm_log_string ); return( FAILURE ); } /* SINCE I GOT HERE, THINGS MUST BE ALL RIGHT */ return( SUCCESS ); } /************************* End of write_seed_directory() **************/ /********************* End of write_directory.c ***********************/