Skip to content
Permalink
Browse files

MD-921

  • Loading branch information...
rossetantoine committed Jan 31, 2014
1 parent f04103f commit 20254f65e1a17b9c41353a3640c70559ebf22b19
Showing with 67 additions and 55 deletions.
  1. BIN Binaries/libPapyrusToolkit.a.zip
  2. +2 −2 DCMPix.m
  3. +4 −4 DicomDatabase.mm
  4. +42 −31 DicomDir.mm
  5. +2 −1 Papyrus3/PapyPubFunctionDef3.h
  6. +17 −17 dicomFile.m
Binary file not shown.
@@ -6831,10 +6831,10 @@ - (void*) getPapyGroup: (int) group error: (int*) error
if( theErr == 0)
{
theErr = Papy3GotoGroupNb (fileNb, group);
if( theErr >= 0)
{
theErr = Papy3GroupRead(fileNb, &theGroupP);
theErr = Papy3GroupReadNb(fileNb, &theGroupP, group);
if( theErr > 0)
{
[cachedGroupsForThisFile setValue: [NSValue valueWithPointer: theGroupP] forKey: groupKey];
@@ -1843,16 +1843,16 @@ -(NSArray*)addFilesDescribedInDictionaries:(NSArray*)dicomFilesArray postNotific

if( supportedSOPClass == NO)
{
NSLog( @"unsupported DICOM SOP CLASS (%@)-> Reject the file : %@", SOPClassUID, newFile);
curDict = nil;
NSLog( @"unsupported DICOM SOP CLASS (%@)-> for the file : %@", SOPClassUID, newFile);
// curDict = nil;
}
}
}

if ([curDict objectForKey:@"SOPClassUID"] == nil && [[curDict objectForKey: @"fileType"] hasPrefix:@"DICOM"] == YES)
{
NSLog(@"no DICOM SOP CLASS -> Reject the file: %@", newFile);
curDict = nil;
NSLog(@"no DICOM SOP CLASS -> for the file: %@", newFile);
// curDict = nil;
}

if (curDict != nil)
@@ -13,6 +13,7 @@
=========================================================================*/

#import "DicomDir.h"
#import "N2Debug.h"
#include "dcddirif.h"
#include "ofstd.h"

@@ -22,40 +23,50 @@
@implementation DicomDir

+(void)createDicomDirAtDir:(NSString*)path {
DicomDirInterface ddir;
// ddir.enableVerboseMode();
ddir.disableConsistencyCheck(); // -W
ddir.disableTransferSyntaxCheck(); // -Nxc
ddir.enableInventMode(OFTrue); // +I

// ddir.enableIconImageMode(); // +X
ddir.enableOneIconPerSeriesMode(); // OsiriX addition
ddir.setIconSize(128); // we let DicomDirInterface pick the icon size.. which, depending on the modality, will be either 128 or 64
try {
@try {
DicomDirInterface ddir;
// ddir.enableVerboseMode();
ddir.disableConsistencyCheck(); // -W
ddir.disableTransferSyntaxCheck(); // -Nxc
ddir.enableInventMode(OFTrue); // +I

// ddir.enableIconImageMode(); // +X
ddir.enableOneIconPerSeriesMode(); // OsiriX addition
ddir.setIconSize(128); // we let DicomDirInterface pick the icon size.. which, depending on the modality, will be either 128 or 64

DicomDirImageImplementation imagePlugin;
ddir.addImageSupport(&imagePlugin);

OFList<OFString> fileNames;
OFStandard::searchDirectoryRecursively("", fileNames, NULL, path.fileSystemRepresentation); // +r +id burnFolder

NSString* dicomdirPath = [path stringByAppendingPathComponent:[NSString stringWithUTF8String:DEFAULT_DICOMDIR_NAME]];
OFCondition result = ddir.createNewDicomDir(DicomDirInterface::AP_USBandFlash, [dicomdirPath fileSystemRepresentation], DEFAULT_FILESETID); // -Pfl
if (!result.good())
[NSException raise:NSGenericException format:@"Couldn't create new DICOMDIR file: %s", result.text()];

ddir.setFilesetDescriptor(NULL, DEFAULT_DESCRIPTOR_CHARSET); // UTF-8 ?

for (OFListIterator(OFString) iter = fileNames.begin(); iter != fileNames.end(); ++iter) {
result = ddir.addDicomFile((*iter).c_str(), path.fileSystemRepresentation);
if (result.bad())
NSLog(@"Warning: couldn't add %s to DICOMDIR: %s", (*iter).c_str(), result.text());
DicomDirImageImplementation imagePlugin;
ddir.addImageSupport(&imagePlugin);

OFList<OFString> fileNames;
OFStandard::searchDirectoryRecursively("", fileNames, NULL, path.fileSystemRepresentation); // +r +id burnFolder

NSString* dicomdirPath = [path stringByAppendingPathComponent:[NSString stringWithUTF8String:DEFAULT_DICOMDIR_NAME]];
OFCondition result = ddir.createNewDicomDir(DicomDirInterface::AP_USBandFlash, [dicomdirPath fileSystemRepresentation], DEFAULT_FILESETID); // -Pfl
if (!result.good())
[NSException raise:NSGenericException format:@"Couldn't create new DICOMDIR file: %s", result.text()];

ddir.setFilesetDescriptor(NULL, DEFAULT_DESCRIPTOR_CHARSET); // UTF-8 ?

for (OFListIterator(OFString) iter = fileNames.begin(); iter != fileNames.end(); ++iter) {
result = ddir.addDicomFile((*iter).c_str(), path.fileSystemRepresentation);
if (result.bad())
NSLog(@"Warning: couldn't add %s to DICOMDIR: %s", (*iter).c_str(), result.text());
}

result = ddir.writeDicomDir(EET_ExplicitLength, EGL_withoutGL);
if (!result.good())
[NSException raise:NSGenericException format:@"Couldn't write DICOMDIR file: %s", result.text()];

chmod([dicomdirPath fileSystemRepresentation], 0755);
}
@catch (NSException *exception) {
N2LogException( exception);
}
} catch (std::exception &e) {
std::cout << e.what() << std::endl;
}

result = ddir.writeDicomDir(EET_ExplicitLength, EGL_withoutGL);
if (!result.good())
[NSException raise:NSGenericException format:@"Couldn't write DICOMDIR file: %s", result.text()];

chmod([dicomdirPath fileSystemRepresentation], 0755);
}

@end
@@ -185,7 +185,8 @@ Papy3GetPixelData (PapyShort , int , SElement *, int , long *);
extern EXPORT32 PapyShort EXPORT
Papy3GroupRead (PapyShort, SElement **);


extern EXPORT32 PapyShort EXPORT
Papy3GroupReadNb (PapyShort, SElement **, int);

/* --- PapyUtils3 --- */

@@ -2059,7 +2059,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
if( COMMENTSGROUP && COMMENTSELEMENT)
{
theErr = Papy3GotoGroupNb (fileNb, COMMENTSGROUP);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, COMMENTSGROUP) > 0)
{
SElement *inGrOrModP = theGroupP;

@@ -2093,7 +2093,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted


theErr = Papy3GotoGroupNb (fileNb, COMMENTSGROUP2);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, COMMENTSGROUP2) > 0)
{
SElement *inGrOrModP = theGroupP;

@@ -2129,7 +2129,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
theErr = Papy3FSeek (gPapyFile [fileNb], SEEK_SET, 132L);

theErr = Papy3GotoGroupNb (fileNb, COMMENTSGROUP3);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, COMMENTSGROUP3) > 0)
{
SElement *inGrOrModP = theGroupP;

@@ -2165,7 +2165,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
theErr = Papy3FSeek (gPapyFile [fileNb], SEEK_SET, 132L);

theErr = Papy3GotoGroupNb (fileNb, COMMENTSGROUP4);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, COMMENTSGROUP4) > 0)
{
SElement *inGrOrModP = theGroupP;

@@ -2204,7 +2204,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
// NSString *album = nil;
//
// theErr = Papy3GotoGroupNb (fileNb, 0x0020);
// if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
// if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0020) > 0)
// {
// SElement *inGrOrModP = theGroupP;
//
@@ -2241,7 +2241,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
// }
//
// theErr = Papy3GotoGroupNb (fileNb, 0x0040);
// if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
// if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0040) > 0)
// {
// SElement *inGrOrModP = theGroupP;
//
@@ -2303,7 +2303,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
if (gIsPapyFile [fileNb] == DICOM10) theErr = Papy3FSeek (gPapyFile [fileNb], SEEK_SET, 132L);

theErr = Papy3GotoGroupNb(fileNb, (PapyShort)0x0002);
if (theErr >= 0 && Papy3GroupRead(fileNb, &theGroupP) > 0)
if (theErr >= 0 && Papy3GroupReadNb(fileNb, &theGroupP, 0x0002) > 0)
{
val = Papy3GetElement(theGroupP, papPrivateInformationCreatorUIDGr, &nbVal, &itemType);
if (val != NULL && val->a && validAPointer( itemType))
@@ -2317,7 +2317,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
}

theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0008);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0008) > 0)
{
val = Papy3GetElement (theGroupP, papSOPClassUIDGr, &nbVal, &itemType);
if (val != NULL && val->a && validAPointer( itemType))
@@ -2534,7 +2534,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
//if (gIsPapyFile [fileNb] == DICOM10) theErr = Papy3FSeek (gPapyFile [fileNb], SEEK_SET, 132L);
// get the Patient group
theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0010);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0010) > 0)
{
//Patient Name
val = Papy3GetElement (theGroupP, papPatientsNameGr, &nbVal, &itemType);
@@ -2592,7 +2592,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
// if (gIsPapyFile [fileNb] == DICOM10) theErr = Papy3FSeek (gPapyFile [fileNb], SEEK_SET, 132L);

theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0018);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0018) > 0)
{
val = Papy3GetElement (theGroupP, papScanOptionsGr, &nbVal, &itemType);
if (val != NULL && val->a && validAPointer( itemType))
@@ -2642,7 +2642,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted

// get the General Image module
theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0020);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0020) > 0)
{
val = Papy3GetElement (theGroupP, papImageNumberGr, &nbVal, &itemType);
if (val != NULL && val->a && validAPointer( itemType))
@@ -2780,7 +2780,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
}

theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0028);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0028) > 0)
{
long realwidth;

@@ -2811,7 +2811,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
if( COMMENTSFROMDICOMFILES)
{
theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0032);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0032) > 0)
{
val = Papy3GetElement (theGroupP, papStudyCommentsGr, &nbVal, &itemType);
if (val != NULL && val->a && validAPointer( itemType) && strlen( val->a) > 0 && [dicomElements objectForKey: @"commentsAutoFill"] == nil)
@@ -2824,7 +2824,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
if( serie == nil)
{
theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0040);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0040) > 0)
{
val = Papy3GetElement (theGroupP, papPerformedProcedureStepDescriptionGr, &nbVal, &itemType);
if (val != NULL && val->a && validAPointer( itemType) && strlen( val->a) > 0)
@@ -2842,7 +2842,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted

// Is it a multi frame DICOM files? We need to parse these sequences for the correct sliceLocation value !
theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x5200);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x5200) > 0)
{
float originMultiFrame[ 3], orientationMultiFrame[ 9];

@@ -3149,7 +3149,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
if ([sopClassUID isEqualToString: [DCMAbstractSyntaxUID pdfStorageClassUID]])
{
theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x0042);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x0042) > 0)
{
SElement *element = theGroupP + papEncapsulatedDocumentGr;

@@ -3236,7 +3236,7 @@ -(short) getDicomFilePapyrus :(BOOL) forceConverted
if( COMMENTSFROMDICOMFILES)
{
theErr = Papy3GotoGroupNb (fileNb, (PapyShort) 0x4008);
if( theErr >= 0 && Papy3GroupRead (fileNb, &theGroupP) > 0)
if( theErr >= 0 && Papy3GroupReadNb (fileNb, &theGroupP, 0x4008) > 0)
{
val = Papy3GetElement (theGroupP, papInterpretationStatusIDGr, &nbVal, &itemType);
if (val != NULL && val->a && validAPointer( itemType) && strlen( val->a) > 0)

0 comments on commit 20254f6

Please sign in to comment.
You can’t perform that action at this time.