fw4spl
helper/Fiducial.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwGdcmIO/helper/Fiducial.hpp"
8 
9 #include "fwGdcmIO/helper/DicomDataTools.hpp"
10 
11 #include <fwData/Image.hpp>
12 #include <fwData/PointList.hpp>
13 #include <fwData/Vector.hpp>
14 
15 #include <fwDataTools/fieldHelper/Image.hpp>
16 
17 #include <fwMedData/ImageSeries.hpp>
18 #include <fwMedData/SeriesDB.hpp>
19 
20 namespace fwGdcmIO
21 {
22 namespace helper
23 {
24 
25 //------------------------------------------------------------------------------
26 
28 {
29  // Let's find if a series contains distances
30  for(const ::fwMedData::Series::sptr& series : seriesDB->getContainer())
31  {
32  ::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
33  if(imageSeries)
34  {
35  ::fwData::Image::sptr image = imageSeries->getImage();
36  if(image)
37  {
38  ::fwData::PointList::sptr pointList =
40  if(pointList && !pointList->getPoints().empty())
41  {
42  return true;
43  }
44  }
45  }
46  }
47 
48  return false;
49 }
50 
51 //------------------------------------------------------------------------------
52 
54 {
55  // Let's find if a series contains distances
56  for(const ::fwMedData::Series::sptr& series : seriesDB->getContainer())
57  {
58  ::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
59  if(imageSeries)
60  {
61  ::fwData::Image::sptr image = imageSeries->getImage();
62  if(image)
63  {
64  ::fwData::Vector::sptr distanceVector =
66  if(distanceVector && !distanceVector->empty())
67  {
68  return true;
69  }
70  }
71  }
72  }
73 
74  return false;
75 }
76 
77 //------------------------------------------------------------------------------
78 
80 {
81  // Let's find if a series contains distances
82  for(const ::fwMedData::Series::sptr& series : seriesDB->getContainer())
83  {
84  ::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
85  if(imageSeries)
86  {
87  ::fwData::Image::csptr image = imageSeries->getImage();
88  if(image)
89  {
90  ::fwData::Vector::sptr distanceVector =
92  if(distanceVector && !distanceVector->empty())
93  {
94  for(const ::fwData::Object::sptr& object : distanceVector->getContainer())
95  {
96  ::fwData::PointList::sptr pointList = ::fwData::PointList::dynamicCast(object);
97  if(pointList && pointList->getPoints().size() >= 2)
98  {
99  const ::fwData::Point::csptr point1 = *pointList->getPoints().begin();
100  const ::fwData::Point::csptr point2 = *(++pointList->getPoints().begin());
101  const size_t frameNumber1 =
103  const size_t frameNumber2 =
105  if(frameNumber1 != frameNumber2)
106  {
107  return true;
108  }
109  }
110  }
111  }
112  }
113  }
114  }
115 
116  return false;
117 }
118 
119 //------------------------------------------------------------------------------
120 
121 } // namespace helper
122 } // namespace fwGdcmIO
#define SPTR(_cls_)
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
This class defines a vector of objects.
static FWGDCMIO_API bool containsLandmarks(const std::shared_ptr< ::fwMedData::SeriesDB > &seriesDB)
Return true if the series contains at least one image containing landmarks.
static FWGDCMIO_API bool contains3DDistances(const std::shared_ptr< ::fwMedData::SeriesDB > &seriesDB)
Return true if the series contains at least one image containing 3D distances.
static FWGDCMIO_API bool containsDistances(const std::shared_ptr< ::fwMedData::SeriesDB > &seriesDB)
Return true if the series contains at least one image containing distances.
ContainerType & getContainer()
Series container.
This class defines a list of points.
static FWGDCMIO_API std::size_t convertPointToFrameNumber(const ::fwData::Image::csptr &image, const ::fwData::Point::csptr &point)
Convert a 3D point to the closest frame number index.