pro testPolygons device, decomposed=0 loadct,0 tek_color seed = 123 numGrid = 11 gridX = (findgen(numGrid)) # (fltarr(numGrid)+1) gridY = (findgen(numGrid)) ## (fltarr(numGrid)+1 ) window,0,xsize=800,ysize=500 plot, gridX, gridY, psym=1, /nodata for i=0, n_elements(gridX)-1 do begin repeat begin x = randomu(seed,10)/2 + gridX[i] y = randomu(seed,10)/2 + gridY[i] triangulate, x,y, triangles,b ;b = [b,b[0]] endrep until n_elements(b) eq 4 ;oplot, x, y, psym=1,color=3 ind = [b,b[0]] oplot, x[ind],y[ind],color=2 if i eq 0 then begin allX = x[b] allY = y[b] connectivity = indgen(n_elements(b)) next = n_elements(b) endif else begin allX = [allX,x[b]] allY = [allY,y[b]] connectivity = [[connectivity],[indgen(n_elements(b))+next]] next = next + n_elements(b) endelse endfor ;10201 points gridX = reform((findgen(101)/10) # (fltarr(101)+1), 101*101) gridY = reform((findgen(101)/10) ## (fltarr(101)+1 ),101*101) oplot, gridX, gridY, psym=3 data = transpose([[gridX],[gridY]]) validPointIndices = pointInsideApolygon(allX,allY,connectivity, data, count=count) x = gridX[validPointIndices] y = gridY[validPointIndices] plots, x,y, psym=3,color=2 return & end