Exemplo n.º 1
0
def _create_id_array(dataobject, attributeType):
    """Returns a VTKArray or VTKCompositeDataArray for the ids"""
    if not dataobject:
        raise RuntimeError("dataobject cannot be None")
    if dataobject.IsA("vtkCompositeDataSet"):
        ids = []
        for ds in dataobject:
            ids.append(_create_id_array(ds, attributeType))
        return dsa.VTKCompositeDataArray(ids)
    else:
        return dsa.VTKArray(\
                np.arange(dataobject.GetNumberOfElements(attributeType)))
Exemplo n.º 2
0
def compute(inputs, expression, ns=None):
    #  build the locals environment used to eval the expression.
    mylocals = dict()
    if ns:
        mylocals.update(ns)
    mylocals["inputs"] = inputs
    try:
        mylocals["points"] = inputs[0].Points
    except AttributeError:
        pass

    finalRet = None
    for subEx in expression.split(' and '):
        retVal = eval(subEx, globals(), mylocals)
        if finalRet is None:
            finalRet = retVal
        else:
            finalRet = dsa.VTKArray([a & b for a, b in zip(finalRet, retVal)])

    return finalRet