Commit cb19aa03 authored by Emilie Harquel's avatar Emilie Harquel
Browse files

* fixed image backup : fields are automatically copied in deepCopy

 * fixed Boolean, Float, Integer and String copy : copy of m_value
 * fixed Image and TriangularMesh deepCopy

--HG--
branch : fw4spl_0.6
parent 7e156bf6
......@@ -142,85 +142,9 @@ bool BackupHelper::backupSelectedImage(::fwData::PatientDB::sptr _pPatientDB, ::
::fwData::Study::AcquisitionIterator acquisitionIter = (*studyIter)->getAcquisitions().first;
acquisitionIter += myIntAcq->value();
// Image backup
//assert(false && "TODO : clone need backup of all temp field (medical image)");
//::fwData::Acquisition::sptr pAquisitionBackup = (*acquisitionIter)->clone();
::fwData::Acquisition::NewSptr pAquisitionBackup;
pAquisitionBackup->deepCopy( *acquisitionIter );
::fwData::Image::sptr pImageBackup = pAquisitionBackup->getImage();
if ( (*acquisitionIter)->getImage()->getFieldSize( ::fwComEd::Dictionary::m_transfertFunctionCompositeId ) )
{
::fwComEd::fieldHelper::MedicalImageHelpers::checkMinMaxTF( pImageBackup );
::fwComEd::fieldHelper::MedicalImageHelpers::checkImageSliceIndex( pImageBackup );
::fwComEd::fieldHelper::MedicalImageHelpers::checkLandmarks( pImageBackup );
// clone TF
::fwData::Composite::sptr cTF = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::Composite >( ::fwComEd::Dictionary::m_transfertFunctionCompositeId );
::fwData::String::sptr sTF = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::String >( ::fwComEd::Dictionary::m_transfertFunctionId );
::fwData::Composite::sptr cTFBackup = ::fwData::Composite::New();
::fwData::String::sptr sTFBackup = ::fwData::String::New();
::fwData::Composite::Container::iterator iterTF;
for (iterTF = cTF->getRefMap().begin() ; iterTF != cTF->getRefMap().end() ; ++iterTF)
{
//cTFBackup->getRefMap()[iterTF->first] = ::fwData::TransfertFunction::dynamicCast(iterTF->second)->clone();
::fwData::TransfertFunction::NewSptr newTF;
newTF->deepCopy( iterTF->second );
cTFBackup->getRefMap()[iterTF->first] = newTF;
}
sTFBackup->value() = sTF->value();
pImageBackup->setFieldSingleElement(::fwComEd::Dictionary::m_transfertFunctionCompositeId, cTFBackup);
pImageBackup->setFieldSingleElement(::fwComEd::Dictionary::m_transfertFunctionId, sTFBackup);
// clone min/max
int min = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_windowMinId)->value();
pImageBackup->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_windowMinId)->value() = min;
int max = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_windowMaxId)->value();
pImageBackup->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_windowMaxId)->value() = max;
// clone landmarks ???
// m�me question pour les distances ...
}
// clone axial slice index
if ((*acquisitionIter)->getImage()->getFieldSize( ::fwComEd::Dictionary::m_axialSliceIndexId ) )
{
int axialSliceIndex = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_axialSliceIndexId)->value();
pImageBackup->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_axialSliceIndexId)->value() = axialSliceIndex;
}
// clone frontal slice inde
if ((*acquisitionIter)->getImage()->getFieldSize( ::fwComEd::Dictionary::m_frontalSliceIndexId ) )
{
int frontalSliceIndex = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_frontalSliceIndexId)->value();
pImageBackup->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_frontalSliceIndexId)->value() = frontalSliceIndex;
}
// clone sagittal slice inde
if ((*acquisitionIter)->getImage()->getFieldSize( ::fwComEd::Dictionary::m_sagittalSliceIndexId ) )
{
int sagittalSliceIndex = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_sagittalSliceIndexId)->value();
pImageBackup->getFieldSingleElement< ::fwData::Integer >(::fwComEd::Dictionary::m_sagittalSliceIndexId)->value() = sagittalSliceIndex;
}
// clone comment
if ((*acquisitionIter)->getImage()->getFieldSize( ::fwComEd::Dictionary::m_commentId ) )
{
std::string comment = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::String >( ::fwComEd::Dictionary::m_commentId )->value();
::fwData::String::NewSptr commentField;
commentField->value() = comment;
pImageBackup->setFieldSingleElement( ::fwComEd::Dictionary::m_commentId, commentField);
}
// clone label
if ((*acquisitionIter)->getImage()->getFieldSize( ::fwComEd::Dictionary::m_imageLabelId ) )
{
std::string label = (*acquisitionIter)->getImage()->getFieldSingleElement< ::fwData::String >( ::fwComEd::Dictionary::m_imageLabelId )->value();
::fwData::String::NewSptr labelField;
labelField->value() = label;
pImageBackup->setFieldSingleElement( ::fwComEd::Dictionary::m_imageLabelId, labelField);
}
(*studyIter)->addAcquisition( pAquisitionBackup );
bRes = true;
......
......@@ -30,6 +30,7 @@ Boolean::~Boolean() throw()
void Boolean::shallowCopy( Boolean::csptr _source )
{
::fwTools::Object::shallowCopyOfChildren( _source );
this->m_value = _source->m_value;
}
//------------------------------------------------------------------------------
......@@ -37,6 +38,7 @@ void Boolean::shallowCopy( Boolean::csptr _source )
void Boolean::deepCopy( Boolean::csptr _source )
{
::fwTools::Object::deepCopyOfChildren( _source );
this->m_value = _source->m_value;
}
} // namespace fwData
......@@ -30,6 +30,7 @@ Float::~Float() throw()
void Float::shallowCopy( Float::csptr _source )
{
::fwTools::Object::shallowCopyOfChildren( _source );
this->m_value = _source->m_value;
}
//------------------------------------------------------------------------------
......@@ -37,6 +38,7 @@ void Float::shallowCopy( Float::csptr _source )
void Float::deepCopy( Float::csptr _source )
{
::fwTools::Object::deepCopyOfChildren( _source );
this->m_value = _source->m_value;
}
......
......@@ -157,7 +157,7 @@ void Image::shallowCopy( Image::csptr _source )
void Image::deepCopy( Image::csptr _source )
{
::fwTools::Object::shallowCopyOfChildren( _source );
::fwTools::Object::deepCopyOfChildren( _source );
// Assign
this->m_ui8Dimension = _source->m_ui8Dimension;
......
......@@ -31,6 +31,7 @@ Integer::~Integer() throw()
void Integer::shallowCopy( Integer::csptr _source )
{
::fwTools::Object::shallowCopyOfChildren( _source );
this->m_value = _source->m_value;
}
//------------------------------------------------------------------------------
......@@ -38,6 +39,7 @@ void Integer::shallowCopy( Integer::csptr _source )
void Integer::deepCopy( Integer::csptr _source )
{
::fwTools::Object::deepCopyOfChildren( _source );
this->m_value = _source->m_value;
}
} // namespace fwData
......@@ -29,6 +29,7 @@ String::~String() throw()
void String::shallowCopy( String::csptr _source )
{
::fwTools::Object::shallowCopyOfChildren( _source );
this->m_value = _source->m_value;
}
//------------------------------------------------------------------------------
......@@ -36,6 +37,7 @@ void String::shallowCopy( String::csptr _source )
void String::deepCopy( String::csptr _source )
{
::fwTools::Object::deepCopyOfChildren( _source );
this->m_value = _source->m_value;
}
} // namespace fwData
......@@ -35,7 +35,7 @@ void TriangularMesh::shallowCopy( TriangularMesh::csptr _source )
void TriangularMesh::deepCopy( TriangularMesh::csptr _source )
{
::fwTools::Object::shallowCopyOfChildren( _source );
::fwTools::Object::deepCopyOfChildren( _source );
this->m_points = _source->m_points;
this->m_cells = _source->m_cells;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment