Skip to content
Closed
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
114 changes: 114 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: CI

on:
workflow_dispatch:
pull_request:
push:

jobs:
build-and-test:
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
sofa_branch: [master]

steps:

- name: Setup SOFA and environment
id: sofa
uses: sofa-framework/sofa-setup-action@v5
with:
sofa_root: ${{ github.workspace }}/sofa
sofa_version: ${{ matrix.sofa_branch }}
sofa_scope: 'standard'
sofa_with_sofapython3: 'true'

- name: Checkout source code
uses: actions/checkout@v2
with:
path: ${{ env.WORKSPACE_SRC_PATH }}

- name: Build and install
shell: bash
run: |
cmake_options="-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
"
if [ -e "$(command -v ccache)" ]; then
cmake_options="$cmake_options -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi
cmake_options="$(echo $cmake_options)" # prettify

if [[ "$RUNNER_OS" == "Windows" ]]; then
cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
&& cd /d $WORKSPACE_BUILD_PATH \
&& cmake $cmake_options ../src \
&& ninja install"
else
cd "$WORKSPACE_BUILD_PATH"
ccache -z
cmake $cmake_options ../src
ninja install
echo ${CCACHE_BASEDIR}
ccache -s
fi

- name: Sanitize artifact name
id: sanitize
# This step removes special characters from the artifact name to ensure compatibility with upload-artifact
# Characters removed: " : < > | * ? \r \n \ /
# Spaces are replaced with underscores
# This sanitization prevents errors in artifact creation and retrieval
shell: pwsh
run: |
$originalName = "Shell_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
$artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT

- name: Create artifact
uses: actions/upload-artifact@v4.4.0
with:
name: ${{ steps.sanitize.outputs.artifact_name }}
path: ${{ env.WORKSPACE_INSTALL_PATH }}

- name: Install artifact
uses: actions/download-artifact@v4.1.7
with:
name: ${{ steps.sanitize.outputs.artifact_name }}
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}

deploy:
name: Deploy artifacts
if: always() && startsWith(github.repository, 'SofaDefrost') && (startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/')) # we are not on a fork and on a branch or a tag (not a PR)
needs: [build-and-test]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Get artifacts
uses: actions/download-artifact@v4.1.7
with:
path: artifacts

- name: Zip artifacts
shell: bash
run: |
cd $GITHUB_WORKSPACE/artifacts
for artifact in *; do
zip $artifact.zip -r $artifact/*
done
- name: Upload release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
tag_name: release-${{ github.ref_name }}
fail_on_unmatched_files: false
target_commitish: ${{ github.ref_name }}
files: |
artifacts/Shell_*_Linux.zip
artifacts/Shell_*_Windows.zip
artifacts/Shell_*_macOS.zip
211 changes: 101 additions & 110 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12)
project(SofaShells VERSION 1.0 LANGUAGES CXX)

project(Shell VERSION 1.0 LANGUAGES CXX)

# Find and load CMake configuration of packages containing this plugin's dependencies
find_package(Sofa.Config REQUIRED)
sofa_find_package(Sofa.GL REQUIRED)
sofa_find_package(Sofa.Type REQUIRED)
Expand All @@ -17,135 +17,126 @@ sofa_find_package(Sofa.Component.Constraint.Lagrangian.Solver REQUIRED)
sofa_find_package(Sofa.Component.Topology.Container.Dynamic REQUIRED)
sofa_find_package(Sofa.Component.Collision.Detection.Intersection REQUIRED)



set(README_FILE "SofaShells.txt" )
set(README_FILE README.md)
set(SOFASHELLS_SRC_DIR src/SofaShells)


option(SOFA-PLUGIN_SHELLS_ADAPTIVITY "Enables shells adaptivity" OFF)


# List all files
set(SHELL_SRC_DIR src/Shell)
set(HEADER_FILES

${SOFASHELLS_SRC_DIR}/config.h.in
${SOFASHELLS_SRC_DIR}/controller/MeshChangedEvent.h
${SOFASHELLS_SRC_DIR}/controller/MeshInterpolator.h
${SOFASHELLS_SRC_DIR}/controller/MeshInterpolator.inl
${SOFASHELLS_SRC_DIR}/controller/TriangleSwitchExample.h
${SOFASHELLS_SRC_DIR}/controller/TriangleSwitchExample.inl
${SOFASHELLS_SRC_DIR}/engine/JoinMeshPoints.h
${SOFASHELLS_SRC_DIR}/engine/JoinMeshPoints.inl
${SOFASHELLS_SRC_DIR}/engine/FindClosePoints.h
${SOFASHELLS_SRC_DIR}/engine/FindClosePoints.inl
${SOFASHELLS_SRC_DIR}/forcefield/BezierTriangularBendingFEMForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/BezierTriangularBendingFEMForceField.inl
${SOFASHELLS_SRC_DIR}/forcefield/CstFEMForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/CstFEMForceField.inl
${SOFASHELLS_SRC_DIR}/forcefield/TriangularBendingFEMForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/TriangularBendingFEMForceField.inl
${SOFASHELLS_SRC_DIR}/forcefield/TriangularShellForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/TriangularShellForceField.inl
${SOFASHELLS_SRC_DIR}/mapping/BendingPlateMechanicalMapping.h
${SOFASHELLS_SRC_DIR}/mapping/BendingPlateMechanicalMapping.inl
${SOFASHELLS_SRC_DIR}/mapping/BezierTriangleMechanicalMapping.h
${SOFASHELLS_SRC_DIR}/mapping/BezierTriangleMechanicalMapping.inl
${SOFASHELLS_SRC_DIR}/misc/PointProjection.h
${SOFASHELLS_SRC_DIR}/misc/PointProjection.inl
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolation.h
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolation.inl
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolationM.h
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolationM.inl
${SOFASHELLS_SRC_DIR}/shells2/forcefield/BezierShellForceField.h
${SOFASHELLS_SRC_DIR}/shells2/forcefield/BezierShellForceField.inl
${SOFASHELLS_SRC_DIR}/shells2/mapping/BezierShellMechanicalMapping.h
${SOFASHELLS_SRC_DIR}/shells2/mapping/BezierShellMechanicalMapping.inl
)
${SOFASHELLS_SRC_DIR}/config.h.in
${SOFASHELLS_SRC_DIR}/controller/MeshChangedEvent.h
${SOFASHELLS_SRC_DIR}/controller/MeshInterpolator.h
${SOFASHELLS_SRC_DIR}/controller/MeshInterpolator.inl
${SOFASHELLS_SRC_DIR}/controller/TriangleSwitchExample.h
${SOFASHELLS_SRC_DIR}/controller/TriangleSwitchExample.inl
${SOFASHELLS_SRC_DIR}/engine/JoinMeshPoints.h
${SOFASHELLS_SRC_DIR}/engine/JoinMeshPoints.inl
${SOFASHELLS_SRC_DIR}/engine/FindClosePoints.h
${SOFASHELLS_SRC_DIR}/engine/FindClosePoints.inl
${SOFASHELLS_SRC_DIR}/forcefield/BezierTriangularBendingFEMForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/BezierTriangularBendingFEMForceField.inl
${SOFASHELLS_SRC_DIR}/forcefield/CstFEMForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/CstFEMForceField.inl
${SOFASHELLS_SRC_DIR}/forcefield/TriangularBendingFEMForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/TriangularBendingFEMForceField.inl
${SOFASHELLS_SRC_DIR}/forcefield/TriangularShellForceField.h
${SOFASHELLS_SRC_DIR}/forcefield/TriangularShellForceField.inl
${SOFASHELLS_SRC_DIR}/mapping/BendingPlateMechanicalMapping.h
${SOFASHELLS_SRC_DIR}/mapping/BendingPlateMechanicalMapping.inl
${SOFASHELLS_SRC_DIR}/mapping/BezierTriangleMechanicalMapping.h
${SOFASHELLS_SRC_DIR}/mapping/BezierTriangleMechanicalMapping.inl
${SOFASHELLS_SRC_DIR}/misc/PointProjection.h
${SOFASHELLS_SRC_DIR}/misc/PointProjection.inl
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolation.h
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolation.inl
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolationM.h
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolationM.inl
${SOFASHELLS_SRC_DIR}/shells2/forcefield/BezierShellForceField.h
${SOFASHELLS_SRC_DIR}/shells2/forcefield/BezierShellForceField.inl
${SOFASHELLS_SRC_DIR}/shells2/mapping/BezierShellMechanicalMapping.h
${SOFASHELLS_SRC_DIR}/shells2/mapping/BezierShellMechanicalMapping.inl
)

set(SOURCE_FILES

${SOFASHELLS_SRC_DIR}/initPluginShells.cpp
${SOFASHELLS_SRC_DIR}/controller/MeshChangedEvent.cpp
${SOFASHELLS_SRC_DIR}/controller/MeshInterpolator.cpp
${SOFASHELLS_SRC_DIR}/controller/TriangleSwitchExample.cpp
${SOFASHELLS_SRC_DIR}/engine/JoinMeshPoints.cpp
${SOFASHELLS_SRC_DIR}/engine/FindClosePoints.cpp
${SOFASHELLS_SRC_DIR}/forcefield/BezierTriangularBendingFEMForceField.cpp
${SOFASHELLS_SRC_DIR}/forcefield/CstFEMForceField.cpp
${SOFASHELLS_SRC_DIR}/forcefield/TriangularBendingFEMForceField.cpp
${SOFASHELLS_SRC_DIR}/forcefield/TriangularShellForceField.cpp
${SOFASHELLS_SRC_DIR}/mapping/BendingPlateMechanicalMapping.cpp
${SOFASHELLS_SRC_DIR}/mapping/BezierTriangleMechanicalMapping.cpp
${SOFASHELLS_SRC_DIR}/misc/PointProjection.cpp
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolation.cpp
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolationM.cpp
${SOFASHELLS_SRC_DIR}/shells2/forcefield/BezierShellForceField.cpp
${SOFASHELLS_SRC_DIR}/shells2/mapping/BezierShellMechanicalMapping.cpp
)





${SOFASHELLS_SRC_DIR}/initPluginShells.cpp
${SOFASHELLS_SRC_DIR}/controller/MeshChangedEvent.cpp
${SOFASHELLS_SRC_DIR}/controller/MeshInterpolator.cpp
${SOFASHELLS_SRC_DIR}/controller/TriangleSwitchExample.cpp
${SOFASHELLS_SRC_DIR}/engine/JoinMeshPoints.cpp
${SOFASHELLS_SRC_DIR}/engine/FindClosePoints.cpp
${SOFASHELLS_SRC_DIR}/forcefield/BezierTriangularBendingFEMForceField.cpp
${SOFASHELLS_SRC_DIR}/forcefield/CstFEMForceField.cpp
${SOFASHELLS_SRC_DIR}/forcefield/TriangularBendingFEMForceField.cpp
${SOFASHELLS_SRC_DIR}/forcefield/TriangularShellForceField.cpp
${SOFASHELLS_SRC_DIR}/mapping/BendingPlateMechanicalMapping.cpp
${SOFASHELLS_SRC_DIR}/mapping/BezierTriangleMechanicalMapping.cpp
${SOFASHELLS_SRC_DIR}/misc/PointProjection.cpp
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolation.cpp
${SOFASHELLS_SRC_DIR}/shells2/fem/BezierShellInterpolationM.cpp
${SOFASHELLS_SRC_DIR}/shells2/forcefield/BezierShellForceField.cpp
${SOFASHELLS_SRC_DIR}/shells2/mapping/BezierShellMechanicalMapping.cpp
)

if(SOFA-PLUGIN_SHELLS_ADAPTIVITY)
set(COMPILER_DEFINE "SOFA_BUILD_SHELLS_ADAPTIVITY")

list(APPEND HEADER_FILES

${SOFASHELLS_SRC_DIR}/controller/AdaptiveCuttingController.h
${SOFASHELLS_SRC_DIR}/controller/AdaptiveCuttingController.inl
${SOFASHELLS_SRC_DIR}/controller/Test2DAdapter.h
${SOFASHELLS_SRC_DIR}/controller/Test2DAdapter.inl
${SOFASHELLS_SRC_DIR}/misc/Optimize2DSurface.h
${SOFASHELLS_SRC_DIR}/misc/Optimize2DSurface.inl
${SOFASHELLS_SRC_DIR}/misc/SurfaceParametrization.h
${SOFASHELLS_SRC_DIR}/misc/SurfaceParametrization.inl
)


list(APPEND SOURCE_FILES

${SOFASHELLS_SRC_DIR}/controller/AdaptiveCuttingController.cpp
${SOFASHELLS_SRC_DIR}/controller/Test2DAdapter.cpp
${SOFASHELLS_SRC_DIR}/misc/Optimize2DSurface.cpp
${SOFASHELLS_SRC_DIR}/misc/SurfaceParametrization.cpp
)


if(SofaGui_FOUND AND SofaOpenglVisual_FOUND)
set(COMPILER_DEFINE "SOFA_BUILD_SHELLS_ADAPTIVITY")

list(APPEND HEADER_FILES
${SOFASHELLS_SRC_DIR}/controller/AdaptiveCuttingController.h
${SOFASHELLS_SRC_DIR}/controller/AdaptiveCuttingController.inl
${SOFASHELLS_SRC_DIR}/controller/Test2DAdapter.h
${SOFASHELLS_SRC_DIR}/controller/Test2DAdapter.inl
${SOFASHELLS_SRC_DIR}/misc/Optimize2DSurface.h
${SOFASHELLS_SRC_DIR}/misc/Optimize2DSurface.inl
${SOFASHELLS_SRC_DIR}/misc/SurfaceParametrization.h
${SOFASHELLS_SRC_DIR}/misc/SurfaceParametrization.inl
)

list(APPEND HEADER_FILES
${SOFASHELLS_SRC_DIR}/cutting/AdaptiveCutting.h
)
list(APPEND SOURCE_FILES
${SOFASHELLS_SRC_DIR}/controller/AdaptiveCuttingController.cpp
${SOFASHELLS_SRC_DIR}/controller/Test2DAdapter.cpp
${SOFASHELLS_SRC_DIR}/misc/Optimize2DSurface.cpp
${SOFASHELLS_SRC_DIR}/misc/SurfaceParametrization.cpp
)

list(APPEND SOURCE_FILES
${SOFASHELLS_SRC_DIR}/cutting/AdaptiveCutting.cpp
)
if(SofaGui_FOUND AND SofaOpenglVisual_FOUND)
list(APPEND HEADER_FILES
${SOFASHELLS_SRC_DIR}/cutting/AdaptiveCutting.h
)

endif()
list(APPEND SOURCE_FILES
${SOFASHELLS_SRC_DIR}/cutting/AdaptiveCutting.cpp
)
endif()

endif()


# Create the plugin library
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${README_FILES})

# Link the plugin library to its dependency
target_link_libraries(${PROJECT_NAME} Sofa.Component.Controller Sofa.Helper Sofa.Type Sofa.Component.Topology.Container.Dynamic Sofa.Component.StateContainer
Sofa.Core Sofa.Geometry Sofa.GL Sofa.Component.Collision.Detection.Intersection Sofa.Component.Mapping.NonLinear Sofa.Component.Constraint.Lagrangian.Model
Sofa.Component.Constraint.Lagrangian.Solver Sofa.Component.Constraint.Lagrangian Sofa.Component.Constraint
Sofa.Simulation.Core Sofa.Component.Constraint.Projective Sofa.Component.Mass Sofa.Component.SolidMechanics.Spring Sofa.Component.MechanicalLoad
Sofa.Component.LinearSolver.Iterative Sofa.Component.ODESolver.Backward Sofa.Component.Engine.Select Sofa.Component.Mapping.Linear
# Link the plugin library to its dependency(ies).
target_link_libraries(${PROJECT_NAME}
Sofa.Component.Controller
Sofa.Component.Topology.Container.Dynamic
Sofa.Component.StateContainer
Sofa.GL
Sofa.Component.Collision.Detection.Intersection
Sofa.Component.Mapping.NonLinear
Sofa.Component.Constraint.Lagrangian.Model
Sofa.Component.Constraint.Lagrangian.Solver
Sofa.Component.Constraint.Lagrangian
Sofa.Component.Constraint.Projective
Sofa.Component.Mass
Sofa.Component.SolidMechanics.Spring
Sofa.Component.MechanicalLoad
Sofa.Component.LinearSolver.Iterative
Sofa.Component.ODESolver.Backward
Sofa.Component.Engine.Select
Sofa.Component.Mapping.Linear
)


if(SofaGui_FOUND AND SofaOpenglVisual_FOUND)
target_link_libraries(${PROJECT_NAME} SofaGui SofaOpenglVisual)
endif()


# Create package Config, Version & Target files
sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
PACKAGE_VERSION ${PROJECT_VERSION}
Expand Down
Loading
Loading