comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » IDLgrPolygon Leak?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDLgrPolygon Leak? [message #70009] Wed, 03 March 2010 11:24 Go to next message
KRDean is currently offline  KRDean
Messages: 69
Registered: July 2006
Member
Not a memory leak, but a polygon leak.

The 2010 IDL User Group meeting got me inspired to work with some
object graphics mapping.

However, I am running into some problems with adding a Shapefile to a
object graphics window. When I call the IDLgrPOLYGON to draw and fill
the shapefile vertices, there seems to be a leak or overflowing the
polygon.

Any thoughts on why. Sample code below. The IDLgrPOLYGON is set to
work with vertices that only have one part. Anything else, the
IDLgrPOLYLINE is used.

Kelly Dean
Fort Collins, CO

=============== Test_PolyShp ===============

;+
;
; <P>Prepare Shapefile Entities for object model.
;
;----------------------------------------------------------- -----------
PRO CountryModel, oModelSHP

COMPILE_OPT DEFINT32, STRICTARR

shpFile = FILEPATH( Subdirectory=['resource', 'maps', 'shape'],
'cntry02.shp' )
oSHP = OBJ_NEW( 'IDLffShape', shpFile )
IF ( OBJ_VALID( oSHP ) ) THEN BEGIN
oModelSHP = OBJ_NEW( 'IDLgrModel' )
oSHP -> GetProperty, N_ENTITIES = num_ent
FOR entn = 0, num_ent-1 DO BEGIN
ent = oSHP -> GetEntity( entn )
IF ( ent.n_parts GE 2 ) THEN BEGIN
cuts = [ (*ent.parts), ent.n_vertices ]
FOR partn = 0, ent.N_parts-1 DO BEGIN
; oGon = OBJ_NEW('IDLgrPolygon', (*ent.vertices)[*,
cuts[partn]:cuts[partn+1]-1] )
oGon = OBJ_NEW('IDLgrPolyline', (*ent.vertices)[*,
cuts[partn]:cuts[partn+1]-1] )
oGon -> SetProperty, COLOR = [ 034, 139, 87 ] ; Forest Green
oModelSHP -> ADD, oGon
ENDFOR
ENDIF ELSE IF ( ent.n_parts EQ 1 ) THEN BEGIN
oGon = OBJ_NEW('IDLgrPolygon', (*ent.vertices) )
oModelSHP -> ADD, oGon
ENDIF ELSE BEGIN
ENDELSE
oSHP -> DestroyEntity, ent
ENDFOR
OBJ_DESTROY, oSHP
ENDIF ELSE BEGIN
ENDELSE

END
;+
;
;
;----------------------------------------------------------- -----------
PRO Test_PolyShp

COMPILE_OPT DEFINT32, STRICTARR

CountryModel, oModelCntry
XOBJVIEW, oModelCntry

;WARNING: Big time memory leak
;Do IDL> HEAP_GC, /Verbose

END
Re: IDLgrPolygon Leak? [message #70054 is a reply to message #70009] Fri, 05 March 2010 21:37 Go to previous message
KRDean is currently offline  KRDean
Messages: 69
Registered: July 2006
Member
Thanks again Karl.

IDLgrTessellator solved my 'holes' issue. I reposted the code
using the Tessellator object to help with drawing the Shapefile
polygons. Also, taking David's suggestion, which removed the
memory leak.

Kelly Dean
Fort Collins, CO

=============================Test_PolyShp.pro
===========================

;+
;
; <P>Prepare Shapefile Entities for object model.
;
;----------------------------------------------------------- -----------
PRO CountryModel, oModelSHP

COMPILE_OPT DEFINT32, STRICTARR

shpFile = FILEPATH( Subdirectory=['resource', 'maps', 'shape'],
'cntry02.shp' )
oSHP = OBJ_NEW( 'IDLffShape', shpFile )
IF ( OBJ_VALID( oSHP ) ) THEN BEGIN
oModelSHP = OBJ_NEW( 'IDLgrModel' )
oSHP -> GetProperty, N_ENTITIES = num_ent
FOR entn = 0, num_ent-1 DO BEGIN
ent = oSHP -> GetEntity( entn )
IF ( ent.n_parts GE 2 ) THEN BEGIN
cuts = [ (*ent.parts), ent.n_vertices ]
FOR partn = 0, ent.N_parts-1 DO BEGIN
oGon = OBJ_NEW('IDLgrPolygon' )
oTess = OBJ_NEW('IDLgrTessellator')
oTess -> AddPolygon, (*ent.vertices)[*, cuts[partn]:cuts[partn
+1]-1]
iStatus = oTess -> tessellate(fVerts,iConn)
IF (iStatus EQ 1) THEN BEGIN
oGon -> SetProperty, DATA = fVerts, POLYGONS = iConn
oGon -> SetProperty, COLOR = [ 034, 139, 87 ] ; Forest
Green
oModelSHP -> ADD, oGon
ENDIF ELSE BEGIN
STOP
ENDELSE
ENDFOR
ENDIF ELSE IF ( ent.n_parts EQ 1 ) THEN BEGIN
oGon = OBJ_NEW('IDLgrPolygon' )
oTess = OBJ_NEW('IDLgrTessellator')
oTess -> AddPolygon, (*ent.vertices)
iStatus = oTess -> tessellate(fVerts,iConn)
IF (iStatus EQ 1) THEN BEGIN
oGon -> SetProperty, DATA = fVerts, POLYGONS = iConn
oModelSHP -> ADD, oGon
ENDIF ELSE BEGIN
STOP
ENDELSE
OBJ_DESTROY, oTess
ENDIF ELSE BEGIN
ENDELSE
oSHP -> DestroyEntity, ent
ENDFOR
OBJ_DESTROY, oSHP
ENDIF ELSE BEGIN
ENDELSE
END
;+
;
;
;----------------------------------------------------------- -----------
PRO Test_PolyShp
COMPILE_OPT DEFINT32, STRICTARR
CountryModel, oModelCntry
XOBJVIEW, oModelCntry, /BLOCK
Obj_Destroy, oModelCntry
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Blogging the IDL User's Group Meeting
Next Topic: percent disagreement

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 02:41:25 PDT 2025

Total time taken to generate the page: 0.00806 seconds