Hmmm, I have some C++/PDL code that may help you here. It is a set of rendering primitives that operate directly on piddles, including filled polygons. You can use that to render a mask based on your mouse clicks.
I don't get your algorithm below. Why is the min bound rec in there at all? If that is what you want to get to, why do you need the polygon at all, as it's waaaay easier to just keep track of the bounds of the mouse clicks. I suspect you don't really want anything to do with the bbox at all, in which case the polygons are a good idea... Anyway, I'll send you a load of mapping code tomorrow morning. I'll let you pick out the rendering portion on your own, as it should be an educational exercise to see it's context and implementations. Also, the code here has nothing to do with the PDL::IO::GD rendering, which operates on gd objects, not piddles. What I'll send tomorrow is hugely faster, as well. -Judd On Sep 7, 2010, at 8:48 PM, "P Kishor" <[email protected]> wrote: > On Tue, Sep 7, 2010 at 8:39 PM, Craig DeForest > <[email protected]> wrote: >> I am on alert about local wildfires, so I will not type up a large >> discussion of hulls, but if you generate a selection mask image (zero >> outside the selection, one inside it) then the obvious thing to use is >> either "do_something_to($source->where($mask));" if you don't need to track >> the coordinates themselves, or "$dex = $mask->whichND; >> do_something_to($source->indexND($dex));" if you do. > > > Thanks Craig. I did see the where and which methods, but, I guess the > challenge here is to generate the selection mask in the first place. > Don't want to take your mind away form wildfires, but if you have any > suggestions on the path to explore for the selection itself given a > set of click coordinates, send them my way when you get a chance. > > Additionally, I also noticed the annotation in the docs that there is > no whereND. I will investigate this further and see if it affects me. > > Thanks for the suggestion. > >> >> >> >> On Sep 7, 2010, at 7:31 PM, P Kishor wrote: >> >>> Rectangular selections from 2D piddles are easy and fast with the >>> range operator. However, I would like to grab a non-rectangular >>> selection out of a piddle, setting all out-of-area-of-interest >>> elements to BAD. >>> >>> Background -- >>> >>> - The user clicks on a map and creates an irregular polygon >>> - I (somehow **) figure out the piddle elements, aka cells, that lie >>> within the drawn poly >>> - Out of the base piddle, I grab the tightest rect that contains the >>> cells within the drawn poly (the min. bounding box) >>> - Set all the cells outside the drawn poly to BAD so they don't figure >>> in the rest of the calculations >>> >>> I searched the docs, but the closest discussion I found was on >>> convex-hulls from June 2005 [1]. Suggestions? >>> >>> ** the reason I say "somehow" is because I can do a lookup using a >>> database to get the indices of the mouse-clicks, and the elements that >>> lie within the bounding rect, but I would prefer to do this without a >>> database. I am generally finding PDL to be substantively faster than a >>> database, and would like to stay out of a db as much as possible. I >>> initiated a discussion on this a while back, but that was restricted >>> to rectangular selects. >>> >>> [1] http://mailman.jach.hawaii.edu/pipermail/perldl/2005-June/000036.html >>> >>> -- >>> Puneet Kishor http://www.punkish.org >>> Carbon Model http://carbonmodel.org >>> Charter Member, Open Source Geospatial Foundation http://www.osgeo.org >>> Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor >>> Nelson Institute, UW-Madison http://www.nelson.wisc.edu >>> ----------------------------------------------------------------------- >>> Assertions are politics; backing up assertions with evidence is science >>> ======================================================================= >>> >>> _______________________________________________ >>> Perldl mailing list >>> [email protected] >>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >>> >> >> > > > > -- > Puneet Kishor http://www.punkish.org > Carbon Model http://carbonmodel.org > Charter Member, Open Source Geospatial Foundation http://www.osgeo.org > Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor > Nelson Institute, UW-Madison http://www.nelson.wisc.edu > ----------------------------------------------------------------------- > Assertions are politics; backing up assertions with evidence is science > ======================================================================= > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
