Package geomss.geom
Class LinearComboCurve
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<T>
-
- geomss.geom.AbstractCurve<LinearComboCurve>
-
- geomss.geom.LinearComboCurve
-
- All Implemented Interfaces:
Curve<LinearComboCurve>
,GeomElement<LinearComboCurve>
,GeometryList<LinearComboCurve,Curve>
,LinearCombination<LinearComboCurve,Curve>
,ParametricGeometry<LinearComboCurve>
,Transformable<LinearComboCurve>
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,java.lang.Iterable<Curve>
,java.util.Collection<Curve>
,java.util.List<Curve>
,javolution.lang.Reusable
,javolution.xml.XMLSerializable
public class LinearComboCurve extends AbstractCurve<LinearComboCurve> implements LinearCombination<LinearComboCurve,Curve>
Represents a linear combination made up of a list ofCurve
objects. A linear combination curve is formed by a weighted linear addition of a list of one or more curves. For example:B = W1*Crv_1 + ... + Wn*Crv_n
where W1 through Wn are scalar weights. The linear addition is done independently of physical dimension (each dimension is added separately) and the weighted addition is done in parameter space:B = W1*Crv_1(s) + ... + Wn*Crv_n(s)
.Any number of curves may be added to a LinearComboCurve, but they all must have the same physical dimensions.
Modified by: Joseph A. Huwaldt
- Version:
- February 17, 2025
- Author:
- Joseph A. Huwaldt, Date: September 8, 2015
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class geomss.geom.AbstractCurve
GTOL
-
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, Curve value)
Inserts the specifiedCurve
at the specified position in this list with a default weight of 1.0.boolean
add(int index, Curve... array)
Inserts all of theCurve
objects in the specified list of arguments into this LinearComboCurve at the specified position with a default weight of 1.0 assigned to each.void
add(int index, Curve curve, java.lang.Double weight)
Inserts the specifiedCurve
at the specified position in this list.boolean
add(Curve curve)
Appends the specifiedCurve
to the end of this LinearComboCurve with a default weight of 1.0.boolean
add(Curve... array)
Appends all of the elements in the specified list of arguments to this LinearComboCurve with a default weight of 1.0 assigned to each.boolean
add(Curve curve, java.lang.Double weight)
Appends the specifiedCurve
to the end of this list of curves.boolean
addAll(int index, Curve[] arr)
Inserts all of theCurve
objects in the specified array into this LinearComboCurve at the specified position with a default weight of 1.0 assigned to each.boolean
addAll(int index, java.util.Collection<? extends Curve> curves)
Inserts all of the curves in the specified collection of curves into this LinearComboCurve with default weights of 1.0 for each.boolean
addAll(int index, java.util.Collection<? extends Curve> curves, java.util.Collection<java.lang.Double> weights)
Inserts all of the curves in the specified collection and their associated weights into this LinearComboCurve at the specified position.boolean
addAll(Curve[] arr)
Appends all of the curves in the specified array to this LinearComboCurve with a default weight of 1.0 assigned to each.boolean
addAll(java.util.Collection<? extends Curve> curves)
Adds all of the curves in the specified collection to this LinearComboCurve with a default weight of 1.0 for each.boolean
addAll(java.util.Collection<? extends Curve> curves, java.util.Collection<java.lang.Double> weights)
Appends all of the curves in the specified collection to this LinearComboCurve.void
clear()
Removes all of the curves from this linear combination.boolean
contains(java.lang.Object o)
Returns true if this LinearComboCurve contains the specifiedCurve
.boolean
containsAll(java.util.Collection<?> c)
Returns true if this collection contains all of theCurve
objects in the specified collection.boolean
containsGeometry()
Returnstrue
if this list actually contains any curves andfalse
if this list is empty.LinearComboCurve
copy()
Returns a copy of thisLinearComboCurve
instanceallocated
by the calling thread (possibly on the stack).LinearComboCurve
copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).boolean
equals(java.lang.Object obj)
Compares the specified object with this list ofCurve
objects for equality.Curve
get(int index)
Returns the Curve at the specified position in this LinearComboCurve.Curve
get(java.lang.String name)
Returns theCurve
with the specified name from this list.GeomList<Curve>
getAll()
Returns an newGeomList
with all the curves in this list.Point
getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).Point
getBoundsMin()
Return the coordinate point representing the minimum bounding box corner of this geometry element (e.g.: min X, min Y, min Z).Curve
getFirst()
Returns the first curve from this LinearComboCurve.java.lang.Double
getFirstWeight()
Returns the first linear combination weight from this LinearComboCurve.int
getIndexFromName(java.lang.String name)
Return the index to the 1st Curve in this list with the specified name.Curve
getLast()
Returns the last curve from this LinearComboCurve list of curves.java.lang.Double
getLastWeight()
Returns the last linear combination weight from this LinearComboCurve.int
getPhyDimension()
Returns the number of physical dimensions of the geometry element.LinearComboCurve
getRange(int first, int last)
Returns the range of Curves in this LinearComboCurve from the specified start and ending indexes as a new LinearComboCurve.Point
getRealPoint(double s)
Calculate a point on the curve for the given parametric distance along the curve.java.util.List<Vector<javax.measure.quantity.Length>>
getSDerivatives(double s, int grade)
Calculate all the derivatives from0
tograde
with respect to parametric distance on the curve for the given parametric distance along the curve,d^{grade}p(s)/d^{grade}s
.LinearComboCurve
getTransformed(GTransform transform)
Returns a transformed version of this element.javax.measure.unit.Unit<javax.measure.quantity.Length>
getUnit()
Returns the unit in which the curves in this linear combination curve are stated.java.lang.Double
getWeight(int index)
Returns the linear combination weight at the specified position in this LinearComboCurve.java.util.List<java.lang.Double>
getWeightRange(int first, int last)
Returns the range of linear combination weights in this LinearComboCurve from the specified start and ending indexes as a List of double values.int
hashCode()
Returns the hash code for thisLinearComboCurve
.int
indexOf(java.lang.Object element)
Returns the index in this list of the first occurrence of the specifiedCurve
, or -1 if the list does not contain this curve.boolean
isEmpty()
Returnstrue
if this collection contains no elements.boolean
isValid()
Returntrue
if this LinearComboCurve contains valid and finite numerical components.java.util.Iterator<Curve>
iterator()
Returns an iterator over the curves in this LinearComboCurve.int
lastIndexOf(java.lang.Object element)
Returns the index in this list of the last occurrence of the specifiedCurve
, or -1 if the list does not contain this curve.java.util.ListIterator<Curve>
listIterator()
Returns a list iterator over the curves in this LinearComboCurve.java.util.ListIterator<Curve>
listIterator(int index)
Returns a Curve list iterator from the specified position.static LinearComboCurve
newInstance()
Returns a new, empty, preallocated or recycledLinearComboCurve
instance (on the stack when executing in aStackContext
), that can store a list ofCurve
objects and associated weighting factors.static LinearComboCurve
newInstance(java.lang.String name)
Returns a new, empty, preallocated or recycledLinearComboCurve
instance (on the stack when executing in aStackContext
), that can store a list ofCurve
objects and associated weighting factors.static void
recycle(LinearComboCurve instance)
Recycles a case instance immediately (on the stack when executing in a StackContext).Curve
remove(int index)
Removes the curve (and its associated weight) at the specified position in this LinearComboCurve.boolean
remove(java.lang.Object o)
Removes a single instance of the specifiedCurve
(and its associated weight) from this collection, if it is present.Curve
remove(java.lang.String name)
Removes the curve with the specified name from this list.boolean
removeAll(java.util.Collection<?> c)
Removes from this list all theCurve
objects that are contained in the specified collection.void
reset()
Resets the internal state of this object to its default values.boolean
retainAll(java.util.Collection<?> c)
Retains only the curves in this list that are contained in the specified collection.LinearComboCurve
reverse()
Return a new curve that is identical to this one, but with the parameterization reversed.Curve
set(int index, Curve curve)
Replaces the Curve at the specified position in this list of curves with the specified Curve.Curve
set(int index, Curve curve, java.lang.Double weight)
Replaces the Curve and weight at the specified position in this LinearComboCurve with the specified curve and weight.java.lang.Double
setWeight(int index, java.lang.Double weight)
Replaces the weight at the specified position in this LinearComboCurve with the specified weight.int
size()
Returns the number ofCurve
objects that make up this linear combination curve.GeomList<LinearComboCurve>
splitAt(double s)
Split this curve at the specified parametric position returning a list containing two curves (a lower curve with smaller parametric positions than "s" and an upper curve with larger parametric positions).LinearComboCurve
subList(int fromIndex, int toIndex)
Returns a view of the portion of this LinearComboCurve between fromIndex, inclusive, and toIndex, exclusive.LinearComboCurve
to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns the equivalent to this LinearComboCurve but stated in the specified unit.Curve[]
toArray()
Returns an array containing all of the curves in this collection.<T> T[]
toArray(T[] a)
Returns an array containing all of the curves in this collection.LinearComboCurve
toDimension(int newDim)
Return the equivalent of this LinearComboCurve converted to the specified number of physical dimensions.NurbsCurve
toNurbs(Parameter<javax.measure.quantity.Length> tol)
Return a NURBS curve representation of this curve to within the specified tolerance.javolution.text.Text
toText()
Returns the text representation of this geometry element.java.util.List<Curve>
unmodifiableList()
Returns an unmodifiable list view of the curves in this list.java.util.List<java.lang.Double>
unmodifiableWeightList()
Returns an unmodifiable list view of the weights in this list.static LinearComboCurve
valueOf(Curve... curves)
Return a LinearComboCurve made up of theCurve
objects in the specified array each with a default weight of 1.0.static LinearComboCurve
valueOf(java.util.Collection<? extends Curve> curves, java.util.Collection<java.lang.Double> weights)
Return a LinearComboCurve made up of theCurve
and weight objects in the specified collections.-
Methods inherited from class geomss.geom.AbstractCurve
extractGrid, getArcLength, getArcLength, getArcLength, getBinormal, getBinormal, getClosest, getClosest, getClosest, getClosest, getClosest, getClosest, getCurvature, getCurvature, getDerivatives, getEnclosedArea, getFarthest, getFarthest, getFarthest, getLimitPoint, getParDimension, getPoint, getPoint, getPointAtArcLength, getPrincipalNormal, getPrincipalNormal, getRealPoint, getSDerivative, getSDerivatives, getTangencyPoint, getTangent, getTangent, getTorsion, getTorsion, getVariationOfCurvature, getVariationOfCurvature, gridToTolerance, intersect, intersect, intersect, intersect, intersect, isCircular, isDegenerate, isLine, isPlanar, splitAt
-
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, getID, getLimitPoint, getName, getParDimension, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName
-
-
-
-
Method Detail
-
newInstance
public static LinearComboCurve newInstance()
Returns a new, empty, preallocated or recycledLinearComboCurve
instance (on the stack when executing in aStackContext
), that can store a list ofCurve
objects and associated weighting factors. The list is initially empty and therefore the linear combination is initially undefined.- Returns:
- A new empty LinearComboCurve.
-
newInstance
public static LinearComboCurve newInstance(java.lang.String name)
Returns a new, empty, preallocated or recycledLinearComboCurve
instance (on the stack when executing in aStackContext
), that can store a list ofCurve
objects and associated weighting factors. The list is initially empty and therefore the linear combination is initially undefined.- Parameters:
name
- The name to be assigned to this LinearComboCurve (may be null).- Returns:
- A new empty LinearComboCurve.
-
valueOf
public static LinearComboCurve valueOf(java.util.Collection<? extends Curve> curves, java.util.Collection<java.lang.Double> weights)
Return a LinearComboCurve made up of theCurve
and weight objects in the specified collections.- Parameters:
curves
- A collection of curves that define the LinearComboCurve. May not be null.weights
- A collection of weights (one for each curve). May not be null and must have the same size as "curves".- Returns:
- A new LinearComboCurve made up of the curves and weights in the specified collections.
-
valueOf
public static LinearComboCurve valueOf(Curve... curves)
Return a LinearComboCurve made up of theCurve
objects in the specified array each with a default weight of 1.0.- Parameters:
curves
- An array of curves that define the LinearComboCurve. May not be null.- Returns:
- A new LinearComboCurve made up of the curves in the specified array each with a default weight of 1.0.
-
unmodifiableList
public java.util.List<Curve> unmodifiableList()
Returns an unmodifiable list view of the curves in this list. Attempts to modify the returned collection result in an UnsupportedOperationException being thrown.- Specified by:
unmodifiableList
in interfaceGeometryList<LinearComboCurve,Curve>
- Returns:
- the unmodifiable view over this list of curves.
-
unmodifiableWeightList
public java.util.List<java.lang.Double> unmodifiableWeightList()
Returns an unmodifiable list view of the weights in this list. Attempts to modify the returned collection result in an UnsupportedOperationException being thrown.- Specified by:
unmodifiableWeightList
in interfaceLinearCombination<LinearComboCurve,Curve>
- Returns:
- the unmodifiable view over this list of weights.
-
isEmpty
public boolean isEmpty()
Returnstrue
if this collection contains no elements.
-
containsGeometry
public boolean containsGeometry()
Returnstrue
if this list actually contains any curves andfalse
if this list is empty.- Specified by:
containsGeometry
in interfaceGeometryList<LinearComboCurve,Curve>
- Returns:
- true if this list actually contains geometry.
-
size
public int size()
Returns the number ofCurve
objects that make up this linear combination curve. If the surface contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.- Specified by:
size
in interfacejava.util.Collection<Curve>
- Specified by:
size
in interfaceGeomElement<LinearComboCurve>
- Specified by:
size
in interfacejava.util.List<Curve>
- Returns:
- the number of elements in this list of curves.
-
get
public Curve get(int index)
Returns the Curve at the specified position in this LinearComboCurve.- Specified by:
get
in interfacejava.util.List<Curve>
- Parameters:
index
- index of curve to return (0 returns the 1st element, -1 returns the last, -2 returns the 2nd from last, etc).- Returns:
- the Curve at the specified position in this LinearComboCurve.
- Throws:
java.lang.IndexOutOfBoundsException
- if the given index is out of range:index > size()
-
getWeight
public java.lang.Double getWeight(int index)
Returns the linear combination weight at the specified position in this LinearComboCurve.- Specified by:
getWeight
in interfaceLinearCombination<LinearComboCurve,Curve>
- Parameters:
index
- index of weight to return (0 returns the 1st element, -1 returns the last, -2 returns the 2nd from last, etc).- Returns:
- the linear combination weight at the specified position in this LinearComboCurve.
- Throws:
java.lang.IndexOutOfBoundsException
- if the given index is out of range:index > size()
-
getFirst
public Curve getFirst()
Returns the first curve from this LinearComboCurve.- Specified by:
getFirst
in interfaceGeometryList<LinearComboCurve,Curve>
- Returns:
- the first curve in this list.
-
getFirstWeight
public java.lang.Double getFirstWeight()
Returns the first linear combination weight from this LinearComboCurve.- Specified by:
getFirstWeight
in interfaceLinearCombination<LinearComboCurve,Curve>
- Returns:
- the first weight in this list.
-
getLast
public Curve getLast()
Returns the last curve from this LinearComboCurve list of curves.- Specified by:
getLast
in interfaceGeometryList<LinearComboCurve,Curve>
- Returns:
- the last curve in this list.
-
getLastWeight
public java.lang.Double getLastWeight()
Returns the last linear combination weight from this LinearComboCurve.- Specified by:
getLastWeight
in interfaceLinearCombination<LinearComboCurve,Curve>
- Returns:
- the last weight in this list.
-
getRange
public LinearComboCurve getRange(int first, int last)
Returns the range of Curves in this LinearComboCurve from the specified start and ending indexes as a new LinearComboCurve.- Specified by:
getRange
in interfaceGeometryList<LinearComboCurve,Curve>
- 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:
- A LinearComboCurve made up of the curves in the given range from this LinearComboCurve.
- Throws:
java.lang.IndexOutOfBoundsException
- if the given index is out of range:index ≥ size()
-
getWeightRange
public java.util.List<java.lang.Double> getWeightRange(int first, int last)
Returns the range of linear combination weights in this LinearComboCurve from the specified start and ending indexes as a List of double values.- Specified by:
getWeightRange
in interfaceLinearCombination<LinearComboCurve,Curve>
- 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:
- A List made up of the weights in the given range from this LinearComboCurve.
- Throws:
java.lang.IndexOutOfBoundsException
- if the given index is out of range:index ≥ size()
-
get
public Curve get(java.lang.String name)
Returns theCurve
with the specified name from this list.- Specified by:
get
in interfaceGeometryList<LinearComboCurve,Curve>
- Parameters:
name
- The name of the curve we are looking for in the list.- Returns:
- The curve matching the specified name. If the specified element name
isn't found in the list, then
null
is returned.
-
subList
public LinearComboCurve subList(int fromIndex, int toIndex)
Returns a view of the portion of this LinearComboCurve between fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned LinearComboCurve is empty.) The returned LinearComboCurve is backed by this LinearComboCurve, so changes in the returned LinearComboCurve are reflected in this LinearComboCurve, and vice-versa. This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of values from a list:list.subList(from, to).clear();
Similar idioms may be constructed forindexOf
andlastIndexOf
, and all of the algorithms in theCollections
class can be applied to a subList. The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list (structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results).- Specified by:
subList
in interfacejava.util.List<Curve>
- Parameters:
fromIndex
- low endpoint (inclusive) of the subList.toIndex
- high endpoint (exclusive) of the subList.- Returns:
- a view of the specified range within this LinearComboCurve.
- Throws:
java.lang.IndexOutOfBoundsException
- if the given index is out of range:index > size()
-
getAll
public GeomList<Curve> getAll()
Returns an newGeomList
with all the curves in this list.- Specified by:
getAll
in interfaceGeometryList<LinearComboCurve,Curve>
- Returns:
- A new GeomList with all the curves in this list.
-
reverse
public LinearComboCurve reverse()
Return a new curve that is identical to this one, but with the parameterization reversed.- Specified by:
reverse
in interfaceCurve<LinearComboCurve>
- Specified by:
reverse
in interfaceGeometryList<LinearComboCurve,Curve>
- Returns:
- A new curve that is identical to this one, but with the parameterization reversed.
-
indexOf
public int indexOf(java.lang.Object element)
Returns the index in this list of the first occurrence of the specifiedCurve
, or -1 if the list does not contain this curve.- Specified by:
indexOf
in interfacejava.util.List<Curve>
- Parameters:
element
- The Curve to search for.- Returns:
- the index in this List of the first occurrence of the specified curve, or -1 if the List does not contain this curve.
-
lastIndexOf
public int lastIndexOf(java.lang.Object element)
Returns the index in this list of the last occurrence of the specifiedCurve
, or -1 if the list does not contain this curve. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.- Specified by:
lastIndexOf
in interfacejava.util.List<Curve>
- Parameters:
element
- The Curve to search for.- Returns:
- the index in this list of the last occurrence of the specified curve, or -1 if the list does not contain this curve.
-
contains
public boolean contains(java.lang.Object o)
Returns true if this LinearComboCurve contains the specifiedCurve
. More formally, returns true if and only if this LinearComboCurve's curves contains at least one element e such that (o==null ? e==null : o.equals(e)).
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
Returns true if this collection contains all of theCurve
objects in the specified collection.- Specified by:
containsAll
in interfacejava.util.Collection<Curve>
- Specified by:
containsAll
in interfacejava.util.List<Curve>
- Parameters:
c
- collection of curves to be checked for containment in this collection.- Returns:
true
if this collection contains all of the curves in the specified collection.
-
getIndexFromName
public int getIndexFromName(java.lang.String name)
Return the index to the 1st Curve in this list with the specified name.- Specified by:
getIndexFromName
in interfaceGeometryList<LinearComboCurve,Curve>
- Parameters:
name
- The name of the Curve to find in this list- Returns:
- The index to the named Curve or -1 if it is not found.
-
add
public void add(int index, Curve value)
Inserts the specifiedCurve
at the specified position in this list with a default weight of 1.0. 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 table is not thread-safe).
- Specified by:
add
in interfacejava.util.List<Curve>
- 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 Curve to be inserted with a default weight of 1.0.- Throws:
java.lang.IndexOutOfBoundsException
- ifindex > size()
DimensionException
- if the input value dimensions are different from this list's dimensions.
-
add
public void add(int index, Curve curve, java.lang.Double weight)
Inserts the specifiedCurve
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 curve 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 table is not thread-safe).
- Specified by:
add
in interfaceLinearCombination<LinearComboCurve,Curve>
- 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).curve
- The Curve to be inserted. May not be null.weight
- The linear combination weight of the curve to be inserted. May not be null.- Throws:
java.lang.IndexOutOfBoundsException
- ifindex > size()
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
add
public boolean add(Curve curve)
Appends the specifiedCurve
to the end of this LinearComboCurve with a default weight of 1.0. Null values are ignored. The input curve 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 table is not thread-safe).
- Specified by:
add
in interfacejava.util.Collection<Curve>
- Specified by:
add
in interfacejava.util.List<Curve>
- Parameters:
curve
- The curve to be appended to this list with a default weight of 1.0. May not be null.- Returns:
- true if this list changed as a result of this call.
- Throws:
DimensionException
- if the input element's dimensions are different from this list's dimensions.DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
add
public boolean add(Curve curve, java.lang.Double weight)
Appends the specifiedCurve
to the end of this list of curves. Null values are ignored. The input curve 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 table is not thread-safe).
- Specified by:
add
in interfaceLinearCombination<LinearComboCurve,Curve>
- Parameters:
curve
- The curve to be appended to this list. May not be null.weight
- The linear combination weight of the curve to be appended. May not be null.- Returns:
- true if this list changed as a result of this call.
- Throws:
DimensionException
- if the input element's dimensions are different from this list's dimensions.DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
add
public boolean add(Curve... array)
Appends all of the elements in the specified list of arguments to this LinearComboCurve with a default weight of 1.0 assigned to each. The input curve must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
add
in interfaceGeometryList<LinearComboCurve,Curve>
- Parameters:
array
- the curves to be inserted into this collection with a default weight of 1.0 assigned to each. May not be null.- Returns:
true
if this collection changed as a result of the call.- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
add
public boolean add(int index, Curve... array)
Inserts all of theCurve
objects in the specified list of arguments into this LinearComboCurve at the specified position with a default weight of 1.0 assigned to each. 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 appeared in the array. The input curve must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
add
in interfaceGeometryList<LinearComboCurve,Curve>
- Parameters:
index
- index at which to insert first element from the specified array.array
- the curves to be inserted into this collection with a default weight of 1.0 for each. May not be null.- Returns:
true
if this collection changed as a result of the call.- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
addAll
public boolean addAll(java.util.Collection<? extends Curve> curves)
Adds all of the curves in the specified collection to this LinearComboCurve with a default weight of 1.0 for each. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty. The input curves must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
addAll
in interfacejava.util.Collection<Curve>
- Specified by:
addAll
in interfacejava.util.List<Curve>
- Parameters:
curves
- curves to be inserted into this list with a default of 1.0 for each. May not be null.- Returns:
true
if this LinearComboCurve changed as a result of the call- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
addAll
public boolean addAll(int index, java.util.Collection<? extends Curve> curves)
Inserts all of the curves in the specified collection of curves into this LinearComboCurve with default weights of 1.0 for each. Shifts the curve currently at that position (if any) and any subsequent curves to the right (increases their indices). The new curves 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 curves 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<Curve>
- Parameters:
index
- index at which to insert first curve from the specified collection.curves
- curves to be inserted into this list with default weights of 1.0 for each. May not be null.- Returns:
true
if this LinearComboCurve changed as a result of the call- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
addAll
public boolean addAll(java.util.Collection<? extends Curve> curves, java.util.Collection<java.lang.Double> weights)
Appends all of the curves in the specified collection to this LinearComboCurve. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty. The input curves must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
addAll
in interfaceLinearCombination<LinearComboCurve,Curve>
- Parameters:
curves
- the curves to be appended onto this list of curves. May not be null.weights
- the linear combination weights associated with all of the curves being appended. May not be null and must be the same size as "curves".- Returns:
true
if this LinearComboCurve changed as a result of the call- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
addAll
public boolean addAll(int index, java.util.Collection<? extends Curve> curves, java.util.Collection<java.lang.Double> weights)
Inserts all of the curves in the specified collection and their associated weights into this LinearComboCurve at the specified position. Shifts the curve currently at that position (if any) and any subsequent curves to the right (increases their indices). The new curves 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 curves must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
addAll
in interfaceLinearCombination<LinearComboCurve,Curve>
- Parameters:
index
- index at which to insert first curve from the specified collection.curves
- the curves to be inserted into this linear combination. May not be null.weights
- the linear combination weights associated with each curve being inserted. May not be null and must be the same size as "curves".- Returns:
true
if this LinearComboCurve changed as a result of the call- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
addAll
public boolean addAll(Curve[] arr)
Appends all of the curves in the specified array to this LinearComboCurve with a default weight of 1.0 assigned to each. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. The input curves must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
addAll
in interfaceGeometryList<LinearComboCurve,Curve>
- Parameters:
arr
- curves to be appended onto this collection with a default weight of 1.0 for each. May not be null.- Returns:
true
if this collection changed as a result of the call.- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
addAll
public boolean addAll(int index, Curve[] arr)
Inserts all of theCurve
objects in the specified array into this LinearComboCurve at the specified position with a default weight of 1.0 assigned to each. 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 input curves must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
addAll
in interfaceGeometryList<LinearComboCurve,Curve>
- Parameters:
index
- index at which to insert first element from the specified array.arr
- the curves to be inserted into this collection with a default weight of 1.0 for each. May not be null.- Returns:
true
if this collection changed as a result of the call.- Throws:
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
set
public Curve set(int index, Curve curve)
Replaces the Curve at the specified position in this list of curves with the specified Curve. The weight at that position is left unchanged. Null elements are ignored. The input curve 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<Curve>
- Parameters:
index
- The index of the curve to replace (0 returns the 1st curve, -1 returns the last, -2 returns the 2nd from last, etc).curve
- The curve to be stored at the specified position. The weight at that position is left unchanged. May not be null.- Returns:
- The curve previously at the specified position in this list.
- Throws:
java.lang.IndexOutOfBoundsException
- - ifindex > size()
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
setWeight
public java.lang.Double setWeight(int index, java.lang.Double weight)
Replaces the weight at the specified position in this LinearComboCurve with the specified weight. The curve at that position is left unchanged. Null elements are ignored.- Specified by:
setWeight
in interfaceLinearCombination<LinearComboCurve,Curve>
- Parameters:
index
- The index of the weight to replace (0 returns the 1st element, -1 returns the last, -2 returns the 2nd from last, etc).weight
- The weight to be stored at the specified position. The curve at that position is left unchanged. May not be null.- Returns:
- The weight previously at the specified position in this list.
- Throws:
java.lang.IndexOutOfBoundsException
- - ifindex > size()
-
set
public Curve set(int index, Curve curve, java.lang.Double weight)
Replaces the Curve and weight at the specified position in this LinearComboCurve with the specified curve and weight. Null elements are ignored. The input curve must have the same physical dimensions as the other items in this list, or an exception is thrown.- Specified by:
set
in interfaceLinearCombination<LinearComboCurve,Curve>
- Parameters:
index
- The index of the curve and weight to replace (0 returns the 1st element, -1 returns the last, -2 returns the 2nd from last, etc).curve
- The curve to be stored at the specified position. May not be null.weight
- The weight to be stored at the specified position. May not be null.- Returns:
- The curve previously at the specified position in this list. The previous weight is lost.
- Throws:
java.lang.IndexOutOfBoundsException
- - ifindex > size()
DimensionException
- if the input curve dimensions are different from this list's dimensions.
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
Removes from this list all theCurve
objects that are contained in the specified collection.
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
Retains only the curves in this list that are contained in the specified collection. In other words, removes from this LinearComboCurve all theCurve
objects that are not contained in the specified collection.
-
remove
public boolean remove(java.lang.Object o)
Removes a single instance of the specifiedCurve
(and its associated weight) from this collection, if it is present. More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if this collection contains one or more such elements. Returns true if this collection contained the specified curve (or equivalently, if this collection changed as a result of the call).
-
remove
public Curve remove(int index)
Removes the curve (and its associated weight) at the specified position in this LinearComboCurve. Shifts any subsequent curves and weights to the left (subtracts one from their indices). Returns the curve that was removed from the list; the removed weight is lost.- Specified by:
remove
in interfacejava.util.List<Curve>
- Parameters:
index
- the index of the curve and weight to remove. (0 returns the 1st element, -1 returns the last, -2 returns the 2nd from last, etc).- Returns:
- the curve previously at the specified position.
-
remove
public Curve remove(java.lang.String name)
Removes the curve with the specified name from this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.- Specified by:
remove
in interfaceGeometryList<LinearComboCurve,Curve>
- Parameters:
name
- the name of the element to remove.- Returns:
- the element previously at the specified position.
-
clear
public void clear()
Removes all of the curves from this linear combination. The linear combination will be empty and undefined after this call returns.
-
iterator
public java.util.Iterator<Curve> iterator()
Returns an iterator over the curves in this LinearComboCurve.
-
listIterator
public java.util.ListIterator<Curve> listIterator()
Returns a list iterator over the curves in this LinearComboCurve.- Specified by:
listIterator
in interfacejava.util.List<Curve>
- Returns:
- an iterator over this list of curves.
-
listIterator
public java.util.ListIterator<Curve> listIterator(int index)
Returns a Curve list iterator from the specified position.- Specified by:
listIterator
in interfacejava.util.List<Curve>
- Parameters:
index
- the index of first Curve to be returned from the list iterator (by a call to the next method).- Returns:
- a list iterator of the curves in this list starting at the specified position in this list.
-
toArray
public <T> T[] toArray(T[] a)
Returns an array containing all of the curves in this collection. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.- Specified by:
toArray
in interfacejava.util.Collection<Curve>
- Specified by:
toArray
in interfacejava.util.List<Curve>
- Type Parameters:
T
- The type of elements in this LinearComboCurve (Curve type).- Parameters:
a
- the array into which the elements of the collection are to be stored, if it is big enough; otherwise, a new array of the same type is allocated for this purpose.- Returns:
- an array containing the curves of this collection.
-
getPhyDimension
public int getPhyDimension()
Returns the number of physical dimensions of the geometry element. This implementation always returns the physical dimension of the underlying Curve objects or 0 if this list has no Curve objects in it.- Specified by:
getPhyDimension
in interfaceGeomElement<LinearComboCurve>
- Returns:
- The number of physical dimensions of the geometry element.
-
getRealPoint
public Point getRealPoint(double s)
Calculate a point on the curve for the given parametric distance along the curve.- Specified by:
getRealPoint
in interfaceCurve<LinearComboCurve>
- Parameters:
s
- parametric distance to calculate a point for (0.0 to 1.0 inclusive).- Returns:
- the calculated point
-
getSDerivatives
public java.util.List<Vector<javax.measure.quantity.Length>> getSDerivatives(double s, int grade)
Calculate all the derivatives from0
tograde
with respect to parametric distance on the curve for the given parametric distance along the curve,d^{grade}p(s)/d^{grade}s
.Example:
1st derivative (grade = 1), this returns[p(s), dp(s)/ds]
;
2nd derivative (grade = 2), this returns[p(s), dp(s)/ds, d^2p(s)/d^2s]
; etc.- Specified by:
getSDerivatives
in interfaceCurve<LinearComboCurve>
- Parameters:
s
- Parametric distance to calculate derivatives for (0.0 to 1.0 inclusive).grade
- The maximum grade to calculate the derivatives for (1=1st derivative, 2=2nd derivative, etc)- Returns:
- A list of derivatives up to the specified grade of the curve at the specified parametric position.
- Throws:
java.lang.IllegalArgumentException
- if the grade is < 0.
-
splitAt
public GeomList<LinearComboCurve> splitAt(double s)
Split this curve at the specified parametric position returning a list containing two curves (a lower curve with smaller parametric positions than "s" and an upper curve with larger parametric positions).- Specified by:
splitAt
in interfaceCurve<LinearComboCurve>
- Parameters:
s
- The parametric position where this curve should be split (must not be 0 or 1!).- Returns:
- A list containing two curves: 0 == the lower curve, 1 == the upper curve.
-
isValid
public boolean isValid()
Returntrue
if this LinearComboCurve contains valid and finite numerical components. A value offalse
will be returned if any of the coordinate values or weights are NaN or Inf.- Specified by:
isValid
in interfaceGeomElement<LinearComboCurve>
- Returns:
- true if this line segment contains valid and finite data.
-
getTransformed
public LinearComboCurve getTransformed(GTransform transform)
Returns a transformed version of this element. The returned list of objects implementGeomTransform
and contains transformed versions of the contents of this list as children.- Specified by:
getTransformed
in interfaceTransformable<LinearComboCurve>
- Parameters:
transform
- The transformation to apply to this geometry. May not be null.- Returns:
- A new LinearCombonCurve that is identical to this one with the specified transformation applied to member curves.
- Throws:
DimensionException
- if this surface is not 3D.
-
getBoundsMin
public Point getBoundsMin()
Return the coordinate point representing the minimum bounding box corner of this geometry element (e.g.: min X, min Y, min Z).- Specified by:
getBoundsMin
in interfaceGeomElement<LinearComboCurve>
- Returns:
- The minimum bounding box coordinate for this geometry element.
- Throws:
java.lang.IndexOutOfBoundsException
- if this list contains no geometry.
-
getBoundsMax
public Point getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).- Specified by:
getBoundsMax
in interfaceGeomElement<LinearComboCurve>
- Returns:
- The maximum bounding box coordinate for this geometry element.
- Throws:
java.lang.IndexOutOfBoundsException
- if this list contains no elements.
-
getUnit
public javax.measure.unit.Unit<javax.measure.quantity.Length> getUnit()
Returns the unit in which the curves in this linear combination curve are stated.- Specified by:
getUnit
in interfaceGeomElement<LinearComboCurve>
- Returns:
- The unit in which the curves in this LinearComboCurve are stated or the default unit if this surface has no member curves.
-
to
public LinearComboCurve to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this LinearComboCurve but stated in the specified unit.- Specified by:
to
in interfaceCurve<LinearComboCurve>
- Specified by:
to
in interfaceGeomElement<LinearComboCurve>
- Specified by:
to
in interfaceGeometryList<LinearComboCurve,Curve>
- Specified by:
to
in interfaceParametricGeometry<LinearComboCurve>
- Parameters:
unit
- the length unit of the curve to be returned. May not be null.- Returns:
- an equivalent to this LinearComboCurve but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException
- if the the input unit is not a length unit.
-
toDimension
public LinearComboCurve toDimension(int newDim)
Return the equivalent of this LinearComboCurve 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 element is simply returned.- Specified by:
toDimension
in interfaceCurve<LinearComboCurve>
- Specified by:
toDimension
in interfaceGeomElement<LinearComboCurve>
- Specified by:
toDimension
in interfaceGeometryList<LinearComboCurve,Curve>
- Specified by:
toDimension
in interfaceParametricGeometry<LinearComboCurve>
- Parameters:
newDim
- The dimension of the curve to return.- Returns:
- This LinearComboCurve converted to the new dimensions.
-
toNurbs
public NurbsCurve toNurbs(Parameter<javax.measure.quantity.Length> tol)
Return a NURBS curve representation of this curve to within the specified tolerance.- Specified by:
toNurbs
in interfaceCurve<LinearComboCurve>
- Parameters:
tol
- The greatest possible difference between this curve and the NURBS representation returned. May not be null.- Returns:
- A NURBS curve that represents this curve to within the specified tolerance.
-
toText
public javolution.text.Text toText()
Returns the text representation of this geometry element.- Specified by:
toText
in interfaceGeomElement<LinearComboCurve>
- Overrides:
toText
in classAbstractGeomElement<LinearComboCurve>
- Returns:
- the text representation of this geometry element.
-
equals
public boolean equals(java.lang.Object obj)
Compares the specified object with this list ofCurve
objects for equality. Returns true if and only if both collections are of the same type and both collections contain equal elements in the same order.- Specified by:
equals
in interfacejava.util.Collection<Curve>
- Specified by:
equals
in interfacejava.util.List<Curve>
- Overrides:
equals
in classAbstractGeomElement<LinearComboCurve>
- Parameters:
obj
- the object to compare with.- Returns:
true
if this list is identical to that list;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code for thisLinearComboCurve
.- Specified by:
hashCode
in interfacejava.util.Collection<Curve>
- Specified by:
hashCode
in interfacejava.util.List<Curve>
- Overrides:
hashCode
in classAbstractGeomElement<LinearComboCurve>
- Returns:
- the hash code value.
-
copy
public LinearComboCurve copy()
Returns a copy of thisLinearComboCurve
instanceallocated
by the calling thread (possibly on the stack).- Specified by:
copy
in interfaceCurve<LinearComboCurve>
- Specified by:
copy
in interfaceGeomElement<LinearComboCurve>
- Specified by:
copy
in interfaceParametricGeometry<LinearComboCurve>
- Returns:
- an identical and independent copy of this object.
-
copyToReal
public LinearComboCurve copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Specified by:
copyToReal
in interfaceCurve<LinearComboCurve>
- Specified by:
copyToReal
in interfaceGeomElement<LinearComboCurve>
- Returns:
- A copy of this object with any transformations or subranges removed.
-
reset
public void reset()
Resets the internal state of this object to its default values. Subclasses that override this method must callsuper.reset();
to ensure that the state is reset properly.- Specified by:
reset
in interfacejavolution.lang.Reusable
- Overrides:
reset
in classAbstractGeomElement<LinearComboCurve>
-
recycle
public static void recycle(LinearComboCurve instance)
Recycles a case instance immediately (on the stack when executing in a StackContext).- Parameters:
instance
- The instance to be recycled.
-
-