JavaView® v2.12

jv.geom
Class PgPolygonSet

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jv.project.PgGeometry
              |
              +--jv.geom.PgPointSet
                    |
                    +--jv.geom.PgPolygonSet
All Implemented Interfaces:
java.lang.Cloneable, PgGeometryIf, PsUpdateIf, java.io.Serializable

public class PgPolygonSet
extends PgPointSet

Basic class for collections of lines and polygons. The class contains an array with polygons, each polygon is given by a list of vertex indices in the vertex array of its superclass PgPointSet. Each polygon may have a different number of vertices.

The dimension of all points is determined as argument of the constructor and cannot be changed later. See PgPointSet for details about allocation and access.

The number of vertices per polygon may be the same for all polygons of the polygon set, and assigned using the method setDimOfPolygons(int num). Or, the size of polygons may differ in which case getDimOfPolygons()==-1, which is the default case. The advantage of the first case is, that the class is able to do more memory allocations automatically.

There exist several utility functions to allocate and modify the number of polygons, for example,

	setNumPolygons(int num)
 
allocates num polygons. Internally, there exists a cache to reduce the number of actual memory allocations. The size of the cache is managed by protected methods.

Whenever the number of polygons is changed, the class automatically adjusts the size of those polygon properties which are currently in use, i.e. whose array is not null.

Applications may modify the entries of an polygon and of polygon properties by direct method calls such as

	setPolygon(int ind, PiVector v)
 
which sets the polygon with index ind equal to the components of a vector v by copying. Alternatively, if an application modifies a larger number of polygons then the application may prefer to obtain the polygon array from the polygon set and directly modify the array
	PiVector [] polygon = polygonSet.getPolygons();
	for (int i=0; i<pointSet.getNumPolygons(); i++)
		polygon[i].copy(v);
 
The same choice is available for arrays containing polygon properties. Note, that the actual size of the polygon array may be larger than m_numPolygons efficiency reasons. Therefore, do not use polygon.length but use getNumPolygons().

This class contains mainly basic methods for memory allocation and access to instance variables. Geometric methods operating on polygon sets such as computing a specific surface or computing the intersection of two surfaces are available in special workshop classes as extensions outside the base JavaView packages.

A good starting to obtain further insight are methods like PgPolygon.computeEight(int) (if source code access to JavaView is available), or the tutorial applets of JavaView.

Version:
21.07.00, 2.50 revised (kp) Global properties of normals splitted into vertex and element part.
02.04.00, 2.00 revised (kp) PdColor replaced with Color in lists.
04.10.99, 1.10 revised (ur) m_dimOfPolygons added.
23.09.99, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
Serialized Form

Field Summary
 int BINORMAL
           
 int CURVATURE_NORMAL
           
 int NORMAL
           
 int OFFSET_NORMAL
           
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, NUM_TAGS
 
Fields inherited from interface jv.project.PgGeometryIf
AMBIENT_H2_HYPERBOLIC, AMBIENT_H3_HYPERBOLIC, AMBIENT_H4_HYPERBOLIC, AMBIENT_PROJECTIONS, AMBIENT_R1_EUCLIDEAN, AMBIENT_R2_EUCLIDEAN, AMBIENT_R3_EUCLIDEAN, AMBIENT_R4_EUCLIDEAN, AMBIENT_R5_EUCLIDEAN, AMBIENT_S1_SPHERE, AMBIENT_S2_SPHERE, AMBIENT_S3_SPHERE, AMBIENT_S4_SPHERE, AMBIENT_SPACES, INSPECTOR_CONTROL, INSPECTOR_CONTROL_EXT, INSPECTOR_MATERIAL, INSPECTOR_MATERIAL_EXT, INSPECTOR_TEXTURE, INSPECTOR_TEXTURE_EXT, LABEL_BASE, LABEL_CENTER, LABEL_HEAD, LABEL_MIDDLE, LABEL_TAIL, LABEL_TOP, METHOD_EXT, PROJ_KLEIN_BALL, PROJ_PARALLEL, PROJ_POINCARE_BALL, PROJ_STEREOGRAPHIC, PROJ_UPPER_HALFSPACE
 
Constructor Summary
PgPolygonSet()
          Constructor of a polygon set in three-dimensional space.
PgPolygonSet(int aVertexDim)
          Constructor of a polygon set in a space of given dimension.
 
Method Summary
 int addPolygon(PiVector aPolygon)
          Add new polygon to the end of the polygon list.
 boolean assureDimOfPolygons()
          Assure correctness of value m_dimOfPolygons specifying the number of vertices per polygon.
 void assurePolygonColors()
          Assures respectively allocates correct length of polygon color array.
 void assurePolygonNormals()
          Assures respectively allocates correct length of polygon normal array.
 boolean blend(double s, PgGeometry ag, double t, PgGeometry bg)
          Blend between two polygonSets, used in interpolation and computing the associate surfaces this = s*a + t*b.
 void clearTagPolygon(int anIndex, int aTag)
          Clear a single tag of a polygon.
 java.lang.Object clone()
          Duplicate geometry by recursively cloning all instance variables except inspector panels and lists of registered listeners.
 void copy(PgGeometry geom)
          Copy instance variables by duplication, not by copying a reference.
 void copyPolygonSet(PgPolygonSet geom)
          Copy instance variables of this class but not of the superclass.
 int getDimOfPolygons()
          Retrieve number of vertices per polygon, if it is the same for all polygons, otherwise return -1.
 java.awt.Color getGlobalPolygonColor()
          Get global polygon color which is used if no local colors are available.
 java.awt.Color getGlobalPolygonNormalColor()
          Get global element color which is used if no local colors are available.
 double getGlobalPolygonNormalLength()
          Get length factor of normal vectors when drawn in display.
 double getGlobalPolygonNormalSize()
          Get thickness in pixels of normals when drawn in display.
 double getGlobalPolygonSize()
          Get thickness in pixels of polygon when drawn in display.
 java.awt.Color getGlobalPolygonTagColor()
          Get global color of tagged polygons.
 PgJvxSrc getJvx()
          Fills a geometry object with data from this instance, for example, to print to file.
 double getLength()
          Compute total length of all polygons.
 double getLengthOfPolygon(int ind)
          Compute length of a single polygon with given index.
 int getMaxNumPolygons()
          Get total length of allocated polygon array.
 int getNumEdges()
          Calculate total number of edges of all polygons.
 int getNumPolygons()
          Get number of polygons in vertex array.
 PiVector getPolygon(int anIndex)
          Get a reference to an individual polygon array with vertex indices.
 java.awt.Color getPolygonColor(int anIndex)
          Get a reference to an individual polygon color.
 java.awt.Color[] getPolygonColors()
          Get color array for read and write access, but do not modify the size of any color vector.
 PdVector getPolygonNormal(int anIndex)
          Get a reference to an individual polygon normal.
 PdVector[] getPolygonNormals()
          Get vertex normal array for read and write access, but do not modify the size of any normal vector.
 PiVector[] getPolygons()
          Get polygon array for read and write access.
 PdVector[] getPolygonVertices(int ind)
          Get an array with pointers to all vertices of an polygon.
 int getPolygonWithVertex(int vertexInd)
          Find first polygon referencing a given vertex.
 double getVertexAngle(int ind, int locInd)
          Compute angle at vertex of polygon.
 boolean hasPolygonColors()
          Check if polygon colors have been allocated.
 boolean hasPolygonNormals()
          Check if polygon normals have been allocated.
 boolean hasTagPolygon(int anIndex, int aTag)
          Check whether polygon has given tag.
 void init()
          Initialize and reset instance variables after call to super.init().
 PvPickEvent intersectionWithLine(PdVector rayBase, PdVector rayDir)
          Find intersection of polygon set with a given ray.
 boolean isClosed(int ind)
          Check whether polygon is closed, i.e.if endpoints are identical.
 boolean isShowingEdgeLabels()
          Determine whether showing of edge labels is enabled.
 boolean isShowingPolygonColors()
          Set flag to enable drawing of polygon colors.
 boolean isShowingPolygonEndArrow()
          Determines whether drawing of arrow at last point of polygon is enabled.
 boolean isShowingPolygonLabels()
          Determine whether showing of polygon labels is enabled.
 boolean isShowingPolygonNormalArrow()
          Determines whether drawing of arrow of polygon normals is enabled.
 boolean isShowingPolygonNormals()
          Set flag to enable drawing of polygon normals.
 boolean isShowingPolygons()
          Set flag to enable drawing of polygons.
 boolean isShowingPolygonStartArrow()
          Determines whether drawing of arrow at first point of polygon is enabled.
 void makeBiNormals()
          Compute binormals at vertices which are orthogonal to both adjacent edges.
 void makeCurvatureNormals()
          Compute normals at vertices as edge bisectors with length equal to (Pi-vertexAngle).
 void makeNormals()
          Compute normals at vertices as edge bisectors with unit length.
 void makeNormals(int type, double length)
          Compute normals at vertices which lie in the span of the adjacent edges.
 void makeOffsetNormals()
          Compute normals at vertices as edge bisectors whose tip lies on an offset==1 curve.
 boolean makePolygonColorsFromXYZ()
          Create color from the edge position within its bounding box which is interpreted as RGB cube.
 boolean makePolygonColorsFromZ()
          Create color from the vertical z-height within its bounding box ranging from red to blue.
 boolean makePolygonColorsFromZHue()
          Create color from the vertical z-height within its bounding box ranging through hue rainbow.
 boolean merge(PgGeometryIf aGeom)
          Merge polygon set with current object and store union of both objects in 'this'.
 void paint(PvGeometryIf dc)
          Major rendering method fills an internal container class supplied by the display.
 int[] removeMarkedPolygons()
          Remove all polygons which have been marked PsObject.IS_DELETED.
 int[] removeMarkedVertices()
          Remove vertices marked with tag PsObject#IS_DELETED from polygons.
 int[] removePolygon(int ind)
          Remove polygon with given index, and decrement index of all polygons with higher index.
 boolean removeUnusedVertices()
          Remove all points not referenced by polygons.
 boolean setClosed(int ind, boolean flag)
          Close a polygon such that first and last vertex are identical.
 void setDimOfColors(int aSize)
          Let all colors have same number of components aSize<>0.
 void setDimOfPolygons(int aSize)
          Let all polygons have same number of vertices aSize<>0, or individual aSize=-1.
 void setDimOfVectors(int aSize)
          Let all vectors have same number of vectors aSize<>0.
 void setGlobalPolygonColor(java.awt.Color color)
          Set global polygon color to be used if no local colors are available.
 void setGlobalPolygonNormalColor(java.awt.Color color)
          Set global normal color to be used if no local colors are available.
 void setGlobalPolygonNormalLength(double length)
          Get length factor of normal vectors when drawn in display.
 void setGlobalPolygonNormalSize(double size)
          Get thickness in pixels of normals when drawn in display.
 void setGlobalPolygonSize(double size)
          Set thickness in pixels of polygon when drawn in display.
 void setGlobalPolygonTagColor(java.awt.Color color)
          Set global color of tagged polygons.
 void setJvx(PgJvxSrc src)
          Fill this instance with data from a geometry source, for example, previously read from file.
 void setNumPolygons(int aNumPolygons)
          Allocate given number of polygons, and allocate normals, colors etc. if they already exist.
 void setPolygon(int anIndex, int a, int b)
          Copy new vertex indices to polygon at specified position in the polygon list.
 boolean setPolygon(int anIndex, PiVector aPolygon)
          Set index vector of polygon with given index.
 boolean setPolygonColor(int anIndex, java.awt.Color aColor)
          Copy new color to polygon color at specified position in the color list
 void setPolygonColors(java.awt.Color[] color)
          Copy polygon colors of list to existing array of polygon colors.
 boolean setPolygonNormal(int anIndex, PdVector aNormal)
          Copy new normal to polygon normal at specified position in the normal list
 void setPolygonNormals(PdVector[] normal)
          Copy polygon normals of list to existing array of polygon normals.
 void setPolygons(PiVector[] polygon)
          Copy all polygons of polygon list to existing array of polygons.
 boolean setPolygonVertices(int ind, PdVector[] vArray)
          Copy new polygon vertices to polygon at specified position in the polygon list.
 void setSizeOfPolygon(int ind, int aSize)
          Let all polygons have same number of vertices aSize<>0, or individual aSize=-1.
 void setTagPolygon(int anIndex, int aTag)
          Set a tag of a polygon.
 void showEdgeLabels(boolean flag)
          Set flag to enable drawing of edge labels in display.
 void showPolygonColors(boolean flag)
          Set flag to enable drawing of polygon colors.
 void showPolygonEndArrow(boolean flag)
          Set flag to enable drawing of arrow at last point of polygons.
 void showPolygonLabels(boolean flag)
          Set flag to enable drawing of polygon labels in display.
 void showPolygonNormalArrow(boolean flag)
          Set flag to enable drawing of arrow of polygon normal.
 void showPolygonNormals(boolean flag)
          Set flag to enable drawing of polygon normals.
 void showPolygons(boolean flag)
          Set flag to enable drawing of polygons.
 void showPolygonStartArrow(boolean flag)
          Set flag to enable drawing of arrow at first point of polygons.
 java.lang.String toString()
          Create a multi-line string representation with detailed information about all instance variables.
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 void useGlobalPolygonColor(boolean flag)
          Deprecated. use showPolygonColors(boolean)
 void useGlobalPolygonSize(boolean flag)
          Use global polygon size instead of sizing each polygon individually.
 
Methods inherited from class jv.geom.PgPointSet
addVectorField, addVertex, assureVertexColors, assureVertexNormals, assureVertexTextures, clearTagVertex, computeCylinder, computeDisk, computePlane, computeRotation, computeSnail, computeSphere, computeTorus, flipOrientation, getAmbientBounds, getBounds, getCenterOfBndBox, getCenterOfGravity, getDimOfColors, getDimOfTextures, getDimOfVectors, getGlobalVectorColor, getGlobalVectorLength, getGlobalVectorSize, getGlobalVertexColor, getGlobalVertexNormalColor, getGlobalVertexNormalLength, getGlobalVertexNormalSize, getGlobalVertexSize, getGlobalVertexTagColor, getIndexOfVectorField, getMaxNumVertices, getNumVectorFields, getNumVertices, getTexture, getTextureImage, getTextureImageName, getVectorField, getVectorField, getVertex, getVertexColor, getVertexColors, getVertexNormal, getVertexNormals, getVertexTextures, getVertices, hasTagVertex, hasVertex, hasVertex, hasVertexColors, hasVertexNormals, hasVertexTextures, isDefaultLabelEnabled, isShowingIndices, isShowingTaggedVertices, isShowingVectorArrow, isShowingVectorArrows, isShowingVectorColors, isShowingVectorField, isShowingVertexColors, isShowingVertexLabels, isShowingVertexNormalArrow, isShowingVertexNormals, isShowingVertexTexture, isShowingVertices, makeColorFromVectorLength, makeVertexColorsFromXYZ, makeVertexColorsFromZ, makeVertexColorsFromZHue, makeVertexNormals, makeVertexTextureFromBndBox, makeVertexTextureFromCylinder, makeVertexTextureFromSphere, projectToSphere, reflect, removeAllVectorFields, removeVectorField, removeVertex, scale, scale, setCenterOfBndBox, setDefaultLabelEnabled, setDimOfTextures, setGlobalVectorColor, setGlobalVectorLength, setGlobalVectorSize, setGlobalVertexColor, setGlobalVertexNormalColor, setGlobalVertexNormalLength, setGlobalVertexNormalSize, setGlobalVertexSize, setGlobalVertexTagColor, setNumVertices, setState, setTagVertex, setTexture, setTextureImage, setTextureImageName, setTransparency, setVertex, setVertex, setVertex, setVertex, setVertexColor, setVertexColors, setVertexNormal, setVertexNormals, setVertexTextures, setVertices, showIndices, showTaggedVertices, showVectorArrow, showVectorArrows, showVectorColors, showVectorField, showVectorFields, showVertexColors, showVertexLabels, showVertexNormalArrow, showVertexNormals, showVertexTexture, showVertices, translate
 
Methods inherited from class jv.project.PgGeometry
addDisplay, addElement, clearTagElement, fillMethodMenu, getAmbientInvMatrix, getAmbientMatrix, getAmbientProjection, getAmbientSpace, getAuthorInfo, getAuthors, getCenter, getCenterOfElement, getControlPanel, getDiameter, getDimOfSimplex, getDimOfVertices, getDisplays, getElement, getGeometryInfo, getLabelAttribute, getMaterialPanel, getModelMatrix, getTitle, getVersion, getVersionType, hasAmbientMatrix, hasDisplay, hasModelMatrix, hasTagElement, isConfigurable, isShowingBndBox, isShowingCenter, isShowingTitle, isVisible, removeDisplay, removeElement, setAmbientMatrix, setAmbientProjection, setAmbientSpace, setAuthorInfo, setAuthors, setCenter, setDimOfSimplex, setElement, setGeometryInfo, setLabelAttribute, setLabelAttribute, setModelMatrix, setTagElement, setTitle, setVersion, setVersionType, setVisible, showBndBox, showCenter, showTitle
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, updatePanels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jv.project.PgGeometryIf
assureInspector, getInfoPanel, getName, setName
 
Methods inherited from interface jv.object.PsUpdateIf
getFather, setParent
 

Field Detail

NORMAL

public int NORMAL

BINORMAL

public int BINORMAL

OFFSET_NORMAL

public int OFFSET_NORMAL

CURVATURE_NORMAL

public int CURVATURE_NORMAL
Constructor Detail

PgPolygonSet

public PgPolygonSet()
Constructor of a polygon set in three-dimensional space.

PgPolygonSet

public PgPolygonSet(int aVertexDim)
Constructor of a polygon set in a space of given dimension.
Method Detail

init

public void init()
Initialize and reset instance variables after call to super.init().
Overrides:
init in class PgPointSet

getJvx

public PgJvxSrc getJvx()
Fills a geometry object with data from this instance, for example, to print to file.
Overrides:
getJvx in class PgPointSet
Returns:
src a geometry source to be filled with data from this instance.

setJvx

public void setJvx(PgJvxSrc src)
Fill this instance with data from a geometry source, for example, previously read from file.
Overrides:
setJvx in class PgPointSet
Parameters:
src - a geometry source used to fill this instance with data.

clone

public java.lang.Object clone()
Duplicate geometry by recursively cloning all instance variables except inspector panels and lists of registered listeners. The parent relationship is maintained only within this class but not to external classes. In general, all links of the clone to external objects are set to null. Tags of this object are not copied but maybe copied of subclasses.
Overrides:
clone in class PgPointSet
See Also:
#copy(PgPolygonSet)

copy

public void copy(PgGeometry geom)
Copy instance variables by duplication, not by copying a reference.
Overrides:
copy in class PgPointSet

copyPolygonSet

public void copyPolygonSet(PgPolygonSet geom)
Copy instance variables of this class but not of the superclass.

toString

public java.lang.String toString()
Create a multi-line string representation with detailed information about all instance variables.
Overrides:
toString in class PgPointSet

update

public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.
Overrides:
update in class PgPointSet
Following copied from interface: jv.object.PsUpdateIf
Parameters:
event - carries a lot of information
Returns:
true if event has been handled, otherwise false
See Also:
PsObject, PsUpdateIf.getFather(), PsUpdateIf.setParent(PsUpdateIf)

getGlobalPolygonColor

public java.awt.Color getGlobalPolygonColor()
Get global polygon color which is used if no local colors are available.

getGlobalPolygonTagColor

public java.awt.Color getGlobalPolygonTagColor()
Get global color of tagged polygons.

getGlobalPolygonSize

public double getGlobalPolygonSize()
Get thickness in pixels of polygon when drawn in display.

getGlobalPolygonNormalColor

public java.awt.Color getGlobalPolygonNormalColor()
Get global element color which is used if no local colors are available.

getGlobalPolygonNormalLength

public double getGlobalPolygonNormalLength()
Get length factor of normal vectors when drawn in display.

getGlobalPolygonNormalSize

public double getGlobalPolygonNormalSize()
Get thickness in pixels of normals when drawn in display.

setGlobalPolygonColor

public void setGlobalPolygonColor(java.awt.Color color)
Set global polygon color to be used if no local colors are available.

setGlobalPolygonTagColor

public void setGlobalPolygonTagColor(java.awt.Color color)
Set global color of tagged polygons.

setGlobalPolygonSize

public void setGlobalPolygonSize(double size)
Set thickness in pixels of polygon when drawn in display.

setGlobalPolygonNormalColor

public void setGlobalPolygonNormalColor(java.awt.Color color)
Set global normal color to be used if no local colors are available.

setGlobalPolygonNormalLength

public void setGlobalPolygonNormalLength(double length)
Get length factor of normal vectors when drawn in display.

setGlobalPolygonNormalSize

public void setGlobalPolygonNormalSize(double size)
Get thickness in pixels of normals when drawn in display.

addPolygon

public int addPolygon(PiVector aPolygon)
Add new polygon to the end of the polygon list. Method just calls setPolygon(PiVector, numPolygons).
Overrides:
addPolygon in class PgGeometry
Parameters:
PiVector - polygon to be added to polygon list
Returns:
int index of added polygon in polygon list

getPolygons

public PiVector[] getPolygons()
Get polygon array for read and write access. Also note, that the actual size of the array may be larger than m_numPolygons for efficiency reasons. Therefore, do not use length of array.

getPolygonColors

public java.awt.Color[] getPolygonColors()
Get color array for read and write access, but do not modify the size of any color vector. Note, that subclasses may not reference all vertex colors. Also note, that the actual size of the color array may be larger than m_numVertices for efficiency reasons. Therefore, do not use length of array.

getPolygonNormals

public PdVector[] getPolygonNormals()
Get vertex normal array for read and write access, but do not modify the size of any normal vector. Note, that subclasses may not reference all vertex normals. Also note, that the actual size of the color may be larger than m_numVertices for efficiency reasons. Therefore, do not use length of array.

isShowingEdgeLabels

public boolean isShowingEdgeLabels()
Determine whether showing of edge labels is enabled.

isShowingPolygonLabels

public boolean isShowingPolygonLabels()
Determine whether showing of polygon labels is enabled.

isShowingPolygons

public boolean isShowingPolygons()
Set flag to enable drawing of polygons.

isShowingPolygonColors

public boolean isShowingPolygonColors()
Set flag to enable drawing of polygon colors.

isShowingPolygonNormals

public boolean isShowingPolygonNormals()
Set flag to enable drawing of polygon normals.

isShowingPolygonNormalArrow

public boolean isShowingPolygonNormalArrow()
Determines whether drawing of arrow of polygon normals is enabled.

isShowingPolygonStartArrow

public boolean isShowingPolygonStartArrow()
Determines whether drawing of arrow at first point of polygon is enabled.

isShowingPolygonEndArrow

public boolean isShowingPolygonEndArrow()
Determines whether drawing of arrow at last point of polygon is enabled.

showEdgeLabels

public void showEdgeLabels(boolean flag)
Set flag to enable drawing of edge labels in display.

showPolygonLabels

public void showPolygonLabels(boolean flag)
Set flag to enable drawing of polygon labels in display.

showPolygons

public void showPolygons(boolean flag)
Set flag to enable drawing of polygons.

showPolygonColors

public void showPolygonColors(boolean flag)
Set flag to enable drawing of polygon colors.

showPolygonNormals

public void showPolygonNormals(boolean flag)
Set flag to enable drawing of polygon normals.

showPolygonNormalArrow

public void showPolygonNormalArrow(boolean flag)
Set flag to enable drawing of arrow of polygon normal.

showPolygonStartArrow

public void showPolygonStartArrow(boolean flag)
Set flag to enable drawing of arrow at first point of polygons.

showPolygonEndArrow

public void showPolygonEndArrow(boolean flag)
Set flag to enable drawing of arrow at last point of polygons.

useGlobalPolygonColor

public void useGlobalPolygonColor(boolean flag)
Deprecated. use showPolygonColors(boolean)

Set flag of using global polygon color instead of coloring each polygon individually.

useGlobalPolygonSize

public void useGlobalPolygonSize(boolean flag)
Use global polygon size instead of sizing each polygon individually.

getMaxNumPolygons

public int getMaxNumPolygons()
Get total length of allocated polygon array. Usually, only a subset is filled with data. Method is for internal use, see getNumPolygons() for daily work.

getNumPolygons

public int getNumPolygons()
Get number of polygons in vertex array. Note, that the actual size of the polygon array may be larger for efficiency reasons. Therefore, do not use m_polygon.length.

setNumPolygons

public void setNumPolygons(int aNumPolygons)
Allocate given number of polygons, and allocate normals, colors etc. if they already exist. Internally, there may exist more polygons than requested serving as buffer and to reduce allocation times.

setSizeOfPolygon

public void setSizeOfPolygon(int ind,
                             int aSize)
Let all polygons have same number of vertices aSize<>0, or individual aSize=-1. It is more efficient to call method before setNumPolygons().
Parameters:
aSize - Number of vertices for all polygons.
See Also:
setNumPolygons(int)

setDimOfPolygons

public void setDimOfPolygons(int aSize)
Let all polygons have same number of vertices aSize<>0, or individual aSize=-1. It is more efficient to call method before setNumPolygons().
Parameters:
aSize - Number of vertices for all polygons.
See Also:
setNumPolygons(int)

getDimOfPolygons

public int getDimOfPolygons()
Retrieve number of vertices per polygon, if it is the same for all polygons, otherwise return -1. Note: this check does not include the size of polygons with index in {m_numPolygons, m_maxNumPolygons-1}.
See Also:
setDimOfPolygons(int)

assureDimOfPolygons

public boolean assureDimOfPolygons()
Assure correctness of value m_dimOfPolygons specifying the number of vertices per polygon.
Returns:
true if m_dimOfPolygons had the correct value. Note: this check does not include the size of polygons with index in {m_numPolygons, m_maxNumPolygons-1}.
See Also:
setDimOfPolygons(int)

setDimOfColors

public void setDimOfColors(int aSize)
Let all colors have same number of components aSize<>0.
Overrides:
setDimOfColors in class PgPointSet
Parameters:
aSize - Number of components of each color vector.

setDimOfVectors

public void setDimOfVectors(int aSize)
Let all vectors have same number of vectors aSize<>0. It is more efficient to call method before setNumVertices().
Overrides:
setDimOfVectors in class PgPointSet
Parameters:
aSize - Number of coordinates of each vertex.
See Also:
PgPointSet.setDimOfVectors(int)

hasPolygonColors

public boolean hasPolygonColors()
Check if polygon colors have been allocated.
See Also:
assurePolygonColors()

hasPolygonNormals

public boolean hasPolygonNormals()
Check if polygon normals have been allocated.
See Also:
assurePolygonNormals()

assurePolygonColors

public void assurePolygonColors()
Assures respectively allocates correct length of polygon color array. Length of array is equal to length of polygon array.

assurePolygonNormals

public void assurePolygonNormals()
Assures respectively allocates correct length of polygon normal array. Length of array is equal to length of polygon array. Dimension of normal vectors is equal to dimension of vertices.

paint

public void paint(PvGeometryIf dc)
Major rendering method fills an internal container class supplied by the display. See jv.project.PgGeometryIf for detailed information.
Overrides:
paint in class PgPointSet
See Also:
PgGeometryIf

removeMarkedVertices

public int[] removeMarkedVertices()
Remove vertices marked with tag PsObject#IS_DELETED from polygons. It is neccessary to keep a valid polygon set after removal of vertices in the superclass.

Polygons with no or one remaining vertice are removed.

Overrides:
removeMarkedVertices in class PgPointSet
Returns:
array with indices of new positions of vertices
See Also:
PgPointSet.removeMarkedVertices()

removePolygon

public int[] removePolygon(int ind)
Remove polygon with given index, and decrement index of all polygons with higher index. Method just marks polygon with tag PsObject.IS_DELETED and invokes #removeMarkedPolygons().
Overrides:
removePolygon in class PgGeometry
Returns:
array with indices of new positions of polygons

removeMarkedPolygons

public int[] removeMarkedPolygons()
Remove all polygons which have been marked PsObject.IS_DELETED. E.g. after application of method close() polygons are no longer in use since polygons are shrunk at zero-length boundary curves. First, the method computes where each polygon is moved to, then all polygon data is moved and the references to the polygon in bnd curves is changed. This routine is O(n).

Method assumes that there exist no references to marked polygons. Otherwise application of this method would lead to upredictable results.

Returns:
array with indices of new positions of polygons

removeUnusedVertices

public boolean removeUnusedVertices()
Remove all points not referenced by polygons. First, the method computes where each point is moved to, then all point data is moved and the vertex indices are changed. This routine is O(n). The implementation is based on GRAPE method "sort-points-send" of B. Oberknapp.
Returns:
true if method was successfull

merge

public boolean merge(PgGeometryIf aGeom)
Merge polygon set with current object and store union of both objects in 'this'. Number of points and polygons is the sum of both objects.
Overrides:
merge in class PgPointSet
Parameters:
geom - Polygon set to be merged into 'this'
Returns:
true if method was successfull

getPolygonWithVertex

public int getPolygonWithVertex(int vertexInd)
Find first polygon referencing a given vertex.

clearTagPolygon

public void clearTagPolygon(int anIndex,
                            int aTag)
Clear a single tag of a polygon. For possible tags see PvGeometryIf.
Overrides:
clearTagPolygon in class PgGeometry

hasTagPolygon

public boolean hasTagPolygon(int anIndex,
                             int aTag)
Check whether polygon has given tag. For possible tags see PvGeometryIf.
Overrides:
hasTagPolygon in class PgGeometry

setTagPolygon

public void setTagPolygon(int anIndex,
                          int aTag)
Set a tag of a polygon. For possible tags see PvGeometryIf.
Overrides:
setTagPolygon in class PgGeometry

getPolygonVertices

public PdVector[] getPolygonVertices(int ind)
Get an array with pointers to all vertices of an polygon. Vertices appear in the array in the same order as in the polygon.
Returns:
Array with vertices, or null if vertices are not available.

getPolygon

public PiVector getPolygon(int anIndex)
Get a reference to an individual polygon array with vertex indices.
Overrides:
getPolygon in class PgGeometry
Returns:
Vector with indices, or null if index out of range.

getPolygonColor

public java.awt.Color getPolygonColor(int anIndex)
Get a reference to an individual polygon color.
Returns:
Vector with indices, or null if index out of range.

getPolygonNormal

public PdVector getPolygonNormal(int anIndex)
Get a reference to an individual polygon normal.
Returns:
Vector with indices, or null if index out of range.

setPolygonVertices

public boolean setPolygonVertices(int ind,
                                  PdVector[] vArray)
Copy new polygon vertices to polygon at specified position in the polygon list. Destination polygon must already exists.
Parameters:
ind - index of polygon
vArray - array with new coordinates of polygon vertices
Returns:
boolean false, if index out of range, or argument missing

setPolygon

public void setPolygon(int anIndex,
                       int a,
                       int b)
Copy new vertex indices to polygon at specified position in the polygon list. Number of polygons is increased if required. Dimension of polygons is adjusted if necessary.
Parameters:
anIndex - index of polygon
a,b - new vertex indices of polygon

setPolygon

public boolean setPolygon(int anIndex,
                          PiVector aPolygon)
Set index vector of polygon with given index. Copy new polygon to polygon at specified position in the polygon list. Number of polygons is increased if required. Size of polygon is adjusted if too small or too large.
Overrides:
setPolygon in class PgGeometry
Parameters:
anIndex - index of polygon
aPolygon - array with indices of new polygon
Returns:
boolean false, if index out of range, or argument missing

setPolygonColor

public boolean setPolygonColor(int anIndex,
                               java.awt.Color aColor)
Copy new color to polygon color at specified position in the color list
Parameters:
anIndex - index of vertex position
aColor - color to be copied to color list
Returns:
boolean false, if index out of range, or argument missing

setPolygonNormal

public boolean setPolygonNormal(int anIndex,
                                PdVector aNormal)
Copy new normal to polygon normal at specified position in the normal list
Parameters:
anIndex - index of polygon position
aNormal - normal to be copied to normal list
Returns:
boolean false, if index out of range, or argument missing

setPolygons

public void setPolygons(PiVector[] polygon)
Copy all polygons of polygon list to existing array of polygons. Length of argument polygon list must be equal or larger than getNumPolygons(). All polygons are copied.
Parameters:
polygon - array with new polygons

setPolygonColors

public void setPolygonColors(java.awt.Color[] color)
Copy polygon colors of list to existing array of polygon colors. Length of argument list must be equal or larger than getNumPolygons(). All polygon colors are copied. The dimension of all argument colors must be equal to getDimOfColors() of the geometry.
Parameters:
color - array with new polygon colors

setPolygonNormals

public void setPolygonNormals(PdVector[] normal)
Copy polygon normals of list to existing array of polygon normals. Length of argument list must be equal or larger than getNumPolygons(). All polygon normals are copied. The dimension of all argument normals must be equal to getDimOfVectors() of the geometry.
Parameters:
normal - array with new polygon normals

isClosed

public boolean isClosed(int ind)
Check whether polygon is closed, i.e.if endpoints are identical.
Returns:
flag whether polygon is closed, false if index out of bounds
See Also:
setClosed(int, boolean)

setClosed

public boolean setClosed(int ind,
                         boolean flag)
Close a polygon such that first and last vertex are identical. Size of polygon increases if end points where different.

The dimension of the polygon set may affected when closing multiple polygons of a set. Therefore, this method uses #assureDimOfPolygons to restore the dimension.

PgPolygonSet does not use a flag since PgPolygonSet uses explicit index vectors to determine the polygon. Therefore, the user may just add the first index at the end of the polygon to close it.

Parameters:
flag - true ensures identical endpoints of polygons
Returns:
false if index out of bounds
See Also:
isClosed(int)

getLengthOfPolygon

public double getLengthOfPolygon(int ind)
Compute length of a single polygon with given index.

getLength

public double getLength()
Compute total length of all polygons.

getVertexAngle

public double getVertexAngle(int ind,
                             int locInd)
Compute angle at vertex of polygon. If vertex index is 0 or length-1, then angle of closed polygon is taken.
Parameters:
ind - index of polygon
locInd - local index of vertex
Returns:
angle between edges at vertex

getNumEdges

public int getNumEdges()
Calculate total number of edges of all polygons.
Returns:
number of edges

blend

public boolean blend(double s,
                     PgGeometry ag,
                     double t,
                     PgGeometry bg)
Blend between two polygonSets, used in interpolation and computing the associate surfaces this = s*a + t*b.
Overrides:
blend in class PgPointSet
Parameters:
double - s, t weights of vertices of each polygonSet
PgPolygonSet - a, b two polygonSets used for blending
Returns:
true on success

intersectionWithLine

public PvPickEvent intersectionWithLine(PdVector rayBase,
                                        PdVector rayDir)
Find intersection of polygon set with a given ray. Closest polygon edge is located. Method is used for interactive picking.
Overrides:
intersectionWithLine in class PgPointSet
Parameters:
rayBase - base point of ray eventually hitting the polygon set
rayDir - direction point of ray eventually hitting the polygon set
Returns:
full information about hit polygon, barycentric coordinates etc.

makeNormals

public void makeNormals()
Compute normals at vertices as edge bisectors with unit length. All normals are oriented to show to the same side of the polygon as the first normal which is non-degenerate.

This method correctly handles polygons with sequences of parallel edges and multiple vertices.


makeBiNormals

public void makeBiNormals()
Compute binormals at vertices which are orthogonal to both adjacent edges. All binormals lie in the span of the two edges of a vertex and all binormals have the same orientation as the normal vector of the enclosed patch surface.

This method correctly handles polygons with sequences of parallel edges and multiple vertices.


makeOffsetNormals

public void makeOffsetNormals()
Compute normals at vertices as edge bisectors whose tip lies on an offset==1 curve. All normals are oriented to show to the same side of the polygon as the first normal which is non-degenerate.

This method correctly handles polygons with sequences of parallel edges and multiple vertices.


makeCurvatureNormals

public void makeCurvatureNormals()
Compute normals at vertices as edge bisectors with length equal to (Pi-vertexAngle). All normals are oriented to show to the same side of the polygon as the first normal which is non-degenerate.

This method correctly handles polygons with sequences of parallel edges and multiple vertices.


makeNormals

public void makeNormals(int type,
                        double length)
Compute normals at vertices which lie in the span of the adjacent edges. All normals are oriented to show to the same side of the polygon as the first normal which is non-degenerate.

This method correctly handles polygons with sequences of parallel edges and multiple vertices.


makePolygonColorsFromXYZ

public boolean makePolygonColorsFromXYZ()
Create color from the edge position within its bounding box which is interpreted as RGB cube. If dimension of vertices is smaller than three then only the first vertex components are used in the color computation.

makePolygonColorsFromZ

public boolean makePolygonColorsFromZ()
Create color from the vertical z-height within its bounding box ranging from red to blue. If dimension of vertices is smaller than three then the highest vertex component are used instead of the z-component in the color computation.

makePolygonColorsFromZHue

public boolean makePolygonColorsFromZHue()
Create color from the vertical z-height within its bounding box ranging through hue rainbow. If dimension of vertices is smaller than three then the highest vertex component are used instead of the z-component in the color computation.

JavaView® v2.12

The software JavaView® is copyright protected. All Rights Reserved.