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

Home » Public Forums » archive » IDLgrPolygon question
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 question [message #89893] Thu, 18 December 2014 05:25 Go to next message
natha is currently offline  natha
Messages: 482
Registered: October 2007
Senior Member
Hi guys,

I am wondering if it is possible to create the following image with ONLY 1 instance of an IDLgrPolygon and without repeating vertices...
http://pdroms.de/wp-content/uploads/2012/04/ColorSquares.png

Create the polygons and their connectivity it's not difficult. What I don't see is how to associate different colors to each square.
I don't know how the VERT_COLORS property would work since almost all vertices are shared between different polygons.

Thank you for your help in advance,
Bernat
Re: IDLgrPolygon question [message #89896 is a reply to message #89893] Thu, 18 December 2014 22:56 Go to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
nata wrote, On 2014-12-18, 5:25am:
> Hi guys,
>
> I am wondering if it is possible to create the following image with ONLY 1 instance of an IDLgrPolygon and without repeating vertices...
> http://pdroms.de/wp-content/uploads/2012/04/ColorSquares.png
>
> Create the polygons and their connectivity it's not difficult. What I don't see is how to associate different colors to each square.
> I don't know how the VERT_COLORS property would work since almost all vertices are shared between different polygons.
>
> Thank you for your help in advance,
> Bernat

Hi Bernat,

First point to make: IDLgrPolygon (and IDLgrSurface) can give you the colored quadrilaterals (quads) with Style=2, but
if you need the black lines, you need a second "grid" object, rendered slightly in front of the colored object. I'll
show you how.

If you're OK with IDLgrSurface, it's very easy: each quad takes color of its lower-left vertex.
If you need IDLgrPolygon, each quad takes color of lower-left vertex. (this makes some colored triangle meshes
impossible, but for this it will work out fine)

Compile and run this program to see both ways of doing this. I hope my comments here give a good enough explanation:


=====

PRO SurfaceAndPolygonVertColorsTest

;; Set up the colors for the blocks

blockDims = [16, 14] ; [nCols, nRows]
blockColors = BytScl(RandomU(seed, [3, blockDims])) ; [3, nCols, nRows] RGB

;; Set up the colors for the vertices (with an extra row and column of
;; colors that will be ignored)

vertDims = blockDims + [1, 1]
vertColors = BytArr([3, vertDims]) ; Make array with extra "row" and "column"
vertColors[0, 0, 0] = blockColors ; Lay blockColors into vertColors
vertColors = Reform(vertColors, [3, Product(vertDims)], /OVERWRITE)

;; Make string for title to confirm lower-left and upper-right block colors

colorStr = String(Format='(" LL=[",I0,",",I0,",",I0,"] '+ $
'UR=[",I0,",",I0,",",I0,"]")', $
blockColors[*,0,0], blockColors[*,-1,-1])

;; With IDLgrSurface, each quad takes color of lower-left vertex

oSurface = IDLgrSurface(FltArr(vertDims), Style=2, VERT_COLORS=vertColors, $
DEPTH_OFFSET=1)
oSurfaceGrid = IDLgrSurface(FltArr(vertDims), Style=1, $
DEPTH_OFFSET=0)
XObjView, [oSurface, oSurfaceGrid], Title='IDLgrSurface'+colorStr, $
STATIONARY=Obj_New('IDLgrLight') ; A "null light" to display pure colors

;; With IDLgrPolygon, each quad takes color of first vertex (Mesh_Obj lists
;; lower-left vertex first)

Mesh_Obj, 1, verts, conn, FltArr(vertDims)
oPolygon = IDLgrPolygon(verts, Polygons=conn, Style=2, VERT_COLORS=vertColors,$
DEPTH_OFFSET=1)
oPolygonGrid = IDLgrPolygon(verts, Polygons=conn, Style=1,$
DEPTH_OFFSET=0)
XObjView, [oPolygon, oPolygonGrid], Title='IDLgrPolygon'+colorStr, $
STATIONARY=Obj_New('IDLgrLight'), $ ; A "null light" to display pure colors
XOFFSET=420

END

=====


Cheers,
-Dick

Dick Jackson Software Consulting Inc.
Victoria, BC, Canada
www.d-jackson.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: quirk End of file encountered before end of program
Next Topic: Daily to monthly

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

Current Time: Wed Oct 08 09:15:29 PDT 2025

Total time taken to generate the page: 0.00366 seconds