Package org.tinfour.utils.alphashape
Class AlphaShape
- java.lang.Object
-
- org.tinfour.utils.alphashape.AlphaShape
-
public class AlphaShape extends Object
Provides methods and elements to support the creation of an alpha shape from a Delaunay triangulation. The alpha shape concept introduced by Edelsbrunner, et al., is a not-necessarily convex bounding polygon that defines a region covered by a set of vertices. The alpha shape may also include "holes" within the bounds of the outer polygon.Instances are coupled to the source triangulation: When an instance of this class is created, it receives several elements from the source Incremental TIN instance supplied in the constructor. Therefore, it is imperative that the source triangulation not be modified while the AlphaShape instance is still being used.
References: H. Edelsbrunner, D. Kirkpatrick and R. Seidel, "On the shape of a set of points in the plane," in IEEE Transactions on Information Theory, vol. 29, no. 4, pp. 551-559, July 1983, doi: 10.1109/TIT.1983.1056714.
-
-
Constructor Summary
Constructors Constructor Description AlphaShape(IIncrementalTin tin, double radius)Constructs an alpha shape based on the specified Delaunay triangulation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<AlphaPart>getAlphaParts()Gets a list of the components of the alpha-shape.List<IConstraint>getConstraints()Constructs a set of constraint objects based on the geometry of the alpha shape.IIncrementalTingetDelaunayTriangulation()Gets the Delaunay triangulation from which this instance was derived.Path2DgetOuterPolygonsPath2D()Gets a path containing only those parts that are not enclosed by other polygons.Path2DgetPath2D()Gets a instance of a Path2D based on the polygon geometry of the alpha shape, including any enclosed (hole) features.Path2DgetPath2D(boolean polygonFlag)Gets a instance of a Path2D based on the geometry of the alpha shape, including any enclosed (hole) features.doublegetRadius()Gets the alpha-radius parameter that was used to construct the shape.voidsummarize(PrintStream ps, boolean extendedSummary)Prints a summary of the content of the alpha shape to the specified print-stream instance (such as System.out, etc.).StringtoString()Iterable<SimpleTriangle>triangles()Provides an instance of an iterable that can be used to access the set of triangles interior to the alpha shape.
-
-
-
Constructor Detail
-
AlphaShape
public AlphaShape(IIncrementalTin tin, double radius)
Constructs an alpha shape based on the specified Delaunay triangulation. Note that this constructor takes the specification of a radius for the alpha-circle features used to develop the alpha shape. Various authors in the published literature use different definitions for the alpha parameter. Software libraries other than Tinfour may use different definitions alpha parameter than the simple radius.- Parameters:
tin- a valid instance of a Triangulated Irregular Network (TIN).radius- the radius for alpha circle computations.
-
-
Method Detail
-
summarize
public void summarize(PrintStream ps, boolean extendedSummary)
Prints a summary of the content of the alpha shape to the specified print-stream instance (such as System.out, etc.). The standard summary provides a list of the polygons that comprise the alpha shape. The extended summary also prints the edges for each polygon.- Parameters:
ps- a valid print stream.extendedSummary- true if more detail is to be printed; otherwise, false.
-
getPath2D
public Path2D getPath2D()
Gets a instance of a Path2D based on the polygon geometry of the alpha shape, including any enclosed (hole) features. Non-polygon features are excluded.- Returns:
- a valid, potentially empty instance.
-
getPath2D
public Path2D getPath2D(boolean polygonFlag)
Gets a instance of a Path2D based on the geometry of the alpha shape, including any enclosed (hole) features. If polygonFlag option is specified, only valid polygon features will be included (a polygon is considered if it has a non-zero area and is suitable for plotting with a fill operation). If polygonFlag option is false, open-line (non-polygon) features and zero-area polygons will be included.- Parameters:
polygonFlag- true if only valid polygon features are included; false if only open-line features are included.- Returns:
- a valid, potentially empty instance.
-
getOuterPolygonsPath2D
public Path2D getOuterPolygonsPath2D()
Gets a path containing only those parts that are not enclosed by other polygons. Typically, this selection set represents the outer envelope of the alpha shape.- Returns:
- a valid Path2D instance.
-
getConstraints
public List<IConstraint> getConstraints()
Constructs a set of constraint objects based on the geometry of the alpha shape. For the current implementation, this method produces only linear constraints based on the valid-polygon parts of the alpha shape. Future implementation may broaden this behavior.- Returns:
- a valid, potentially empty list.
-
getAlphaParts
public List<AlphaPart> getAlphaParts()
Gets a list of the components of the alpha-shape. Typically, these include polygon features.- Returns:
- a valid, potentially empty list of AlphaPart instances.
-
getRadius
public double getRadius()
Gets the alpha-radius parameter that was used to construct the shape.- Returns:
- a finite value greater than zero.
-
getDelaunayTriangulation
public IIncrementalTin getDelaunayTriangulation()
Gets the Delaunay triangulation from which this instance was derived.- Returns:
- a valid reference to an instance of IIncrementalTin.
-
triangles
public Iterable<SimpleTriangle> triangles()
Provides an instance of an iterable that can be used to access the set of triangles interior to the alpha shape.For example, this method could be used in the following manner:
AlphaShape alphaShape = // some implementation for(SimpleTriangle t: alphaShape.triangles(){ // some processing logic }- Returns:
- a valid instance.
-
-