JavaView® v2.12

jv.geom
Class PgPointSet

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

public class PgPointSet
extends PgGeometry

Base class for most geometric objects with points resp. vertices, for example point sets, polygons, element set, and other simplicial complexes.

The class has an array of n-dimensional points where each point is an instance of type PdVector containing the n coordinate components. Additionally, there exist instance variables for vertex normals, vertex colors, vertex texture coordinates, and other vertex properties. Note, that such vertex properties are not stored with each vertex but each property is stored in an additional array of same length as the array of vertices. If a property is not available then the corresponding array is null.

The dimension of all points is determined as argument of the constructor and cannot be changed later. The dimension is the same for all points of the point set. There exist several utility functions to allocate and modify the number of points, for example,

	setNumVertices(int)
 
allocates num vertices. 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 vertices is changed, the class automatically adjusts the size of those vertex properties which are currently in use, i.e. whose array is not null.

Applications may modify the coordinates of vertices and of vertex properties by direct method calls such as

	setVertex(int, PdVector)
 
which sets the vertex with index ind equal to the vertex v by copying the coordinates. Alternatively, if an application modifies a larger number of vertices then the application may prefer to obtain the coordinate array from the point set and directly modify the array
	PdVector [] vertex = pointSet.getVertices();
	for (int i=0; i<pointSet.getNumVertices(); i++)
		vertex[i].copy(v);
 
The same choice is available for arrays containing vertex properties. Note, that subclasses, such as PgElementSet, may not reference all vertices, e.g. if the currently active elements consists of a subset of all vertices. Also note, that the actual size of the vertex array may differ from m_numVertices efficiency reasons. Therefore, do not use vertex.length but use getNumVertices().

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

Version:
21.09.01, 3.03 revised (ur) Call VectorField.setGeometry in method copy for Vertex-based VectorFields only.
12.09.01, 3.02 revised (ep) Copy vector fields in copy-method.
14.08.01, 3.01 revised (ep) Set vector field names in setJvx.
19.05.01, 3.00 revised (kp) Vector field handling slightly revised.
12.02.00, 2.90 revised (ep) Compute vertex normals in computePlane only if dim==3.
21.07.00, 2.80 revised (kp) Global properties of normals splitted into vertex and element part.
19.07.00, 2.65 revised (kp) Flag and methods to enable drawing of default labels added.
18.07.00, 2.61 revised (kp) Instance variable m_useGlobalVertexColor renamed to m_bShowVertexColors.
18.07.00, 2.60 revised (kp) Instance variable m_useGlobalVectorColor renamed to m_bShowVectorColors.
25.04.00, 2.50 revised (kp) Members+Methods userData renamed to vectorField.
16.04.00, 2.10 revised (ep)
02.04.00, 2.00 revised (kp) PdColor replaced with Color in lists.
18.09.99, 1.10 revised (kp) Showing of vectorfields separated from user data.
20.02.99, 1.02 revised (kp) init() method enabled as reset method.
03.01.99, 1.01 revised (kp) set of get-methods implemented, texture.
01.09.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
Serialized Form

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
PgPointSet()
          Constructor of a point set in three-dimensional space.
PgPointSet(int aVertexDim)
          Constructor of a point set in n-dimensional space.
 
Method Summary
 int addVectorField(PgVectorField aVectorField)
          Add a vertex or element based vector field to geometry.
 int addVertex(PdVector aVertex)
          Add new vertex to the end of the vertex list Method just calls setVertex(int, PdVector).
 void assureVertexColors()
          Assures respectively allocates correct length of vertex color array.
 void assureVertexNormals()
          Assures respectively allocates correct length of vertex normal array.
 void assureVertexTextures()
          Assures respectively allocates correct length of vertex texture array.
 boolean blend(double s, PgGeometry ag, double t, PgGeometry bg)
          Blend between two pointSets, used in interpolation and computing the associate surfaces this = s*a + t*b.
 void clearTagVertex(int anIndex, int aTag)
          Clear a single tag of a vertex.
 java.lang.Object clone()
          Duplicate geometry by recursively cloning all instance variables except inspector panels and lists of registered listeners.
 void computeCylinder(int numULines, int numVLines, double radius, double length)
          Generate cylinder in z-direction with given radius and length.
 void computeDisk(int numULines, int numVLines, double radius)
          Generate disk in xy-plane with given radius.
 void computePlane(int numULines, int numVLines, double uMin, double vMin, double uMax, double vMax)
          Generate rectangle in z=0 plane with given min/max values.
 void computeRotation(PgPolygon meridian, int numULines)
          Generate rotational symmetric surface from given meridian around x-axis.
 void computeSnail(int numULines, int numVLines, double numWindings)
          Generate a winding snail.
 void computeSphere(int numULines, int numVLines, double radius)
          Generate sphere at origin with given radius.
 void computeTorus(int numULines, int numVLines, double radius, double thick)
          Generate torus in x-y plane with given radius of soal and thickness of tube.
 void copy(PgGeometry aGeom)
          Copy instance variables by duplication, not by copying a reference.
 void flipOrientation()
          Change orientation of normal vectors.
 PdVector[] getAmbientBounds()
          Compute bounding box of this geometry from the set of all vertices, or return null if no vertices.
 PdVector[] getBounds()
          Compute bounding box of the vertices which are transformed with ambient and model matrix.
 PdVector getCenterOfBndBox()
          Compute center of geometry as midpoint of the bounding box.
 PdVector getCenterOfGravity()
          Compute center of geometry as the mean all vertices, i.e. center of gravity.
 int getDimOfColors()
          Get dimension of colors, i.e. number of components of each color vector.
 int getDimOfTextures()
          Get dimension of textures, i.e. number of components of each of the texture vectors.
 int getDimOfVectors()
          Get dimension of vectors, i.e. number of components of each of the vectors.
 java.awt.Color getGlobalVectorColor()
          Get global vector color which is used if no local colors are available.
 double getGlobalVectorLength()
          Get length factor of vectors when drawn in display.
 double getGlobalVectorSize()
          Get thickness in pixels of vectors when drawn in display.
 java.awt.Color getGlobalVertexColor()
          Get global vertex color which is used if no local colors are available.
 java.awt.Color getGlobalVertexNormalColor()
          Get global vertex normal color which is used if no local colors are available.
 double getGlobalVertexNormalLength()
          Get length factor of vertex normal vectors when drawn in display.
 double getGlobalVertexNormalSize()
          Get thickness in pixels of vertex normals when drawn in display.
 int getGlobalVertexSize()
          Get global radius in pixels of circle to visualize vertices in display.
 java.awt.Color getGlobalVertexTagColor()
          Get global color of tagged vertices.
 int getIndexOfVectorField(PgVectorField aVectorField)
          Get index of vector fields, assumes user data is stored in a vector.
 PgJvxSrc getJvx()
          Fills a geometry container with data from this instance, for example, to print to file.
 int getMaxNumVertices()
          Get total length of allocated vertex array.
 int getNumVectorFields()
          Get number of vector fields.
 int getNumVertices()
          Get number of vertices in vertex array.
 PgTexture getTexture()
          Get current texture of surface.
 java.awt.Image getTextureImage()
          Get image of texture.
 java.lang.String getTextureImageName()
          Get name of texture image, a full URL or a relative file name.
 PgVectorField getVectorField(int anInd)
          Get a vector field via its index.
 PgVectorField getVectorField(java.lang.String name)
          Get a vector field via its name.
 PdVector getVertex(int anIndex)
          Get a reference to an individual vertex.
 java.awt.Color getVertexColor(int anIndex)
          Get a reference to an individual vertex color.
 java.awt.Color[] getVertexColors()
          Get color array for read and write access, but do not modify the size of any color vector.
 PdVector getVertexNormal(int anIndex)
          Get a reference to an individual vertex normal.
 PdVector[] getVertexNormals()
          Get vertex normal array for read and write access, but do not modify the size of any normal vector.
 PdVector[] getVertexTextures()
          Get vertex texture array for read and write access, but do not modify the size of any texture vector.
 PdVector[] getVertices()
          Get vertex array for read and write access, but do not modify the size of any vector.
 boolean hasTagVertex(int anIndex, int aTag)
          Check whether vertex has given tag.
 int hasVertex(PdVector aVertex)
          Looks in the vertex list if there is a vertex with same coordinates like the passed one.
 int hasVertex(PdVector aVertex, double eps)
          Looks in the vertex list if there is a vertex within a given euclidean distance.
 boolean hasVertexColors()
          Check if vertex colors have been allocated.
 boolean hasVertexNormals()
          Check if vertex normals have been allocated.
 boolean hasVertexTextures()
          Check if vertex textures have been allocated.
 void init()
          Initialize and reset instance variables after call to super.init().
 PvPickEvent intersectionWithLine(PdVector rayBase, PdVector rayDir)
          Find intersection of this point set with a given ray.
 boolean isDefaultLabelEnabled()
          Determine whether drawing of default labels, i.e. item indices, is enabled.
 boolean isShowingIndices()
          Check whether showing of indices is switched on.
 boolean isShowingTaggedVertices()
          Determine whether showing of tagged vertices is enabled.
 boolean isShowingVectorArrow()
          Deprecated. use isShowingVectorArrows(boolean)
 boolean isShowingVectorArrows()
          Determine whether showing of tip of vectors as arrow is enabled.
 boolean isShowingVectorColors()
          Determine whether showing of vertex normals is enabled.
 boolean isShowingVectorField()
          Determine whether showing of vectorfields is enabled.
 boolean isShowingVertexColors()
          Determine whether showing of vertex colors is enabled.
 boolean isShowingVertexLabels()
          Determine whether showing of vertex labels is enabled.
 boolean isShowingVertexNormalArrow()
          Determines whether drawing of arrow of vertex normals is enabled.
 boolean isShowingVertexNormals()
          Determine whether showing of vertex normals is enabled.
 boolean isShowingVertexTexture()
          Determine whether showing of vertex textures is enabled.
 boolean isShowingVertices()
          Determine whether showing of vertices is enabled.
 boolean makeColorFromVectorLength()
          Create color from the length of vectors of the first vector field.
 boolean makeVertexColorsFromXYZ()
          Create color from the vertex position within its bounding box which is interpreted as RGB cube.
 boolean makeVertexColorsFromZ()
          Create color from the vertical z-height within its bounding box ranging from red to blue.
 boolean makeVertexColorsFromZHue()
          Create color from the vertical z-height within its bounding box ranging through hue rainbow.
 boolean makeVertexNormals()
          Method does nothing and should be overwritten by subclasses.
 boolean makeVertexTextureFromBndBox(int ix, int iy)
          Create vertex texture from a plane of the bounding box.
 boolean makeVertexTextureFromCylinder(PdVector center, PdVector axis)
          Create vertex texture from cylinder with given axis.
 boolean makeVertexTextureFromSphere(PdVector center)
          Create vertex texture from sphere with given center.
 boolean merge(PgGeometryIf aGeom)
          Merge two point sets and store union in this.
 void paint(PvGeometryIf dc)
          Major rendering method fills an internal container class supplied by the display.
 void projectToSphere(PdVector center, double radius)
          Project all vertices to the unit sphere with given center.
 PgGeometry reflect(PdMatrix mat, boolean bOrient, boolean bVector)
          Generate a cloned geometry and transform vertices by a matrix.
 void removeAllVectorFields()
          Remove all user added vector fields.
 int[] removeMarkedVertices()
          Remove vertices marked with tag PsObject#IS_DELETED from the vertex list.
 boolean removeVectorField(PgGeometryIf aVectorField)
          Remove a vector field from geometry.
 int[] removeVertex(int ind)
          Remove vertex at specified position in the vertex list.
 void scale(double factor)
          Scale each vertex of geometry by given factor w.r.t. its center using formula: vertex = (1-s)*center + s*vertex.
 void scale(double factor, PdVector center)
          Deprecated. use scale(double) instead
 void setCenterOfBndBox(PdVector center)
          Move each vertex of geometry by vector center-oldCenter.
 void setDefaultLabelEnabled(boolean flag)
          Determine whether drawing of default labels, i.e. item indices, is enabled.
 void setDimOfColors(int aSize)
          Let all colors have same number of components aSize<>0.
 void setDimOfTextures(int dim)
          Set dimension of texture domain.
 void setDimOfVectors(int aSize)
          Let all vectors have same number of components aSize<>0.
 void setGlobalVectorColor(java.awt.Color color)
          Set global vector color to be used if no local colors are available.
 void setGlobalVectorLength(double length)
          Get length factor of vectors when drawn in display.
 void setGlobalVectorSize(double size)
          Get thickness in pixels of vectors when drawn in display.
 void setGlobalVertexColor(java.awt.Color color)
          Set global vertex color to be used if no local colors are available.
 void setGlobalVertexNormalColor(java.awt.Color color)
          Set global vertex normal color to be used if no local colors are available.
 void setGlobalVertexNormalLength(double length)
          Get length factor of vertex normal vectors when drawn in display.
 void setGlobalVertexNormalSize(double size)
          Get thickness in pixels of vertex normals when drawn in display.
 void setGlobalVertexSize(int size)
          Set global radius in pixels of circle to visualize vertices in display.
 void setGlobalVertexTagColor(java.awt.Color color)
          Set global color of tagged vertices.
 void setJvx(PgJvxSrc src)
          Fill this instance with data from a geometry source, for example, previously read from file.
 void setNumVertices(int aNumVertices)
          Allocate given number of vertices, and allocate normals, colors etc. if they already exist.
 void setState(int aKey, boolean aState)
          Set drawing flags of this geometry from within the display.
 void setTagVertex(int anIndex, int aTag)
          Set a tag of a vertex.
 void setTexture(PgTexture texture)
          Set current texture of surface with reference to texture image.
 void setTextureImage(java.awt.Image image)
          Set texture image for vertex and element textures.
 void setTextureImageName(java.lang.String name)
          Set name of texture image, a URL or a relative file name.
 void setTransparency(double alpha)
          Set transparency of surface to be used in textures.
 void setVertex(int anIndex, double x)
          Copy new coordinate to vertex at specified position in the vertex list.
 void setVertex(int anIndex, double x, double y)
          Copy new coordinates to vertex at specified position in the vertex list.
 void setVertex(int anIndex, double x, double y, double z)
          Copy new coordinates to vertex at specified position in the vertex list.
 boolean setVertex(int anIndex, PdVector aVertex)
          Copy new vertex to vertex at specified position in the vertex list.
 void setVertexColor(int anIndex, java.awt.Color aVertex)
          Copy new color to vertex color at specified position in the color list
 void setVertexColors(java.awt.Color[] aVertexColorList)
          Copy vertex colors of list to existing array of vertex colors.
 void setVertexNormal(int anIndex, PdVector aVertex)
          Copy new normal to vertex normal at specified position in the normal list
 void setVertexNormals(PdVector[] aVertexNormalList)
          Copy vertex normals of list to existing array of vertex normals.
 void setVertexTextures(PdVector[] aVertexTextureList)
          Copy vertex textures of list to existing array of vertex textures.
 void setVertices(PdVector[] aVertexList)
          Copy the first getNumVertices() vertices of source array into an existing vertex array.
 void showIndices(boolean flag)
          Enable and disable showing of indices in display.
 void showTaggedVertices(boolean flag)
          Set flag to enable drawing of tagged vertices.
 void showVectorArrow(boolean flag)
          Deprecated. use showVectorArrows(boolean)
 void showVectorArrows(boolean flag)
          Set flag to enable drawing of tip of vectors as arrow.
 void showVectorColors(boolean flag)
          Set flag to enable drawing of individual vector colors.
 void showVectorField(boolean flag)
          Deprecated. use showVectorFields(boolean)
 void showVectorFields(boolean flag)
          Set flag to enable drawing of all vectorfields.
 void showVertexColors(boolean flag)
          Set flag to enable drawing of individual vertex colors.
 void showVertexLabels(boolean flag)
          Set flag to enable drawing of vertex labels in display.
 void showVertexNormalArrow(boolean flag)
          Set flag to enable drawing of arrow of vertex normal.
 void showVertexNormals(boolean flag)
          Set flag to enable drawing of vertex normals.
 void showVertexTexture(boolean flag)
          Set flag to enable drawing of vertex textures.
 void showVertices(boolean flag)
          Set flag to enable drawing of vertices.
 java.lang.String toString()
          Create a multi-line string representation with detailed information about all instance variables.
 void translate(PdVector diff)
          Translate each vertex of geometry by given vector.
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 
Methods inherited from class jv.project.PgGeometry
addDisplay, addElement, addPolygon, clearTagElement, clearTagPolygon, fillMethodMenu, getAmbientInvMatrix, getAmbientMatrix, getAmbientProjection, getAmbientSpace, getAuthorInfo, getAuthors, getCenter, getCenterOfElement, getControlPanel, getDiameter, getDimOfSimplex, getDimOfVertices, getDisplays, getElement, getGeometryInfo, getLabelAttribute, getMaterialPanel, getModelMatrix, getPolygon, getTitle, getVersion, getVersionType, hasAmbientMatrix, hasDisplay, hasModelMatrix, hasTagElement, hasTagPolygon, isConfigurable, isShowingBndBox, isShowingCenter, isShowingTitle, isVisible, removeDisplay, removeElement, removePolygon, setAmbientMatrix, setAmbientProjection, setAmbientSpace, setAuthorInfo, setAuthors, setCenter, setDimOfSimplex, setElement, setGeometryInfo, setLabelAttribute, setLabelAttribute, setModelMatrix, setPolygon, setTagElement, setTagPolygon, 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
 

Constructor Detail

PgPointSet

public PgPointSet()
Constructor of a point set in three-dimensional space.

PgPointSet

public PgPointSet(int aVertexDim)
Constructor of a point set in n-dimensional space.
Method Detail

init

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

setState

public void setState(int aKey,
                     boolean aState)
Set drawing flags of this geometry from within the display. Currently, this method is not intended for public use. Subclasses should overwrite this method and call super for unhandled keys.
Overrides:
setState in class PgGeometry
Parameters:
aKey - flag to be set, choose among PvGeometryIf.SHOW_...
aState - enable or disable state

getJvx

public PgJvxSrc getJvx()
Fills a geometry container with data from this instance, for example, to print to file.
Overrides:
getJvx in class PgGeometry
Returns:
geometry container 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 PgGeometry
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 PgGeometry
See Also:
#copy(PgPointSet)

copy

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

toString

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

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

getTexture

public PgTexture getTexture()
Get current texture of surface.

setTexture

public void setTexture(PgTexture texture)
Set current texture of surface with reference to texture image. Passing null as argument will remove texture.

getTextureImageName

public java.lang.String getTextureImageName()
Get name of texture image, a full URL or a relative file name.
Overrides:
getTextureImageName in class PgGeometry

setTextureImageName

public void setTextureImageName(java.lang.String name)
Set name of texture image, a URL or a relative file name. If instance variable texture does not exist then allocate a new instance.
Overrides:
setTextureImageName in class PgGeometry
Parameters:
name - Name of a texture image file.

getTextureImage

public java.awt.Image getTextureImage()
Get image of texture.
Overrides:
getTextureImage in class PgGeometry

setTextureImage

public void setTextureImage(java.awt.Image image)
Set texture image for vertex and element textures. If instance variable texture does not exist then allocate a new instance.
Overrides:
setTextureImage in class PgGeometry
Parameters:
name - Name of a texture image.

setTransparency

public void setTransparency(double alpha)
Set transparency of surface to be used in textures. Currently not used since Java 1.1 graphics does not support continuous alpha.

getBounds

public PdVector[] getBounds()
Compute bounding box of the vertices which are transformed with ambient and model matrix.

The two returned bounding box vectors are 3-dimensional. If dimension of vertices is less than 3 then remaining components are zeroed.

Note, transformation not supported yet.

Overrides:
getBounds in class PgGeometry
Returns:
two 3d vectors which are the extremal corners of the bounding cube
See Also:
getAmbientBounds()

getAmbientBounds

public PdVector[] getAmbientBounds()
Compute bounding box of this geometry from the set of all vertices, or return null if no vertices. Method returns two vectors whose size is equal to the dimenstion of this geometry. The two bounding vectors are first, the minimal corner, and second, the maximal corner of the bounding m_dim-cube. Both vectors uniquely determine the bounding box.

Note, the bounding box does not include transformations from the ambient or model matrix.

Overrides:
getAmbientBounds in class PgGeometry
Returns:
two vectors which are the extremal corners of the bounding cube
See Also:
getBounds()

getCenterOfBndBox

public PdVector getCenterOfBndBox()
Compute center of geometry as midpoint of the bounding box. If geometry has no vertices, center is undetermined.

The center has same dimension as all vertices.

Returns:
Center of bounding box
See Also:
getCenterOfGravity(), PgGeometry.getCenter()

setCenterOfBndBox

public void setCenterOfBndBox(PdVector center)
Move each vertex of geometry by vector center-oldCenter. Method calls #translate to shift vertices.
See Also:
PgGeometry.getCenter(), PgGeometry.setCenter(jv.vecmath.PdVector)

getCenterOfGravity

public PdVector getCenterOfGravity()
Compute center of geometry as the mean all vertices, i.e. center of gravity. Return origin if no vertices available. Return null if missing dimension of vertices.

The center has same dimension as all vertices.

See Also:
PgGeometry.getCenter()

getNumVertices

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

getMaxNumVertices

public final int getMaxNumVertices()
Get total length of allocated vertex array. Usually, only a subset is filled with data. Method is for internal use, see getNumVertices() for daily work.

getVertices

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

Note, that the actual size of the vertex array may differ from getNumVertices() for efficiency reasons. Therefore, do not use vertex.length but use getNumVertices().

Note, the array is void as soon as the number of vertices changes. After issuing setNumVertices(int) then call this method again.


getVertex

public PdVector getVertex(int anIndex)
Get a reference to an individual vertex.
Overrides:
getVertex in class PgGeometry
Parameters:
anIndex - index of vertex

getVertexColor

public java.awt.Color getVertexColor(int anIndex)
Get a reference to an individual vertex color.
Parameters:
anIndex - index of vertex

getVertexNormal

public PdVector getVertexNormal(int anIndex)
Get a reference to an individual vertex normal.
Parameters:
anIndex - index of vertex

getGlobalVertexColor

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

getGlobalVertexTagColor

public java.awt.Color getGlobalVertexTagColor()
Get global color of tagged vertices.

getGlobalVertexSize

public int getGlobalVertexSize()
Get global radius in pixels of circle to visualize vertices in display.

getGlobalVertexNormalColor

public java.awt.Color getGlobalVertexNormalColor()
Get global vertex normal color which is used if no local colors are available.

getGlobalVertexNormalLength

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

getGlobalVertexNormalSize

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

getGlobalVectorLength

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

getGlobalVectorSize

public double getGlobalVectorSize()
Get thickness in pixels of vectors when drawn in display.

getGlobalVectorColor

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

setGlobalVertexColor

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

setGlobalVertexTagColor

public void setGlobalVertexTagColor(java.awt.Color color)
Set global color of tagged vertices.

setGlobalVertexSize

public void setGlobalVertexSize(int size)
Set global radius in pixels of circle to visualize vertices in display.

setGlobalVertexNormalColor

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

setGlobalVertexNormalLength

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

setGlobalVertexNormalSize

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

setGlobalVectorLength

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

setGlobalVectorSize

public void setGlobalVectorSize(double size)
Get thickness in pixels of vectors when drawn in display.

setGlobalVectorColor

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

getVertexColors

public java.awt.Color[] getVertexColors()
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.

getVertexNormals

public PdVector[] getVertexNormals()
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.

getVertexTextures

public PdVector[] getVertexTextures()
Get vertex texture array for read and write access, but do not modify the size of any texture vector. Note, that subclasses may not reference all vertex textures. Also note, that the actual size of the texture array may be larger than m_numVertices for efficiency reasons. Therefore, do not use length of array. Each vertex has associated a 2-dimensional vector with normalized texture coordinates.

isDefaultLabelEnabled

public boolean isDefaultLabelEnabled()
Determine whether drawing of default labels, i.e. item indices, is enabled. Usually, the default label is the index of an item in an array. For example, the index of a vertex in the vertex array of a point set. On default, usage of default labels is enabled.
See Also:
isShowingIndices()

isShowingIndices

public boolean isShowingIndices()
Check whether showing of indices is switched on. If no label is specified for an item the a default label is drawing.
See Also:
isDefaultLabelEnabled(), setDefaultLabelEnabled(boolean)

isShowingVertexLabels

public boolean isShowingVertexLabels()
Determine whether showing of vertex labels is enabled.

isShowingVertices

public boolean isShowingVertices()
Determine whether showing of vertices is enabled.

isShowingTaggedVertices

public boolean isShowingTaggedVertices()
Determine whether showing of tagged vertices is enabled.

isShowingVertexColors

public boolean isShowingVertexColors()
Determine whether showing of vertex colors is enabled.

isShowingVertexNormals

public boolean isShowingVertexNormals()
Determine whether showing of vertex normals is enabled.

isShowingVertexNormalArrow

public boolean isShowingVertexNormalArrow()
Determines whether drawing of arrow of vertex normals is enabled.

isShowingVertexTexture

public boolean isShowingVertexTexture()
Determine whether showing of vertex textures is enabled.

isShowingVectorField

public boolean isShowingVectorField()
Determine whether showing of vectorfields is enabled.

isShowingVectorArrow

public boolean isShowingVectorArrow()
Deprecated. use isShowingVectorArrows(boolean)

Determine whether showing of tip of vectors as arrow is enabled.

isShowingVectorArrows

public boolean isShowingVectorArrows()
Determine whether showing of tip of vectors as arrow is enabled.

isShowingVectorColors

public boolean isShowingVectorColors()
Determine whether showing of vertex normals is enabled.

setDefaultLabelEnabled

public void setDefaultLabelEnabled(boolean flag)
Determine whether drawing of default labels, i.e. item indices, is enabled. Usually, the default label is the index of an item in an array. For example, the index of a vertex in the vertex array of a point set. On default, usage of of default labels is enabled.
See Also:
showIndices(boolean)

showIndices

public void showIndices(boolean flag)
Enable and disable showing of indices in display. If no label is specified for an item then a default label is drawing. Usually, the default label is the index of an item in an array. For example, the index of a vertex in the vertex array of a point set. On default, showing of labels is disabled.
See Also:
isDefaultLabelEnabled(), setDefaultLabelEnabled(boolean)

showVertexLabels

public void showVertexLabels(boolean flag)
Set flag to enable drawing of vertex labels in display.

showVertices

public void showVertices(boolean flag)
Set flag to enable drawing of vertices.

showTaggedVertices

public void showTaggedVertices(boolean flag)
Set flag to enable drawing of tagged vertices.

showVertexColors

public void showVertexColors(boolean flag)
Set flag to enable drawing of individual vertex colors.

showVertexNormals

public void showVertexNormals(boolean flag)
Set flag to enable drawing of vertex normals.

showVertexNormalArrow

public void showVertexNormalArrow(boolean flag)
Set flag to enable drawing of arrow of vertex normal.

showVertexTexture

public void showVertexTexture(boolean flag)
Set flag to enable drawing of vertex textures.

showVectorField

public void showVectorField(boolean flag)
Deprecated. use showVectorFields(boolean)

Set flag to enable drawing of all vectorfields.

showVectorFields

public void showVectorFields(boolean flag)
Set flag to enable drawing of all vectorfields.

showVectorArrow

public void showVectorArrow(boolean flag)
Deprecated. use showVectorArrows(boolean)

Set flag to enable drawing of tip of vectors as arrow.

showVectorArrows

public void showVectorArrows(boolean flag)
Set flag to enable drawing of tip of vectors as arrow.

showVectorColors

public void showVectorColors(boolean flag)
Set flag to enable drawing of individual vector colors.

makeVertexNormals

public boolean makeVertexNormals()
Method does nothing and should be overwritten by subclasses.

setNumVertices

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

getDimOfColors

public int getDimOfColors()
Get dimension of colors, i.e. number of components of each color vector.

setDimOfColors

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

getDimOfVectors

public int getDimOfVectors()
Get dimension of vectors, i.e. number of components of each of the vectors.

setDimOfVectors

public void setDimOfVectors(int aSize)
Let all vectors have same number of components aSize<>0. It is more efficient to call method before setNumVertices(). TODO: currently, only length of normal vectors is modified.
Parameters:
aSize - Number of coordinates of each vertex.

getDimOfTextures

public int getDimOfTextures()
Get dimension of textures, i.e. number of components of each of the texture vectors.

setDimOfTextures

public void setDimOfTextures(int dim)
Set dimension of texture domain. TODO: do not allocate vertex texture coordinates here since user might use element textures.

hasVertexColors

public boolean hasVertexColors()
Check if vertex colors have been allocated.
See Also:
assureVertexColors()

hasVertexNormals

public boolean hasVertexNormals()
Check if vertex normals have been allocated.
See Also:
assureVertexNormals()

hasVertexTextures

public boolean hasVertexTextures()
Check if vertex textures have been allocated.
See Also:
assureVertexTextures()

assureVertexColors

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

assureVertexNormals

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

assureVertexTextures

public void assureVertexTextures()
Assures respectively allocates correct length of vertex texture array. Length of array is equal to length of vertex array. Dimension of texture coordinates is equal to getDimOfTextures().

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 PgGeometry
See Also:
PgGeometryIf

clearTagVertex

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

hasTagVertex

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

setTagVertex

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

hasVertex

public int hasVertex(PdVector aVertex,
                     double eps)
Looks in the vertex list if there is a vertex within a given euclidean distance. Method calls PdVector.equals(PdVector, double).
Parameters:
PdVector - vertex to be found in vertex list
Returns:
int index of first found identical vertex (-1 if none)

hasVertex

public int hasVertex(PdVector aVertex)
Looks in the vertex list if there is a vertex with same coordinates like the passed one. Method calls PdVector.equals(PdVector).
Parameters:
PdVector - vertex to be found in vertex list
Returns:
int index of first found identical vertex (-1 if none)

addVertex

public int addVertex(PdVector aVertex)
Add new vertex to the end of the vertex list Method just calls setVertex(int, PdVector).
Overrides:
addVertex in class PgGeometry
Parameters:
PdVector - vertex to be added to vertex list
Returns:
int index of added vertex in vertex list

removeVertex

public int[] removeVertex(int ind)
Remove vertex at specified position in the vertex list. Index Method just marks vertex with tag PsObject.IS_DELETED and invokes #removeMarkedVertices().

Note, when removeMarkedVertices() is called then many subclasses remove elements which refer to the deleted vertex. Therefore, it is not advised to use this method for frequent updating of a geometry.

Overrides:
removeVertex in class PgGeometry
Returns:
array with indices of new positions of vertices

setVertices

public void setVertices(PdVector[] aVertexList)
Copy the first getNumVertices() vertices of source array into an existing vertex array. Length of argument vertex list must be equal or larger than getNumVertices(). The dimension of all argument vertices must be equal to getDimOfVertices() of the geometry.
Parameters:
aVertexList - array with new vertices

removeMarkedVertices

public int[] removeMarkedVertices()
Remove vertices marked with tag PsObject#IS_DELETED from the vertex list. Method should usually be overwritten in subclasses to ensure that vertices are no longer referenced by elements or polygons.
Returns:
array with indices of new positions of vertices

setVertexColors

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

setVertexNormals

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

setVertexTextures

public void setVertexTextures(PdVector[] aVertexTextureList)
Copy vertex textures of list to existing array of vertex textures. Length of argument list must be equal or larger than getNumVertices(). All vertex textures are copied. The dimension of all argument textures must be equal to getDimOfTextures() of the geometry.
Parameters:
aVertexTextureList - array with new vertex textures

setVertex

public boolean setVertex(int anIndex,
                         PdVector aVertex)
Copy new vertex to vertex at specified position in the vertex list. Vertex must have same dimension as geometry. If too large then the exceeding components are truncated, if too small then missing components are filled with zero.
Overrides:
setVertex in class PgGeometry
Parameters:
int - index of vertex position
PdVector - vertex to be copied to vertex list
Returns:
boolean false, if index out of range, or argument missing

setVertex

public void setVertex(int anIndex,
                      double x)
Copy new coordinate to vertex at specified position in the vertex list. Number of vertices is increased if required. Dimension of vertices of geometry must be equal 1.
Parameters:
anIndex - index of vertex
x - coordinate of vertex

setVertex

public void setVertex(int anIndex,
                      double x,
                      double y)
Copy new coordinates to vertex at specified position in the vertex list. Number of vertices is increased if required. Dimension of vertices of geometry must be equal 2.
Parameters:
anIndex - index of vertex
x,y - coordinates of vertex

setVertex

public void setVertex(int anIndex,
                      double x,
                      double y,
                      double z)
Copy new coordinates to vertex at specified position in the vertex list. Number of vertices is increased if required. Dimension of vertices of geometry must be equal 3.
Parameters:
anIndex - index of vertex
x,y,z - coordinates of vertex

setVertexColor

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

setVertexNormal

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

addVectorField

public int addVectorField(PgVectorField aVectorField)
Add a vertex or element based vector field to geometry. Adding the same vector field again will have no effect unless the vector field is removed. Geometry is registered in vector field with PgVectorField#setGeometry(PgPointSet)

getNumVectorFields

public int getNumVectorFields()
Get number of vector fields.

getIndexOfVectorField

public int getIndexOfVectorField(PgVectorField aVectorField)
Get index of vector fields, assumes user data is stored in a vector.

getVectorField

public PgVectorField getVectorField(java.lang.String name)
Get a vector field via its name.

getVectorField

public PgVectorField getVectorField(int anInd)
Get a vector field via its index.

removeVectorField

public boolean removeVectorField(PgGeometryIf aVectorField)
Remove a vector field from geometry.

removeAllVectorFields

public void removeAllVectorFields()
Remove all user added vector fields.

computeRotation

public void computeRotation(PgPolygon meridian,
                            int numULines)
Generate rotational symmetric surface from given meridian around x-axis. Compute vertex normals.
Parameters:
numULines - discretization in angular direction

computeCylinder

public void computeCylinder(int numULines,
                            int numVLines,
                            double radius,
                            double length)
Generate cylinder in z-direction with given radius and length. Compute vertex normals. Sample method to have simple geometry available for test purposes.
Parameters:
numULines - discretization in angular direction
numVLines - discretization in z-axis direction
radius - radius of cylinder
length - height of cylinder

computeDisk

public void computeDisk(int numULines,
                        int numVLines,
                        double radius)
Generate disk in xy-plane with given radius. Compute vertex normals. Sample method to have simple geometry available for test purposes.
Parameters:
numULines - discretization in radial direction
numVLines - discretization in angular direction
radius - radius of disk

computePlane

public void computePlane(int numULines,
                         int numVLines,
                         double uMin,
                         double vMin,
                         double uMax,
                         double vMax)
Generate rectangle in z=0 plane with given min/max values. Compute vertex normals. Sample method to have simple geometry available for test purposes.
Parameters:
numULines - discretization in x direction
numVLines - discretization in y direction
uMin, - vMin, uMax, vMax size of rectangle

computeSphere

public void computeSphere(int numULines,
                          int numVLines,
                          double radius)
Generate sphere at origin with given radius. Compute vertex normals. Sample method to have simple geometry available for test purposes.
Parameters:
numULines - discretization in angular direction
numVLines - discretization in meridian direction
radius - radius of sphere

computeTorus

public void computeTorus(int numULines,
                         int numVLines,
                         double radius,
                         double thick)
Generate torus in x-y plane with given radius of soal and thickness of tube. Compute vertex normals. Sample method to have simple geometry available for test purposes.
Parameters:
numULines - discretization in angular direction
numVLines - discretization in meridian direction
radius - radius of soal
thick - radius of torus tube

computeSnail

public void computeSnail(int numULines,
                         int numVLines,
                         double numWindings)
Generate a winding snail. Sample method to have simple geometry available for test purposes.
Parameters:
numULines - discretization in angular direction
numVLines - discretization in meridian direction
numWindings - number of half-turns of snail house

merge

public boolean merge(PgGeometryIf aGeom)
Merge two point sets and store union in this. Number of vertices is the sum of both objects.
Overrides:
merge in class PgGeometry
Parameters:
aGeom - Second geometry, will not be modified.
Returns:
true on success, false is argument null.

blend

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

flipOrientation

public void flipOrientation()
Change orientation of normal vectors. This method just multiplies each normal vector with -1 and, therefore, must be overwritten by subclasses such as PgElementSet and PgPolygon.

projectToSphere

public void projectToSphere(PdVector center,
                            double radius)
Project all vertices to the unit sphere with given center.

translate

public void translate(PdVector diff)
Translate each vertex of geometry by given vector. Method translates the actual center of the geometry too.

scale

public void scale(double factor)
Scale each vertex of geometry by given factor w.r.t. its center using formula: vertex = (1-s)*center + s*vertex. A factor value 1 will not change the geometry, and a factor 0 will shrink geometry to its center.
See Also:
PgGeometry.getCenter()

scale

public void scale(double factor,
                  PdVector center)
Deprecated. use scale(double) instead

Scale each vertex of geometry by given factor w.r.t. to given center.

makeColorFromVectorLength

public boolean makeColorFromVectorLength()
Create color from the length of vectors of the first vector field.

makeVertexColorsFromXYZ

public boolean makeVertexColorsFromXYZ()
Create color from the vertex 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.

makeVertexColorsFromZ

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

makeVertexColorsFromZHue

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

makeVertexTextureFromBndBox

public boolean makeVertexTextureFromBndBox(int ix,
                                           int iy)
Create vertex texture from a plane of the bounding box. Plane is determined by the integer arguments (ix,iy). For example, (0,1) uses the xy-plane, and (1,2) the yz-plane of the bounding box. Bounding box is normalized to unit cube. Dimension of vertices must be 2 or greater.
Parameters:
ix - index of x-direction of plane
iy - index of y-direction of plane

makeVertexTextureFromCylinder

public boolean makeVertexTextureFromCylinder(PdVector center,
                                             PdVector axis)
Create vertex texture from cylinder with given axis. Dimension of vertices and of both arguments must be 3 or greater. Axis must have unit length.
Parameters:
center - an arbitrary point on the axis of the cylinder
axis - unit length direction of the axis of the cylinder

makeVertexTextureFromSphere

public boolean makeVertexTextureFromSphere(PdVector center)
Create vertex texture from sphere with given center. Dimension of vertices must be 3 or greater.

reflect

public PgGeometry reflect(PdMatrix mat,
                          boolean bOrient,
                          boolean bVector)
Generate a cloned geometry and transform vertices by a matrix. For example, this method is called to calculate mirror images of a geometry. Orientation of geometry affects surface vectors.
Overrides:
reflect in class PgGeometry
Parameters:
mat - 3*3 or 4*4 transformation matrix
bOrient - flag whether to keep the orientation of the geometry
bVector - flag whether to keep the orientation of vectors
Returns:
new reflected copy of the geometry

intersectionWithLine

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

JavaView® v2.12

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