java.lang.Object
imagingbook.common.geometry.shape.ShapeChecker
Used to check if AWT shapes produced by
ShapeProducer.getShape()
match the underlying curve
(Primitive2d
). This is mainly used to test if generated shapes (to be drawn to the screen) are sufficiently
accurate.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
check
(Primitive2d curve, Shape shape) Checks if all points of the specified AWTShape
are sufficiently close to thePrimitive2d
instance specified in the constructor.
-
Constructor Details
-
ShapeChecker
Constructor.- Parameters:
tolerance
- maximum deviation between curve and shape
-
ShapeChecker
public ShapeChecker()Constructor.
-
-
Method Details
-
check
Checks if all points of the specified AWTShape
are sufficiently close to thePrimitive2d
instance specified in the constructor. This is typically used to test if a shape produced byShapeProducer.getShape()
coincides with this curve. Only the discrete sample points produced byShapePointIterator
are checked, not the points on connecting polygon segments. Typical usage example:GeometricCircle circle = ... ; // implements ShapeProducer and Curve2d Shape shape = circle.getShape(); boolean ok = new ShapeChecker().checkShape(circle, shape);
- Parameters:
curve
- aPrimitive2d
instanceshape
- the AWT shape to check- Returns:
- true if all points of the shape are closer to the curve than tolerance
-