Package geomss.geom
Class PointArray<E extends GeomPoint>
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<T>
-
- geomss.geom.AbstractGeomList<T,E>
-
- geomss.geom.AbstractPointGeomList<PointArray<E>,PointString<E>>
-
- geomss.geom.PointArray<E>
-
- Type Parameters:
E
- The type of GeomPoint stored in this array of points.
- All Implemented Interfaces:
GeomElement<PointArray<E>>
,GeometryList<PointArray<E>,PointString<E>>
,PointGeometry<PointArray<E>>
,Transformable<PointArray<E>>
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,java.lang.Iterable<PointString<E>>
,java.util.Collection<PointString<E>>
,java.util.List<PointString<E>>
,javolution.lang.Reusable
,javolution.xml.XMLSerializable
public final class PointArray<E extends GeomPoint> extends AbstractPointGeomList<PointArray<E>,PointString<E>>
APointArray
is a collection ofPointString
objects that make up a "list of strings of points". Any number of strings may be added to an array. All the strings in an array must have the same dimensions. In order to draw the array, all the strings in a array must also have the same number of points.WARNING: This list allows geometry to be stored in different units. If consistent units are required, then the user must specifically convert the list items.
Modified by: Joseph A. Huwaldt
- Version:
- February 17, 2025
- Author:
- Joseph A. Huwaldt, Date: March 5, 2003
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, PointString<E> value)
Inserts the specifiedPointString
at the specified position in this list.boolean
addAll(int index, java.util.Collection<? extends PointString<E>> c)
Inserts all of thePointString
objects in the specified collection into this list at the specified position.PointArray<E>
copy()
Returns a copy of thisPointArray
instanceallocated
by the calling thread (possibly on the stack).PointArray
copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).PointArray<E>
enrich()
Returns a newPointArray
that is identical to this array but with new rows (strings of points) and columns (points in each string) of points linearly interpolated between each of the existing rows and columns.PointArray<E>
enrichColumns()
Returns a newPointArray
that is identical to this array but with a new column (point) linearly interpolated between each point of the existing strings.PointArray<E>
enrichRows()
Returns a newPointArray
that is identical to this array but with a new row (string of points) linearly interpolated between each of the existing rows.E
get(int row, int col)
Returns theGeomPoint
at the specified pair of indices in this array.Parameter<javax.measure.quantity.Area>
getArea()
Return the total surface area of all the panels formed by this array of points.PointString<E>
getColumn(int col)
Return a column of points from this array as a new PointString object.int
getNumberOfPanels()
Return the total number of quadrilateral panels in this array of points.PointArray<E>
getRange(int first, int last)
Returns the range of elements in this list from the specified start and ending indexes.PointArray
getTransformed(GTransform transform)
Returns transformed version of this element.static void
main(java.lang.String[] args)
Tests the methods in this class.static PointArray
newInstance()
Returns a new, empty, preallocated or recycledPointArray
instance (on the stack when executing in aStackContext
), that can store a list ofPointString
objects.static PointArray
newInstance(java.lang.String name)
Returns a new, preallocated or recycledPointArray
instance (on the stack when executing in aStackContext
) with the specified name, that can store a list ofPointString
objects.static void
recycle(PointArray instance)
Recycles a case instance immediately (on the stack when executing in a StackContext).PointArray<E>
reverse()
Returns an newPointArray
with the elements in this list in reverse order.PointArray<E>
reverseStrings()
Returns an newPointArray
with the points in each string in this array in reverse order.PointString<E>
set(int index, PointString<E> element)
Replaces thePointString
at the specified position in this list with the specified element.PointArray<E>
thin()
Returns a newPointArray
that is identical to this array but with every other row (string of points) and column (points in the strings) removed.PointArray<E>
thinColumns()
Returns a newPointArray
that is identical to this array but with every other column (points in strings) removed.PointArray<E>
thinRows()
Returns a newPointArray
that is identical to this array but with every other row (string of points) removed.PointArray
to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns the equivalent to this list but with all the elements stated in the specified unit.PointArray<E>
toDimension(int newDim)
Return the equivalent of this list converted to the specified number of physical dimensions.PointArray<E>
transpose()
Returns a newPointArray
that is the transpose this array (rows and columns swapped).TriangleList<Triangle>
triangulate()
Return a TriangleList containing a simple triangulation of the input array of quadrilateral panels.static <E extends GeomPoint>
PointArray<E>valueOf(PointString<E>... elements)
Return a PointArray made up of thePointString
objects in the specified array.static <E extends GeomPoint>
PointArray<E>valueOf(java.lang.String name, PointString<E>... elements)
Return a PointArray made up of thePointString
objects in the specified array.static <E extends GeomPoint>
PointArray<E>valueOf(java.lang.String name, java.util.Collection<? extends PointString<E>> elements)
Return a PointArray made up of thePointString
objects in the specified collection.-
Methods inherited from class geomss.geom.AbstractPointGeomList
getNumberOfPoints, getPhyDimension
-
Methods inherited from class geomss.geom.AbstractGeomList
add, add, add, addAll, addAll, addAll, clear, contains, containsAll, containsGeometry, equals, get, get, getAll, getBoundsMax, getBoundsMin, getFirst, getIndexFromName, getLast, getLimitPoint, getParDimension, getUnit, hashCode, indexOf, isEmpty, isValid, iterator, lastIndexOf, listIterator, listIterator, remove, remove, remove, removeAll, reset, retainAll, size, subList, toArray, toArray, toText, unmodifiableList
-
Methods inherited from class geomss.geom.AbstractGeomElement
addChangeListener, clone, compareTo, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, toString
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getBoundsMax, getBoundsMin, getID, getLimitPoint, getName, getParDimension, getUnit, getUserData, isValid, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, size, toText
-
-
-
-
Method Detail
-
newInstance
public static PointArray newInstance()
Returns a new, empty, preallocated or recycledPointArray
instance (on the stack when executing in aStackContext
), that can store a list ofPointString
objects.- Returns:
- A new, empty PointArray
-
newInstance
public static PointArray newInstance(java.lang.String name)
Returns a new, preallocated or recycledPointArray
instance (on the stack when executing in aStackContext
) with the specified name, that can store a list ofPointString
objects.- Parameters:
name
- The name to be assigned to this list (may benull
).- Returns:
- A new, empty PointArray
-
valueOf
public static <E extends GeomPoint> PointArray<E> valueOf(java.lang.String name, java.util.Collection<? extends PointString<E>> elements)
Return a PointArray made up of thePointString
objects in the specified collection.- Type Parameters:
E
- The type of GeomPoint stored in this array of points.- Parameters:
name
- The name to be assigned to this list (may benull
).elements
- A collection that contains a set of strings. May not be null.- Returns:
- A new PointArray containing the elements in the specified collection.
-
valueOf
public static <E extends GeomPoint> PointArray<E> valueOf(java.lang.String name, PointString<E>... elements)
Return a PointArray made up of thePointString
objects in the specified array.- Type Parameters:
E
- The type of GeomPoint stored in this array of points.- Parameters:
name
- The name to be assigned to this string (may benull
).elements
- A list that contains a set of strings. May not be null.- Returns:
- A new PointArray containing the elements in the specified array.
-
valueOf
public static <E extends GeomPoint> PointArray<E> valueOf(PointString<E>... elements)
Return a PointArray made up of thePointString
objects in the specified array.- Type Parameters:
E
- The type of GeomPoint stored in this array of points.- Parameters:
elements
- A list that contains a set of strings. May not be null.- Returns:
- A new PointArray containing the elements in the specified array.
-
get
public E get(int row, int col) throws java.lang.IndexOutOfBoundsException
Returns theGeomPoint
at the specified pair of indices in this array. This is a convenience method that is identical toarray.get(row).get(col)
.- Parameters:
row
- The row (string or "T") index of the panel to be returnedcol
- The column (point in a string or "S") index of the panel to be returned- Returns:
- The point at the specified row and column in this array.
- Throws:
java.lang.IndexOutOfBoundsException
- if there the specified indices do not exist in this array.
-
getColumn
public PointString<E> getColumn(int col) throws java.lang.IndexOutOfBoundsException
Return a column of points from this array as a new PointString object. A column is made up of a point from each string of the array.- Parameters:
col
- The column of points to return.- Returns:
- A new PointString object containing the points from the specified column of this array.
- Throws:
java.lang.IndexOutOfBoundsException
- if there the specified index does not exist in this array.
-
getRange
public PointArray<E> getRange(int first, int last)
Returns the range of elements in this list from the specified start and ending indexes.- Specified by:
getRange
in interfaceGeometryList<PointArray<E extends GeomPoint>,PointString<E extends GeomPoint>>
- Specified by:
getRange
in classAbstractGeomList<PointArray<E extends GeomPoint>,PointString<E extends GeomPoint>>
- Parameters:
first
- index of the first element to return (0 returns the 1st element, -1 returns the last, etc).last
- index of the last element to return (0 returns the 1st element, -1 returns the last, etc).- Returns:
- the list of elements in the given range from this list.
- Throws:
java.lang.IndexOutOfBoundsException
- if the given index is out of range:index ≥= size()
-
reverse
public PointArray<E> reverse()
Returns an newPointArray
with the elements in this list in reverse order.- Specified by:
reverse
in interfaceGeometryList<PointArray<E extends GeomPoint>,PointString<E extends GeomPoint>>
- Specified by:
reverse
in classAbstractGeomList<PointArray<E extends GeomPoint>,PointString<E extends GeomPoint>>
- Returns:
- A new PointArray with the elements in this list in reverse order. This reverses the rows of the array.
-
reverseStrings
public PointArray<E> reverseStrings()
Returns an newPointArray
with the points in each string in this array in reverse order.- Returns:
- A new PointArray with the points in each string in reverse order. This reverses the columns of the array.
-
transpose
public PointArray<E> transpose() throws java.lang.IndexOutOfBoundsException
Returns a newPointArray
that is the transpose this array (rows and columns swapped). This method can only be called if all the strings in this array have the same number of points in them.- Returns:
- A new PointArray that is the transpose of this array.
- Throws:
java.lang.IndexOutOfBoundsException
- if the number of points is not the same in each string in this array.
-
thin
public PointArray<E> thin()
Returns a newPointArray
that is identical to this array but with every other row (string of points) and column (points in the strings) removed. The 1st row and column and the last row and column are always retained. If there are less than 3 columns in the array, then a new array is returned that contains the same columns as this array. If there are less than 3 rows, then a new array is returned that contains the same rows as this array.- Returns:
- A new PointArray identical to this array, but with every other row and column removed.
-
thinRows
public PointArray<E> thinRows()
Returns a newPointArray
that is identical to this array but with every other row (string of points) removed. The 1st row (index = 0) and last row (index = size()-1) are always retained. If there are less than 3 rows in the array, then a new array is returned that contains the same rows as this array.- Returns:
- A new PointArray that is identical to this array but with every other row removed.
-
thinColumns
public PointArray<E> thinColumns() throws java.lang.IndexOutOfBoundsException
Returns a newPointArray
that is identical to this array but with every other column (points in strings) removed. The 1st column (index = 0) and last column (index = get(0).size()-1) are always retained. If there are less than 3 columns in the array, then a new array is returned that contains the same columns as this array.- Returns:
- A new PointArray that is identical to this array, but with every other column (points in the strings) removed.
- Throws:
java.lang.IndexOutOfBoundsException
- if the number of points is not the same in each string in this array.
-
enrich
public PointArray<E> enrich() throws java.lang.IndexOutOfBoundsException
Returns a newPointArray
that is identical to this array but with new rows (strings of points) and columns (points in each string) of points linearly interpolated between each of the existing rows and columns. If there are less than 2 columns in the array, then a new array is returned that contains the one column in this array. If there are less than 2 points in each string of the array, then a new array is returned that contains the one point in each string in this array.- Returns:
- A new PointArray with new rows and columns linearly interpolated between each of the existing rows and columns.
- Throws:
java.lang.IndexOutOfBoundsException
- if the number of points is not the same in each string in this array.
-
enrichRows
public PointArray<E> enrichRows() throws java.lang.IndexOutOfBoundsException
Returns a newPointArray
that is identical to this array but with a new row (string of points) linearly interpolated between each of the existing rows. If there are less than 2 rows in the array, then a new array is returned that contains the one row in this array.- Returns:
- A new PointArray with new rows linearly interpolated between each of the existing rows.
- Throws:
java.lang.IndexOutOfBoundsException
- if the number of points is not the same in each string in this array.
-
enrichColumns
public PointArray<E> enrichColumns() throws java.lang.IndexOutOfBoundsException
Returns a newPointArray
that is identical to this array but with a new column (point) linearly interpolated between each point of the existing strings. If there are less than 2 points in each string of the array, then a new array is returned that contains the one point in each string in this array.- Returns:
- A new PointArray with new column linearly interpolated between each of the existing columns.
- Throws:
java.lang.IndexOutOfBoundsException
- if the number of points is not the same in each string in this array.
-
triangulate
public TriangleList<Triangle> triangulate()
Return a TriangleList containing a simple triangulation of the input array of quadrilateral panels. The input panels are triangulated by dividing each quad, formed by two adjacent strings of points, into two triangles. Any subranges or transforms on the input points is lost (using copyToReal()) by this triangulation.- Returns:
- A new TriangleList containing a triangulation of the this array of quadrilateral panels.
- See Also:
copyToReal()
-
toDimension
public PointArray<E> toDimension(int newDim)
Return the equivalent of this list converted to the specified number of physical dimensions. If the number of dimensions is greater than this element, then zeros are added to the additional dimensions. If the number of dimensions is less than this element, then the extra dimensions are simply dropped (truncated). If the new dimensions are the same as the dimension of this element, then this list is simply returned.- Parameters:
newDim
- The dimension of the element to return.- Returns:
- The equivalent of this list converted to the new dimensions.
-
to
public PointArray to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns the equivalent to this list but with all the elements stated in the specified unit.- Parameters:
unit
- the length unit of the list to be returned. May not be null.- Returns:
- an equivalent to this list but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException
- if the the input unit is not a length unit.
-
copy
public PointArray<E> copy()
Returns a copy of thisPointArray
instanceallocated
by the calling thread (possibly on the stack).- Returns:
- an identical and independent copy of this object.
-
copyToReal
public PointArray copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Returns:
- A copy of this list with any sub-element transformations or subranges removed.
-
getNumberOfPanels
public int getNumberOfPanels() throws java.lang.IndexOutOfBoundsException
Return the total number of quadrilateral panels in this array of points.- Returns:
- the total number of panels in this array.
- Throws:
java.lang.IndexOutOfBoundsException
- if the strings in this array have different lengths.
-
getArea
public Parameter<javax.measure.quantity.Area> getArea()
Return the total surface area of all the panels formed by this array of points.- Returns:
- The total surface area of all the panels formed by this array of points.
-
getTransformed
public PointArray getTransformed(GTransform transform)
Returns transformed version of this element. The returned object implementsGeomTransform
and contains transformed versions of the contents of this list as children.- Parameters:
transform
- The transform to apply to this geometry element. May not be null.- Returns:
- A transformed version of this geometry element.
- Throws:
DimensionException
- if this element is not 3D.
-
set
public PointString<E> set(int index, PointString<E> element)
Replaces thePointString
at the specified position in this list with the specified element. Null elements are ignored. The input element must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
set
in interfacejava.util.List<E extends GeomPoint>
- Overrides:
set
in classAbstractPointGeomList<PointArray<E extends GeomPoint>,PointString<E extends GeomPoint>>
- Parameters:
index
- The index of the element to replace (0 returns the 1st element, -1 returns the last, -2 returns the 2nd from last, etc).element
- The element to be stored at the specified position.null
elements are ignored.- Returns:
- The element previously at the specified position in this list. May not be null.
- Throws:
java.lang.IndexOutOfBoundsException
- - ifindex > size()
DimensionException
- if the input element's dimensions are different from this list's dimensions.
-
add
public void add(int index, PointString<E> value)
Inserts the specifiedPointString
at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). Null values are ignored. The input value must have the same physical dimensions as the other items in this list, or an exception is thrown.Note: If this method is used concurrent access must be synchronized (the list is not thread-safe).
- Specified by:
add
in interfacejava.util.List<E extends GeomPoint>
- Overrides:
add
in classAbstractPointGeomList<PointArray<E extends GeomPoint>,PointString<E extends GeomPoint>>
- Parameters:
index
- the index at which the specified element is to be inserted. (0 returns the 1st element, -1 returns the last, -2 returns the 2nd from last, etc).value
- the element to be inserted. May not be null.- Throws:
java.lang.IndexOutOfBoundsException
- ifindex > size()
DimensionException
- if the input value dimensions are different from this list's dimensions.
-
addAll
public boolean addAll(int index, java.util.Collection<? extends PointString<E>> c)
Inserts all of thePointString
objects in the specified collection into this list at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. Note that this will occur if the specified collection is this list, and it's nonempty. The input elements must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
addAll
in interfacejava.util.List<E extends GeomPoint>
- Overrides:
addAll
in classAbstractGeomList<PointArray<E extends GeomPoint>,PointString<E extends GeomPoint>>
- Parameters:
index
- index at which to insert first element from the specified collection.c
- elements to be inserted into this collection. May not be null.- Returns:
true
if this collection changed as a result of the call.- Throws:
DimensionException
- if the input element's dimensions are different from this list's dimensions.
-
recycle
public static void recycle(PointArray instance)
Recycles a case instance immediately (on the stack when executing in a StackContext).- Parameters:
instance
- The instance to be recycled.
-
main
public static void main(java.lang.String[] args)
Tests the methods in this class.- Parameters:
args
- Command-line arguments (ignored).
-
-