def buildPOVRay(self): if (not self.isSphere): return povray.Box(povray.Vector(self.minX,self.minY,self.minZ), povray.Vector(self.maxX,self.maxY,self.maxZ)) if (self.isSphere): return povray.Sphere(povray.Vector( self.minX + (self.maxX - self.minX)/2.0, self.minY + (self.maxY - self.minY)/2.0, self.minZ + (self.maxZ - self.minZ)/2.0), (self.maxZ - self.minZ)/2.0) return 0
def getTransformationArgs(self): transArgs = {} # http://www.povray.org/documentation/view/3.6.1/49/ # http://www.f-lohmueller.de/pov_tut/trans/trans_400e.htm if (self.rotation): rot = Rotation.Rotation(self.rotation[0], self.rotation[1], self.rotation[2], self.rotation[3], self.rotation[4], self.rotation[5], self.rotation[6], self.rotation[7], self.rotation[8]) if (self.translation): transArgs['matrix'] = povray.Vector(rot.xx, rot.xy, rot.xz, rot.yx, rot.yy, rot.yz, rot.zx, rot.zy, rot.zz, float(self.translation[0]), float(self.translation[1]), float(self.translation[2])) else: transArgs['matrix'] = povray.Vector(rot.xx, rot.xy, rot.xz, rot.yx, rot.yy, rot.yz, rot.zx, rot.zy, rot.zz, 0.0, 0.0, 0.0) else: if (self.translation): transArgs['translate'] = povray.Vector( float(self.translation[0]), float(self.translation[1]), float(self.translation[2])) return transArgs
def getPovRayArgs(self): self.povRayArgs = {} if (self.translation): self.povRayArgs['translate'] = povray.Vector( self.translation.o1, self.translation.o2, self.translation.o3) # http://www.povray.org/documentation/view/3.6.1/49/ # http://www.f-lohmueller.de/pov_tut/trans/trans_400e.htm if (self.rotation): self.povRayArgs['matrix'] = povray.Vector( self.rotation.xx, self.rotation.xy, self.rotation.xz, self.rotation.yx, self.rotation.yy, self.rotation.yz, self.rotation.zx, self.rotation.zy, self.rotation.zz, 0.0, 0.0, 0.0) return self.povRayArgs
def getUniversePovRayArgs(self): universePovRayArgs = {'//UNIVERSE': self.fillUniverse} if (self.universeTranslation): universePovRayArgs['translate'] = povray.Vector( self.universeTranslation.o1, self.universeTranslation.o2, self.universeTranslation.o3) if (len(universePovRayArgs) > 1): return universePovRayArgs else: return {}
def addVolumeDataSlice(self, volumedata, origin, normal, colormap): vb = volumedata.value_bounds cb = colormap.value_bounds a = (vb[0] - cb[0]) / (cb[1] - cb[0]) m = (vb[1] - vb[0]) / (cb[1] - cb[0]) style = """ texture { pigment { function { %s + %s*%s(x,y,z) } color_map { %s } } finish { specular 0. ambient 1. } }""" % (a, m, volumedata.name, colormap.name) o = pv.Plane( pv.Vector(*normal), np.dot(origin, normal), pv.ClippedBy( pv.Box(volumedata.worldbox[:, 0], volumedata.worldbox[:, 1])), style) o.write(self.pvfile)