Skip to content

Commit a2d8898

Browse files
alxbilgerepernod
andauthored
[PersistentContact] Update the plugin according to SOFA changes (#5791)
* [PersistentContact] Update the plugin according to SOFA changes * unused variable --------- Co-authored-by: erik pernod <erik.pernod@gmail.com>
1 parent 260aa32 commit a2d8898

18 files changed

+207
-222
lines changed

Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/RigidMapping.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ class RigidMapping : public core::Mapping<TIn, TOut>, public NonLinearMappingDat
169169
template <std::size_t N, class Real>
170170
struct RigidMappingMatrixHelper;
171171

172-
template<>
172+
template<> SOFA_COMPONENT_MAPPING_NONLINEAR_API
173173
void RigidMapping< sofa::defaulttype::Rigid2Types, sofa::defaulttype::Vec2Types >::updateK( const core::MechanicalParams* mparams, core::ConstMultiVecDerivId childForceId );
174-
template<>
174+
template<> SOFA_COMPONENT_MAPPING_NONLINEAR_API
175175
const linearalgebra::BaseMatrix* RigidMapping< sofa::defaulttype::Rigid2Types, sofa::defaulttype::Vec2Types >::getK();
176176

177177
#if !defined(SOFA_COMPONENT_MAPPING_RIGIDMAPPING_CPP)
Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
cmake_minimum_required(VERSION 3.22)
2-
project(PersistentContact)
2+
project(PersistentContact VERSION 0.1)
33

44

55
set(HEADER_FILES
6-
config.h
7-
PersistentContactBarycentricMapping.h
8-
PersistentContactBarycentricMapping.inl
9-
PersistentContactMapping.h
10-
PersistentContactRigidMapping.h
11-
PersistentContactRigidMapping.inl
12-
PersistentFrictionContact.h
13-
PersistentFrictionContact.inl
14-
PersistentUnilateralInteractionConstraint.h
15-
PersistentUnilateralInteractionConstraint.inl
6+
src/PersistentContact/config.h.in
7+
src/PersistentContact/PersistentContactBarycentricMapping.h
8+
src/PersistentContact/PersistentContactBarycentricMapping.inl
9+
src/PersistentContact/PersistentContactMapping.h
10+
src/PersistentContact/PersistentContactRigidMapping.h
11+
src/PersistentContact/PersistentContactRigidMapping.inl
12+
src/PersistentContact/PersistentFrictionContact.h
13+
src/PersistentContact/PersistentFrictionContact.inl
14+
src/PersistentContact/PersistentUnilateralInteractionConstraint.h
15+
src/PersistentContact/PersistentUnilateralInteractionConstraint.inl
1616
)
1717

1818
set(SOURCE_FILES
19-
PersistentContactBarycentricMapping.cpp
20-
PersistentContactMapping.cpp
21-
PersistentContactRigidMapping.cpp
22-
PersistentFrictionContact.cpp
23-
PersistentUnilateralInteractionConstraint.cpp
24-
initPersistentContact.cpp
19+
src/PersistentContact/PersistentContactBarycentricMapping.cpp
20+
src/PersistentContact/PersistentContactMapping.cpp
21+
src/PersistentContact/PersistentContactRigidMapping.cpp
22+
src/PersistentContact/PersistentFrictionContact.cpp
23+
src/PersistentContact/PersistentUnilateralInteractionConstraint.cpp
24+
src/PersistentContact/initPersistentContact.cpp
2525
)
2626

2727
set(README_FILES PersistentContact.txt)
2828

2929
set(README_FILES
3030
PersistentContact.txt)
3131

32-
find_package(SofaBaseMechanics REQUIRED)
33-
find_package(SofaRigid REQUIRED)
34-
find_package(SofaConstraint REQUIRED)
32+
sofa_find_package(Sofa.Component.Mapping REQUIRED)
33+
sofa_find_package(Sofa.Component.Collision.Response.Contact REQUIRED)
34+
sofa_find_package(Sofa.Component.Constraint.Lagrangian.Model REQUIRED)
3535

3636
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${README_FILES})
37-
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-DSOFA_BUILD_PERSISTENTCONTACT")
38-
target_link_libraries(${PROJECT_NAME} SofaBaseMechanics SofaRigid SofaConstraint)
39-
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
40-
41-
install(TARGETS ${PROJECT_NAME}
42-
COMPONENT PersistentContact_libraries
43-
EXPORT PersistentContactTargets
44-
RUNTIME DESTINATION bin
45-
LIBRARY DESTINATION lib
46-
ARCHIVE DESTINATION lib
47-
PUBLIC_HEADER DESTINATION "include/${PROJECT_NAME}")
48-
49-
install(DIRECTORY examples/ DESTINATION share/sofa/plugins/${PROJECT_NAME})
37+
target_link_libraries(${PROJECT_NAME}
38+
Sofa.Component.Mapping
39+
Sofa.Component.Collision.Response.Contact
40+
Sofa.Component.Constraint.Lagrangian.Model
41+
)
42+
43+
sofa_create_package_with_targets(
44+
PACKAGE_NAME ${PROJECT_NAME}
45+
PACKAGE_VERSION ${PROJECT_VERSION}
46+
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
47+
INCLUDE_SOURCE_DIR "src"
48+
INCLUDE_INSTALL_DIR ${PROJECT_NAME}
49+
RELOCATABLE "plugins"
50+
)

applications/plugins/PersistentContact/PersistentContactBarycentricMapping.cpp renamed to applications/plugins/PersistentContact/src/PersistentContact/PersistentContactBarycentricMapping.cpp

File renamed without changes.

applications/plugins/PersistentContact/PersistentContactBarycentricMapping.h renamed to applications/plugins/PersistentContact/src/PersistentContact/PersistentContactBarycentricMapping.h

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@
2222
#ifndef SOFA_COMPONENT_MAPPING_PERSISTENTCONTACTBARYCENTRICMAPPING_H
2323
#define SOFA_COMPONENT_MAPPING_PERSISTENTCONTACTBARYCENTRICMAPPING_H
2424

25-
#include <SofaBaseMechanics/BarycentricMapping.h>
25+
#include <PersistentContact/config.h>
26+
#include <sofa/component/mapping/linear/BarycentricMappers/BarycentricMapperMeshTopology.h>
27+
#include <sofa/component/mapping/linear/BarycentricMappers/BarycentricMapperSparseGridTopology.h>
28+
#include <sofa/component/mapping/linear/BarycentricMapping.h>
29+
#include <sofa/component/mapping/linear/BarycentricMappingRigid.h>
30+
#include <sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h>
31+
#include <sofa/component/topology/container/grid/SparseGridTopology.h>
2632

2733
#include "PersistentContactMapping.h"
28-
#include <PersistentContact/config.h>
2934

3035
namespace sofa
3136
{
@@ -65,10 +70,10 @@ class PersistentContactBarycentricMapper : public virtual core::objectmodel::Ba
6570

6671

6772
template<class TIn, class TOut>
68-
class PersistentContactBarycentricMapperMeshTopology : public BarycentricMapperMeshTopology< TIn , TOut>, public PersistentContactBarycentricMapper< TIn , TOut>
73+
class PersistentContactBarycentricMapperMeshTopology : public linear::BarycentricMapperMeshTopology<TIn, TOut>, public PersistentContactBarycentricMapper< TIn , TOut>
6974
{
7075
public:
71-
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapperMeshTopology, TIn, TOut), SOFA_TEMPLATE2(BarycentricMapperMeshTopology, TIn, TOut), SOFA_TEMPLATE2(PersistentContactBarycentricMapper, TIn, TOut));
76+
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapperMeshTopology, TIn, TOut), SOFA_TEMPLATE2(linear::BarycentricMapperMeshTopology, TIn, TOut), SOFA_TEMPLATE2(PersistentContactBarycentricMapper, TIn, TOut));
7277

7378
typedef TIn In;
7479
typedef TOut Out;
@@ -80,8 +85,8 @@ class PersistentContactBarycentricMapperMeshTopology : public BarycentricMapperM
8085
typedef typename InDataTypes::Real Real;
8186

8287
PersistentContactBarycentricMapperMeshTopology(core::topology::BaseMeshTopology* fromTopology,
83-
topology::PointSetTopologyContainer* toTopology)
84-
: BarycentricMapperMeshTopology<TIn, TOut>(fromTopology, toTopology)
88+
sofa::component::topology::container::dynamic::PointSetTopologyContainer* toTopology)
89+
: linear::BarycentricMapperMeshTopology<TIn, TOut>(fromTopology, toTopology)
8590
{
8691
}
8792

@@ -95,10 +100,10 @@ class PersistentContactBarycentricMapperMeshTopology : public BarycentricMapperM
95100

96101

97102
template<class TIn, class TOut>
98-
class PersistentContactBarycentricMapperSparseGridTopology : public BarycentricMapperSparseGridTopology< TIn , TOut>, public PersistentContactBarycentricMapper< TIn , TOut>
103+
class PersistentContactBarycentricMapperSparseGridTopology : public linear::BarycentricMapperSparseGridTopology<TIn, TOut>, public PersistentContactBarycentricMapper< TIn , TOut>
99104
{
100105
public:
101-
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapperSparseGridTopology, TIn, TOut), SOFA_TEMPLATE2(BarycentricMapperSparseGridTopology, TIn, TOut), SOFA_TEMPLATE2(PersistentContactBarycentricMapper, TIn, TOut));
106+
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapperSparseGridTopology, TIn, TOut), SOFA_TEMPLATE2(linear::BarycentricMapperSparseGridTopology, TIn, TOut), SOFA_TEMPLATE2(PersistentContactBarycentricMapper, TIn, TOut));
102107

103108
typedef TIn In;
104109
typedef TOut Out;
@@ -109,12 +114,12 @@ class PersistentContactBarycentricMapperSparseGridTopology : public BarycentricM
109114
typedef typename InDataTypes::Deriv InDeriv;
110115
typedef typename InDataTypes::Real Real;
111116

112-
typedef BarycentricMapperSparseGridTopology< TIn , TOut> Inherit;
117+
typedef linear::BarycentricMapperSparseGridTopology< TIn , TOut> Inherit;
113118
typedef typename Inherit::CubeData CubeData;
114119

115-
PersistentContactBarycentricMapperSparseGridTopology(topology::SparseGridTopology* fromTopology,
116-
topology::PointSetTopologyContainer* toTopology)
117-
: BarycentricMapperSparseGridTopology<TIn, TOut>(fromTopology, toTopology)
120+
PersistentContactBarycentricMapperSparseGridTopology(sofa::component::topology::container::grid::SparseGridTopology* fromTopology,
121+
topology::container::dynamic::PointSetTopologyContainer* toTopology)
122+
: linear::BarycentricMapperSparseGridTopology<TIn, TOut>(fromTopology, toTopology)
118123
{
119124
}
120125

@@ -135,10 +140,10 @@ class PersistentContactBarycentricMapperSparseGridTopology : public BarycentricM
135140

136141

137142
template<class TIn, class TOut>
138-
class PersistentContactBarycentricMapperTetrahedronSetTopology : public BarycentricMapperTetrahedronSetTopology< TIn , TOut>, public PersistentContactBarycentricMapper< TIn , TOut>
143+
class PersistentContactBarycentricMapperTetrahedronSetTopology : public linear::BarycentricMapperTetrahedronSetTopology<TIn, TOut>, public PersistentContactBarycentricMapper< TIn , TOut>
139144
{
140145
public:
141-
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapperTetrahedronSetTopology, TIn, TOut), SOFA_TEMPLATE2(BarycentricMapperTetrahedronSetTopology, TIn, TOut), SOFA_TEMPLATE2(PersistentContactBarycentricMapper, TIn, TOut));
146+
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapperTetrahedronSetTopology, TIn, TOut), SOFA_TEMPLATE2(linear::BarycentricMapperTetrahedronSetTopology, TIn, TOut), SOFA_TEMPLATE2(PersistentContactBarycentricMapper, TIn, TOut));
142147

143148
typedef TIn In;
144149
typedef TOut Out;
@@ -149,12 +154,13 @@ class PersistentContactBarycentricMapperTetrahedronSetTopology : public Barycent
149154
typedef typename InDataTypes::Deriv InDeriv;
150155
typedef typename InDataTypes::Real Real;
151156

152-
typedef BarycentricMapperTetrahedronSetTopology<TIn, TOut> Inherit;
153-
typedef typename Inherit::MappingData MappingData;
157+
typedef linear::BarycentricMapperTetrahedronSetTopology<TIn, TOut> Inherit;
158+
typedef typename linear::BarycentricMapper<TIn, TOut>::MappingData3D MappingData;
154159

155-
PersistentContactBarycentricMapperTetrahedronSetTopology(topology::TetrahedronSetTopologyContainer* fromTopology,
156-
topology::PointSetTopologyContainer* toTopology)
157-
: BarycentricMapperTetrahedronSetTopology<TIn, TOut>(fromTopology, toTopology)
160+
PersistentContactBarycentricMapperTetrahedronSetTopology(
161+
topology::container::dynamic::TetrahedronSetTopologyContainer* fromTopology,
162+
topology::container::dynamic::PointSetTopologyContainer* toTopology)
163+
: linear::BarycentricMapperTetrahedronSetTopology<TIn, TOut>(fromTopology, toTopology)
158164
{
159165
}
160166

@@ -176,12 +182,12 @@ class PersistentContactBarycentricMapperTetrahedronSetTopology : public Barycent
176182

177183

178184
template <class TIn, class TOut>
179-
class PersistentContactBarycentricMapping : public BarycentricMapping<TIn, TOut>, public PersistentContactMapping
185+
class PersistentContactBarycentricMapping : public linear::BarycentricMapping<TIn, TOut>, public PersistentContactMapping
180186
{
181187
public:
182-
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapping,TIn,TOut), SOFA_TEMPLATE2(BarycentricMapping,TIn,TOut), PersistentContactMapping);
188+
SOFA_CLASS2(SOFA_TEMPLATE2(PersistentContactBarycentricMapping,TIn,TOut), SOFA_TEMPLATE2(linear::BarycentricMapping,TIn,TOut), PersistentContactMapping);
183189

184-
typedef BarycentricMapping<TIn, TOut> Inherit;
190+
typedef linear::BarycentricMapping<TIn, TOut> Inherit;
185191
typedef TIn In;
186192
typedef TOut Out;
187193
typedef In InDataTypes;

0 commit comments

Comments
 (0)