/// CONSTRUCTOR RARO DE LA MALLA (FUNCIONA) double Malla::makeMalla(mdouble nods, mint e, mdouble cond){ cout<<"INICIO CARGA MALLA"<<endl; /// INICIALIZAMOS LOS NODOS vector<vector<Nodo>::iterator > nodoIte; int nNodos = nods.size(); for(int i=0;i<nNodos;i++) nodos.push_back(Nodo(nods[i][0],nods[i][1])); /// CON SU RESPECTIVO ITERADOR for(int i=0;i<nNodos;i++) nodoIte.push_back(nodos.begin() + i); cout<<"CARGO "<< nNodos<<" NODOS"<<endl; /// VARIABLE DE CONTROL (TRIANGULOS CUADRADOS) int nEle = e.size(), cnod = e[0].size(), id_ari = 0; /// CREAMOS LOS NUEVOS ELEMENTOS for(int i=0;i<nEle;i++){ /// ASIGNAMOS LOS NODOS DEL ELEMENTO I vector<vector<Nodo>::iterator > nele; for(int n=0;n<cnod;n++) nele.push_back(nodoIte[e[i][n]]); /// AGREGAMOS EL NUEVO Elemento elementos.push_back(Elemento(nele,i)); /// PARA CADA PAR DE NODOS CREAMOS UNA ARISTA Y VERIFICAMOS /// QUE NO HAYA SIDO CREADA Y LA GUARDAMOS EN EL ITERADOR "a" for(int j=0;j<cnod;j++){ vector<vector<Nodo>::iterator > naux; /// GUARDAMOS LOS ITERADORES A LOS NODOS naux.push_back(nodoIte[e[i][j]]); naux.push_back(nodoIte[e[i][(j+1)%cnod]]); /// CREAMOS LA ARISTA CON EL I PAR DE NODOS Arista ari; ari.addNodos(naux[0],naux[1]); if( ari_NoExiste(*naux[0],*naux[1])){ /// AGREGAMOS LA CONDICION DE CONTORNO DE LA Arista /// DEFINIMOS VARIABLES A UTILIZAR int ncond = cond.size(); /// BUSCAMOS LOS NODOS EN LAS CONDICIONES "cond" for(int i=0;i<ncond;i++){ if((nodos[cond[i][0]] == *naux[0] && nodos[cond[i][1]] == *naux[1]) || (nodos[cond[i][0]] == *naux[1] && nodos[cond[i][1]] == *naux[0])){ if(cond[i][2] == 1) ari.setFront(cond[i][3],cond[i][4]); else ari.setFront(cond[i][3]); } } ari.setId(id_ari); aristas.push_back(ari); naux[0]->push_ariId(id_ari); naux[1]->push_ariId(id_ari); id_ari++; } } } nEle = elementos.size(); int nAri = aristas.size(); cout<<"CARGO "<<nAri<<" ARISTAS Y "<<nEle<<" ELEMENTOS"<<endl; /// RECORREMOS LOS ELEMENTOS PARA ASIGNARLE LAS ARISTAS for(int i=0;i<nEle;i++){ /// SETEAMOS LAS ARISTAS DEL ELEMENTO elementos[i].setAristas(aristas.begin(), elementos.begin()); } cout<<"ASIGNO ARISTAS A ELEMENTOS"<<endl; for(int i=0;i<nNodos;i++) nodos[i].aris.clear(); cout<<"ELIMINAMOS LAS ARI DE LOS NODOS"<<endl; h=aristas[0].getModulo(); U.setSizeCeros(nEle*2,cnod+2); M.setSizeCeros(nEle,cnod+2); F = vec(nEle); P = vec(nEle); B = vec(nEle*2); cout<<"FIN - CARGA MALLA"<<endl; return h; }
void Lexico::createLexico() { bool sig; int nTab = 0; while (noError && (sig = nextPosition())) { sig = false; if (isdigit(cadena[position])) { elementos.push_back(Elemento(std::string(1, cadena[position]), T_ENTERO)); while (nextPosition()) { if (isdigit(cadena[position])) { elementos.back().simbolo.append(1, cadena[position]); } else if (cadena[position] == '.') { elementos.back().tipo = T_FLOTANTE; elementos.back().simbolo.append(1, cadena[position]); while ((sig = nextPosition()) && isdigit(cadena[position])) { elementos.back().simbolo.append(1, cadena[position]); } if (sig) position--; break; } else { position--; break; } } } else if (isalpha(cadena[position]) || cadena[position] == '_') { elementos.push_back(Elemento(std::string(1, cadena[position]), T_ID)); while ((sig = nextPosition()) && isalnum(cadena[position]) || cadena[position] == '_') { elementos.back().simbolo.append(1, cadena[position]); } if (sig) position--; } else { switch (cadena[position]) { case ' ': case '\t': break; case '\n': case '\r': elementos.push_back(Elemento(std::string(1, cadena[position]), T_SALTO_LINEA)); while ((sig = nextPosition()) && cadena[position] == '\n' || cadena[position] == '\r'); if (sig) position--; nTab = 0; while ((sig = nextPosition()) && cadena[position] == '\t') { nTab++; } if (sig) { position--; } if (indent > nTab) { for (int a = 0; a < indent - nTab; a++) elementos.push_back(Elemento(std::string(1, cadena[position]), T_DEDENT)); } else if (indent < nTab) { for (int a = 0; a < nTab - indent; a++) elementos.push_back(Elemento(std::string(1, cadena[position]), T_INDENT)); } indent = nTab; break; case ':': elementos.push_back(Elemento(std::string(1, cadena[position]), T_DOS_PUNTOS)); break; case '+': case '-': elementos.push_back(Elemento(std::string(1, cadena[position]), T_ADICION)); break; case ',': elementos.push_back(Elemento(std::string(1, cadena[position]), T_COMA)); break; case '(': case ')': elementos.push_back(Elemento(std::string(1, cadena[position]), T_PARENTESIS)); break; case '*': case '/': elementos.push_back(Elemento(std::string(1, cadena[position]), T_MULTIPLICACION)); break; case '=': if ((sig = nextPosition()) && cadena[position] == '=') { elementos.push_back(Elemento("==", T_IGUAL_QUE)); } else { if (sig) position--; elementos.push_back(Elemento("=", T_ASIGNACION)); } break; case '&': if ((sig = nextPosition()) && cadena[position] == '&') { elementos.push_back(Elemento("&&", T_AND)); } else { noError = false; } break; case '|': if ((sig = nextPosition()) && cadena[position] == '|') { elementos.push_back(Elemento("||", T_OR)); } else { noError = false; } break; case '!': if ((sig = nextPosition()) && cadena[position] == '=') { elementos.push_back(Elemento("!=", T_DIFERENTE)); } else { if (sig) position--; elementos.push_back(Elemento("!", T_NOT)); } break; case '<': case '>': if ((sig = nextPosition()) && cadena[position] == '=') { elementos.push_back(Elemento(cadena.substr(position - 1, 2), T_MAYOR_MENOR_IGUAL_QUE)); } else { if (sig) position--; elementos.push_back(Elemento(std::string(1, cadena[position]), T_MAYOR_MENOR_QUE)); } break; default: noError = false; } } } }