Panda3D
Loading...
Searching...
No Matches
triangulator.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file triangulator.I
10 * @author drose
11 * @date 2007-01-18
12 */
13
14/**
15 * Adds a new vertex to the vertex pool. Returns the vertex index number.
16 */
18add_vertex(double x, double y) {
19 return add_vertex(LPoint2d(x, y));
20}
21
22/**
23 * Returns the number of vertices in the pool. Note that the Triangulator
24 * might append new vertices, in addition to those added by the user, if any
25 * of the polygon is self-intersecting, or if any of the holes intersect some
26 * part of the polygon edges.
27 */
28INLINE int Triangulator::
29get_num_vertices() const {
30 return _vertices.size();
31}
32
33/**
34 * Returns the nth vertex.
35 */
36INLINE const LPoint2d &Triangulator::
37get_vertex(int n) const {
38 nassertr(n >= 0 && n < (int)_vertices.size(), LPoint2d::zero());
39 return _vertices[n];
40}
41
42/**
43 * Returns true if the polygon vertices are listed in counterclockwise order,
44 * or false if they appear to be listed in clockwise order.
45 */
46INLINE bool Triangulator::
47is_left_winding() const {
48 return check_left_winding(_polygon);
49}
50
51/**
52 *
53 */
54INLINE Triangulator::Triangle::
55Triangle(Triangulator *t, int v0, int v1, int v2) :
56 _v0(t->vert[v0].user_i),
57 _v1(t->vert[v1].user_i),
58 _v2(t->vert[v2].user_i)
59{
60}
61
62/**
63 *
64 */
65INLINE Triangulator::segment_t::
66segment_t() {
67}
68
69/**
70 *
71 */
72INLINE Triangulator::segment_t::
73segment_t(Triangulator *t, int v0_i, int v1_i, int prev, int next) :
74 is_inserted(false),
75 root0(0), root1(0),
76 next(next),
77 prev(prev),
78 v0_i(v0_i)
79{
80 v0.x = t->_vertices[v0_i][0];
81 v0.y = t->_vertices[v0_i][1];
82
83 v1.x = t->_vertices[v1_i][0];
84 v1.y = t->_vertices[v1_i][1];
85}
This class can triangulate a convex or concave polygon, even one with holes.
get_vertex
Returns the nth vertex.
bool is_left_winding() const
Returns true if the polygon vertices are listed in counterclockwise order, or false if they appear to...
int add_vertex(const LPoint2d &point)
Adds a new vertex to the vertex pool.
get_num_vertices
Returns the number of vertices in the pool.