pro testPolyhedron ;give the cube a non zero center offset = -2 ;build a cube verts = [[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]] - 0.5 + offset connectivity = [4,3,0,4,7,$ 4,0,1,5,4,$ 4,4,5,6,7,$ 4,1,2,6,5,$ 4,2,3,7,6,$ 4,3,2,1,0] ;random points num = 100 x = (randomu(seed,num)-0.5)*2 + offset y = (randomu(seed,num)-0.5)*2 + offset z = (randomu(seed,num)-0.5)*2 + offset ;get the indices of the points inside indices = pointInsideApolyhedron(verts, connectivity, transpose([[x],[y],[z]])) ;display them oCube = obj_new('IDLgrPolygon',verts, poly= connectivity, color=[0,0,0], style=1) oModel = obj_new('IDLgrModel') oModel->add, oCube xobjview, oModel for i=0,n_elements(x)-1 do begin void = where( i eq indices, count) if count eq 0 then color=[255,0,0] else color=[0,255,0] oSym = obj_new('IDlgrSymbol',1, size=0.1, color=color) op = obj_new('idlgrpolyline',[x[i],x[i]],[y[i],y[i]],[z[i],z[i]],sym=osym);, hide=(Q lt 0)) oModel-> add, op endfor return & end