00001 /* 00002 * Copyright (C) Massimo Cora' 2005 <maxcvs@email.it> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 00020 #include "TrackingWindow.hh" 00021 00022 //================================================================== 00023 //==== TRACKING WINDOW ==== 00024 //================================================================== 00025 00026 00027 //------------------------------------------------------------------------- 00028 // 00029 00030 TrackingWindow::TrackingWindow( int window_id, int theta_start, int theta_end, int theta_max, 00031 int freeze_frame_bound ) : 00032 _freeze_frame_bound( freeze_frame_bound ), 00033 _window_id( window_id ), 00034 _theta_start( theta_start ), 00035 _theta_end( theta_end ), 00036 _theta_max( theta_max ) 00037 { 00038 _freeze_frame_remaining = _freeze_frame_bound; 00039 00040 if ( _theta_start < _theta_end ) // 0 .. | | | |S| | | | | | |E| | | .. theta_max 00041 this->_window_length = _theta_end - _theta_start; 00042 else // 0 .. | | | |E| | | | | | |S| | | .. theta_max 00043 this->_window_length = _theta_end + _theta_max - _theta_start; 00044 } 00045 00046 //------------------------------------------------------------------------- 00047 // 00048 00049 TrackingWindow::~TrackingWindow() { 00050 00051 } 00052 00053 //------------------------------------------------------------------------- 00054 // 00055 00056 int TrackingWindow::get_id() { 00057 return _window_id; 00058 } 00059 00060 00061 //------------------------------------------------------------------------- 00062 // perform the effective write of the angle interval to the degree table. 00063 // No check is done on value of the destination cell. 00064 00065 void TrackingWindow::write_window_to_table( char* degree_table ) { 00066 00067 for ( int i = 0 ; i < _window_length; i++ ) { 00068 degree_table[(_theta_start + i) % _theta_max] = VALUE_TRACKED; 00069 } 00070 } 00071 00072 00073 //------------------------------------------------------------------------- 00074 // Sets the new bounds and length. 00075 // return false if the freeze status has expired 00076 00077 bool TrackingWindow::update_window_bounds( int new_theta_start, int new_theta_end ) { 00078 00079 // before setting the new values check about the freezing status 00080 if ( this->_theta_start == new_theta_start && 00081 this->_theta_end == new_theta_end ) 00082 _freeze_frame_remaining--; 00083 else // give it some bonus :) 00084 _freeze_frame_remaining = _freeze_frame_bound; 00085 00086 this->_theta_start = new_theta_start; 00087 this->_theta_end = new_theta_end; 00088 00089 if ( _theta_start < _theta_end ) // 0 .. | | | |S| | | | | | |E| | | .. theta_max 00090 this->_window_length = _theta_end - _theta_start; 00091 else // 0 .. | | | |E| | | | | | |S| | | .. theta_max 00092 this->_window_length = _theta_end + _theta_max - _theta_start; 00093 00094 // if the freeze limit has expired we will update the bound status 00095 // BUT return false, signaling this 00096 if ( _freeze_frame_remaining <= 0 ) 00097 return false; 00098 00099 return true; 00100 } 00101 00102 00103 00104 //------------------------------------------------------------------------- 00105 // change the id of the window 00106 00107 void TrackingWindow::change_id( int new_id ) { 00108 _window_id = new_id; 00109 } 00110 00111 00112 00113