Skip to content

Commit 3570713

Browse files
committed
refactor blade module
1 parent 0f235bc commit 3570713

File tree

12 files changed

+967
-1032
lines changed

12 files changed

+967
-1032
lines changed

bladex/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
'reconstruct_f', 'scipy_bspline'
99
]
1010

11-
from .meta import *
1211
from .profile import ProfileInterface
1312
from .profile import NacaProfile
1413
from .profile import CustomProfile
1514
from .blade import Blade
16-
from .shaft import Shaft
15+
from .shaft.shaft import Shaft
1716
from .propeller import Propeller
1817
from .deform import Deformation
1918
from .params import ParamFile
2019
from .ndinterpolator import RBF, reconstruct_f, scipy_bspline
2120
from .reversepropeller import ReversePropeller
22-
from .cylinder_shaft import CylinderShaft
21+
from .shaft.cylinder_shaft import CylinderShaft
22+
from .intepolatedface import InterpolatedFace

bladex/blade.py

Lines changed: 82 additions & 239 deletions
Large diffs are not rendered by default.

bladex/genericsolid.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
Module for the blade bottom-up parametrized construction.
3+
"""
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
from mpl_toolkits.mplot3d import Axes3D
7+
8+
class GenericSolid:
9+
10+
def __init__(self, *args, **kwds):
11+
pass

bladex/intepolatedface.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Module for the blade bottom-up parametrized construction.
3+
"""
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
from mpl_toolkits.mplot3d import Axes3D
7+
from OCC.Core.BRepOffsetAPI import BRepOffsetAPI_ThruSections
8+
from OCC.Core.gp import gp_Pnt
9+
from OCC.Core.TColgp import TColgp_HArray1OfPnt
10+
from OCC.Core.GeomAPI import GeomAPI_Interpolate
11+
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeVertex,\
12+
BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire,\
13+
BRepBuilderAPI_Sewing, BRepBuilderAPI_MakeSolid
14+
15+
class InterpolatedFace:
16+
17+
def __init__(self, pts, max_deg=3, tolerance=1e-10):
18+
19+
print(pts.shape)
20+
if pts.ndim not in [2, 3]:
21+
raise ValueError("pts must be a 2D or 3D array.")
22+
23+
if pts.ndim == 2:
24+
pts = pts[None, :, :]
25+
26+
if pts.shape[1] != 3:
27+
raise ValueError("Each point must have 3 coordinates for X, Y, Z.")
28+
29+
self.max_deg = max_deg
30+
self.tolerance = tolerance
31+
32+
generator = BRepOffsetAPI_ThruSections(False, False, tolerance)
33+
generator.SetMaxDegree(max_deg)
34+
35+
for id_section, section in enumerate(pts):
36+
vertices = TColgp_HArray1OfPnt(1, section.shape[1])
37+
for id_pt, pt in enumerate(section.T, start=1):
38+
vertices.SetValue(id_pt, gp_Pnt(*pt))
39+
40+
# Initializes an algorithm for constructing a constrained
41+
# BSpline curve passing through the points of the blade last
42+
# section
43+
bspline = GeomAPI_Interpolate(vertices, False, tolerance)
44+
bspline.Perform()
45+
46+
edge = BRepBuilderAPI_MakeEdge(bspline.Curve()).Edge()
47+
48+
if id_section == 0:
49+
root_edge = edge
50+
51+
# Add BSpline wire to the generator constructor
52+
generator.AddWire(BRepBuilderAPI_MakeWire(edge).Wire())
53+
54+
generator.Build()
55+
self.face = generator.GeneratedFace(root_edge)

bladex/meta.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)