00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 00002 00003 /* 00004 * shadowing-vis.h 00005 * Copyright (C) 2000 by the University of Southern California 00006 * $Id: shadowing-vis.h,v 1.3 2005/08/25 18:58:09 johnh Exp $ 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License, 00010 * version 2, as published by the Free Software Foundation. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License along 00018 * with this program; if not, write to the Free Software Foundation, Inc., 00019 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00020 * 00021 * 00022 * The copyright of this module includes the following 00023 * linking-with-specific-other-licenses addition: 00024 * 00025 * In addition, as a special exception, the copyright holders of 00026 * this module give you permission to combine (via static or 00027 * dynamic linking) this module with free software programs or 00028 * libraries that are released under the GNU LGPL and with code 00029 * included in the standard release of ns-2 under the Apache 2.0 00030 * license or under otherwise-compatible licenses with advertising 00031 * requirements (or modified versions of such code, with unchanged 00032 * license). You may copy and distribute such a system following the 00033 * terms of the GNU GPL for this module and the licenses of the 00034 * other code concerned, provided that you include the source code of 00035 * that other code when and as the GNU GPL requires distribution of 00036 * source code. 00037 * 00038 * Note that people who make modified versions of this module 00039 * are not obligated to grant this special exception for their 00040 * modified versions; it is their choice whether to do so. The GNU 00041 * General Public License gives permission to release a modified 00042 * version without this exception; this exception also makes it 00043 * possible to release a modified version which carries forward this 00044 * exception. 00045 * 00046 */ 00047 00048 /* 00049 * Visibiliy-based Shadowing propation model. A bitmap is used for the 00050 * simulation environment. It has 2 shadowing model instances that 00051 * represent good (has line-of-sight path) and bad (obstructed) 00052 * propagation conditions. 00053 * Wei Ye, weiye@isi.edu, 2000 00054 */ 00055 00056 #ifndef visibiliy_shadowing_h 00057 #define visibiliy_shadowing_h 00058 00059 #include <shadowing.h> 00060 #include <packet-stamp.h> 00061 #include <wireless-phy.h> 00062 #include <propagation.h> 00063 00064 class ShadowingVis : public Propagation { 00065 public: 00066 ShadowingVis(); 00067 virtual double Pr(PacketStamp *tx, PacketStamp *rx, WirelessPhy *ifp); 00068 virtual double getDist(double Pr, double Pt, double Gt, double Gr, 00069 double hr, double ht, double L, double lambda) { 00070 return DBL_MAX; 00071 } 00072 00073 virtual int command(int argc, const char*const* argv); 00074 00075 // bitmap handling 00076 void loadImg(const char* fname); 00077 inline char get_pixel(int x, int y) { 00078 if (x<0 || x>=width || y<0 || y>=height) return 0; 00079 return pixel[x + y * width]; 00080 } 00081 00082 /* 00083 inline void set_pixel(int x, int y, char c) { 00084 if (x<0 || x>=width || y<0 || y>=height) return; 00085 pixel[(x + y * width)] = c; 00086 } 00087 00088 00089 inline unsigned int RGB( int r, int g, int b ) { 00090 return (((r << 8) | g) << 8) | b; 00091 } 00092 */ 00093 00094 // get prop condition: good or bad 00095 int getPropCond(float xr, float yr, float xt, float yt); 00096 00097 protected: 00098 Shadowing *goodProp, *badProp; // two shadowing models 00099 unsigned char *pixel; // bitmap pixels 00100 int width, height; 00101 int ppm; // number of pixels per meter 00102 00103 }; 00104 00105 #endif 00106