def add_tensor_glyph(self, input, type, resolution=None, name=None, scale=None): # Helper function. version = self.version if version == 4: if type == 'Cylinder': source = servermanager.sources.CylinderSource() if resolution != None: source.Resolution = resolution if scale != None: source.Radius = 0.5 * scale elif type == 'Box': source = servermanager.sources.CubeSource() tensor_glyph = servermanager.filters.TensorGlyph(Input=input, Source=source) tensor_glyph.SelectInputTensors = ['0', '', '', '', 'tensors'] # The specified scalar array is the only array that gets copied. tensor_glyph.SelectInputScalars = ['1', '', '', '', 'colors'] else: tensor_glyph = servermanager.filters.TensorGlyph(Input=input, GlyphType=type) # Heads up. The first or the specified vector array is the only # array that gets copied (scalar arrays don't get copied). tensor_glyph.Vectors = ['POINTS', 'colors_as_vectors'] if resolution != None: tensor_glyph.GlyphType.Resolution = resolution if scale != None: tensor_glyph.GlyphType.Radius *= scale if name != None: servermanager.Register(tensor_glyph, registrationName=name) else: servermanager.Register(tensor_glyph) return tensor_glyph
def __GetLookupTableForArray(self,aArray,**kwargs): """ Set the lookup table for the given array and assign the named properties. """ proxyName='%d.%s.PVLookupTable'%(aArray.GetNumberOfComponents(),aArray.GetName()) lut = servermanager.ProxyManager().GetProxy('lookup_tables',proxyName) if not lut: lut = servermanager.rendering.PVLookupTable(ColorSpace="HSV",RGBPoints=[0,0,0,1, 1,1,0,0]) servermanager.Register(lut, registrationName=proxyName) for arg in kwargs.keys(): if not hasattr(lut, arg): raise AttributeError("LUT has no property %s"%(arg)) setattr(lut,arg,kwargs[arg]) return lut
def applyMaterialToRepresentation(self, name, representation): material = self.materials[name] if name in self.materials else {} if 'map_Kd' in material: if name not in self.textures: from paraview import servermanager texture = servermanager._getPyProxy( servermanager.CreateProxy('textures', 'ImageTexture')) texture.FileName = os.path.join(self.baseDir, material['map_Kd'][0]) self.textures[name] = texture servermanager.Register(texture) representation.Texture = self.textures[name] if 'Ka' in material: representation.AmbientColor = [float(n) for n in material['Ka']] if 'Ks' in material: representation.SpecularColor = [float(v) for v in material['Ks']] if 'Kd' in material: representation.DiffuseColor = [float(v) for v in material['Kd']] if 'd' in material: representation.Opacity = float(material['d'][0]) if 'Ns' in material: representation.SpecularPower = float(material['Ns'][0]) if 'illum' in material: representation.Ambient = 1.0 if 0 <= float( material['illum'][0]) else 0.0 representation.Diffuse = 1.0 if 1 <= float( material['illum'][0]) else 0.0 representation.Specular = 1.0 if 2 <= float( material['illum'][0]) else 0.0