def gen_collimators(self, detector_angles=[-45, -135], multiple_collimator=True, collimator_Nosupport=True): """ Parameters ---------- detector_angles multiple_collimator collimator_Nosupport Returns ------- """ if multiple_collimator is True: rotated_coll = [ operations.rotate(self.gen_one_col(collimator_Nosupport), beam="1", angle='%s*deg' % (a)) for a in detector_angles ] all_coll = operations.unite(*rotated_coll) else: rotated_coll = operations.rotate( self.gen_one_col(collimator_Nosupport), vertical="1", angle='%s*deg' % (180 + detector_angles[0])) # transversal ,90 all_coll = rotated_coll return (all_coll)
def generate_vertical_blade_PLUS_border_list(self): height = (self.channel_length + self.collimator_front_end_from_center) * 1.2 arc_width = height * np.deg2rad(self.maximum_vertical_acceptance_angle) thickness = self.blade_width pillar = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness, thickness='%s *mm' % (arc_width)) pyl_d = operations.translate(pillar, vertical='%s *mm' % (-(height) / 2)) one_vertical_blade = operations.rotate(pyl_d, transversal=1, angle='%s *degree' % (90)) vertical_blades = [ operations.rotate(one_vertical_blade, vertical="1", angle='%s*deg' % a) for a in self.horizontal_pillar_angle_list() ] return (vertical_blades)
def generate_vertical_blade_PLUS_border_list(self): height = self.horizontal_outer_radius * 1.2 arc_width = height * np.deg2rad(self.vertical_acceptance_angle) thickness = self.wall_thickness pillar = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness, thickness='%s *mm' % (arc_width)) pyl_d = operations.translate(pillar, vertical='%s *mm' % (-(height) / 2)) one_vertical_blade = operations.rotate(pyl_d, transversal=1, angle='%s *degree' % (90)) vertical_blades = [ operations.rotate(one_vertical_blade, vertical="1", angle='%s*deg' % a) for a in self.horizontal_pillar_angle_list ] return (vertical_blades)
def vision_seat_piston(self): seat = self.vision_seat() piston = self.vision_piston() piston_Not_just_below_seat_ = operations.translate( piston, vertical='%s *mm' % (-(self.vision_seat_skirt_height / 2. + self.vision_seat_shaft_height))) piston_below_seat = operations.translate( piston, vertical='%s *mm' % (-(self.vision_seat_skirt_height))) seat_W_piston = operations.unite(seat, piston_below_seat) # seat_W_piston_below_dac= operations.translate(seat_W_piston,vertical='%s *mm' # % (-(self.pavilion_total_triangle_height() +self.girdle_height))) seat_W_piston_below_dac = operations.translate( seat_W_piston, vertical='%s *mm' % (-(self.pavilion_height() + self.sample_height / 2. + self.girdle_height))) seat_W_piston_above_dac = operations.rotate( operations.rotate(seat_W_piston_below_dac, transversal=1, angle='%s *degree' % (180)), vertical=1, angle='%s *degree' % -180) seat_piston_both = operations.unite(seat_W_piston_below_dac, seat_W_piston_above_dac) return (seat_piston_both)
def test(self): """ instrument.geometry.pml.render """ import numpy as np from instrument.geometry.pml import weave from instrument.geometry import shapes, operations pyramid = shapes.pyramid(thickness="20.*mm", width="20.*mm", height="110.*mm") pyramid_along_beam = operations.rotate(pyramid, transversal="1", angle="90.*deg") angles = np.arange(-160, 0., 15.) pyramids = [ operations.rotate(pyramid_along_beam, vertical="1", angle='%s*deg' % a) for a in angles ] channels = operations.unite(*pyramids) hollow_cylinder = operations.subtract( shapes.cylinder(radius="55.*mm", height="50.*mm"), shapes.cylinder(radius="25.*mm", height="60.*mm"), ) half_cylinder = operations.subtract( hollow_cylinder, operations.translate( shapes.block(height="110*mm", width="110*mm", thickness="110*mm"), transversal="-55.*mm", )) all = operations.subtract(half_cylinder, channels) # use a special renderer from instrument.geometry.pml.Renderer import Renderer as base class Renderer(base): def _renderDocument(self, body): self.onGeometry(body) return def header(self): return [] def footer(self): return [] def end(self): return text = weave(all, open('collimator.xml', 'wt'), print_docs=False, renderer=Renderer(), author='') return
def tab_screw(self): height = self.max_max_coll_width_detector width = 3.6 * 5 thickness = 6. source_distance = self.inner_radius + 5 span = self.angle2span(source_distance, self.horizontal_acceptance_angle) large_pillar = shapes.block(height='%s *mm' % height, width='%s *mm' % width, thickness='%s *mm' % thickness) small_pillar = shapes.block(height='%s *mm' % span, width='%s *mm' % (width + 1), thickness='%s *mm' % (thickness + 1)) pillar = operations.subtract(large_pillar, small_pillar) length = height - span holes_position = span / 2 + length / 4 holes = [ operations.translate(operations.rotate(shapes.cylinder( radius='%s*mm' % 1.6, height='%s *mm' % (thickness + 55)), transversal=1, angle='%s *deg' % 90), vertical='%s *mm' % a) for a in [holes_position, -holes_position] ] all_holes = operations.unite(*holes) pillar_holes = operations.subtract(large_pillar, all_holes) vertical_rot = operations.rotate(pillar_holes, vertical=1, angle='%s *deg' % 90) beam_rot = operations.rotate(vertical_rot, beam=1, angle='%s *deg' % 90) move_beam = operations.translate( beam_rot, beam='%s *mm' % -(self.inner_radius + self.base_thickness / 2)) move_ver = operations.translate( move_beam, vertical='%s *mm' % (-(self.max_coll_height_detector) / 2 + thickness / 2)) return (vertical_rot)
def generate_oneside_discrete_vertical_channel_left_borders(self): r""" Generate the list of the vertical channels left borders". (left or right??., please check with figures) Return ---------- list of vertical channel left borders (largest dimension in vertical direction) """ if self.collimator_height_detector > self.collimator_width_detector: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 else: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 self.vertical_channel_angle = self.span2angle( self.channel_height, self.collimator_front_end_from_center) arc_width = height * np.deg2rad(self.vertical_channel_angle) thickness = self.blade_width pyr = shapes.pyramid(thickness='%s *mm' % (thickness), height='%s *mm' % (height), width='%s *mm' % (arc_width)) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) pyl_beam_vertical = operations.rotate(pyr, beam=1, angle='%s *degree' % (90)) horizontal_pillar_extreme_angle_list = self.horizontal_pillar_angle_list( )[0] # [self.horizontal_pillar_min_angle, self.horizontal_pillar_max_angle] one_channel_border = operations.rotate( pyl_beam_vertical, vertical="1", angle='%s*deg' % horizontal_pillar_extreme_angle_list) all_channel_borders = [ operations.rotate(one_channel_border, transversal="1", angle='%s*deg' % a) for a in self.vertical_pillar_angle_list() ] return (all_channel_borders)
def generate_channels_list(self): if self.max_coll_height_detector > self.max_coll_width_detector: height = self.horizontal_outer_radius * 1.2 arc_width = height * np.deg2rad(self.vertical_acceptance_angle) # print ('height') else: height = self.vertical_outer_radius * 1.2 arc_width = height * np.deg2rad(self.horizontal_acceptance_angle) # print ('width') width = abs(self.angle2span(height, self.horizontal_acceptance_angle)) # arc_width = height * np.deg2rad(self.horizontal_acceptance_angle) # height = self.horizontal_outer_radius * 1.2 # arc_width = height * np.deg2rad(self.vertical_acceptance_angle) thickness = self.wall_thickness pillar = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness, thickness='%s *mm' % (arc_width)) pyl_d = operations.translate(pillar, vertical='%s *mm' % (-(height) / 2)) pyl_beam_vertical = operations.rotate(pyl_d, transversal=1, angle='%s *degree' % (90)) pyls_beam_vertical = [ operations.rotate(pyl_beam_vertical, vertical="1", angle='%s*deg' % a) for a in self.horizontal_pillar_angle_list ] pyl_beam_horizontal = operations.rotate(pyl_beam_vertical, beam=1, angle='%s *degree' % 90) pyls_beam_horizontal = [ operations.rotate(pyl_beam_horizontal, transversal="1", angle='%s*deg' % a) for a in self.vertical_pillar_angle_list ] return (pyls_beam_vertical, pyls_beam_horizontal)
def solid_pyramid(self): """ Returns ------- """ scale_pyr = 1.1 pyr_ht = (self.horizontal_arc_length_detector / np.deg2rad(self.horizontal_acceptance_angle)) * scale_pyr thickness = (self.max_coll_height_detector + 1 * self.wall_thickness) * scale_pyr, height = (self.horizontal_arc_length_detector / np.deg2rad(self.horizontal_acceptance_angle)) * scale_pyr, width = (self.max_coll_width_detector + 1 * self.wall_thickness) * scale_pyr # pyr_ht = self.vertical_outer_radius * np.cos(np.deg2rad(self.horizontal_acceptance_angle/2.)) * scale_pyr pyr = shapes.pyramid( thickness='%s *mm' % (thickness), # height='%s *mm' % (height), height='%s *mm' % (height), width='%s *mm' % width) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) return (pyr)
def generate_box_toIntersect_big_end(self, width=None, height=None): if height is None: height = (self.channel_length + self.collimator_front_end_from_center) else: height = height if width is None: width = self.collimator_height_detector( ) * 1.2 #height of the collimator else: width = width thickness = (self.channel_length + self.collimator_front_end_from_center ) * 1.2 #width of the collimator box = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness, thickness='%s *mm' % (width)) box_d = operations.translate(box, vertical='%s *mm' % (-(height) / 2)) box_beam_vertical = operations.rotate(box_d, transversal=1, angle='%s *degree' % (90)) return (box_beam_vertical)
def generate_box_toIntersect_big_end(self, width=None, height=None): if height is None: height = self.vertical_outer_radius else: height=height if width is None: width = self.max_coll_height_detector * 1.2 #height of the collimator else: width=width thickness = self.vertical_outer_radius * 1.2 #width of the collimator box = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness, thickness='%s *mm' % (width)) box_d = operations.translate(box, vertical='%s *mm' % (-(height) / 2)) box_beam_vertical = operations.rotate(box_d, transversal=1, angle='%s *degree' % (90)) return(box_beam_vertical)
def generate_box_toCut_big_end(self, width=None, height=None): if height is None: height = self.outer_radius else: height = height # print ('blade height', height) if width is None: width = self.max_coll_height_detector * 1.2 else: width = width thickness = self.outer_radius * 1.2 box = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness, thickness='%s *mm' % (width)) box_d = operations.translate(box, vertical='%s *mm' % (-(height) / 2)) box_beam_vertical = operations.rotate(box_d, transversal=1, angle='%s *degree' % (90)) return (box_beam_vertical)
def inner_sleeve(self): CuBe_InDiameter = 4.74 # mm CuBe_InRadius = CuBe_InDiameter / 2 CuBe_InHeight = self.sample_height + 10 #mm (total height 95.758 mm) CuBe_Height = self.sample_height CuBe_OutSmallestCone_Dia = 14.63 #(outer boundary is tappered cylinder, bottom diameter ) CuBe_OutSmallestCone_Rad = CuBe_OutSmallestCone_Dia / 2 CuBe_OutconeAngle = 2 # the tappered angle CuBe_OutLargestCone_Dia = ( 2 * np.tan(np.deg2rad(CuBe_OutconeAngle / 2)) * CuBe_Height ) + CuBe_OutSmallestCone_Dia #( tappered cylinder top diamter) CuBe_OutLargestCone_Rad = CuBe_OutLargestCone_Dia / 2 CuBe_OutSmallest_ConeHeight = CuBe_OutSmallestCone_Dia / ( 2 * np.tan(np.deg2rad(CuBe_OutconeAngle / 2))) CuBe_OutLargest_ConeHeight = CuBe_OutSmallest_ConeHeight + CuBe_Height CuBe_boxHeightToSubtract = CuBe_OutSmallest_ConeHeight * 2 CuBe_boxthisckness = CuBe_OutSmallestCone_Dia + 20 CuBe_HalfHeight = CuBe_Height / 2 CuBe_moving_height = CuBe_OutSmallest_ConeHeight + CuBe_HalfHeight ### CReate the string for INNER SLEEVE ###### CuBe_InRadius_str = str(CuBe_InRadius) + r'*mm' CuBe_InHeight_str = str(CuBe_InHeight) + r'*mm' CuBe_Height_str = str(CuBe_Height) + r'*mm' CuBe_OutLargestCone_Rad_str = str(CuBe_OutLargestCone_Rad) + r'*mm' CuBe_OutLargest_ConeHeight_str = str( CuBe_OutLargest_ConeHeight) + r'*mm' CuBe_boxHeightToSubtract_str = str(CuBe_boxHeightToSubtract) + r'*mm' CuBe_boxthisckness_str = str(CuBe_boxthisckness) + r'*mm' CuBe_moving_height_str = str(-CuBe_moving_height) + r'*mm' #create the outer CuBe largest cone CuBe_largest_cone = shapes.cone( radius=CuBe_OutLargestCone_Rad_str, height=CuBe_OutLargest_ConeHeight_str) # upside down #rotation to make top wider CuBe_largest_cone_widertip = operations.rotate(CuBe_largest_cone, angle="180*deg", vertical="0", transversal="1", beam="0") #make a tapered cylinder CuBe_tapered_cylinder = operations.Difference( CuBe_largest_cone_widertip, shapes.block(thickness=CuBe_boxthisckness_str, height=CuBe_boxHeightToSubtract_str, width=CuBe_boxthisckness_str)) #moving the center of the cylinder to the center of the coordinate CuBe_centered_taperedCylinder = operations.translate( CuBe_tapered_cylinder, vertical=CuBe_moving_height_str) #Creating the InnerSleeve CuBe_innerSleeve = operations.subtract( CuBe_centered_taperedCylinder, shapes.cylinder(radius=CuBe_InRadius_str, height=CuBe_InHeight_str), ) return (CuBe_innerSleeve)
def generate_channels_list(self): height = self.outer_radius * 1.2 # print ('blade height', height) width = abs(self.angle2span(height, self.horizontal_acceptance_angle)) arc_width = height * np.deg2rad(self.horizontal_acceptance_angle) # print (' arc width', arc_width) thickness = self.wall_thickness # print ('blade width', width) # print ('blade thickness', thickness) pillar = shapes.block(height='%s *mm' % height, width='%s *mm' % thickness, thickness='%s *mm' % (arc_width)) pyl_d = operations.translate(pillar, vertical='%s *mm' % (-(height) / 2)) pyl_beam_vertical = operations.rotate(pyl_d, transversal=1, angle='%s *degree' % (90)) pyls_beam_vertical = [ operations.rotate(pyl_beam_vertical, vertical="1", angle='%s*deg' % a) for a in self.horizontal_pillar_angle_list ] pyl_beam_horizontal = operations.rotate(pyl_beam_vertical, beam=1, angle='%s *degree' % 90) pyls_beam_horizontal = [ operations.rotate(pyl_beam_horizontal, transversal="1", angle='%s*deg' % a) for a in self.vertical_pillar_angle_list ] return (pyls_beam_vertical, pyls_beam_horizontal)
def outer_body(self): Al_OutDiameter = 32.05 # mm Al_OutRadius = Al_OutDiameter / 2 Al_Height = self.sample_height #28.57 #mm (total height 95.758 mm) Al_InSmallestCone_Dia = 14.59 #mm (inner boundary is tappered cylinder, bottom Diameter ) Al_InSmallestCone_Rad = Al_InSmallestCone_Dia / 2 Al_InconeAngle = 2 Al_InHeight = Al_Height + 10 #mm (tappered cylinder height) (this should be same as Al_Height, but in constructive geometry the inner height has to be larger for correct subtraction) Al_InLargestCone_Dia = ( 2 * np.tan(np.deg2rad(Al_InconeAngle / 2)) * Al_InHeight ) + Al_InSmallestCone_Dia #( tappered cylinder top diameter) Al_InLargestCone_Rad = Al_InLargestCone_Dia / 2 Al_InSmallest_ConeHeight = Al_InSmallestCone_Dia / ( 2 * np.tan(np.deg2rad(Al_InconeAngle / 2))) Al_InLargest_ConeHeight = Al_InSmallest_ConeHeight + Al_InHeight Al_boxHeightToSubtract = Al_InSmallest_ConeHeight * 2 Al_boxthisckness = Al_InSmallestCone_Dia + 20 Al_HalfHeight = Al_InHeight / 2 Al_moving_height = Al_InSmallest_ConeHeight + Al_HalfHeight ### CReate the string for OUTER BODY ###### Al_OutRadius_str = str(Al_OutRadius) + r'*mm' Al_Height_str = str(Al_Height) + r'*mm' Al_InLargestCone_Rad_str = str(Al_InLargestCone_Rad) + r'*mm' Al_InLargest_ConeHeight_str = str(Al_InLargest_ConeHeight) + r'*mm' Al_InSmallest_ConeHeight_str = str(Al_InSmallest_ConeHeight) + r'*mm' Al_boxHeightToSubtract_str = str(Al_boxHeightToSubtract) + r'*mm' Al_boxthisckness_str = str(Al_boxthisckness) + r'*mm' Al_moving_height_str = str(-Al_moving_height) + r'*mm' #create the inner Al largest cone Al_largest_cone = shapes.cone( radius=Al_InLargestCone_Rad_str, height=Al_InLargest_ConeHeight_str) # upside down #rotation to make top wider Al_largest_cone_widertip = operations.rotate(Al_largest_cone, angle="180*deg", vertical="0", transversal="1", beam="0") #make a tapered cylinder Al_tapered_cylinder = operations.Difference( Al_largest_cone_widertip, shapes.block(thickness=Al_boxthisckness_str, height=Al_boxHeightToSubtract_str, width=Al_boxthisckness_str)) #moving the center of the cylinder to the center of the coordinate Al_centered_taperedCylinder = operations.translate( Al_tapered_cylinder, vertical=Al_moving_height_str) #Creating the outer Al body outer_Al = operations.subtract( shapes.cylinder(radius=Al_OutRadius_str, height=Al_Height_str), Al_centered_taperedCylinder, ) return (outer_Al)
def generate_oneside_discrete_vertical_channel_right_borders(self): r""" Generate the list of the vertical channels right borders". Return ---------- list of vertical channel right borders (largest dimension in vertical direction) """ if self.max_coll_height_detector > self.max_coll_width_detector: height = self.horizontal_outer_radius * 1.2 else: height = self.vertical_outer_radius * 1.2 arc_width = height * np.deg2rad(self.vertical_channel_angle) thickness = self.wall_thickness pyr = shapes.pyramid(thickness='%s *mm' % (thickness), height='%s *mm' % (height), width='%s *mm' % (arc_width)) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) pyl_beam_vertical = operations.rotate(pyr, beam=1, angle='%s *degree' % (90)) horizontal_pillar_extreme_angle_list = self.horizontal_pillar_max_angle one_channel_border = operations.rotate( pyl_beam_vertical, vertical="1", angle='%s*deg' % horizontal_pillar_extreme_angle_list) all_channel_borders = [ operations.rotate(one_channel_border, transversal="1", angle='%s*deg' % a) for a in self.vertical_pillar_angle_list ] return (all_channel_borders)
def generate_oneside_discrete_horizontal_channel_bottom_borders(self): r""" Generate the list of the horizontal channels bottom borders". Return ---------- list of horizontal channel bottom borders (largest dimension in horizontal direction) """ if self.collimator_height_detector > self.collimator_width_detector: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 else: height = (self.collimator_front_end_from_center + self.channel_length) * 1.2 arc_width = height * np.deg2rad(self.horizontal_channel_angle) thickness = self.blade_width pyr = shapes.pyramid(thickness='%s *mm' % (thickness), height='%s *mm' % (height), width='%s *mm' % (arc_width)) pyr = operations.rotate(pyr, transversal=1, angle='%s *degree' % (90)) vertical_blade_extreme_angle_list = self.vertical_pillar_angle_list[-1] one_channel_border = operations.rotate( pyr, transversal="1", angle='%s*deg' % vertical_blade_extreme_angle_list) all_channel_borders = [ operations.rotate(one_channel_border, vertical="1", angle='%s*deg' % a) for a in self.horizontal_pillar_angle_list() ] return (all_channel_borders)
def test(self): """ instrument.geometry.pml.render """ from instrument.geometry.pml import render from instrument.geometry import shapes, operations cyl = shapes.cylinder(radius="1.*cm", height="5.*cm") sphere = shapes.sphere(radius="2.*cm") block = shapes.block(width="5*cm", height="4.*cm", thickness="1.*mm") u = operations.unite(cyl, sphere, block) t = operations.translate(u, vertical="0.2*cm") r = operations.rotate(t, vertical=1., angle=90.) pyramid = shapes.pyramid(width="4.*cm", height="2.*cm", thickness="1.*cm") i = operations.intersect(r, pyramid) cone = shapes.cone(radius="2.*cm", height="2.*cm") u = operations.unite(i, cone) sphere2 = shapes.sphere(radius="3.*cm") s = operations.subtract(sphere2, u) text = render(s, print_docs=False) print('\n'.join(text), file=open('test2.xml.rendered', 'w')) return
def gen_one_col(self, collimator_Nosupport=True): pyr = self.solid_pyramid() big_cylinder = shapes.cylinder(radius='%s *mm' % (self.vertical_outer_radius), height='%s *mm' % (self.max_coll_height_detector * 10)) big_box=self.generate_box_toIntersect_big_end() outside_sphere = shapes.sphere(radius='%s *mm' % self.vertical_outer_radius) channels=self.generate_collimator_channels() channels_border=self.generate_channels_border() conical_colli = operations.intersect(channels, pyr) conical_channels_border=operations.intersect(channels_border, pyr) cutoff_cylinder = shapes.cylinder(radius='%s *mm' % (self.inner_radius), height='%s *mm' % (self.max_coll_height_detector * 90.)) blade_cutoff_cylinder = shapes.cylinder(radius='%s *mm' % (self.vertical_blade_dist_fr_sample_center), height='%s *mm' % (self.max_coll_height_detector * 10)) cutoff_box = shapes.block(width='%s *mm' % (self.inner_radius*2), thickness='%s *mm' % (self.inner_radius*2), height='%s *mm' % (self.max_coll_height_detector * 90.)) blade_cutoff_box = shapes.block(width='%s *mm' % (self.vertical_blade_dist_fr_sample_center*2), thickness='%s *mm' % (self.vertical_blade_dist_fr_sample_center*2), height='%s *mm' % (self.max_coll_height_detector * 10)) # return (operations.subtract(conical_channels_border, cutoff_cylinder)) if self.collimator_parts is True: open_collimator = operations.intersect(operations.subtract(conical_channels_border, cutoff_box), big_box) collimator_with_blades = operations.intersect(operations.subtract(conical_colli, blade_cutoff_box), big_box) else: open_collimator=operations.intersect(operations.subtract(conical_channels_border, cutoff_cylinder), big_box) collimator_with_blades = operations.intersect(operations.subtract(conical_colli, blade_cutoff_cylinder), big_box) collimator=operations.unite(open_collimator, collimator_with_blades) scale_pyr = 1.1 pyr_ht = (self.horizontal_arc_length_detector / np.deg2rad(self.horizontal_acceptance_angle)) * scale_pyr thickness = (self.max_coll_height_detector + 1 * self.wall_thickness) * scale_pyr height = (self.horizontal_arc_length_detector / np.deg2rad(self.horizontal_acceptance_angle)) * scale_pyr width = (self.max_coll_width_detector + 1 * self.wall_thickness) * scale_pyr # pyr_ht = self.vertical_outer_radius * np.cos(np.deg2rad(self.horizontal_acceptance_angle/2.)) * scale_pyr pyr_lateral = shapes.pyramid( thickness='%s *mm' % (thickness), # height='%s *mm' % (height), height='%s *mm' % (height), width='%s *mm' % (width+900.)) pyr_lateral = operations.rotate(pyr_lateral, transversal=1, angle='%s *degree' % (90)) pyr_depth = shapes.pyramid( thickness='%s *mm' % (thickness+6900), # height='%s *mm' % (height), height='%s *mm' % (height), width='%s *mm' % (width )) pyr_depth = operations.rotate(pyr_depth, transversal=1, angle='%s *degree' % (90)) # collimator_support = Collimator_support() # collimator_support.set_constraints( # truss_base_thickness=30., trass_final_height_factor=0.45, # touch_to_halfcircle=6, SNAP_acceptance_angle=False) # # supports = collimator_support.support() supports = self.support() support_top=operations.intersect(operations.subtract(supports, pyr_lateral), pyr_depth) # support_top =operations.subtract(self.support(), pyr_lateral) support_bottom=operations.rotate(operations.rotate(support_top, transversal=1, angle='%s *degree' %(-180)), vertical=1, angle='%s *degree' %180) supports=operations.subtract(operations.unite(support_top, support_bottom), cutoff_cylinder) if collimator_Nosupport is True: return(collimator) else: return(operations.unite(collimator,supports))
def support(self): main_cylinder_radius = self.inner_radius * self.truss_height_factor main_cylinder_diameter = main_cylinder_radius * 2. height_support_main = main_cylinder_diameter - self.beam_dist_support base_width_support = self.truss_base_thickness cyli_radius = main_cylinder_radius * 2 height_support = height_support_main cyli_dia = cyli_radius * 2. ################################################ cylinder_radius=self.inner_radius cylinder_radius = cyli_dia / 2. vertical_cylinder_height = cyli_dia + 100 ## big cylinder height should be greater than the cyli diameter suppert_end_distance_fr_source = self.inner_radius + base_width_support thickness_collimator_at_support_end = self.angle2span( suppert_end_distance_fr_source, self.vertical_acceptance_angle) height_factor = 1. height = thickness_collimator_at_support_end * height_factor cylinder = shapes.cylinder(radius='%s *mm' % (cylinder_radius), height='%s *mm' % (height * 2 + 10)) cylinder_transversal = operations.rotate(cylinder, beam=1, angle='%s *degree' % 90) vertical_cylinder = shapes.cylinder( radius='%s *mm' % (cylinder_radius), height='%s *mm' % (vertical_cylinder_height)) distance_fr_center_height_main = np.sqrt((main_cylinder_radius)**2 - (height_support / 2)**2) angular_cut = self.span2angle(height_support, distance_fr_center_height_main) / 2. distance_fr_center_height = cylinder_radius * np.cos( np.deg2rad(angular_cut)) vertical_cylinder_move_dist = abs(cylinder_radius - distance_fr_center_height) distance_fr_center_height = np.sqrt((cylinder_radius)**2 - (height_support / 2)**2) vertical_cylinder_move_dist = abs(cylinder_radius - distance_fr_center_height_main) unwanted_part_of_smallcircle0 = operations.subtract( cylinder_transversal, operations.translate(vertical_cylinder, beam='%s *mm' % -vertical_cylinder_move_dist)) moving_dist_cylinder = 20 # unwanted_part_of_smallcircle0= operations.translate(unwanted_part_of_smallcircle0, beam='%s *mm' %-moving_dist_cylinder) unwanted_part_of_bigcircle2 = operations.translate( unwanted_part_of_smallcircle0, beam='%s *mm' % (1)) cylinder_radius = self.inner_radius cylinder_transversal_1_0 = operations.rotate(shapes.cylinder( radius='%s *mm' % (cylinder_radius), height='%s *mm' % ((height * 2))), beam=1, angle='%s *degree' % 90) # return(operations.unite(cylinder_transversal_1_0, operations.translate(vertical_cylinder, beam='%s *mm' % -vertical_cylinder_move_dist))) mod_cylinder_transversal = operations.subtract( cylinder_transversal_1_0, unwanted_part_of_smallcircle0) # return (operations.subtract(cylinder_transversal,operations.subtract(cylinder_transversal,operations.translate(vertical_cylinder, beam='%s *mm' % -vertical_cylinder_move_dist)))) # return (operations.unite(cylinder_transversal_1_0,unwanted_part_of_smallcircle0 )) # return(mod_cylinder_transversal) # return (vertical_cylinder) # return (operations.subtract(vertical_cylinder, cylinder_transversal)) ######################################################################################################################################## ######################################################################################################################################### solid_shape = mod_cylinder_transversal cylinder_transversal = mod_cylinder_transversal ## small inside cylinder cylinder_2 = shapes.cylinder( radius='%s *mm' % (cylinder_radius + 1), ###big cylinder (outside cylinder) height='%s *mm' % (height * 2)) cylinder_transversal_2_0 = operations.rotate(cylinder_2, beam=1, angle='%s *degree' % 90) cylinder_transversal_2 = operations.subtract( cylinder_transversal_2_0, unwanted_part_of_bigcircle2) width_factor = 2. big_block = shapes.block( height='%s *mm' % cyli_dia, width='%s *mm' % (suppert_end_distance_fr_source * width_factor), thickness='%s *mm' % (height)) big_block_rotate = operations.rotate(big_block, vertical=1, angle='%s *degree' % 90) big_block_2 = shapes.block( height='%s *mm' % (cyli_dia - 1), width='%s *mm' % ((suppert_end_distance_fr_source * width_factor) - 2), thickness='%s *mm' % (height + 1)) #### small blog big_block_rotate_2 = operations.rotate(big_block_2, vertical=1, angle='%s *degree' % 90) parts = operations.subtract(big_block_rotate, cylinder_transversal) # return(operations.unite(big_block_rotate, cylinder_transversal)) # return(big_block_rotate) parts_2 = operations.subtract(big_block_rotate_2, cylinder_transversal_2) parts_frame = operations.subtract(parts, parts_2) # parts_frame=operations.unite(parts_frame, solid_shape) # return (parts_frame) # return (operations.subtract(parts_frame,parts_2)) # return operations.unite(cylinder_transversal_1_0,unwanted_part_of_smallcircle0) # return(operations.unite(cylinder_transversal, cylinder_transversal_2)) blades_in_frames = operations.subtract(self.support_design(), cylinder_transversal) parts_frame_blades_pre = operations.unite(parts_frame, blades_in_frames) parts_frame_blades_pre = parts_frame # return (parts_frame_blades_pre) #############################################################CHANGES##################################################### ######################################################################################################################### # solid=operations.subtract(vertical_cylinder, unwanted_part_of_bigcircle2) # # parts_frame_blades_pre = operations.unite(parts_frame_blades_pre, solid) side_cut_box = operations.translate(operations.rotate( shapes.block(height='%s *mm' % cyli_dia, width='%s *mm' % (suppert_end_distance_fr_source * width_factor), thickness='%s *mm' % (height * 2)), vertical=1, angle='%s *degree' % 90), beam='%s *mm' % -(suppert_end_distance_fr_source)) up_cut_box = operations.translate( operations.rotate(shapes.block( height='%s *mm' % cyli_dia, width='%s *mm' % ((suppert_end_distance_fr_source * width_factor) + 1), thickness='%s *mm' % (height * 2)), vertical=1, angle='%s *degree' % 90), vertical='%s *mm' % (cyli_dia / 2.)) ######################## down_cut_box = operations.translate(operations.rotate( shapes.block(height='%s *mm' % cyli_dia, width='%s *mm' % ((suppert_end_distance_fr_source * width_factor) + 1), thickness='%s *mm' % (height * 2)), vertical=1, angle='%s *degree' % 90), vertical='%s *mm' % (-(cyli_dia - 2))) parts_frame_blades = operations.subtract( operations.subtract( operations.subtract(parts_frame_blades_pre, side_cut_box), up_cut_box), down_cut_box) parts_frame_blades = operations.unite(parts_frame_blades, blades_in_frames) parts_frame_blades = operations.subtract( operations.subtract(parts_frame_blades, side_cut_box), down_cut_box) # return (parts_frame_blades) thickness_parts = ((suppert_end_distance_fr_source * width_factor) - (self.inner_radius)) / 2 parts_move_beam = operations.translate( parts_frame_blades, beam='%s *mm' % (-(self.inner_radius) * 2 - base_width_support + 1)) angle = self.vertical_acceptance_angle # 15 # parts_move_up = operations.translate(parts_move_beam, vertical='%s *mm' % ( # self.inner_radius + ( # self.curvature * self.inner_radius * np.tan(np.deg2rad(angle/2.))))) parts_move_up = operations.translate( parts_move_beam, vertical='%s *mm' % (self.inner_radius + (self.curvature * (self.inner_radius * 2. + base_width_support) * np.tan(np.deg2rad(angle / 2.))))) # return (parts_move_up) # return(parts_frame) return (operations.intersect( parts_move_up, self.generate_box_toCut_big_end( width=self.max_coll_height_detector * self.trass_final_height_factor, height=(self.inner_radius * 2. + base_width_support + 100.))))
def support_design(self): main_cylinder_radius = self.inner_radius main_cylinder_diameter = main_cylinder_radius * 2. height_support = main_cylinder_diameter - 8. # print (height_support) distance_fr_center_height_main = np.sqrt((main_cylinder_radius)**2 - (height_support / 2)**2) base_width_support = self.truss_base_thickness suppert_end_distance_fr_source = self.inner_radius + base_width_support thickness_collimator_at_support_end = self.angle2span( suppert_end_distance_fr_source, self.vertical_acceptance_angle) pillar = shapes.block( height='%s *mm' % (main_cylinder_diameter + base_width_support + self.truss_blade_length), width='%s *mm' % (thickness_collimator_at_support_end), thickness='%s *mm' % 1) pillar_beam = operations.rotate(pillar, transversal=1, angle="%s *degree" % 90) small_pillar_beam_tocut = operations.rotate(shapes.block( height='%s *mm' % (main_cylinder_diameter / 2.), width='%s *mm' % (thickness_collimator_at_support_end + 5), thickness='%s *mm' % 5), transversal=1, angle="%s *degree" % 90) pillar_beam = operations.subtract( pillar_beam, operations.translate(small_pillar_beam_tocut, beam='%s*mm' % -(main_cylinder_radius / 2))) angle = 10 truss_rot_degree = 10 pillar_beam_dia = operations.rotate(pillar_beam, transversal=1, angle='%s *degree' % truss_rot_degree) # return (pillar_beam_dia) blade1_needed = operations.translate(operations.subtract( operations.rotate(shapes.block( height='%s *mm' % (self.max_coll_height_detector * 90.), width='%s *mm' % (thickness_collimator_at_support_end), thickness='%s *mm' % 2), transversal=1, angle="%s *degree" % 90), operations.translate(small_pillar_beam_tocut, beam='%s*mm' % -(main_cylinder_radius / 2))), beam='%s *mm' % (distance_fr_center_height_main)) blade1 = operations.translate(pillar_beam, beam='%s *mm' % (distance_fr_center_height_main)) blade1_dia = operations.translate(pillar_beam_dia, beam='%s *mm' % (distance_fr_center_height_main)) vertical_blade = operations.rotate(operations.subtract( operations.rotate(shapes.block( height='%s *mm' % (self.max_coll_height_detector), width='%s *mm' % (thickness_collimator_at_support_end), thickness='%s *mm' % 1), transversal=1, angle="%s *degree" % 90), operations.translate(small_pillar_beam_tocut, beam='%s*mm' % -(main_cylinder_radius / 2))), beam=1, angle='%s *degree' % (90)) vertical_blade = operations.translate(vertical_blade, beam='%s *mm' % (self.inner_radius)) vertical_blade = operations.rotate(vertical_blade, transversal=1, angle='%s *degree' % (90)) vertical_blade = operations.rotate(vertical_blade, vertical=1, angle='%s *degree' % (90)) vertical_blade = operations.translate(vertical_blade, beam='%s *mm' % (self.inner_radius)) # # return (vertical_blade) # return (operations.unite(blade1, blade1_dia)) pillar_beam2 = operations.translate( pillar_beam, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia2 = operations.rotate(pillar_beam2, transversal=1, angle='%s *degree' % truss_rot_degree) blade2 = operations.translate(pillar_beam2, beam='%s *mm' % (distance_fr_center_height_main)) blade2_dia = operations.translate(pillar_beam_dia2, beam='%s *mm' % (distance_fr_center_height_main)) # return (operations.unite(operations.unite(pillar_beam2, pillar_beam_dia2), pillar_beam)) pillar_beam3 = operations.translate( pillar_beam2, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia3 = operations.rotate(pillar_beam3, transversal=1, angle='%s *degree' % truss_rot_degree) blade3 = operations.translate( pillar_beam3, beam='%s *mm' % (distance_fr_center_height_main - self.touch_to_halfcircle)) blade3_dia = operations.translate(pillar_beam_dia3, beam='%s *mm' % (distance_fr_center_height_main)) pillar_beam4 = operations.translate( pillar_beam3, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia4 = operations.rotate(pillar_beam4, transversal=1, angle='%s *degree' % (truss_rot_degree)) blade4 = operations.translate(pillar_beam4, beam='%s *mm' % (distance_fr_center_height_main)) blade4_dia = operations.translate(pillar_beam_dia4, beam='%s *mm' % (distance_fr_center_height_main)) pillar_beam5 = operations.translate( pillar_beam4, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia5 = operations.rotate(pillar_beam5, transversal=1, angle='%s *degree' % (truss_rot_degree)) blade5 = operations.translate(pillar_beam5, beam='%s *mm' % (distance_fr_center_height_main)) blade5_dia = operations.translate(pillar_beam_dia5, beam='%s *mm' % (distance_fr_center_height_main)) pillar_beam6 = operations.translate( pillar_beam5, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia6 = operations.rotate(pillar_beam6, transversal=1, angle='%s *degree' % (truss_rot_degree)) blade6 = operations.translate(pillar_beam6, beam='%s *mm' % (distance_fr_center_height_main)) blade6_dia = operations.translate(pillar_beam_dia6, beam='%s *mm' % (distance_fr_center_height_main)) # return (operations.unite(operations.unite(operations.unite(operations.unite(operations.unite(blade1, blade2), blade3), blade4), blade5), blade6)) pillar_beam7 = operations.translate( pillar_beam6, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia7 = operations.rotate(pillar_beam7, transversal=1, angle='%s *degree' % (truss_rot_degree)) blade7 = operations.translate(pillar_beam7, beam='%s *mm' % (distance_fr_center_height_main)) blade7_dia = operations.translate(pillar_beam_dia7, beam='%s *mm' % (distance_fr_center_height_main)) pillar_beam8 = operations.translate( pillar_beam7, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia8 = operations.rotate(pillar_beam8, transversal=1, angle='%s *degree' % (truss_rot_degree)) blade8 = operations.translate(pillar_beam8, beam='%s *mm' % (distance_fr_center_height_main)) blade8_dia = operations.translate(pillar_beam_dia8, beam='%s *mm' % (distance_fr_center_height_main)) # return (operations.unite(blade1, blade3)) pillar_beam9 = operations.translate( pillar_beam8, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia9 = operations.rotate(pillar_beam9, transversal=1, angle='%s *degree' % (truss_rot_degree)) blade9 = operations.translate(pillar_beam9, beam='%s *mm' % (distance_fr_center_height_main)) blade9_dia = operations.translate(pillar_beam_dia9, beam='%s *mm' % (distance_fr_center_height_main)) pillar_beam10 = operations.translate( pillar_beam9, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia10 = operations.rotate(pillar_beam10, transversal=1, angle='%s *degree' % (truss_rot_degree)) blade10 = operations.translate(pillar_beam10, beam='%s *mm' % (distance_fr_center_height_main)) blade10_dia = operations.translate(pillar_beam_dia10, beam='%s *mm' % (distance_fr_center_height_main)) pillar_beam_last = operations.translate( pillar_beam10, vertical="%s *mm" % -(suppert_end_distance_fr_source * np.sin(np.deg2rad(angle)))) pillar_beam_dia_last = operations.rotate(blade1, transversal=1, angle='%s *degree' % (90)) blade_last = operations.translate(pillar_beam_last, beam='%s *mm' % (distance_fr_center_height_main)) blade_last_dia = operations.translate(pillar_beam_dia_last, beam='%s *mm' % (distance_fr_center_height_main)) # blade_last_up = operations.rotate( # operations.rotate(pillar_beam_last, transversal=1, angle='%s *degree' % (-180)), vertical=1, # angle='%s *degree' % 180) # return(blade_last) blades = [ vertical_blade, blade1_needed, blade1_dia, blade2, blade2_dia, blade3, blade3_dia, blade4, blade4_dia, blade5, blade5_dia, blade6, ] # blades = [vertical_blade, blade1_needed, blade1_dia,blade2, blade2_dia, blade3, blade4, # blade4_dia, blade5, # blade5_dia, blade6, blade6_dia, blade7, ] all_blades_down = operations.unite(*blades) blades_up = operations.rotate(operations.rotate(all_blades_down, transversal=1, angle='%s *degree' % (-180)), vertical=1, angle='%s *degree' % 180) # return (blades_up) side_cut_box = shapes.block(height='%s *mm' % 10000, width='%s *mm' % (100), thickness='%s *mm' % (self.inner_radius * 2)) blades_up = operations.subtract(blades_up, side_cut_box) # return (operations.unite(blades_up, self.generate_box_toCut_big_end())) all_blades = operations.unite(all_blades_down, blades_up) # more_blades_up=operations.rotate( # operations.rotate(all_blades, transversal=1, angle='%s *degree' % (-180)), vertical=1, # angle='%s *degree' % 180) return (all_blades)
def notify(self, parent): import instrument.geometry.operations as ops rotation = ops.rotate(self._body, angle=self._angle, **self._axis) parent.onRotation(rotation) return
def vision_seat(self): seat_hollow_angle = self.table_angle seat_larger_cone_height = (self.vision_seat_bottom_diameter/ 2) / \ np.tan(np.deg2rad(self.vision_seat_skirt_angle / 2)) # seat_smaller_cone_height = (self.vision_seat_skirt_height * self.seat_top_diameter) / \ # (self.seat_bottom_diameter - self.seat_top_diameter) seat_smaller_cone_height = seat_larger_cone_height - self.vision_seat_skirt_height seat_hollow_large_cone_height_at_top_seat = ((self.vision_seat_hollow_top_diamter) / 2) / \ np.tan(np.deg2rad(seat_hollow_angle / 2)) seat_hollow_large_cone_height = seat_hollow_large_cone_height_at_top_seat + 50 seat_hollow_large_cone_diameter = 2 * seat_hollow_large_cone_height * np.tan( np.deg2rad(seat_hollow_angle / 2)) # cone has to be translated to center and after translation, the cone is in the negative Y direction seat_cone_to_subtract = operations.translate( shapes.cone(radius='%s *mm' % (self.seat_top_diameter / 2. + 500.), height='%s *mm' % (seat_smaller_cone_height)), vertical='%s *mm' % (-seat_smaller_cone_height)) seat_larger_cone = operations.translate(shapes.cone( radius='%s *mm' % (self.vision_seat_bottom_diameter / 2.), height='%s *mm' % (seat_larger_cone_height)), vertical='%s *mm' % (-seat_larger_cone_height)) solid_seat_not_atCenter = operations.subtract(seat_larger_cone, seat_cone_to_subtract) solid_seat_at_center = operations.translate( solid_seat_not_atCenter, vertical='%s *mm' % (seat_smaller_cone_height)) # solid seat at center(0,0) ######## HOLLOW TAPPERED CONE ######### seat_hollow_large_cone = operations.translate( shapes.cone(radius='%s *mm' % ((seat_hollow_large_cone_diameter) / 2.), height='%s *mm' % (seat_hollow_large_cone_height)), vertical='%s *mm' % (-(seat_hollow_large_cone_height))) # invert the tappered hollow seat_tappered_hollow = operations.translate( operations.rotate(seat_hollow_large_cone, transversal=1, angle='%s *degree' % (-180)), vertical='%s *mm' % (-seat_hollow_large_cone_height_at_top_seat)) hollow_seat = operations.subtract(solid_seat_at_center, seat_tappered_hollow) smaller_saft_to_drill = shapes.cylinder( radius='%s *mm' % (self.vision_seat_hollow_bottom_diameter / 2.), height='%s *mm' % (self.vision_seat_shaft_height + 100.)) seat_withSmall_hollow_shaft = operations.subtract( hollow_seat, smaller_saft_to_drill) ######## CYLINDER SHAFT ############# solid_shaft = shapes.cylinder( radius='%s *mm' % (self.vision_seat_shaft_diameter / 2.), height='%s *mm' % (self.vision_seat_shaft_height)) shaft_to_drill = shapes.cylinder( radius='%s *mm' % (self.vision_seat_hollow_bottom_diameter / 2.), height='%s *mm' % (self.seat_shaft_height + 100.)) hollow_shaft_atCenter = operations.translate( operations.subtract(solid_shaft, shaft_to_drill), vertical='%s *mm' % (-self.vision_seat_shaft_height / 2.)) hollow_shaft_atSkirt = operations.translate( hollow_shaft_atCenter, vertical='%s *mm' % (-self.vision_seat_skirt_height)) ######## COMBINING SEAT AND SHAFT ############# seat_shaft_down_center = operations.unite(seat_withSmall_hollow_shaft, hollow_shaft_atSkirt) return (seat_shaft_down_center)
def support_design(self): angle = 4 truss_rot_degree = 5 main_cylinder_radius = self.inner_radius # inner radius of the collimator main_cylinder_diameter = main_cylinder_radius * 2. # # support_height = main_cylinder_diameter - self.beam_dist_support # # # # distance_fr_center_support = np.sqrt((main_cylinder_radius) ** 2 - (height_support / 2) ** 2) base_width_support = self.truss_base_thickness suppert_end_distance_fr_source = self.inner_radius + base_width_support collimator_thickness_at_support_end = self.angle2span( suppert_end_distance_fr_source, self.vertical_acceptance_angle) length = 1000. ## as big as possible width = collimator_thickness_at_support_end pillar = shapes.block(height='%s *mm' % (length), width='%s *mm' % (collimator_thickness_at_support_end), thickness='%s *mm' % 1) pillar_beam = operations.rotate(pillar, transversal=1, angle="%s *degree" % 90) pillar_beamT = operations.rotate(pillar, transversal=1, angle="%s *degree" % 90) small_pillar_beam_tocut = operations.rotate(shapes.block( height='%s *mm' % (length), width='%s *mm' % (width + 5), thickness='%s *mm' % 5), transversal=1, angle="%s *degree" % 90) pillar_beam = operations.subtract( pillar_beam, operations.translate(small_pillar_beam_tocut, beam='%s*mm' % -(length / 2))) pillar_beam_dia = operations.rotate(pillar_beam, transversal=1, angle='%s *degree' % truss_rot_degree) number_blades = 10 vertical_distance = 0 pillar_beams = [] pillar_beams_dia = [] for i in xrange(number_blades): pillar_beam = operations.translate(pillar_beam, vertical="%s *mm" % -(vertical_distance)) vertical_distance = length / 2. * np.sin(np.deg2rad(angle)) # truss_rot_degree = angle*(i/0.2) truss_rot_degree = 3 pillar_beam_dia = operations.rotate(pillar_beam, transversal=1, angle='%s *degree' % truss_rot_degree) pillar_beams.append(pillar_beam) pillar_beams_dia.append(pillar_beam_dia) united_blades = operations.unite(*pillar_beams) united_blades_dia = operations.unite(*pillar_beams_dia) verticle_pillar = operations.translate(pillar, beam="%s *mm" % (self.inner_radius)) blades = operations.unite( operations.unite(united_blades, united_blades_dia), verticle_pillar) side_cut_box = shapes.block(height='%s *mm' % 10000, width='%s *mm' % (100), thickness='%s *mm' % (self.inner_radius * 2)) blades_cleanUp = operations.subtract(blades, side_cut_box) return (blades_cleanUp)
def anvil(self, girdle_length=6.): crown_top_triangle_height = self.crown_top_triangle_height() crown_total_triangle_height = self.crown_total_triangle_height( girdle_length) pavilion_bottom_triangle_height = self.pavilion_bottom_triangle_height( ) print('pavilion from center', pavilion_bottom_triangle_height) pavilion_total_triangle_height = self.pavilion_total_triangle_height( girdle_length) upper_orLower_anvil_height_from_center = self.upper_orLower_anvil_height_from_center( ) crown_top_cone = operations.translate( shapes.cone(radius='%s *mm' % 500, height='%s*mm' % (crown_top_triangle_height)), vertical='%s *mm' % (-crown_top_triangle_height)) crown_total_cone = operations.translate( shapes.cone(radius='%s*mm' % (girdle_length / 2, ), height='%s*mm' % crown_total_triangle_height), vertical='%s *mm' % (-crown_total_triangle_height)) crown = operations.subtract(crown_total_cone, crown_top_cone) pavilion_bottom_cone = operations.translate( shapes.cone(radius='%s *mm' % 500., height='%s*mm' % (pavilion_bottom_triangle_height)), vertical='%s *mm' % (-pavilion_bottom_triangle_height)) pavilion_total_cone = operations.translate( shapes.cone(radius='%s*mm' % (girdle_length / 2), height='%s*mm' % pavilion_total_triangle_height), vertical='%s *mm' % (-pavilion_total_triangle_height)) pavilion = operations.rotate(operations.subtract( pavilion_total_cone, pavilion_bottom_cone), transversal=1, angle='%s *degree' % (180)) girdle = shapes.cylinder(radius='%s*mm' % (girdle_length / 2.), height='%s*mm' % (self.girdle_height)) girdle_inplace = operations.translate( girdle, vertical='%s *mm' % (pavilion_total_triangle_height + self.girdle_height / 2.)) crown_inplace = operations.translate( crown, vertical='%s *mm' % (pavilion_total_triangle_height + self.girdle_height + crown_total_triangle_height)) upper_diamond_anvil = operations.unite( operations.unite(crown_inplace, girdle_inplace), pavilion) lower_diamond_anvil = operations.rotate(operations.rotate( upper_diamond_anvil, transversal=1, angle='%s *degree' % (-180)), vertical=1, angle='%s *degree' % 180) # return (operations.unite(upper_diamond_anvil, lower_diamond_anvil)) #### the following is for changing the gap between two anvil ########## upper_diamond_anvil_at_center = operations.translate( upper_diamond_anvil, vertical='%s *mm' % (-pavilion_bottom_triangle_height)) upper_diamond_anvil_at_positive_pt_one_from_center = operations.translate( upper_diamond_anvil_at_center, vertical='%s *mm' % (self.sample_height / 2.)) lower_diamond_anvil_at_neg_pt_one_from_center = operations.rotate( operations.rotate( upper_diamond_anvil_at_positive_pt_one_from_center, transversal=1, angle='%s *degree' % (-180)), vertical=1, angle='%s *degree' % 180) return (operations.unite( upper_diamond_anvil_at_positive_pt_one_from_center, lower_diamond_anvil_at_neg_pt_one_from_center))
def body_bar_rotated(self): return (operations.rotate(self.body_bar(), vertical=1, angle='%s *degree' % (90)))