Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/testing_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
python-version: [3.8, 3.9]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ See the [**Examples**](#examples) section below and the [**Tutorials**](tutorial

## Dependencies and installation
**BladeX** requires `numpy`, `scipy`, `matplotlib`, `sphinx` (for the documentation), and `pytest` (for the local test). They can be easily installed using `pip`.
**BladeX** is compatible with Python 3.6. Moreover, some of the modules require `OCC` to be installed for the `.iges` or `.stl` CAD generation. This requirement cannot be satisfied through `pip`, but the precompiled binaries are available on `conda` using the command:
**BladeX** is compatible with Python>=3.9. Moreover, some of the modules require `OCC` to be installed for the `.iges` or `.stl` CAD generation. This requirement cannot be satisfied through `pip`, but the precompiled binaries are available on `conda` using the command:

```bash
> conda install -c conda-forge pythonocc-core=7.4.0
> conda install -c conda-forge pythonocc-core
```

You can also refer to `pythonocc.org` or `github.com/tpaviot/pythonocc-core` for further instructions.
Expand Down
10 changes: 7 additions & 3 deletions bladex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""
BladeX init
"""
__all__ = ['ProfileInterface', 'NacaProfile', 'CustomProfile',
'ReversePropeller', 'Blade', 'Shaft', 'Propeller', 'Deformation',
'ParamFile', 'RBF', 'reconstruct_f', 'scipy_bspline']
__all__ = [
'ProfileInterface', 'NacaProfile', 'CustomProfile',
'ReversePropeller', 'Blade', 'Shaft', 'CylinderShaft',
'Propeller', 'Deformation', 'ParamFile', 'RBF',
'reconstruct_f', 'scipy_bspline'
]

from .meta import *
from .profile import ProfileInterface
Expand All @@ -16,3 +19,4 @@
from .params import ParamFile
from .ndinterpolator import RBF, reconstruct_f, scipy_bspline
from .reversepropeller import ReversePropeller
from .cylinder_shaft import CylinderShaft
2 changes: 1 addition & 1 deletion bladex/blade.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def generate_solid(self,
sewer.Perform()
result_shell = sewer.SewedShape()
solid_maker = BRepBuilderAPI_MakeSolid()
solid_maker.Add(OCC.Core.TopoDS.topods_Shell(result_shell))
solid_maker.Add(OCC.Core.TopoDS.topods.Shell(result_shell))
if not solid_maker.IsDone():
raise RuntimeError('Unsuccessful assembling of solid blade')
result_solid = solid_maker.Solid()
Expand Down
53 changes: 53 additions & 0 deletions bladex/cylinder_shaft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
""" Cylinder Shaft """
from OCC.Display.SimpleGui import init_display
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeCylinder
from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Ax2


class CylinderShaft:
"""
Cylinder shaft construction.

:param float radius: radius of the cylinder shaft. Defaults to 1.0.
:param float height: height of the cylinder shaft. Defaults to 1.0.
:param list orientation: orientation vector of the cylinder shaft. Defaults
to [1.0, 0.0, 0.0], so along X axis.
:param list origin: origin point of the cylinder shaft. Defaults to
[0.0, 0.0, 0.0].
"""

def __init__(self, radius=1.0, height=1.0, orientation=None, origin=None):
self.radius = radius
self.height = height

if orientation is None:
self.orientation = [1.0, 0.0, 0.0] # default orientation along X

if origin is None:
self.origin = [0.0, 0.0, 0.0] # default origin at (0,0,0)

def generate_solid(self):
"""
Generate a cylindrical shaft using the BRepBuilderAPI_MakeCylinder
algorithm. This method requires PythonOCC to be installed.

:return: solid shaft
:rtype: OCC.Core.TopoDS.TopoDS_Solid
"""

origin = gp_Pnt(*self.origin)
orientation = gp_Dir(*self.orientation)
ax2 = gp_Ax2(origin, orientation)

shape = BRepPrimAPI_MakeCylinder(ax2, self.radius, self.height).Shape()

return shape

def display(self):
"""
Display the shaft.
"""
shaft_solid = self.generate_solid()
display, start_display = init_display()[:2]
display.DisplayShape(shaft_solid, update=True)
start_display()
2 changes: 1 addition & 1 deletion bladex/shaft.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_solid(self):
sewer.Perform()
result_sewed_shaft = sewer.SewedShape()
shaft_solid_maker = BRepBuilderAPI_MakeSolid()
shaft_solid_maker.Add(OCC.Core.TopoDS.topods_Shell(result_sewed_shaft))
shaft_solid_maker.Add(OCC.Core.TopoDS.topods.Shell(result_sewed_shaft))
if not shaft_solid_maker.IsDone():
raise RuntimeError('Unsuccessful assembling of solid shaft')
shaft_solid = shaft_solid_maker.Solid()
Expand Down
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[build-system]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "BladeX"
version = "0.1.0"
description = "Python Blade Morphing"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.9"
license = { text = "MIT" }
authors = [
{ name = "Marco Tezzele", email = "[email protected]" },
{ name = "Mahmoud Gadalla", email = "[email protected]" }
]
keywords = ["blade-generation", "propeller", "iges", "procal"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Mathematics"
]
dependencies = [
"numpy",
"scipy",
"matplotlib",
]

[project.optional-dependencies]
docs = [
"Sphinx",
"sphinx_rtd_theme"
]
test = [
"pytest",
"pytest-cov"
]

[project.urls]
Homepage = "https://github.com/mathLab/BladeX"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = ["bladex*"]

61 changes: 0 additions & 61 deletions setup.py

This file was deleted.

9 changes: 9 additions & 0 deletions tests/test_cylinder_shaft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from unittest import TestCase
from bladex import CylinderShaft
from OCC.Core.TopoDS import TopoDS_Solid


def test_generate_solid_01():
sh = CylinderShaft()
shaft_solid = sh.generate_solid()
assert isinstance(shaft_solid, TopoDS_Solid)
Loading