//
// VisADLineStripArray.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;
/**
VisADLineStripArray stands in for j3d.LineStripArray
and is Serializable.
*/
public class VisADLineStripArray extends VisADGeometryArray {
public int[] stripVertexCounts;
public static VisADLineStripArray merge(VisADLineStripArray[] arrays)
throws VisADException {
if (arrays == null || arrays.length == 0) return null;
VisADLineStripArray array = new VisADLineStripArray();
merge(arrays, array);
int n = arrays.length;
int nstrips = 0;
for (int i=0; i 0.0f) {
ratios[i] = cd / rd;
num_ratio++;
mean_ratio += ratios[i];
var_ratio += ratios[i] * ratios[i];
if (ratios[i] > max_ratio) max_ratio = ratios[i];
}
} // end for (int i=last_i; i limit_ratio);
} // end for (int i=last_i; i= 2) {
svcs[svc_index] = accum;
svc_index++;
}
accum = 0; // reset strip counter;
} // end if split
j += color_length;
} // end for (int i=last_i; i= 2) {
svcs[svc_index] = accum;
svc_index++;
}
last_i += stripVertexCounts[i_svc]*3;
} // end for (int i_svc=0; i_svc= 2) {
svcs[svc_index] = accum;
svc_index++;
}
accum = 0; // reset strip counter;
}
else { // lon_axis >= 0
// split line by interpolation
float a, b;
float coord_first, coord_second;
if (lons[i3] < low) {
a = lons[i3] - bottom;
b = top - lons[i3 + 1];
coord_first = coord_bottom;
coord_second = coord_top;
}
else {
a = top - lons[i3];
b = lons[i3 + 1] - bottom;
coord_first = coord_top;
coord_second = coord_bottom;
}
float alpha = b / (a + b);
alpha = (alpha != alpha || alpha < 0.0f) ? 0.0f :
((1.0f < alpha) ? 1.0f : alpha);
float beta = 1.0f - alpha;
// create first point of split;
coord = new float[]
{alpha * coordinates[i] + beta * coordinates[i+3],
alpha * coordinates[i+1] + beta * coordinates[i+4],
alpha * coordinates[i+2] + beta * coordinates[i+5]};
coord[lon_axis] = coord_first;
col = null;
if (color_length == 3) {
col = new byte[]
{ShadowType.floatToByte(
alpha * ShadowType.byteToFloat(colors[j]) +
beta * ShadowType.byteToFloat(colors[j+3])),
ShadowType.floatToByte(
alpha * ShadowType.byteToFloat(colors[j+1]) +
beta * ShadowType.byteToFloat(colors[j+4])),
ShadowType.floatToByte(
alpha * ShadowType.byteToFloat(colors[j+2]) +
beta * ShadowType.byteToFloat(colors[j+5]))};
}
else if (color_length == 4) {
col = new byte[]
{ShadowType.floatToByte(
alpha * ShadowType.byteToFloat(colors[j]) +
beta * ShadowType.byteToFloat(colors[j+4])),
ShadowType.floatToByte(
alpha * ShadowType.byteToFloat(colors[j+1]) +
beta * ShadowType.byteToFloat(colors[j+5])),
ShadowType.floatToByte(
alpha * ShadowType.byteToFloat(colors[j+2]) +
beta * ShadowType.byteToFloat(colors[j+6])),
ShadowType.floatToByte(
alpha * ShadowType.byteToFloat(colors[j+3]) +
beta * ShadowType.byteToFloat(colors[j+7]))};
}
accum++;
if (accum == 1) {
lastcoord = coord;
lastcol = col;
}
else {
nextPoint(accum, color_length, coords, cols, coord, col,
lastcoord, lastcol, km);
}
// break strip between first and second points
if (accum >= 2) {
svcs[svc_index] = accum;
svc_index++;
}
accum = 0; // reset strip counter;
// create second point of split, identical to first except:
coord[lon_axis] = coord_second;
accum++;
if (accum == 1) {
lastcoord = coord;
lastcol = col;
}
else {
nextPoint(accum, color_length, coords, cols, coord, col,
lastcoord, lastcol, km);
}
} // end if (lon_axis >= 0)
} // end if split
j += color_length;
} // end for (int i=last_i; i= 2) {
svcs[svc_index] = accum;
svc_index++;
}
last_i += stripVertexCounts[i_svc]*3;
} // end for (int i_svc=0; i_svc= 2) {
int iml = i;
int jml = j;
if (accum == 2) {
iml = i - 3;
jml = j - color_length;
}
int jm = jml;
for (int im=iml; im<=i; im+=3) {
coords[k] = coordinates[im];
coords[k+1] = coordinates[im+1];
coords[k+2] = coordinates[im+2];
if (colors != null) {
cols[m] = colors[jm];
cols[m+1] = colors[jm+1];
cols[m+2] = colors[jm+2];
m += 3;
if (color_length == 4) {
cols[m++] = colors[jm+3];
}
}
k += 3;
jm += color_length;
} // end for (im=iml; im<=i; im+=3)
} // end if (accum >= 2)
}
else { // missing coordinates values
any_missing = true;
if (accum >= 2) {
svcs[svc_index] = accum;
svc_index++;
}
accum = 0; // reset strip counter;
}
j += color_length;
} // end for (int i=last_i; i= 2) {
svcs[svc_index] = accum;
svc_index++;
}
last_i += stripVertexCounts[i_svc]*3;
} // end for (int i_svc=0; i_svc
Ads help maintain this website.