#ifndef _ENVIRONMENT_H_ #define _ENVIRONMENT_H_ #include "global.h" #define HIT_ON_VERTEX ((Segment *)-1) /* * Environment Class * * This class contains the polygonal environment to be searched. Note * that for this project, the environment must be one continuous * polygon (thus making it a polygonal environment), so free-standing * objects in the middle of a room, for instance, cannot be modelled. * */ class State; class Segment; class Vertex; class List; class Roadmap; /* vertex_pair * * This struct is used to hold general purpose pairs of vertices. * * When it is used directionally, the Direction value should be set. */ typedef struct { Vertex *v1, *v2; Vertex **external_hits; Segment *seg; Segment *seg_hit[2]; Vertex *termination[2]; int toward[2]; } vertex_pair; class Environment { public: Environment(void); Environment(Polygon *p); ~Environment(); void GenerateCells(int m_num_robots); void ComputeShortestPaths(Vertex *start, int num); void ComputeVisibility(); // This function returns a list of vertices. List *PlanPath(int robot, Vertex *to); // This function returns a boolean as to whether these two vertices // can see each other. int CanSee(Vertex *v1, Vertex *v2); // This function computes the path to guarantee I find an evader. // It returns the path as a list of vertices. List *PursueEvader(State *state, void *m_start_state, Polygon *start_polygon); // Accessor Functions: Polygon *GetPolygon() { return env_polygon; } void SetPolygon(Polygon *p) { env_polygon = p; } List *InternalPolygons() {return internal_polygons;} Polygon *vertex_in_which_polygon(Vertex *v); void *best_state; Polygon *best_polygon; private: void precompute_external_hits(); void generate_extension_queue(); void generate_internal_segments(); void generate_subpolygons(); void split_polygon(Polygon *orig, Polygon *sub1, Polygon *sub2, Segment *s); Polygon *which_polygon(Segment *s); int InPolygon(Segment *s, Polygon *p); void link_roadmap(); int PathStep(int robot, Polygon *curr_polygon, Polygon *dest_polygon, List *result_list); int PursueStep(State *state, void *elem, Polygon *p, List *result_list); // Here we have information about the environment polygon. Polygon *env_polygon; Segment **env_segs; Vertex **env_verts; int num_env_segs; List *extendable_pairs; List *internal_polygons; Roadmap *roadmap; Roadmap **shortest_path_roadmaps; vertex_pair *hit_list; Vertex **robot_starts; State *state; int num_robots; }; #endif /* _ENVIRONMENT_H_ */