Panda3D
 All Classes Functions Variables Enumerations
triangulator.I
00001 // Filename: triangulator.I
00002 // Created by:  drose (18Jan07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: Triangulator::add_vertex
00018 //       Access: Published
00019 //  Description: Adds a new vertex to the vertex pool.  Returns the
00020 //               vertex index number.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE int Triangulator::
00023 add_vertex(double x, double y) {
00024   return add_vertex(LPoint2d(x, y));
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: Triangulator::get_num_vertices
00029 //       Access: Published
00030 //  Description: Returns the number of vertices in the pool.  Note
00031 //               that the Triangulator might append new vertices, in
00032 //               addition to those added by the user, if any of the
00033 //               polygon is self-intersecting, or if any of the holes
00034 //               intersect some part of the polygon edges.
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE int Triangulator::
00037 get_num_vertices() const {
00038   return _vertices.size();
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: Triangulator::get_vertex
00043 //       Access: Published
00044 //  Description: Returns the nth vertex.
00045 ////////////////////////////////////////////////////////////////////
00046 INLINE const LPoint2d &Triangulator::
00047 get_vertex(int n) const {
00048   nassertr(n >= 0 && n < (int)_vertices.size(), LPoint2d::zero());
00049   return _vertices[n];
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: Triangulator::is_left_winding
00054 //       Access: Published
00055 //  Description: Returns true if the polygon vertices are listed in
00056 //               counterclockwise order, or false if they appear to be
00057 //               listed in clockwise order.
00058 ////////////////////////////////////////////////////////////////////
00059 INLINE bool Triangulator::
00060 is_left_winding() const {
00061   return check_left_winding(_polygon);
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: Triangulator::Triangle::Constructor
00066 //       Access: Private
00067 //  Description: 
00068 ////////////////////////////////////////////////////////////////////
00069 INLINE Triangulator::Triangle::
00070 Triangle(Triangulator *t, int v0, int v1, int v2) :
00071   _v0(t->vert[v0].user_i), 
00072   _v1(t->vert[v1].user_i),
00073   _v2(t->vert[v2].user_i)
00074 {
00075 }
00076 
00077 ////////////////////////////////////////////////////////////////////
00078 //     Function: Triangulator::segment_t::Default Constructor
00079 //       Access: Private
00080 //  Description: 
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE Triangulator::segment_t::
00083 segment_t() {
00084 }
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //     Function: Triangulator::segment_t::Constructor
00088 //       Access: Private
00089 //  Description: 
00090 ////////////////////////////////////////////////////////////////////
00091 INLINE Triangulator::segment_t::
00092 segment_t(Triangulator *t, int v0_i, int v1_i, int prev, int next) :
00093   is_inserted(false),
00094   root0(0), root1(0),
00095   next(next),
00096   prev(prev),
00097   v0_i(v0_i)
00098 {
00099   v0.x = t->_vertices[v0_i][0];
00100   v0.y = t->_vertices[v0_i][1];
00101 
00102   v1.x = t->_vertices[v1_i][0];
00103   v1.y = t->_vertices[v1_i][1];
00104 }
 All Classes Functions Variables Enumerations