DICOMSR - How to convert frame list to std::vector<int>?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
kstn_hut_hat
Posts: 28
Joined: Mon, 2016-05-09, 08:32

DICOMSR - How to convert frame list to std::vector<int>?

#1 Post by kstn_hut_hat »

I'm using dcmtk 3.6.0 library.
My input: DICOMSR file that be referenced to multi-frame image.
Based on dcmtk library, I can get frame list by using the following statement : ((DSRImageTreeNode *)node)->getFrameList().
It returns to the DSRImageFrameList type.
How to convert to std::vector<int> type ? :)
Sorry if my English not good! :( :(
Thanks for seeing!

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DICOMSR - How to convert frame list to std::vector<int>?

#2 Post by J. Riesmeier »

Based on dcmtk library, I can get frame list by using the following statement : ((DSRImageTreeNode *)node)->getFrameList().
It returns to the DSRImageFrameList type.
How to convert to std::vector<int> type ? :)
Such a method is still on my to-do list, so in the meantime you have to implement it on your own (by iterating over the elements of the frame list...).

kstn_hut_hat
Posts: 28
Joined: Mon, 2016-05-09, 08:32

Re: DICOMSR - How to convert frame list to std::vector<int>?

#3 Post by kstn_hut_hat »

J. Riesmeier wrote:
Based on dcmtk library, I can get frame list by using the following statement : ((DSRImageTreeNode *)node)->getFrameList().
It returns to the DSRImageFrameList type.
How to convert to std::vector<int> type ? :)
Such a method is still on my to-do list, so in the meantime you have to implement it on your own (by iterating over the elements of the frame list...).
I'm using VisualStudio 2013.
I have tried using the following code, but failed:

Code: Select all

std::vector<int> vtFrameList;
auto frameList = imageNode->getFrameList(); // get frame list. Return to the DSRImageFrameList type.
size_t count = 0;
while (count < frameList.getNumberOfItems())
{
	auto item = frameList.getItem(count++);
	int value = OFstatic_cast(Sint32, item);
	vtFrameList.push_back(value);
}
When build it, have an error:
"Error 118 error LNK2001: unresolved external symbol "public: static long const DSRListOfItems<long>::EmptyItem" (?EmptyItem@?$DSRListOfItems@J@@2JB)"
Last edited by kstn_hut_hat on Mon, 2016-05-09, 09:56, edited 1 time in total.

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DICOMSR - How to convert frame list to std::vector<int>?

#4 Post by J. Riesmeier »

Not sure whether your first "auto" statement is actually correct. I would rather use "DSRImageFrameList &" (by-refence) instead.

By the way, the reason why no std::vector is used internally for the frame list is quite simple: the implementation of the "dcmsr" module started back in the year 2000. And at that time support for the vector class was quite limited (if I remember correctly). That's also the reason why we have alternative implementations in "ofstd".

kstn_hut_hat
Posts: 28
Joined: Mon, 2016-05-09, 08:32

Re: DICOMSR - How to convert frame list to std::vector<int>?

#5 Post by kstn_hut_hat »

I have changed from "auto" to "DSRImageFrameList &" but not success. Is there any other way?
Thanks for your reply!

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DICOMSR - How to convert frame list to std::vector<int>?

#6 Post by J. Riesmeier »

I checked your sample code with gcc 4.8.4 (Linux x86_64)... and it works. So, it seems to be an issue with your compiler/linker or with your project-specific settings.

gayathri.emd
Posts: 10
Joined: Tue, 2020-03-31, 09:12

Re: DICOMSR - How to convert frame list to std::vector<int>?

#7 Post by gayathri.emd »

kstn_hut_hat wrote: Mon, 2016-05-09, 09:34
J. Riesmeier wrote:
Based on dcmtk library, I can get frame list by using the following statement : ((DSRImageTreeNode *)node)->getFrameList().
It returns to the DSRImageFrameList type.
How to convert to std::vector<int> type ? :)
Such a method is still on my to-do list, so in the meantime you have to implement it on your own (by iterating over the elements of the frame list...).
I'm using VisualStudio 2013.
I have tried using the following code, but failed:

Code: Select all

std::vector<int> vtFrameList;
auto frameList = imageNode->getFrameList(); // get frame list. Return to the DSRImageFrameList type.
size_t count = 0;
while (count < frameList.getNumberOfItems())
{
	auto item = frameList.getItem(count++);
	int value = OFstatic_cast(Sint32, item);
	vtFrameList.push_back(value);
}
When build it, have an error:
"Error 118 error LNK2001: unresolved external symbol "public: static long const DSRListOfItems<long>::EmptyItem" (?EmptyItem@?$DSRListOfItems@J@@2JB)"
Hi,
Did u found any soluion for above error. I am looking solution for this now.

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DICOMSR - How to convert frame list to std::vector<int>?

#8 Post by J. Riesmeier »

Which version of the DCMTK do you use and which version of Visual Studio?

gayathri.emd
Posts: 10
Joined: Tue, 2020-03-31, 09:12

Re: DICOMSR - How to convert frame list to std::vector<int>?

#9 Post by gayathri.emd »

visual studio 2013 and Dcmtk -3.6.0

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DICOMSR - How to convert frame list to std::vector<int>?

#10 Post by J. Riesmeier »

DCMTK 3.6.0 is more than 9 years old. Please try again with a more recent version, e.g. 3.6.5 from October 2019.

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DICOMSR - How to convert frame list to std::vector<int>?

#11 Post by J. Riesmeier »

By the way, the base class of DSRImageFrameList, i.e. DSRListOfItems<T>, now also offers a getItems(OFVector<T> &items) method. This answers the original question "How to convert to std::vector<int> type?"

gayathri.emd
Posts: 10
Joined: Tue, 2020-03-31, 09:12

Re: DICOMSR - How to convert frame list to std::vector<int>?

#12 Post by gayathri.emd »

J. Riesmeier wrote: Wed, 2020-04-01, 12:20 DCMTK 3.6.0 is more than 9 years old. Please try again with a more recent version, e.g. 3.6.5 from October 2019.
okay will update and check . thanks for your response

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest