Skip to content

Commit 1bb7ef1

Browse files
committed
Moved some repeated code to the base class and implemented check for empty intersection between blade and cutting cylinder
1 parent 69842e9 commit 1bb7ef1

File tree

3 files changed

+128
-58
lines changed

3 files changed

+128
-58
lines changed

bladex/reversepropeller/basereversepropeller.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,45 @@ def _build_cylinder(self, radius):
183183
self.cylinder_lateral_faces_list.append(surface)
184184
faces_explorer.Next()
185185

186+
def _build_intersection_cylinder_blade(self):
187+
"""
188+
Private method that constructs the section lines which are the intersections
189+
between the cylinder at a fixed radius and the blade, and the camber points.
190+
"""
191+
# Construction of the section lines between two shapes (in this case the
192+
# blade and the lateral face of the cylinder)
193+
section_builder = BRepAlgoAPI_Section(self.blade_solid,
194+
self.cylinder_lateral_face, False)
195+
# Define and build the parametric 2D curve (pcurve) for the section lines defined above
196+
section_builder.ComputePCurveOn2(True)
197+
section_builder.Build()
198+
self.section = section_builder.Shape()
199+
edgeExplorer = TopExp_Explorer(self.section, TopAbs_EDGE)
200+
wire_maker = BRepBuilderAPI_MakeWire()
201+
202+
edgeCount = 0
203+
edgeList = TopTools_ListOfShape()
204+
# Checking if the intersection is null, i.e. no edes from the the section
205+
if not edgeExplorer.More():
206+
raise ValueError(
207+
"Cylinder radius too small/large: no intersection with blade." \
208+
"The radii must be in mm and not m"
209+
)
210+
211+
while edgeExplorer.More():
212+
edgeCount = edgeCount + 1 # Numbering from 1 in OCC
213+
edge = topods.Edge(edgeExplorer.Current())
214+
edgeList.Append(edge)
215+
edgeExplorer.Next()
216+
wire_maker.Add(edgeList)
217+
self.wire = wire_maker.Wire()
218+
self.section_wires_list.append(self.wire)
219+
self.curve_adaptor = BRepAdaptor_CompCurve(
220+
OCC.Core.TopoDS.topods.Wire(self.wire))
221+
# Length of the curve section (ascissa curvilinea)
222+
self.total_section_length = GCPnts_AbscissaPoint.Length(
223+
self.curve_adaptor)
224+
186225
def _extract_parameters_and_transform_profile(self, radius):
187226
"""
188227
Private method which extracts the parameters (pitch, rake, skew ,...) related

bladex/reversepropeller/reversepropeller.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -153,38 +153,37 @@ def __init__(self, filename, radii_list, num_points_top_bottom):
153153
ind_sec = ind_sec + 1
154154

155155

156-
def _build_intersection_cylinder_blade(self):
157-
"""
158-
Private method that constructs the section lines which are the intersections
159-
between the cylinder at a fixed radius and the blade, and the camber points.
160-
"""
161-
# Construction of the section lines between two shapes (in this case the
162-
# blade and the lateral face of the cylinder)
163-
section_builder = BRepAlgoAPI_Section(self.blade_solid,
164-
self.cylinder_lateral_face, False)
165-
# Define and build the parametric 2D curve (pcurve) for the section lines defined above
166-
section_builder.ComputePCurveOn2(True)
167-
section_builder.Build()
168-
self.section = section_builder.Shape()
169-
edgeExplorer = TopExp_Explorer(self.section, TopAbs_EDGE)
170-
wire_maker = BRepBuilderAPI_MakeWire()
171-
172-
edgeCount = 0
173-
self.total_section_length = 0.0
174-
edgeList = TopTools_ListOfShape()
175-
while edgeExplorer.More():
176-
edgeCount = edgeCount + 1 # Numbering from 1 in OCC
177-
edge = topods.Edge(edgeExplorer.Current())
178-
edgeList.Append(edge)
179-
edgeExplorer.Next()
180-
wire_maker.Add(edgeList)
181-
self.wire = wire_maker.Wire()
182-
self.section_wires_list.append(self.wire)
183-
self.curve_adaptor = BRepAdaptor_CompCurve(
184-
OCC.Core.TopoDS.topods.Wire(self.wire))
185-
# Length of the curve section (ascissa curvilinea)
186-
self.total_section_length = GCPnts_AbscissaPoint.Length(
187-
self.curve_adaptor)
156+
# def _build_intersection_cylinder_blade(self):
157+
# """
158+
# Private method that constructs the section lines which are the intersections
159+
# between the cylinder at a fixed radius and the blade, and the camber points.
160+
# """
161+
# # Construction of the section lines between two shapes (in this case the
162+
# # blade and the lateral face of the cylinder)
163+
# section_builder = BRepAlgoAPI_Section(self.blade_solid,
164+
# self.cylinder_lateral_face, False)
165+
# # Define and build the parametric 2D curve (pcurve) for the section lines defined above
166+
# section_builder.ComputePCurveOn2(True)
167+
# section_builder.Build()
168+
# self.section = section_builder.Shape()
169+
# edgeExplorer = TopExp_Explorer(self.section, TopAbs_EDGE)
170+
# wire_maker = BRepBuilderAPI_MakeWire()
171+
172+
# edgeCount = 0
173+
# edgeList = TopTools_ListOfShape()
174+
# while edgeExplorer.More():
175+
# edgeCount = edgeCount + 1 # Numbering from 1 in OCC
176+
# edge = topods.Edge(edgeExplorer.Current())
177+
# edgeList.Append(edge)
178+
# edgeExplorer.Next()
179+
# wire_maker.Add(edgeList)
180+
# self.wire = wire_maker.Wire()
181+
# self.section_wires_list.append(self.wire)
182+
# self.curve_adaptor = BRepAdaptor_CompCurve(
183+
# OCC.Core.TopoDS.topods.Wire(self.wire))
184+
# # Length of the curve section (ascissa curvilinea)
185+
# self.total_section_length = GCPnts_AbscissaPoint.Length(
186+
# self.curve_adaptor)
188187

189188

190189
def _camber_points(self, radius):

bladex/reversepropeller/reversepropellerbladex.py

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,46 +111,23 @@ def __init__(self, filename, radii_list, num_points_top_bottom):
111111

112112

113113
def _build_intersection_cylinder_blade(self):
114-
"""
115-
Private method that constructs the section lines which are the intersections
116-
between the cylinder at a fixed radius and the blade, and the camber points.
117-
"""
118-
# Construction of the section lines between two shapes (in this case the
119-
# blade and the lateral face of the cylinder)
120-
section_builder = BRepAlgoAPI_Section(self.blade_solid,
121-
self.cylinder_lateral_face, False)
122-
# Define and build the parametric 2D curve (pcurve) for the section lines defined above
123-
section_builder.ComputePCurveOn2(True)
124-
section_builder.Build()
125-
self.section = section_builder.Shape()
126-
wire_maker = BRepBuilderAPI_MakeWire()
114+
super()._build_intersection_cylinder_blade()
127115
wire_maker_top = BRepBuilderAPI_MakeWire()
128116
wire_maker_bottom = BRepBuilderAPI_MakeWire()
129-
130-
edgeList = TopTools_ListOfShape()
131117
edgeList_top = TopTools_ListOfShape()
132118
edgeList_bottom = TopTools_ListOfShape()
133-
edgeExplorer = TopExp_Explorer(self.section, TopAbs_EDGE)
134119
edgeCount = 0
120+
edgeExplorer = TopExp_Explorer(self.section, TopAbs_EDGE)
135121
while edgeExplorer.More():
136122
edgeCount = edgeCount + 1 # Numbering from 1 in OCC
137123
edge = edgeExplorer.Current()
138-
edgeList.Append(edge)
139124
if edgeCount % 2 == 1:
140125
edgeList_top.Append(edge)
141126
else:
142127
edgeList_bottom.Append(edge)
143128
edgeExplorer.Next()
144129

145-
# Total sectional curve
146-
wire_maker.Add(edgeList)
147-
self.wire = wire_maker.Wire()
148-
self.section_wires_list.append(self.wire)
149-
self.curve_adaptor = BRepAdaptor_CompCurve(
150-
OCC.Core.TopoDS.topods.Wire(self.wire))
151-
self.total_section_length = GCPnts_AbscissaPoint.Length(
152-
self.curve_adaptor)
153-
# Top part
130+
# Top part of section
154131
wire_maker_top.Add(edgeList_top)
155132
self.wire_top = wire_maker_top.Wire()
156133
self.curve_adaptor_top = BRepAdaptor_CompCurve(
@@ -165,6 +142,61 @@ def _build_intersection_cylinder_blade(self):
165142
self.total_section_bottom_length = GCPnts_AbscissaPoint.Length(
166143
self.curve_adaptor_bottom)
167144

145+
# def _build_intersection_cylinder_blade(self):
146+
# """
147+
# Private method that constructs the section lines which are the intersections
148+
# between the cylinder at a fixed radius and the blade, and the camber points.
149+
# """
150+
# # Construction of the section lines between two shapes (in this case the
151+
# # blade and the lateral face of the cylinder)
152+
# section_builder = BRepAlgoAPI_Section(self.blade_solid,
153+
# self.cylinder_lateral_face, False)
154+
# # Define and build the parametric 2D curve (pcurve) for the section lines defined above
155+
# section_builder.ComputePCurveOn2(True)
156+
# section_builder.Build()
157+
# self.section = section_builder.Shape()
158+
# wire_maker = BRepBuilderAPI_MakeWire()
159+
# wire_maker_top = BRepBuilderAPI_MakeWire()
160+
# wire_maker_bottom = BRepBuilderAPI_MakeWire()
161+
162+
# edgeList = TopTools_ListOfShape()
163+
# edgeList_top = TopTools_ListOfShape()
164+
# edgeList_bottom = TopTools_ListOfShape()
165+
# edgeExplorer = TopExp_Explorer(self.section, TopAbs_EDGE)
166+
# edgeCount = 0
167+
# while edgeExplorer.More():
168+
# edgeCount = edgeCount + 1 # Numbering from 1 in OCC
169+
# edge = edgeExplorer.Current()
170+
# edgeList.Append(edge)
171+
# if edgeCount % 2 == 1:
172+
# edgeList_top.Append(edge)
173+
# else:
174+
# edgeList_bottom.Append(edge)
175+
# edgeExplorer.Next()
176+
177+
# # Total sectional curve
178+
# wire_maker.Add(edgeList)
179+
# self.wire = wire_maker.Wire()
180+
# self.section_wires_list.append(self.wire)
181+
# self.curve_adaptor = BRepAdaptor_CompCurve(
182+
# OCC.Core.TopoDS.topods.Wire(self.wire))
183+
# self.total_section_length = GCPnts_AbscissaPoint.Length(
184+
# self.curve_adaptor)
185+
# # Top part
186+
# wire_maker_top.Add(edgeList_top)
187+
# self.wire_top = wire_maker_top.Wire()
188+
# self.curve_adaptor_top = BRepAdaptor_CompCurve(
189+
# OCC.Core.TopoDS.topods.Wire(self.wire_top))
190+
# self.total_section_top_length = GCPnts_AbscissaPoint.Length(
191+
# self.curve_adaptor_top)
192+
# # Bottom part
193+
# wire_maker_bottom.Add(edgeList_bottom)
194+
# self.wire_bottom = wire_maker_bottom.Wire()
195+
# self.curve_adaptor_bottom = BRepAdaptor_CompCurve(
196+
# OCC.Core.TopoDS.topods.Wire(self.wire_bottom))
197+
# self.total_section_bottom_length = GCPnts_AbscissaPoint.Length(
198+
# self.curve_adaptor_bottom)
199+
168200

169201
def _camber_curve(self, radius):
170202
"""

0 commit comments

Comments
 (0)