//
// ShadowTextureFillSetTypeJ3D.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.bom;

import visad.*;
import visad.java3d.*;

import javax.media.j3d.*;

import java.util.Vector;
import java.util.Enumeration;
import java.rmi.*;

import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.awt.image.DataBufferInt;

/**
   The ShadowTextureFillSetTypeJ3D class shadows the FunctionType class for
   TextureFillRendererJ3D, within a DataDisplayLink, under Java3D.

*/ public class ShadowTextureFillSetTypeJ3D extends ShadowSetTypeJ3D { private static final int MISSING1 = Byte.MIN_VALUE; // least byte private DisplayImplJ3D display = null; public ShadowTextureFillSetTypeJ3D(MathType t, DataDisplayLink link, ShadowType parent) throws VisADException, RemoteException { super(t, link, parent); display = (DisplayImplJ3D) link.getDisplay(); } // transform data into a depiction under group public boolean doTransform(Object group, Data data, float[] value_array, float[] default_values, DataRenderer renderer) throws VisADException, RemoteException { DataDisplayLink link = renderer.getLink(); // System.out.println("start doTransform " + (System.currentTimeMillis() - link.start_time)); // return if data is missing or no ScalarMaps if (data.isMissing()) { ((ImageRendererJ3D) renderer).markMissingVisADBranch(); return false; } if (getLevelOfDifficulty() == NOTHING_MAPPED) return false; ShadowFunctionOrSetType adaptedShadowType = (ShadowFunctionOrSetType) getAdaptedShadowType(); DisplayImpl display = getDisplay(); GraphicsModeControl mode = (GraphicsModeControl) display.getGraphicsModeControl().clone(); // get 'shape' flags boolean anyContour = adaptedShadowType.getAnyContour(); boolean anyFlow = adaptedShadowType.getAnyFlow(); boolean anyShape = adaptedShadowType.getAnyShape(); boolean anyText = adaptedShadowType.getAnyText(); if (anyContour || anyFlow || anyShape || anyText) { throw new BadMappingException("no contour, flow, shape or text allowed"); } // get some precomputed values useful for transform // length of ValueArray int valueArrayLength = display.getValueArrayLength(); // mapping from ValueArray to DisplayScalar int[] valueToScalar = display.getValueToScalar(); // mapping from ValueArray to MapVector int[] valueToMap = display.getValueToMap(); Vector MapVector = display.getMapVector(); // array to hold values for various mappings float[][] display_values = new float[valueArrayLength][]; int[] inherited_values = adaptedShadowType.getInheritedValues(); for (int i=0; i 0) { display_values[i] = new float[1]; display_values[i][0] = value_array[i]; } } // analyze data's domain (its a Field) Set domain_set = (Set) data; Unit[] dataUnits = domain_set.getSetUnits(); CoordinateSystem dataCoordinateSystem = domain_set.getCoordinateSystem(); float[][] domain_values = null; double[][] domain_doubles = null; ShadowRealTupleType Domain = adaptedShadowType.getDomain(); Unit[] domain_units = ((RealTupleType) Domain.getType()).getDefaultUnits(); int domain_length; int domain_dimension; try { domain_length = domain_set.getLength(); domain_dimension = domain_set.getDimension(); } catch (SetException e) { return false; } // ShadowRealTypes of Domain ShadowRealType[] DomainComponents = adaptedShadowType.getDomainComponents(); if (!adaptedShadowType.getIsTerminal()) { throw new DisplayException("not Terminal"); } // check domain and determine whether it is square or curved texture if (!Domain.getAllSpatial() || Domain.getMultipleDisplayScalar()) { throw new BadMappingException("domain must be only spatial"); } // get and process domain values float[][] spline_domain = domain_set.getSamples(); spline_domain = Unit.convertTuple(spline_domain, dataUnits, domain_units, false); // transform for any CoordinateSystem in data (Field) Domain ShadowRealTupleType domain_reference = Domain.getReference(); ShadowRealType[] DC = DomainComponents; if (domain_reference != null && domain_reference.getMappedDisplayScalar()) { RealTupleType ref = (RealTupleType) domain_reference.getType(); renderer.setEarthSpatialData(Domain, domain_reference, ref, ref.getDefaultUnits(), (RealTupleType) Domain.getType(), new CoordinateSystem[] {dataCoordinateSystem}, domain_units); spline_domain = CoordinateSystem.transformCoordinates( ref, null, ref.getDefaultUnits(), null, (RealTupleType) Domain.getType(), dataCoordinateSystem, domain_units, null, spline_domain); // ShadowRealTypes of DomainReference DC = adaptedShadowType.getDomainReferenceComponents(); } else { RealTupleType ref = (domain_reference == null) ? null : (RealTupleType) domain_reference.getType(); Unit[] ref_units = (ref == null) ? null : ref.getDefaultUnits(); renderer.setEarthSpatialData(Domain, domain_reference, ref, ref_units, (RealTupleType) Domain.getType(), new CoordinateSystem[] {dataCoordinateSystem}, domain_units); } int[] tuple_index = new int[3]; int[] spatial_value_indices = {-1, -1, -1}; ScalarMap[] spatial_maps = new ScalarMap[3]; DisplayTupleType spatial_tuple = null; for (int i=0; i 0 && real.equals(display.getDisplayScalar(valueToScalar[i])) ) { value2 = value_array[i]; break; } } float[][] spatial_values = new float[3][]; spatial_values[tuple_index[0]] = spline_domain[0]; spatial_values[tuple_index[1]] = spline_domain[1]; spatial_values[tuple_index[2]] = new float[domain_length]; for (int i=0; i

Ads help maintain this website.