rules/wiredbas/link/WiringRule.h

Go to the documentation of this file.
00001 //============================================================================
00002 // Author      : Alessandro Pinto <apinto@eecs.berkeley.edu>
00003 //               University of California, Berkeley
00004 //               545 Cory Hall, Berkeley, CA 94720
00005 // Copyright   : See COPYING file that comes with this distribution
00006 //============================================================================
00007 
00008 #ifndef WIRINGRULE_H_
00009 #define WIRINGRULE_H_
00010 
00011 #include <iostream>
00012 #include <string>
00013 #include <map>
00014 #include <set>
00015 #include "newmat.h"
00016 #include "float.h"
00017 #include "core/CommunicationStructure.hpp"
00018 #include "label/Label.hpp"
00019 #include "core/Quantity.h"
00020 #include "quantities/WiringPath.h"
00021 #include "quantities/Position.h"
00022 #include "environment/bas/InstSurface.h"
00023 #include "networks/wiredbas/WiredBasImplementation.h"
00024 
00025 namespace cosi {
00026 
00027 namespace rules {
00028 
00029 namespace wiredbas {
00030 
00031 class WiringRule {
00032 public:
00033 
00034         class SurfacePair : public Quantity {
00035                 std::pair<std::string ,std::string> mPair;
00036 public:
00037                 SurfacePair() {
00038                 }
00039                 SurfacePair(std::string pFirst, std::string pSecond) {
00040                         mPair.first = pFirst ;
00041                         mPair.second = pSecond ;
00042                 }
00043                 ;
00044                 ~SurfacePair() {
00045                 }
00046                 ;
00047 
00048                 SurfacePair Get() {
00049                         return (*this);
00050                 }
00051 
00052                 std::string GetFirst() {
00053                         return mPair.first;
00054                 }
00055                 ;
00056                 void SetFirst(std::string pFirst) {
00057                         mPair.first = pFirst ;
00058                 }
00059                 ;
00060                 std::string GetSecond() {
00061                         return mPair.second;
00062                 }
00063                 ;
00064                 void SetSecond(std::string pSecond) {
00065                         mPair.second = pSecond ;
00066                 }
00067                 ;
00068                 bool Contains(std::string pS) {
00069                         return ( (mPair.first == pS) || (mPair.second==pS));
00070                 }
00071                 ;
00072                 bool Intersects(SurfacePair pP) {
00073                         return ( (GetFirst() == pP.GetFirst()) ||(GetFirst()
00074                                         == pP.GetSecond())||(GetSecond() == pP.GetFirst())
00075                                         ||(GetSecond() == pP.GetSecond()));
00076                 }
00077                 ;
00078 
00079                 bool operator==(SurfacePair pP) {
00080                         return ( (GetFirst() == pP.GetFirst() && GetSecond()
00081                                         == pP.GetSecond()) ||(GetFirst() == pP.GetSecond()
00082                                         && GetSecond() == pP.GetFirst()));
00083                 }
00084                 ;
00085 
00086                 friend std::ostream& operator <<(std::ostream &pOs,
00087                                 const SurfacePair &pS);
00088 
00089                 static std::string sQuantityName;
00090                 static std::string sQuantityType;
00091 
00092         };
00093                         WiringRule(
00094                                         std::map< std::string , cosi::environment::bas::InstSurface > pInstallationSurfaces);
00095         virtual ~WiringRule();
00096         virtual WiringPath GetWiringPath(Position pStart, Position pEnd);
00097         cosi::commstruct::wiredbas::Implementation* GetConnectivityGraph() ;
00098 private:
00099         std::map< std::string , cosi::environment::bas::InstSurface >
00100                         mInstallationSurfaces;
00101 
00102         CommunicationStructure< Label_2<Position,SurfacePair> > mConnectivityGraph;
00103 
00104         void BuildSurfaceConnectivityGraph();
00105 
00106         Position FindIntersectionPoint(std::string pS1, std::string pS2);
00107 
00108         Position LineIntersection(ColumnVector a1, ColumnVector b1, double Ub1 ,
00109                         ColumnVector a2, ColumnVector b2,double Ub2);
00110 
00111         Position ClosestPoint(Position pP, std::string pSurface);
00112 
00113         int mLastId;
00114 
00115 };
00116 
00117 }
00118 }
00119 }
00120 #endif /*WIRINGRULE_H_*/

Generated on Sun Sep 7 18:37:43 2008 for COSI by  doxygen 1.5.4
Contact 
©2002-2018 U.C. Regents