proj home

Files   Classes   Functions   Hierarchy  

polytopeD2linked Class Reference

Linked polygons. More...

#include <polytopeD2linked.h>

Collaboration diagram for polytopeD2linked:

List of all members.

Public Member Functions

uintc nifrom (uintc gpt) const
 Use global points as references to get the opposite neighbor.
 polytopeD2linked ()
 Construct a null polytope.
 polytopeD2linked (uintc p0, uintc p1, uintc n0, uintc n1)
 A line.
 polytopeD2linked (uintc p0, uintc p1, uintc p2, uintc n0, uintc n1, uintc n2)
 A triangle.
 polytopeD2linked (uintc p0, uintc p1, uintc p2, uintc p3, uintc n0, uintc n1, uintc n2, uintc n3)
 A quadrilateral.
 polytopeD2linked (uintc p0, uintc p1, uintc p2, uintc p3, uintc p4, uintc n0, uintc n1, uintc n2, uintc n3, uintc n4)
 A 5 point polygon.
 polytopeD2linked (uintc p0, uintc p1, uintc p2, uintc p3, uintc p4, uintc p5, uintc n0, uintc n1, uintc n2, uintc n3, uintc n4, uintc n5)
 A 6 point polygon.
 polytopeD2linked (uintc p0, uintc p1, uintc p2, uintc p3, uintc p4, uintc p5, uintc p6, uintc n0, uintc n1, uintc n2, uintc n3, uintc n4, uintc n5, uintc n6)
 A 7 point polygon.
 polytopeD2linked (uintc p0, uintc p1, uintc p2, uintc p3, uintc p4, uintc p5, uintc p6, uintc p7, uintc n0, uintc n1, uintc n2, uintc n3, uintc n4, uintc n5, uintc n6, uintc n7)
 A 8 point polygon.
polytopeD2linkedadd (uintc p, uintc n)
 Add to end of polytope point and neighbor list.
uintc piInverse (uintc gpt) const
 Get the local point index.
boolc isnull () const
 Is this polytope not constructed?
boolc niInverseHas (uintc neib) const
 Does the polytope have a link to this neighbor?
 operator string () const
 Write the object out.
void addpoint (uintc ptindex, uintc ptglobal)
 Add a new point to the polytope, the insert position indexed with an existing polygon point.

Public Attributes

vector< uintpi
 Indexes to the points.
vector< uintni
 Indexes to the neighbors.


Detailed Description

Linked polygons.

NOTE: Suspend development. The primary problem is with memory reallocation, for example adding a point. However once this type of structure has stabalized the array is ideal as it reduces the memory requirements and provides fast access, so this class may be implemented for this purpose - as an optimization.

The points have an anti clockwise winding. ni[k] points to the neighboring polygon on the edge from pi[k] to pi[k+1].

Traveling anti clockwise around the points forms a polygon. ni[k] is link at pi[k] to another polygon. The side of the link is pi[k] to pi[k+1] and is right of the line.

For infinite regions a neighbor having a value of 0. Or it could also mean that there is no link. So a value of 0 in ni[] is dependent on the context/algorithm using this data structure.

Definition at line 34 of file polytopeD2linked.h.


Constructor & Destructor Documentation

polytopeD2linked::polytopeD2linked (  )  [inline]

Construct a null polytope.

Definition at line 49 of file polytopeD2linked.h.

00049 {}

polytopeD2linked::polytopeD2linked ( uintc  p0,
uintc  p1,
uintc  n0,
uintc  n1 
)

A line.

Definition at line 27 of file polytopeD2linked.cpp.

00031 {
00032   pi.push_back(p0);
00033   pi.push_back(p1);
00034 
00035   ni.push_back(n0);
00036   ni.push_back(n1);
00037 }

polytopeD2linked::polytopeD2linked ( uintc  p0,
uintc  p1,
uintc  p2,
uintc  n0,
uintc  n1,
uintc  n2 
)

A triangle.

Definition at line 40 of file polytopeD2linked.cpp.

00044 {
00045   pi.push_back(p0);
00046   pi.push_back(p1);
00047   pi.push_back(p2);
00048 
00049   ni.push_back(n0);
00050   ni.push_back(n1);
00051   ni.push_back(n2);
00052 }

polytopeD2linked::polytopeD2linked ( uintc  p0,
uintc  p1,
uintc  p2,
uintc  p3,
uintc  n0,
uintc  n1,
uintc  n2,
uintc  n3 
)

A quadrilateral.

Definition at line 56 of file polytopeD2linked.cpp.

00060 {
00061   pi.push_back(p0);
00062   pi.push_back(p1);
00063   pi.push_back(p2);
00064   pi.push_back(p3);
00065 
00066   ni.push_back(n0);
00067   ni.push_back(n1);
00068   ni.push_back(n2);
00069   ni.push_back(n3);
00070 }

polytopeD2linked::polytopeD2linked ( uintc  p0,
uintc  p1,
uintc  p2,
uintc  p3,
uintc  p4,
uintc  n0,
uintc  n1,
uintc  n2,
uintc  n3,
uintc  n4 
)

A 5 point polygon.

Definition at line 73 of file polytopeD2linked.cpp.

00077 {
00078   pi.push_back(p0);
00079   pi.push_back(p1);
00080   pi.push_back(p2);
00081   pi.push_back(p3);
00082   pi.push_back(p4);
00083 
00084   ni.push_back(n0);
00085   ni.push_back(n1);
00086   ni.push_back(n2);
00087   ni.push_back(n3);
00088   ni.push_back(n4);
00089 }

polytopeD2linked::polytopeD2linked ( uintc  p0,
uintc  p1,
uintc  p2,
uintc  p3,
uintc  p4,
uintc  p5,
uintc  n0,
uintc  n1,
uintc  n2,
uintc  n3,
uintc  n4,
uintc  n5 
)

A 6 point polygon.

Definition at line 92 of file polytopeD2linked.cpp.

00096 {
00097   pi.push_back(p0);
00098   pi.push_back(p1);
00099   pi.push_back(p2);
00100   pi.push_back(p3);
00101   pi.push_back(p4);
00102   pi.push_back(p5);
00103 
00104   ni.push_back(n0);
00105   ni.push_back(n1);
00106   ni.push_back(n2);
00107   ni.push_back(n3);
00108   ni.push_back(n4);
00109   ni.push_back(n5);
00110 }

polytopeD2linked::polytopeD2linked ( uintc  p0,
uintc  p1,
uintc  p2,
uintc  p3,
uintc  p4,
uintc  p5,
uintc  p6,
uintc  n0,
uintc  n1,
uintc  n2,
uintc  n3,
uintc  n4,
uintc  n5,
uintc  n6 
)

A 7 point polygon.

Definition at line 113 of file polytopeD2linked.cpp.

00117 {
00118   pi.push_back(p0);
00119   pi.push_back(p1);
00120   pi.push_back(p2);
00121   pi.push_back(p3);
00122   pi.push_back(p4);
00123   pi.push_back(p5);
00124   pi.push_back(p6);
00125 
00126   ni.push_back(n0);
00127   ni.push_back(n1);
00128   ni.push_back(n2);
00129   ni.push_back(n3);
00130   ni.push_back(n4);
00131   ni.push_back(n5);
00132   ni.push_back(n6);
00133 }

polytopeD2linked::polytopeD2linked ( uintc  p0,
uintc  p1,
uintc  p2,
uintc  p3,
uintc  p4,
uintc  p5,
uintc  p6,
uintc  p7,
uintc  n0,
uintc  n1,
uintc  n2,
uintc  n3,
uintc  n4,
uintc  n5,
uintc  n6,
uintc  n7 
)

A 8 point polygon.

Definition at line 136 of file polytopeD2linked.cpp.

00140 {
00141   pi.push_back(p0);
00142   pi.push_back(p1);
00143   pi.push_back(p2);
00144   pi.push_back(p3);
00145   pi.push_back(p4);
00146   pi.push_back(p5);
00147   pi.push_back(p6);
00148   pi.push_back(p7);
00149 
00150   ni.push_back(n0);
00151   ni.push_back(n1);
00152   ni.push_back(n2);
00153   ni.push_back(n3);
00154   ni.push_back(n4);
00155   ni.push_back(n5);
00156   ni.push_back(n6);
00157   ni.push_back(n7);
00158 }


Member Function Documentation

polytopeD2linked& polytopeD2linked::add ( uintc  p,
uintc  n 
) [inline]

Add to end of polytope point and neighbor list.

Definition at line 90 of file polytopeD2linked.h.

References ni, and pi.

00091     { pi.push_back(p); ni.push_back(n); return *this; }

void polytopeD2linked::addpoint ( uintc  ptindex,
uintc  ptglobal 
)

Add a new point to the polytope, the insert position indexed with an existing polygon point.

Definition at line 183 of file polytopeD2linked.cpp.

References ni, pi, and piInverse().

Referenced by polytopeD2tess< VPOLY, VPTS >::addpoint().

00184 {
00185 //cout << SHOW(ptindex) << endl;
00186 //cout << SHOW(ptglobal) << endl;
00187   uintc i0 = piInverse(ptindex);
00188 //cout << SHOW(i0) << endl;
00189   uint sz = pi.size();
00190   pi.resize(sz+1);
00191   ni.resize(sz+1);
00192   
00193   uint k=sz;
00194   uintc imax = sz-i0;
00195   
00196   for (uint i=0; i<imax; ++i)
00197   {
00198     pi[k] = pi[k-1];
00199     ni[k] = ni[k-1];
00200     --k;
00201   }
00202 
00203   pi[(i0+1)%(sz+1)] = ptglobal;
00204 }

boolc polytopeD2linked::isnull (  )  const [inline]

Is this polytope not constructed?

Definition at line 107 of file polytopeD2linked.h.

References pi.

Referenced by polytopeD2tess< VPOLY, VPTS >::verify().

00108     { return pi.empty(); }

uintc polytopeD2linked::nifrom ( uintc  gpt  )  const [inline]

Use global points as references to get the opposite neighbor.

Definition at line 45 of file polytopeD2linked.h.

References ni, and piInverse().

00046     { return ni[piInverse(gpt)]; }

boolc polytopeD2linked::niInverseHas ( uintc  neib  )  const

Does the polytope have a link to this neighbor?

Definition at line 9 of file polytopeD2linked.cpp.

References ni.

00010 {
00011   // Let the client as if there are null neighbors.
00012   //assert(neib!=0);
00013 
00014   for (uint i=0; i<ni.size(); ++i)
00015   {
00016 //    if (ni[i]==0)
00017 //      continue;
00018 
00019     if (ni[i]==neib)
00020       return true;
00021   }
00022 
00023   return false;
00024 }

polytopeD2linked::operator string (  )  const

Write the object out.

Definition at line 160 of file polytopeD2linked.cpp.

References ni, and pi.

00161 {
00162   string s;
00163   uint sz = pi.size();
00164   { stringstream ss; ss << sz; s+=ss.str(); s += "  "; }
00165   for (uint i=0; i<sz; ++i)
00166   {
00167     { stringstream ss; ss << pi[i]; s+=ss.str(); }
00168     s += " ";
00169   }
00170 
00171   s += "  ";
00172 
00173   for (uint i=0; i<sz; ++i)
00174   {
00175     { stringstream ss; ss << ni[i]; s+=ss.str(); }
00176     s += " ";
00177   }
00178 
00179   return s;
00180 }

uintc polytopeD2linked::piInverse ( uintc  gpt  )  const [inline]

Get the local point index.

Definition at line 94 of file polytopeD2linked.h.

References pi.

Referenced by addpoint(), and nifrom().

00095   {
00096     assert(gpt!=0);
00097     uintc sz = pi.size();
00098     for ( uint i=0; i<sz; ++i)
00099       if (pi[i]==gpt)
00100         return i;
00101 
00102     assert(false);
00103     return sz+1;
00104   }


Member Data Documentation

Indexes to the neighbors.

Definition at line 41 of file polytopeD2linked.h.

Referenced by add(), addpoint(), nifrom(), niInverseHas(), operator string(), and polytopeD2tess< VPOLY, VPTS >::verify().

Indexes to the points.

Definition at line 39 of file polytopeD2linked.h.

Referenced by add(), addpoint(), isnull(), operator string(), piInverse(), and polytopeD2tess< VPOLY, VPTS >::verify().


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

Generated on Fri Mar 4 00:50:10 2011 for Chelton Evans Source by  doxygen 1.5.8