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 notify(self, parent): sphere = shapes.sphere(radius=self._radius) parent.onSphere(sphere) return