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 addIsosurface(self, volumedata, level, style_object, clip_object, clip_style_object): vb = volumedata.value_bounds wb = volumedata.worldbox difference = vb[1] - vb[0] if __debug__: print('Adding Isosuface! See if threshold is reasonable:') print('vb[1]-vb[0]: %f ' % difference) threshold = -(level - vb[0]) / difference if np.isnan(threshold) or np.isinf(threshold): threshold = -1. o = pv.Isosurface( pv.Function('-%s(x,y,z)' % (volumedata.name)), ['max_gradient', volumedata.max_grad], pv.ContainedBy(pv.Box(wb[:, 0], wb[:, 1])), ['threshold', threshold], ['all_intersections'], #['scale', (wb[:,1]-wb[:,0])], #['translate', (wb[:,0])], ) o = pv.Object(o, style_object()) if clip_object: s = krebsutils.povray_clip_object_str(clip_object, str(clip_style_object)) if s: o = pv.Intersection(o, s) o.write(self.pvfile)
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)