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

[SofaBase] Package SofaBaseCollision #1653

Merged
merged 9 commits into from
Dec 17, 2020
Merged
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
4 changes: 2 additions & 2 deletions SofaKernel/SofaBase/src/SofaBase/initSofaBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <SofaBase/initSofaBase.h>
#include <SofaBaseTopology/initBaseTopology.h>
#include <SofaBaseMechanics/initBaseMechanics.h>
#include <SofaBaseCollision/initBaseCollision.h>
#include <SofaBaseCollision/initSofaBaseCollision.h>
#include <SofaBaseLinearSolver/initBaseLinearSolver.h>
#include <SofaBaseVisual/initBaseVisual.h>
#include <SofaBaseUtils/initSofaBaseUtils.h>
Expand All @@ -42,7 +42,7 @@ void initSofaBase()
{
initBaseTopology();
initBaseMechanics();
initBaseCollision();
initSofaBaseCollision();
initBaseLinearSolver();
initBaseVisual();
initSofaBaseUtils();
Expand Down
145 changes: 80 additions & 65 deletions SofaKernel/modules/SofaBaseCollision/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,77 +1,92 @@
cmake_minimum_required(VERSION 3.12)
project(SofaBaseCollision)
project(SofaBaseCollision LANGUAGES CXX)

set(SOFABASECOLLISION_SRC "src/${PROJECT_NAME}")

set(HEADER_FILES
BaseContactMapper.h
BaseIntTool.h
BaseProximityIntersection.h
BruteForceDetection.h
CapsuleIntTool.h
CapsuleIntTool.inl
CapsuleModel.h
CapsuleModel.inl
ContactListener.h
Cube.h
CubeModel.h
CylinderModel.h
CylinderModel.inl
DefaultContactManager.h
DefaultPipeline.h
DiscreteIntersection.h
Intersector.h
IntrCapsuleOBB.h
IntrCapsuleOBB.inl
IntrOBBOBB.h
IntrOBBOBB.inl
IntrSphereOBB.h
IntrSphereOBB.inl
IntrUtility3.h
IntrUtility3.inl
MinProximityIntersection.h
NewProximityIntersection.h
NewProximityIntersection.inl
OBBIntTool.h
OBBModel.h
OBBModel.inl
RigidCapsuleModel.h
RigidCapsuleModel.inl
Sphere.h
SphereModel.h
SphereModel.inl
config.h
initBaseCollision.h
${SOFABASECOLLISION_SRC}/config.h.in
${SOFABASECOLLISION_SRC}/initSofaBaseCollision.h
${SOFABASECOLLISION_SRC}/BaseContactMapper.h
${SOFABASECOLLISION_SRC}/BaseIntTool.h
${SOFABASECOLLISION_SRC}/BaseProximityIntersection.h
${SOFABASECOLLISION_SRC}/BruteForceDetection.h
${SOFABASECOLLISION_SRC}/CapsuleIntTool.h
${SOFABASECOLLISION_SRC}/CapsuleIntTool.inl
${SOFABASECOLLISION_SRC}/CapsuleModel.h
${SOFABASECOLLISION_SRC}/CapsuleModel.inl
${SOFABASECOLLISION_SRC}/ContactListener.h
${SOFABASECOLLISION_SRC}/Cube.h
${SOFABASECOLLISION_SRC}/CubeModel.h
${SOFABASECOLLISION_SRC}/CylinderModel.h
${SOFABASECOLLISION_SRC}/CylinderModel.inl
${SOFABASECOLLISION_SRC}/DefaultContactManager.h
${SOFABASECOLLISION_SRC}/DefaultPipeline.h
${SOFABASECOLLISION_SRC}/DiscreteIntersection.h
${SOFABASECOLLISION_SRC}/Intersector.h
${SOFABASECOLLISION_SRC}/IntrCapsuleOBB.h
${SOFABASECOLLISION_SRC}/IntrCapsuleOBB.inl
${SOFABASECOLLISION_SRC}/IntrOBBOBB.h
${SOFABASECOLLISION_SRC}/IntrOBBOBB.inl
${SOFABASECOLLISION_SRC}/IntrSphereOBB.h
${SOFABASECOLLISION_SRC}/IntrSphereOBB.inl
${SOFABASECOLLISION_SRC}/IntrUtility3.h
${SOFABASECOLLISION_SRC}/IntrUtility3.inl
${SOFABASECOLLISION_SRC}/MinProximityIntersection.h
${SOFABASECOLLISION_SRC}/NewProximityIntersection.h
${SOFABASECOLLISION_SRC}/NewProximityIntersection.inl
${SOFABASECOLLISION_SRC}/OBBIntTool.h
${SOFABASECOLLISION_SRC}/OBBModel.h
${SOFABASECOLLISION_SRC}/OBBModel.inl
${SOFABASECOLLISION_SRC}/RigidCapsuleModel.h
${SOFABASECOLLISION_SRC}/RigidCapsuleModel.inl
${SOFABASECOLLISION_SRC}/Sphere.h
${SOFABASECOLLISION_SRC}/SphereModel.h
${SOFABASECOLLISION_SRC}/SphereModel.inl
)

set(SOURCE_FILES
BaseContactMapper.cpp
BaseIntTool.cpp
BaseProximityIntersection.cpp
BruteForceDetection.cpp
CapsuleIntTool.cpp
CapsuleModel.cpp
ContactListener.cpp
CubeModel.cpp
CylinderModel.cpp
DefaultContactManager.cpp
DefaultPipeline.cpp
DiscreteIntersection.cpp
IntrCapsuleOBB.cpp
IntrOBBOBB.cpp
IntrSphereOBB.cpp
IntrUtility3.cpp
MinProximityIntersection.cpp
NewProximityIntersection.cpp
OBBIntTool.cpp
OBBModel.cpp
RigidCapsuleModel.cpp
SphereModel.cpp
initBaseCollision.cpp
${SOFABASECOLLISION_SRC}/initSofaBaseCollision.cpp
${SOFABASECOLLISION_SRC}/BaseContactMapper.cpp
${SOFABASECOLLISION_SRC}/BaseIntTool.cpp
${SOFABASECOLLISION_SRC}/BaseProximityIntersection.cpp
${SOFABASECOLLISION_SRC}/BruteForceDetection.cpp
${SOFABASECOLLISION_SRC}/CapsuleIntTool.cpp
${SOFABASECOLLISION_SRC}/CapsuleModel.cpp
${SOFABASECOLLISION_SRC}/ContactListener.cpp
${SOFABASECOLLISION_SRC}/CubeModel.cpp
${SOFABASECOLLISION_SRC}/CylinderModel.cpp
${SOFABASECOLLISION_SRC}/DefaultContactManager.cpp
${SOFABASECOLLISION_SRC}/DefaultPipeline.cpp
${SOFABASECOLLISION_SRC}/DiscreteIntersection.cpp
${SOFABASECOLLISION_SRC}/IntrCapsuleOBB.cpp
${SOFABASECOLLISION_SRC}/IntrOBBOBB.cpp
${SOFABASECOLLISION_SRC}/IntrSphereOBB.cpp
${SOFABASECOLLISION_SRC}/IntrUtility3.cpp
${SOFABASECOLLISION_SRC}/MinProximityIntersection.cpp
${SOFABASECOLLISION_SRC}/NewProximityIntersection.cpp
${SOFABASECOLLISION_SRC}/OBBIntTool.cpp
${SOFABASECOLLISION_SRC}/OBBModel.cpp
${SOFABASECOLLISION_SRC}/RigidCapsuleModel.cpp
${SOFABASECOLLISION_SRC}/SphereModel.cpp
)

find_package(SofaFramework REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore SofaSimulationCommon)

sofa_add_targets_to_package(
PACKAGE_NAME SofaBase
sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
PACKAGE_VERSION ${Sofa_VERSION}
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
)
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)

# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(SOFABASECOLLISION_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(SOFABASECOLLISION_BUILD_TESTS)
enable_testing()
add_subdirectory(SofaBaseCollision_test)
endif()
1 change: 1 addition & 0 deletions SofaKernel/modules/SofaBaseCollision/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SofaBaseCollision
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# CMake package configuration file for the @PROJECT_NAME@ module

@PACKAGE_GUARD@
@PACKAGE_INIT@

find_package(SofaFramework QUIET REQUIRED)

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
endif()

check_required_components(@PROJECT_NAME@)
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@

#include <sofa/defaulttype/VecTypes.h>

namespace sofa
{

namespace component
{

namespace collision
namespace sofa::component::collision
{

using namespace defaulttype;
Expand All @@ -49,20 +43,15 @@ std::string GenerateStringID::generate(){
}


//template class SOFA_BASE_COLLISION_API BaseContactMapper<defaulttype::Vec2Types>;
template class SOFA_BASE_COLLISION_API BaseContactMapper<defaulttype::Vec3Types>;
template class SOFA_BASE_COLLISION_API BaseContactMapper<defaulttype::Rigid3Types>;

//template class SOFA_SOFABASECOLLISION_API BaseContactMapper<defaulttype::Vec2Types>;
template class SOFA_SOFABASECOLLISION_API BaseContactMapper<defaulttype::Vec3Types>;
template class SOFA_SOFABASECOLLISION_API BaseContactMapper<defaulttype::Rigid3Types>;

} // namespace collision

} // namespace component
} // namespace sofa::component::collision

namespace helper
namespace sofa::helper
{
//template class SOFA_BASE_COLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Vec2Types>, core::CollisionModel* >;
template class SOFA_BASE_COLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Vec3Types>, core::CollisionModel* >;
template class SOFA_BASE_COLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Rigid3Types>, core::CollisionModel* >;
} // namespace helper

} // namespace sofa
template class SOFA_SOFABASECOLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Vec3Types>, core::CollisionModel* >;
template class SOFA_SOFABASECOLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Rigid3Types>, core::CollisionModel* >;
} // namespace sofa::helper
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,19 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_COMPONENT_COLLISION_BASECONTACTMAPPER_H
#define SOFA_COMPONENT_COLLISION_BASECONTACTMAPPER_H
#include "config.h"
#pragma once
#include <SofaBaseCollision/config.h>

#include <sofa/helper/Factory.h>
#include <sofa/core/CollisionModel.h>
#include <sofa/defaulttype/RigidTypes.h>
#include <sofa/defaulttype/VecTypes.h>
#include <sofa/core/behavior/MechanicalState.h>

namespace sofa
namespace sofa::component::collision
{

namespace core
{

namespace behavior
{
template <class T> class MechanicalState;
} // namespace behavior

} // namespace core

namespace component
{

namespace collision
{

class SOFA_BASE_COLLISION_API GenerateStringID
class SOFA_SOFABASECOLLISION_API GenerateStringID
{
public :
static const int length {15};
Expand Down Expand Up @@ -132,24 +116,19 @@ class ContactMapperCreator : public helper::Creator < typename Mapper::ContactMa
};

#if !defined(SOFA_COMPONENT_COLLISION_BASECONTACTMAPPER_CPP)
extern template class SOFA_BASE_COLLISION_API BaseContactMapper<defaulttype::Vec3Types>;
extern template class SOFA_BASE_COLLISION_API BaseContactMapper<defaulttype::Rigid3Types>;
extern template class SOFA_SOFABASECOLLISION_API BaseContactMapper<defaulttype::Vec3Types>;
extern template class SOFA_SOFABASECOLLISION_API BaseContactMapper<defaulttype::Rigid3Types>;

#endif

} // namespace collision
} // namespace sofa::component::collision

} // namespace component

#if !defined(SOFA_COMPONENT_COLLISION_BASECONTACTMAPPER_CPP)
namespace helper
namespace sofa::helper
{
//extern template class SOFA_BASE_COLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Vec2Types>, core::CollisionModel* >;
extern template class SOFA_BASE_COLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Vec3Types>, core::CollisionModel* >;
extern template class SOFA_BASE_COLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Rigid3Types>, core::CollisionModel* >;
} // namespace helper
#endif

} // namespace sofa

//extern template class SOFA_SOFABASECOLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Vec2Types>, core::CollisionModel* >;
extern template class SOFA_SOFABASECOLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Vec3Types>, core::CollisionModel* >;
extern template class SOFA_SOFABASECOLLISION_API Factory< std::string, sofa::component::collision::BaseContactMapper<defaulttype::Rigid3Types>, core::CollisionModel* >;
} // namespace sofa::helper
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
******************************************************************************/
#include <SofaBaseCollision/BaseIntTool.h>

namespace sofa{namespace component{namespace collision{
namespace sofa::component::collision
{

//template<>
bool BaseIntTool::testIntersection(Cube &cube1, Cube &cube2,SReal alarmDist)
Expand All @@ -48,6 +49,6 @@ bool BaseIntTool::testIntersection(Cube &cube1, Cube &cube2,SReal alarmDist)
return true;
}

class SOFA_BASE_COLLISION_API BaseIntTool;
class SOFA_SOFABASECOLLISION_API BaseIntTool;

}}}
} // namespace sofa::component::collision
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef BASEINTTOOL_H
#define BASEINTTOOL_H
#include "config.h"
#pragma once
#include <SofaBaseCollision/config.h>

#include <SofaBaseCollision/CubeModel.h>
#include <SofaBaseCollision/CapsuleIntTool.h>
#include <SofaBaseCollision/OBBIntTool.h>

namespace sofa
{
namespace component
{
namespace collision
namespace sofa::component::collision
{

class SOFA_BASE_COLLISION_API BaseIntTool : public CapsuleIntTool,public OBBIntTool{
class SOFA_SOFABASECOLLISION_API BaseIntTool : public CapsuleIntTool,public OBBIntTool
{
public:
typedef sofa::helper::vector<sofa::core::collision::DetectionOutput> OutputVector;

Expand All @@ -54,10 +50,6 @@ class SOFA_BASE_COLLISION_API BaseIntTool : public CapsuleIntTool,public OBBIntT
return ( sph1.center() - sph2.center() ).norm2() <= r*r;
}





template <class DataTypes1,class DataTypes2>
static int computeIntersection(TSphere<DataTypes1>& sph1, TSphere<DataTypes2>& sph2,SReal alarmDist,SReal contactDist,OutputVector* contacts)
{
Expand Down Expand Up @@ -121,7 +113,4 @@ class SOFA_BASE_COLLISION_API BaseIntTool : public CapsuleIntTool,public OBBIntT



}
}
}
#endif // BASEINTTOOL_H
} // namespace sofa::component::collision
Loading