package org.jzy3d.plot3d.builder.concrete;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

// import org.apache.log4j.Logger;
import org.jzy3d.colors.Color;
import org.jzy3d.colors.ColorMapper;
import org.jzy3d.maths.Array;
import org.jzy3d.maths.Coord3d;
import org.jzy3d.plot3d.builder.Tessellator;
import org.jzy3d.plot3d.primitives.AbstractComposite;
import org.jzy3d.plot3d.primitives.AbstractDrawable;
import org.jzy3d.plot3d.primitives.Point;
import org.jzy3d.plot3d.primitives.Polygon;
import org.jzy3d.plot3d.primitives.Shape;


/** The {@link OrthonormalTessellator} checks that coordinates are lying on an orthormal grid,
 * and is able to provide a {@link AbstractComposite} made of {@link Polygon}s built according to this grid
 * 
 * On this model, one input coordinate is represented by one {@link Polygon}, for which each point is
 * a mean point between two grid ticks:
 * 
 * 
 * 
 *  ^                           ^
 *  |                           |
 *  -   +   +   +               -   +   +   +
 *  |                           |     *---*
 *  -   +   o   +        >>     -   + | o | +
 *  |                           |     *---*
 *  -   +   +   +               -   +   +   +
 *  |                           |
 *  |---|---|---|-->            |---|---|---|-->
 *  
 *  
 *  
* * In this figure, the representation of a coordinate ("o" on the left) is a polygon * made of mean points ("*" on the right) that require the existence of four surrounding * points (the "o" and the three "+") * * @author Martin Pernollet * */ public class OrthonormalTessellator extends Tessellator{ // static Logger logger = Logger.getLogger(OrthonormalTessellator.class); @Override public AbstractComposite build(float[] x, float[] y, float[] z) { setData(x, y, z); Shape s = new Shape(); s.add(getSquarePolygonsOnCoordinates()); return s; } /************************************************************************************************/ /** Set the array of data. X,Y, and Z are arrays that must implicitely * represent an orthonormal grid. * * If some data are missing for representing this grid, missing data * will be considered as NaN. The actual management of missing values * is thus left to the object that loads these data. * * In the following example, the o represent a NaN Z value, meaning that * there was no (x[i],y[i],z[i]) triplet for representing it correctly: *
*
	 * 
	 * 11111111 y
	 * 11111111  
	 * 11o11111  
	 * 11111111  
	 * 
	 * x         
	 * 
	 * 
*
* * @param x list of x coordinates * @param y list of y coordinates * @param z list of z coordinates * * @throws an IllegalArgumentException if x, y , and z have not the same size */ protected void setData(float x[], float y[], float z[]){ if(x.length!=y.length || x.length!=z.length) throw new IllegalArgumentException("x, y, and z arrays must agree in length."); // Initialize loading this.x = unique(x); this.y = unique(y); this.z = new float[this.x.length][this.y.length]; for(int i=0; i getSquarePolygonsOnCoordinates(){ return getSquarePolygonsOnCoordinates(null, null); } public List getSquarePolygonsAroundCoordinates(){ return getSquarePolygonsAroundCoordinates(null, null); } public List getSquarePolygonsOnCoordinates(ColorMapper cmap, Color colorFactor){ List polygons = new ArrayList(); for(int xi=0; xi getSquarePolygonsAroundCoordinates(ColorMapper cmap, Color colorFactor){ List polygons = new ArrayList(); for(int xi=1; xi

Ads help maintain this website.