반응형
#include "dcmtk/dcmnet/dstorscu.h"
#include "dcmtk/dcmjpeg/djdecode.h"
#include "dcmtk/dcmjpls/djdecode.h"
#include "dcmtk/dcmdata/dcrledrg.h"
bool StoreSCU::SendCompressedFilesToPacs()
{
if (storageSCU == NULL)
storageSCU = new DcmStorageSCU();
// register JPEG decoder
DJDecoderRegistration::registerCodecs();
// register JPEG-LS decoder
DJLSDecoderRegistration::registerCodecs();
// register RLE decoder
DcmRLEDecoderRegistration::registerCodecs();
if (!dcmDataDict.isDictionaryLoaded())
{
//cout << "no data dictionary loaded, check environment variable: "
// << DCM_DICT_ENVIRONMENT_VARIABLE;
}
storageSCU->setDecompressionMode(DcmStorageSCU::DM_never);
storageSCU->setPeerHostName("127.0.01");
storageSCU->setPeerPort(3000);
storageSCU->setPeerAETitle("BUNNY");
storageSCU->setAETitle("STORESCU");
storageSCU->setVerbosePCMode(true);
storageSCU->setDIMSEBlockingMode(DIMSE_BLOCKING);
storageSCU->setReadFromDICOMDIRMode(false);
storageSCU->setHaltOnInvalidFileMode(true);
storageSCU->setAllowIllegalProposalMode(true);
OFCondition status;
int numInvalidFiles = 0;
//for (auto it : list_file)
{
//cout << "list=" << it << endl;
//status = storageSCU->addDicomFile(it.c_str(), ERM_fileOnly, true);
status = storageSCU->addDicomFile("C:\\Workspace\\CHEST PA.dcm", ERM_fileOnly, true);
if (status.bad())
{
/* check for empty filename */
//if (it.size() == 0)
// cout << "<empty string>" << endl;
numInvalidFiles++;
}
}
while ((status = storageSCU->addPresentationContexts()).good())
{
storageSCU->initNetwork();
storageSCU->negotiateAssociation();
if (storageSCU->getNumberOfSOPInstances() == 0)
{
//cout << "no valid input files to be processed" << endl;
}
else
{
//cout << "in total, there are " << storageSCU->getNumberOfSOPInstances()
// << " SOP instances to be sent, " << numInvalidFiles << " invalid files are ignored" << endl;
}
status = storageSCU->sendSOPInstances();
if (status.bad())
{
//cout << "cannot send SOP instance: " << status.text() << endl;;
storageSCU->releaseAssociation();
delete storageSCU;
storageSCU = NULL;
return false;
}
else
{
//cout << "sending SOP instance: " << status.text() << endl;
}
}
return true;
}
반응형
'[====== Development ======] > DICOM' 카테고리의 다른 글
[DCMTK] Source Code 빌드 방법 정리 (2) | 2021.08.27 |
---|---|
DICOM UID 생성규칙 (0) | 2021.08.18 |
[DCMTK] Simple StoreSCP (0) | 2021.07.29 |
[DCMTK] decompress DICOM (0) | 2021.07.27 |
[DCMTK] Echo SCU (0) | 2021.07.27 |