Skip to content

Commit

Permalink
upload to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-ziqi committed Nov 13, 2024
1 parent 0e16e0d commit d8aac8a
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build
.idea
dist
venv
*.spec
*.spec
*.egg-info
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ STL Compressor is a tool designed to compress STL files efficiently. Users can c

## Usage

* Windows users can download [here](https://github.com/fan-ziqi/stl_compresser/releases)
* Windows users can download [here](https://github.com/fan-ziqi/stl_compressor/releases)

* Python

```bash
git clone https://github.com/fan-ziqi/stl_compresser.git
cd stl_compresser
pip install -r requirements.txt
python stl_compresser_ui.py
pip install --upgrade stl_compressor -i https://www.pypi.org/simple/
stl_compressor
```

## Packaging

To package the application as a standalone executable, use PyInstaller:

```bash
pyinstaller --onefile --windowed stl_compresser_ui.py
```
pyinstaller --onefile --windowed stl_compressor/stl_compressor_ui.py
```

## Upload to Pypi

```bash
python setup.py check
python setup.py sdist bdist_wheel
twine upload dist/*
```
Binary file removed output/3DBenchy.stl
Binary file not shown.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
trimesh
open3d
open3d
fast_simplification
25 changes: 25 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from distutils.core import setup
from setuptools import find_packages

with open("README.md", "r") as f:
long_description = f.read()

setup(
name="stl_compressor",
version="2.2",
description="STL Compressor",
long_description=long_description,
long_description_content_type="text/markdown",
author="Ziqi Fan",
author_email="[email protected]",
url="https://github.com/fan-ziqi/stl_compressor",
install_requires=[],
license="Apache License 2.0",
packages=find_packages(),
entry_points={"console_scripts": ["stl_compressor = stl_compressor.stl_compressor_ui:main"]},
platforms=["all"],
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
)
19 changes: 0 additions & 19 deletions stl_compresser.py

This file was deleted.

Empty file added stl_compressor/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions stl_compressor/stl_compressor_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
import open3d as o3d

target_number_of_triangles = 1000

current_directory = os.getcwd()

input_directory = os.path.join(current_directory, 'test/input')
output_directory = os.path.join(current_directory, 'test/output')

if not os.path.exists(output_directory):
os.makedirs(output_directory)

for stl_file in os.listdir(input_directory):
if stl_file.lower().endswith(".stl"):
mesh = o3d.io.read_triangle_mesh(os.path.join(input_directory, stl_file))
simplified_mesh = mesh.simplify_quadric_decimation(target_number_of_triangles)
simplified_mesh.compute_triangle_normals()
simplified_mesh.compute_vertex_normals()
output_file_path = os.path.join(output_directory, stl_file)
o3d.io.write_triangle_mesh(output_file_path, simplified_mesh)
27 changes: 20 additions & 7 deletions stl_compresser_ui.py → stl_compressor/stl_compressor_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import tkinter as tk
from tkinter import filedialog
from tkinter import ttk
import trimesh
# import trimesh
import open3d as o3d
import threading

def choose_files(entry_widget):
# Function to choose input files
paths = filedialog.askopenfilenames(filetypes=[("STL files", "*.stl")])
paths = filedialog.askopenfilenames(filetypes=[("STL files", "*.stl"), ("STL files", "*.STL")])
if paths:
entry_widget.delete(0, tk.END)
entry_widget.insert(0, ";".join(paths))
Expand All @@ -27,10 +28,17 @@ def compress_stl(input_paths, output_path, target_triangles, progress_bar, progr
progress_per_file = 100 / total_files

for i, file_path in enumerate(files):
mesh = trimesh.load_mesh(file_path)
# mesh = trimesh.load_mesh(file_path)
# simplified_mesh = mesh.simplify_quadric_decimation(target_triangles)
# output_file_path = os.path.join(output_path, os.path.basename(file_path))
# simplified_mesh.export(output_file_path)

mesh = o3d.io.read_triangle_mesh(file_path)
simplified_mesh = mesh.simplify_quadric_decimation(target_triangles)
simplified_mesh.compute_triangle_normals()
simplified_mesh.compute_vertex_normals()
output_file_path = os.path.join(output_path, os.path.basename(file_path))
simplified_mesh.export(output_file_path)
o3d.io.write_triangle_mesh(output_file_path, simplified_mesh)

# Update progress bar
progress = int((i + 1) * progress_per_file)
Expand Down Expand Up @@ -84,6 +92,7 @@ def on_compress_finished():
# Start the thread
compress_thread.start()


root = tk.Tk()
root.title("STL Compressor")
root.resizable(False, False) # Disable resizing
Expand Down Expand Up @@ -142,12 +151,16 @@ def on_compress_finished():
bottom_frame = tk.Frame(window)
bottom_frame.pack(side=tk.BOTTOM, fill=tk.X)

version_label = tk.Label(bottom_frame, text="STL Compressor v1.2")
version_label = tk.Label(bottom_frame, text="STL Compressor v2.2")
version_label.pack(side=tk.LEFT)

licence_label = tk.Label(bottom_frame, text="Made by github@fan-ziqi")
licence_label = tk.Label(bottom_frame, text="Developed by github@fan-ziqi")
licence_label.pack(side=tk.RIGHT)

window.grid(row=0, column=0)

window.mainloop()
def main():
window.mainloop()

if __name__ == '__main__':
main()
File renamed without changes.
Binary file added test/output/3DBenchy.stl
Binary file not shown.

0 comments on commit d8aac8a

Please sign in to comment.