Re: filled triangles

Hi Bill,

I meant,

float theColor=3.0f*(float)Math.random();
java.util.Arrays.fill(colors[0],j*4,(j+1)*4-1,theColor);

behaves differently from:

float theColor=3.0f*(float)Math.random();
for (int i = j*4; i < (j+1)*4; i++) colors[0][i]=theColor;

Cheers,
  Ricardo

Ricardo Mantilla wrote:
Hi Bill,

I wanted to close this thread letting you know that I found that the strategy that you suggested of creating the FlatField was correct from the beginning.
For some reason the line of code:

float theColor=3.0f*(float)Math.random();
java.util.Arrays.fill(colors[0],j*4,(j+1)*4-1,2.0f);

behaves differently from:

float theColor=3.0f*(float)Math.random();
for (int i = j*4; i < (j+1)*4; i++) colors[0][i]=theColor;

in a loop of j. This was causing the colors array to end up with some 0's.

This is probably a Java1.5 on Mac OS X issue, completely unrelated to VisAD.

Cheers,
   Ricardo

Bill Hibbard wrote:
Hi Ricardo,

To get solid color triangles, all vertices of a triangle must have the
same color. To achieve this, it may be necessary that each
Irregular2Dset in the UnionSet consist of a single triangle (so that
no triangles share any vertices).

Good luck,
Bill

    ----- Original Message -----
    From: "Ricardo Mantilla"
    To: "Bill Hibbard"
    Subject: Re: filled triangles
    Date: Thu, 08 Mar 2007 21:54:41 -0700


    Hi Bill,

    Thanks for your suggestion, however I am getting a some color
    gradients on my graph (attached) rather than flat colors inside the
    triangles. It may be due to how I am setting up the FlatField. In
    the code that follows "regions" is an Irregular2DSet[] array, and
    "colors" is a float[] array with as many positions as points in all
    the Irregular2DSet.

    CODE FOLLOWS +++++++++++++++++++

    RealType xEasting =RealType.getRealType("xEasting"),
    yNorthing=RealType.getRealType("yNorthing"),
    tileColor=RealType.getRealType("tileColor");

    RealTupleType domainXLYL=new RealTupleType(new RealType[]
    {xEasting,yNorthing});

    FunctionType func_xEasting_yNorthing_to_Color=new
    FunctionType(domainXLYL,tileColor);

    UnionSet allRegions=new UnionSet(domainXLYL,regions);

    FlatField theColors=new
    FlatField(func_xEasting_yNorthing_to_Color,allRegions);
    theColors.setSamples(colors);

    DataReference region_ref = new DataReferenceImpl("region");
    region_ref.setData(theColors);

    display_TIN.addReference(region_ref);

    CODE ENDS +++++++++++++++++++

    What am I doing wrong?

    Thanks,
    Ricardo



    Bill Hibbard wrote:
    > Hi Ricardo,
    >
    > I am using VisAD to display a bunch of filled triangles (as shown
    > in attachment). Since each triangle is supposed to be a different
    > color my approach was to create an irregular2DSet for each one
    > (using Delaunay.fill()) and then create a reference for each one
    > with an associated constant map (describing Red, Green, Blue).
    >
    > However, this is awfully slow when I have hundreds of triangles. I
    > was looking for something like creating an unionSet with the
    > irregular2DSets with each irregular2DSet having a property
    > associated to the color but I couldn't find a way to to it.
    >
    >
    > Construct a FlatField with MathType ((x, y) -> (r, g, b)) and
    use the
    > UnionSet as the domain Set of the FlatField. Then you have
    ScalarMaps
    > of the Field range values to Red, Green and Blue, and fill the
    triangle
    > vertex colors into those range values.
    >
    > Good luck,
    > Bill
    >
    >
    > --
    >

    -- -------------------------------------------------------------
    Ricardo Mantilla
    Posdoctoral Research Associate

    Department of Earth and Environmental Science
    New Mexico Institute of Mining and Technology
    801 Leroy Pl. MSEC 254
    Socorro, NM 87801

    Phone: (505) 835-5068
    Office: MSEC 254
    http://cires.colorado.edu/~ricardo/
    -------------------------------------------------------------
    << triangles2.png >>


--

<http://a8-asy.a8ww.net/a8-ads/adftrclick?redirectid=en-mail_a_01>



--
-------------------------------------------------------------
Ricardo Mantilla
Posdoctoral Research Associate

Department of Earth and Environmental Science
New Mexico Institute of Mining and Technology
801 Leroy Pl. MSEC 254
Socorro, NM 87801

Phone: (505) 835-5068
Office: MSEC 254
http://cires.colorado.edu/~ricardo/
-------------------------------------------------------------

==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


  • 2007 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: