Here's a routine that might help you understand how to do what you
want. IDLffShape has a nasty gotcha that can trip people up : it only
defines the parts pointer if the polygon contains multiple contours.
So I usually handle that by checking the n_parts and if it is zero
then I set parts = [0]. That way I don't have to have a bunch of
nasty if (nparts eq 0) logic in my code.
pro printPoly, verts, partsPtr
nParts = N_Elements(partsPtr)
nVerts = N_Elements(verts[0,*])
for ndx=0L, nParts-1L do begin
sIdx = partsPtr[ndx]
eIdx = ( (ndx+1) gt nParts-1L) ? nVerts - 1L : partsPtr[ndx+1L]-1L
Print, '==============================='
Print, 'NDX: ', String(StrTrim(ndx, 2))
Print, 'VERTICES: ', verts[*,sIdx:eIdx]
endfor
end
pro testShape
filename = Dialog_Pickfile(TITLE='Pick the shapefile...')
oShape = Obj_New('IDLffShape', filename)
oShape->GetProperty, N_ENTITIES=nEnt
window, 1
for ndx=0L, nEnt-1L do begin
ent = oShape->GetEntity(ndx)
verts = *ent.vertices
parts = *ent.parts
nParts = ent.n_parts
if (nParts eq 0) then parts = [0]
printPoly, verts, parts
oShape->DestroyEntity, ent
endfor
Obj_Destroy, oShape
end


|