@@ -429,6 +429,39 @@ def rotate(self, deg_angle=None, rad_angle=None, axis='x'):
429429 self .blade_coordinates_down = np .einsum ('ij, kjl->kil' ,
430430 rot_matrix , self .blade_coordinates_down )
431431
432+ # TODO: working but ugly
433+ for id , face in enumerate ([self .upper_face , self .lower_face ,
434+ self .tip_face , self .root_face ]):
435+ from OCC .Core .BRepBuilderAPI import BRepBuilderAPI_Transform
436+ from OCC .Core .gp import gp_Pnt
437+ from OCC .Core .gp import gp_Dir
438+ from OCC .Core .gp import gp_Ax1
439+ from OCC .Core .gp import gp_Trsf
440+
441+ origin = gp_Pnt (0 , 0 , 0 )
442+ if axis == 'y' :
443+ direction = gp_Dir (0 , 1 , 0 )
444+ elif axis == 'z' :
445+ direction = gp_Dir (0 , 0 , 1 )
446+ elif axis == 'x' :
447+ direction = gp_Dir (1 , 0 , 0 )
448+ else :
449+ raise ValueError ('Axis must be either x, y, or z.' )
450+ ax1 = gp_Ax1 (origin , direction )
451+ trsf = gp_Trsf ()
452+ trsf .SetRotation (ax1 , rad_angle )
453+
454+ brep_tr = BRepBuilderAPI_Transform (face , trsf , True , True )
455+ face = brep_tr .Shape ()
456+ if id == 0 :
457+ self .upper_face = face
458+ elif id == 1 :
459+ self .lower_face = face
460+ elif id == 2 :
461+ self .tip_face = face
462+ elif id == 3 :
463+ self .root_face = face
464+
432465 def scale (self , factor ):
433466 """
434467 Scale the blade coordinates by a specified factor.
@@ -438,11 +471,29 @@ def scale(self, factor):
438471 from OCC .Core .BRepBuilderAPI import BRepBuilderAPI_Transform
439472 self .blade_coordinates_up *= factor
440473 self .blade_coordinates_down *= factor
441- # for face in [self.upper_face, self.lower_face, self.tip_face, self.root_face]:
442- # brepgp_Trsf = BRepBuilderAPI_Transform()
443- # brepgp_Trsf.SetScale(gp_Pnt(0, 0, 0), factor)
444- # brepgp_Trsf.Perform(face, True)
445- # face = brepgp_Trsf.Shape()
474+
475+ for id , face in enumerate ([self .upper_face , self .lower_face ,
476+ self .tip_face , self .root_face ]):
477+ from OCC .Core .BRepBuilderAPI import BRepBuilderAPI_Transform
478+ from OCC .Core .gp import gp_Pnt
479+ from OCC .Core .gp import gp_Dir
480+ from OCC .Core .gp import gp_Ax1
481+ from OCC .Core .gp import gp_Trsf
482+
483+ origin = gp_Pnt (0 , 0 , 0 )
484+ trsf = gp_Trsf ()
485+ trsf .SetScale (origin , factor )
486+
487+ brep_tr = BRepBuilderAPI_Transform (face , trsf , True , True )
488+ face = brep_tr .Shape ()
489+ if id == 0 :
490+ self .upper_face = face
491+ elif id == 1 :
492+ self .lower_face = face
493+ elif id == 2 :
494+ self .tip_face = face
495+ elif id == 3 :
496+ self .root_face = face
446497
447498 def plot (self , elev = None , azim = None , ax = None , outfile = None ):
448499 """
@@ -944,3 +995,15 @@ def __str__(self):
944995 string += '\n Induced rake from skew (in unit length)' \
945996 ' for the sections = {}' .format (self .induced_rake )
946997 return string
998+
999+ def display (self ):
1000+ """
1001+ Display the propeller with shaft.
1002+ """
1003+ from OCC .Display .SimpleGui import init_display
1004+ display , start_display = init_display ()[:2 ]
1005+ display .DisplayShape (self .upper_face , update = True )
1006+ display .DisplayShape (self .lower_face , update = True )
1007+ display .DisplayShape (self .root_face , update = True )
1008+ display .DisplayShape (self .tip_face , update = True )
1009+ start_display ()
0 commit comments