//
// VisADGeometryArray.java
//

/*
VisAD system for interactive analysis and visualization of numerical
data.  Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package visad;

import java.util.*;

/**
   VisADGeometryArray stands in for j3d.GeometryArray
   and is Serializable.

*/ public abstract class VisADGeometryArray extends VisADSceneGraphObject implements Cloneable { public int vertexCount; public int vertexFormat; public float[] coordinates; public float[] normals; public byte[] colors; public float[] texCoords; // stuff for longitude boolean any_longitude_rotate = false; int longitude_axis = -1; ScalarMap longitude_map = null; CoordinateSystem longitude_cs = null; float[][] longitude_coords = null; public VisADGeometryArray() { vertexCount = 0; vertexFormat = 0; coordinates = null; normals = null; colors = null; texCoords = null; } /** eliminate any vectors or triangles crossing seams of map projections, defined by display-side CoordinateSystems; this default implementation does nothing */ public VisADGeometryArray adjustSeam(DataRenderer renderer) throws VisADException { CoordinateSystem coord_sys = renderer.getDisplayCoordinateSystem(); // WLH 13 March 2000 // if (coord_sys == null) return this; if (coord_sys == null || coord_sys instanceof SphericalCoordinateSystem) { return this; } return this; } /** like adjustLongitude, but rather than splitting vectors or triangles, keep the VisADGeometryArray intact but possibly move it in longitude (try to keep its centroid on the "main" side of the seam) */ public VisADGeometryArray adjustLongitudeBulk(DataRenderer renderer) throws VisADException { float[] lons = getLongitudes(renderer, true); // bulk = true return this; } /** split any vectors or triangles crossing crossing longitude seams when Longitude is mapped to a Cartesian display axis; default implementation: rotate if necessary, then return points */ public VisADGeometryArray adjustLongitude(DataRenderer renderer) throws VisADException { float[] lons = getLongitudes(renderer); if (any_longitude_rotate) { // some coordinates changed, so return VisADPointArray VisADPointArray array = new VisADPointArray(); array.vertexCount = vertexCount; array.coordinates = coordinates; array.colors = colors; return array; } else { return this; } } static float rotateOneLongitude(float lon, float base) { if (lon == lon) { float x = (lon - base) % 360.0f; return (x + ((x < 0.0f) ? (360.0f + base) : base)); } else { return lon; } } void rotateLongitudes(float[] lons, float base, boolean bulk) throws VisADException { boolean any = false; // so rotate longitudes to base if (bulk) { float mean_lon = 0.0f; int n = 0; for (int i=0; i

Ads help maintain this website.