def wtexture(xv, yv, zv, wv):
    """ Since the function will be used alot and is tedious to implement """
    xv = numpy.array(xv)
    yv = numpy.array(yv)
    zv = numpy.array(zv)
    wv = numpy.array(wv)

    swv = sum(wv)
    xm = numpy.multiply(xv, wv) / swv
    ym = numpy.multiply(yv, wv) / swv
    zm = numpy.multiply(zv, wv) / swv

    xv -= xm
    yv -= ym
    zv -= zm

    xv *= wv
    yv *= wv
    zv *= wv

    textMat = [[sum(xv * xv) / swv, sum(xv * yv) / swv, sum(xv * zv) / swv]]
    textMat += [[sum(yv * xv) / swv, sum(yv * yv) / swv, sum(yv * zv) / swv]]
    textMat += [[sum(zv * xv) / swv, sum(zv * yv) / swv, sum(zv * zv) / swv]]
    return textMat
    DA.numpyTovtkDataArray(numpy.random.rand(50, 1))
Exemplo n.º 2
0
def wtexture(xv, yv, zv, wv):
    """ Since the function will be used alot and is tedious to implement """
    xv = numpy.array(xv)
    yv = numpy.array(yv)
    zv = numpy.array(zv)
    wv = numpy.array(wv)

    swv = sum(wv)
    xm = numpy.multiply(xv, wv) / swv
    ym = numpy.multiply(yv, wv) / swv
    zm = numpy.multiply(zv, wv) / swv

    xv -= xm
    yv -= ym
    zv -= zm

    xv *= wv
    yv *= wv
    zv *= wv

    textMat = [[sum(xv * xv) / swv, sum(xv * yv) / swv, sum(xv * zv) / swv]]
    textMat += [[sum(yv * xv) / swv, sum(yv * yv) / swv, sum(yv * zv) / swv]]
    textMat += [[sum(zv * xv) / swv, sum(zv * yv) / swv, sum(zv * zv) / swv]]
    return textMat
    DA.numpyTovtkDataArray(numpy.random.rand(50, 1))
Exemplo n.º 3
0
def ExtractElements(self, inputDS, selection, mask):
    if mask is None:
        # nothing was selected
        return None
    elif type(mask) == bool:
        if mask:
            # FIXME: We need to add the "vtkOriginalIds" array.
            return inputDS
        else:
            # nothing was extracted.
            return None
    else:
        # mask must be an array. Process it.
        mask_array = dataset_adapter.numpyTovtkDataArray(int8(mask), "_mask_array")
        retVal = self.ExtractElements(inputDS, selection, mask_array)
        if retVal:
            retVal.UnRegister(None)
            return retVal
    return None
Exemplo n.º 4
0
for i in range(numPoints):
    x,y,z=input.GetPoint(i)
    newPoints.InsertPoint(i, x, y, 1 + z*0.3)

output.SetPoints(newPoints)
#--------------------------------------------------------------------------
from paraview.vtk.dataset_adapter import numpyTovtkDataArray

input = inputs[0]

newPoints = vtk.vtkPoints()

zs = 1 + input.Points[:,2]*0.3
coords = hstack([input.Points[:,0:2],zs])
newPoints.SetData(numpyTovtkDataArray(coords))

output.SetPoints(newPoints)
###########################################################################
#3.Deal with multiple inputs
output.PointData.append(inputs[1].PointData['p']-inputs[0].PointData['p'],
                       "difference")
###########################################################################
#4.vtkTable
rtdata = inputs[0].PointData['RTData']
output.RowData.append(min(rtdata), 'min')
output.RowData.append(max(rtdata), 'max')
###########################################################################
#5.CSV Reader(Source)
#file format:
# x,y,z,velocity
for i in range(numPoints):
    x,y,z=input.GetPoint(i)
    newPoints.InsertPoint(i, x, y, 1 + z*0.3)

output.SetPoints(newPoints)
#--------------------------------------------------------------------------
from paraview.vtk.dataset_adapter import numpyTovtkDataArray

input = inputs[0]

newPoints = vtk.vtkPoints()

zs = 1 + input.Points[:,2]*0.3
coords = hstack([input.Points[:,0:2],zs])
newPoints.SetData(numpyTovtkDataArray(coords))

output.SetPoints(newPoints)
###########################################################################
#3.Deal with multiple inputs
output.PointData.append(inputs[1].PointData['p']-inputs[0].PointData['p'],
                       "difference")
###########################################################################
#4.vtkTable
rtdata = inputs[0].PointData['RTData']
output.RowData.append(min(rtdata), 'min')
output.RowData.append(max(rtdata), 'max')
###########################################################################
#5.CSV Reader(Source)
#file format:
# x,y,z,velocity