User Manual, Developers Guide and API Documentation

Walls.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include <RISE/scenario/sceneryfile/Walls.hpp>
00029 
00030 #include <cctype>
00031 #include <fstream>
00032 
00033 #include <WNS/Assure.hpp>
00034 #include <WNS/PowerRatio.hpp>
00035 
00036 using namespace rise::scenario::sceneryfile;
00037 
00038 Walls::Walls()
00039     : initialized(false),
00040       obstructionList()
00041 {
00042 }
00043 
00044 Walls::Walls(const std::string filename)
00045     : initialized(false),
00046       obstructionList()
00047 {
00048     std::ifstream file(filename.c_str());
00049     assure(file.is_open(), "could not open " + filename);
00050 
00051     std::string inputLine = "";
00052     while (inputLine.find("numWalls1") == std::string::npos)
00053     {
00054         file >> inputLine;
00055     }
00056 
00057     unsigned int numWalls = atoi(inputLine.substr(inputLine.find("=") + 1).c_str());
00058     for (unsigned int wallI = 0; wallI < numWalls; ++wallI)
00059     {
00060         file >> inputLine;
00061         if (inputLine[0] == 'w') {
00062             obstructionList.push_front(createWall(inputLine.substr(2)));
00063         }
00064     }
00065 
00066     file.close();
00067     initialized = true;
00068 }
00069 
00070 Walls::Wall*
00071 Walls::createWall(std::string input)
00072 {
00073     input = input.substr(input.find_first_not_of(" \t"));
00074     double x1 = strtod(input.substr(0, input.find_first_of(" \t")).c_str(), NULL);
00075     input = input.substr(input.find_first_of(" \t"));
00076 
00077     input = input.substr(input.find_first_not_of(" \t"));
00078     double y1 = strtod(input.substr(0, input.find_first_of(" \t")).c_str(), NULL);
00079     input = input.substr(input.find_first_of(" \t"));
00080 
00081     input = input.substr(input.find_first_not_of(" \t"));
00082     double x2 = strtod(input.substr(0, input.find_first_of(" \t")).c_str(), NULL);
00083     input = input.substr(input.find_first_of(" \t"));
00084 
00085     input = input.substr(input.find_first_not_of(" \t"));
00086     double y2 = strtod(input.substr(0, input.find_first_of(" \t")).c_str(), NULL);
00087     input = input.substr(input.find_first_of(" \t"));
00088 
00089     input = input.substr(input.find_first_not_of(" \t"));
00090     unsigned int floor = atoi(input.substr(0, input.find_first_of(" \t")).c_str());
00091     input = input.substr(input.find_first_of(" \t"));
00092     floor = floor;
00093 
00094     input = input.substr(input.find_first_not_of(" \t"));
00095     double attenuation = strtod(input.substr(0, input.find_first_of(" \t")).c_str(), NULL);
00096 
00097     wns::geometry::Point a(x1, y1, 0);
00098     wns::geometry::Point b(x2, y2, 0);
00099 
00100     return (new Wall(wns::geometry::LineSegment(a, b), wns::Ratio::from_dB(attenuation)));
00101 }

Generated on Sat May 26 03:31:55 2012 for openWNS by  doxygen 1.5.5