-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Triangulator interface as per #23
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package triangulate | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-spatial/geom" | ||
) | ||
|
||
type nodata struct{} | ||
|
||
// EmptyMetadata can be used to indicate that this point or line does | ||
// not have any metadata associated with it. | ||
var EmptyMetadata = nodata{} | ||
|
||
// 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 triangulations | ||
// the number of data elements should be equal to or less then | ||
// the number of the points, where the index of the data maps | ||
// to the point. The EmptyMetadata value can be used to indicate no metadata | ||
// for that point. | ||
SetPoints(ctx context.Context, pts []geom.Point, data []interface{}) | ||
|
||
// Triangles returns the triangles that were 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(ctx context.Context, includeFrame bool) []geom.Triangle | ||
} | ||
|
||
// Constrainer is a Triangulator that can take 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. | ||
// Data is any matadata to be attached to each constraint. The number of data | ||
// elements must be less then the number of lines. The EmptyMetadata value can be used to | ||
// indicate no metadata for that constraint. | ||
AddConstraint(ctx context.Context, constraints []geom.Line, data []interface{}) error | ||
} |