Compare commits

...
30 Commits
Author SHA1 Message Date
Alex38Lyon db3f81a0aa Auto-convert PLY to reduced STL 2026-08-28 08:07:42 +00:00
Alex38Lyon fba7a1f901 ply tests 2026-08-28 10:06:14 +02:00
Alex38Lyon 66e9ca81eb Auto-convert PLY to reduced STL 2026-08-28 08:01:58 +00:00
Alex38Lyon ad33c6449a Create Complexe_Lonne_Peyret-Bourrugues.ply 2026-08-28 10:01:01 +02:00
Alex38Lyon c9cfabde08 Delete UKK22-Tobozo-Plan.ply 2026-08-28 10:00:32 +02:00
Alex38Lyon 135bd8e49c Modify PLY to STL conversion workflow
Updated GitHub Actions workflow for PLY to STL conversion.
2026-08-28 09:59:16 +02:00
Alex38Lyon 45cd0c8b89 Create UKK22-Tobozo-Plan.ply 2026-08-28 09:56:46 +02:00
Alex38Lyon 2883e7ace6 update 2026-08-28 09:56:23 +02:00
Alex38Lyon fe21631616 Add workflow to convert PLY files to STL
This workflow automates the conversion of PLY files to STL format, optimizing the output size while maintaining quality. It includes steps for checking out the repository, setting up Python, installing dependencies, and committing the generated STL files.
2026-08-28 09:55:01 +02:00
Alex38Lyon 4b24224e5c update ply 2026-08-28 09:42:30 +02:00
Alex38Lyon e182fde460 Auto-convert PLY to STL/OBJ 2026-08-28 07:38:27 +00:00
Alex38Lyon f65ea58cb5 update 2026-08-28 09:37:32 +02:00
Alex38Lyon db3a64bb6a Merge branch 'main' of https://github.com/Alex38Lyon/Synthese-PSM_LARRA 2026-08-28 09:20:57 +02:00
Alex38Lyon ef2efe20ac update 2026-08-28 09:20:39 +02:00
Alex38Lyon dd0dc5261d Update workflow to include write permissions
Add permissions for write access to contents
2026-08-28 09:16:16 +02:00
Alex38Lyon a959db91e6 Create UKK22-Tobozo-Plan.ply 2026-08-28 09:09:25 +02:00
Alex38Lyon ec4bff6518 Add workflow to convert PLY to STL/OBJ
This workflow automatically converts PLY files to STL and OBJ formats upon push events.
2026-08-28 09:07:01 +02:00
Alex38Lyon 13b3afb09b Delete ConvertPLYtoSTL.yml 2026-08-28 09:04:58 +02:00
Alex38Lyon b6865401df Merge branch 'main' of https://github.com/Alex38Lyon/Synthese-PSM_LARRA 2026-08-28 09:04:25 +02:00
Alex38Lyon ace675538f Create Complexe_PSM_GdP.lox 2026-08-28 09:04:06 +02:00
Alex38Lyon 4bde4ac20a Delete .github/workflows/convertPLYtoSTL.yml 2026-08-28 09:01:05 +02:00
Alex38Lyon 92a104f42f Create Synthese-PSM_LARRA.ply 2026-08-28 08:58:25 +02:00
Alex38Lyon 7af32bee16 Delete Synthese-PSM_LARRA.ply 2026-08-28 08:57:40 +02:00
Alex38Lyon 9d1b646a6e Merge branch 'main' of https://github.com/Alex38Lyon/Synthese-PSM_LARRA 2026-08-28 08:55:35 +02:00
Alex38Lyon 2550fc7033 Update Synthese-PSM_LARRA.ply 2026-08-28 08:55:08 +02:00
Alex38Lyon ec246b9604 Add workflow to convert PLY to STL/OBJ 2026-08-28 08:53:58 +02:00
Alex38Lyon 28797bea79 Update convertPLYtoSTL.yml 2026-08-28 08:50:56 +02:00
Alex38Lyon 5316c570b5 Merge branch 'main' of https://github.com/Alex38Lyon/Synthese-PSM_LARRA 2026-08-28 08:44:47 +02:00
Alex38Lyon 53ff8cf394 Create Synthese-PSM_LARRA.ply 2026-08-28 08:44:42 +02:00
Alex38Lyon 90a00c1f50 Add workflow to convert PLY to STL/OBJ
This workflow automatically converts PLY files to STL format upon push.
2026-08-28 08:42:29 +02:00
10 changed files with 290 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
name: Convert PLY to STL/OBJ
on:
push:
paths:
- '**/*.ply'
permissions:
contents: write
jobs:
convert:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v7
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install trimesh numpy
- name: Convert PLY files
run: |
python -c "
import trimesh
import glob
import os
for f in glob.glob('**/*.ply', recursive=True):
print(f'Conversion de {f}')
mesh = trimesh.load(f)
stl = os.path.splitext(f)[0] + '.stl'
obj = os.path.splitext(f)[0] + '.obj'
mesh.export(stl)
mesh.export(obj)
print(f' -> {stl}')
print(f' -> {obj}')
"
- name: Commit converted files
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "Auto-convert PLY to STL/OBJ"
+246
View File
@@ -0,0 +1,246 @@
name: Convert PLY to STL
on:
push:
paths:
- '**/*.ply'
workflow_dispatch:
permissions:
contents: write
jobs:
convert:
runs-on: ubuntu-latest
steps:
# ------------------------------------------------------------
# Récupération du dépôt
# ------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v6
# ------------------------------------------------------------
# Installation de Python
# ------------------------------------------------------------
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.13'
# ------------------------------------------------------------
# Installation des bibliothèques
# ------------------------------------------------------------
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install trimesh numpy fast-simplification
# ------------------------------------------------------------
# Conversion PLY -> STL
# Recherche automatique du meilleur compromis qualité/taille
# ------------------------------------------------------------
- name: Convert PLY files to STL
run: |
python <<'PY'
import trimesh
import glob
import os
import tempfile
# Taille maximale autorisée.
# 50 MiB = 50 * 1024 * 1024 octets
MAX_SIZE = 50 * 1024 * 1024
# Marge de sécurité :
# on vise légèrement sous 50 MiB afin d'éviter
# tout dépassement lié aux métadonnées ou différences
# de calcul.
TARGET_SIZE = 49 * 1024 * 1024
# Ratios testés, du meilleur au moins bon.
# Le script s'arrête dès qu'il trouve un fichier
# suffisamment petit.
RATIOS = [
1.00,
0.90,
0.80,
0.70,
0.60,
0.50,
0.40,
0.30,
0.20,
0.10
]
ply_files = glob.glob('**/*.ply', recursive=True)
if not ply_files:
print("Aucun fichier PLY trouvé.")
exit(0)
for ply in ply_files:
print()
print("=" * 70)
print(f"Fichier : {ply}")
print("=" * 70)
# ----------------------------------------------------
# Chargement du maillage
# ----------------------------------------------------
mesh = trimesh.load(ply, force='mesh')
if mesh.is_empty:
print("ERREUR : maillage vide")
continue
if not isinstance(mesh, trimesh.Trimesh):
print("ERREUR : le fichier ne contient pas un maillage triangulaire.")
continue
original_faces = len(mesh.faces)
print(f"Triangles initiaux : {original_faces:,}")
# ----------------------------------------------------
# Fichier STL temporaire
# ----------------------------------------------------
base = os.path.splitext(ply)[0]
stl = base + '.stl'
best_mesh = None
best_size = None
best_ratio = None
# ----------------------------------------------------
# Essai des différents niveaux de simplification
# ----------------------------------------------------
for ratio in RATIOS:
target_faces = max(
1000,
int(original_faces * ratio)
)
print()
print(
f"Test : {ratio * 100:.0f}% "
f"({target_faces:,} triangles)"
)
# ------------------------------------------------
# Pas de simplification pour 100 %
# ------------------------------------------------
if ratio >= 1.0:
test_mesh = mesh.copy()
else:
try:
test_mesh = mesh.simplify_quadric_decimation(
face_count=target_faces
)
except Exception as e:
print(
"Erreur lors de la simplification : "
f"{e}"
)
continue
# ------------------------------------------------
# Export STL temporaire
# ------------------------------------------------
with tempfile.NamedTemporaryFile(
suffix='.stl',
delete=False
) as tmp:
temp_stl = tmp.name
try:
test_mesh.export(temp_stl)
size = os.path.getsize(temp_stl)
finally:
if os.path.exists(temp_stl):
os.remove(temp_stl)
size_mb = size / (1024 * 1024)
print(
f" -> {len(test_mesh.faces):,} triangles"
)
print(
f" -> {size_mb:.2f} MiB"
)
# ------------------------------------------------
# On conserve le premier résultat sous 49 MiB.
#
# Comme les ratios sont testés du plus grand
# au plus petit, c'est le meilleur résultat
# possible parmi les valeurs testées.
# ------------------------------------------------
if size < TARGET_SIZE:
best_mesh = test_mesh
best_size = size
best_ratio = ratio
print(" -> Taille acceptable")
break
# ----------------------------------------------------
# Aucun résultat suffisamment petit
# ----------------------------------------------------
if best_mesh is None:
print()
print(
"ERREUR : impossible d'obtenir un STL "
f"inférieur à {TARGET_SIZE / (1024 * 1024):.0f} MiB."
)
continue
# ----------------------------------------------------
# Export définitif
# ----------------------------------------------------
best_mesh.export(stl)
final_size = os.path.getsize(stl)
final_size_mb = final_size / (1024 * 1024)
print()
print("-" * 70)
print("RESULTAT")
print("-" * 70)
print(f"Fichier STL : {stl}")
print(f"Triangles : {len(best_mesh.faces):,}")
print(f"Ratio : {best_ratio * 100:.0f}%")
print(f"Taille : {final_size_mb:.2f} MiB")
print(f"Taille limite : 50.00 MiB")
if final_size >= MAX_SIZE:
print("ATTENTION : fichier supérieur à 50 MiB !")
else:
print("OK : fichier inférieur à 50 MiB.")
print("-" * 70)
PY
# ------------------------------------------------------------
# Commit des STL générés
# ------------------------------------------------------------
- name: Commit converted STL files
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "Auto-convert PLY to reduced STL"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.