Example #1
0
def makeSimpleGeom(array, ctup, geomType = GeomPoints, fix = False):
    fmt = GeomVertexFormat.getV3c4()

    vertexData = GeomVertexData('points', fmt, Geom.UHDynamic) #FIXME use the index for these too? with setPythonTag, will have to 'reserve' some
    cloudGeom = Geom(vertexData)
    cloudNode = GeomNode('just some points')

    verts = GeomVertexWriter(vertexData, 'vertex')
    color = GeomVertexWriter(vertexData, 'color')

    if fix:
        if len(ctup) == len(array):
            for point,c in zip(array, ctup):
                verts.addData3f(*point)
                color.addData4f(*c)
        else:
            for point in array:
                verts.addData3f(*point)
                color.addData4f(*ctup)
    else:
        for point in array:
            verts.addData3f(*point)
            color.addData4f(*ctup)

    points = geomType(Geom.UHDynamic)
    points.addConsecutiveVertices(0,len(array))
    points.closePrimitive()

    cloudGeom.addPrimitive(points)
    cloudNode.addGeom(cloudGeom) #TODO figure out if it is faster to add and subtract Geoms from geom nodes...

    if fix:
        return cloudNode.__reduce__()
    else:
        return cloudNode  # decoding fails becuase ForkingPickler is called for reasons beyond comprehension
Example #2
0
def make_response_pipe(pipe, request):
    """ returns the request hash and a compressed bam stream """
    np.random.seed()  # looky here!
    rh = request.hash_

    n = 9999
    positions = np.cumsum(np.random.randint(-1, 2, (n, 3)), axis=0)
    uuids = np.array(['%s' % uuid4() for _ in range(n)])
    bounds = np.ones(n) * .5
    example_coll = pickle.dumps(
        (positions, uuids,
         bounds))  # FIXME putting pickles last can bollox the STOP
    print('making example bam')
    #example_bam = makeSimpleGeom(positions, np.random.rand(4)).__reduce__()[1][-1]  # the ONE way we can get this to work atm; GeomNode iirc; FIXME make sure -1 works every time
    #print('done making bam',example_bam)  # XXX if you want this use repr() ffs

    array, ctup, geomType = positions, np.random.rand(4), GeomPoints
    fmt = GeomVertexFormat.getV3c4()

    vertexData = GeomVertexData(
        'points', fmt, Geom.UHDynamic
    )  #FIXME use the index for these too? with setPythonTag, will have to 'reserve' some
    cloudGeom = Geom(vertexData)
    cloudNode = GeomNode('just some points')

    verts = GeomVertexWriter(vertexData, 'vertex')
    color = GeomVertexWriter(vertexData, 'color')

    for point in array:
        verts.addData3f(*point)
        color.addData4f(*ctup)

    points = geomType(Geom.UHDynamic)
    points.addConsecutiveVertices(0, len(array))
    points.closePrimitive()

    cloudGeom.addPrimitive(points)
    cloudNode.addGeom(
        cloudGeom
    )  #TODO figure out if it is faster to add and subtract Geoms from geom nodes...
    example_bam = cloudNode.__reduce__()[1][-1]

    data_tuple = (example_bam, example_coll, b'this is a UI data I swear')

    data_stream = ResponseByteStream.makeResponseStream(rh, data_tuple)
    pipe.send_bytes(data_stream)
    pipe.close()
Example #3
0
def makeSimpleGeom(array, ctup, geomType=GeomPoints, fix=False):
    fmt = GeomVertexFormat.getV3c4()

    vertexData = GeomVertexData(
        'points', fmt, Geom.UHDynamic
    )  #FIXME use the index for these too? with setPythonTag, will have to 'reserve' some
    cloudGeom = Geom(vertexData)
    cloudNode = GeomNode('just some points')

    verts = GeomVertexWriter(vertexData, 'vertex')
    color = GeomVertexWriter(vertexData, 'color')

    if fix:
        if len(ctup) == len(array):
            for point, c in zip(array, ctup):
                verts.addData3f(*point)
                color.addData4f(*c)
        else:
            for point in array:
                verts.addData3f(*point)
                color.addData4f(*ctup)
    else:
        for point in array:
            verts.addData3f(*point)
            color.addData4f(*ctup)

    points = geomType(Geom.UHDynamic)
    points.addConsecutiveVertices(0, len(array))
    points.closePrimitive()

    cloudGeom.addPrimitive(points)
    cloudNode.addGeom(
        cloudGeom
    )  #TODO figure out if it is faster to add and subtract Geoms from geom nodes...

    if fix:
        return cloudNode.__reduce__()
    else:
        return cloudNode  # decoding fails becuase ForkingPickler is called for reasons beyond comprehension