Commit 000a0acc authored by Pascal Monnier's avatar Pascal Monnier
Browse files

Fixed deepCopy of the ModelSeries and updated test for modelSeries.

--HG--
branch : fw4spl_0.10.1
parent e02a59ea
......@@ -8,6 +8,7 @@
#include <fwData/Image.hpp>
#include <fwData/registry/macros.hpp>
#include <fwData/Exception.hpp>
#include <fwData/Reconstruction.hpp>
#include "fwMedData/ModelSeries.hpp"
......@@ -50,7 +51,11 @@ void ModelSeries::cachedDeepCopy(const ::fwData::Object::csptr &_source, DeepCop
this->::fwMedData::Series::cachedDeepCopy(_source, cache);
m_attrReconstructionDB = other->m_attrReconstructionDB;
m_attrReconstructionDB.clear();
for(const ::fwData::Reconstruction::sptr &rec : other->m_attrReconstructionDB)
{
m_attrReconstructionDB.push_back(::fwData::Object::copy(rec, cache));
}
}
//------------------------------------------------------------------------------
......
......@@ -18,6 +18,8 @@ class ModelSeriesTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE( ModelSeriesTest );
CPPUNIT_TEST(modelTest);
CPPUNIT_TEST(deepCopyTest);
CPPUNIT_TEST(shallowCopyTest);
CPPUNIT_TEST_SUITE_END();
public:
......@@ -26,6 +28,8 @@ public:
void tearDown();
void modelTest();
void deepCopyTest();
void shallowCopyTest();
private:
ModelSeries::sptr m_series;
......
......@@ -73,5 +73,58 @@ void ModelSeriesTest::modelTest()
//------------------------------------------------------------------------------
void ModelSeriesTest::deepCopyTest()
{
CPPUNIT_ASSERT(m_series);
::fwData::Reconstruction::sptr rec1 = ::fwData::Reconstruction::New();
::fwData::Mesh::sptr mesh1 = ::fwData::Mesh::New();
::fwTest::generator::Mesh::generateQuadMesh(mesh1);
rec1->setMesh(mesh1);
ModelSeries::ReconstructionVectorType recs;
recs.push_back(rec1);
m_series->setReconstructionDB(recs);
::fwMedData::ModelSeries::sptr secondSeries = ::fwMedData::ModelSeries::New();
secondSeries->deepCopy(m_series);
CPPUNIT_ASSERT_EQUAL(1, (int)m_series->getReconstructionDB().size());
CPPUNIT_ASSERT_EQUAL(1, (int)secondSeries->getReconstructionDB().size());
CPPUNIT_ASSERT (m_series->getReconstructionDB()[0] != secondSeries->getReconstructionDB()[0]);
}
//------------------------------------------------------------------------------
void ModelSeriesTest::shallowCopyTest()
{
CPPUNIT_ASSERT(m_series);
::fwData::Reconstruction::sptr rec1 = ::fwData::Reconstruction::New();
::fwData::Mesh::sptr mesh1 = ::fwData::Mesh::New();
::fwTest::generator::Mesh::generateQuadMesh(mesh1);
rec1->setMesh(mesh1);
ModelSeries::ReconstructionVectorType recs;
recs.push_back(rec1);
m_series->setReconstructionDB(recs);
::fwMedData::ModelSeries::sptr secondSeries = ::fwMedData::ModelSeries::New();
secondSeries->shallowCopy(m_series);
CPPUNIT_ASSERT(m_series->getReconstructionDB()[0] == secondSeries->getReconstructionDB()[0]);
CPPUNIT_ASSERT_EQUAL(m_series->getReconstructionDB()[0], secondSeries->getReconstructionDB()[0]);
CPPUNIT_ASSERT_EQUAL(recs[0], m_series->getReconstructionDB()[0]);
CPPUNIT_ASSERT_EQUAL(recs[0], secondSeries->getReconstructionDB()[0]);
CPPUNIT_ASSERT_EQUAL(1, (int)m_series->getReconstructionDB().size());
CPPUNIT_ASSERT_EQUAL(1, (int)secondSeries->getReconstructionDB().size());
}
//------------------------------------------------------------------------------
} //namespace ut
} //namespace fwMedData
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