Panda3D
Public Member Functions | List of all members
Triangulator3 Class Reference

This is an extension of Triangulator to handle polygons with three-dimensional points. More...

#include "triangulator3.h"

Inheritance diagram for Triangulator3:
Triangulator

Public Member Functions

int add_vertex (const LPoint3d &point)
 Adds a new vertex to the vertex pool. More...
 
int add_vertex (double x, double y, double z)
 Adds a new vertex to the vertex pool. More...
 
void clear ()
 Removes all vertices and polygon specifications from the Triangulator, and prepares it to start over. More...
 
int get_num_vertices () const
 Returns the number of vertices in the pool. More...
 
const LPlaned & get_plane () const
 Returns the plane of the polygon. More...
 
const LPoint3dget_vertex (int n) const
 Returns the nth vertex. More...
 
 MAKE_SEQ (get_vertices, get_num_vertices, get_vertex)
 
void triangulate ()
 Does the work of triangulating the specified polygon. More...
 
- Public Member Functions inherited from Triangulator
void add_hole_vertex (int index)
 Adds the next consecutive vertex of the current hole. More...
 
void add_polygon_vertex (int index)
 Adds the next consecutive vertex of the polygon. More...
 
int add_vertex (const LPoint2d &point)
 Adds a new vertex to the vertex pool. More...
 
int add_vertex (double x, double y)
 Adds a new vertex to the vertex pool. More...
 
void begin_hole ()
 Finishes the previous hole, if any, and prepares to add a new hole. More...
 
void clear ()
 Removes all vertices and polygon specifications from the Triangulator, and prepares it to start over. More...
 
void clear_polygon ()
 Removes the current polygon definition (and its set of holes), but does not clear the vertex pool. More...
 
int get_num_triangles () const
 Returns the number of triangles generated by the previous call to triangulate(). More...
 
int get_num_vertices () const
 Returns the number of vertices in the pool. More...
 
int get_triangle_v0 (int n) const
 Returns vertex 0 of the nth triangle generated by the previous call to triangulate(). More...
 
int get_triangle_v1 (int n) const
 Returns vertex 1 of the nth triangle generated by the previous call to triangulate(). More...
 
int get_triangle_v2 (int n) const
 Returns vertex 2 of the nth triangle generated by the previous call to triangulate(). More...
 
const LPoint2dget_vertex (int n) const
 Returns the nth vertex. More...
 
bool is_left_winding () const
 Returns true if the polygon vertices are listed in counterclockwise order, or false if they appear to be listed in clockwise order. More...
 
 MAKE_SEQ (get_vertices, get_num_vertices, get_vertex)
 
void triangulate ()
 Does the work of triangulating the specified polygon. More...
 

Detailed Description

This is an extension of Triangulator to handle polygons with three-dimensional points.

It assumes all of the points lie in a single plane, and internally projects the supplied points into 2-D for passing to the underlying Triangulator object.

Definition at line 31 of file triangulator3.h.

Member Function Documentation

◆ add_vertex() [1/2]

int Triangulator3::add_vertex ( const LPoint3d point)

Adds a new vertex to the vertex pool.

Returns the vertex index number.

Definition at line 47 of file triangulator3.cxx.

References triangulate().

Referenced by add_vertex(), clear(), and ObjToEggConverter::convert_file().

◆ add_vertex() [2/2]

int Triangulator3::add_vertex ( double  x,
double  y,
double  z 
)
inline

Adds a new vertex to the vertex pool.

Returns the vertex index number.

Definition at line 23 of file triangulator3.I.

References add_vertex(), and get_num_vertices().

◆ clear()

void Triangulator3::clear ( )

Removes all vertices and polygon specifications from the Triangulator, and prepares it to start over.

Definition at line 34 of file triangulator3.cxx.

References add_vertex(), and Triangulator::clear().

◆ get_num_vertices()

int Triangulator3::get_num_vertices ( ) const
inline

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.

Definition at line 37 of file triangulator3.I.

References get_vertex().

Referenced by add_vertex().

◆ get_plane()

const LPlaned & Triangulator3::get_plane ( ) const
inline

Returns the plane of the polygon.

This is only available after calling triangulate().

Definition at line 59 of file triangulator3.I.

Referenced by get_vertex().

◆ get_vertex()

const LPoint3d & Triangulator3::get_vertex ( int  n) const
inline

Returns the nth vertex.

Definition at line 47 of file triangulator3.I.

References get_plane(), and LPoint3d::zero().

Referenced by get_num_vertices().

◆ triangulate()

void Triangulator3::triangulate ( )

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().

Definition at line 62 of file triangulator3.cxx.

References LMatrix4d::invert_in_place(), LVecBase3d::normalize(), LMatrix4d::set_row(), Triangulator::triangulate(), and LVector3d::zero().

Referenced by add_vertex(), and ObjToEggConverter::convert_file().


The documentation for this class was generated from the following files: