예제 #1
0
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
예제 #2
0
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
예제 #3
0
def createData(func,idx):
  global gDataSet, adata, gCenter, gMinValue, gMaxValue

  import numpy
  from pyvisus.numpyconversion import VisusIncoreEncoder

  print "Create data for idx(%d)" % idx

  dimi = 50
  dimj = 50
  dimk = 50

  gCenter[0] = 0.5 * (dimi-1)
  gCenter[1] = 0.5 * (dimj-1)
  gCenter[2] = 0.5 * (dimk-1)

  data = []
  for i in xrange(dimi*dimj*dimk):
    data.append(0)

  for i in xrange(dimi):
    for j in xrange(dimj):
      for k in xrange(dimk):
        value = func(i,j,k)
        data[k + j*dimk + i*dimk*dimj] = value

	if idx == COLOR_NDX:
          if value < gMinValue:
            gMinValue = value
          if value > gMaxValue:
            gMaxValue = value

  adata[idx] = numpy.array(data)

  encoder = VisusIncoreEncoder(dimi,dimj,dimk,1)
  encoder.domain([0,0,0],[dimk,dimj,dimi])
  encoder.field(adata[idx], "density")
  gDataSet[idx] = str(encoder) 
    
  # Make the data source
  print "Opening dataset(%s)" % gDataSet[idx]
  data =  VisusDataSourceFactory.make(gDataSet[idx]); 
  if not data.isValid():
    raise RuntimeError("Loaded data is not valid")

  return data
예제 #4
0
def createData(func, idx):
    global gDataSet, adata, gCenter, gMinValue, gMaxValue

    import numpy
    from pyvisus.numpyconversion import VisusIncoreEncoder

    print "Create data for idx(%d)" % idx

    dimi = 50
    dimj = 50
    dimk = 50

    gCenter[0] = 0.5 * (dimi - 1)
    gCenter[1] = 0.5 * (dimj - 1)
    gCenter[2] = 0.5 * (dimk - 1)

    data = []
    for i in xrange(dimi * dimj * dimk):
        data.append(0)

    for i in xrange(dimi):
        for j in xrange(dimj):
            for k in xrange(dimk):
                value = func(i, j, k)
                data[k + j * dimk + i * dimk * dimj] = value

                if idx == COLOR_NDX:
                    if value < gMinValue:
                        gMinValue = value
                    if value > gMaxValue:
                        gMaxValue = value

    adata[idx] = numpy.array(data)

    encoder = VisusIncoreEncoder(dimi, dimj, dimk, 1)
    encoder.domain([0, 0, 0], [dimk, dimj, dimi])
    encoder.field(adata[idx], "density")
    gDataSet[idx] = str(encoder)

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

    return data
예제 #5
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
예제 #6
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
예제 #7
0
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
예제 #8
0
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
예제 #9
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
예제 #10
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
예제 #11
0
def addIsoSurface(parent):
    global gDataSet, gFocus, gValues, gMinValue, gMaxValue

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

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

    print "right:", right[0], right[1], right[2]
    print "left: ", left[0], left[1], left[2]

    # 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])
    print "extent: ", extent[0], extent[1], extent[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
    extractorIso = VisusAxisAlignedExtractor.construct()
    extractorIso.setValue(gDataSet[ISO_NDX])

    extractorColor = VisusAxisAlignedExtractor.construct()
    extractorColor.setValue(gDataSet[COLOR_NDX])

    # Create Consumer
    iso = VisusColoredIsoSurface.construct()

    # Create Display
    display = VisusMeshDisplay.construct()
    display.normalIndex(3)
    display.colorIndex(6)
    display.minValue(gMinValue)
    display.maxValue(gMaxValue)
    display.setValue(gColorMap)

    # Attach To Tree
    parent.attachSubTree(iso)
    iso.attachSubTree(extractorIso)
    iso.attachSubTree(extractorColor)
    iso.attachSubTree(display)

    # Connect Request
    # extractorIso.inherit(VisusSharedDataRequest.typeIndex(),True)
    # extractorColor.inherit(VisusSharedDataRequest.typeIndex(),True)
    extractorColor.setValue(request)
    extractorIso.setValue(request)

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

    if not iso.connectColor(extractorColor):
        raise RuntimeError("unable to connect extractor as color input")

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

    gFocus = iso
    gFocus.drawBoundingBox(True)

    gValues.extend([iso, extractorIso, extractorColor])

    return iso
예제 #12
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 
예제 #13
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