当前位置: 首页>>代码示例>>C++>>正文


C++ DcmDataset类代码示例

本文整理汇总了C++中DcmDataset的典型用法代码示例。如果您正苦于以下问题:C++ DcmDataset类的具体用法?C++ DcmDataset怎么用?C++ DcmDataset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DcmDataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: file

// Load our vtkImageData object from a list of DICOM image filenames...
// http://www.vtk.org/pipermail/vtkusers/2007-August/042635.html
void vtkDicom::load_dcmFiles(QStringList dcm_fileList) {
    DcmFileFormat dcm;
    std::string imgFname;
    std::cout << "vtkdicom: Files/Images(?): " << dcm_fileList.size() << "\n";
    for (int sei = 0; sei < dcm_fileList.size(); ++sei) {
        imgFname = dcm_fileList.at(sei).toLocal8Bit().constData();
        OFCondition status = dcm.loadFile(imgFname.c_str());
        if (!status.good()) {
            std::cout << "    vtkdicom: Error: cannot read file (" << status.text() << ")" << "\n";
            return;
        }
        if (sei == 0) {
            OFString acquisitionNumber, instanceNumber, imagePositionPatient, patientsName;
            DcmDataset *dcmDs = dcm.getDataset();
            dcmDs->findAndGetOFStringArray(DCM_ImagePositionPatient, imagePositionPatient);
            dcmDs->findAndGetOFString(DCM_AcquisitionNumber, acquisitionNumber);
            dcmDs->findAndGetOFString(DCM_InstanceNumber, instanceNumber);
            dcmDs->findAndGetOFString(DCM_PatientName, patientsName);
            std::cout << "vtkdicom: I#, IPP: " << instanceNumber << " - " << imagePositionPatient << "\n";
        }
        dcm.loadAllDataIntoMemory();
        const unsigned short* p = NULL;
        dcm.getDataset()->findAndGetUint16Array(DCM_PixelData, p);

    }
}
开发者ID:umm-mrrc,项目名称:augReality,代码行数:28,代码来源:vtkdicom.cpp

示例2: Q_D

//------------------------------------------------------------------------------
void ctkDICOMDatabase::loadFileHeader (QString fileName)
{
  Q_D(ctkDICOMDatabase);
  DcmFileFormat fileFormat;
  OFCondition status = fileFormat.loadFile(fileName.toLatin1().data());
  if (status.good())
    {
    DcmDataset *dataset = fileFormat.getDataset();
    DcmStack stack;
    while (dataset->nextObject(stack, true) == EC_Normal)
      {
      DcmObject *dO = stack.top();
      if (dO->isaString())
        {
        QString tag = QString("%1,%2").arg(
            dO->getGTag(),4,16,QLatin1Char('0')).arg(
            dO->getETag(),4,16,QLatin1Char('0'));
        std::ostringstream s;
        dO->print(s);
        d->LoadedHeader[tag] = QString(s.str().c_str());
        }
      }
    }
  return;
}
开发者ID:jhnstrk,项目名称:CTK,代码行数:26,代码来源:ctkDICOMDatabase.cpp

示例3: cgetDcm

bool DcmSend::cgetDcm()
{
    OFVector<RetrieveResponse*> findResponses;
    DcmDataset req;
//    req.putAndInsertString(DCM_PatientName,"Nurmukhametov");
//    req.putAndInsertString(DCM_SOPInstanceUID,"1.3.12.2.1107.5.4.5.55301.30000013021404234482800000106.512");
    req.putAndInsertString(DCM_SeriesInstanceUID,"1.3.12.2.1107.5.2.13.20561.30000005042216091690600002608");
    req.putAndInsertString(DCM_QueryRetrieveLevel,"SERIES");
//    req.putAndInsertString(DCM_SOPClassUID,"1.2.840.10008.5.1.4.1.1.4");
//    req.putAndInsertString(DCM_StudyInstanceUID,"1.2.840.113745.101000.1008000.38446.6272.7138759");

    Sender.setStorageMode(DCMSCU_STORAGE_DISK);
    Sender.setStorageDir("/tmp/dcmstorage");
//    req.putAndInsertOFStringArray(DCM_QueryRetrieveLevel, "STUDY");
//    req.putAndInsertOFStringArray(DCM_StudyInstanceUID, "");
    T_ASC_PresentationContextID presID = findUncompressedPC(UID_GETStudyRootQueryRetrieveInformationModel, Sender);
    if (presID == 0)
    {
        DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
        return false;
    }
    result=Sender.sendCGETRequest(presID,&req,&findResponses);
    if (result.bad())
        return false;
    return true;


}
开发者ID:neodiz,项目名称:dcmviewer,代码行数:28,代码来源:dcmsend.cpp

示例4: Q_D

void ctkDICOMDataset::Deserialize()
{
  Q_D(ctkDICOMDataset);
  // read attribute m_ctkDICOMDataset
  // construct a DcmDataset from it
  // calls InitializeData(DcmDataset*)

  // this method can be called both from sub-classes when they get the InitializeData signal from the persistence framework
  // and from EnsureDcmDataSetIsInitialized() when a GetElement.. or SetElement.. method is called.

  if (d->m_DICOMDataSetInitialized) return; // only need to do this once

  QString stringbuffer = this->GetStoredSerialization();
  if ( stringbuffer.isEmpty() )
  {
    d->m_DICOMDataSetInitialized = true;
    return; // TODO nicer: hold three states: newly created / loaded but not initialized / restored from DB
  }


  //std::cerr << "** " << (void*)this << " ctkDICOMDataset: Deserialize Dataset from string of size " << stringbuffer.size() << "\n" << stringbuffer.toStdString() << std::endl;

  QByteArray qtArray = QByteArray::fromBase64( stringbuffer.toAscii() );
  //std::cerr << "** " << (void*)this << " ctkDICOMDataset: Deserialize Dataset from byte array of size " << qtArray.size() << std::endl;

  DcmInputBufferStream dcmbuffer;
  dcmbuffer.setBuffer( qtArray.data(), qtArray.size() );
  //std::cerr << "** Buffer state: " << dcmbuffer.status().code() << " " <<  dcmbuffer.good() << " " << dcmbuffer.eos() << " tell " << dcmbuffer.tell() << " avail " << dcmbuffer.avail() << std::endl;

  DcmDataset dataset;
  dataset.transferInit();
  //std::cerr << "** Dataset state: " << dataset.transferState() << std::endl << std::endl;
  OFCondition condition = dataset.read( dcmbuffer, EXS_LittleEndianImplicit );
  dataset.transferEnd();

  // do this in all cases, even when reading reported an error
  this->InitializeFromDataset(&dataset);

  if ( condition.bad() )
  {
    std::cerr << "** Condition code of Dataset::read() is "
              << condition.code() << std::endl;
    std::cerr << "** Buffer state: " << dcmbuffer.status().code()
              << " " <<  dcmbuffer.good()
              << " " << dcmbuffer.eos()
              << " tell " << dcmbuffer.tell()
              << " avail " << dcmbuffer.avail() << std::endl;
    std::cerr << "** Dataset state: "
              << static_cast<int>(dataset.transferState()) << std::endl;
    std::cerr << "Could not DcmDataset::read(..): "
              << condition.text() << std::endl;
    //throw std::invalid_argument( std::string("Could not DcmDataset::read(..): ") + condition.text() );
  }
}
开发者ID:Koki-Shimizu,项目名称:CTK,代码行数:54,代码来源:ctkDICOMDataset.cpp

示例5: convert

Status ConvertDicomToLittleEndian::convert(QString inputFile, QString outputFile)
{
    DcmFileFormat fileformat;
    DcmDataset *dataset = fileformat.getDataset();
    OFCondition error;
    Status state;
    // Transfer Syntax del fitxer d'entrada
    E_TransferSyntax opt_ixfer = EXS_Unknown;
    E_FileReadMode opt_readMode = ERM_autoDetect;
    E_TransferSyntax opt_oxfer = EXS_LittleEndianExplicit;
    QString descriptionError;
    E_EncodingType opt_oenctype = EET_ExplicitLength;
    E_GrpLenEncoding opt_oglenc = EGL_recalcGL;
    E_PaddingEncoding opt_opadenc = EPD_noChange;
    OFCmdUnsignedInt opt_filepad = 0;
    OFCmdUnsignedInt opt_itempad = 0;
    E_FileWriteMode writeMode = EWM_fileformat;

    error = fileformat.loadFile(qPrintable(QDir::toNativeSeparators(inputFile)), opt_ixfer, EGL_noChange, DCM_MaxReadLength, opt_readMode);

    if (error.bad())
    {
        ERROR_LOG(QString("No s'ha pogut obrir el fitxer a convertir LittleEndian %1, descripcio error: %2").arg(inputFile, error.text()));
        return state.setStatus(error);
    }
    dataset->loadAllDataIntoMemory();

    DcmXfer opt_oxferSyn(opt_oxfer);

    dataset->chooseRepresentation(opt_oxfer, NULL);

    if (!dataset->canWriteXfer(opt_oxfer))
    {
        descriptionError = "Error: no conversion to transfer syntax " + QString(opt_oxferSyn.getXferName()) + " possible";
        state.setStatus(qPrintable(descriptionError), false, 1300);
        ERROR_LOG(descriptionError);
        return state;
    }

    error = fileformat.saveFile(qPrintable(QDir::toNativeSeparators(outputFile)), opt_oxfer, opt_oenctype, opt_oglenc, opt_opadenc,
                                OFstatic_cast(Uint32, opt_filepad), OFstatic_cast(Uint32, opt_itempad), writeMode);

    if (!error.good())
    {
        ERROR_LOG(QString("S'ha produit un error al intentar gravar la imatge %1 convertida a LittleEndian al path %2, descripcio error: %3")
                     .arg(inputFile, outputFile, error.text()));
    }

    return state.setStatus(error);
}
开发者ID:chinhtrandn,项目名称:starviewer,代码行数:50,代码来源:convertdicomtolittleendian.cpp

示例6: dumpDicomFile

void vtkDicom::dumpDicomFile(std::string imgFname)
{
    DcmFileFormat dfile;
    OFCondition status = dfile.loadFile(imgFname.c_str());
    if (status.good()) {
        OFString acquisitionNumber, instanceNumber, imagePositionPatient, patientsName;
        dfile.loadAllDataIntoMemory();
        DcmDataset *dcmDs = dfile.getDataset();
        dcmDs->findAndGetOFStringArray(DCM_ImagePositionPatient, imagePositionPatient);
        dcmDs->findAndGetOFString(DCM_AcquisitionNumber, acquisitionNumber);
        dcmDs->findAndGetOFString(DCM_InstanceNumber, instanceNumber);
        dcmDs->findAndGetOFString(DCM_PatientName, patientsName);
        std::cout << "    " << instanceNumber << " - " << imagePositionPatient << "\n";
    } else {
        std::cout << "    Error: cannot read file (" << status.text() << ")" << "\n";
    }
}
开发者ID:umm-mrrc,项目名称:augReality,代码行数:17,代码来源:vtkdicom.cpp

示例7: query_series_instances

/*
 * query the number instances of a series
 */
int query_series_instances(const std::string& studyinstanceuid, const std::string& seriesinstanceuid, const std::string& server, const std::string& local_aet) {
	DcmDataset query;
	DcmElement* e = NULL;
	
	e = newDicomElement(DCM_QueryRetrieveLevel);
	e->putString("IMAGE");
	query.insert(e);

	e = newDicomElement(DCM_StudyInstanceUID);
	e->putString(studyinstanceuid.c_str());
	query.insert(e);

	e = newDicomElement(DCM_SeriesInstanceUID);
	e->putString(seriesinstanceuid.c_str());
	query.insert(e);

	e = newDicomElement(DCM_SOPInstanceUID);
	query.insert(e);

	e = newDicomElement(DCM_InstanceNumber);
	query.insert(e);

	std::cout << "NEW QUERY:" << std::endl;
	query.print(COUT);

	NetClient<FindAssociation> a;
	a.QueryServer(&query, server, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel);

	DcmStack* result = a.GetResultStack();
	std::cout << "query_series_instances = " << result->card() << std::endl;
 
	return result->card();
}
开发者ID:Debian,项目名称:aeskulap,代码行数:36,代码来源:netquery.cpp

示例8: printMessage

OFCondition I2DOutputPlugSC::convert(DcmDataset &dataset) const
{
        if (m_debug)
                printMessage(m_logStream, "I2DOutputPlugSC: Inserting SC specific attributes");
        OFCondition cond;
        cond = dataset.putAndInsertOFStringArray(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);

        return EC_Normal;
}
开发者ID:151706061,项目名称:ginkgocadx,代码行数:9,代码来源:i2dplsc.cpp

示例9: main

int main(int argc, const char *argv[]) {

    string root_path;

    // SOURCE_CODE_LOCATION is set by cmake during compilation.
    // this contains the path to the source folder.
    // This is only helper for convenience. Without this
    // in_file below should contain absolute path.
    #ifdef SOURCE_CODE_LOCATION
        root_path = SOURCE_CODE_LOCATION;
    #endif

    // where does this example dcm come from, is
    // is explained at https://github.com/marcinwol/dcmtk-basic-example
    string in_file {root_path  + "/DCMIMAGES/77654033/20010101/CR1/6154"};

    DcmFileFormat file_format;
    OFCondition status = file_format.loadFile(in_file.c_str());

    if (status.bad()) {
        cerr << "Problem openning file:" << in_file << endl;
        return 1;
    }

    DcmDataset* dataset = file_format.getDataset();

    OFString patient_name;

    OFCondition condition;
    condition = dataset->findAndGetOFStringArray(DCM_PatientName, patient_name);

    if (condition.good())  {
        cout << "Patient name is: " << patient_name << endl;
    } else {
        cerr << "Could not get patient name" << endl;
    }

    cout << "Program finish." << endl;

    return 0;
}
开发者ID:marcinwol,项目名称:dcmtk-basic-example,代码行数:41,代码来源:main.cpp

示例10: open_dicomdir_series_result

    static void open_dicomdir_series_result(const Glib::ustring &dicomdir, DcmDirectoryRecord *patRec, DcmDirectoryRecord *studyRec, const sigc::slot< void, const Glib::RefPtr< ImagePool::Series >& >& resultslot) {
        DcmDirectoryRecord *seriesRec;
        DcmDirectoryRecord *sopRec;
        assert(studyRec->getRecordType()==ERT_Study);

        seriesRec = studyRec->nextSub(NULL);
        while ( seriesRec ) {
            DcmDataset series;
            DcmElement *el;

            if ( seriesRec->findAndCopyElement(DCM_SpecificCharacterSet, el) == ECC_Normal )
                series.insert(el);
            if ( seriesRec->findAndCopyElement(DCM_SeriesDescription, el) == ECC_Normal )
                series.insert(el);
            if ( seriesRec->findAndCopyElement(DCM_SeriesInstanceUID, el) == ECC_Normal )
                series.insert(el);
            if ( seriesRec->findAndCopyElement(DCM_Modality, el) == ECC_Normal )
                series.insert(el);
            if ( seriesRec->findAndCopyElement(DCM_SeriesDate, el) == ECC_Normal )
                series.insert(el);
            if ( seriesRec->findAndCopyElement(DCM_SeriesTime, el) == ECC_Normal )
                series.insert(el);
            if ( studyRec->findAndCopyElement(DCM_StudyDescription, el) == ECC_Normal )
                series.insert(el);
            if ( studyRec->findAndCopyElement(DCM_StationName, el) == ECC_Normal )
                series.insert(el);

            // Count Related SOP Instances
            int nSop=0;
            sopRec = seriesRec->nextSub(NULL);
            while (sopRec) {
                nSop++;
                sopRec = seriesRec->nextSub(sopRec);
            }
            series.putAndInsertUint16(DCM_NumberOfSeriesRelatedInstances, nSop);
            resultslot(create_query_series(&series));
            seriesRec = studyRec->nextSub(seriesRec);
        }
    }
开发者ID:Debian,项目名称:aeskulap,代码行数:39,代码来源:dicomdir.cpp

示例11: query_study_series

/*
 * query all seriesinstanceuid's and the number series of a study
 */
int query_study_series(const std::string& studyinstanceuid, const std::string& server, const std::string& local_aet, std::list<std::string>& seriesinstanceuids) {
	DcmDataset query;
	DcmElement* e = NULL;
	
	e = newDicomElement(DCM_QueryRetrieveLevel);
	e->putString("SERIES");
	query.insert(e);

	e = newDicomElement(DCM_StudyInstanceUID);
	e->putString(studyinstanceuid.c_str());
	query.insert(e);

	e = newDicomElement(DCM_SeriesInstanceUID);
	query.insert(e);

	e = newDicomElement(DCM_SeriesNumber);
	query.insert(e);

	e = newDicomElement(DCM_Modality);
	query.insert(e);

	std::cout << "NEW QUERY:" << std::endl;
	query.print(COUT);

	NetClient<FindAssociation> a;
	a.QueryServer(&query, server, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel);

	DcmStack* result = a.GetResultStack();
	DcmDataset* dset;
	OFString ofstr;

	seriesinstanceuids.clear();
	for(int i = 0; i < result->card(); i++) {
		dset = (DcmDataset*)result->elem(i);
		if(dset->findAndGetOFString(DCM_SeriesInstanceUID, ofstr).good()) {
			seriesinstanceuids.push_back(ofstr.c_str());
		}
	}

	std::cout << result->card() << " Responses" << std::endl;
	int count = result->card();

	return count;
}
开发者ID:Debian,项目名称:aeskulap,代码行数:47,代码来源:netquery.cpp

示例12: open_dicomdir_study

    static bool open_dicomdir_study(const Glib::ustring& dicomdir, DcmDirectoryRecord *patRec, DcmDirectoryRecord *studyRec, const sigc::slot< void, const Glib::RefPtr< ImagePool::Study >& >& resultslot) {
        bool seriesFound(false);
        DcmDirectoryRecord *subRec;

        assert(studyRec->getRecordType()==ERT_Study);
        subRec = studyRec->nextSub(NULL);
        while ( subRec && !seriesFound ) {
            switch ( subRec->getRecordType() ) {
            case ERT_Series:
                // Check if valid series (contains at least 1 image)
                seriesFound = true;
                break;
            case ERT_Private:
                break;
            default:
                std::cout << "WARNING: Bad DICOMDIR SubRecord type[" << subRec->getRecordType() << "] for Study found\n";
            }
            subRec = studyRec->nextSub(subRec);
        }
        if ( seriesFound ) {
            DcmDataset study;
            DcmElement *el;

            if ( studyRec->findAndCopyElement(DCM_SpecificCharacterSet, el) == ECC_Normal )
                study.insert(el);
            if ( studyRec->findAndCopyElement(DCM_StudyInstanceUID, el) == ECC_Normal )
                study.insert(el);
            if ( studyRec->findAndCopyElement(DCM_StudyDate, el) == ECC_Normal )
                study.insert(el);
            if ( studyRec->findAndCopyElement(DCM_StudyTime, el) == ECC_Normal )
                study.insert(el);
            if ( studyRec->findAndCopyElement(DCM_StudyDescription, el) == ECC_Normal )
                study.insert(el);
            if ( patRec->findAndCopyElement(DCM_PatientsName, el) == ECC_Normal )
                study.insert(el);
            if ( patRec->findAndCopyElement(DCM_PatientsBirthDate, el) == ECC_Normal )
                study.insert(el);
            if ( patRec->findAndCopyElement(DCM_PatientsSex, el) == ECC_Normal )
                study.insert(el);
            resultslot(create_query_study(&study, std::string("DICOMDIR:") + dicomdir));
        }
        return seriesFound;
    }
开发者ID:Debian,项目名称:aeskulap,代码行数:43,代码来源:dicomdir.cpp

示例13: queryDcm

bool DcmSend::queryDcm(QList <QString>  &QueryPatientName, QList <QString> &QueryPatientID, QList <QString> &QueryAccessionNumber)
{

    OFVector<QRResponse*> findResponses;
    DcmDataset req;
    req.insertEmptyElement(DCM_PatientName);
    req.insertEmptyElement(DCM_PatientID);
    req.insertEmptyElement(DCM_AccessionNumber);
    req.putAndInsertOFStringArray(DCM_QueryRetrieveLevel, "STUDY");
    req.putAndInsertOFStringArray(DCM_StudyInstanceUID, "");
    T_ASC_PresentationContextID presID = findUncompressedPC(UID_FINDStudyRootQueryRetrieveInformationModel, Sender);
    if (presID == 0)
    {
        DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
        return 1;
    }
    result = Sender.sendFINDRequest(presID, &req,&findResponses);


    if (result.bad())
       return false;


    OFString NamePatient;
    OFString PatientID;
    OFString AccessionNumber;
    for (int i=0;i<findResponses.size();i++){
        if (findResponses.at(i)->m_dataset != NULL){

            result= findResponses.at(i)->m_dataset->findAndGetOFString(DCM_PatientName,NamePatient);
            result= findResponses.at(i)->m_dataset->findAndGetOFString(DCM_AccessionNumber,AccessionNumber);
            result= findResponses.at(i)->m_dataset->findAndGetOFString(DCM_PatientID,PatientID);
            QueryPatientName << NamePatient.data();
            QueryPatientID << PatientID.data();
            QueryAccessionNumber << AccessionNumber.data();
        }
    }
    return true;

}
开发者ID:neodiz,项目名称:dcmviewer,代码行数:40,代码来源:dcmsend.cpp

示例14: DcmDataset

DcmDataset* RetrieveDICOMFilesFromPACS::getDcmDatasetOfImagesToRetrieve(const QString &studyInstanceUID, const QString &seriesInstanceUID, const QString &sopInstanceUID)
{
    DcmDataset *dcmDatasetToRetrieve = new DcmDataset();
    QString retrieveLevel = "STUDY";

    DcmElement *elemSpecificCharacterSet = newDicomElement(DCM_SpecificCharacterSet);
    // ISO_IR 100 és Latin1
    elemSpecificCharacterSet->putString("ISO_IR 100");
    dcmDatasetToRetrieve->insert(elemSpecificCharacterSet, OFTrue);

    DcmElement *elem = newDicomElement(DCM_StudyInstanceUID);
    elem->putString(qPrintable(studyInstanceUID));
    dcmDatasetToRetrieve->insert(elem, OFTrue);

    if (!seriesInstanceUID.isEmpty())
    {
        DcmElement *elem = newDicomElement(DCM_SeriesInstanceUID);
        elem->putString(qPrintable(seriesInstanceUID));
        dcmDatasetToRetrieve->insert(elem, OFTrue);
        retrieveLevel = "SERIES";
    }

    if (!sopInstanceUID.isEmpty())
    {
        DcmElement *elem = newDicomElement(DCM_SOPInstanceUID);
        elem->putString(qPrintable(sopInstanceUID));
        dcmDatasetToRetrieve->insert(elem, OFTrue);
        retrieveLevel = "IMAGE";
    }

    // Especifiquem a quin nivell es fa el QueryRetrieve
    DcmElement *elemQueryRetrieveLevel = newDicomElement(DCM_QueryRetrieveLevel);
    elemQueryRetrieveLevel->putString(qPrintable(retrieveLevel));
    dcmDatasetToRetrieve->insert(elemQueryRetrieveLevel, OFTrue);

    return dcmDatasetToRetrieve;
}
开发者ID:chinhtrandn,项目名称:starviewer,代码行数:37,代码来源:retrievedicomfilesfrompacs.cpp

示例15: OFString

//------------------------------------------------------------------------------
bool ctkDICOMRetrievePrivate::retrieve ( QString UID, RetrieveType retriveType ) {

  if ( !this->RetrieveDatabase )
    {
    logger.error ( "Must have RetrieveDatabase for retrieve transaction" );
    return false;
    }

  // Register the JPEG libraries in case we need them
  //   (registration only happens once, so it's okay to call repeatedly)
  // register global JPEG decompression codecs
  DJDecoderRegistration::registerCodecs();
  // register global JPEG compression codecs
  DJEncoderRegistration::registerCodecs();
  // register RLE compression codec
  DcmRLEEncoderRegistration::registerCodecs();
  // register RLE decompression codec
  DcmRLEDecoderRegistration::registerCodecs();

  // Set the DCMTK log level
  log4cplus::Logger rootLogger = log4cplus::Logger::getRoot();
  rootLogger.setLogLevel(log4cplus::DEBUG_LOG_LEVEL);

  // TODO: use this->SCU instead ?
  DcmSCU scu;
  scu.setAETitle ( OFString(this->CallingAETitle.toStdString().c_str()) );
  scu.setPort ( this->CallingPort );
  scu.setPeerAETitle ( OFString(this->CalledAETitle.toStdString().c_str()) );
  scu.setPeerHostName ( OFString(this->Host.toStdString().c_str()) );
  scu.setPeerPort ( this->CalledPort );
  scu.setMoveDestinationAETitle ( OFString(this->MoveDestinationAETitle.toStdString().c_str()) );

  logger.info ( "Setting Transfer Syntaxes" );
  OFList<OFString> transferSyntaxes;
  transferSyntaxes.push_back ( UID_LittleEndianExplicitTransferSyntax );
  transferSyntaxes.push_back ( UID_BigEndianExplicitTransferSyntax );
  transferSyntaxes.push_back ( UID_LittleEndianImplicitTransferSyntax );
  scu.addPresentationContext ( UID_FINDStudyRootQueryRetrieveInformationModel, transferSyntaxes );
  scu.addPresentationContext ( UID_MOVEStudyRootQueryRetrieveInformationModel, transferSyntaxes );

  if ( !scu.initNetwork().good() ) 
    {
    logger.error ( "Error initializing the network" );
    return false;
    }
  logger.debug ( "Negotiating Association" );
  if ( !scu.negotiateAssociation().good() )
    {
    logger.error ( "Error negotiating association" );
    return false;;
    }

  logger.debug ( "Setting Parameters" );
  // Clear the query
  unsigned long elements = this->parameters->card();
  // Clean it out
  for ( unsigned long i = 0; i < elements; i++ ) 
    {
    this->parameters->remove ( 0ul );
    }
  if ( retriveType == RetrieveSeries )
    {
    this->parameters->putAndInsertString ( DCM_QueryRetrieveLevel, "SERIES" );
    this->parameters->putAndInsertString ( DCM_SeriesInstanceUID, UID.toStdString().c_str() );
    } 
  else
    {
    this->parameters->putAndInsertString ( DCM_QueryRetrieveLevel, "STUDY" );
    this->parameters->putAndInsertString ( DCM_StudyInstanceUID, UID.toStdString().c_str() );  
    }

  logger.debug ( "Sending Move Request" );
  MOVEResponses *responses = new MOVEResponses();
  OFCondition status = scu.sendMOVERequest ( 0, this->parameters, responses );
  if (!status.good())
    {
    logger.error ( "MOVE Request failed: " + QString ( status.text() ) );
    return false;
    }

  logger.debug ( "Find succeded" );

  logger.debug ( "Making Output Directory" );
  QDir directory = QDir( RetrieveDatabase->databaseDirectory() );

  if ( responses->begin() == responses->end() )
    {
    logger.error ( "No responses!" );
    throw std::runtime_error( std::string("No responses!") );
    }

  // Write the responses out to disk
  for ( OFListIterator(FINDResponse*) it = responses->begin(); it != responses->end(); it++ )
    {
    DcmDataset *dataset = (*it)->m_dataset;
    if ( dataset != NULL )
      {
      logger.debug ( "Got a valid dataset" );
      // Save in correct directory
//.........这里部分代码省略.........
开发者ID:mcaylus,项目名称:CTK,代码行数:101,代码来源:ctkDICOMRetrieve.cpp


注:本文中的DcmDataset类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。