00001 #include "SliceDataWriter.h" 00002 #include "scan.h" 00003 #include "ScanWriterFactory.h" 00004 #include "ScanResultWriter.h" 00005 #include "dataTypes.h" 00006 #include "Sct/UnsupportedOperationError.h" 00007 00008 using namespace std; 00009 00010 namespace SctData { 00011 00012 //Make sure we are in the map 00013 bool SliceDataWriter::inMap = ScanWriterFactory::getFactory().addWriterToMap(SR_DT_SLICE, ScanResultWriter::getRawWriter(), *(new SliceDataWriter())); 00014 00015 //Do the publishing! 00016 void SliceDataWriter::writeData(scan_result_ptrs& scanResult, OStream& out) { 00017 ScanResultWriter::writeClass("SliceRawData", out); 00018 //cout << "Publishing slice data" << endl; 00019 //data 00020 switch (scanResult.header.width) { 00021 case SR_WD_32: { 00022 out << scanResult.header.size/2 << scanResult.header.dataType << scanResult.header.width; 00023 00024 UINT32* data = reinterpret_cast<UINT32*>(scanResult.data); 00025 out.put(data, scanResult.header.size/2); 00026 } 00027 break; 00028 00029 case SR_WD_16: { 00030 //data header - no need to output width 00031 out << scanResult.header.size << scanResult.header.dataType << scanResult.header.width; 00032 00033 UINT16* data = reinterpret_cast<UINT16*>(scanResult.data); 00034 out.put(data, scanResult.header.size); 00035 } 00036 break; 00037 00038 default: 00039 ostringstream oss; 00040 oss << "SliceDataWriter only supports 16 and 32 bit widths, was given: " << scanResult.header.width; 00041 throw UnsupportedOperationError(oss.str(), __FILE__, __LINE__); 00042 break; 00043 } 00044 } 00045 00046 }