From 6e86ce8b4926a53726c3a47df75c6e59474e3dfc Mon Sep 17 00:00:00 2001 From: Gautam Dey Date: Wed, 22 Aug 2018 08:26:28 -0700 Subject: [PATCH 1/3] Added proposed interface for triangulation Add the description for an interface for triangulation. --- planar/triangulate/triangulate.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 planar/triangulate/triangulate.go diff --git a/planar/triangulate/triangulate.go b/planar/triangulate/triangulate.go new file mode 100644 index 00000000..5e3c0023 --- /dev/null +++ b/planar/triangulate/triangulate.go @@ -0,0 +1,16 @@ +package triangulate + +import "github.com/go-spatial/geom" + +type Interface interface { + // SetPoints sets the nodes to be used in the triangulation + SetPoints(pts []geom.Point, data []interface{}) + // Triangles returns the triangles that are produced by the triangulation + Triangles() []geom.Triangle +} + +type Constrainer interface { + // AddConstraints adds constraint lines to the triangulation, this may require + // the triangulation to be recalculated. + AddConstraints(constraints ...geom.Line) +} From fcb58cab1e6aaf0ebcd3086798f986b9bd28f326 Mon Sep 17 00:00:00 2001 From: Gautam Dey Date: Fri, 24 Aug 2018 11:07:04 -0700 Subject: [PATCH 2/3] Uodated Triangulator and Constrainer interfaces. Updated interfaces according to feedback. --- planar/triangulate/triangulate.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/planar/triangulate/triangulate.go b/planar/triangulate/triangulate.go index 5e3c0023..8eafbac7 100644 --- a/planar/triangulate/triangulate.go +++ b/planar/triangulate/triangulate.go @@ -2,15 +2,31 @@ package triangulate import "github.com/go-spatial/geom" -type Interface interface { +// Triangulator describes an object that can take a set of points and produce +// a triangulation. +type Triangulator interface { + // SetPoints sets the nodes to be used in the triangulation - SetPoints(pts []geom.Point, data []interface{}) + // data is any metadata to be attached to each point. + // This is a one to one mapping. The length of data MUST be either zero, + // or equal to the length of points + SetPoints(points []geom.Point, data []interface{}) error + // Triangles returns the triangles that are produced by the triangulation - Triangles() []geom.Triangle + // If the triangulation uses a frame the includeFrame should be used to + // determine if the triangles touching the frame should be included or not. + Triangles(includeFrame bool) ([]geom.Triangle, error) } +// Constrainer is a Triangulator that can take a set of points and ensure that the +// given set of edges (the constraints) exist in the triangulation type Constrainer interface { + Triangulator + // AddConstraints adds constraint lines to the triangulation, this may require // the triangulation to be recalculated. - AddConstraints(constraints ...geom.Line) + // data is any metadata to be attached to each constraint. + // This is a one to one mapping. The length of data MUST be either zero, + // or equal to the length of constraints + AddConstraints(constraints []geom.Line, data []interface{}) error } From 4d7e2d3772bc73a30bc2f11596e476ce35efcd7a Mon Sep 17 00:00:00 2001 From: Gautam Dey Date: Tue, 19 Mar 2019 16:22:40 -0700 Subject: [PATCH 3/3] Updated with comments in discussion. --- planar/triangulate/triangulate.go | 43 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/planar/triangulate/triangulate.go b/planar/triangulate/triangulate.go index 8eafbac7..224adfb9 100644 --- a/planar/triangulate/triangulate.go +++ b/planar/triangulate/triangulate.go @@ -1,32 +1,45 @@ package triangulate -import "github.com/go-spatial/geom" +import ( + "context" + + "github.com/go-spatial/geom" +) // Triangulator describes an object that can take a set of points and produce // a triangulation. type Triangulator interface { - // SetPoints sets the nodes to be used in the triangulation - // data is any metadata to be attached to each point. - // This is a one to one mapping. The length of data MUST be either zero, - // or equal to the length of points - SetPoints(points []geom.Point, data []interface{}) error + // SetPoints sets the nodes to be used in the triangulation, this will replace + // any current points in the triangulation + SetPoints(ctx context.Context, points ...geom.Point) error // Triangles returns the triangles that are produced by the triangulation - // If the triangulation uses a frame the includeFrame should be used to - // determine if the triangles touching the frame should be included or not. - Triangles(includeFrame bool) ([]geom.Triangle, error) + Triangles(ctx context.Context, includeFrame bool) ([]geom.Triangle, error) +} + +// IncrementatlTriangulator describes an triangulation where points can be +// incrementally added. +type IncrementalTriangulator interface { + Triangulator + + // InsertPoint inserts a point into an existing triangulation + InsertPoints(ctx context.Context, points ...geom.Point) error } -// Constrainer is a Triangulator that can take a set of points and ensure that the +// ConstrainedTriangulator is a Triangulator that can take a set of points and ensure that the // given set of edges (the constraints) exist in the triangulation -type Constrainer interface { +type ConstrainedTriangulator interface { Triangulator // AddConstraints adds constraint lines to the triangulation, this may require // the triangulation to be recalculated. - // data is any metadata to be attached to each constraint. - // This is a one to one mapping. The length of data MUST be either zero, - // or equal to the length of constraints - AddConstraints(constraints []geom.Line, data []interface{}) error + AddConstraints(ctx context.Context, constraints ...geom.Line) error +} + +// ConstrainedIncrementalTriangulator is an Incremental Triangulator that can take a set of points and ensure that the +// given set of edges (the constraints) exist in the triangulation +type ConstrainedIncrementalTriangulator interface { + IncrementalTriangulator + ConstrainedTriangulator }