NASA World Wind

gov.nasa.worldwind.render
Class SurfacePolygons

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.render.AbstractSurfaceObject
          extended by gov.nasa.worldwind.render.AbstractSurfaceShape
              extended by gov.nasa.worldwind.render.SurfacePolylines
                  extended by gov.nasa.worldwind.render.SurfacePolygons
All Implemented Interfaces:
AVList, ExtentHolder, MeasurableArea, MeasurableLength, Movable, Highlightable, OrderedRenderable, PreRenderable, Renderable, SurfaceObject, SurfaceShape, Restorable

public class SurfacePolygons
extends SurfacePolylines

Renders fast multiple polygons with or without holes in one pass. It relies on a CompoundVecBuffer.

Whether a polygon ring is filled or is a hole in another polygon depends on the vertices winding order and the winding rule used - see setWindingRule(String).


Nested Class Summary
 
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractSurfaceShape
AbstractSurfaceShape.GeometryKey, AbstractSurfaceShape.SurfaceShapeStateKey
 
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
AbstractSurfaceObject.CacheEntry, AbstractSurfaceObject.SurfaceObjectStateKey
 
Field Summary
protected  Object interiorDisplayListCacheKey
           
protected  boolean needsInteriorTessellation
           
protected  int[] polygonRingGroups
           
protected  WWTexture texture
           
protected  String windingRule
           
 
Fields inherited from class gov.nasa.worldwind.render.SurfacePolylines
buffer, crossesDateLine, needsOutlineTessellation, outlineDisplayListCacheKey, sectors
 
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceShape
activeAttrs, activeGeometry, areaMeasurer, areaMeasurerLastModifiedTime, DEFAULT_HIGHLIGHT_MATERIAL, DEFAULT_INTERIOR_MATERIAL, DEFAULT_MAX_EDGE_INTERVALS, DEFAULT_MIN_EDGE_INTERVALS, DEFAULT_OUTLINE_MATERIAL, DEFAULT_PATH_TYPE, DEFAULT_TEXELS_PER_EDGE_INTERVAL, defaultAttrs, geometryCache, highlightAttrs, highlighted, maxEdgeIntervals, minEdgeIntervals, normalAttrs, pathType, sectorCache, stackHandler, texelsPerEdgeInterval, vertexBuffer
 
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
delegateOwner, drawBoundingSectors, enableBatchPicking, extentCache, lastModifiedTime, nextUniqueId, pickLayer, pickSupport, pickTileBuilder, pickTiles, uniqueId, visible
 
Constructor Summary
SurfacePolygons(CompoundVecBuffer buffer)
           
SurfacePolygons(Sector sector, CompoundVecBuffer buffer)
           
 
Method Summary
protected  List<double[]> computeDateLineCrossingPoints(VecBuffer vecBuffer)
           
protected  double[] computeDateLineEntryPoint(double[] from, double[] to)
           
protected  int computePole(List<double[]> dateLineCrossingPoints)
           
protected  double[] computePoleWrappingPoint(int pole, List<double[]> dateLineCrossingPoints)
           
protected  int[] doTessellateInterior(DrawContext dc, LatLon referenceLocation)
           
protected  void drawInterior(DrawContext dc, SurfaceTileDrawContext sdc)
           
 int[] getPolygonRingGroups()
          Get a copy of the polygon ring groups array - can be null.
protected  WWTexture getTexture()
           
 String getWindingRule()
          Get the winding rule used when tessellating polygons.
protected  void handleUnsuccessfulInteriorTessellation(DrawContext dc)
           
protected  void onGeometryChanged()
           
 void setPolygonRingGroups(int[] ringGroups)
          Set the polygon ring groups array - can be null.
 void setWindingRule(String windingRule)
          Set the winding rule used when tessellating polygons.
protected  int[] tessellateInterior(DrawContext dc, LatLon referenceLocation)
           
protected  int tessellateInteriorVertices(GLU glu, GLUtessellator tess, LatLon referenceLocation)
           
protected  boolean tessellateRing(GLU glu, GLUtessellator tess, VecBuffer vecBuffer, LatLon referenceLocation)
           
 
Methods inherited from class gov.nasa.worldwind.render.SurfacePolylines
createGeometry, determineActiveGeometry, doMoveTo, drawOutline, getBuffer, getLocations, getLocations, getReferencePosition, getSectors, setLocations, tessellateOutline, tessellatePart
 
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceShape
addIntermediateLocations, applyInteriorState, applyInteriorTextureState, applyModelviewTransform, applyOutlineState, beginDrawing, clearCaches, computeEdgeIntervalsPerDegree, computeSectors, computeSectors, createActiveAttributes, createGeometryKey, determineActiveAttributes, doDrawGeographic, doGetRestorableState, doRestoreState, doTessellateInterior, drawGeographic, endDrawing, generateIntermediateLocations, getActiveAttributes, getActiveGeometry, getArea, getArea, getAttributes, getCachedGeometry, getExtent, getHeight, getHighlightAttributes, getInteriorTexture, getLength, getMinAndMaxEdgeIntervals, getPathType, getPerimeter, getRestorableState, getStateKey, getTexelsPerEdgeInterval, getWidth, isHighlighted, isSectorEmpty, legacyRestoreState, makeOrderedPreRenderable, move, moveTo, onShapeChanged, pathTypeFromString, restoreState, setAttributes, setHighlightAttributes, setHighlighted, setMinAndMaxEdgeIntervals, setPathType, setTexelsPerEdgeInterval, setupAreaMeasurer, tessellateInterior, tessellateInteriorVertices
 
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
buildPickRepresentation, computeExtent, computeExtent, createPickedObject, createPickTileBuilder, drawBoundingSectors, drawOrderedRenderable, drawPickRepresentation, getDelegateOwner, getDistanceFromEye, getExtent, getUniqueId, intersectsFrustum, intersectsPickFrustum, intersectsVisibleSector, isDrawBoundingSectors, isEnableBatchPicking, isVisible, makeOrderedRenderable, nextUniqueId, pick, pickBatched, pickOrderedRenderable, preRender, render, setDelegateOwner, setDrawBoundingSectors, setEnableBatchPicking, setVisible, updateModifiedTime
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.render.SurfaceObject
getDelegateOwner, getDistanceFromEye, getExtent, isVisible, pick, preRender, render, setDelegateOwner, setVisible
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 

Field Detail

interiorDisplayListCacheKey

protected Object interiorDisplayListCacheKey

needsInteriorTessellation

protected boolean needsInteriorTessellation

polygonRingGroups

protected int[] polygonRingGroups

texture

protected WWTexture texture

windingRule

protected String windingRule
Constructor Detail

SurfacePolygons

public SurfacePolygons(CompoundVecBuffer buffer)

SurfacePolygons

public SurfacePolygons(Sector sector,
                       CompoundVecBuffer buffer)
Method Detail

computeDateLineCrossingPoints

protected List<double[]> computeDateLineCrossingPoints(VecBuffer vecBuffer)

computeDateLineEntryPoint

protected double[] computeDateLineEntryPoint(double[] from,
                                             double[] to)

computePole

protected int computePole(List<double[]> dateLineCrossingPoints)

computePoleWrappingPoint

protected double[] computePoleWrappingPoint(int pole,
                                            List<double[]> dateLineCrossingPoints)

doTessellateInterior

protected int[] doTessellateInterior(DrawContext dc,
                                     LatLon referenceLocation)

drawInterior

protected void drawInterior(DrawContext dc,
                            SurfaceTileDrawContext sdc)
Overrides:
drawInterior in class SurfacePolylines

getPolygonRingGroups

public int[] getPolygonRingGroups()
Get a copy of the polygon ring groups array - can be null.

When not null the polygon ring groups array identifies the starting sub buffer index for each polygon. In that case rings from a same group will be tesselated together as part of the same polygon.

When null polygon rings that follow the current winding rule are tessellated separatly as different polygons. Rings that are reverse winded are considered holes to be applied to the last straight winded ring polygon.

Returns:
a copy of the polygon ring groups array - can be null.

getTexture

protected WWTexture getTexture()

getWindingRule

public String getWindingRule()
Get the winding rule used when tessellating polygons. Can be one of AVKey.CLOCKWISE (default) or AVKey.COUNTER_CLOCKWISE.

When set to AVKey.CLOCKWISE polygons which run clockwise will be filled and those which run counter clockwise will produce 'holes'. The interpretation is reversed when the winding rule is set to AVKey.COUNTER_CLOCKWISE.

Returns:
the winding rule used when tessellating polygons.

handleUnsuccessfulInteriorTessellation

protected void handleUnsuccessfulInteriorTessellation(DrawContext dc)
Overrides:
handleUnsuccessfulInteriorTessellation in class AbstractSurfaceShape

onGeometryChanged

protected void onGeometryChanged()
Overrides:
onGeometryChanged in class SurfacePolylines

setPolygonRingGroups

public void setPolygonRingGroups(int[] ringGroups)
Set the polygon ring groups array - can be null.

When not null the polygon ring groups array identifies the starting sub buffer index for each polygon. In that case rings from a same group will be tesselated together as part of the same polygon.

When null polygon rings that follow the current winding rule are tessellated separatly as different polygons. Rings that are reverse winded are considered holes to be applied to the last straight winded ring polygon.

Parameters:
ringGroups - a copy of the polygon ring groups array - can be null.

setWindingRule

public void setWindingRule(String windingRule)
Set the winding rule used when tessellating polygons. Can be one of AVKey.CLOCKWISE (default) or AVKey.COUNTER_CLOCKWISE.

When set to AVKey.CLOCKWISE polygons which run clockwise will be filled and those which run counter clockwise will produce 'holes'. The interpretation is reversed when the winding rule is set to AVKey.COUNTER_CLOCKWISE.

Parameters:
windingRule - the winding rule to use when tessellating polygons.

tessellateInterior

protected int[] tessellateInterior(DrawContext dc,
                                   LatLon referenceLocation)

tessellateInteriorVertices

protected int tessellateInteriorVertices(GLU glu,
                                         GLUtessellator tess,
                                         LatLon referenceLocation)

tessellateRing

protected boolean tessellateRing(GLU glu,
                                 GLUtessellator tess,
                                 VecBuffer vecBuffer,
                                 LatLon referenceLocation)

NASA World Wind