[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Repeats and Triangulation



Hello all,

Just when I thought I had a handle on making polyline
descriptors (for the IDLgrPolyLine object) I bumped into
something tricky and over my head.

The short routine below will triangulate a small set of
points and then display the Delaunay triangulation
graphically (a direct graphics plot and an xObjView display
of an IDLgrPolyline.)  The routine can be called with the
keepReps keyword set which will introduce two extra points
in the data set (each of which repeats an exsiting point.)
Call the routine without the keyword to see how it is
supposed to behave. Then try it with the keepReps keyword
set... and it will fall apart.  The value of REPEATS is
printed each time it is called.

The REPEATS keyword to TRIANGULATION returns a 2,n element
array of pairs indices of repeated values.  If no values are
repeated then REPEATS = [-1,-1].  My question is 'How do I
pull out the repeated values efficiently?'

Thanks,

Ben

;--------START
PRO Test, keepReps = keepReps

 ;make x and y
if keyword_set(keepReps)  then begin
 x = [2,5,2,2,2,4,9]
 y = [1,3,5,5,5,5,8]
endif else begin
 x = [2,5,2,4,9]
 y = [1,3,5,5,8]
endelse
 ;make a z value
z = (x-y)^2

 ; triangulate
triangulate, x, y, tr, b, connectivity = conn, repeats = rep



 ;show the results as a bird's eye view
 ;as shown in online help
plot, x,y,psym = 6
 ; Show the triangles:
for i=0, n_elements(tr)/3-1 do begin
   t = [tr[*,i], tr[0,i]]
   plots, x[t], y[t] , linestyle = 2
endfor

 ;make the polygon descriptor (see IDLgrPolyLine)
List = Conn[Conn[0]:Conn[1]-1L]
Ptr = Ptr_NEW([N_elements(List),List])
For  i = 1, n_elements(X) -1 DO Begin
 List = Conn[conn[i]:Conn[i+1]-1]
 *Ptr = [*Ptr, n_elements(List), List]
EndFor

Poly = *Ptr & Ptr_Free,Ptr

poly1 = obj_new('idlgrpolyline', x,y,z, polylines = poly)

xobjview, poly1,/modal

if obj_valid(poly1) then obj_destroy, poly1
End
;--------FINISH
--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539

Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net