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


C++ DcmFileFormat::loadFile方法代码示例

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


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

示例1: LOG

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);
  }
}
开发者ID:JanKolomaznik,项目名称:MedV4D,代码行数:32,代码来源:LocalService.cpp

示例2:

bool
ParserDicom::isValidFile(string filename)
{
    DcmFileFormat dcm;
    OFCondition cond = dcm.loadFile(filename.c_str());
    return cond.good();
}
开发者ID:jjalageas,项目名称:cpMoteur3D,代码行数:7,代码来源:ParserDicom.cpp

示例3: DetermineSopClass

void DicomImporter::DetermineSopClass(const String& _file)
{
	try
	{
		DcmFileFormat ff;
		ff.loadFile(_file.c_str());
		DcmMetaInfo *m = ff.getMetaInfo();
		
		DcmElement* elem = NULL;
		elem = DcmtkHelper::searchElement(m, 0002, 0002);

		std::string sopClass;
		if (elem != NULL)
		{
			sopClass = DcmtkConvert::DcmElementValueToString(elem);
		}
		else
		{
			return;
		}

		if (sopClass == "1.2.840.10008.1.3.10")
		{
			dicomdirFiles.push_back(_file);
		}
		else
		{
			nonDicomdirFiles.push_back(_file);
		}
	}
	catch (...)
	{
		throw;
	}
}
开发者ID:twissmueller,项目名称:dicmlib,代码行数:35,代码来源:DicomImporter.cpp

示例4: loadFileHeader

//------------------------------------------------------------------------------
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

示例5: CanReadFile

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;
}
开发者ID:fvichot,项目名称:medInria-public,代码行数:35,代码来源:itkDCMTKImageIO.cpp

示例6: load_dcmFiles

// 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

示例7: IsFileValid

bool DicomImporter::IsFileValid(const String& _file)
{
	try
	{
		//
		// create the dicom fileformat and check if this is possible
		//
		DcmFileFormat ff;
		OFCondition cond = ff.loadFile(_file.c_str());
		if (cond.bad()) return false;
	    
		//
		// ist it in part 10 format (does meta-header exist)?
		//
		DcmMetaInfo *m = ff.getMetaInfo();
		if (m == NULL || m->card() == 0) return false;

		//
		// does the file contain data (does the dataset exist)?
		//
		DcmDataset *d = ff.getDataset();
		if (d == NULL) return false;

		//
		// yes, it is a valid dicom file!
		//
		return true;
	}
	catch (...)
	{
		throw;
	}
}
开发者ID:twissmueller,项目名称:dicmlib,代码行数:33,代码来源:DicomImporter.cpp

示例8: opendir

Examen*
ParserDicom::loadFile(string dirName)
{
    // Open directory
    DIR* dir = opendir(dirName.c_str());
    if (dir == NULL) {
        return NULL;
    }

    // Get examen informations
    ExamenParams* params = getInfos(dir, dirName);
    if (params == NULL) {
        return NULL;
    }

    // Create struct examen
    Volume* img = new Volume(params->width, params->height, params->depth);
    Examen* exam = new Examen(img, params);

    // Read data
    int index = 0;
    struct dirent* file;
    rewinddir(dir);
    string pathDirectory = dirName + PATH_SEPARATOR;
    int tabSize = params->width * params->height;
    float tab[tabSize];
    while ((file = readdir(dir)) != NULL) {
        if (strcmp(file->d_name, ".") != 0 &&
                strcmp(file->d_name, "..") != 0) {
            string fullpath = pathDirectory + file->d_name;
            DcmFileFormat dcm;
            OFCondition cond = dcm.loadFile(fullpath.c_str());
            if (cond.bad()) {
                delete img;
                delete params;
                return NULL;
            }
            DiDocument* didoc = new DiDocument(fullpath.c_str());
            DiMono2Image* dimg = new DiMono2Image(didoc, EIS_Normal);
            OFString s;
            dcm.getDataset()->findAndGetOFString(DCM_BitsStored, s);
            int bitsStored = atoi(s.c_str());

            short* slice = (short*) dimg->getOutputData(0, bitsStored, 0);
            for(int i=0; i<tabSize; ++i) {
                tab[i] = (float) slice[i];
            }
            img->setSlice(tab, index++);
            delete dimg;
            delete didoc;
        }
    }
    closedir(dir);
    return exam;
}
开发者ID:jjalageas,项目名称:cpMoteur3D,代码行数:55,代码来源:ParserDicom.cpp

示例9: LoadRTDose

  mitk::DataNode::Pointer RTDoseReader::
      LoadRTDose(const char* filename)
  {
    DcmFileFormat fileformat;
    OFCondition outp = fileformat.loadFile(filename, EXS_Unknown);
    if(outp.bad())
    {
      MITK_ERROR << "Cant read the file" << std::endl;
    }
    DcmDataset *dataset = fileformat.getDataset();

    std::string name = filename;
    itk::FilenamesContainer file;
    file.push_back(name);

    mitk::DicomSeriesReader* reader = new mitk::DicomSeriesReader;

    mitk::DataNode::Pointer originalNode = reader->LoadDicomSeries(file,false);

    if(originalNode.IsNull())
    {
      MITK_ERROR << "Error reading the dcm file" << std::endl;
      return 0;
    }

    mitk::Image::Pointer originalImage
        = dynamic_cast<mitk::Image*>(originalNode->GetData());

    DRTDoseIOD doseObject;
    OFCondition result = doseObject.read(*dataset);

    if(result.bad())
    {
      MITK_ERROR << "Error reading the Dataset" << std::endl;
      return 0;
    }

    OFString gridScaling;
    Float32 gridscale;

    doseObject.getDoseGridScaling(gridScaling);
    gridscale = OFStandard::atof(gridScaling.c_str());

    AccessByItk_1(originalImage, MultiplayGridScaling, gridscale);

    double prescripeDose = this->GetMaxDoseValue(dataset);

    originalNode->SetName("RT Dose");
    originalNode->SetFloatProperty(mitk::Constants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str(),prescripeDose);
    originalNode->SetFloatProperty(mitk::Constants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), 40);
    originalNode->SetBoolProperty(mitk::Constants::DOSE_PROPERTY_NAME.c_str(),true);
    return originalNode;
  }
开发者ID:DiagnosisMultisystems,项目名称:MITK,代码行数:53,代码来源:mitkRTDoseReader.cpp

示例10: 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

示例11: main

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;
}
开发者ID:NavigationTest,项目名称:Navigation,代码行数:14,代码来源:DCMTest.cpp

示例12: loadDcmFile

int Opendcm::loadDcmFile()
{

        // OFCondition status;
        DcmFileFormat fileformat;
        fileformat.loadFile("/home/jeannypan/Documents/dcmtk_image/real_dicom.dcm");
        QString sopClass,;
        fileformat.getMetaInfo()->findAndGetString(DCM_MediaStorageSOPClassUID),sopClass





//        QString out;
//        string sopClass;
//        status= fileformat.loadFile("/home/jeannypan/Documents/dcmtk_image/real_dicom.dcm");
//        if (status.good())
//        {
//                OFString sopClassUID, xferUID;
//                //if(fileformat.getMetaInfo()->findAndGetString(DCM_MediaStorageSOPClassUID),sopClassUID).good())
//                if(fileformat.getMetaInfo()->findAndGetOFString(DCM_MediaStorageSOPClassUID,sopClassUID).good())

//                    //COUT << "SOP Class UID:" << sopClassUID << OFendl;
//                    sopClass =sopClassUID;
//                    sopClass = QString ::fromStdString(sopClass);
//                    //sopClass = QsopClassUID;
//                    //out="SOP Class UID:";
//                    //out += sopClass;

//                    ui->textEdit->setPlainText(sopClass);

//                //ui->textBrowser->out();

//                if(fileformat.getMetaInfo() ->findAndGetOFString(DCM_TransferSyntaxUID,xferUID).good())
//                    //COUT << "Transfer Syntax UID:" << xferUID << OFendl;
//                    out="SOP Class UID:";//+sopClassUID;
//                    ui->textEdit->setText(out);
//                //ui->textBrowser->out();
//                //fileformat.print(out);

//        } else
//        //cerr << "Error: cannot read DICOM file"<<status.text()<<endl;
//            out="Error: cannot read DICOM file";//+sopClassUID;
//            ui->textEdit->setPlainText(out);
//        //ui->textBrowser->out();


               return 0;

}
开发者ID:panjeanny,项目名称:LoadRTdcmPointer,代码行数:50,代码来源:opendcm.cpp

示例13: get_patientname

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 "fuck";
}
开发者ID:fengbs,项目名称:Dicom,代码行数:15,代码来源:ImageMatrix.cpp

示例14: 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

示例15: InitializeFromFile

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);
}
开发者ID:Koki-Shimizu,项目名称:CTK,代码行数:21,代码来源:ctkDICOMDataset.cpp


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