Beispiel #1
0
void test_element_from_odil(
    TInputType const & source_value,
    TInputType const & (odil::Element::*getter)() const)
{
    odil::Tag const source_tag(0xdead, 0xbeef);
    DcmTagKey const destination_tag = odil::dcmtk::convert(source_tag);

    odil::Element const source(source_value, VVR);

    DcmElement * destination = odil::dcmtk::convert(source_tag, source);
    BOOST_CHECK_NE(destination, (DcmElement const *)(NULL));

    BOOST_CHECK_EQUAL(destination->getVR(), VEVR);
    BOOST_CHECK_NE(
        dynamic_cast<TOutputType *>(destination), (TOutputType *)(NULL));

    BOOST_CHECK_EQUAL(destination->getVM(), source.size());
    for(std::size_t i=0; i<source.size(); ++i)
    {
        typedef typename odil::dcmtk::VRTraits<VEVR>::ValueType ValueType;
        if(typeid(TInputType) == typeid(odil::Value::Reals))
        {
            compare<ValueType>(
                odil::dcmtk::ElementAccessor<ValueType>::element_get(*destination, i),
                (source.*getter)()[i]);
        }
        else
        {
            BOOST_CHECK_EQUAL(
                odil::dcmtk::ElementAccessor<ValueType>::element_get(*destination, i),
                (source.*getter)()[i]);
        }
    }
}
Beispiel #2
0
    // Loads all dicom file in m_FileList
    // Initializes m_Cache
    // returns true if viewable files found, otherwise false
    bool DicomdirLoader::scan_study(const std::string &studyinstanceuid, class DcmDirectoryRecord *studyRec, const Glib::ustring &dicomdir) {
        DcmDirectoryRecord *seriesRec;
        DcmDirectoryRecord *sopRec;
        std::string path;
        std::string file;

        assert(studyRec->getRecordType()==ERT_Study);

        path = Glib::path_get_dirname(dicomdir);
        seriesRec = studyRec->nextSub(NULL);
        while ( seriesRec ) {
            OFString modality;

            if ( seriesRec->findAndGetOFString(DCM_Modality, modality) == EC_Normal ) {
                OFString seriesinstanceuid;
                if ( seriesRec->findAndGetOFString(DCM_SeriesInstanceUID, seriesinstanceuid) != EC_Normal ) {
                    seriesRec = studyRec->nextSub(seriesRec);
                    continue;
                }

                if ( ImageModalities.find(modality.c_str()) != std::string::npos  ) {
                    // Load Series...
                    OFString fileID;
                    int vm;
                    int i;
                    DcmElement *el;
                    for (sopRec = seriesRec->nextSub(NULL); sopRec; sopRec = seriesRec->nextSub(sopRec) ) {
                        switch ( sopRec->getRecordType() ) {
                        case ERT_Image:
                        case ERT_StoredPrint:
                            if ( sopRec->findAndGetElement(DCM_ReferencedFileID, el, true)!=EC_Normal ) {
                                sopRec = seriesRec->nextSub(sopRec);
                                continue;
                            }
                            vm = el->getVM();
                            file = "";
                            for ( i=0; i<vm; i++ ) {
                                el->getOFString(fileID, i);
                                file = file + "/" + fileID.c_str();
                            }

                            if ( file.size() > 0 ) {
                                std::cout << "Loading DICOMDIR file [" << path.c_str() << file.c_str() << "]" << std::endl;
                                m_filelist->push_back(path + file);

                                std::string SeriesUID = seriesinstanceuid.c_str();
                                m_cache[studyinstanceuid].m_instancecount++;
                                m_cache[studyinstanceuid].m_seriesuid.insert(SeriesUID);
                                m_cache[studyinstanceuid].m_seriescount = m_cache[studyinstanceuid].m_seriesuid.size();
                            }
                            break;
                        default:
                            break;
                        }
                    }
                }
            }
            seriesRec = studyRec->nextSub(seriesRec);
        }
        return true;
    }