Dec 17, 2009

Library dependency in DCMTK with MSVC

Quoted from:
DICOM @ OFFIS :: View topic - FAQ #27: Compilation of DCMTK-based program fails with LNK2001 [MSVC]
# dcmdata -> ofstd
# dcmimage -> dcmimgle, dcmdata, ofstd
# dcmimgle -> dcmdata, ofstd
# dcmjpeg -> ijg8, ijg12, ijg16, dcmimage, dcmimgle, dcmdata, ofstd
# dcmnet -> dcmdata, ofstd
# dcmpstat -> dcmimage, dcmimgle, dcmsign, dcmsr, imagectn, dcmtls, dcmnet, dcmdata, ofstd
# dcmsign -> dcmdata, ofstd
# dcmsr -> dcmdata, ofstd
# dcmtls -> dcmnet, dcmdata, ofstd
# dcmwlm -> dcmnet, dcmdata, ofstd
# imagectn/dcmqrdb -> dcmnet, dcmdata, ofstd



And additional link to the libraries of "netapi32.lib" and "wsock32.lib" from microsoft's Platform SDK/Windows SDK(generally included in VC++ installation) are required because some of libraries in the DCMTK uses its functionality.

The first "choke" step for building own application is here. If you forget to link to the "netapi32.lib", the linker will output several errors as like followings:

In English version of VC:
error LNK2019: unsolved link symbol _Netbios@4 is referenced in the function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z)
Debug/Xxxx.exe : fatal error LINK1120: There is 1 unsolved external reference.
(This message is manually translated to English from Japanese. so, it may not be exactly same message in actual message emitted from English version of VC.)

In Japanese version of VC:
dcmtk.lib(dcuid.obj) : error LNK2019: 未解決の外部シンボル _Netbios@4 が関数 "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z) で参照されました。
Debug/Xxxx.exe : fatal error LNK1120: 外部参照 1 が未解決です。

Dec 16, 2009

Pre-defined DcmTagKey object for each dicom attribute

DCMTK defines generally used tags as pre-defined DcmTagKey object.

You can find the list of the pre-defined DcmTagKey in dcdeftag.h and it is automatically included if you are including "dctk.h" header file.

The definitions use the syntax as following:

    DCM_<TagNameWidthNoSpace>

To use this pre-defined definitions, we can easily type the tags than typing the group-element values in hex decimal values with less stress.  And also, code's reviewability will goes up, and the typing miss can be eliminated by using this definition.



Dec 15, 2009

How to read / write DICOMDIR using DCMTK


Quoted from the Reading DICOMDIR using dcmtk - Unix Linux Forum - Fixunix.com
class DcmDicomDir is what you are looking for (see
dcmdata/include/dcdicdir.h). This class allows you to read a DICOMDIR
file and to browse through the logical structure (patient - study -
series - instance) of the directory records.

Use DcmDicomDir::getRootRecord() to get access to the root directory
record, then use methods of class DcmDirectoryRecord to walk through
the tree.

DicomDirInterface is, as the documentation suggests, only a helper
class (a wrapper around class DcmDicomDir) that simplifies the task
of creating or extending a DICOMDIR from a number of DICOM files.


We can read and write the DICOMDIR file by using DcmDicomDir class.
This class strictly compliant to DICOM specification, so we need to care especially the "Transfer syntax" and "File name".