//
// ShadowFunctionOrSetTypeJ3D.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.java3d;

import visad.*;
import visad.util.ThreadManager;

import javax.media.j3d.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import java.rmi.*;

import java.awt.image.*;


/**
   The ShadowFunctionOrSetTypeJ3D is an abstract parent for
   ShadowFunctionTypeJ3D and ShadowSetTypeJ3D.

*/ public class ShadowFunctionOrSetTypeJ3D extends ShadowTypeJ3D { ShadowRealTupleTypeJ3D Domain; ShadowTypeJ3D Range; // null for ShadowSetTypeJ3D private Vector AccumulationVector = new Vector(); boolean post = false; boolean doTrajectory = false; boolean isAnimation1d = false; int domainLength = 0; Set anim1DdomainSet; Set domainSet; double trajVisibilityTimeWindow; FlowControl flowCntrl = null; ScalarMap flowMap = null; TrajectoryParams trajParams; ScalarMap altitudeToDisplayZ; List branches = null; Switch swit = null; Switch switB = null; TrajectoryAVHandlerJ3D avHandler = null; public ShadowFunctionOrSetTypeJ3D(MathType t, DataDisplayLink link, ShadowType parent) throws VisADException, RemoteException { super(t, link, parent); if (this instanceof ShadowFunctionTypeJ3D) { Domain = (ShadowRealTupleTypeJ3D) ((FunctionType) Type).getDomain().buildShadowType(link, this); Range = (ShadowTypeJ3D) ((FunctionType) Type).getRange().buildShadowType(link, this); adaptedShadowType = new ShadowFunctionType(t, link, getAdaptedParent(parent), (ShadowRealTupleType) Domain.getAdaptedShadowType(), Range.getAdaptedShadowType()); } else { Domain = (ShadowRealTupleTypeJ3D) ((SetType) Type).getDomain().buildShadowType(Link, this); Range = null; adaptedShadowType = new ShadowSetType(t, link, getAdaptedParent(parent), (ShadowRealTupleType) Domain.getAdaptedShadowType()); } } public ShadowRealTupleTypeJ3D getDomain() { return Domain; } public ShadowTypeJ3D getRange() { return Range; } /** clear AccumulationVector */ public void preProcess() throws VisADException { AccumulationVector.removeAllElements(); if (this instanceof ShadowFunctionTypeJ3D) { Range.preProcess(); } } /** transform data into a Java3D scene graph; add generated scene graph components as children of group; value_array are inherited valueArray values; default_values are defaults for each display.DisplayRealTypeVector; return true if need post-process */ public boolean doTransform(Object group, Data data, final float[] value_array, final float[] default_values, final DataRenderer renderer) throws VisADException, RemoteException { boolean isTerminal = adaptedShadowType.getIsTerminal(); ScalarMap timeMap = null; // used in the animation case to get control DataDisplayLink[] link_s = renderer.getLinks(); DataDisplayLink link = link_s[0]; Vector scalarMaps = link.getSelectedMapVector(); // only determine if it's an animation if non-terminal. isTerminal will // only be determined if there are scalar maps - defaults to false if (!isTerminal && !scalarMaps.isEmpty()) { // determine if it's an animation MathType mtype = data.getType(); if (mtype instanceof FunctionType) { int ani_map_idx = 0; FunctionType function = (FunctionType) mtype; RealTupleType functionD = function.getDomain(); for (int kk = 0; kk < scalarMaps.size(); kk++) { ScalarMap scalarMap = (ScalarMap) scalarMaps.elementAt(kk); String scalar_name = scalarMap.getScalarName(); if (scalar_name.equals(((RealType) functionD.getComponent(0)).getName())) { if (((scalarMap.getDisplayScalar()).equals(Display.Animation)) && (functionD.getDimension() == 1)) { isAnimation1d = true; ani_map_idx = kk; } } } // animation domain timeMap = (ScalarMap) scalarMaps.elementAt(ani_map_idx); } // check for trajectory for (int kk=0; kk(); for (int i=0; iDisplayImplJ3D.TEXTURE_NPOT then return * data_width, otherwise return the minimum power of two greater * than data_width. * @see DisplayImplJ3D#TEXTURE_NPOT */ public int textureWidth(int data_width) { if (DisplayImplJ3D.TEXTURE_NPOT) return data_width; // must be a power of 2 in Java3D int texture_width = 1; while (texture_width < data_width) texture_width *= 2; return texture_width; } /** * Get the possibly adjusted texture height. * @param data_height The initial texture height. * @return If DisplayImplJ3D.TEXTURE_NPOT then return * data_height, otherwise return the minimum power of two greater * than data_height. * @see DisplayImplJ3D#TEXTURE_NPOT */ public int textureHeight(int data_height) { if (DisplayImplJ3D.TEXTURE_NPOT) return data_height; // must be a power of 2 in Java3D int texture_height = 1; while (texture_height < data_height) texture_height *= 2; return texture_height; } /** * Get the possibly adjusted texture depth. * @param data_depth The initial texture depth. * @return If DisplayImplJ3D.TEXTURE_NPOT then return * data_depth, otherwise return the minimum power of two greater * than data_depth. * @see DisplayImplJ3D#TEXTURE_NPOT */ public int textureDepth(int data_depth) { if (DisplayImplJ3D.TEXTURE_NPOT) return data_depth; // must be a power of 2 in Java3D int texture_depth = 1; while (texture_depth < data_depth) texture_depth *= 2; return texture_depth; } public void adjustZ(float[] coordinates) { if (display.getDisplayRenderer().getMode2D()) { for (int i=2; i flowInfoList = Range.getAdaptedShadowType().getFlowInfo(); int dataDomainLength = anim1DdomainSet.getLength(); boolean trcrEnabled = trajParams.getMarkerEnabled(); int trajForm = trajParams.getTrajectoryForm(); boolean autoSizeTrcr = true; float trcrSize = trajParams.getMarkerSize(); double trajRefreshInterval = trajParams.getTrajRefreshInterval(); int direction = trajParams.getDirection(); DataRenderer renderer = getLink().getRenderer(); ProjectionControl pCntrl = renderer.getDisplay().getProjectionControl(); MouseBehavior mouseBehav = renderer.getDisplay().getMouseBehavior(); FixGeomSizeAppearance listener = null; double[] times = TrajectoryManager.getTimes((Gridded1DSet)anim1DdomainSet); double[] timeSteps = TrajectoryManager.getTimeSteps((Gridded1DSet)anim1DdomainSet); TrajectoryManager trajMan = new TrajectoryManager(renderer, trajParams, flowInfoList, dataDomainLength, times[0], altitudeToDisplayZ); trcrEnabled = (trcrEnabled && (trajForm == TrajectoryManager.LINE)) && trajForm != TrajectoryManager.POINT; if (autoSizeTrcr && trcrEnabled) { listener = new FixGeomSizeAppearanceJ3D(pCntrl, this, mouseBehav); trajMan.setListener(pCntrl, listener, flowCntrl); listener.lock(); } double[] dspScale = TrajectoryManager.getScale(mouseBehav, pCntrl); // current dispaly scale double scale = dspScale[0]; trajMan.initCleanUp(flowMap, flowCntrl, pCntrl, display); double trcrSizeRatio = 1; double timeAccum = 0; VisADGeometryArray array = null; VisADGeometryArray trcrArray = null; VisADGeometryArray[] auxArray = new VisADGeometryArray[1]; ArrayList achrArrays = null; for (int k=0; k 0) { achrArrays = new ArrayList(); trcrArray = trajMan.makeTracerGeometry(achrArrays, direction, trcrSize, dspScale, true); trcrArray = TrajectoryManager.scaleGeometry(trcrArray, achrArrays, (float)(1.0/scale)); } GraphicsModeControl mode = (GraphicsModeControl) info.mode.clone(); // something weird with this, everything being removed ? //array = (VisADLineArray) array.removeMissing(); if ((k==0) || (timeAccum >= trajRefreshInterval)) { // for non steady state trajectories (refresh frequency) avHandler.setNoneVisibleIndex(i); timeAccum = 0.0; } timeAccum += timeSteps[i]; if (trcrEnabled) { Object group = switB.getChild(i); BranchGroup trcrBG = addToDetachableGroup(group, trcrArray, mode, info.constant_alpha, info.constant_color); if (listener != null && trcrArray != null) { listener.add(trcrBG, trcrArray, achrArrays, mode, info.constant_alpha, info.constant_color); } } BranchGroup branch = (BranchGroup) branches.get(i); addToGroup(branch, array, mode, info.constant_alpha, info.constant_color); BranchGroup node = (BranchGroup) swit.getChild(i); node.addChild(branch); if (auxArray[0] != null) { BranchGroup auxBrnch = (BranchGroup) makeBranch(); addToGroup(auxBrnch, auxArray[0], mode, info.constant_alpha, info.constant_color); ((BranchGroup)switB.getChild(i)).addChild(auxBrnch); } } //--- domain length (time steps) outer time loop ------------------------- if (listener != null) { if (listener.isLocked()) { listener.update(); listener.unlock(); } } } }

Ads help maintain this website.