comparison OrthancServer/FromDcmtkBridge.cpp @ 62:a70bb32802ae orthanc-renaming

renaming Server
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 16 Sep 2012 09:33:19 +0200
parents 4bc019d2f969
children aa65ced5f0f0
comparison
equal deleted inserted replaced
61:d1c511efd6b1 62:a70bb32802ae
1 /** 1 /**
2 * Palanthir - A Lightweight, RESTful DICOM Store 2 * Orthanc - 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/PalanthirException.h" 25 #include "../Core/OrthancException.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 Palanthir 48 namespace Orthanc
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 PalanthirException("Only applicable to leaf elements"); 76 throw OrthancException("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 PalanthirException(ErrorCode_BadFileFormat); 373 throw OrthancException(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 }
471 case ImageExtractionMode_UInt16: 471 case ImageExtractionMode_UInt16:
472 format = PixelFormat_Grayscale16; 472 format = PixelFormat_Grayscale16;
473 break; 473 break;
474 474
475 default: 475 default:
476 throw PalanthirException(ErrorCode_NotImplemented); 476 throw OrthancException(ErrorCode_NotImplemented);
477 } 477 }
478 478
479 if (accessor.get() == NULL || 479 if (accessor.get() == NULL ||
480 accessor->GetWidth() == 0 || 480 accessor->GetWidth() == 0 ||
481 accessor->GetHeight() == 0) 481 accessor->GetHeight() == 0)
498 case ImageExtractionMode_UInt16: 498 case ImageExtractionMode_UInt16:
499 ExtractPngImageTruncate<uint16_t>(result, *accessor, format); 499 ExtractPngImageTruncate<uint16_t>(result, *accessor, format);
500 break; 500 break;
501 501
502 default: 502 default:
503 throw PalanthirException(ErrorCode_NotImplemented); 503 throw OrthancException(ErrorCode_NotImplemented);
504 } 504 }
505 } 505 }
506 } 506 }
507 507
508 508
523 { 523 {
524 ExtractPngImage(result, *dicom.getDataset(), frame, mode); 524 ExtractPngImage(result, *dicom.getDataset(), frame, mode);
525 } 525 }
526 else 526 else
527 { 527 {
528 throw PalanthirException(ErrorCode_BadFileFormat); 528 throw OrthancException(ErrorCode_BadFileFormat);
529 } 529 }
530 } 530 }
531 531
532 532
533 533
554 const DcmDictEntry* entry = dict.findEntry(name); 554 const DcmDictEntry* entry = dict.findEntry(name);
555 555
556 if (entry == NULL) 556 if (entry == NULL)
557 { 557 {
558 dcmDataDict.unlock(); 558 dcmDataDict.unlock();
559 throw PalanthirException("Unknown DICOM tag"); 559 throw OrthancException("Unknown DICOM tag");
560 } 560 }
561 else 561 else
562 { 562 {
563 DcmTagKey key = entry->getKey(); 563 DcmTagKey key = entry->getKey();
564 DicomTag tag(key.getGroup(), key.getElement()); 564 DicomTag tag(key.getGroup(), key.getElement());
583 void FromDcmtkBridge::ToJson(Json::Value& result, 583 void FromDcmtkBridge::ToJson(Json::Value& result,
584 const DicomMap& values) 584 const DicomMap& values)
585 { 585 {
586 if (result.type() != Json::objectValue) 586 if (result.type() != Json::objectValue)
587 { 587 {
588 throw PalanthirException(ErrorCode_BadParameterType); 588 throw OrthancException(ErrorCode_BadParameterType);
589 } 589 }
590 590
591 result.clear(); 591 result.clear();
592 592
593 for (DicomMap::Map::const_iterator 593 for (DicomMap::Map::const_iterator