Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Triangulation Class Reference

Triangulating a convex polygon by ear-removal. More...

#include <Triangulation.h>

Collaboration diagram for Triangulation:

Classes

class  Node
 

Public Types

typedef CGAL::PointS2< RealPointS2
 
typedef CGAL::Simple_cartesian
< Real >::Segment_2 
SegmentS2
 
typedef Three_tuple< int > Triangle
 Connectivity for a triangle. More...
 
typedef std::vector< TriangleConnectivity
 Element connectivity table. More...
 

Public Member Functions

 Triangulation ()
 A constructor. More...
 
void triangulate (const Point_2 *ps, int n, Connectivity *tri)
 Main entry for triangulation. More...
 

Private Types

typedef std::list< NodeNode_list
 
typedef Node_list::iterator Node_iterator
 
typedef Node_list::const_iterator Node_const_iterator
 

Private Member Functions

const PointS2get_point (const Node &v) const
 
Node_iterator get_next (Node_iterator i)
 
Node_iterator get_prev (Node_iterator i)
 
Node_const_iterator get_next (Node_const_iterator i) const
 
Node_const_iterator get_prev (Node_const_iterator i) const
 
bool is_diagonal (Node_const_iterator u, Node_const_iterator v) const
 
bool in_cone (Node_const_iterator u, Node_const_iterator v) const
 
bool is_diagonalie (Node_const_iterator u, Node_const_iterator v) const
 

Private Attributes

const Point_2_pnts
 
Node_list _nodes
 

Detailed Description

Triangulating a convex polygon by ear-removal.

This class implements the ear-removal algorithm described in the book "Computational Geometry in C" for triangulating a convex polygon. It triangulates a polygon by cutting off ears incrementally until only one triangle is left. This method may generate triangles with poor quality, but quality is not a concern because we will compute integration instead of differentiation.

Definition at line 50 of file Triangulation.h.

Member Typedef Documentation

typedef std::vector< Triangle> Connectivity

Element connectivity table.

Definition at line 75 of file Triangulation.h.

typedef Node_list::const_iterator Node_const_iterator
private

Definition at line 71 of file Triangulation.h.

typedef Node_list::iterator Node_iterator
private

Definition at line 70 of file Triangulation.h.

typedef std::list< Node> Node_list
private

Definition at line 69 of file Triangulation.h.

typedef CGAL::PointS2<Real> PointS2

Definition at line 52 of file Triangulation.h.

typedef CGAL::Simple_cartesian<Real>::Segment_2 SegmentS2

Definition at line 53 of file Triangulation.h.

typedef Three_tuple< int> Triangle

Connectivity for a triangle.

Definition at line 73 of file Triangulation.h.

Constructor & Destructor Documentation

Triangulation ( )
inline

A constructor.

Definition at line 79 of file Triangulation.h.

79 {}

Member Function Documentation

Node_iterator get_next ( Node_iterator  i)
inlineprivate

Definition at line 130 of file Triangulation.h.

References _nodes, and i.

Referenced by in_cone(), is_diagonalie(), and triangulate().

130  {
131  return ( ++i==_nodes.end()) ? _nodes.begin() : i;
132  }
Node_list _nodes
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

Node_const_iterator get_next ( Node_const_iterator  i) const
inlineprivate

Definition at line 138 of file Triangulation.h.

References _nodes, and i.

138  {
139  return ( ++i==_nodes.end()) ? _nodes.begin() : i;
140  }
Node_list _nodes
blockLoc i
Definition: read.cpp:79
const PointS2& get_point ( const Node v) const
inlineprivate

Definition at line 128 of file Triangulation.h.

References _pnts, and Triangulation::Node::id().

Referenced by in_cone(), and is_diagonalie().

128 { return (PointS2&)_pnts[v.id()]; }
int id() const
Obtain the node ID within its Pane_manifold_2.
Definition: Manifold_2.h:391
const Point_2 * _pnts

Here is the call graph for this function:

Here is the caller graph for this function:

Node_iterator get_prev ( Node_iterator  i)
inlineprivate

Definition at line 133 of file Triangulation.h.

References _nodes, and i.

Referenced by in_cone(), and triangulate().

133  {
134  if ( i==_nodes.begin()) i=_nodes.end();
135  return --i;
136  }
Node_list _nodes
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

Node_const_iterator get_prev ( Node_const_iterator  i) const
inlineprivate

Definition at line 141 of file Triangulation.h.

References _nodes, and i.

141  {
142  if ( i==_nodes.begin()) i=_nodes.end();
143  return --i;
144  }
Node_list _nodes
blockLoc i
Definition: read.cpp:79
bool in_cone ( Node_const_iterator  u,
Node_const_iterator  v 
) const
inlineprivate

Definition at line 150 of file Triangulation.h.

References get_next(), get_point(), get_prev(), leftturn(), and rightturn().

Referenced by is_diagonal().

150  {
151  Node_const_iterator a0 = get_prev( u);
152  Node_const_iterator a1 = get_next( u);
153 
154  if ( !CGAL::rightturn( get_point(*u), get_point(*a1), get_point(*a0))) {
155  return ( CGAL::leftturn(get_point(*u), get_point(*v), get_point(*a0)) &&
157  }
158 
159  return ( ! CGAL::rightturn(get_point(*v), get_point(*u), get_point(*a1)) &&
160  ! CGAL::rightturn(get_point(*a0), get_point(*u), get_point(*v)));
161  }
Node_list::const_iterator Node_const_iterator
Definition: Triangulation.h:71
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
const PointS2 & get_point(const Node &v) const
bool rightturn(const Point_2< R > &p, const Point_2< R > &q, const Point_2< R > &r)
Node_iterator get_prev(Node_iterator i)
Node_iterator get_next(Node_iterator i)
bool leftturn(const Point_2< R > &p, const Point_2< R > &q, const Point_2< R > &r)

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_diagonal ( Node_const_iterator  u,
Node_const_iterator  v 
) const
inlineprivate

Definition at line 146 of file Triangulation.h.

References in_cone(), and is_diagonalie().

Referenced by triangulate().

146  {
147  return in_cone( u, v) && in_cone( v, u) && is_diagonalie( u, v);
148  }
bool is_diagonalie(Node_const_iterator u, Node_const_iterator v) const
bool in_cone(Node_const_iterator u, Node_const_iterator v) const
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_diagonalie ( Node_const_iterator  u,
Node_const_iterator  v 
) const
inlineprivate

Definition at line 163 of file Triangulation.h.

References _nodes, CGAL::do_intersect(), get_next(), get_point(), i, and j.

Referenced by is_diagonal().

163  {
164  for ( Node_const_iterator i=_nodes.begin(); i!=_nodes.end(); ++i) {
166 
167  if ( u!=i && u!=j && v!=i && v!=j &&
169  SegmentS2( get_point(*i), get_point(*j))))
170  return false;
171  }
172  return true;
173  }
Node_list _nodes
Node_list::const_iterator Node_const_iterator
Definition: Triangulation.h:71
CGAL::Simple_cartesian< Real >::Segment_2 SegmentS2
Definition: Triangulation.h:53
bool do_intersect(const Segment_2< R > &seg1, const Segment_2< R > &seg2)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
const PointS2 & get_point(const Node &v) const
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
Node_iterator get_next(Node_iterator i)

Here is the call graph for this function:

Here is the caller graph for this function:

void triangulate ( const Point_2 ps,
int  n,
Connectivity tri 
)
inline

Main entry for triangulation.

Parameters
psthe coordinates of the nodes.
nthe number of nodes.
trithe element connectivity for output.

Definition at line 87 of file Triangulation.h.

References _nodes, _pnts, get_next(), get_prev(), i, is_diagonal(), n, and RFC_assertion.

Referenced by Overlay::number_subfaces().

87  {
88  _pnts = ps;
89  _nodes.clear();
90  for ( int i=0; i<n; ++i) _nodes.push_back( Node(i));
91 
92  // Initialize ears
93  for ( Node_iterator it=_nodes.begin(); it!=_nodes.end(); ++it) {
94  it->set_ear( is_diagonal( get_prev(it), get_next(it)));
95  }
96 
97  tri->resize(0); tri->reserve( n-2);
98  // Loop through to remove ears.
99  for ( ; n>3; --n) {
100  // The inner loop searches for an ear
101  for ( Node_iterator it=_nodes.begin(); it!=_nodes.end(); ++it) {
102  if ( it->is_ear()) {
103  Node_iterator v1=get_prev( it), v0=get_prev( v1);
104  Node_iterator v3=get_next( it), v4=get_next( v3);
105 
106  // Output the ear
107  tri->push_back( Triangle( v1->id(), it->id(), v3->id()));
108 
109  // update neighbor vertices
110  v1->set_ear( is_diagonal( v0, v3));
111  v3->set_ear( is_diagonal( v1, v4));
112 
113  // Cut off the ear
114  _nodes.erase( it);
115  break;
116  }
117  }
118  }
119  RFC_assertion( n==3);
120 
121  tri->push_back( Triangle( _nodes.front().id(), (++_nodes.begin())->id(),
122  _nodes.back().id()));
123  _nodes.clear();
124  }
Node_list _nodes
This class encapsulate a node over a window manifold.
Definition: Manifold_2.h:370
const Point_2 * _pnts
Three_tuple< int > Triangle
Connectivity for a triangle.
Definition: Triangulation.h:73
blockLoc i
Definition: read.cpp:79
const NT & n
bool is_diagonal(Node_const_iterator u, Node_const_iterator v) const
Node_iterator get_prev(Node_iterator i)
Node_iterator get_next(Node_iterator i)
Node_list::iterator Node_iterator
Definition: Triangulation.h:70
#define RFC_assertion
Definition: rfc_basic.h:65

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Node_list _nodes
private

Definition at line 177 of file Triangulation.h.

Referenced by get_next(), get_prev(), is_diagonalie(), and triangulate().

const Point_2* _pnts
private

Definition at line 176 of file Triangulation.h.

Referenced by get_point(), and triangulate().


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