Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CollisionOBBCapsule] Fix Capsule destructor #5147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(HEADER_FILES
)

set(SOURCE_FILES
CapsuleModel_test.cpp
OBB_test.cpp
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: [email protected] *
******************************************************************************/
#include <gtest/gtest.h>
#include <CollisionOBBCapsule/geometry/CapsuleModel.h>
#include <sofa/core/ObjectFactory.h>

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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<sofa::defaulttype::Vec3Types> >()
.add< CapsuleCollisionModel<sofa::defaulttype::Vec3Types> >()
.add< CapsuleCollisionModel<sofa::defaulttype::Rigid3Types> >()
;

template class COLLISIONOBBCAPSULE_API TCapsule<defaulttype::Vec3Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class CapsuleCollisionModel : public core::CollisionModel

CapsuleCollisionModel();
CapsuleCollisionModel(core::behavior::MechanicalState<TDataTypes>* mstate );

~CapsuleCollisionModel() override;
public:
void init() override;

Expand Down Expand Up @@ -153,11 +155,14 @@ class CapsuleCollisionModel : public core::CollisionModel
template<class T>
static bool canCreate(T*& obj, core::objectmodel::BaseContext* context, core::objectmodel::BaseObjectDescription* arg)
{
if (dynamic_cast<core::behavior::MechanicalState<TDataTypes>*>(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<core::behavior::MechanicalState<TDataTypes>*>(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ CapsuleCollisionModel<DataTypes>::CapsuleCollisionModel(core::behavior::Mechanic
enum_type = CAPSULE_TYPE;
}

template <class TDataTypes>
CapsuleCollisionModel<TDataTypes>::~CapsuleCollisionModel()
{}

template<class DataTypes>
void CapsuleCollisionModel<DataTypes>::resize(sofa::Size size)
{
Expand Down
Loading