Computational Geometry Algorithms Library  1.0
Computational Geometry Algorithms Library Documentation
Public Member Functions | Public Attributes | List of all members
VertexList Class Reference

#include <VertexList.h>

Collaboration diagram for VertexList:
Collaboration graph
[legend]

Public Member Functions

 VertexList (void)
 
 ~VertexList (void)
 
void addToList (DCELVertex *newVertex)
 
void removeFromList (DCELVertex *vertex)
 
void echo ()
 

Public Attributes

DCELVertexhead
 
DCELVertextail
 
int length
 

Constructor & Destructor Documentation

VertexList::VertexList ( void  )
18  : head(NULL), tail(NULL), length(0)
19 {
20 }
DCELVertex * tail
Definition: VertexList.h:10
int length
Definition: VertexList.h:13
DCELVertex * head
Definition: VertexList.h:9
VertexList::~VertexList ( void  )
23 {
24 }

Member Function Documentation

void VertexList::addToList ( DCELVertex newVertex)
39 {
40  length++;
41  if ( head ) {
42  if ((head->y < newVertex->y) || (head->y == newVertex->y && head->x > newVertex->x)) {
43  newVertex->next = head;
44  head = newVertex;
45  return;
46  }
47  DCELVertex* walker = head;
48  while (walker->next) {
49  if ((walker->next->y < newVertex->y) || (walker->next->y == newVertex->y && walker->next->x > newVertex->x)) break;
50  walker = walker->next;
51  }
52  newVertex->next = walker->next;
53  walker->next = newVertex;
54  }
55  else {
56  head = newVertex;
57  tail = newVertex;
58  }
59 }
DCELVertex * tail
Definition: VertexList.h:10
Definition: DCELVertex.h:2
double x
Definition: DCELVertex.h:8
int length
Definition: VertexList.h:13
double y
Definition: DCELVertex.h:9
DCELVertex * next
Definition: DCELVertex.h:18
DCELVertex * head
Definition: VertexList.h:9
void VertexList::echo ( )
26  {
27  DCELVertex* walker = head;
28  int i = 0;
29  while (1) {
30  walker->index = i++;
31  cout << walker->x << " " << walker->y << " 0" << endl;
32  if (walker->next)
33  walker = walker->next;
34  else break;
35  }
36 }
Definition: DCELVertex.h:2
double x
Definition: DCELVertex.h:8
int index
Definition: DCELVertex.h:16
double y
Definition: DCELVertex.h:9
DCELVertex * next
Definition: DCELVertex.h:18
DCELVertex * head
Definition: VertexList.h:9
void VertexList::removeFromList ( DCELVertex vertex)
62 {
63  length--;
64  if (head) {
65  DCELVertex* walker = head;
66  if (walker == vertex) {
67  head = walker->next;
68  delete walker;
69  }
70  while (walker->next != vertex && walker->next != NULL) {
71  walker = walker->next;
72  }
73  if (walker->next = vertex) {
74  walker->next = vertex->next;
75  delete vertex;
76  }
77  }
78 }
Definition: DCELVertex.h:2
int length
Definition: VertexList.h:13
DCELVertex * next
Definition: DCELVertex.h:18
DCELVertex * head
Definition: VertexList.h:9

Member Data Documentation

DCELVertex* VertexList::head
int VertexList::length
DCELVertex* VertexList::tail

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