Exemplo n.º 1
0
    def getCachedDataArray(self, pMd5, binary=False, compression=False):
        cacheObj = self.dataArrayCache[pMd5]
        array = cacheObj['array']
        cacheTime = cacheObj['mTime']

        if cacheTime != array.GetMTime():
            if context.debugAll:
                print(' ***** ERROR: you asked for an old cache key! ***** ')

        if array.GetDataType() in (12, 16, 17):
            arraySize = array.GetNumberOfTuples() * array.GetNumberOfComponents()
            if array.GetDataType() in (12, 17):
                # IdType and unsigned long long need to be converted to Uint32
                newArray = vtkTypeUInt32Array()
            else:
                #  long long need to be converted to Int32
                newArray = vtkTypeInt32Array()
            newArray.SetNumberOfTuples(arraySize)
            for i in range(arraySize):
                newArray.SetValue(i, -1 if array.GetValue(i)
                                  < 0 else array.GetValue(i))
            pBuffer = buffer(newArray)
        else:
            pBuffer = buffer(array)

        if binary:
            # Convert the vtkUnsignedCharArray into a bytes object, required by
            # Autobahn websockets
            return pBuffer.tobytes() if not compression else zipCompression(pMd5, pBuffer.tobytes())

        return base64Encode(pBuffer if not compression else zipCompression(pMd5, pBuffer.tobytes()))
Exemplo n.º 2
0
  def getCachedDataArray(self, pMd5):
    cacheObj = self.dataArrayCache[pMd5]
    array = cacheObj['array']
    cacheTime = cacheObj['mTime']

    if cacheTime != array.GetMTime():
      if context.debugAll: print(' ***** ERROR: you asked for an old cache key! ***** ')

    if array.GetDataType() == 12:
      # IdType need to be converted to Uint32
      arraySize = array.GetNumberOfTuples() * array.GetNumberOfComponents()
      newArray = vtkTypeUInt32Array()
      newArray.SetNumberOfTuples(arraySize)
      for i in range(arraySize):
        newArray.SetValue(i, -1 if array.GetValue(i) < 0 else array.GetValue(i))
      pBuffer = buffer(newArray)
    else:
      pBuffer = buffer(array)

    return base64.b64encode(pBuffer)
    def getCachedDataArray(self, pMd5):
        cacheObj = self.dataArrayCache[pMd5]
        array = cacheObj['array']
        cacheTime = cacheObj['mTime']

        if cacheTime != array.GetMTime():
            if context.debugAll:
                print(' ***** ERROR: you asked for an old cache key! ***** ')

        if array.GetDataType() == 12:
            # IdType need to be converted to Uint32
            arraySize = array.GetNumberOfTuples(
            ) * array.GetNumberOfComponents()
            newArray = vtkTypeUInt32Array()
            newArray.SetNumberOfTuples(arraySize)
            for i in range(arraySize):
                newArray.SetValue(
                    i, -1 if array.GetValue(i) < 0 else array.GetValue(i))
            pBuffer = buffer(newArray)
        else:
            pBuffer = buffer(array)

        return base64Encode(pBuffer)
Exemplo n.º 4
0
  def getCachedDataArray(self, pMd5, binary = False):
    cacheObj = self.dataArrayCache[pMd5]
    array = cacheObj['array']
    cacheTime = cacheObj['mTime']

    if cacheTime != array.GetMTime():
      if context.debugAll: print(' ***** ERROR: you asked for an old cache key! ***** ')

    if array.GetDataType() == 12:
      # IdType need to be converted to Uint32
      arraySize = array.GetNumberOfTuples() * array.GetNumberOfComponents()
      newArray = vtkTypeUInt32Array()
      newArray.SetNumberOfTuples(arraySize)
      for i in range(arraySize):
        newArray.SetValue(i, -1 if array.GetValue(i) < 0 else array.GetValue(i))
      pBuffer = buffer(newArray)
    else:
      pBuffer = buffer(array)

    if binary:
      # Convert the vtkUnsignedCharArray into a bytes object, required by Autobahn websockets
      return pBuffer.tobytes()

    return base64Encode(pBuffer)