JavaView© v3.95.000

jv.geom
Class PgPolygonSet

java.lang.Object
  extended byjv.object.PsObject
      extended byjv.project.PgGeometry
          extended byjv.geom.PgPointSet
              extended byjv.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.

See Also:
Serialized Form

Field Summary
static int BINORMAL
           
static int CURVATURE_NORMAL
           
static int NORMAL
           
static int OFFSET_NORMAL
           
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, 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, HAS_METHOD_MENU, 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, m_numLabelTypes, 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 poly)
          Add new polygon to the end of the polygon list.
 boolean applyModelingMatrix()
          Multiply the modeling matrix to all vertices and vectors.
 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.
 void assurePolygonSizes()
          Assures respectively allocates correct length of polygon size vector.
 boolean blend(double s, PgGeometry ag, double t, PgGeometry bg)
          Blend between two polygon sets using this = s*ag + t*bg.
 void clearTagPolygon(int ind, 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.
static PgPolygonSet convert(PgPolygon poly)
          Convert a PgPolygon into a PgPolygonSet.
 void copy(PsObject object)
          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.
 void flipOrientation()
          Change orientation of the polygon, i.e. the end point becomes the first point.
 int getDimOfPolygons()
          Retrieve number of vertices per polygon, if it is the same for all polygons, otherwise return -1.
 int[] getFVector()
          Compute F-vector that is the number of points, edges, faces, etc.
 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 getMaxDimOfPolygons()
          Get maximal number of vertices appearing in a polygon.
 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 ind)
          Get a reference to an individual polygon array with vertex indices.
 java.awt.Color getPolygonColor(int ind)
          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 ind)
          Get a reference to an individual polygon normal.
 PdVector[] getPolygonNormals()
          Get polygon 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.
 double getPolygonSize(int ind)
          Get size of a single polygon.
 PdVector getPolygonSizes()
          Get polygon size 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 hasPolygonSizes()
          Check if polygon sizes have been allocated.
 boolean hasTagPolygon(int ind, 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 isShowingEdgeFromVertexColors()
          Determines whether smooth edge coloring uses vertex colors at vertices, requires vertex colors.
 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 isShowingPolygonSizes()
          Set flag to enable usage of polygon sizes.
 boolean isShowingPolygonStartArrow()
          Determines whether drawing of arrow at first point of polygon is enabled.
 boolean isShowingSmoothEdgeColors()
          Determines whether smooth coloring of polygons is enabled, currently requires vertex colors.
 boolean isShowingSmoothLighting()
          Determines whether smooth lighting is enabled, requires vertex normals.
 boolean isShowingTaggedPolygons()
          Determine whether showing of tagged polygons 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()
          Deprecated. since JavaView 3.50.002, use makeVertexNormals().
 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 makePolygonColorsFromLength()
          Create polygon color from the polygon length ranging through hue rainbow.
 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 low blue to high red.
 boolean makePolygonColorsFromZHue()
          Create color from the vertical z-height within its bounding box ranging through hue rainbow.
 boolean makePolygonFromVertexColors()
          Create polygon colors as average of the color of its vertices.
 boolean makeVertexColorsFromLength()
          Create vertex color from the polygon length ranging through hue rainbow.
 boolean makeVertexFromPolygonColors()
          Create vertex colors as average of color of all adjacent polygons.
 boolean makeVertexNormals()
          Compute normals at vertices as edge bisectors with unit length.
 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.
 void removePolygonColors()
          Remove local polygon colors from a geometry and use global polygon color instead.
 void removePolygonNormals()
          Remove local polygon normals from a geometry.
 void removePolygonSizes()
          Remove polygon sizes from a geometry.
 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 setDimOfVertices(int dim)
          Set dimension of vertices.
 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 numPolygons)
          Allocate given number of polygons, and allocate normals, colors etc.
 void setPolygon(int ind, int a, int b)
          Copy new vertex indices to polygon at specified position in the polygon list.
 boolean setPolygon(int ind, PiVector aPolygon)
          Set index vector of polygon with given index.
 boolean setPolygonColor(int ind, 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 ind, 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 setPolygonSize(int ind, double size)
          Set the thickness of the given polygon.
 void setPolygonSizes(PdVector size)
          Copy polygon sizes of list to existing array of polygon sizes.
 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)
          Set number of vertices of a specific polygon.
 void setTagPolygon(int ind, int aTag)
          Set a tag of a polygon.
 void showEdgeFromVertexColors(boolean flag)
          Set flag to enable smooth edge coloring using vertex colors at vertices, requires vertex colors.
 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 showPolygonSizes(boolean flag)
          Set flag to enable usage of individual polygon sizes.
 void showPolygonStartArrow(boolean flag)
          Set flag to enable drawing of arrow at first point of polygons.
 void showSmoothEdgeColors(boolean flag)
          Set flag to enable smooth coloring of edges, currently requires vertex colors.
 void showSmoothLighting(boolean flag)
          Set flag to enable smooth lighting, requires vertex normals.
 void showTaggedPolygons(boolean flag)
          Set flag to enable drawing of tagged polygons.
 java.lang.String toString()
          Create a multi-line string representation with detailed information about all instance variables.
 PiVector[] triangulate()
          The method triangulates the polygon patches by successively removing the vertex with the smallest interior angle.
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 void useGlobalPolygonColor(boolean flag)
          Deprecated. use showPolygonColors(boolean)
 
Methods inherited from class jv.geom.PgPointSet
addVectorField, addVertex, applyAmbientMatrix, assureVertexColors, assureVertexNormals, assureVertexSizes, assureVertexTextures, clearTagVertex, computeCone, computeCylinder, computeDisk, computePlane, computeRotation, computeSnail, computeSphere, computeTorus, getAmbientBounds, getBounds, getCenterOfBndBox, getCenterOfGravity, getDimOfColors, getDimOfTextures, getDimOfVectors, getEulerCharacteristic, getGlobalVectorColor, getGlobalVectorLength, getGlobalVectorSize, getGlobalVertexColor, getGlobalVertexNormalColor, getGlobalVertexNormalLength, getGlobalVertexNormalSize, getGlobalVertexSize, getGlobalVertexTagColor, getIndexOfVectorField, getMarkedVertices, getMaxNumVertices, getNumVectorFields, getNumVertices, getSelectedVectorField, getShininess, getSpecularColor, getTexture, getTextureImage, getTextureImageName, getTransparency, getVectorField, getVectorField, getVertex, getVertexColor, getVertexColors, getVertexNormal, getVertexNormals, getVertexSize, getVertexSizes, getVertexTexture, getVertexTextures, getVertices, hasTagVertex, hasVertex, hasVertex, hasVertexColors, hasVertexNormals, hasVertexSizes, hasVertexTextures, isDefaultLabelEnabled, isEnabledIndexLabels, isShowingIndices, isShowingSingleVectorField, isShowingTaggedVertices, isShowingTransparency, isShowingVectorArrow, isShowingVectorArrows, isShowingVectorColors, isShowingVectorField, isShowingVectorFields, isShowingVertexColors, isShowingVertexLabels, isShowingVertexNormalArrow, isShowingVertexNormals, isShowingVertexOutline, isShowingVertexSizes, isShowingVertexTexture, isShowingVertices, makeColorFromVectorLength, makeQuadrVertexTexture, makeVertexColorsFromXYZ, makeVertexColorsFromZ, makeVertexColorsFromZHue, makeVertexTextureFromBndBox, makeVertexTextureFromCylinder, makeVertexTextureFromSphere, makeVertexTextureFromUV, projectFromAmbientSpace, projectToSphere, reflect, removeAllVectorFields, removeHiddenVectorFields, removeTexture, removeVectorField, removeVertex, removeVertexColors, removeVertexNormals, removeVertexSizes, scale, scale, selectVectorField, setCenterOfBndBox, setDefaultLabelEnabled, setDimOfTextures, setEnabledIndexLabels, setGlobalVectorColor, setGlobalVectorLength, setGlobalVectorSize, setGlobalVertexColor, setGlobalVertexNormalColor, setGlobalVertexNormalLength, setGlobalVertexNormalSize, setGlobalVertexSize, setGlobalVertexSize, setGlobalVertexTagColor, setNumVertices, setShininess, setSpecularColor, setState, setTagVertex, setTexture, setTextureImage, setTextureImageName, setTransparency, setVertex, setVertex, setVertex, setVertex, setVertexColor, setVertexColors, setVertexNormal, setVertexNormals, setVertexSize, setVertexSizes, setVertexTexture, setVertexTextures, setVertices, showIndices, showSingleVectorField, showTaggedVertices, showTransparency, showVectorArrow, showVectorArrows, showVectorColors, showVectorField, showVectorFields, showVertexColors, showVertexLabels, showVertexNormalArrow, showVertexNormals, showVertexOutline, showVertexSizes, showVertexTexture, showVertices, translate
 
Methods inherited from class jv.project.PgGeometry
addDisplay, addElement, clearTagElement, fillMethodMenu, fillMethodMenu, getAmbientInvMatrix, getAmbientMatrix, getAmbientProjection, getAmbientSpace, getAuthorInfo, getAuthors, getCenter, getCenterOfElement, getControlPanel, getDiameter, getDimOfSimplex, getDimOfVertices, getDisplayList, getDisplays, getElement, getGeometryInfo, getLabelAttribute, getLabelColor, getLabelFont, getLabelSize, getLabelStyle, getMaterialPanel, getModelMatrix, getState, getTitle, getType, getVersion, getVersionType, hasAmbientMatrix, hasDisplay, hasModelMatrix, hasTagElement, isConfigurable, isEnabledInstanceSharing, isShowingBndBox, isShowingCenter, isShowingName, isShowingTitle, isVisible, removeDisplay, removeElement, removeMethodMenus, setAmbientMatrix, setAmbientProjection, setAmbientSpace, setAuthorInfo, setAuthors, setCenter, setDimOfSimplex, setElement, setEnabledInstanceSharing, setGeometryInfo, setLabelAttribute, setLabelAttribute, setLabelColor, setLabelFont, setLabelSize, setLabelStyle, setModelMatrix, setTagElement, setTitle, setType, setVersion, setVersionType, setVisible, showBndBox, showCenter, showName, showTitle
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, 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, hasTag, setName
 
Methods inherited from interface jv.object.PsUpdateIf
getFather, setParent
 

Field Detail

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

BINORMAL

public static final int BINORMAL
See Also:
Constant Field Values

OFFSET_NORMAL

public static final int OFFSET_NORMAL
See Also:
Constant Field Values

CURVATURE_NORMAL

public static final int CURVATURE_NORMAL
See Also:
Constant Field Values
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.

Specified by:
getJvx in interface PgGeometryIf
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.

Specified by:
setJvx in interface PgGeometryIf
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.

Specified by:
clone in interface PgGeometryIf
Overrides:
clone in class PgPointSet
See Also:
copy(PsObject)

copy

public void copy(PsObject object)
Copy instance variables by duplication, not by copying a reference.

The argument was changed from PgGeometry to PsObject since there were problems in J/Link which preferred to use jv.object.PsObject#copy(PsObject) instead of jv.project.PgGeometry#copy(PsObject).

Overrides:
copy in class PgPointSet
See Also:
clone()

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.

Specified by:
toString in interface PgGeometryIf
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.

Specified by:
update in interface PsUpdateIf
Overrides:
update in class PgPointSet

applyModelingMatrix

public boolean applyModelingMatrix()
Multiply the modeling matrix to all vertices and vectors. The modeling matrix of this geometry is set to the identity matrix.

Overrides:
applyModelingMatrix in class PgPointSet
Returns:
true if operation was applied successfully.
Since:
JavaView 2.36

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 poly)
Add new polygon to the end of the polygon list. Method just calls setPolygon(numPolygons, PiVector).

Specified by:
addPolygon in interface PgGeometryIf
Overrides:
addPolygon in class PgGeometry
Parameters:
poly - polygon to be added to polygon list
Returns:
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.


getPolygonNormals

public PdVector[] getPolygonNormals()
Get polygon normal array for read and write access, but do not modify the size of any normal vector.


getPolygonSizes

public PdVector getPolygonSizes()
Get polygon size array for read and write access.


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.


isShowingPolygonSizes

public boolean isShowingPolygonSizes()
Set flag to enable usage of polygon sizes.


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.


isShowingTaggedPolygons

public boolean isShowingTaggedPolygons()
Determine whether showing of tagged polygons is enabled.


showTaggedPolygons

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


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.


showPolygonSizes

public void showPolygonSizes(boolean flag)
Set flag to enable usage of individual polygon sizes.


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.


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 numPolygons)
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)
Set number of vertices of a specific polygon. Polygon must exist already, and index of polygon must be in range [0,m_numPolygons-1]. Method may modify instance variable m_dimOfPolygons.

Parameters:
ind - Index of polygon.
aSize - Number of vertices given polygon.
See Also:
setNumPolygons(int)

setDimOfVertices

public void setDimOfVertices(int dim)
Set dimension of vertices. Make rare use, and try to assign dimension of vertices already in the constructor.

Overrides:
setDimOfVertices in class PgPointSet

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)

getMaxDimOfPolygons

public int getMaxDimOfPolygons()
Get maximal number of vertices appearing in a polygon. Method returns the same value as getDimOfPolygons() if all polygons have the same size.

Since:
JavaView 2.84.000
See Also:
getDimOfPolygons()

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()

hasPolygonSizes

public boolean hasPolygonSizes()
Check if polygon sizes have been allocated.

See Also:
assurePolygonSizes()

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.

Specified by:
paint in interface PgGeometryIf
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().

Specified by:
removePolygon in interface PgGeometryIf
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. 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).

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.

The merged geometry will local colors allocated and assignd if

		1. both the global color of both geometries are different, or
		2. either geometry has local colors.
 
If local colors are allocated but one of the geometries does not have local colors then its local colors are be assumed to be its global color. The merged geometry will show globalVertexColors if
		1. the global color of both geometries is the same, and
		2. both geometries are showing the global color.
 
In all other cases the merged geometry will show local colors. The global color of the merged geometry is never changed.

Specified by:
merge in interface PgGeometryIf
Overrides:
merge in class PgPointSet
Parameters:
aGeom - 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 ind,
                            int aTag)
Clear a single tag of a polygon. For possible tags see PvGeometryIf.

Specified by:
clearTagPolygon in interface PgGeometryIf
Overrides:
clearTagPolygon in class PgGeometry

hasTagPolygon

public boolean hasTagPolygon(int ind,
                             int aTag)
Check whether polygon has given tag. For possible tags see PvGeometryIf.

Specified by:
hasTagPolygon in interface PgGeometryIf
Overrides:
hasTagPolygon in class PgGeometry

setTagPolygon

public void setTagPolygon(int ind,
                          int aTag)
Set a tag of a polygon. For possible tags see PvGeometryIf.

Specified by:
setTagPolygon in interface PgGeometryIf
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 ind)
Get a reference to an individual polygon array with vertex indices.

Specified by:
getPolygon in interface PgGeometryIf
Overrides:
getPolygon in class PgGeometry
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 ind,
                       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:
ind - index of polygon
a - index of first vertex of new polygon edge
b - index of second vertex of new polygon edge

setPolygon

public boolean setPolygon(int ind,
                          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.

Specified by:
setPolygon in interface PgGeometryIf
Overrides:
setPolygon in class PgGeometry
Parameters:
ind - index of polygon
aPolygon - array with indices of new polygon
Returns:
false, if index out of range, or argument missing

getPolygonColor

public java.awt.Color getPolygonColor(int ind)
Get a reference to an individual polygon color.

Returns:
Vector with indices, or null if index out of range.

setPolygonColor

public boolean setPolygonColor(int ind,
                               java.awt.Color aColor)
Copy new color to polygon color at specified position in the color list

Parameters:
ind - index of polygon
aColor - color to be copied to color list
Returns:
false, if index out of range, or argument missing

getPolygonNormal

public PdVector getPolygonNormal(int ind)
Get a reference to an individual polygon normal.

Returns:
Vector with indices, or null if index out of range.

setPolygonNormal

public boolean setPolygonNormal(int ind,
                                PdVector aNormal)
Copy new normal to polygon normal at specified position in the normal list

Parameters:
ind - index of polygon
aNormal - normal to be copied to normal list
Returns:
false, if index out of range, or argument missing

getPolygonSize

public double getPolygonSize(int ind)
Get size of a single polygon.

Returns:
Thickness of specified polygon.

removePolygonSizes

public void removePolygonSizes()
Remove polygon sizes from a geometry.

Showing of polygon sizes must be switched off explicitly using showPolygonSizes(boolean).

Since:
JavaView 3.09

setPolygonSize

public boolean setPolygonSize(int ind,
                              double size)
Set the thickness of the given polygon.

Parameters:
ind - index of polygon
size - thickness of polygon
Returns:
false, if index out of range, or argument missing

setPolygonSizes

public void setPolygonSizes(PdVector size)
Copy polygon sizes of list to existing array of polygon sizes. Length of argument list must be equal or larger than getNumPolygons(). All polygon sizes are copied.

Showing of polygon sizes must be switched on in order to be visible.

Parameters:
size - array with new polygon size for all polygons
Since:
JavaView 3.09

assurePolygonSizes

public void assurePolygonSizes()
Assures respectively allocates correct length of polygon size vector. Length of vector is equal to length of polygon array. Dimension of size vector is equal to maximal number of vertices.

Since:
JavaView 3.09

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

removePolygonColors

public void removePolygonColors()
Remove local polygon colors from a geometry and use global polygon color instead.

Showing of polygon colors must be switched off explicitly using showPolygonColors(boolean).


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

removePolygonNormals

public void removePolygonNormals()
Remove local polygon normals from a geometry.

Showing of polygon normals must be switched off explicitly using showPolygonColors(boolean).


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 be 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 polygon sets using this = s*ag + t*bg.

Specified by:
blend in interface PgGeometryIf
Overrides:
blend in class PgPointSet
Parameters:
s - weight of vertices of first geometry
ag - first geometry used for blending
t - weight of vertices of second geometry
bg - second geometry 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.

Specified by:
intersectionWithLine in interface PgGeometryIf
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.

makeVertexNormals

public boolean makeVertexNormals()
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.

Overrides:
makeVertexNormals in class PgPointSet

makeNormals

public void makeNormals()
Deprecated. since JavaView 3.50.002, use makeVertexNormals().

Compute normals at vertices as edge bisectors with unit length.


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 low blue to high red. If dimension of vertices is smaller than three then the highest vertex component is 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 is used instead of the z-component in the color computation.


getFVector

public int[] getFVector()
Compute F-vector that is the number of points, edges, faces, etc.

Overrides:
getFVector in class PgPointSet

triangulate

public PiVector[] triangulate()
The method triangulates the polygon patches by successively removing the vertex with the smallest interior angle. The method can handle non-convex polygons.

Returns:
Array of vectors each containing the vertex indices of a triangle.

flipOrientation

public void flipOrientation()
Change orientation of the polygon, i.e. the end point becomes the first point. This method just multiplies each normal vector with -1 and, therefore, must be overwritten by subclasses such as PgElementSet and PgPolygon.

Overrides:
flipOrientation in class PgPointSet

isShowingSmoothLighting

public boolean isShowingSmoothLighting()
Determines whether smooth lighting is enabled, requires vertex normals.

Since:
JavaView 2.69

showSmoothLighting

public void showSmoothLighting(boolean flag)
Set flag to enable smooth lighting, requires vertex normals.

Since:
JavaView 2.69

isShowingSmoothEdgeColors

public boolean isShowingSmoothEdgeColors()
Determines whether smooth coloring of polygons is enabled, currently requires vertex colors.

Since:
JavaView 2.69

showSmoothEdgeColors

public void showSmoothEdgeColors(boolean flag)
Set flag to enable smooth coloring of edges, currently requires vertex colors.

Since:
JavaView 2.69

isShowingEdgeFromVertexColors

public boolean isShowingEdgeFromVertexColors()
Determines whether smooth edge coloring uses vertex colors at vertices, requires vertex colors.

Since:
JavaView 2.69

showEdgeFromVertexColors

public void showEdgeFromVertexColors(boolean flag)
Set flag to enable smooth edge coloring using vertex colors at vertices, requires vertex colors.

Since:
JavaView 2.69

makePolygonFromVertexColors

public boolean makePolygonFromVertexColors()
Create polygon colors as average of the color of its vertices. Vertex colors must be available.

Since:
JavaView 2.69

makeVertexFromPolygonColors

public boolean makeVertexFromPolygonColors()
Create vertex colors as average of color of all adjacent polygons. Polygon colors must be available.

Since:
JavaView 2.69

makePolygonColorsFromLength

public boolean makePolygonColorsFromLength()
Create polygon color from the polygon length ranging through hue rainbow. If polygon is closed then both end points have the same color red, otherwise color ranges from red to bluish.

Since:
JavaView 2.70

makeVertexColorsFromLength

public boolean makeVertexColorsFromLength()
Create vertex color from the polygon length ranging through hue rainbow. If polygon is closed then both end points have the same color red, otherwise color ranges from red to bluish.

Since:
JavaView 2.70

convert

public static PgPolygonSet convert(PgPolygon poly)
Convert a PgPolygon into a PgPolygonSet. The polygon is converted to a single polygon in the new set, therefore, individual edge settings are ignored.

Since:
JavaView 3.11.003

JavaView© v3.95.000

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