Skip to content

Commit faf0668

Browse files
authored
Merge pull request #30 from mahgadalla/dev
Blade setMaxDeg with tests. Readme acknowledge prelica
2 parents 37f72a9 + 79cb2f1 commit faf0668

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ Here we show a bottom-up parametrized construction of the [Potsdam Propeller Tes
105105
* [Mahmoud Gadalla](mailto:[email protected])
106106
* [Marco Tezzele](mailto:[email protected])
107107

108-
under the supervision of [Dr. Andrea Mola](mailto:[email protected]) and [Prof. Gianluigi Rozza](mailto:[email protected]).
108+
under the supervision of [Dr. Andrea Mola](mailto:[email protected]) and [Prof. Gianluigi Rozza](mailto:[email protected]) in the framework of the project [PRELICA: Advanced Methodologies for Hydro-acoustic Design of Naval Propulsion](https://mathlab.sissa.it/project/prelica-metodologie-avanzate-la-progettazione-idro-acustica-dell%E2%80%99elica-navale-por-fesr-2017).
109+
109110

110111
Contact us by email for further information or questions about **BladeX**, or suggest pull requests. Contributions improving either the code or the documentation are welcome!
111112

bladex/blade.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ def generate_iges(self,
486486
upper_face=None,
487487
lower_face=None,
488488
tip=None,
489+
maxDeg=1,
489490
display=False,
490491
errors=None):
491492
"""
@@ -504,6 +505,8 @@ def generate_iges(self,
504505
the blade tip using the BRepOffsetAPI_ThruSections algorithm
505506
in order to close the blade, then exports the generated CAD into
506507
.iges file holding the name <tip_string>.iges. Default value is None
508+
:param int maxDeg: Define the maximal U degree of generated surface.
509+
Default value is 1
507510
:param bool display: if True, then display the generated CAD. Default
508511
value is False
509512
:param string errors: if string is passed then the method writes out
@@ -527,13 +530,17 @@ def generate_iges(self,
527530
from OCC.BRepOffsetAPI import BRepOffsetAPI_ThruSections
528531
from OCC.BRepExtrema import BRepExtrema_DistShapeShape
529532

533+
if maxDeg <= 0:
534+
raise ValueError('maxDeg argument must be a positive integer.')
535+
530536
if upper_face:
531537
self._check_string(filename=upper_face)
532538
# Initializes ThruSections algorithm for building a shell passing
533539
# through a set of sections (wires). The generated faces between
534540
# the edges of every two consecutive wires are smoothed out with
535541
# a precision criterion = 1e-10
536542
generator = BRepOffsetAPI_ThruSections(False, False, 1e-10)
543+
generator.SetMaxDegree(maxDeg)
537544
# Define upper edges (wires) for the face generation
538545
for i in range(self.n_sections):
539546
npoints = len(self.blade_coordinates_up[i][0])
@@ -571,6 +578,7 @@ def generate_iges(self,
571578
# the edges of every two consecutive wires are smoothed out with
572579
# a precision criterion = 1e-10
573580
generator = BRepOffsetAPI_ThruSections(False, False, 1e-10)
581+
generator.SetMaxDegree(maxDeg)
574582
# Define upper edges (wires) for the face generation
575583
for i in range(self.n_sections):
576584
npoints = len(self.blade_coordinates_down[i][0])
@@ -604,8 +612,7 @@ def generate_iges(self,
604612
if tip:
605613
self._check_string(filename=tip)
606614
generator = BRepOffsetAPI_ThruSections(False, False, 1e-10)
607-
generator.SetMaxDegree(1)
608-
615+
generator.SetMaxDegree(maxDeg)
609616
# npoints_up == npoints_down
610617
npoints = len(self.blade_coordinates_down[-1][0])
611618
vertices_1 = TColgp_HArray1OfPnt(1, npoints)

tests/test_blade.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,18 @@ def test_iges_blade_tip_generate(self):
499499
self.assertTrue(os.path.isfile('tests/test_datasets/tip.iges'))
500500
self.addCleanup(os.remove, 'tests/test_datasets/tip.iges')
501501

502+
def test_iges_blade_maxDeg_exception(self):
503+
blade = create_sample_blade_NACA()
504+
blade.apply_transformations()
505+
with self.assertRaises(ValueError):
506+
blade.generate_iges(
507+
upper_face=None,
508+
lower_face=None,
509+
tip=None,
510+
maxDeg=-1,
511+
display=False,
512+
errors=None)
513+
502514
def test_iges_errors_exception(self):
503515
blade = create_sample_blade_NACA()
504516
blade.apply_transformations()

0 commit comments

Comments
 (0)