Ejemplo n.º 1
0
class PhysicalVolume:
	def __init__(self):
		self.position = Translation()
		self.rotation = Rotation()
		self.logvolref = 0
		self.logvol = 0
	
	def getTransform( self ):
		return AffineTransform( self.rotation, self.position )
	
	def __str__(self):
		return "PhysicalVolume - "+str(self.logvol)
		
	def write( self, stream ):
		stream.write(self.__class__.__name__+"\n")
		stream.write(self.logvolref+"\n")
		self.rotation.write(stream)
		self.position.write(stream)
Ejemplo n.º 2
0
	def startElement(self, name, attrs):
	
		if name == "position":
			self.positions[ attrs.get("name") ] = Translation.Create(*readxyz( attrs ))
		elif name == "rotation":
			self.rotations[ attrs.get("name") ] = Rotation.CreateEuler(*readxyz( attrs ))
			
		elif name == "material" or name == "element":
			self.inMaterial = True
			n = attrs.get("name")
			self.curmaterial = Material(n)
			self.materials[ n ] = self.curmaterial
		elif name == "D" and self.inMaterial:
			self.curmaterial.D = attrs.get("value")
		elif name == "atom" and self.inMaterial:
			self.curmaterial.atom = attrs.get("value")
			
		elif name == "tube":
			self.solids[ attrs.get("name") ] = Tube( attrs )
		elif name == "box":
			self.solids[ attrs.get("name") ] = Box( attrs )
		elif name == "cone":
			self.solids[ attrs.get("name") ] = Cone( attrs )
			
		elif name == "polycone":
			self.inPolycone = True
			self.polyconeZ = []
			self.polyconeAttrs = attrs
		elif name == "zplane" and self.inPolycone:
			self.polyconeZ.append( ZPlane( attrs ) )
			
		elif name in self.knownSolids:
			if name in self.missedsolids: self.missedsolids[name] += 1
			else: self.missedsolids[name] = 1
			self.missedsolidkeys.add( attrs.get("name") )
			
		elif name == "volume":
			n = attrs.get("name")
			self.curlogvol = LogicalVolume( n )
			self.logvols[ n ] = self.curlogvol
			
		elif name == "physvol":
			self.inPhysVol = True
			self.curphysvol = PhysicalVolume()
			self.curlogvol.daughters.append( self.curphysvol )
			
		elif name == "materialref":
			matref = attrs.get("ref")
			if matref not in self.materials:
				raise RuntimeError("Invalid material "+matref)
			self.curlogvol.material = matref
		elif name == "solidref":
			solidref = attrs.get("ref")
			if solidref in self.solids:
				self.curlogvol.solid = self.solids[solidref]
			elif solidref not in self.missedsolidkeys:
				raise RuntimeError("Invalid solid key "+solidref)
				
		elif self.inPhysVol:
			if name == "positionref":
				self.curphysvol.position = self.positions[ attrs.get("ref") ]
			if name == "rotationref":
				self.curphysvol.rotation = self.rotations[ attrs.get("ref") ]
			if name == "volumeref":
				self.curphysvol.logvolref = attrs.get("ref")
			
		elif name == "world":
			self.worldvol = self.logvols[ attrs.get("ref") ]
		else:
			self.unrecognized.add( name )
Ejemplo n.º 3
0
	def __init__(self):
		self.position = Translation()
		self.rotation = Rotation()
		self.logvolref = 0
		self.logvol = 0