com.caffeineowl.graphics.bezier.flatnessalgos
Class LineDefectSubdivCriterion

java.lang.Object
  extended by com.caffeineowl.graphics.bezier.flatnessalgos.LineDefectFlatnessAlgo
      extended by com.caffeineowl.graphics.bezier.flatnessalgos.LineDefectSubdivCriterion
All Implemented Interfaces:
CubicFlatnessAlgorithm, CubicSubdivisionCriterion, QuadFlatnessAlgorithm, QuadSubdivisionCriterion

public class LineDefectSubdivCriterion
extends LineDefectFlatnessAlgo
implements CubicSubdivisionCriterion, QuadSubdivisionCriterion

Will require the subdivision of a cubic or a quadratic curve any time the cubic's flatness (or the quad's flatness) is greater than a provided tolerance.

Actually, because the LineDefectFlatnessAlgo may prefer either the flatness or the squared flatness, the decision to subdivide is taken based on whatever is less expensive to compute, thus either the precision or the squared precision will be used.

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

Field Summary
protected static double defaultTol
           
protected  double sqTol
          The squared precision to use in deciding whether or not the curve should be split.
protected  double tol
          The precision to use in deciding whether or not the curve should be split.
 
Fields inherited from class com.caffeineowl.graphics.bezier.flatnessalgos.LineDefectFlatnessAlgo
CBSV_DIST, distType, EUCL_DIST, MNHT_DIST, usingSum
 
Constructor Summary
LineDefectSubdivCriterion()
          Initialises this instance to use euclidian distance, positively make use of summation for computing the defect of cubic curves and the default precision.
LineDefectSubdivCriterion(boolean useSum)
          Initialises this instance to use euclidian distance, the specified sum/max strategy (when computing the defect of cubic curves) and the default precision.
LineDefectSubdivCriterion(boolean useSum, double tolerance)
          Initialises this instance to use euclidian distance, make use of the specified sum/max strategy for computing the defect of cubic curves and the specified precision.
LineDefectSubdivCriterion(double tolerance)
          Initialises this instance to use euclidian distance, positively make use of summation for computing the defect of cubic curves and the specified precision.
LineDefectSubdivCriterion(int distType)
          Initialises this instance to use the specified distance type, positively make use of summation (when computing the defect of cubic curves) and the default precision.
LineDefectSubdivCriterion(int distType, boolean useSum)
          Initialises this instance to use specified distance type, and sum/max strategy for computing the defect of cubic curves and the default precision.
LineDefectSubdivCriterion(int distType, boolean useSum, double tolerance)
          Initialises this instance to use the specified values for distance type, sum/max strategy (when computing the defect of cubic curves) and precision.
LineDefectSubdivCriterion(int distType, double tolerance)
          Initialises this instance to use the specified distance type , positively make use of summation for computing the defect of cubic curves and the specified precision.
 
Method Summary
 boolean shouldSplit(java.awt.geom.CubicCurve2D curve)
          Returns true whenever the defect of approximating the provided cubic by a line segment is higher than the tolerance for which this instance is initialised with.
 boolean shouldSplit(java.awt.geom.QuadCurve2D curve)
          Returns true whenever the defect of approximating the provided quad by a line segment is higher than the tolerance for which this instance is initialised with.
 
Methods inherited from class com.caffeineowl.graphics.bezier.flatnessalgos.LineDefectFlatnessAlgo
getFlatness, getFlatness, getSquaredFlatness, getSquaredFlatness, isDegenerationRobust, isSquaredFlatenessPreferred
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultTol

protected static final double defaultTol
See Also:
Constant Field Values

tol

protected double tol
The precision to use in deciding whether or not the curve should be split.


sqTol

protected double sqTol
The squared precision to use in deciding whether or not the curve should be split.

Constructor Detail

LineDefectSubdivCriterion

public LineDefectSubdivCriterion()
Initialises this instance to use euclidian distance, positively make use of summation for computing the defect of cubic curves and the default precision.


LineDefectSubdivCriterion

public LineDefectSubdivCriterion(int distType)
Initialises this instance to use the specified distance type, positively make use of summation (when computing the defect of cubic curves) and the default precision.


LineDefectSubdivCriterion

public LineDefectSubdivCriterion(boolean useSum)
Initialises this instance to use euclidian distance, the specified sum/max strategy (when computing the defect of cubic curves) and the default precision.


LineDefectSubdivCriterion

public LineDefectSubdivCriterion(double tolerance)
Initialises this instance to use euclidian distance, positively make use of summation for computing the defect of cubic curves and the specified precision.


LineDefectSubdivCriterion

public LineDefectSubdivCriterion(int distType,
                                 boolean useSum)
Initialises this instance to use specified distance type, and sum/max strategy for computing the defect of cubic curves and the default precision.


LineDefectSubdivCriterion

public LineDefectSubdivCriterion(int distType,
                                 double tolerance)
Initialises this instance to use the specified distance type , positively make use of summation for computing the defect of cubic curves and the specified precision. precision.


LineDefectSubdivCriterion

public LineDefectSubdivCriterion(boolean useSum,
                                 double tolerance)
Initialises this instance to use euclidian distance, make use of the specified sum/max strategy for computing the defect of cubic curves and the specified precision.


LineDefectSubdivCriterion

public LineDefectSubdivCriterion(int distType,
                                 boolean useSum,
                                 double tolerance)
Initialises this instance to use the specified values for distance type, sum/max strategy (when computing the defect of cubic curves) and precision.

Method Detail

shouldSplit

public final boolean shouldSplit(java.awt.geom.CubicCurve2D curve)
Returns true whenever the defect of approximating the provided cubic by a line segment is higher than the tolerance for which this instance is initialised with. The method chooses whether or not using the direct or squared defect is less expensive to compute and reacts accordingly.

Specified by:
shouldSplit in interface CubicSubdivisionCriterion

shouldSplit

public final boolean shouldSplit(java.awt.geom.QuadCurve2D curve)
Returns true whenever the defect of approximating the provided quad by a line segment is higher than the tolerance for which this instance is initialised with. The method chooses whether or not using the direct or squared defect is less expensive to compute and reacts accordingly.

Specified by:
shouldSplit in interface QuadSubdivisionCriterion