示例#1
0
/*
 * 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();
}
DcmElement* DcmtkHelper::searchElement(DcmObject* _object, unsigned int _group, unsigned int _element)
{
	try
	{
		if (_object == NULL)
		{
			throw DicomLibException("No data!", __FILE__, __LINE__);
		}

		DcmTagKey searchKey;
		searchKey.set(_group, _element);

		DcmStack stack;

		_object -> search(searchKey, stack, ESM_fromHere, OFTrue);

		DcmElement* element = NULL;
		element = reinterpret_cast<DcmElement*>(stack.elem(0));

		return element;
	}
	catch (...)
	{
		throw;
	}
}
示例#3
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;
}
示例#4
0
文件: prelude.cpp 项目: xorgy/dcm
void cbDef(DcmStack& stk) {
    DcmExec *exec = static_cast<DcmExec*>(safePeekMain(stk,
      {DcmExec::typeVal()}));
    stk.pop();
    stk.push(new DcmPrimFun(new ExecCallback(exec)));
    // We took it off the stack
    del(exec);
}
DcmStack FindAssociation::CopyResultStack()
{
        DcmStack copy;

        for (unsigned int i = 0; i < result.card(); i++) {
                DcmDataset* dset = new DcmDataset( *(static_cast<DcmDataset*>(result.elem(i))) );
                copy.push(dset);
        }

        return copy;
}
示例#6
0
文件: io.cpp 项目: xorgy/dcm
void cbPStk(DcmStack& stk) {
    stack<DcmType*> items;
    while (!stk.empty()) {
        items.push(stk.top());
        stk.pop();
    }
    while (!items.empty()) {
        dcmout << items.top()->repr() << ' ';
        stk.push(items.top());
        items.pop();
    }
    dcmout << endl;
}
示例#7
0
void query_series_from_net(const std::string& studyinstanceuid, const std::string& server, const std::string& local_aet, const sigc::slot< void, const Glib::RefPtr< ImagePool::Series >& >& resultslot) {
	DcmDataset query;
	DcmElement* e = NULL;
	
	e = newDicomElement(DCM_QueryRetrieveLevel);
	e->putString("SERIES");
	query.insert(e);

	e = newDicomElement(DCM_SpecificCharacterSet);
	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);

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

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

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

	e = newDicomElement(DCM_NumberOfSeriesRelatedInstances);
	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();
	for(unsigned int i=0; i<result->card(); i++) {
		DcmDataset* dset = (DcmDataset*)result->elem(i);
		dset->print(COUT);
		resultslot(create_query_series(dset));
	}
}
示例#8
0
文件: io.cpp 项目: xorgy/dcm
void cbPutLine(DcmStack& stk) {
    DcmString *dcmStr = static_cast<DcmString*>(
      safePeekMain(stk, {DcmString::typeVal()}));
    stk.pop();
    dcmout << *dcmStr << endl;
    del(dcmStr);
}
示例#9
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;
}
示例#10
0
/*
 * 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;
}
示例#11
0
文件: prelude.cpp 项目: xorgy/dcm
void cbDup(DcmStack& stk) {
    stk.push(dup(safePeekMain(stk)));
}
示例#12
0
文件: prelude.cpp 项目: xorgy/dcm
void cbCopy(DcmStack& stk) {
    DcmType *dcm = safePeekMain(stk);
    stk.pop();
    stk.push(dcm->copy());
    del(dcm);
}
示例#13
0
文件: prelude.cpp 项目: xorgy/dcm
// Eventually we'll want ExecStrCallback("$a $b @a @b");
void cbRev(DcmStack& stk) {
    DcmType **dcms = popN(stk, 2);
    stk.push(dcms[0]);
    stk.push(dcms[1]);
    delete[] dcms;
}
示例#14
0
文件: io.cpp 项目: xorgy/dcm
void cbInput(DcmStack& stk) {
    string str;
    getline(dcmin, str);
    stk.push(new DcmString(str));
}
示例#15
0
文件: prelude.cpp 项目: xorgy/dcm
void cbRefs(DcmStack& stk) {
    DcmType *dcm = safePeekMain(stk);
    stk.push(new DcmInt(dcm->refCount()));
}
示例#16
0
文件: prelude.cpp 项目: xorgy/dcm
void cbBottom(DcmStack& stk) {
    stk.push(new DcmBool(stk.empty()));
}
示例#17
0
文件: prelude.cpp 项目: xorgy/dcm
void cbClear(DcmStack& stk) {
    while (!stk.empty()) {
        del(stk.top());
        stk.pop();
    }
}
示例#18
0
文件: io.cpp 项目: xorgy/dcm
void cbPrint(DcmStack& stk) {
    DcmType *dcm = safePeekMain(stk);
    stk.pop();
    dcmout << dcm->repr() << endl;
    del(dcm);
}
示例#19
0
文件: prelude.cpp 项目: xorgy/dcm
void cbNone(DcmStack& stk) {
    stk.push(dup(dcmNone));
}
示例#20
0
文件: prelude.cpp 项目: xorgy/dcm
void cbTrue(DcmStack& stk) {
    stk.push(dup(dcmTrue));
}
示例#21
0
文件: prelude.cpp 项目: xorgy/dcm
void cbFalse(DcmStack& stk) {
    stk.push(dup(dcmFalse));
}
示例#22
0
文件: prelude.cpp 项目: xorgy/dcm
void cbRepr(DcmStack& stk) {
    DcmType *dcm = safePeekMain(stk);
    stk.pop();
    stk.push(new DcmString(dcm->repr()));
    del(dcm);
}
示例#23
0
文件: prelude.cpp 项目: xorgy/dcm
void cbType(DcmStack& stk) {
    DcmType *dcm = safePeekMain(stk);
    stk.push(new DcmString(typeVal2Str(dcm->type())));
}
示例#24
0
文件: prelude.cpp 项目: xorgy/dcm
void cbDel(DcmStack& stk) {
    del(safePeekMain(stk));
    stk.pop();
}