comparison PalanthirServer/FromDcmtkBridge.cpp @ 50:a15e90e5d6fc

rename in code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Sep 2012 15:50:12 +0200
parents 33d67e1ab173
children 293038baf8f1
comparison
equal deleted inserted replaced
49:e1a3ae0dadf3 50:a15e90e5d6fc
1 /** 1 /**
2 * Palantir - A Lightweight, RESTful DICOM Store 2 * Palanthir - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
4 * Belgium 4 * Belgium
5 * 5 *
6 * This program is free software: you can redistribute it and/or 6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
20 20
21 #include "FromDcmtkBridge.h" 21 #include "FromDcmtkBridge.h"
22 22
23 #include "ToDcmtkBridge.h" 23 #include "ToDcmtkBridge.h"
24 #include "DicomIntegerPixelAccessor.h" 24 #include "DicomIntegerPixelAccessor.h"
25 #include "../Core/PalantirException.h" 25 #include "../Core/PalanthirException.h"
26 #include "../Core/PngWriter.h" 26 #include "../Core/PngWriter.h"
27 #include "../Core/DicomFormat/DicomString.h" 27 #include "../Core/DicomFormat/DicomString.h"
28 #include "../Core/DicomFormat/DicomNullValue.h" 28 #include "../Core/DicomFormat/DicomNullValue.h"
29 29
30 #include <boost/locale.hpp> 30 #include <boost/locale.hpp>
43 #include <dcmtk/dcmdata/dcvrul.h> 43 #include <dcmtk/dcmdata/dcvrul.h>
44 #include <dcmtk/dcmdata/dcvrus.h> 44 #include <dcmtk/dcmdata/dcvrus.h>
45 45
46 #include <boost/math/special_functions/round.hpp> 46 #include <boost/math/special_functions/round.hpp>
47 47
48 namespace Palantir 48 namespace Palanthir
49 { 49 {
50 void FromDcmtkBridge::Convert(DicomMap& target, DcmDataset& dataset) 50 void FromDcmtkBridge::Convert(DicomMap& target, DcmDataset& dataset)
51 { 51 {
52 target.Clear(); 52 target.Clear();
53 for (unsigned long i = 0; i < dataset.card(); i++) 53 for (unsigned long i = 0; i < dataset.card(); i++)
71 71
72 DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element) 72 DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element)
73 { 73 {
74 if (!element.isLeaf()) 74 if (!element.isLeaf())
75 { 75 {
76 throw PalantirException("Only applicable to leaf elements"); 76 throw PalanthirException("Only applicable to leaf elements");
77 } 77 }
78 78
79 if (element.isaString()) 79 if (element.isaString())
80 { 80 {
81 char *c; 81 char *c;
368 unsigned int maxStringLength) 368 unsigned int maxStringLength)
369 { 369 {
370 DcmFileFormat dicom; 370 DcmFileFormat dicom;
371 if (!dicom.loadFile(path.c_str()).good()) 371 if (!dicom.loadFile(path.c_str()).good())
372 { 372 {
373 throw PalantirException(ErrorCode_BadFileFormat); 373 throw PalanthirException(ErrorCode_BadFileFormat);
374 } 374 }
375 else 375 else
376 { 376 {
377 FromDcmtkBridge::ToJson(target, *dicom.getDataset(), maxStringLength); 377 FromDcmtkBridge::ToJson(target, *dicom.getDataset(), maxStringLength);
378 } 378 }
469 case ImageExtractionMode_UInt16: 469 case ImageExtractionMode_UInt16:
470 format = PixelFormat_Grayscale16; 470 format = PixelFormat_Grayscale16;
471 break; 471 break;
472 472
473 default: 473 default:
474 throw PalantirException(ErrorCode_NotImplemented); 474 throw PalanthirException(ErrorCode_NotImplemented);
475 } 475 }
476 476
477 if (accessor.get() == NULL || 477 if (accessor.get() == NULL ||
478 accessor->GetWidth() == 0 || 478 accessor->GetWidth() == 0 ||
479 accessor->GetHeight() == 0) 479 accessor->GetHeight() == 0)
496 case ImageExtractionMode_UInt16: 496 case ImageExtractionMode_UInt16:
497 ExtractPngImageTruncate<uint16_t>(result, *accessor, format); 497 ExtractPngImageTruncate<uint16_t>(result, *accessor, format);
498 break; 498 break;
499 499
500 default: 500 default:
501 throw PalantirException(ErrorCode_NotImplemented); 501 throw PalanthirException(ErrorCode_NotImplemented);
502 } 502 }
503 } 503 }
504 } 504 }
505 505
506 506
520 { 520 {
521 ExtractPngImage(result, *dicom.getDataset(), mode); 521 ExtractPngImage(result, *dicom.getDataset(), mode);
522 } 522 }
523 else 523 else
524 { 524 {
525 throw PalantirException(ErrorCode_BadFileFormat); 525 throw PalanthirException(ErrorCode_BadFileFormat);
526 } 526 }
527 } 527 }
528 528
529 529
530 530
551 const DcmDictEntry* entry = dict.findEntry(name); 551 const DcmDictEntry* entry = dict.findEntry(name);
552 552
553 if (entry == NULL) 553 if (entry == NULL)
554 { 554 {
555 dcmDataDict.unlock(); 555 dcmDataDict.unlock();
556 throw PalantirException("Unknown DICOM tag"); 556 throw PalanthirException("Unknown DICOM tag");
557 } 557 }
558 else 558 else
559 { 559 {
560 DcmTagKey key = entry->getKey(); 560 DcmTagKey key = entry->getKey();
561 DicomTag tag(key.getGroup(), key.getElement()); 561 DicomTag tag(key.getGroup(), key.getElement());
580 void FromDcmtkBridge::ToJson(Json::Value& result, 580 void FromDcmtkBridge::ToJson(Json::Value& result,
581 const DicomMap& values) 581 const DicomMap& values)
582 { 582 {
583 if (result.type() != Json::objectValue) 583 if (result.type() != Json::objectValue)
584 { 584 {
585 throw PalantirException(ErrorCode_BadParameterType); 585 throw PalanthirException(ErrorCode_BadParameterType);
586 } 586 }
587 587
588 result.clear(); 588 result.clear();
589 589
590 for (DicomMap::Map::const_iterator 590 for (DicomMap::Map::const_iterator