TeSkaterFunctions.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 #ifndef ParticaoH
00003 #define ParticaoH
00004 
00005 
00006 
00007 #define SKATER_SEM_POPULACAO 0
00008 #define SKATER_COM_POPULACAO 1
00009 
00010 
00011 #define SKATER_POR_GRUPO     0
00012 #define SKATER_POR_POPULACAO 1
00013 #define SKATER_POR_AMBOS     2
00014 
00015 #include "TeSkaterGrafo.h"
00016 #include "TeSkaterArvore.h"
00017 #include "filaR.h"
00018 #include "filaDouble.h"
00019 #include "filaInt.h"
00020 #include <string>
00021 #include <vector>
00022 using namespace std;
00023 
00024 class TeElementSet;
00025 
00026 class STAT_DLL TParticao{
00027 private:
00028   double*  BFS_Media(int,int,long*);
00029   double  BFS_Desvio(int,int,double*);
00030   double  Dist(int,double*);
00031   void  BFS_Main(TFilaR::Item_ptr);//Raiz,Populacao,Desvio
00032   TSkaterGrafo *Grafo;
00033   long PopMin;
00034   int Num_Grupos;
00035 public:
00036   TFilaR *Clusters;
00037   TParticao(TSkaterGrafo*);
00038   ~TParticao();
00039   TFilaDouble *QuedaDesv; 
00040   void  Particiona(int,long);
00041   void  BFS_Salva(TeSTElementSet& regSet, string name);
00042 };
00043 
00044 /** Funcao de regionalizacao de um conjunto de poligonos
00045  *  hasPop: se ha atributo de populacao, que devera ser o ultimo
00046  *  tipo:   tipo de quebra, por grupo, por populacao ou por ambos
00047  *  nGrupos: numero de grupos de quebra
00048  *  popMin:  tamanho minimo da populacao
00049  *  regSet:  conjunto de areas a serem regionalizadas, com seus atributos
00050  *  hetDrop: heterogeneidade dado cada uma das divisoes
00051  **/
00052 template<typename Matrix> bool 
00053 TeSkaterFunction(bool hasPop, int tipo, int nGrupos, int popMin, TeSTElementSet& regSet, 
00054                                   Matrix* proxMatrix, string resName, vector<double>& hetDrop); 
00055 
00056 
00057 template<typename Matrix> bool 
00058 TeSkaterFunction(bool hasPop, int tipo, int nGrupos, int popMin, TeSTElementSet& regSet, 
00059                                  Matrix* proxMatrix, string name, vector<double>& hetDrop) 
00060 {
00061   
00062         TParticao *Particao = 0;
00063         try
00064         {
00065                 //Monta grafo a partir do conjunto 
00066           TSkaterGrafo g(hasPop);
00067           if (!g.MontaGrafo(regSet, proxMatrix)) {
00068                 return false;
00069           }
00070 
00071           TArvore* a = new TArvore();
00072           a->Monta_Arvore(&g);
00073           delete a;
00074 
00075   
00076           Particao = new TParticao(&g);
00077           switch (tipo) {
00078           case SKATER_POR_GRUPO:
00079                  Particao->Particiona(nGrupos,-1);
00080                  break;
00081           case SKATER_POR_POPULACAO:
00082                  Particao->Particiona(0,popMin);
00083                  break;
00084           case SKATER_POR_AMBOS:
00085                  Particao->Particiona(nGrupos,popMin);
00086                  break;
00087           }
00088 
00089           Particao->BFS_Salva(regSet, name);
00090 
00091           //Copia as quedas a partir do numero de grupos para hetDrop,
00092           //comecando do menor
00093           hetDrop.clear();
00094           int size = Particao->QuedaDesv->Size();
00095           for (int gr = 0; gr < size; gr++) {
00096                 double het = Particao->QuedaDesv->Retira();
00097                 hetDrop.push_back(het);
00098           }
00099           delete Particao;
00100         }
00101         catch(...)
00102         {
00103                 if(Particao)
00104                         delete Particao;
00105 
00106                 return false;
00107         }
00108 
00109   return true;
00110 }
00111 
00112 //---------------------------------------------------------------------------
00113 #endif

Generated on Sun Jul 29 04:01:28 2012 for TerraLib - Development Source by  doxygen 1.5.3