7 #include "fwDataTools/fieldHelper/MedicalImageHelpers.hpp" 9 #include "fwDataTools/fieldHelper/Image.hpp" 11 #include <fwData/Composite.hpp> 12 #include <fwData/Integer.hpp> 13 #include <fwData/PointList.hpp> 14 #include <fwData/ResectionDB.hpp> 15 #include <fwData/String.hpp> 17 #include <fwMath/MeshFunctions.hpp> 29 bool fieldIsModified =
false;
34 ::fwData::PointList::sptr pl = ::fwData::PointList::New();
36 fieldIsModified =
true;
39 return fieldIsModified;
49 bool dataImageIsAllocated = (_pImg != ::fwData::Image::sptr());
51 if (dataImageIsAllocated)
53 size_t nbDim = _pImg->getNumberOfDimensions();
54 dataImageIsAllocated &= nbDim > 1;
56 for (
size_t k = 0; dataImageIsAllocated && k < nbDim; ++k )
58 dataImageIsAllocated = dataImageIsAllocated && ( _pImg->getSize()[k] >= 1 );
62 return dataImageIsAllocated;
71 bool fieldIsModified =
false;
73 const ::fwData::Image::SizeType& imageSize = _pImg->getSize();
83 if ( !(axialIdx && frontalIdx && sagittalIdx) )
86 axialIdx = ::fwData::Integer::New(-1);
89 frontalIdx = ::fwData::Integer::New(-1);
92 sagittalIdx = ::fwData::Integer::New(-1);
95 fieldIsModified =
true;
99 "Information on image slice index is not correct, miss one of these fields : m_axialSliceIndexId, m_frontalSliceIndexId, m_sagittalSliceIndexId.",
100 axialIdx && frontalIdx && sagittalIdx
104 if( axialIdx->value() < 0 || imageSize[2] < axialIdx->value() )
106 axialIdx->value() =
static_cast< ::fwData::Integer::ValueType
>(imageSize[2] / 2);
107 fieldIsModified =
true;
110 if( frontalIdx->value() < 0 || imageSize[1] < frontalIdx->value() )
112 frontalIdx->value() =
static_cast< ::fwData::Integer::ValueType
>(imageSize[1] / 2);
113 fieldIsModified =
true;
116 if( sagittalIdx->value() < 0 || imageSize[0] < sagittalIdx->value() )
118 sagittalIdx->value() =
static_cast< ::fwData::Integer::ValueType
>(imageSize[0] / 2);
119 fieldIsModified =
true;
122 return fieldIsModified;
131 ::fwData::Point::sptr
point = ::fwData::Point::New();
135 point->getCoord()[0] =
137 point->getCoord()[1] =
139 point->getCoord()[2] =
151 bool fieldIsModified =
false;
156 ::fwData::String::sptr param = ::fwData::String::New(
"Original image");
158 fieldIsModified =
true;
161 return fieldIsModified;
167 ::fwData::Image::sptr imgToInitialize)
169 SLM_ASSERT(
"Image source must be initialized", imgSrc);
174 imgToInitialize = ::fwData::Image::New();
176 ::fwData::Array::sptr imgData = imgSrc->getDataArray();
177 imgSrc->setDataArray(::fwData::Array::sptr(),
false);
181 imgSrc->setDataArray(imgData,
false);
183 imgToInitialize->allocate();
185 return imgToInitialize;
190 bool MedicalImageHelpers::isBufNull(const ::fwData::Image::BufferType* buf,
const unsigned int len)
193 const ::fwData::Image::BufferType* ucbuf =
static_cast< const ::fwData::Image::BufferType*
> (buf);
194 isNull = 0 == std::accumulate(
#define SLM_TRACE_FUNC()
Trace contextual function signature.
This class contains an integer value. Integer object is essentially used as a field in other objects...
FWDATA_API::fwData::Object::sptr getField(const FieldNameType &name,::fwData::Object::sptr defaultValue=::fwData::Object::sptr()) const
Returns a pointer of corresponding field (null if non exist).
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.