User Manual, Developers Guide and API Documentation

Objects.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/shadowing/Objects.hpp>
00029 #include <RISE/scenario/sceneryfile/SceneryFile.hpp>
00030 #include <RISE/scenario/sceneryfile/Walls.hpp>
00031 
00032 #include <WNS/StaticFactoryBroker.hpp>
00033 #include <WNS/pyconfig/View.hpp>
00034 #include <WNS/Position.hpp>
00035 
00036 #include <string>
00037 
00038 using namespace rise::scenario::shadowing;
00039 using namespace rise::scenario;
00040 
00041 STATIC_FACTORY_BROKER_REGISTER(Objects, Shadowing, "Objects");
00042 
00043 STATIC_FACTORY_REGISTER_WITH_CREATOR(Obstructing<wns::geometry::AxisParallelRectangle>,
00044                                      IObstruction,
00045                                      "rise.shadowing.obstruction.AxisParallelRectangle",
00046                                      IObstructionCreator);
00047 
00048 STATIC_FACTORY_REGISTER_WITH_CREATOR(Obstructing<wns::geometry::LineSegment>,
00049                                      IObstruction,
00050                                      "rise.shadowing.obstruction.LineSegment",
00051                                      IObstructionCreator);
00052 
00053 Objects::Objects(const wns::pyconfig::View& config) :
00054     obstructionList(Objects::fetchObstructionList(config))
00055 {
00056 }
00057 
00058 
00059 rise::scenario::ObstructionList
00060 Objects::fetchObstructionList(const wns::pyconfig::View& config)
00061 {
00062     ObstructionList obstructions;
00063 
00064     for( int ii = 0; ii < config.len("obstructionList"); ++ii)
00065     {
00066         wns::pyconfig::View objectView = config.getView("obstructionList", ii);
00067         obstructions.push_front(ObstructionFactory::creator(objectView.get<std::string>("__plugin__"))->create(objectView));
00068     }
00069 
00070     return obstructions;
00071 }
00072 
00073 
00074 rise::scenario::ObstructionList
00075 Objects::fetchObstructionList(Scenario& scenario,
00076                               const wns::pyconfig::View& config)
00077 {
00078     std::string fileName = config.get<std::string>("obstructionFileName");
00079 
00080     scenario.openSceneryFile(fileName, "WallsFile");
00081 
00082     const sceneryfile::Walls& walls =
00083         dynamic_cast<const sceneryfile::Walls&>(scenario.getSceneryFile(fileName));
00084 
00085     return walls.getObstructionList();
00086 }
00087 
00088 
00089 wns::Ratio
00090 Objects::getShadowing(const antenna::Antenna& source,
00091                       const antenna::Antenna& target) const
00092 {
00093     const wns::Position& sourcePos = source.getPosition();
00094     const wns::Position& targetPos = target.getPosition();
00095 
00096     wns::geometry::LineSegment signalPath(sourcePos, targetPos);
00097 
00098     wns::Ratio shadowing;
00099 
00100     for (ObstructionList::const_iterator itr = obstructionList.begin();
00101          itr != obstructionList.end();
00102          ++itr)
00103     {
00104         shadowing += (*itr)->getAttenuation(signalPath);
00105     }
00106 
00107     return shadowing;
00108 }

Generated on Fri May 25 03:31:59 2012 for openWNS by  doxygen 1.5.5