|
JavaView® v2.00.008 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jv.object.PsObject
|
+--jv.project.PgGeometry
|
+--jv.geom.PgPointSet
|
+--jv.geom.PgPolygonSet
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.
| Field Summary | |
protected boolean |
m_bShowEdgeLabels
Flag whether labels of edges are shown in display. |
protected boolean |
m_bShowPolygonColors
Flag if local color of polygons used in display, applied if individual polygon coloring is available. |
protected boolean |
m_bShowPolygonEndArrow
Flag whether arrow is shown at last point of polygon. |
protected boolean |
m_bShowPolygonLabels
Flag whether labels of polygons are shown in display. |
protected boolean |
m_bShowPolygonNormalArrow
Flag whether to show arrow of edge normals or not. |
protected boolean |
m_bShowPolygonNormals
Flag whether to show edge normals or not. |
protected boolean |
m_bShowPolygons
Flag whether polygons are shown in display. |
protected boolean |
m_bShowPolygonStartArrow
Flag whether arrow is shown at first point of polygon. |
protected boolean |
m_bShowTaggedPolygons
Flag whether tagged polygons are shown in display. |
protected int |
m_dimOfPolygons
Determines size of polygons. |
protected PdColor |
m_globalPolygonColor
Global color of polygons used in display, applied if no individual polygon coloring available. |
protected PdColor |
m_globalPolygonNormalColor
Global color of polygon normals used in display, applied if no individual normal coloring available. |
protected PuDouble |
m_globalPolygonNormalLength
Scaling factor of all polygon normals used in display. |
protected PuDouble |
m_globalPolygonNormalSize
Thickness in pixels of each polygon normal used in display. |
protected PuDouble |
m_globalPolygonSize
Thickness in pixels of each polygon used in display. |
protected PdColor |
m_globalPolygonTagColor
Global color of tagged polygons used in display. |
protected int |
m_maxNumPolygons
Number of allocated vertices. |
protected int |
m_numPolygons
Number of used polygons. |
protected PiVector[] |
m_polygon
Array with all polygonal polygons. |
protected java.awt.Color[] |
m_polygonColor
Array with a color of each polygon. |
protected PdVector[] |
m_polygonNormal
Array with a normal per polygon. |
protected boolean |
m_useGlobalPolygonSize
Flag if global size of edges used in display, applied if no individual edge sizes available. |
| Fields inherited from class jv.project.PgGeometry |
m_ambientProj, m_ambientSpace, m_authorInfo, m_bShowBndBox, m_bShowCenter, m_bShowing, m_bShowTitle, m_center, m_dim, m_dimOfSimplex, m_displayList, m_geometryInfo, m_labelAttribute, m_methodMenu, m_modelMatrix, m_title, m_version, m_versionType |
| Fields inherited from class jv.object.PsObject |
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS |
| Constructor Summary | |
PgPolygonSet()
Constructor of a polygon set in three-dimensional space. |
|
PgPolygonSet(int aVertexDim)
Constructor of a polygon set in a space of given dimension. |
|
| Method Summary | |
int |
addPolygon(PiVector aPolygon)
Add new polygon to the end of the polygon list. |
boolean |
assureDimOfPolygons()
Assure correctness of value m_dimOfPolygons specifying the number of vertices per polygon. |
void |
assurePolygonColors()
Assures respectively allocates correct length of polygon color array. |
void |
assurePolygonNormals()
Assures respectively allocates correct length of polygon normal array. |
boolean |
blend(double s,
PgGeometry ag,
double t,
PgGeometry bg)
Blend between two polygonSets, used in interpolation and computing the associate surfaces this = s*a + t*b. |
void |
clearTagPolygon(int anIndex,
int aTag)
Clear a single tag of a polygon. |
java.lang.Object |
clone()
Duplicate geometry by recursively cloning all instance variables except inspector panels and lists of registered listeners. |
void |
copy(PgGeometry geom)
Copy instance variables by duplication, not by copying a reference. |
void |
copyPolygonSet(PgPolygonSet geom)
Copy instance variables of this class but not of the superclass. |
int |
getDimOfPolygons()
Retrieve number of vertices per polygon, if it is the same for all polygons, otherwise return -1. |
java.awt.Color |
getGlobalPolygonColor()
Get global polygon color which is used if no local colors are available. |
java.awt.Color |
getGlobalPolygonNormalColor()
Get global element color which is used if no local colors are available. |
double |
getGlobalPolygonNormalLength()
Get length factor of normal vectors when drawn in display. |
double |
getGlobalPolygonNormalSize()
Get thickness in pixels of normals when drawn in display. |
double |
getGlobalPolygonSize()
Get thickness in pixels of polygon when drawn in display. |
java.awt.Color |
getGlobalPolygonTagColor()
Get global color of tagged polygons. |
PgJvxSrc |
getJvx()
Fills a geometry object with data from this instance, for example, to print to file. |
double |
getLength()
Compute total length of all polygons. |
double |
getLengthOfPolygon(int ind)
Compute length of a single polygon with given index. |
int |
getMaxNumPolygons()
Get total length of allocated polygon array. |
int |
getNumEdges()
Calculate total number of edges of all polygons. |
int |
getNumPolygons()
Get number of polygons in vertex array. |
PiVector |
getPolygon(int anIndex)
Get a reference to an individual polygon array with vertex indices. |
java.awt.Color |
getPolygonColor(int anIndex)
Get a reference to an individual polygon color. |
java.awt.Color[] |
getPolygonColors()
Get color array for read and write access, but do not modify the size of any color vector. |
PdVector |
getPolygonNormal(int anIndex)
Get a reference to an individual polygon normal. |
PdVector[] |
getPolygonNormals()
Get vertex normal array for read and write access, but do not modify the size of any normal vector. |
PiVector[] |
getPolygons()
Get polygon array for read and write access. |
PdVector[] |
getPolygonVertices(int ind)
Get an array with pointers to all vertices of an polygon. |
int |
getPolygonWithVertex(int vertexInd)
Find first polygon referencing a given vertex. |
double |
getVertexAngle(int ind,
int locInd)
Compute angle at vertex of polygon. |
boolean |
hasPolygonColors()
Check if polygon colors have been allocated. |
boolean |
hasPolygonNormals()
Check if polygon normals have been allocated. |
boolean |
hasTagPolygon(int anIndex,
int aTag)
Check whether polygon has given tag. |
void |
init()
Initialize and reset instance variables after call to super.init(). |
PvPickEvent |
intersectionWithLine(PdVector rayBase,
PdVector rayDir)
Find intersection of polygon set with a given ray. |
boolean |
isClosed(int ind)
Check whether polygon is closed, i.e.if endpoints are identical. |
boolean |
isShowingEdgeLabels()
Determine whether showing of edge labels is enabled. |
boolean |
isShowingPolygonColors()
Set flag to enable drawing of polygon colors. |
boolean |
isShowingPolygonEndArrow()
Determines whether drawing of arrow at last point of polygon is enabled. |
boolean |
isShowingPolygonLabels()
Determine whether showing of polygon labels is enabled. |
boolean |
isShowingPolygonNormalArrow()
Determines whether drawing of arrow of polygon normals is enabled. |
boolean |
isShowingPolygonNormals()
Set flag to enable drawing of polygon normals. |
boolean |
isShowingPolygons()
Set flag to enable drawing of polygons. |
boolean |
isShowingPolygonStartArrow()
Determines whether drawing of arrow at first point of polygon is enabled. |
void |
makeNormals()
Compute normals at polygon vertices as anle bisectors. |
boolean |
makePolygonColorsFromXYZ()
Create color from the edge position within its bounding box which is interpreted as RGB cube. |
boolean |
makePolygonColorsFromZ()
Create color from the vertical z-height within its bounding box ranging from red to blue. |
boolean |
makePolygonColorsFromZHue()
Create color from the vertical z-height within its bounding box ranging through hue rainbow. |
boolean |
merge(PgGeometryIf aGeom)
Merge polygon set with current object and store union of both objects in 'this'. |
void |
paint(PvGeometryIf dc)
Major rendering method fills an internal container class supplied by the display. |
int[] |
removeMarkedPolygons()
Remove all polygons which have been marked PsObject.IS_DELETED.
|
int[] |
removeMarkedVertices()
Remove vertices marked with tag PsObject#IS_DELETED from polygons. |
int[] |
removePolygon(int ind)
Remove polygon with given index, and decrement index of all polygons with higher index. |
boolean |
removeUnusedVertices()
Remove all points not referenced by polygons. |
boolean |
setClosed(int ind,
boolean flag)
Close a polygon such that first and last vertex are identical. |
void |
setDimOfColors(int aSize)
Let all colors have same number of components aSize<>0. |
void |
setDimOfPolygons(int aSize)
Let all polygons have same number of vertices aSize<>0, or individual aSize=-1.
|
void |
setDimOfVectors(int aSize)
Let all vectors have same number of vectors aSize<>0.
|
void |
setGlobalPolygonColor(java.awt.Color color)
Set global polygon color to be used if no local colors are available. |
void |
setGlobalPolygonNormalColor(java.awt.Color color)
Set global normal color to be used if no local colors are available. |
void |
setGlobalPolygonNormalLength(double length)
Get length factor of normal vectors when drawn in display. |
void |
setGlobalPolygonNormalSize(double size)
Get thickness in pixels of normals when drawn in display. |
void |
setGlobalPolygonSize(double size)
Set thickness in pixels of polygon when drawn in display. |
void |
setGlobalPolygonTagColor(java.awt.Color color)
Set global color of tagged polygons. |
void |
setJvx(PgJvxSrc src)
Fill this instance with data from a geometry source, for example, previously read from file. |
protected void |
setMaxNumPolygons(int aNumPolygons)
Allocate given number of polygons, and allocate normals, colors etc. if they already exist. |
void |
setNumPolygons(int aNumPolygons)
Allocate given number of polygons, and allocate normals, colors etc. if they already exist. |
boolean |
setPolygon(int anIndex,
PiVector aPolygon)
Set index vector of polygon with given index. |
boolean |
setPolygonColor(int anIndex,
java.awt.Color aColor)
Copy new color to polygon color at specified position in the color list |
void |
setPolygonColors(java.awt.Color[] color)
Copy polygon colors of list to existing array of polygon colors. |
boolean |
setPolygonNormal(int anIndex,
PdVector aNormal)
Copy new normal to polygon normal at specified position in the normal list |
void |
setPolygonNormals(PdVector[] normal)
Copy polygon normals of list to existing array of polygon normals. |
void |
setPolygons(PiVector[] polygon)
Copy all polygons of polygon list to existing array of polygons. |
boolean |
setPolygonVertices(int ind,
PdVector[] vArray)
Copy new polygon vertices to polygon at specified position in the polygon list. |
void |
setSizeOfPolygon(int ind,
int aSize)
Let all polygons have same number of vertices aSize<>0, or individual aSize=-1.
|
void |
setTagPolygon(int anIndex,
int aTag)
Set a tag of a polygon. |
void |
showEdgeLabels(boolean flag)
Set flag to enable drawing of edge labels in display. |
void |
showPolygonColors(boolean flag)
Set flag to enable drawing of polygon colors. |
void |
showPolygonEndArrow(boolean flag)
Set flag to enable drawing of arrow at last point of polygons. |
void |
showPolygonLabels(boolean flag)
Set flag to enable drawing of polygon labels in display. |
void |
showPolygonNormalArrow(boolean flag)
Set flag to enable drawing of arrow of polygon normal. |
void |
showPolygonNormals(boolean flag)
Set flag to enable drawing of polygon normals. |
void |
showPolygons(boolean flag)
Set flag to enable drawing of polygons. |
void |
showPolygonStartArrow(boolean flag)
Set flag to enable drawing of arrow at first point of polygons. |
java.lang.String |
toString()
Create a multi-line string representation with detailed information about all instance variables. |
boolean |
update(java.lang.Object event)
Update the class whenever a child has changed. |
void |
useGlobalPolygonColor(boolean flag)
Deprecated. use showPolygonColors(boolean) |
void |
useGlobalPolygonSize(boolean flag)
Use global polygon size instead of sizing each polygon individually. |
| Methods inherited from class jv.object.PsObject |
addInspector, addUpdateListener, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface jv.project.PgGeometryIf |
getInfoPanel, getName, setName |
| Methods inherited from interface jv.object.PsUpdateIf |
getFather, setParent |
| Field Detail |
protected boolean m_bShowEdgeLabels
protected boolean m_bShowPolygonLabels
protected int m_dimOfPolygons
setDimOfPolygons(int)protected int m_numPolygons
setNumPolygons(int)protected int m_maxNumPolygons
setNumPolygons(int)
This value is adjusted automatically whenever more memory is needed.setNumPolygons(int),
setMaxNumPolygons(int)protected PiVector[] m_polygon
protected java.awt.Color[] m_polygonColor
null.protected PdVector[] m_polygonNormal
protected boolean m_bShowPolygons
protected boolean m_bShowTaggedPolygons
protected boolean m_bShowPolygonStartArrow
protected boolean m_bShowPolygonEndArrow
protected boolean m_bShowPolygonNormals
protected boolean m_bShowPolygonNormalArrow
protected PuDouble m_globalPolygonNormalLength
protected PuDouble m_globalPolygonNormalSize
protected PdColor m_globalPolygonNormalColor
protected boolean m_bShowPolygonColors
protected PdColor m_globalPolygonColor
protected PdColor m_globalPolygonTagColor
protected PuDouble m_globalPolygonSize
protected boolean m_useGlobalPolygonSize
| Constructor Detail |
public PgPolygonSet()
public PgPolygonSet(int aVertexDim)
| Method Detail |
public void init()
init in class PgPointSetpublic PgJvxSrc getJvx()
getJvx in class PgPointSetpublic void setJvx(PgJvxSrc src)
setJvx in class PgPointSetsrc - a geometry source used to fill this instance with data.public java.lang.Object clone()
null.
Tags of this object are not copied but maybe copied of subclasses.clone in class PgPointSet#copy(PgPolygonSet)public void copy(PgGeometry geom)
copy in class PgPointSetpublic void copyPolygonSet(PgPolygonSet geom)
public java.lang.String toString()
toString in class PgPointSetpublic boolean update(java.lang.Object event)
update in class PgPointSetjv.object.PsUpdateIfevent - carries a lot of informationPsObject,
PsUpdateIf.getFather(),
PsUpdateIf.setParent(PsUpdateIf)public java.awt.Color getGlobalPolygonColor()
public java.awt.Color getGlobalPolygonTagColor()
public double getGlobalPolygonSize()
public java.awt.Color getGlobalPolygonNormalColor()
public double getGlobalPolygonNormalLength()
public double getGlobalPolygonNormalSize()
public void setGlobalPolygonColor(java.awt.Color color)
public void setGlobalPolygonTagColor(java.awt.Color color)
public void setGlobalPolygonSize(double size)
public void setGlobalPolygonNormalColor(java.awt.Color color)
public void setGlobalPolygonNormalLength(double length)
public void setGlobalPolygonNormalSize(double size)
public int addPolygon(PiVector aPolygon)
setPolygon(PiVector, numPolygons).addPolygon in class PgGeometryPiVector - polygon to be added to polygon listpublic PiVector[] getPolygons()
public java.awt.Color[] getPolygonColors()
public PdVector[] getPolygonNormals()
public boolean isShowingEdgeLabels()
public boolean isShowingPolygonLabels()
public boolean isShowingPolygons()
public boolean isShowingPolygonColors()
public boolean isShowingPolygonNormals()
public boolean isShowingPolygonNormalArrow()
public boolean isShowingPolygonStartArrow()
public boolean isShowingPolygonEndArrow()
public void showEdgeLabels(boolean flag)
public void showPolygonLabels(boolean flag)
public void showPolygons(boolean flag)
public void showPolygonColors(boolean flag)
public void showPolygonNormals(boolean flag)
public void showPolygonNormalArrow(boolean flag)
public void showPolygonStartArrow(boolean flag)
public void showPolygonEndArrow(boolean flag)
public void useGlobalPolygonColor(boolean flag)
public void useGlobalPolygonSize(boolean flag)
public int getMaxNumPolygons()
protected void setMaxNumPolygons(int aNumPolygons)
public int getNumPolygons()
public void setNumPolygons(int aNumPolygons)
public void setSizeOfPolygon(int ind,
int aSize)
aSize<>0, or individual aSize=-1.
It is more efficient to call method before setNumPolygons().aSize - Number of vertices for all polygons.setNumPolygons(int)public void setDimOfPolygons(int aSize)
aSize<>0, or individual aSize=-1.
It is more efficient to call method before setNumPolygons().aSize - Number of vertices for all polygons.setNumPolygons(int)public int getDimOfPolygons()
setDimOfPolygons(int)public boolean assureDimOfPolygons()
setDimOfPolygons(int)public void setDimOfColors(int aSize)
aSize<>0.setDimOfColors in class PgPointSetaSize - Number of components of each color vector.public void setDimOfVectors(int aSize)
aSize<>0.
It is more efficient to call method before setNumVertices().setDimOfVectors in class PgPointSetaSize - Number of coordinates of each vertex.PgPointSet.setDimOfVectors(int)public boolean hasPolygonColors()
assurePolygonColors()public boolean hasPolygonNormals()
assurePolygonNormals()public void assurePolygonColors()
public void assurePolygonNormals()
public void paint(PvGeometryIf dc)
jv.project.PgGeometryIf for detailed information.paint in class PgPointSetPgGeometryIfpublic int[] removeMarkedVertices()
Polygons with no or one remaining vertice are removed.
removeMarkedVertices in class PgPointSetPgPointSet.removeMarkedVertices()public int[] removePolygon(int ind)
PsObject.IS_DELETED
and invokes #removeMarkedPolygons().removePolygon in class PgGeometrypublic int[] removeMarkedPolygons()
PsObject.IS_DELETED.
E.g. after application of method close() polygons are
no longer in use since polygons are shrunk at zero-length boundary curves.
First, the method computes where each polygon is moved to, then all polygon data
is moved and the references to the polygon in bnd curves is changed. This routine is O(n).
Method assumes that there exist no references to marked polygons. Otherwise application of this method would lead to upredictable results.
public boolean removeUnusedVertices()
true if method was successfullpublic boolean merge(PgGeometryIf aGeom)
merge in class PgPointSetgeom - Polygon set to be merged into 'this'true if method was successfullpublic int getPolygonWithVertex(int vertexInd)
public void clearTagPolygon(int anIndex,
int aTag)
PvGeometryIf.clearTagPolygon in class PgGeometry
public boolean hasTagPolygon(int anIndex,
int aTag)
PvGeometryIf.hasTagPolygon in class PgGeometry
public void setTagPolygon(int anIndex,
int aTag)
PvGeometryIf.setTagPolygon in class PgGeometrypublic PdVector[] getPolygonVertices(int ind)
public PiVector getPolygon(int anIndex)
getPolygon in class PgGeometrypublic java.awt.Color getPolygonColor(int anIndex)
public PdVector getPolygonNormal(int anIndex)
public boolean setPolygonVertices(int ind,
PdVector[] vArray)
ind - index of polygonvArray - array with new coordinates of polygon vertices
public boolean setPolygon(int anIndex,
PiVector aPolygon)
setPolygon in class PgGeometryanIndex - index of polygonaPolygon - array with indices of new polygon
public boolean setPolygonColor(int anIndex,
java.awt.Color aColor)
anIndex - index of vertex positionaColor - color to be copied to color list
public boolean setPolygonNormal(int anIndex,
PdVector aNormal)
anIndex - index of polygon positionaNormal - normal to be copied to normal listpublic void setPolygons(PiVector[] polygon)
polygon - array with new polygonspublic void setPolygonColors(java.awt.Color[] color)
color - array with new polygon colorspublic void setPolygonNormals(PdVector[] normal)
normal - array with new polygon normalspublic boolean isClosed(int ind)
setClosed(int, boolean)
public boolean setClosed(int ind,
boolean flag)
The dimension of the polygon set may affected when closing multiple
polygons of a set. Therefore, this method uses
#assureDimOfPolygons to restore
the dimension.
PgPolygonSet does not use a flag since PgPolygonSet uses explicit index vectors to determine the polygon. Therefore, the user may just add the first index at the end of the polygon to close it.
flag - true ensures identical endpoints of polygonsfalse if index out of boundsisClosed(int)public double getLengthOfPolygon(int ind)
public double getLength()
public double getVertexAngle(int ind,
int locInd)
ind - index of polygonlocInd - local index of vertexpublic int getNumEdges()
public boolean blend(double s,
PgGeometry ag,
double t,
PgGeometry bg)
this = s*a + t*b.blend in class PgPointSetdouble - s, t weights of vertices of each polygonSetPgPolygonSet - a, b two polygonSets used for blending
public PvPickEvent intersectionWithLine(PdVector rayBase,
PdVector rayDir)
intersectionWithLine in class PgGeometryrayBase - base point of ray eventually hitting the polygon setrayDir - direction point of ray eventually hitting the polygon setpublic void makeNormals()
public boolean makePolygonColorsFromXYZ()
public boolean makePolygonColorsFromZ()
public boolean makePolygonColorsFromZHue()
|
JavaView® v2.00.008 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||