void atIntersection(int x, int y, int d, char ** maze, int w, int h){ int i; int a; int b; for(i = NORTH; i <= WEST; i++)//iterate through all directions { if (findOpposite(i) != d)//ensure that I don't go back in the direction I came from { a = x; b = y; appendLocation(&a, &b, i); if (maze[a][b] != 'X')//the direction doesn't lead into a wall { moveDirection(x, y, i, maze, w, h);//move in all directions except the the direction I came from } } } }
/* An edge is deemed safe if removal of it will not make the shape irregular. A shape is irregular if a vertex has more than two edges that are on the boundary. */ bool isSafe(const _Internal::_edge* e) { if(isBoundary(e)) { _Internal::_triangle* tr = e->faces[0] ? e->faces[0] : e->faces[1]; //one has to be non NULL if(tr == NULL) return false; //this is a dangling edge. not safe. _Internal::_vertex* v = findOpposite(tr, e); for(int j=0; j<v->edges.size(); ++j) { const _Internal::_edge* e2 = v->edges[j]; if(isBoundary(e2)) { return false; } } return true; } return false; }