X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



2952 Rate this article:
No rating

IDLgrVolume - cube example

A volume object represents a mapping from a three-dimensional array of data to a three-dimensional array of voxel colors, which, when drawn, are projected to two dimensions. 

You can use the IDLgrVolume object, which is an atomic graphic object and one of the basic drawable elements of the IDL Object Graphics system, to create volumes.  Below is a code example on how to create a cubic volume and manipulate the portions of the cube that are and are not seen.
 

pro obj_volume

  data = BYTARR(64, 64, 64)
 
  for ii = 0B, 63 do begin
    data[*, ii, *] = ii*20B
  endfor
  zeroIndex = WHERE(data EQ 0, count)
  IF (count NE 0) THEN data[zeroIndex]=255B
 
  MasterData = data
  data[31:63, 32:63, 32:63]=0
 
  LOADCT, 5
  TVLCT, r, g, b, /get
  ctable = bytarr(256, 3)
  ctable[*, 0] = r
  ctable[*, 1] = g
  ctable[*, 2] = b
 
  opacTbl = bytarr(256) + 255B
  opacTbl[0] = 0
 
  ;create volume object
  oVol = obj_new("IDLgrVolume", data, $
    DEPTH_CUE=[-.5, 1], $
    RGB_TABLE0=ctable, $
    OPACITY_TABLE0 = opacTbl, $
    /ZERO_OPACITY_SKIP)
   
  oVol -> GetProperty, XRANGE=xr, YRANGE=yr, ZRANGE=zr
  oVol -> SetProperty, xcoord_conv = [ -.5, 1/(xr[1]-xr[0]) ], $
    ycoord_conv = [ -.5, 1/(yr[1]-yr[0]) ], $
    zcoord_conv = [ -.5, 1/(zr[1]-zr[0]) ]
   
  ; Create a model for the sphere.
  oModel = OBJ_NEW('IDLgrModel')
  ; Create a view in which to place the model.
  ;
  oView = OBJ_NEW('IDLgrView', VIEWPLANE_RECT = [-1,-1,2,2], $
    Location = [-1, -1], ZCLIP = [1,-1])
   
  oModel->Add, oVol
  oView->Add, oModel
 
  oWindow = OBJ_NEW('IDLgrWindow', DIMENSIONS = [300,300], $
    TITLE = 'Volume Example', renderer = 0);, RETAIN = 2)
  ; Render the volume with various cutting planes.
  ;
  ; None.
  ;
  oModel->Rotate, [0,1,0], -30
  oModel->Rotate, [1,0,0], 20
  oWindow->Draw, oView
  WAIT, 1
 
  data = MasterData
  data[31:63, 0:31, 32:63]=0
 
  oVol-> SetProperty, data0 = data
  oWindow->draw, oView
  wait, 1
 
  data = MasterData
  data[15:45, 32:63, 32:63]=0
 
  oVol-> SetProperty, data0 = data
  oWindow->draw, oView
  wait, 1
 
  data = MasterData
  data[15:45, 32:63, 15:63]=0
  data[15:63, 32:63, 15:45]=0
  oVol-> SetProperty, data0 = data
  oWindow->draw, oView
 
end

The resulting volume should look like the following:

Review on 12/31/2013 MM

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »