本文整理汇总了C++中OFString类的典型用法代码示例。如果您正苦于以下问题:C++ OFString类的具体用法?C++ OFString怎么用?C++ OFString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OFString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetKey
const char* Association::GetKey(DcmDataset* query, const DcmTagKey& tag) {
OFString val;
static char buffer[129];
query->findAndGetOFString(tag, val, 0, OFTrue);
strncpy(buffer, val.c_str(), sizeof(buffer));
return buffer;
}
示例2: GetDicomFormatedDate
std::string Date::GetDicomFormatedDate() const
{
OFString formattedDate;
AIMUtil::DateConvert(*this).getISOFormattedDate(formattedDate, false); // can be empty
return formattedDate.c_str();
}
示例3: toSeriesInstanceUIDContainer
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;
}
示例4: GetDicomFormatedTime
std::string Time::GetDicomFormatedTime() const
{
OFString formattedTime;
AIMUtil::TimeConvert(*this).getISOFormattedTime(formattedTime, true, false, false, false); // can be empty
return formattedTime.c_str();
}
示例5: copyStringWithDefault
// 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);
}
}
示例6: FillInstance
void FillInstance(DcmDirectoryRecord& record,
DcmItem& dicom,
DcmMetaInfo& metaInfo,
const char* path)
{
// cf. "DicomDirInterface::buildImageRecord()"
/* copy attribute values from dataset to image record */
copyElementType1(dicom, DCM_InstanceNumber, record);
//copyElementType1C(dicom, DCM_ImageType, record);
copyElementType1C(dicom, DCM_ReferencedImageSequence, record);
OFString tmp;
DcmElement* item = record.remove(DCM_ReferencedImageSequence);
if (item != NULL)
{
delete item;
}
if (record.putAndInsertString(DCM_ReferencedFileID, path).bad() ||
dicom.findAndGetOFStringArray(DCM_SOPClassUID, tmp).bad() ||
record.putAndInsertString(DCM_ReferencedSOPClassUIDInFile, tmp.c_str()).bad() ||
dicom.findAndGetOFStringArray(DCM_SOPInstanceUID, tmp).bad() ||
record.putAndInsertString(DCM_ReferencedSOPInstanceUIDInFile, tmp.c_str()).bad() ||
metaInfo.findAndGetOFStringArray(DCM_TransferSyntaxUID, tmp).bad() ||
record.putAndInsertString(DCM_ReferencedTransferSyntaxUIDInFile, tmp.c_str()).bad())
{
throw OrthancException(ErrorCode_BadFileFormat);
}
}
示例7:
void
FindService::WholeStudyInfoCallback(
void *callbackData,
T_DIMSE_C_FindRQ * /*request*/,
int /*responseCount*/,
T_DIMSE_C_FindRSP * /*rsp*/,
DcmDataset *responseIdentifiers
)
/*
* This function.is used to indicate progress when findscu receives search results over the
* network. This function will simply cause some information to be dumped to stdout.
*
* Parameters:
* callbackData - [in] data for this callback function
* request - [in] The original find request message.
* responseCount - [in] Specifies how many C-FIND-RSP were received including the current one.
* rsp - [in] the C-FIND-RSP message which was received shortly before the call to
* this function.
* responseIdentifiers - [in] Contains the record which was received. This record matches the search
* mask of the C-FIND-RQ which was sent.
*/
{
OFString str;
std::string imageID;
std::string setID;
// Parse the response
responseIdentifiers->findAndGetOFString( DCM_SOPInstanceUID, str);
imageID = str.c_str();
responseIdentifiers->findAndGetOFString( DCM_SeriesInstanceUID, str);
setID = str.c_str();
// get container that recieved values should go into
StudyInfo *setInfo =
static_cast<StudyInfo*>(callbackData);
StringVector *setImages;
// try to find if there is already just recieved setID within the container
StudyInfo::iterator it =
setInfo->find( setID);
if( it == setInfo->end() )
{
// create new StringVector & insert it into setInfo
StringVector buddy;
setInfo->insert(
StudyInfo::value_type( setID, buddy) );
setImages = &setInfo->find( setID)->second;
}
else
{
setImages = &it->second;
}
// insert imageID
setImages->push_back( imageID);
D_PRINT( "Next record into study info arrived ...");
}
示例8: BOOST_FIXTURE_TEST_CASE
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");
}
示例9: 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;
}
示例10: 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;
}
示例11: GetKey
const char* Association::GetKey(DcmDataset* query, const DcmTagKey& tag)
{
OFString val;
static char buffer[129];
query->findAndGetOFString(tag, val, 0, OFTrue);
#if defined(_WINDOWS)
strncpy_s(buffer, val.c_str(), sizeof (buffer) - 1);
#else
strncpy(buffer, val.c_str(), sizeof (buffer) - 1);
#endif
buffer[sizeof (buffer) - 1] = 0;
return buffer;
}
示例12: 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;
}
示例13: create_query_series
Glib::RefPtr< ImagePool::Series > create_query_series(DcmDataset* dset) {
Glib::RefPtr< ImagePool::Series > result = Glib::RefPtr< ImagePool::Series >(new Series);
OFString seriesUID;
OFString desc;
OFString ofstr;
dset->findAndGetOFString(DCM_SeriesInstanceUID, seriesUID);
dset->findAndGetOFString(DCM_SeriesDescription, desc);
if(result->m_description.empty()) {
dset->findAndGetOFString(DCM_StudyDescription, desc);
}
result->m_seriesinstanceuid = seriesUID.c_str();
result->m_description = desc.c_str();
if(result->m_description.empty()) {
result->m_description = gettext("no description");
}
dset->findAndGetOFString(DCM_Modality, ofstr);
result->m_modality = ofstr.c_str();
dset->findAndGetOFString(DCM_SeriesTime, ofstr);
result->m_seriestime = ofstr.c_str();
if(result->m_seriestime.empty()) {
dset->findAndGetOFString(DCM_StudyTime, ofstr);
result->m_seriestime = ofstr.c_str();
}
dset->findAndGetOFString(DCM_StationName, ofstr);
result->m_stationname = ofstr.c_str();
dset->findAndGetOFString(DCM_NumberOfSeriesRelatedInstances, ofstr);
int i = atoi(ofstr.c_str());
if(i != 0) {
result->m_instancecount = i;
}
fix_time(result->m_seriestime);
return result;
}
示例14: find_study
DcmDirectoryRecord* DicomdirLoader::find_study(const std::string &studyinstanceuid, class DcmDicomDir &dir) {
DcmDirectoryRecord *patRec;
DcmDirectoryRecord *studyRec;
OFCondition ret;
DcmDirectoryRecord &root = dir.getRootRecord();
for ( patRec = root.nextSub(NULL); patRec != NULL; patRec = root.nextSub(patRec) ) {
if ( patRec->getRecordType() == ERT_Patient ) {
for ( studyRec = patRec->nextSub(NULL); studyRec; studyRec = patRec->nextSub(studyRec) ) {
if ( studyRec->getRecordType()==ERT_Study ) {
OFString uid;
if ( studyRec->findAndGetOFString(DCM_StudyInstanceUID, uid)==EC_Normal ) {
if ( studyinstanceuid == uid.c_str() )
return studyRec;
}
}
}
}
}
return NULL;
}
示例15: Q_D
void ctkDICOMDataset::InitializeFromDataset(DcmDataset* dataset, bool takeOwnership)
{
Q_D(ctkDICOMDataset);
if(d->m_DcmDataset != dataset)
{
if (d->m_TakeOwnership)
{
delete d->m_DcmDataset;
}
d->m_DcmDataset = NULL;
}
if (dataset)
{
d->m_DcmDataset=dataset;
d->m_TakeOwnership = takeOwnership;
if (!d->m_DICOMDataSetInitialized)
{
d->m_DICOMDataSetInitialized = true;
OFString encoding;
if ( CheckCondition( dataset->findAndGetOFString(DCM_SpecificCharacterSet, encoding) ) )
{
d->m_SpecificCharacterSet = encoding.c_str();
}
}
if (d->m_SpecificCharacterSet.isEmpty())
{
///
/// see Bug # 6458:
/// There are cases, where different studies of the same person get encoded both with and without the SpecificCharacterSet attribute set.
/// DICOM says: default is ASCII / ISO_IR 6 / ISO 646
/// Since we experienced such mixed data, we supplement missing characterset information with the ISO_IR 100 / Latin1 character set.
/// Since Latin1 is a superset of ASCII, this will not cause problems. PLUS in most cases (Europe) we will guess right and suppress
/// "double patients" in applications.
///
SetElementAsString( DCM_SpecificCharacterSet, "ISO_IR 100" );
}
}
}