com.caffeineowl.graphics.bezier.flatnessalgos
Class GenericCubicSubdivCriterion

java.lang.Object
  extended by com.caffeineowl.graphics.bezier.flatnessalgos.GenericCubicSubdivCriterion
All Implemented Interfaces:
CubicSubdivisionCriterion

public class GenericCubicSubdivCriterion
extends java.lang.Object
implements CubicSubdivisionCriterion

A CubicSubdivisionCriterion which does its job by using a provided CubicFlatnessAlgorithm and a tolerance: the criterion will ask for yet one subdivision whenever algorithm returns a flatness value that's greater than the required tolerance.

Author:
Adrian Colomitchi (acolomitchi(monkey_tail)gmail.com)

Field Summary
protected  CubicFlatnessAlgorithm flatnessAlgo
          The flatness algorithm.
protected  double sqTol
          Squared tolerance, for the CubicFlatnessAlgorithm that prefers working with squared distances.
protected  double tol
          The tolerance.
 
Constructor Summary
GenericCubicSubdivCriterion()
          Initalises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and a tolerance of 1.0e-5.
GenericCubicSubdivCriterion(CubicFlatnessAlgorithm algo)
          Initialises a new instance the provided flatness algo and a tolerance of 1.0e-5.
GenericCubicSubdivCriterion(CubicFlatnessAlgorithm algo, double tolerance)
          Initialises using the provided parameters.
GenericCubicSubdivCriterion(double tolerance)
          Initialises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and the provided tolerance.
 
Method Summary
 boolean shouldSplit(java.awt.geom.CubicCurve2D curve)
          Returns true whenever the flatnessAlgo returns a value greater than the required tolerance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flatnessAlgo

protected CubicFlatnessAlgorithm flatnessAlgo
The flatness algorithm.


tol

protected double tol
The tolerance.


sqTol

protected double sqTol
Squared tolerance, for the CubicFlatnessAlgorithm that prefers working with squared distances.

Constructor Detail

GenericCubicSubdivCriterion

public GenericCubicSubdivCriterion()
Initalises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and a tolerance of 1.0e-5.


GenericCubicSubdivCriterion

public GenericCubicSubdivCriterion(double tolerance)
Initialises a new instance with a ConvexHullFlatnessAlgo as the flatness algorithm and the provided tolerance.


GenericCubicSubdivCriterion

public GenericCubicSubdivCriterion(CubicFlatnessAlgorithm algo)
Initialises a new instance the provided flatness algo and a tolerance of 1.0e-5.


GenericCubicSubdivCriterion

public GenericCubicSubdivCriterion(CubicFlatnessAlgorithm algo,
                                   double tolerance)
Initialises using the provided parameters.

Method Detail

shouldSplit

public boolean shouldSplit(java.awt.geom.CubicCurve2D curve)
Returns true whenever the flatnessAlgo returns a value greater than the required tolerance. If the flatness algorithm prefers the computation of squared distances, the comparison is made against the squared tolerance.

Specified by:
shouldSplit in interface CubicSubdivisionCriterion