Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Modules/SelfLocator/LinesTables2004.cpp

Go to the documentation of this file.
00001 /**
00002  * @file Modules/SelfLocator/LinesTables2004.cpp
00003  * 
00004  * This file contains a class that represents the tables used for localization based on field lines.
00005  *
00006  * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A>
00007  */
00008 
00009 #include "LinesTables2004.h"
00010 #include "Tools/Debugging/Debugging.h"
00011 #include "Tools/Streams/InStreams.h"
00012 
00013 Field LinesTables2004::field;
00014 LinesTables2004::ObsTable* LinesTables2004::observationTable = 0;
00015 LinesTables2004::TempTable* LinesTables2004::templateTable = 0;
00016 int LinesTables2004::refCount = 0;
00017 
00018 //#define SAVE
00019 #ifdef HUGE_FIELD
00020 static const char* fileName = "lines04h.tab";
00021 #else
00022 static const char* fileName = "lines04.tab";
00023 #endif
00024 
00025 LinesTables2004::LinesTables2004()
00026 {
00027   if(!refCount++)
00028   {
00029     int i;
00030     observationTable = new ObsTable[LinesPercept::numberOfLineTypes + 1];
00031     templateTable = new TempTable[2];
00032 
00033 #ifdef SAVE
00034     OutBinaryFile stream(fileName);
00035     for(i = 0; i < LinesPercept::numberOfLineTypes + 1; ++i)
00036     {
00037       if(i == LinesPercept::field)
00038         observationTable[i].create(field,LinesPercept::xField);
00039       else if(i == LinesPercept::numberOfLineTypes)
00040         observationTable[i].create(field,LinesPercept::yField);
00041       else
00042         observationTable[i].create(field,LinesPercept::LineType(i));
00043       stream << observationTable[i];
00044     }
00045     templateTable[0].create(field,LinesPercept::yellowGoal);
00046     templateTable[LinesPercept::skyblueGoal - LinesPercept::yellowGoal].create(field,LinesPercept::skyblueGoal);
00047     stream << templateTable[0] << templateTable[1];
00048 #else
00049     InBinaryFile stream(fileName);
00050     if(stream.exists())
00051     {
00052       for(i = 0; i < LinesPercept::numberOfLineTypes + 1; ++i)
00053         stream >> observationTable[i];
00054       stream >> templateTable[0] >> templateTable[1];
00055     }
00056     else
00057     {
00058       OUTPUT(idText, text, "LinesTables2004 : " << fileName << " not found");
00059     }
00060 #endif
00061   }
00062 }
00063 
00064 LinesTables2004::~LinesTables2004()
00065 {
00066   if(!--refCount)
00067   {
00068     delete [] observationTable;
00069     delete [] templateTable;
00070   }
00071 }

Generated on Mon Mar 20 21:59:56 2006 for GT2005 by doxygen 1.3.6