def addSlice(parent, orientation):
    global gDataSet, gFocus, gValues

    # Get Data
    left = VectorDouble(3)
    right = VectorDouble(3)

    print "Reloading dataset(%s)" % gDataSet
    source = VisusDataSourceFactory.make(gDataSet)
    if not source.isValid():
        raise RuntimeError("Problem loading data set")
    source.domainBoundingBox(left, right)

    # Compute Data Requeset
    request = VisusDataRequest()

    extent = VectorDouble(3)
    extent[0] = 0.9 * (right[0] - left[0])
    extent[1] = 0.9 * (right[1] - left[1])
    extent[2] = 0
    request.extent(extent)
    start = [4, 4, 4]
    end = [1, 1, 1]
    request.setStrides(start, end)
    matrix = translationMatrix(
        (left[0] + right[0]) / 2,
        (left[1] + right[1]) / 2,
        (left[2] + right[2]) / 2,
    )
    request.transformation(matrix)

    # Create Producer
    extractor = VisusAxisAlignedExtractor.construct()
    extractor.setValue(gDataSet)
    extractor.setValue(request)

    # Create Consumer
    slice = VisusOrthogonalSlice.construct()
    slice.orientation(orientation)

    # Attach To Tree
    parent.attachSubTree(extractor)
    extractor.attachSubTree(slice)

    slice.inherit(VisusSharedDataRequest.typeIndex(), True)
    slice.inherit(VisusSharedBoundingBox.typeIndex(), True)
    extractor.setValue(request)
    slice.setValue(request)
    if not slice.connectInput(extractor):
        raise RuntimeError("unable to connect extractor as slice input")

    gFocus = slice

    gValues.extend([slice, extractor])

    return slice
Exemple #2
0
def createData():
    global gBBox, gDataSet, adata

    import numpy
    from math import sqrt, pow
    from pyvisus.numpyconversion import VisusIncoreEncoder

    idim = 50
    jdim = 50
    kdim = 50

    data = []
    for i in xrange(idim * jdim * kdim):
        data.append(0)

    for i in xrange(idim):
        for j in xrange(jdim):
            for k in xrange(kdim):
                data[k + j * kdim + i * jdim * kdim] = sqrt(
                    pow(i - 25.0, 2) + pow(j - 25.0, 2) + pow(k - 25.0, 2))

    adata = numpy.array(data)

    encoder = VisusIncoreEncoder(idim, jdim, kdim, 1)
    encoder.domain([0, 0, 0], [1.0 * idim, 1.0 * jdim, 0.1 * kdim])
    encoder.field(adata)
    gDataSet = str(encoder)

    # Make the data source
    print "Opening dataset(%s)" % gDataSet
    data = VisusDataSourceFactory.make(gDataSet)
    if not data.isValid():
        raise RuntimeError("Loaded data is not valid")

    gSamples = data.samples()
    left = VectorDouble(3)
    right = VectorDouble(3)
    data.domainBoundingBox(left, right)

    gBBox = VisusBoundingBox()
    gBBox.set(left, right)

    return
def createData(filename=None):
    global gBBox, gDataSet, adata

    if filename is None:
        import numpy
        from math import sqrt, pow
        from pyvisus.numpyconversion import VisusIncoreEncoder

        data = []
        for i in xrange(50 * 50 * 50):
            data.append(0)

        for i in xrange(50):
            for j in xrange(50):
                for k in xrange(50):
                    data[k + j * 50 + i * 50 * 50] = sqrt(
                        pow(i - 25.0, 2) + pow(j - 25.0, 2) + pow(k - 25.0, 2))

        adata = numpy.array(data)

        encoder = VisusIncoreEncoder(50, 50, 50)
        encoder.field(adata)
        gDataSet = str(encoder)
    else:
        gDataSet = "Idx:%s" % filename

    # Make the data source
    print "Opening dataset(%s)" % gDataSet
    data = VisusDataSourceFactory.make(gDataSet)
    if not data.isValid():
        raise RuntimeError("Loaded data is not valid")

    gSamples = data.samples()
    left = VectorDouble(3)
    right = VectorDouble(3)
    data.domainBoundingBox(left, right)

    gBBox = VisusBoundingBox()
    gBBox.set(left, right)

    return
Exemple #4
0
def addIsoSurface(parent):
    global gDataSet, gFocus, gValues

    # Get Data
    left = VectorDouble(3)
    right = VectorDouble(3)

    print "Reloading dataset(%s)" % gDataSet
    source = VisusDataSourceFactory.make(gDataSet)
    if not source.isValid():
        raise RuntimeError("Problem loading data set")
    source.domainBoundingBox(left, right)

    # Compute Data Requeset
    request = VisusDataRequest()

    extent = VectorDouble(3)
    extent[0] = 0.5 * (right[0] - left[0])
    extent[1] = 0.5 * (right[1] - left[1])
    extent[2] = 0.5 * (right[2] - left[2])
    request.extent(extent)
    start = [1, 1, 1]
    end = [1, 1, 1]
    request.setStrides(start, end)
    matrix = translationMatrix(
        (left[0] + right[0]) / 2,
        (left[1] + right[1]) / 2,
        (left[2] + right[2]) / 2,
    )
    request.transformation(matrix)

    # Create Producer
    extractor = VisusAxisAlignedExtractor.construct()

    # Create Consumer
    iso = VisusIsoSurface.construct()

    # Create Display
    display = VisusMeshDisplay.construct()
    display.normalIndex(3)

    # Attach To Tree
    parent.attachSubTree(extractor)
    extractor.attachSubTree(iso)
    iso.attachSubTree(display)

    # Connect Request
    extractor.setValue(gDataSet)
    extractor.setValue(request)

    # Connect Inputs
    if not iso.connectIso(extractor):
        raise RuntimeError("unable to connect extractor as iso input")

    if not display.connectInput(iso):
        raise RuntimeError("unable to connect iso as display input")

    gFocus = iso
    gFocus.drawBoundingBox(True)

    gValues.extend([iso, extractor])

    return iso
Exemple #5
0
def addSlice(parent, color, height):
    global gFocus, gValues

    # Get Data
    left = VectorDouble(3)
    right = VectorDouble(3)

    print "Reloading dataset(%s)" % color
    source = VisusDataSourceFactory.make(color)
    if not source.isValid():
        raise RuntimeError("Problem loading data set")
    source.domainBoundingBox(left, right)

    # Compute Data Requeset
    request = VisusDataRequest()

    extent = VectorDouble(3)
    extent[0] = 0.8 * (right[0] - left[0])
    extent[1] = 0.8 * (right[1] - left[1])
    extent[2] = 0
    request.extent(extent)
    start = [8, 8, 8]
    end = [4, 4, 4]
    request.setStrides(start, end)
    matrix = translationMatrix(
        (left[0] + right[0]) / 2.0,
        (left[1] + right[1]) / 2.0,
        (left[2] + right[2]) / 2.0,
    )
    request.transformation(matrix)

    # Create Color Producer
    extractor1 = VisusAxisAlignedExtractor.construct()
    extractor1.setValue(color)

    # Create Height Producer
    extractor2 = VisusAxisAlignedExtractor.construct()
    extractor2.setValue(height)

    # Create Consumer
    hf = VisusHeightField.construct()
    hf.attachSubTree(extractor1)
    hf.attachSubTree(extractor2)
    parent.attachSubTree(hf)

    # Set Data Request
    hf.setValue(request)
    extractor1.inherit(VisusSharedDataRequest.typeIndex(), True)
    extractor2.inherit(VisusSharedDataRequest.typeIndex(), True)
    hf.inherit(VisusSharedBoundingBox.typeIndex(), True)

    # Connect Inputs
    if not hf.connectColor(extractor1):
        raise RuntimeError("unable to connect extractor as color input")

    if not hf.connectHeight(extractor2):
        raise RuntimeError("unable to connect extractor as height input")

    gFocus = hf

    gValues.extend([hf, extractor1, extractor2])

    return hf
Exemple #6
0
    glutInitWindowSize(winWidth, winHeight)
    glutInitWindowPosition(200, 200)

    window = glutCreateWindow("ViSUS Height Field Test")

    glutDisplayFunc(display)
    glutReshapeFunc(reshape)
    glutMouseFunc(mouse)
    glutKeyboardFunc(keyboard)
    glutMotionFunc(motion)
    glutIdleFunc(idle)

    data = createData(func1, 0)
    gSamples = data.samples()

    left = VectorDouble(3)
    right = VectorDouble(3)
    data.domainBoundingBox(left, right)

    gBBox = VisusBoundingBox()
    gBBox.set(left, right)

    createData(func2, 1)

    box = constructWorldBox(gBBox)

    # Create the default scene graph
    #gRoot = VisusSceneNode.construct()
    gRoot = VisusGroup.construct()
    if not gRoot.setValue(gBBox):
        print "Error occurred setting bbox"