def onSphereShell(self, sphereShell): from mccomposite.geometry.primitives import sphere from mccomposite.geometry.operations import subtract r1 = sphereShell.in_radius r2 = sphereShell.out_radius if r1 >= r2: msg = 'inner radius (%s) should be smaller than outer radius (%s)' %( r1, r2) raise RuntimeError, msg if r1 == 0*r1: shape = sphere(r2) else: shape = subtract( sphere(r2), sphere(r1) ) return shape.identify(self)
def test(self): # create a weird shape from mccomposite.geometry import primitives block = primitives.block((1, 1, 1)) sphere = primitives.sphere(1) cylinder = primitives.cylinder(2, 2.001) from mccomposite.geometry import operations dilated = operations.dilate(sphere, 2) translated = operations.translate(block, (0, 0, 0.5)) united = operations.unite(dilated, translated) rotated = operations.rotate(united, (90, 0, 0)) intersect = operations.intersect(rotated, cylinder) difference = operations.subtract(intersect, sphere) print mccomposite.scattererEngine(difference) shape = difference #shape = block #shape = dilated #shape = united #shape = intersect #shape = operations.rotate(block, (90,0,0) ) #shape = rotated #shape = sphere #shape = operations.subtract(sphere, block) #shape = operations.subtract( primitives.cylinder(1, 2.1), sphere ) #create pure python representation of scatterer composite composite = mccomposite.composite(shape) nprinter = NeutronPrinter(shape) composite.addElement(nprinter) #render the c++ representation ccomposite = mccomposite.scattererEngine(composite) ev = mcni.neutron(r=(0, 0, -5), v=(0, 0, 1)) ccomposite.scatter(ev) return
def test(self): # create a weird shape from mccomposite.geometry import primitives block = primitives.block( (1,1,1) ) sphere = primitives.sphere( 1 ) cylinder = primitives.cylinder( 2,2.001 ) from mccomposite.geometry import operations dilated = operations.dilate( sphere, 2 ) translated = operations.translate( block, (0,0,0.5) ) united = operations.unite( dilated, translated ) rotated = operations.rotate( united, (90,0,0) ) intersect = operations.intersect( rotated, cylinder ) difference = operations.subtract( intersect, sphere ) print mccomposite.scattererEngine( difference ) shape = difference #shape = block #shape = dilated #shape = united #shape = intersect #shape = operations.rotate(block, (90,0,0) ) #shape = rotated #shape = sphere #shape = operations.subtract(sphere, block) #shape = operations.subtract( primitives.cylinder(1, 2.1), sphere ) #create pure python representation of scatterer composite composite = mccomposite.composite( shape ) nprinter = NeutronPrinter( shape ) composite.addElement( nprinter ) #render the c++ representation ccomposite = mccomposite.scattererEngine( composite ) ev = mcni.neutron( r = (0,0,-5), v = (0,0,1) ) ccomposite.scatter(ev) return