예제 #1
0
OFCondition Association::Drop(OFCondition cond) {
	// tear down association
	if(cond == EC_Normal) {
		/* release association */
		cond = ASC_releaseAssociation(assoc);
	}
	else if(cond == DUL_PEERREQUESTEDRELEASE) {
		cond = ASC_abortAssociation(assoc);
		if (cond.good()) {
			return cond;
		}
	}
	else if(cond == DUL_PEERABORTEDASSOCIATION) {
		return cond;
	}
	else {
		cond = ASC_abortAssociation(assoc);
		if (cond.good()) {
			return cond;
		}
	}

	Destroy();
	return cond;
}
예제 #2
0
 // copy element from dataset to directory record
 static void copyElement(DcmItem& dataset,
                         const DcmTagKey &key,
                         DcmDirectoryRecord& record,
                         const OFBool optional,
                         const OFBool copyEmpty)
 {
   /* check whether tag exists in source dataset (if optional) */
   if (!optional || (copyEmpty && dataset.tagExists(key)) || dataset.tagExistsWithValue(key))
   {
     DcmElement *delem = NULL;
     /* get copy of element from source dataset */
     OFCondition status = dataset.findAndGetElement(key, delem, OFFalse /*searchIntoSub*/, OFTrue /*createCopy*/);
     if (status.good())
     {
       /* ... and insert it into the destination dataset (record) */
       status = record.insert(delem, OFTrue /*replaceOld*/);
       if (status.good())
       {
         DcmTag tag(key);
         /* check for correct VR in the dataset */
         if (delem->getVR() != tag.getEVR())
         {
           /* create warning message */
           LOG(WARNING) << "DICOMDIR: possibly wrong VR: "
                        << tag.getTagName() << " " << key << " with "
                        << DcmVR(delem->getVR()).getVRName() << " found, expected "
                        << tag.getVRName() << " instead";
         }
       } else
         delete delem;
     } else if (status == EC_TagNotFound)
       status = record.insertEmptyElement(key);
     printAttributeErrorMessage(key, status, "insert");
   }
 }
OFCondition RetrieveDICOMFilesFromPACS::acceptSubAssociation(T_ASC_Network *associationNetwork, T_ASC_Association **association)
{
    const char *knownAbstractSyntaxes[] = { UID_VerificationSOPClass };
    const char *transferSyntaxes[] = { NULL, NULL, NULL, NULL };
    int numTransferSyntaxes;

    OFCondition condition = ASC_receiveAssociation(associationNetwork, association, ASC_DEFAULTMAXPDU);

    if (condition.good())
    {
#ifndef DISABLE_COMPRESSION_EXTENSION
        // Si disposem de compressió la demanem, i podrem accelerar el temps de descàrrega considerablement
        // De moment demanem la compressió lossless que tot PACS que suporti compressió ha
        // de proporcionar: JPEGLossless:Non-Hierarchical-1stOrderPrediction
        transferSyntaxes[0] = UID_JPEGProcess14SV1TransferSyntax;
        transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
        transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
        transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
        numTransferSyntaxes = 4;
#else
        // Defined in dcxfer.h
        if (gLocalByteOrder == EBO_LittleEndian)
        {
        transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax;
        transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax;
        }
        else
        {
        transferSyntaxes[0] = UID_BigEndianExplicitTransferSyntax;
        transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
        }
        transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax;
        numTransferSyntaxes = 3;
#endif

        // Accept the Verification SOP Class if presented
        condition = ASC_acceptContextsWithPreferredTransferSyntaxes((*association)->params, knownAbstractSyntaxes, DIM_OF(knownAbstractSyntaxes),
                                                                    transferSyntaxes, numTransferSyntaxes);

        if (condition.good())
        {
            // The array of Storage SOP Class UIDs comes from dcuid.h
            condition = ASC_acceptContextsWithPreferredTransferSyntaxes((*association)->params, dcmAllStorageSOPClassUIDs, numberOfAllDcmStorageSOPClassUIDs,
                                                                        transferSyntaxes, numTransferSyntaxes);
        }
    }

    if (condition.good())
    {
        condition = ASC_acknowledgeAssociation(*association);
    }
    else
    {
        ASC_dropAssociation(*association);
        ASC_destroyAssociation(association);
    }
    return condition;
}
예제 #4
0
void
LocalService::SolveFile( 
  const boost::filesystem::path & fileName, const boost::filesystem::path & path,
  ResultSet &result)
{
  OFString ofStr;

  DcmFileFormat dfile;
  OFCondition cond = dfile.loadFile( fileName.string().data());
  if (! cond.good())
  {
    LOG( "Loading of " << fileName << " failed. ("  << cond.text() << ")" );
    return;
  }

  DcmDataset *dataSet = dfile.getDataset();

  TableRow row;
  SerieInfo serInfo;

  // load data and check if it is already in tree
  CheckDataSet( dataSet, serInfo, row, path.string());

  // look if this row is already in resultSet
  FoundStudiesSet::iterator found = m_alreadyFoundInRun.find(row.studyID);
  // if not, add it
  if( found == m_alreadyFoundInRun.end() )
  {
    m_alreadyFoundInRun.insert( FoundStudiesSet::value_type( row.studyID) );
    result.push_back( row);
  }
}
// Caller is responsible for deallocating returned object
AnnotationCollection* DcmModel::ReadAnnotationCollectionFromFile(const std::string& fileName){
	DcmModelInternal dcmModelInternal(_uidPrefix);

	AnnotationCollection* pCollection = NULL;
	try
	{
		OFCondition ofCondition = dcmModelInternal.ReadDocFromFile(&pCollection, fileName);
		if (!ofCondition.good())
		{
			if (pCollection){
				delete pCollection;
				pCollection = NULL;
			}
			std::string err = std::string("Failed to load SR from file <").append(fileName).append(">:");
			err += ofCondition.text();
			dcmModelInternal.printDebug(std::string(__FILE__).append(": ").append(err).c_str());
		}
	}
	catch(const std::exception& ex)
	{
		std::string err = std::string("Error loading SR from file<").append(fileName).append(">:");
		err += ex.what();
		dcmModelInternal.printDebug(err.c_str());
	}
	return pCollection;
}
예제 #6
0
 // copy optional string value from dataset to directory record
 static void copyStringWithDefault(DcmItem& dataset,
                                   const DcmTagKey &key,
                                   DcmDirectoryRecord& record,
                                   const char *defaultValue,
                                   const OFBool printWarning)
 {
     OFCondition status;
     if (dataset.tagExistsWithValue(key))
     {
       OFString stringValue;
       /* retrieve string value from source dataset and put it into the destination dataset */
       status = dataset.findAndGetOFStringArray(key, stringValue);
       if (status.good())
         status = record.putAndInsertString(key, stringValue.c_str());
     } else {
       if (printWarning && (defaultValue != NULL))
       {
         /* create warning message */
         LOG(WARNING) << "DICOMDIR: " << DcmTag(key).getTagName() << " "
                      << key << " missing, using alternative: " << defaultValue;
       }
       /* put default value */
       status = record.putAndInsertString(key, defaultValue);
     }
 }
예제 #7
0
bool DCMTKImageIO::CanReadFile(const char* filename)
{
    DcmFileFormat dicomFile;
    OFCondition condition = dicomFile.loadFile( filename );
    if ( !condition.good() ) {
        return false;
    }

    E_TransferSyntax xfer = dicomFile.getDataset()->getOriginalXfer();

    if( xfer == EXS_JPEG2000LosslessOnly ||
        xfer == EXS_JPEG2000 ||
        xfer == EXS_JPEG2000MulticomponentLosslessOnly ||
        xfer == EXS_JPEG2000Multicomponent ) {
        return false;
    }

    // search for mandatory tags
    DcmStack stack;
    DcmTagKey searchKey;
    unsigned int group = 0x0028; // samples per pixel
    unsigned int elem  = 0x0002; // samples per pixel

    searchKey.set(group, elem);
    if (dicomFile.search(searchKey, stack, ESM_fromHere, OFTrue) != EC_Normal)
        return false;

    group = 0x0028; // pixel type
    elem  = 0x0100; // pixel type
    searchKey.set(group, elem);
    if (dicomFile.search(searchKey, stack, ESM_fromHere, OFTrue) != EC_Normal)
        return false;

    return true;
}
예제 #8
0
//------------------------------------------------------------------------------
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;
}
예제 #9
0
bool EchoToPACS::echo(PacsDevice pacsDevice)
{
    PACSConnection pacsConnection(pacsDevice);

    /// Es fa la connexió connexió
    if (connectToPACS(&pacsConnection))
    {
        /// Es fa un echo al pacs
        OFCondition condition = echoToPACS(&pacsConnection);
        
        /// Desconnexió
        disconnectFromPACS(&pacsConnection);
        
        if (condition.good())
        {
            m_lastError = EchoOk;
        }
        else
        {
            ERROR_LOG("Doing echo to " + pacsDevice.getAETitle() + " does not respond correctly. Error description: " + condition.text());
            m_lastError = EchoFailed;
        }
    }
    else
    {
        INFO_LOG("Doing echo to " + pacsDevice.getAETitle() + " does not respond.");
        m_lastError = EchoCanNotConnectToPACS;
    }

    return m_lastError == EchoOk;
}
예제 #10
0
OFCondition GIL::DICOM::DCMTK::Network::InitializeNetwork(int timeout, Association::RoleType role, int port)
{

    if (m_pDCMTKNetwork != NULL) {
        LOG_WARN("DICOMNetwork", "Shutting down previous initiallized network");
        DropNetwork();
    }

    OFCondition cond;

    switch (role) {
    case Association::RT_Acceptor:
        cond = ASC_initializeNetwork(NET_ACCEPTOR, 0, timeout, &m_pDCMTKNetwork);
        break;
    case Association::RT_Requestor:
        cond = ASC_initializeNetwork(NET_REQUESTOR, port, timeout, &m_pDCMTKNetwork);
        break;
    case Association::RT_AcceptorRequestor:
        cond = ASC_initializeNetwork(NET_ACCEPTORREQUESTOR, port, timeout, &m_pDCMTKNetwork);
        break;
    default:
        cond = EC_IllegalParameter;
        break;
    }
    m_Initiallized = cond.good();
    return cond;
}
예제 #11
0
Series::InstanceUIDContainer Series::toSeriesInstanceUIDContainer(OFList< QRResponse* > responses)
{
    InstanceUIDContainer instanceUIDContainer;

    OFIterator< QRResponse* > it;
    DcmDataset dataset;
    OFCondition result;
    // Every while loop run will get all image for a specific study
    for (it = responses.begin(); it != responses.end(); ++it)
    {
        // Be sure we are not in the last response which does not have a dataset
        if ((*it)->m_dataset != NULL)
        {
            OFString seriesInstanceUID;
            result = (*it)->m_dataset->findAndGetOFStringArray(DCM_SeriesInstanceUID, seriesInstanceUID);
            // Only try to get study if we actually have study instance uid, otherwise skip it
            if (result.good())
            {
                instanceUIDContainer.push_back(seriesInstanceUID.c_str());
            }
            else
            {
                const std::string msg = "There is no \"SeriersInstanceUID\" tag in the selected series :"
                                        + std::string(result.text());
                throw ::fwPacsIO::exceptions::TagMissing(msg);
            }
        }
    }


    return instanceUIDContainer;
}
void RetrieveDICOMFilesFromPACS::subOperationCallback(void *subOperationCallbackData, T_ASC_Network *associationNetwork, T_ASC_Association **subAssociation)
{
    RetrieveDICOMFilesFromPACS *retrieveDICOMFilesFromPACS = (RetrieveDICOMFilesFromPACS*)subOperationCallbackData;
    if (associationNetwork == NULL)
    {
        // Help no net !
        return;
    }

    if (*subAssociation == NULL)
    {
        OFCondition condition = retrieveDICOMFilesFromPACS->acceptSubAssociation(associationNetwork, subAssociation);
        if (!condition.good())
        {
            ERROR_LOG("S'ha produit un error negociant l'associacio de la connexio DICOM entrant, descripcio error: " + QString(condition.text()));
        }
        else
        {
            INFO_LOG("Rebuda solicitud de connexio pel port de connexions DICOM entrants del PACS.");
        }
    }
    else
    {
        retrieveDICOMFilesFromPACS->subOperationSCP(subAssociation);
    }
}
예제 #13
0
bool
ParserDicom::isValidFile(string filename)
{
    DcmFileFormat dcm;
    OFCondition cond = dcm.loadFile(filename.c_str());
    return cond.good();
}
예제 #14
0
// 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);

    }
}
예제 #15
0
OFCondition Network::addAllStoragePresentationContexts(T_ASC_Parameters *params, bool bProposeCompression, int lossy)
{
    OFCondition cond = EC_Normal;
    int i;
    int pid = 1;

    /* 
    ** We prefer to accept Explicitly encoded transfer syntaxes.
    ** If we are running on a Little Endian machine we prefer 
    ** LittleEndianExplicitTransferSyntax to BigEndianTransferSyntax.
    ** Some SCP implementations will just select the first transfer
    ** syntax they support (this is not part of the standard) so
    ** organise the proposed transfer syntaxes to take advantage
    ** of such behaviour.
    */

	const char** transferSyntaxes;
	int transferSyntaxes_count;
    const char* const_transferSyntaxes[] = {UID_JPEGProcess14SV1TransferSyntax, NULL, NULL, UID_LittleEndianImplicitTransferSyntax };

	if(bProposeCompression) {
		if(lossy == 8) {
			const_transferSyntaxes[0] = UID_JPEGProcess1TransferSyntax;
		}
		
		if(lossy == 12) {
			const_transferSyntaxes[0] = UID_JPEGProcess2_4TransferSyntax;
		}
	}
	
    /* gLocalByteOrder is defined in dcxfer.h */
    if (gLocalByteOrder == EBO_LittleEndian) {
		/* we are on a little endian machine */
		const_transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
		const_transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
    } else {
		/* we are on a big endian machine */
		const_transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax;
		const_transferSyntaxes[2] = UID_LittleEndianExplicitTransferSyntax;
    }

	if(bProposeCompression) {
		transferSyntaxes = &const_transferSyntaxes[0];
		transferSyntaxes_count = DIM_OF(const_transferSyntaxes);
	}
	else {
		transferSyntaxes = &const_transferSyntaxes[1];
		transferSyntaxes_count = DIM_OF(const_transferSyntaxes)-1;
	}

	/* the array of Storage SOP Class UIDs comes from dcuid.h */
	for (i=0; i<numberOfAllDcmStorageSOPClassUIDs && cond.good(); i++) {
		cond = ASC_addPresentationContext(params, pid, dcmAllStorageSOPClassUIDs[i], transferSyntaxes, transferSyntaxes_count);
		pid += 2;	/* only odd presentation context id's */
	}

    return cond;
}
예제 #16
0
BOOST_FIXTURE_TEST_CASE(SetEmpty, Fixture)
{
    odil::dcmtk::ElementAccessor<std::string>::set(this->dataset, DCM_PatientName, "FOO");
    OFString value;
    OFCondition const condition =
        this->dataset.findAndGetOFString(DCM_PatientName, value);
    BOOST_REQUIRE(condition.good());
    BOOST_CHECK_EQUAL(std::string(value.c_str()), "FOO");
}
예제 #17
0
bool ctkDICOMDataset::CheckCondition(const OFCondition& condition)
{
  if ( condition.bad() )
  {
    //std::cerr << "Bad return code (" << condition.code() << "): " << condition.text() << std::endl;
  }

  return condition.good();
}
예제 #18
0
bool Association::SendEchoRequest()
{
	DIC_US status;
	DcmDataset *statusDetail = NULL;

	OFCondition cond = DIMSE_echoUser(assoc, ++msgId, DIMSE_BLOCKING, 0, &status, &statusDetail);
	if (cond.good()) {
		std::cout << "Complete [Status: " << DU_cstoreStatusString(status) << "]" << std::endl;
	} else {
		std::cout << "Failed:" << std::endl;
		DimseCondition::dump(cond);
	}
 
	if(statusDetail != NULL) {
		delete statusDetail;
	}

	return cond.good();
}
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);
}
예제 #20
0
int main(void)
{
	DcmFileFormat fileformat;
	OFCondition oc = fileformat.loadFile("D:\\021A3C1C.dcm");
	if(oc.good())
	{
		OFString patientName;
		if(fileformat.getDataset()->findAndGetOFString(DCM_PatientName, patientName).good())
		{
			std::cout<<"Patient Name:"<<patientName<<std::endl;
		}
	}
	return 0;
}
bool CDicomHeader::LoadFromFile(const char *fileName)
{

	OFCondition status = iDicomFile->loadFile(fileName);
	if ( status.good() )
	{
		iDcmFileFormatLoaded=true;
		return true;
	}
	iDcmFileFormatLoaded=false;
	

	return false;
}
예제 #22
0
std::string ImageMatrix::get_patientname(const std::string & dirpath){
	std::string filepath = dirpath + "\\ADC\\ADC_1";
	DcmFileFormat *pDicomFile = new DcmFileFormat();
	OFCondition oc = pDicomFile->loadFile(filepath.c_str());
	if(oc.good()){
		DcmDataset *pDataset = pDicomFile->getDataset();
		const char * name;
		pDataset -> findAndGetString(DCM_PatientName, name);
		std::string res(name);
		delete pDataset;
		return res;
	}
	else
	return "f**k";
}
예제 #23
0
const DcmElement * tissuestack::imaging::DicomFileWrapper::findDcmElement(
	const DcmDataset * dataSet, const DcmTagKey & tagKey) const
{
	DcmStack stack;
	OFCondition status = const_cast<DcmDataset *>(dataSet)->nextObject(stack, OFTrue);
	while (status.good())
	{
		const  DcmObject * dobject = stack.top();
		const DcmElement * delem = (DcmElement *) dobject;
		if (delem->getTag().getXTag() == tagKey)
			return delem;

		status = const_cast<DcmDataset *>(dataSet)->nextObject(stack, OFTrue);
	}

	return nullptr;
}
예제 #24
0
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";
    }
}
예제 #25
0
T_ASC_Network* PACSConnection::initializeAssociationNetwork(PACSServiceToRequest pacsServiceToRequest)
{
    Settings settings;
    // Si no es tracta d'una descarrega indiquem port 0
    int networkPort = pacsServiceToRequest == RetrieveDICOMFiles ? settings.getValue(InputOutputSettings::IncomingDICOMConnectionsPort).toInt() : 0;
    int timeout = settings.getValue(InputOutputSettings::PACSConnectionTimeout).toInt();
    T_ASC_NetworkRole networkRole = pacsServiceToRequest == RetrieveDICOMFiles ? NET_ACCEPTORREQUESTOR : NET_REQUESTOR;
    T_ASC_Network *associationNetwork;

    OFCondition condition = ASC_initializeNetwork(networkRole, networkPort, timeout, &associationNetwork);
    if (!condition.good())
    {
        ERROR_LOG("No s'ha pogut inicialitzar l'objecte network, despripcio error" + QString(condition.text()));
        return NULL;
    }

    return associationNetwork;
}
예제 #26
0
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;
}
예제 #27
0
void
LocalService::SolveFileGET( const boost::filesystem::path & fileName,
  const std::string &patientID,
	const std::string &studyID,
	const std::string &serieID,
  DicomObjSet &result,
  const std::string &path)
{
  OFString ofStr;

  DcmFileFormat dfile;
  OFCondition cond = dfile.loadFile( fileName.string().data());
  if (! cond.good())
  {
    LOG( "Loading of " << fileName << " failed. ("  << cond.text() << ")" );
    return;
  }

  DcmDataset *dataSet = dfile.getDataset();

  TableRow row;
  SerieInfo serInfo;

  // load data and check if it is already in tree
  CheckDataSet( dataSet, serInfo, row, path);

  // compare with wantend ones
  if( row.patientID == patientID
    && row.studyID == studyID
    && serInfo.id == serieID)
  {
    // if it mathes, insert new image into result
    DicomObj buddy;
    result.push_back( buddy);

    // copy dataset reference & init
    DicomObj *newOne = &result.back();
    newOne->Load( fileName.string() );
    newOne->Init();
  }
}
예제 #28
0
void ctkDICOMDataset::InitializeFromFile(const QString& filename,
                                         const E_TransferSyntax readXfer,
                                         const E_GrpLenEncoding groupLength,
                                         const Uint32 maxReadLength,
                                         const E_FileReadMode readMode)
{
  DcmDataset *dataset;

  DcmFileFormat fileformat;
  OFCondition status = fileformat.loadFile(filename.toAscii().data(), readXfer, groupLength, maxReadLength, readMode);
  dataset = fileformat.getAndRemoveDataset();

  if (!status.good())
  {
    qDebug() << "Could not load " << filename << "\nDCMTK says: " << status.text();
    delete dataset;
    return;
  }

  InitializeFromDataset(dataset, true);
}
예제 #29
0
OFCondition GIL::DICOM::DCMTK::Network::ConnectAssociation(Association* assoc, int pdu)
{
    GNC::GCS::ILocker lock(m_sLock);
    OFCondition cond;

    cond = ASC_ConnectAssociation(
               assoc,
               assoc->m_calledAET,
               assoc->m_calledPeer,
               assoc->m_calledPort,
               assoc->m_ourAET,
               pdu);
    if (!cond.good()) {
        assoc->Drop(cond);
        return cond;
    }

    assoc->Net = this;
    assoc->msgId = assoc->assoc->nextMsgID;

    return cond;
}
예제 #30
0
OFCondition Network::ConnectAssociation(Association* assoc, int lossy) {
	OFCondition cond;

	cond = ASC_ConnectAssociation(
						assoc,
						assoc->m_calledAET,
						assoc->m_calledPeer,
						assoc->m_calledPort,
						assoc->m_ourAET,
						assoc->m_abstractSyntax,
						lossy);

	if (!cond.good()) {
		assoc->Drop(cond);
		return cond;
	}

	assoc->dcmNet = this;
	assoc->msgId = assoc->assoc->nextMsgID; //++;
	
	return cond;
}