def loadTextureForMesh(polyData, meshFileName):

        textureFileName = Geometry.getTextureFileName(polyData)
        if textureFileName in Geometry.TextureCache or textureFileName is None:
            return

        if not os.path.isabs(textureFileName):
            baseDir = os.path.dirname(meshFileName)
            imageFile = os.path.join(baseDir, textureFileName)
        else:
            imageFile = textureFileName

        if not os.path.isfile(imageFile):
            print 'cannot find texture file:', textureFileName
            return

        image = ioUtils.readImage(imageFile)
        if not image:
            print 'failed to load image file:', imageFile
            return

        texture = vtk.vtkTexture()
        texture.SetInput(image)
        texture.EdgeClampOn()
        texture.RepeatOn()

        Geometry.TextureCache[textureFileName] = texture
    def loadTextureForMesh(polyData, meshFileName):

        textureFileName = Geometry.getTextureFileName(polyData)
        if textureFileName in Geometry.TextureCache or textureFileName is None:
            return

        if not os.path.isabs(textureFileName):
            baseDir = os.path.dirname(meshFileName)
            imageFile = os.path.join(baseDir, textureFileName)
        else:
            imageFile = textureFileName

        if not os.path.isfile(imageFile):
            print "cannot find texture file:", textureFileName
            return

        image = ioUtils.readImage(imageFile)
        if not image:
            print "failed to load image file:", imageFile
            return

        texture = vtk.vtkTexture()
        texture.SetInput(image)
        texture.EdgeClampOn()
        texture.RepeatOn()

        Geometry.TextureCache[textureFileName] = texture
 def loadBackgroundImage(self, filename):
     view = self.view
     img = ioUtils.readImage(filename)
     tex = vtk.vtkTexture()
     tex.SetInput(img)
     view.renderer().SetBackgroundTexture(tex)
     view.renderer().TexturedBackgroundOn()
Beispiel #4
0
def createTexture(imageFilename):
    image = ioUtils.readImage(imageFilename)
    tex = vtk.vtkTexture()
    tex.SetInput(image)
    tex.EdgeClampOn()
    tex.RepeatOff()
    return tex
Beispiel #5
0
def createTexture(imageFilename):
    image = ioUtils.readImage(imageFilename)
    tex = vtk.vtkTexture()
    tex.SetInput(image)
    tex.EdgeClampOn()
    tex.RepeatOff()
    return tex
Beispiel #6
0
    def getTextureForMaterial(self, material):

        materialDict = dict(material.properties.items())

        if 'file' not in materialDict:
            return None

        textureFile = materialDict['file']

        if textureFile in self.textureCache:
            return self.textureCache[textureFile]

        if not os.path.isabs(textureFile):
            imageFile = os.path.join(self.baseDir, textureFile)
        else:
            imageFile = textureFile

        if os.path.isfile(imageFile):
            image = ioUtils.readImage(imageFile)

            if image:
                texture = vtk.vtkTexture()
                texture.SetInput(image)
                texture.EdgeClampOn()
                texture.RepeatOn()
            else:
                print 'failed to load image file:', imageFile
                texture = None
        else:
            print 'cannot find texture file:', textureFile
            texture = None

        self.textureCache[textureFile] = texture
        return texture