de.cau.cs.kieler.klay.layered.p5edges
Class SplineGenerator

java.lang.Object
  extended by de.cau.cs.kieler.klay.layered.p5edges.SplineGenerator

public class SplineGenerator
extends Object

Simple implementation for the spline calculator.

Rating red

Nested Class Summary
static class SplineGenerator.Curvature
          Defines whether curvature should be increased or decreased.
 
Constructor Summary
SplineGenerator()
           
 
Method Summary
 BezierSpline generateShortSpline(KVector q, KVector s)
          Generates a spline representation for straight edges.
 BezierSpline generateSpline(LinkedList<KVector> pArray)
          generates a simple piecewise bezier curve for given points.
 BezierSpline generateSpline(LinkedList<KVector> pArray, KVector vectorQ, KVector vectorS)
          generates a simple piecewise bezier curve for given points.
 boolean refineSpline(LinkedList<KVector> pArray, BezierSpline ospline, SplineGenerator.Curvature mode)
          perturb the control points of the spline in an attempt to make the spline fit.
 boolean straightenSpline(BezierSpline spline)
          straighten_spline adjusts the control points of the spline to reduce the curvature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplineGenerator

public SplineGenerator()
Method Detail

generateSpline

public BezierSpline generateSpline(LinkedList<KVector> pArray,
                                   KVector vectorQ,
                                   KVector vectorS)
generates a simple piecewise bezier curve for given points.

Parameters:
pArray - array with points which should be lay on the spline
vectorQ - outgoing tangent vector of the initial node
vectorS - incoming tangent vector of the final node
Returns:
created spline

generateSpline

public BezierSpline generateSpline(LinkedList<KVector> pArray)
generates a simple piecewise bezier curve for given points.

Parameters:
pArray - array with points which should be lay on the spline
Returns:
created spline

generateShortSpline

public BezierSpline generateShortSpline(KVector q,
                                        KVector s)
Generates a spline representation for straight edges.

Parameters:
q - start point
s - end point
Returns:
BezierSpline representation.

refineSpline

public boolean refineSpline(LinkedList<KVector> pArray,
                            BezierSpline ospline,
                            SplineGenerator.Curvature mode)
perturb the control points of the spline in an attempt to make the spline fit. The approach is similar to the straightening approach. We try to decrease the curvature of the spline. If this does not seem to improve the fit, we try to increase the curvature. Since this process may never terminate, max_iterations controls how many times to try.

Parameters:
pArray - array with points which should be lay on the spline
ospline - spline to be refined
mode - either decrease or increase the curvature
Returns:
created spline

straightenSpline

public boolean straightenSpline(BezierSpline spline)
straighten_spline adjusts the control points of the spline to reduce the curvature. the method is only used if there's only one bezier segment in the spline

Parameters:
spline - spline to be straightened
Returns:
true if successful otherwise false