environmentManage.cpp
00001
00002
00003
00004
00005
00006
00007 #include "environmentManage.h"
00008 #include "fileStreamToCodec.h"
00009
00010
00011 typedef EnvironmentManage::crd_polygon_t crd_polygon_t;
00012
00013
00014 EnvironmentManage::EnvironmentManage(void) {
00015 }
00016
00017
00018 EnvironmentManage::~EnvironmentManage(void) {
00019 }
00020
00021
00022 bool EnvironmentManage::loadEnvironment(EnvironmentCodecStream& codec) {
00023 enum { First = 0 };
00024
00025 while (!codec.eof()) {
00026 int n;
00027 codec.read1ch();
00028
00029
00030 n = encodeSpaceFromText(codec, First);
00031 if (n > 0) {
00032 codec.clearBuffer(n);
00033 continue;
00034 }
00035
00036 n = encodePolygonFromText(codec, First, crd_env.crd_polygons);
00037 if (n > 0) {
00038 codec.clearBuffer();
00039 continue;
00040 }
00041 }
00042 return true;
00043 }
00044
00045
00046 bool EnvironmentManage::load(const char* envFile) {
00047
00048 FileStreamToCodec fs(envFile);
00049 if (!fs.is_open()) {
00050
00051 return false;
00052 }
00053 return loadEnvironment(fs);
00054 }
00055
00056
00057 std::vector<crd_polygon_t> EnvironmentManage::getPolygonsCopy(void){
00058 return crd_env.crd_polygons;
00059 }
00060
00061
00062 std::vector<crd_polygon_t>& EnvironmentManage::getPolygonsReference(void) {
00063 return crd_env.crd_polygons;
00064 }
00065