Skip to content

Commit

Permalink
Merge pull request #1 from alxbilger/update
Browse files Browse the repository at this point in the history
Update according to SOFA changes
  • Loading branch information
fredroy authored Aug 30, 2023
2 parents ede540c + 6459919 commit 54162cd
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 52 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-10.15, windows-2019]
sofa_branch: [master, v21.12]
os: [ubuntu-20.04, macos-11, windows-2019]
sofa_branch: [master]

steps:
- name: Setup SOFA and environment
id: sofa
uses: sofa-framework/sofa-setup-action@v3.0
uses: sofa-framework/sofa-setup-action@v4
with:
sofa_root: ${{ github.workspace }}/sofa
sofa_version: ${{ matrix.sofa_branch }}
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
with:
name: ${{ github.ref_name }}
tag_name: release-${{ github.ref_name }}
fail_on_unmatched_files: true
fail_on_unmatched_files: false
files: |
artifacts/ShapeMatchingPlugin_*_Linux.zip
artifacts/ShapeMatchingPlugin_*_Windows.zip
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(ShapeMatchingPlugin LANGUAGES CXX)

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

find_package(Sofa.Core REQUIRED)

set(HEADER_FILES
${SHAPEMATCHINGPLUGIN_SRC}/config.h.in
${SHAPEMATCHINGPLUGIN_SRC}/initShapeMatchingPlugin.h
Expand All @@ -18,10 +20,8 @@ set(SOURCE_FILES
${SHAPEMATCHINGPLUGIN_SRC}/ShapeMatchingForceField.cpp
)

find_package(SofaBaseLinearSolver REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC SofaBaseLinearSolver)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Core)

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
Expand Down
2 changes: 1 addition & 1 deletion ShapeMatchingPluginConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@PACKAGE_INIT@

find_package(SofaBaseLinearSolver QUIET REQUIRED)
find_package(Sofa.Core QUIET REQUIRED)

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
Expand Down
40 changes: 26 additions & 14 deletions examples/ConstraintRotationFinder.scn
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
<Node name="root" gravity="0.0 -2.0 0.0" dt="0.04">
<RequiredPlugin name="SofaBoundaryCondition"/>
<RequiredPlugin name="SofaConstraint"/>
<RequiredPlugin name="SofaDeformable"/>
<RequiredPlugin name="SofaEngine"/>
<RequiredPlugin name="SofaGeneralDeformable"/>
<RequiredPlugin name="SofaImplicitOdeSolver"/>
<RequiredPlugin name="SofaLoader"/>
<RequiredPlugin name="SofaMeshCollision"/>
<RequiredPlugin name="SofaOpenglVisual"/>
<RequiredPlugin name="ShapeMatchingPlugin"/>

<FreeMotionAnimationLoop initial_guess="true" displayTime="1" />
<DefaultPipeline verbose="0" draw="0" />
<Node name="plugins">
<RequiredPlugin name="ShapeMatchingPlugin"/> <!-- Needed to use components [ShapeMatchingRotationFinder] -->
<RequiredPlugin name="Sofa.Component.AnimationLoop"/> <!-- Needed to use components [FreeMotionAnimationLoop] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [LocalMinDistance] -->
<RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [LineCollisionModel,PointCollisionModel,TriangleCollisionModel] -->
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
<RequiredPlugin name="Sofa.Component.Constraint.Lagrangian.Correction"/> <!-- Needed to use components [PrecomputedConstraintCorrection] -->
<RequiredPlugin name="Sofa.Component.Constraint.Lagrangian.Solver"/> <!-- Needed to use components [LCPConstraintSolver] -->
<RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedConstraint] -->
<RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
<RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
<RequiredPlugin name="Sofa.Component.SolidMechanics.Spring"/> <!-- Needed to use components [MeshSpringForceField,QuadBendingSprings] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
</Node>

<FreeMotionAnimationLoop />
<CollisionPipeline verbose="0" draw="0" />
<BruteForceBroadPhase />
<BVHNarrowPhase />
<LocalMinDistance name="Proximity" alarmDistance="0.50" contactDistance="0.25" />
<DefaultContactManager name="Response" response="FrictionContact" />
<CollisionResponse name="Response" response="FrictionContactConstraint"/>
<LCPConstraintSolver maxIt="1000" tolerance="0.001" />
<DefaultAnimationLoop />
<DefaultVisualManagerLoop />
<Node name="Floor">
<RegularGridTopology nx="2" ny="1" nz="2" xmin="20" xmax="-20" ymin="-3.05" ymax="-3.05" zmin="-20" zmax="20" />
Expand Down
33 changes: 22 additions & 11 deletions examples/RotationFinder.scn
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
<Node name="root" gravity="0.0 -2.0 0.0" dt="0.04">
<RequiredPlugin name="SofaBoundaryCondition"/>
<RequiredPlugin name="SofaDeformable"/>
<RequiredPlugin name="SofaEngine"/>
<RequiredPlugin name="SofaGeneralDeformable"/>
<RequiredPlugin name="SofaImplicitOdeSolver"/>
<RequiredPlugin name="SofaMeshCollision"/>
<RequiredPlugin name="SofaOpenglVisual"/>
<RequiredPlugin name="SofaLoader"/>
<RequiredPlugin name="ShapeMatchingPlugin"/>

<DefaultPipeline verbose="0" draw="0" />
<Node name="plugins">
<RequiredPlugin name="ShapeMatchingPlugin"/> <!-- Needed to use components [ShapeMatchingRotationFinder] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [NewProximityIntersection] -->
<RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [TriangleCollisionModel] -->
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
<RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedConstraint] -->
<RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [BoxROI] -->
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
<RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
<RequiredPlugin name="Sofa.Component.MechanicalLoad"/> <!-- Needed to use components [PlaneForceField,SphereForceField] -->
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
<RequiredPlugin name="Sofa.Component.SolidMechanics.Spring"/> <!-- Needed to use components [MeshSpringForceField,QuadBendingSprings] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
</Node>

<CollisionPipeline verbose="0" draw="0" />
<BruteForceBroadPhase />
<BVHNarrowPhase />
<DefaultContactManager name="Response" />
<CollisionResponse name="Response" />
<NewProximityIntersection alarmDistance="0.002" contactDistance="0.001" />
<DefaultAnimationLoop />
<DefaultVisualManagerLoop />
Expand Down
25 changes: 18 additions & 7 deletions examples/ShapeMatchingForceField.scn
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<Node name="root" dt="0.02">
<RequiredPlugin name="SofaImplicitOdeSolver"/>
<RequiredPlugin name="SofaLoader"/>
<RequiredPlugin name="SofaOpenglVisual"/>
<RequiredPlugin name="SofaMeshCollision"/>
<RequiredPlugin name="ShapeMatchingPlugin"/>
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
<RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [LineCollisionModel,PointCollisionModel,SphereCollisionModel,TriangleCollisionModel] -->
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
<RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMapping] -->
<RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
<RequiredPlugin name="Sofa.Component.SceneUtility"/> <!-- Needed to use components [InfoComponent] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<RequiredPlugin name="ShapeMatchingPlugin"/> <!-- Needed to use components [ShapeMatchingForceField,ShapeMatchingRotationFinder] -->

<DefaultAnimationLoop/>
<VisualStyle displayFlags="showBehaviorModels showForceFields" />
<DefaultPipeline verbose="0" draw="0" />
<CollisionPipeline verbose="0" draw="0" />
<BruteForceBroadPhase />
<BVHNarrowPhase />
<MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" />
<DefaultContactManager name="Response" response="default" />
<CollisionResponse name="Response" response="PenalityContactForceField" />
<Node name="cubeFEM">
<EulerImplicitSolver name="cg_odesolver" printLog="false" />
<CGLinearSolver iterations="25" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" />
Expand Down
4 changes: 2 additions & 2 deletions src/ShapeMatchingPlugin/ShapeMatchingForceField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace sofa::component::forcefield
using namespace sofa::defaulttype;

int ShapeMatchingForceFieldClass = core::RegisterObject("Meshless deformations based on shape matching")
.add< ShapeMatchingForceField<Vec3dTypes> >()
.add< ShapeMatchingForceField<Vec3Types> >()
;

template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField<Vec3dTypes>;
template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField<Vec3Types>;

} // namespace sofa::component::forcefield
2 changes: 1 addition & 1 deletion src/ShapeMatchingPlugin/ShapeMatchingForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ShapeMatchingForceField : public core::behavior::ForceField<DataTypes>
};

#if !defined(SOFA_COMPONENT_FORCEFIELD_SHAPEMATCHINGFORCEFIELD_CPP)
extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField<defaulttype::Vec3dTypes>;
extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField<defaulttype::Vec3Types>;
#endif // !defined(SOFA_COMPONENT_FORCEFIELD_SHAPEMATCHINGFORCEFIELD_CPP)

} // namespace sofa::component::forcefield
1 change: 0 additions & 1 deletion src/ShapeMatchingPlugin/ShapeMatchingForceField.inl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <sofa/helper/rmath.h>
#include <assert.h>
#include <iostream>
#include <sofa/simulation/Node.h>

namespace sofa::component::forcefield
{
Expand Down
4 changes: 2 additions & 2 deletions src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ using namespace sofa::defaulttype;

// Register in the Factory
int ShapeMatchingRotationFinderClass = core::RegisterObject("ShapeMatchingRotationFinder")
.add< ShapeMatchingRotationFinder< Vec3dTypes > >()
.add< ShapeMatchingRotationFinder< Vec3Types > >()
.addAlias("RotationFinder")
;

template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3dTypes >;
template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3Types >;

} // namespace sofa::component::container
2 changes: 1 addition & 1 deletion src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ShapeMatchingRotationFinder : public sofa::core::behavior::RotationFinder<
};

#if !defined(SOFA_COMPONENT_CONTAINER_SHAPEMATCHINGROTATIONFINDER_CPP)
extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3dTypes >;
extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3Types >;
#endif

} // namespace sofa::component::container
4 changes: 2 additions & 2 deletions src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.inl
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ void ShapeMatchingRotationFinder<DataTypes>::draw(const core::visual::VisualPara

vparams->drawTool()->disableLighting();

std::vector<type::Vector3> vertices;
std::vector<type::Vec3> vertices;
std::vector<type::RGBAColor> colors;

for (unsigned int i=0 ; i<m_rotations.size() ; i++)
Expand Down Expand Up @@ -590,7 +590,7 @@ void ShapeMatchingRotationFinder<DataTypes>::draw(const core::visual::VisualPara

vparams->drawTool()->disableLighting();

std::vector<type::Vector3> vertices;
std::vector<type::Vec3> vertices;
std::vector<type::RGBAColor> colors;

float r, g, b;
Expand Down
8 changes: 7 additions & 1 deletion src/ShapeMatchingPlugin/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@
# define SOFA_SHAPEMATCHINGPLUGIN_API SOFA_EXPORT_DYNAMIC_LIBRARY
#else
# define SOFA_SHAPEMATCHINGPLUGIN_API SOFA_IMPORT_DYNAMIC_LIBRARY
#endif
#endif

namespace shapematching
{
constexpr const char* MODULE_NAME = "@PROJECT_NAME@";
constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@";
}
4 changes: 2 additions & 2 deletions src/ShapeMatchingPlugin/initShapeMatchingPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ namespace sofa::component

const char* getModuleName()
{
return "ShapeMatchingPlugin";
return shapematching::MODULE_NAME;
}

const char* getModuleVersion()
{
return "1.0";
return shapematching::MODULE_VERSION;
}

const char* getModuleLicense()
Expand Down

0 comments on commit 54162cd

Please sign in to comment.