diff --git a/applications/plugins/CollisionOBBCapsule/CollisionOBBCapsule_test/CMakeLists.txt b/applications/plugins/CollisionOBBCapsule/CollisionOBBCapsule_test/CMakeLists.txt index db57d97fb7e..8c5cf6ddefe 100644 --- a/applications/plugins/CollisionOBBCapsule/CollisionOBBCapsule_test/CMakeLists.txt +++ b/applications/plugins/CollisionOBBCapsule/CollisionOBBCapsule_test/CMakeLists.txt @@ -7,6 +7,7 @@ set(HEADER_FILES ) set(SOURCE_FILES + CapsuleModel_test.cpp OBB_test.cpp ) diff --git a/applications/plugins/CollisionOBBCapsule/CollisionOBBCapsule_test/CapsuleModel_test.cpp b/applications/plugins/CollisionOBBCapsule/CollisionOBBCapsule_test/CapsuleModel_test.cpp new file mode 100644 index 00000000000..fb16017105e --- /dev/null +++ b/applications/plugins/CollisionOBBCapsule/CollisionOBBCapsule_test/CapsuleModel_test.cpp @@ -0,0 +1,33 @@ +/****************************************************************************** +* SOFA, Simulation Open-Framework Architecture * +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by * +* the Free Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this program. If not, see . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#include +#include +#include + +TEST(CapsuleModel, creationFromFactory) +{ + const auto entry = sofa::core::ObjectFactory::getInstance()->getEntry("CapsuleCollisionModel"); + const auto creatorRigid = entry.creatorMap.at("Rigid3d"); + + sofa::core::objectmodel::BaseObjectDescription desc; + const auto object = creatorRigid->createInstance(nullptr, &desc); +} diff --git a/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.cpp b/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.cpp index 0a953579c8b..eaf17f99777 100644 --- a/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.cpp +++ b/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.cpp @@ -29,7 +29,8 @@ namespace collisionobbcapsule::geometry using namespace sofa::defaulttype; int CapsuleCollisionModelClass = core::RegisterObject("Collision model which represents a set of Capsules") - .add< CapsuleCollisionModel >() + .add< CapsuleCollisionModel >() + .add< CapsuleCollisionModel >() ; template class COLLISIONOBBCAPSULE_API TCapsule; diff --git a/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.h b/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.h index b76d977f3dd..0619a655d66 100644 --- a/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.h +++ b/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.h @@ -103,6 +103,8 @@ class CapsuleCollisionModel : public core::CollisionModel CapsuleCollisionModel(); CapsuleCollisionModel(core::behavior::MechanicalState* mstate ); + + ~CapsuleCollisionModel() override; public: void init() override; @@ -153,11 +155,14 @@ class CapsuleCollisionModel : public core::CollisionModel template static bool canCreate(T*& obj, core::objectmodel::BaseContext* context, core::objectmodel::BaseObjectDescription* arg) { - if (dynamic_cast*>(context->getMechanicalState()) == nullptr && context->getMechanicalState() != nullptr) + if (context) { - arg->logError(std::string("No mechanical state with the datatype '") + DataTypes::Name() + - "' found in the context node."); - return false; + if (dynamic_cast*>(context->getMechanicalState()) == nullptr && context->getMechanicalState() != nullptr) + { + arg->logError(std::string("No mechanical state with the datatype '") + DataTypes::Name() + + "' found in the context node."); + return false; + } } return BaseObject::canCreate(obj, context, arg); diff --git a/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.inl b/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.inl index 2d279b45b8e..c67b25ec740 100644 --- a/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.inl +++ b/applications/plugins/CollisionOBBCapsule/src/CollisionOBBCapsule/geometry/CapsuleModel.inl @@ -47,6 +47,10 @@ CapsuleCollisionModel::CapsuleCollisionModel(core::behavior::Mechanic enum_type = CAPSULE_TYPE; } +template +CapsuleCollisionModel::~CapsuleCollisionModel() +{} + template void CapsuleCollisionModel::resize(sofa::Size size) {