Triangulator

from panda3d.core import Triangulator
class Triangulator

Bases: DTOOL_SUPER_BASE

This class can triangulate a convex or concave polygon, even one with holes. It is adapted from an algorithm published as:

Narkhede A. and Manocha D., Fast polygon triangulation algorithm based on Seidel’s Algorithm, UNC-CH, 1994.

http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html

It works strictly on 2-d points. See Triangulator3 for 3-d points.

Inheritance diagram

Inheritance diagram of Triangulator

__init__(*args, **kwargs)
addHoleVertex()

C++ Interface: add_hole_vertex(const Triangulator self, int index)

/**
  • Adds the next consecutive vertex of the current hole. This vertex should

  • index into the vertex pool established by repeated calls to add_vertex().

  • The vertices may be listed in either clockwise or counterclockwise order.

  • Vertices should not be repeated.

*/

addPolygonVertex()

C++ Interface: add_polygon_vertex(const Triangulator self, int index)

/**
  • Adds the next consecutive vertex of the polygon. This vertex should index

  • into the vertex pool established by repeated calls to add_vertex().

  • The vertices may be listed in either clockwise or counterclockwise order.

  • Vertices should not be repeated. In particular, do not repeat the first

  • vertex at the end.

*/

addVertex()

C++ Interface: add_vertex(const Triangulator self, const LPoint2d point) add_vertex(const Triangulator self, double x, double y)

/**
  • Adds a new vertex to the vertex pool. Returns the vertex index number.

*/

/**
  • Adds a new vertex to the vertex pool. Returns the vertex index number.

*/

add_hole_vertex()

C++ Interface: add_hole_vertex(const Triangulator self, int index)

/**
  • Adds the next consecutive vertex of the current hole. This vertex should

  • index into the vertex pool established by repeated calls to add_vertex().

  • The vertices may be listed in either clockwise or counterclockwise order.

  • Vertices should not be repeated.

*/

add_polygon_vertex()

C++ Interface: add_polygon_vertex(const Triangulator self, int index)

/**
  • Adds the next consecutive vertex of the polygon. This vertex should index

  • into the vertex pool established by repeated calls to add_vertex().

  • The vertices may be listed in either clockwise or counterclockwise order.

  • Vertices should not be repeated. In particular, do not repeat the first

  • vertex at the end.

*/

add_vertex()

C++ Interface: add_vertex(const Triangulator self, const LPoint2d point) add_vertex(const Triangulator self, double x, double y)

/**
  • Adds a new vertex to the vertex pool. Returns the vertex index number.

*/

/**
  • Adds a new vertex to the vertex pool. Returns the vertex index number.

*/

beginHole()

C++ Interface: begin_hole(const Triangulator self)

/**
  • Finishes the previous hole, if any, and prepares to add a new hole.

*/

begin_hole()

C++ Interface: begin_hole(const Triangulator self)

/**
  • Finishes the previous hole, if any, and prepares to add a new hole.

*/

clear()

C++ Interface: clear(const Triangulator self)

/**
  • Removes all vertices and polygon specifications from the Triangulator, and

  • prepares it to start over.

*/

clearPolygon()

C++ Interface: clear_polygon(const Triangulator self)

/**
  • Removes the current polygon definition (and its set of holes), but does not

  • clear the vertex pool.

*/

clear_polygon()

C++ Interface: clear_polygon(const Triangulator self)

/**
  • Removes the current polygon definition (and its set of holes), but does not

  • clear the vertex pool.

*/

getNumTriangles()

C++ Interface: get_num_triangles(Triangulator self)

/**
  • Returns the number of triangles generated by the previous call to

  • triangulate().

*/

getNumVertices()

C++ Interface: get_num_vertices(Triangulator self)

/**
  • Returns the number of vertices in the pool. Note that the Triangulator

  • might append new vertices, in addition to those added by the user, if any

  • of the polygon is self-intersecting, or if any of the holes intersect some

  • part of the polygon edges.

*/

getTriangleV0()

C++ Interface: get_triangle_v0(Triangulator self, int n)

/**
  • Returns vertex 0 of the nth triangle generated by the previous call to

  • triangulate().

  • This is a zero-based index into the vertices added by repeated calls to

  • add_vertex().

*/

getTriangleV1()

C++ Interface: get_triangle_v1(Triangulator self, int n)

/**
  • Returns vertex 1 of the nth triangle generated by the previous call to

  • triangulate().

  • This is a zero-based index into the vertices added by repeated calls to

  • add_vertex().

*/

getTriangleV2()

C++ Interface: get_triangle_v2(Triangulator self, int n)

/**
  • Returns vertex 2 of the nth triangle generated by the previous call to

  • triangulate().

  • This is a zero-based index into the vertices added by repeated calls to

  • add_vertex().

*/

getVertex()

C++ Interface: get_vertex(Triangulator self, int n)

/**
  • Returns the nth vertex.

*/

getVertices()
get_num_triangles()

C++ Interface: get_num_triangles(Triangulator self)

/**
  • Returns the number of triangles generated by the previous call to

  • triangulate().

*/

get_num_vertices()

C++ Interface: get_num_vertices(Triangulator self)

/**
  • Returns the number of vertices in the pool. Note that the Triangulator

  • might append new vertices, in addition to those added by the user, if any

  • of the polygon is self-intersecting, or if any of the holes intersect some

  • part of the polygon edges.

*/

get_triangle_v0()

C++ Interface: get_triangle_v0(Triangulator self, int n)

/**
  • Returns vertex 0 of the nth triangle generated by the previous call to

  • triangulate().

  • This is a zero-based index into the vertices added by repeated calls to

  • add_vertex().

*/

get_triangle_v1()

C++ Interface: get_triangle_v1(Triangulator self, int n)

/**
  • Returns vertex 1 of the nth triangle generated by the previous call to

  • triangulate().

  • This is a zero-based index into the vertices added by repeated calls to

  • add_vertex().

*/

get_triangle_v2()

C++ Interface: get_triangle_v2(Triangulator self, int n)

/**
  • Returns vertex 2 of the nth triangle generated by the previous call to

  • triangulate().

  • This is a zero-based index into the vertices added by repeated calls to

  • add_vertex().

*/

get_vertex()

C++ Interface: get_vertex(Triangulator self, int n)

/**
  • Returns the nth vertex.

*/

get_vertices()
isLeftWinding()

C++ Interface: is_left_winding(Triangulator self)

/**
  • Returns true if the polygon vertices are listed in counterclockwise order,

  • or false if they appear to be listed in clockwise order.

*/

is_left_winding()

C++ Interface: is_left_winding(Triangulator self)

/**
  • Returns true if the polygon vertices are listed in counterclockwise order,

  • or false if they appear to be listed in clockwise order.

*/

triangulate()

C++ Interface: triangulate(const Triangulator self)

/**
  • Does the work of triangulating the specified polygon. After this call, you

  • may retrieve the new triangles one at a time by iterating through

  • get_triangle_v0/1/2().

*/

vertices