From 90e0642330f102fafaff4de592f87becfe85e364 Mon Sep 17 00:00:00 2001 From: Lionel Untereiner Date: Tue, 6 Jun 2017 10:53:52 +0200 Subject: [PATCH] [SofaSimpleFem] ADD test for computeBBox --- .../HexahedronFEMForceField_test.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/SofaKernel/modules/SofaSimpleFem/SofaSimpleFem_test/HexahedronFEMForceField_test.cpp b/SofaKernel/modules/SofaSimpleFem/SofaSimpleFem_test/HexahedronFEMForceField_test.cpp index dbd68b789e2..e2e2423fddf 100644 --- a/SofaKernel/modules/SofaSimpleFem/SofaSimpleFem_test/HexahedronFEMForceField_test.cpp +++ b/SofaKernel/modules/SofaSimpleFem/SofaSimpleFem_test/HexahedronFEMForceField_test.cpp @@ -41,6 +41,7 @@ struct HexahedronFEMForceField_test : public ForceField_test<_HexahedronFEMForce typedef typename ForceType::VecDeriv VecDeriv; typedef typename ForceType::Coord Coord; typedef typename ForceType::Deriv Deriv; + typedef core::objectmodel::Data DataVecCoord; typedef typename Coord::value_type Real; typedef helper::Vec<3,Real> Vec3; @@ -104,6 +105,22 @@ struct HexahedronFEMForceField_test : public ForceField_test<_HexahedronFEMForce // run the forcefield_test Inherited::run_test( x, v, f ); } + + void test_computeBBox() + { + std::size_t n = x.size(); + // copy the position and velocities to the scene graph + this->dof->resize(n); + typename DOF::WriteVecCoord xdof = this->dof->writePositions(); + copyToData( xdof, x ); + // init scene and compute force + sofa::simulation::getSimulation()->init(this->node.get()); + + Inherited::force->computeBBox(NULL, true); + + EXPECT_EQ(Inherited::force->f_bbox.getValue().minBBox(), Vec3(0,0,0)); + EXPECT_EQ(Inherited::force->f_bbox.getValue().maxBBox(), Vec3(1,1,1.1)); + } }; // ========= Define the list of types to instanciate. @@ -128,4 +145,9 @@ TYPED_TEST( HexahedronFEMForceField_test , extension ) this->test_valueForce(); } +TYPED_TEST( HexahedronFEMForceField_test, test_computeBBox ) +{ + ASSERT_NO_THROW(this->test_computeBBox()) ; +} + } // namespace sofa