math.geom2d.curve
Class PolyCurve2D<T extends ContinuousCurve2D>

java.lang.Object
  extended by math.geom2d.curve.CurveSet2D<T>
      extended by math.geom2d.curve.PolyCurve2D<T>
All Implemented Interfaces:
java.awt.Shape, java.lang.Iterable<T>, ContinuousCurve2D, Curve2D, Shape2D
Direct Known Subclasses:
PolyBezierCurve2D, PolyOrientedCurve2D

public class PolyCurve2D<T extends ContinuousCurve2D>
extends CurveSet2D<T>
implements ContinuousCurve2D

A PolyCurve2D is a set of piecewise smooth curve arcs, such that the end of a curve is the beginning of the next curve, and such that they do not intersect nor self-intersect.

Author:
dlegland

Field Summary
protected  boolean closed
           
 
Fields inherited from class math.geom2d.curve.CurveSet2D
curves
 
Fields inherited from interface math.geom2d.curve.ContinuousCurve2D
CIRCLE, CLOSED_EDGE, LOOP, OPEN_EDGE
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY, defaultClipWindow, EMPTY_SET
 
Constructor Summary
PolyCurve2D()
           
PolyCurve2D(java.util.Collection<? extends T> curves)
           
PolyCurve2D(T[] curves)
           
 
Method Summary
 java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
          Append the path of the curve to the given path.
 CurveSet2D<? extends ContinuousCurve2D> clip(Box2D box)
          Clip the PolyCurve2D by a box.
 Polyline2D getAsPolyline(int n)
          Returns an approximation of the curve as a polyline with n line segments.
protected  java.awt.geom.GeneralPath getGeneralPath()
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans, double flatness)
           
 PolyCurve2D<? extends ContinuousCurve2D> getReverseCurve()
          Returns the curve with same trace on the plane with parametrization in reverse order.
 java.util.Collection<? extends SmoothCurve2D> getSmoothPieces()
          Returns a collection containing only instances of SmoothCurve2D.
 PolyCurve2D<? extends ContinuousCurve2D> getSubCurve(double t0, double t1)
          Return an instance of PolyCurve2D.
 boolean isClosed()
          Return true if the curve makes a loop, that is come back to starting point after covering the path.
 void setClosed(boolean b)
           
 PolyCurve2D<? extends ContinuousCurve2D> transform(AffineTransform2D trans)
          Transform each curve, and build a new CurveSet2D with the set of transformed curves.
 
Methods inherited from class math.geom2d.curve.CurveSet2D
addCurve, clearCurves, contains, contains, contains, contains, equals, fromUnitSegment, getBoundingBox, getBounds, getBounds2D, getContinuousCurves, getCurveNumber, getCurves, getDistance, getDistance, getFirstCurve, getFirstPoint, getIntersections, getLastCurve, getLastPoint, getPoint, getPoint, getPosition, getT0, getT1, intersects, intersects, isBounded, isEmpty, iterator, project, removeCurve, toUnitSegment
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface math.geom2d.curve.Curve2D
getContinuousCurves, getFirstPoint, getIntersections, getLastPoint, getPoint, getPoint, getPosition, getT0, getT1, project
 
Methods inherited from interface math.geom2d.Shape2D
getBoundingBox, getDistance, getDistance, isBounded
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getBounds, getBounds2D, intersects, intersects
 

Field Detail

closed

protected boolean closed
Constructor Detail

PolyCurve2D

public PolyCurve2D()

PolyCurve2D

public PolyCurve2D(T[] curves)

PolyCurve2D

public PolyCurve2D(java.util.Collection<? extends T> curves)
Method Detail

setClosed

public void setClosed(boolean b)

getAsPolyline

public Polyline2D getAsPolyline(int n)
Description copied from interface: ContinuousCurve2D
Returns an approximation of the curve as a polyline with n line segments. If the curve is closed, the method should return an instance of ClosedPolyline2D.

Specified by:
getAsPolyline in interface ContinuousCurve2D
Parameters:
n - the number of line segments
Returns:
a closed polyline with n line segments.

isClosed

public boolean isClosed()
Description copied from interface: ContinuousCurve2D
Return true if the curve makes a loop, that is come back to starting point after covering the path.

Specified by:
isClosed in interface ContinuousCurve2D

getSmoothPieces

public java.util.Collection<? extends SmoothCurve2D> getSmoothPieces()
Returns a collection containing only instances of SmoothCurve2D.

Specified by:
getSmoothPieces in interface ContinuousCurve2D
Returns:
a collection of SmoothCurve2D

getReverseCurve

public PolyCurve2D<? extends ContinuousCurve2D> getReverseCurve()
Description copied from interface: Curve2D
Returns the curve with same trace on the plane with parametrization in reverse order.

Specified by:
getReverseCurve in interface ContinuousCurve2D
Specified by:
getReverseCurve in interface Curve2D
Overrides:
getReverseCurve in class CurveSet2D<T extends ContinuousCurve2D>

getSubCurve

public PolyCurve2D<? extends ContinuousCurve2D> getSubCurve(double t0,
                                                            double t1)
Return an instance of PolyCurve2D. If t0>t1 and curve is not closed, return a PolyCurve2D without curves inside.

Specified by:
getSubCurve in interface ContinuousCurve2D
Specified by:
getSubCurve in interface Curve2D
Overrides:
getSubCurve in class CurveSet2D<T extends ContinuousCurve2D>
Parameters:
t0 - position of the start of the sub-curve
t1 - position of the end of the sub-curve
Returns:
the portion of original curve comprised between t0 and t1.

clip

public CurveSet2D<? extends ContinuousCurve2D> clip(Box2D box)
Clip the PolyCurve2D by a box. The result is an instance of CurveSet2D, which contains only instances of ContinuousCurve2D. If the PolyCurve2D is not clipped, the result is an instance of CurveSet2D which contains 0 curves.

Specified by:
clip in interface ContinuousCurve2D
Specified by:
clip in interface Curve2D
Specified by:
clip in interface Shape2D
Overrides:
clip in class CurveSet2D<T extends ContinuousCurve2D>
Parameters:
box - the clipping box
Returns:
the clipped shape

transform

public PolyCurve2D<? extends ContinuousCurve2D> transform(AffineTransform2D trans)
Description copied from class: CurveSet2D
Transform each curve, and build a new CurveSet2D with the set of transformed curves.

Specified by:
transform in interface ContinuousCurve2D
Specified by:
transform in interface Curve2D
Specified by:
transform in interface Shape2D
Overrides:
transform in class CurveSet2D<T extends ContinuousCurve2D>
Parameters:
trans - an affine transform
Returns:
the transformed shape

appendPath

public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
Description copied from interface: ContinuousCurve2D
Append the path of the curve to the given path.

Specified by:
appendPath in interface ContinuousCurve2D
Parameters:
path - a path to modify
Returns:
the modified path

getGeneralPath

protected java.awt.geom.GeneralPath getGeneralPath()
Overrides:
getGeneralPath in class CurveSet2D<T extends ContinuousCurve2D>

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans)
Specified by:
getPathIterator in interface java.awt.Shape
Overrides:
getPathIterator in class CurveSet2D<T extends ContinuousCurve2D>

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans,
                                                  double flatness)
Specified by:
getPathIterator in interface java.awt.Shape
Overrides:
getPathIterator in class CurveSet2D<T extends ContinuousCurve2D>