PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER* aRouter ) : m_router( aRouter ), m_board( aBoard ) { PNS::NODE* world = m_router->GetWorld(); PNS::TOPOLOGY topo( world ); m_netClearanceCache.resize( m_board->GetNetCount() ); for( unsigned int i = 0; i < m_board->GetNetCount(); i++ ) { NETINFO_ITEM* ni = m_board->FindNet( i ); if( ni == NULL ) continue; CLEARANCE_ENT ent; ent.coupledNet = DpCoupledNet( i ); wxString netClassName = ni->GetClassName(); NETCLASSPTR nc = m_board->GetDesignSettings().m_NetClasses.Find( netClassName ); int clearance = nc->GetClearance(); ent.clearance = clearance; m_netClearanceCache[i] = ent; wxLogTrace( "PNS", "Add net %u netclass %s clearance %d", i, netClassName.mb_str(), clearance ); } for( MODULE* mod = m_board->m_Modules; mod ; mod = mod->Next() ) { auto moduleClearance = mod->GetLocalClearance(); for( D_PAD* pad = mod->Pads(); pad; pad = pad->Next() ) { int padClearance = pad->GetLocalClearance(); if( padClearance > 0 ) m_localClearanceCache[ pad ] = padClearance; else if( moduleClearance > 0 ) m_localClearanceCache[ pad ] = moduleClearance; } } //printf("DefaultCL : %d\n", m_board->GetDesignSettings().m_NetClasses.Find ("Default clearance")->GetClearance()); m_overrideEnabled = false; m_defaultClearance = Millimeter2iu( 0.254 ); // m_board->m_NetClasses.Find ("Default clearance")->GetClearance(); m_overrideNetA = 0; m_overrideNetB = 0; m_overrideClearance = 0; }
bool PNS_MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { VECTOR2I p; if( !aStartItem || !aStartItem->OfKind( PNS_ITEM::SEGMENT ) ) { Router()->SetFailureReason( _( "Please select a differential pair trace you want to tune." ) ); return false; } m_initialSegment = static_cast<PNS_SEGMENT*>( aStartItem ); p = m_initialSegment->Seg().NearestPoint( aP ); m_currentNode = NULL; m_currentStart = p; m_world = Router()->GetWorld( )->Branch(); m_originLine = m_world->AssembleLine( m_initialSegment ); PNS_TOPOLOGY topo( m_world ); m_tunedPath = topo.AssembleTrivialPath( m_initialSegment ); if( !topo.AssembleDiffPair ( m_initialSegment, m_originPair ) ) { Router()->SetFailureReason( _( "Unable to find complementary differential pair " "net for skew tuning. Make sure the names of the nets belonging " "to a differential pair end with either _N/_P or +/-." ) ); return false; } if( m_originPair.Gap() < 0 ) m_originPair.SetGap( Router()->Sizes().DiffPairGap() ); if( !m_originPair.PLine().SegmentCount() || !m_originPair.NLine().SegmentCount() ) return false; m_tunedPathP = topo.AssembleTrivialPath( m_originPair.PLine().GetLink( 0 ) ); m_tunedPathN = topo.AssembleTrivialPath( m_originPair.NLine().GetLink( 0 ) ); m_world->Remove( &m_originLine ); m_currentWidth = m_originLine.Width(); m_currentEnd = VECTOR2I( 0, 0 ); if ( m_originPair.PLine().Net() == m_originLine.Net() ) m_coupledLength = itemsetLength( m_tunedPathN ); else m_coupledLength = itemsetLength( m_tunedPathP ); return true; }
void PNS_DIFF_PAIR_PLACER::updateLeadingRatLine() { SHAPE_LINE_CHAIN ratLineN, ratLineP; PNS_TOPOLOGY topo( m_lastNode ); if( topo.LeadingRatLine( &m_currentTrace.PLine(), ratLineP ) ) { Dbg()->AddLine( ratLineP, 1, 10000 ); } if( topo.LeadingRatLine ( &m_currentTrace.NLine(), ratLineN ) ) { Dbg()->AddLine( ratLineN, 3, 10000 ); } }
int main() { struct graph g; graph_fill(&g); int sorted[MAX_V]; topo(&g, sorted); int i; printf("Orden topologico: "); for (i = 0; i < g.nr_vertices; ++i) printf("%d ", sorted[i]); printf("\n"); return 0; }
int main(){ freopen("hdu2647.txt", "r", stdin); while (scanf("%d%d", &n, &m) != EOF){ // Init. memset(map, 0, sizeof(map)); memset(value, 0, sizeof(value)); memset(in, 0, sizeof(in)); ok = sum = 0; // Read. for (int i = 0; i < m; i++){ int a, b; scanf("%d%d", &a, &b); map[a][in[a]++] = b; } // Handle. for (int i = 1; i <= n; i++){ if (value[i]){ sum += value[i]; continue; } memset(vis, 0, sizeof(vis)); printf("===get %d rewards\n", i ); value[i] = topo(i); if (value[i] == 0){ ok = 1; break; } sum += value[i]; } // Printf. if (ok) printf("-1\n"); else printf("%d\n", sum); } fclose(stdin); return 0;}
void TOOL_BASE::deleteTraces( ITEM* aStartItem, bool aWholeTrack ) { NODE *node = m_router->GetWorld()->Branch(); if( !aStartItem ) return; if( !aWholeTrack ) { node->Remove( aStartItem ); } else { TOPOLOGY topo( node ); ITEM_SET path = topo.AssembleTrivialPath( aStartItem ); for( auto ent : path.Items() ) node->Remove( ent.item ); } m_router->CommitRouting( node ); }
bool PNS_TOPOLOGY::LeadingRatLine( const PNS_LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine ) { PNS_LINE track( *aTrack ); VECTOR2I end; if( !track.PointCount() ) return false; std::unique_ptr<PNS_NODE> tmpNode( m_world->Branch() ); tmpNode->Add( &track ); PNS_JOINT* jt = tmpNode->FindJoint( track.CPoint( -1 ), &track ); if( !jt ) return false; if( ( !track.EndsWithVia() && jt->LinkCount() >= 2 ) || ( track.EndsWithVia() && jt->LinkCount() >= 3 ) ) // we got something connected { end = jt->Pos(); } else { int anchor; PNS_TOPOLOGY topo( tmpNode.get() ); PNS_ITEM* it = topo.NearestUnconnectedItem( jt, &anchor ); if( !it ) return false; end = it->Anchor( anchor ); } aRatLine.Clear(); aRatLine.Append( track.CPoint( -1 ) ); aRatLine.Append( end ); return true; }
PNS_PCBNEW_CLEARANCE_FUNC::PNS_PCBNEW_CLEARANCE_FUNC( PNS_ROUTER* aRouter ) : m_router( aRouter ) { BOARD* brd = m_router->GetBoard(); PNS_NODE* world = m_router->GetWorld(); PNS_TOPOLOGY topo( world ); m_clearanceCache.resize( brd->GetNetCount() ); m_useDpGap = false; for( unsigned int i = 0; i < brd->GetNetCount(); i++ ) { NETINFO_ITEM* ni = brd->FindNet( i ); if( ni == NULL ) continue; CLEARANCE_ENT ent; ent.coupledNet = topo.DpCoupledNet( i ); wxString netClassName = ni->GetClassName(); NETCLASSPTR nc = brd->GetDesignSettings().m_NetClasses.Find( netClassName ); int clearance = nc->GetClearance(); ent.clearance = clearance; m_clearanceCache[i] = ent; TRACE( 1, "Add net %d netclass %s clearance %d", i % netClassName.mb_str() % clearance ); } m_overrideEnabled = false; m_defaultClearance = Millimeter2iu( 0.254 ); // aBoard->m_NetClasses.Find ("Default clearance")->GetClearance(); m_overrideNetA = 0; m_overrideNetB = 0; m_overrideClearance = 0; }
vector<Vertex*> Topological_sort() { //more efficient way is to make the list in DFS():insert the vertex onto the front of list when setting its fTime DFS(); vector<Vertex*> topo(vertex.size()); for(int i=0; i < vertex.size(); ++i) { topo[i] = &(vertex[i]); } sort(topo.begin(),topo.end(),topoBigger); /* for(int i=0; i < topo.size(); ++i) { cout << "Vertex:\t" << topo[i]->number << endl; cout << "state:\t" << topo[i]->state << endl; cout << "dist:\t" << topo[i]->dist << endl; cout << "dTime:\t" << topo[i]->dTime << endl; cout << "fTime:\t" << topo[i]->fTime << endl; cout << "pre:\t" << topo[i]->pre << endl; cout << endl; } */ return topo; }
/* return vector from geocenter->observatory in ICRS coordinates*/ void observatory_geocenter(double jd, int obscode, double *xobs, double *yobs, double *zobs) { /* fprintf(stderr, "Reading site entries\n"); */ if (nsites<=0 && nspacecraft<=0) read_observatories(NULL); /* fprintf(stderr, "Read entries for %i sites\n", nsites); */ if (obscode < OBSCODE_ORBITAL) { /* This is a ground-based observatory */ double obslat, obslon, obsalt, obslmst; /*observatory info*/ int i; if (obscode==OBSCODE_GEOCENTER) { *xobs=*yobs=*zobs=0.; return; } /* get the lat, lon, & altitude of this observatory */ for (i=0; obscode!=sitelist[i].code && i<nsites; i++) ; if (i>=nsites) { fprintf(stderr,"Unknown observatory code %d\n",obscode); exit(1); } obslon = sitelist[i].lon; obslat = sitelist[i].lat; obsalt = sitelist[i].altitude; /* Get the LMST and calculate to ICRS vector */ obslmst=lst(jd,obslon); topo(obslmst*PI/12., obslat, obsalt, xobs, yobs, zobs); } else { /* Orbiting observatory */ double pole, rapole, phase; int i; SPACECRAFT *s; for (i=0; obscode!=spacecraftlist[i].code && i<nspacecraft; i++) ; if (i>=nspacecraft) { fprintf(stderr,"Unknown spacecraft code %d\n",obscode); exit(1); } s = &(spacecraftlist[i]); pole = s->i; phase = -(jd - s->jd0) / s->precess;/* RA of pole DEcreases w/time * for precess > 0 */ phase -= floor(phase); rapole = s->ra0 + phase*TPI; phase = (jd - s->jd0) / s->P; /* orbit is increasing RA * for P > 0 */ phase -= floor(phase); phase *= TPI; *xobs = s->a * (cos(phase)*cos(rapole) - cos(pole)*sin(phase)*sin(rapole)); *yobs = s->a * (cos(phase)*sin(rapole) + cos(pole)*sin(phase)*cos(rapole)); *zobs = s->a * sin(phase)*sin(pole); /*fprintf(stderr,"Obs. Posn at jd %.5f : phase %.1f rapole %.1f pole %.1f \n", jd, phase/DTOR, rapole/DTOR, pole/DTOR);*/ /*fprintf(stderr," x,y,z: %g %g %g\n", *xobs, *yobs, *zobs);*/ } return; }
void infixToPostfix(char expr[], Pilha *p, char post[]) { int i = 0; int count = 0; int abriuParentesis = 0; // flag para indicar se abriu parentesis // limpar o post post[0] = '\0'; // para evitar: a+b+ char ultimo = expr[strlen(expr) - 1]; // Garante que a string possui somente caracteres validos i = 0; while (i < MAX && expr[i] != '\0' && expr[i] != '\n') { if (!operadorValido(expr[i])) { strcpy(post,"Lexical Error!"); return; } i++; } i = 0; while (i < MAX && expr[i] != '\0' && expr[i] != '\n') { // do infix to postfix if (simbolo(expr[i])) { // para evitar: aa+bb, a(b+c) if (i+1 != MAX && (simbolo(expr[i + 1]) || expr[i + 1] == '(')) { strcpy(post,"Syntax Error!"); return; } // concatena o na string posfixa post[count] = expr[i]; post[count + 1] = '\0'; count++; } else { // para evitar: a++b if (expr[i]=='(' && !simbolo(expr[i+1]) || (expr[i]!='(' && expr[i]!=')') && (expr[i+1]!='(' && expr[i+1]!=')') && !simbolo(expr[i+1]) ) { strcpy(post,"Syntax Error!"); return; } if (pilhaVazia(p) || expr[i]=='(' || abriuParentesis) { inserePilha(p, expr[i]); abriuParentesis = expr[i] == '(' ? 1 : 0; } else if (expr[i] == ')') { while (!pilhaVazia(p) && topo(p) != '(') { // remove da pilha e insere na string post[count] = removePilha(p); post[count + 1] = '\0'; count++; } // caso encontre o '(' remove da pilha if (pilhaVazia(p)) { strcpy(post,"Syntax Error!"); return; } else { removePilha(p); abriuParentesis = 0; } } else { if (temPrecedencia(topo(p), expr[i])) { do { post[count] = removePilha(p); post[count + 1] = '\0'; count++; } while (!pilhaVazia(p) && temPrecedencia(topo(p), expr[i])); inserePilha(p, expr[i]); } else { inserePilha(p, expr[i]); } } } i++; } if (operadorValido(ultimo) && !simbolo(ultimo) && ultimo != ')') { strcpy(post,"Syntax Error!"); return; } while(!(pilhaVazia(p))) { post[count] = removePilha(p); post[count + 1] = '\0'; count++; } // verifica se faltou fechar algum parentesis for (i = 0; i < count; i++) { if (post[i] == '(') { strcpy(post,"Syntax Error!"); return; } } }
int analisadorSintatico(FILE* codigo, char** TABGRAFO, char*** TABT, char*** TABNT, char*** ANASIN, int linhasTabNT, int** automato, Hash tab, FILE* tabVar, Hash tabProc){ char nomeArquivo[20]; int* flag1 = (int *)malloc(sizeof(int));; *flag1 = 0; FILE* codigoIntermediario; //Inicializa as Pilhas Pilha* cadeia = inicializarPilha(cadeia); Pilha* naoTerminais = inicializarPilha(naoTerminais); push(naoTerminais,"progrm",10,0); char* cadCaracteres = (char *)malloc(50*sizeof(char)); char* cadTerminais = (char *)malloc(50*sizeof(char)); char* p = (char *)malloc(50*sizeof(char)); //Isso sera alterado quando comecarmos a ler strings ao inves de caracteres char* caracter = (char *)malloc(50*sizeof(char)); int numeroLinha = 0; int aux=0; int aux2=0; int flag = 0; char** vetor = (char **)malloc(4*sizeof(char *)); int i; for(i=0;i<4;i++){ vetor[i] = (char *)malloc(20*sizeof(char)); } int* posicaoArquivo = (int *)malloc(sizeof(int)); int* linhaArquivo = (int *)malloc(sizeof(int)); *linhaArquivo = 1; *posicaoArquivo = 0; while(executaAnalisador(codigo, automato, 34, 7, tab, posicaoArquivo, vetor, tabProc, variaveis, linhaArquivo)) { strcpy(caracter, vetor[1]); printf("\n\nLinha %d | Lexema: \"%s\"\n", aux+1, caracter); if(aux==-1){ printf("\n\n!! Cadeia nao aceita !!\n\n\n"); //printf("\n\nErro na linha %d\n\n",*linhaArquivo); return 0; } while(1){ // para aux == -2 while(aux==-2 && !vaziaNTerminais(naoTerminais)){ //imprimirPilha(naoTerminais); aux = atoi(ANASIN[buscaNoTopo(naoTerminais)][4])-1; printf("Voltando para linha %d.\n", aux+1); if(aux==-1) aux = -2; if(aux!=-2){ while(aux!=-1 && strcmp(ANASIN[aux][1],caracter)!=0){ //Verifica os nos alternativos para procurar o caracter aux = atoi(ANASIN[aux][3])-1; printf("Voltando novamente, para linha %d.\n", aux+1); // trick para tratar alternativo igual a -1 if(aux==-2) aux = -1; } if(aux==-1) aux = -2; } // printf("%s\n",caracter); // printf("O Nao Terminal abaixo eh pai de: "); // imprimePilhaPosicaoAteTopo(cadeia, buscaPosicaoReconhecida(naoTerminais)); desempilhaDaPosicaoAteTopo(cadeia,buscaPosicaoReconhecida(naoTerminais)); //Adicionar uma especie de fila aqui strcpy(p, pop(naoTerminais)); push(cadeia,p,0,0); // printf("Desempilha o nao terminal %s\n",p); } if(vaziaNTerminais(naoTerminais) && aux==-2){ printf("\n\n!! Cadeia nao aceita !!\n\n\n"); // printf("Linha %d - Lexema \"%s\" encontrado.\n", numeroLinha, caracter); return 0; } // Para um Terminal encontrado if(strcmp(ANASIN[aux][0],"T")==0){ // para caracter lido reconhecido if(strcmp(ANASIN[aux][1],caracter)==0){ strcpy(cadCaracteres,ANASIN[aux][1]); push(cadeia,cadCaracteres,0,0); //Insere na pilha o caracter reconhecido aplicaAcoesSemanticas(codigoIntermediario, atoi(ANASIN[aux][5]),vetor, nomeArquivo, flag1); printf("TO AQUI %s\n",ANASIN[aux][5]); //imprimirPilha(cadeia); aux = atoi(ANASIN[aux][4])-1; //Aux recebe a linha correspondente ao sucessor do no encontrado printf("Lexema aceito. O sucessor é a linha: %d\n", aux+1); //printf("%s - %d\n", cadCaracteres, atoi(ANASIN[aux][5])); if(aux==-1) { aux=-2; printf("Linha sucessora é 0, ou seja, Chegamos ao fim dessa cadeia não terminal.\n"); } break; } // para caracter não reconhecido else { aux = atoi(ANASIN[aux][3])-1; //Aux recebe a posicao do no alternativo //Caso nao haja mais nenhum no alternativo if(aux==-2){ printf("\n\n!! Cadeia nao aceita !!\n\n\n"); //printf("\n\nErro na linha %d\n\n",*linhaArquivo); return 0; } printf("Não reconhecido. Alternativo na linha: %d\n", aux+1); } } // para um não terminal encontrado else if(strcmp(ANASIN[aux][0],"N")==0){ //Encontra um Nao Terminal strcpy(cadTerminais,ANASIN[aux][1]); aplicaAcoesSemanticas(codigoIntermediario, atoi(ANASIN[aux][5]),vetor, nomeArquivo, flag1); push(naoTerminais,cadTerminais,atoi(ANASIN[aux][2])-1,topo(cadeia)); //Empilha o nao terminal na pilha de nao naoTerminais printf("Não terminal encontrado: \"%s\". Devemos empilha-lo.\n",cadTerminais); printf("Ao finalizar esse não terminal devemos voltar na linha: %d. ", atoi(ANASIN[aux][4])); aux = verificaLinhaTerminal(TABNT,linhasTabNT,cadTerminais); //Aux vai para a linha correspondente ao grafo do nao terminal printf("Vai para a linha: %d\n", aux+1); // imprimirPilha(naoTerminais); } } numeroLinha = aux; strcpy(vetor[0], ""); strcpy(vetor[1], ""); strcpy(vetor[2], ""); } imprimirPilha(naoTerminais); while(!vazia(naoTerminais)){ // printf("O Nao Terminal Abaixo é pai de: "); // imprimePilhaPosicaoAteTopo(cadeia, buscaPosicaoReconhecida(naoTerminais)); desempilhaDaPosicaoAteTopo(cadeia,buscaPosicaoReconhecida(naoTerminais)); strcpy(p,pop(naoTerminais)); // printf("Desempilhando o %s\n",p); push(cadeia,p,0,0); } printf("\n\n!! Cadeia reconhecida !!\n\n\n"); return 1; }
int main(){ int i; PILHA_ESTATICA pilha; for (i = 0; i < 5; i++){ ITEM item; item.valor = i; if (empilhar(&pilha, &item)){ printf("Entrou na pilha: %d - T: %d\n", item.valor, topo(&pilha)); } else { printf("%d: Pilha cheia.\n", item.valor); } } printf("\nPilha atual: "); imprime(&pilha); printf("\n"); printf("Tamanho: %d\n--\n", contar(&pilha)); ITEM item1; item1.valor = 100; if (empilhar(&pilha, &item1)){ printf("Entrou na pilha: %d - T: %d\n", item1.valor, topo(&pilha)); } else { printf("%d: Pilha cheia.\n", item1.valor); } printf("\nPilha atual: "); imprime(&pilha); printf("\n"); printf("Tamanho: %d\n--\n", contar(&pilha)); frente(&pilha, &item1); printf("Elemento do topo: %d\n--\n, item1.valor"); if (desempilhar(&pilha, &item1)){ printf("Saiu da pilha: %d - T: %d\n", item1.valor, topo(&pilha)); } else { printf("Pilha vazia.\n", item1.valor); } item1.valor = 9; if (empilhar(&pilha, &item1)){ printf("Entrou na pilha: %d - T: %d\n", item1.valor, topo(&pilha)); } else { printf("%d: Pilha cheia.\n", item1.valor); } printf("\nPilha atual: "); imprime(&pilha); printf("\n"); printf("Tamanho: %d\n--\n", contar(&pilha)); return 0; }
bool PNS_DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) { if( !m_fitOk ) return false; if( m_currentTrace.CP().SegmentCount() < 1 || m_currentTrace.CN().SegmentCount() < 1 ) return false; if( m_currentTrace.CP().SegmentCount() > 1 ) m_initialDiagonal = !DIRECTION_45( m_currentTrace.CP().CSegment( -2 ) ).IsDiagonal(); PNS_TOPOLOGY topo( m_lastNode ); if( !m_snapOnTarget && !m_currentTrace.EndsWithVias() ) { SHAPE_LINE_CHAIN newP( m_currentTrace.CP() ); SHAPE_LINE_CHAIN newN( m_currentTrace.CN() ); if( newP.SegmentCount() > 1 && newN.SegmentCount() > 1 ) { newP.Remove( -1, -1 ); newN.Remove( -1, -1 ); } m_currentTrace.SetShape( newP, newN ); } if( m_currentTrace.EndsWithVias() ) { m_lastNode->Add( m_currentTrace.PLine().Via().Clone() ); m_lastNode->Add( m_currentTrace.NLine().Via().Clone() ); m_chainedPlacement = false; } else { m_chainedPlacement = !m_snapOnTarget; } PNS_LINE lineP( m_currentTrace.PLine() ); PNS_LINE lineN( m_currentTrace.NLine() ); m_lastNode->Add( &lineP ); m_lastNode->Add( &lineN ); topo.SimplifyLine( &lineP ); topo.SimplifyLine( &lineN ); m_prevPair = m_currentTrace.EndingPrimitives(); Router()->CommitRouting( m_lastNode ); m_lastNode = NULL; m_placingVia = false; if( m_snapOnTarget ) { m_idle = true; return true; } else { initPlacement(); return false; } }
void mostrarPossibilidades(Pilha * pino1, Pilha * pino2, Pilha * pino3){ printf("Voce pode fazer esses movimentos: "); if((topo(pino1) < topo(pino2) || tamanho(pino2) == 0) && tamanho(pino1) > 0){ printf(" AB "); } if((topo(pino1) < topo(pino3) || tamanho(pino3) == 0) && tamanho(pino1) > 0){ printf(" AC "); } if((topo(pino2) < topo(pino1) || tamanho(pino1) == 0) && tamanho(pino2) > 0){ printf(" BA "); } if((topo(pino2) < topo(pino3) || tamanho(pino3) == 0) && tamanho(pino2) > 0){ printf(" BC "); } if((topo(pino3) < topo(pino1) || tamanho(pino1) == 0) && tamanho(pino3) > 0){ printf(" CA "); } if((topo(pino3) < topo(pino2) || tamanho(pino2) == 0) && tamanho(pino3) > 0){ printf(" CB "); } printf("\n"); }
void ATO::StiffnessObjective<PHAL::AlbanyTraits::Residual, Traits>:: evaluateFields(typename Traits::EvalData workset) { if(m_excludeBlock) return; if( elementBlockName != workset.EBName ) return; int nTopos = topologies->size(); Teuchos::Array<double> topoVals(nTopos); Albany::MDArray F = (*workset.stateArrayPtr)[FName]; Teuchos::Array<Albany::MDArray> dEdp(nTopos), topo(nTopos); for(int itopo=0; itopo<nTopos; itopo++){ dEdp[itopo] = (*workset.stateArrayPtr)[dFdpNames[itopo]]; topo[itopo] = (*workset.stateArrayPtr)[(*topologies)[itopo]->getName()]; } std::vector<int> dims; penaltyModel->getFieldDimensions(dims); int size = dims.size(); double internalEnergy=0.0; int numCells = dims[0]; int numQPs = dims[1]; int numDims = dims[2]; int numNodes = topo[0].dimension(1); double response; Teuchos::Array<double> dResponse(nTopos); for(int cell=0; cell<numCells; cell++){ for(int itopo=0; itopo<nTopos; itopo++) for(int node=0; node<numNodes; node++) dEdp[itopo](cell,node) = 0.0; for(int qp=0; qp<numQPs; qp++){ // compute topology values at this qp for(int itopo=0; itopo<nTopos; itopo++){ topoVals[itopo] = 0.0; for(int node=0; node<numNodes; node++) topoVals[itopo] += topo[itopo](cell,node)*BF(cell,node,qp); } penaltyModel->Evaluate(topoVals, topologies, cell, qp, response, dResponse); internalEnergy += response*qp_weights(cell,qp); // assemble for(int itopo=0; itopo<nTopos; itopo++) for(int node=0; node<numNodes; node++) // dEdp[itopo](cell,node) += dResponse[itopo]*BF(cell,node,qp)*qp_weights(cell,qp); // JR: The negative sign is to make this a total derivative dEdp[itopo](cell,node) -= dResponse[itopo]*BF(cell,node,qp)*qp_weights(cell,qp); } } F(0) += internalEnergy; }
//---------------------------------------------------------------------------// // Tests. //---------------------------------------------------------------------------// TEUCHOS_UNIT_TEST( IntrepidBasisFactory, factory_test ) { typedef Intrepid::FieldContainer<double> MDArray; typedef double Scalar; typedef Intrepid::Basis<Scalar,MDArray> Basis; // Line 2. { shards::CellTopology topo( shards::getCellTopologyData<shards::Line<2> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 2 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Triangle 3. { shards::CellTopology topo( shards::getCellTopologyData<shards::Triangle<3> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 3 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Triangle 6. { shards::CellTopology topo( shards::getCellTopologyData<shards::Triangle<6> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 6 ); TEST_EQUALITY( basis->getDegree(), 2 ); } // Quadrilateral 4. { shards::CellTopology topo( shards::getCellTopologyData<shards::Quadrilateral<4> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 4 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Quadrilateral 9. { shards::CellTopology topo( shards::getCellTopologyData<shards::Quadrilateral<9> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 9 ); TEST_EQUALITY( basis->getDegree(), 2 ); } // Tetrahedron 4. { shards::CellTopology topo( shards::getCellTopologyData<shards::Tetrahedron<4> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 4 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Tetrahedron 10. { shards::CellTopology topo( shards::getCellTopologyData<shards::Tetrahedron<10> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 10 ); TEST_EQUALITY( basis->getDegree(), 2 ); } // Hexahedron 8. { shards::CellTopology topo( shards::getCellTopologyData<shards::Hexahedron<8> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 8 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Hexahedron 27. { shards::CellTopology topo( shards::getCellTopologyData<shards::Hexahedron<27> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 27 ); TEST_EQUALITY( basis->getDegree(), 2 ); } // Wedge 6. { shards::CellTopology topo( shards::getCellTopologyData<shards::Wedge<6> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 6 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Wedge 18. { shards::CellTopology topo( shards::getCellTopologyData<shards::Wedge<18> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 18 ); TEST_EQUALITY( basis->getDegree(), 2 ); } // Pyramid 5. { shards::CellTopology topo( shards::getCellTopologyData<shards::Pyramid<5> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 5 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Pyramid 13. { shards::CellTopology topo( shards::getCellTopologyData<shards::Pyramid<13> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 5 ); TEST_EQUALITY( basis->getDegree(), 1 ); } // Pyramid 14. { shards::CellTopology topo( shards::getCellTopologyData<shards::Pyramid<14> >() ); Teuchos::RCP<Basis> basis = DataTransferKit::IntrepidBasisFactory::create( topo ); TEST_EQUALITY( basis->getCardinality(), 5 ); TEST_EQUALITY( basis->getDegree(), 1 ); } }
int main(int argc, char **argv) { char *mapset; int ret, level; int i, stat = 0, type, display; int chcat = 0; int r, g, b; int has_color, has_fcolor; struct color_rgb color, fcolor; double size; int default_width; double width_scale; int verbose = FALSE; double minreg, maxreg, reg; char map_name[128]; struct GModule *module; struct Option *map_opt; struct Option *color_opt, *fcolor_opt, *rgbcol_opt, *zcol_opt; struct Option *type_opt, *display_opt; struct Option *icon_opt, *size_opt, *sizecolumn_opt, *rotcolumn_opt; struct Option *where_opt; struct Option *field_opt, *cat_opt, *lfield_opt; struct Option *lcolor_opt, *bgcolor_opt, *bcolor_opt; struct Option *lsize_opt, *font_opt, *xref_opt, *yref_opt; struct Option *attrcol_opt, *maxreg_opt, *minreg_opt; struct Option *width_opt, *wcolumn_opt, *wscale_opt; struct Option *render_opt; struct Flag *verbose_flag; /* please remove before GRASS 7 released */ struct Flag *id_flag, *table_acolors_flag, *cats_acolors_flag, *x_flag, *zcol_flag; struct cat_list *Clist; int *cats, ncat; LATTR lattr; struct Map_info Map; struct field_info *fi; dbDriver *driver; dbHandle handle; struct Cell_head window; BOUND_BOX box; double overlap; /* Initialize the GIS calls */ G_gisinit(argv[0]); module = G_define_module(); module->keywords = _("display, vector"); module->description = _("Displays user-specified vector map " "in the active graphics frame."); map_opt = G_define_standard_option(G_OPT_V_MAP); display_opt = G_define_option(); display_opt->key = "display"; display_opt->type = TYPE_STRING; display_opt->required = YES; display_opt->multiple = YES; display_opt->answer = "shape"; display_opt->options = "shape,cat,topo,dir,attr,zcoor"; display_opt->description = _("Display"); display_opt->descriptions = _("shape;Display geometry of features;" "cat;Display category numbers of features;" "topo;Display topology information (nodes, edges);" "dir;Display direction of linear features;" "attr;Display selected attribute based on 'attrcol';" "zcoor;Display z-coordinate of features (only for 3D vector maps)"); /* Query */ type_opt = G_define_standard_option(G_OPT_V_TYPE); type_opt->answer = "point,line,boundary,centroid,area,face"; type_opt->options = "point,line,boundary,centroid,area,face"; type_opt->guisection = _("Selection"); field_opt = G_define_standard_option(G_OPT_V_FIELD); field_opt->label = _("Layer number (if -1, all layers are displayed)"); field_opt->gisprompt = "old_layer,layer,layer_all"; field_opt->guisection = _("Selection"); cat_opt = G_define_standard_option(G_OPT_V_CATS); cat_opt->guisection = _("Selection"); where_opt = G_define_standard_option(G_OPT_WHERE); where_opt->guisection = _("Selection"); /* Colors */ color_opt = G_define_option(); color_opt->key = "color"; color_opt->type = TYPE_STRING; color_opt->answer = DEFAULT_FG_COLOR; color_opt->label = _("Feature color"); color_opt->guisection = _("Colors"); color_opt->gisprompt = "old_color,color,color_none"; color_opt->description = _("Either a standard GRASS color, R:G:B triplet, or \"none\""); fcolor_opt = G_define_option(); fcolor_opt->key = "fcolor"; fcolor_opt->type = TYPE_STRING; fcolor_opt->answer = "200:200:200"; fcolor_opt->label = _("Area fill color"); fcolor_opt->guisection = _("Colors"); fcolor_opt->gisprompt = "old_color,color,color_none"; fcolor_opt->description = _("Either a standard GRASS color, R:G:B triplet, or \"none\""); rgbcol_opt = G_define_standard_option(G_OPT_COLUMN); rgbcol_opt->key = "rgb_column"; rgbcol_opt->guisection = _("Colors"); rgbcol_opt->description = _("Name of color definition column (for use with -a flag)"); rgbcol_opt->answer = "GRASSRGB"; zcol_opt = G_define_option(); zcol_opt->key = "zcolor"; zcol_opt->key_desc = "style"; zcol_opt->type = TYPE_STRING; zcol_opt->required = NO; zcol_opt->description = _("Type of color table (for use with -z flag)"); zcol_opt->answer = "terrain"; zcol_opt->guisection = _("Colors"); /* Lines */ width_opt = G_define_option(); width_opt->key = "width"; width_opt->type = TYPE_INTEGER; width_opt->answer = "0"; width_opt->guisection = _("Lines"); width_opt->description = _("Line width"); wcolumn_opt = G_define_standard_option(G_OPT_COLUMN); wcolumn_opt->key = "wcolumn"; wcolumn_opt->guisection = _("Lines"); wcolumn_opt->description = _("Name of column for line widths (these values will be scaled by wscale)"); wscale_opt = G_define_option(); wscale_opt->key = "wscale"; wscale_opt->type = TYPE_DOUBLE; wscale_opt->answer = "1"; wscale_opt->guisection = _("Lines"); wscale_opt->description = _("Scale factor for wcolumn"); /* Symbols */ icon_opt = G_define_option(); icon_opt->key = "icon"; icon_opt->type = TYPE_STRING; icon_opt->required = NO; icon_opt->multiple = NO; icon_opt->guisection = _("Symbols"); icon_opt->answer = "basic/x"; /* This could also use ->gisprompt = "old,symbol,symbol" instead of ->options */ icon_opt->options = icon_files(); icon_opt->description = _("Point and centroid symbol"); size_opt = G_define_option(); size_opt->key = "size"; size_opt->type = TYPE_DOUBLE; size_opt->answer = "5"; size_opt->guisection = _("Symbols"); size_opt->label = _("Symbol size"); size_opt->description = _("When used with the size_column option this becomes the scale factor"); sizecolumn_opt = G_define_standard_option(G_OPT_COLUMN); sizecolumn_opt->key = "size_column"; sizecolumn_opt->guisection = _("Symbols"); sizecolumn_opt->description = _("Name of numeric column containing symbol size"); rotcolumn_opt = G_define_standard_option(G_OPT_COLUMN); rotcolumn_opt->key = "rot_column"; rotcolumn_opt->guisection = _("Symbols"); rotcolumn_opt->label = _("Name of numeric column containing symbol rotation angle"); rotcolumn_opt->description = _("Measured in degrees CCW from east"); /* Labels */ lfield_opt = G_define_standard_option(G_OPT_V_FIELD); lfield_opt->key = "llayer"; lfield_opt->guisection = _("Labels"); lfield_opt->description = _("Layer number for labels (default: the given layer number)"); attrcol_opt = G_define_standard_option(G_OPT_COLUMN); attrcol_opt->key = "attrcol"; attrcol_opt->multiple = NO; /* or fix attr.c, around line 102 */ attrcol_opt->guisection = _("Labels"); attrcol_opt->description = _("Name of column to be displayed"); lcolor_opt = G_define_option(); lcolor_opt->key = "lcolor"; lcolor_opt->type = TYPE_STRING; lcolor_opt->answer = "red"; lcolor_opt->label = _("Label color"); lcolor_opt->guisection = _("Labels"); lcolor_opt->gisprompt = "old_color,color,color"; lcolor_opt->description = _("Either a standard color name or R:G:B triplet"); bgcolor_opt = G_define_option(); bgcolor_opt->key = "bgcolor"; bgcolor_opt->type = TYPE_STRING; bgcolor_opt->answer = "none"; bgcolor_opt->guisection = _("Labels"); bgcolor_opt->label = _("Label background color"); bgcolor_opt->gisprompt = "old_color,color,color_none"; bgcolor_opt->description = _("Either a standard GRASS color, R:G:B triplet, or \"none\""); bcolor_opt = G_define_option(); bcolor_opt->key = "bcolor"; bcolor_opt->type = TYPE_STRING; bcolor_opt->answer = "none"; bcolor_opt->guisection = _("Labels"); bcolor_opt->label = _("Label border color"); bcolor_opt->gisprompt = "old_color,color,color_none"; bcolor_opt->description = _("Either a standard GRASS color, R:G:B triplet, or \"none\""); lsize_opt = G_define_option(); lsize_opt->key = "lsize"; lsize_opt->type = TYPE_INTEGER; lsize_opt->answer = "8"; lsize_opt->guisection = _("Labels"); lsize_opt->description = _("Label size (pixels)"); font_opt = G_define_option(); font_opt->key = "font"; font_opt->type = TYPE_STRING; font_opt->guisection = _("Labels"); font_opt->description = _("Font name"); xref_opt = G_define_option(); xref_opt->key = "xref"; xref_opt->type = TYPE_STRING; xref_opt->guisection = _("Labels"); xref_opt->answer = "left"; xref_opt->options = "left,center,right"; xref_opt->description = _("Label horizontal justification"); yref_opt = G_define_option(); yref_opt->key = "yref"; yref_opt->type = TYPE_STRING; yref_opt->guisection = _("Labels"); yref_opt->answer = "center"; yref_opt->options = "top,center,bottom"; yref_opt->description = _("Label vertical justification"); minreg_opt = G_define_option(); minreg_opt->key = "minreg"; minreg_opt->type = TYPE_DOUBLE; minreg_opt->required = NO; minreg_opt->description = _("Minimum region size (average from height and width) " "when map is displayed"); maxreg_opt = G_define_option(); maxreg_opt->key = "maxreg"; maxreg_opt->type = TYPE_DOUBLE; maxreg_opt->required = NO; maxreg_opt->description = _("Maximum region size (average from height and width) " "when map is displayed"); render_opt = G_define_option(); render_opt->key = "render"; render_opt->type = TYPE_STRING; render_opt->required = NO; render_opt->multiple = NO; render_opt->answer = "c"; render_opt->options = "g,r,d,c,l"; render_opt->description = _("Rendering method for filled polygons"); render_opt->descriptions = _("g;use the libgis render functions (features: clipping);" "r;use the raster graphics library functions (features: polylines);" "d;use the display library basic functions (features: polylines);" "c;use the display library clipping functions (features: clipping);" "l;use the display library culling functions (features: culling, polylines)"); /* please remove before GRASS 7 released */ verbose_flag = G_define_flag(); verbose_flag->key = 'v'; verbose_flag->description = _("Run verbosely"); /* Colors */ table_acolors_flag = G_define_flag(); table_acolors_flag->key = 'a'; table_acolors_flag->guisection = _("Colors"); table_acolors_flag->description = _("Get colors from map table column (of form RRR:GGG:BBB)"); cats_acolors_flag = G_define_flag(); cats_acolors_flag->key = 'c'; cats_acolors_flag->guisection = _("Colors"); cats_acolors_flag->description = _("Random colors according to category number " "(or layer number if 'layer=-1' is given)"); /* Query */ id_flag = G_define_flag(); id_flag->key = 'i'; id_flag->guisection = _("Selection"); id_flag->description = _("Use values from 'cats' option as feature id"); x_flag = G_define_flag(); x_flag->key = 'x'; x_flag->description = _("Don't add to list of vectors and commands in monitor " "(it won't be drawn if the monitor is refreshed)"); zcol_flag = G_define_flag(); zcol_flag->key = 'z'; zcol_flag->description = _("Colorize polygons according to z height"); zcol_flag->guisection = _("Colors"); /* Check command line */ if (G_parser(argc, argv)) exit(EXIT_FAILURE); if (G_strcasecmp(render_opt->answer, "g") == 0) render = RENDER_GPP; else if (G_strcasecmp(render_opt->answer, "r") == 0) render = RENDER_RPA; else if (G_strcasecmp(render_opt->answer, "d") == 0) render = RENDER_DP; else if (G_strcasecmp(render_opt->answer, "c") == 0) render = RENDER_DPC; else if (G_strcasecmp(render_opt->answer, "l") == 0) render = RENDER_DPL; else render = RENDER_GPP; /* please remove -v flag before GRASS 7 released */ if (verbose_flag->answer) { G_putenv("GRASS_VERBOSE", "3"); G_warning(_("The '-v' flag is superseded and will be removed " "in future. Please use '--verbose' instead.")); } /* but keep this */ if (G_verbose() > G_verbose_std()) verbose = TRUE; G_get_set_window(&window); if (R_open_driver() != 0) G_fatal_error(_("No graphics device selected")); /* Read map options */ /* Check min/max region */ reg = ((window.east - window.west) + (window.north - window.south)) / 2; if (minreg_opt->answer) { minreg = atof(minreg_opt->answer); if (reg < minreg) { G_message(_("Region size is lower than minreg, nothing displayed.")); D_add_to_list(G_recreate_command()); exit(EXIT_SUCCESS); } } if (maxreg_opt->answer) { maxreg = atof(maxreg_opt->answer); if (reg > maxreg) { G_message(_("Region size is greater than maxreg, nothing displayed.")); D_add_to_list(G_recreate_command()); exit(EXIT_SUCCESS); } } G_strcpy(map_name, map_opt->answer); default_width = atoi(width_opt->answer); if (default_width < 0) default_width = 0; width_scale = atof(wscale_opt->answer); if (table_acolors_flag->answer && cats_acolors_flag->answer) { cats_acolors_flag->answer = '\0'; G_warning(_("The '-c' and '-a' flags cannot be used together, " "the '-c' flag will be ignored!")); } color = G_standard_color_rgb(WHITE); ret = G_str_to_color(color_opt->answer, &r, &g, &b); if (ret == 1) { has_color = 1; color.r = r; color.g = g; color.b = b; } else if (ret == 2) { /* none */ has_color = 0; } else if (ret == 0) { /* error */ G_fatal_error(_("Unknown color: [%s]"), color_opt->answer); } fcolor = G_standard_color_rgb(WHITE); ret = G_str_to_color(fcolor_opt->answer, &r, &g, &b); if (ret == 1) { has_fcolor = 1; fcolor.r = r; fcolor.g = g; fcolor.b = b; } else if (ret == 2) { /* none */ has_fcolor = 0; } else if (ret == 0) { /* error */ G_fatal_error(_("Unknown color: '%s'"), fcolor_opt->answer); } size = atof(size_opt->answer); /* Make sure map is available */ mapset = G_find_vector2(map_name, ""); if (mapset == NULL) G_fatal_error(_("Vector map <%s> not found"), map_name); /* if where_opt was specified select categories from db * otherwise parse cat_opt */ Clist = Vect_new_cat_list(); Clist->field = atoi(field_opt->answer); /* open vector */ level = Vect_open_old(&Map, map_name, mapset); if (where_opt->answer) { if (Clist->field < 1) G_fatal_error(_("'layer' must be > 0 for 'where'.")); chcat = 1; if ((fi = Vect_get_field(&Map, Clist->field)) == NULL) G_fatal_error(_("Database connection not defined")); if (fi != NULL) { driver = db_start_driver(fi->driver); if (driver == NULL) G_fatal_error(_("Unable to start driver <%s>"), fi->driver); db_init_handle(&handle); db_set_handle(&handle, fi->database, NULL); if (db_open_database(driver, &handle) != DB_OK) G_fatal_error(_("Unable to open database <%s>"), fi->database); ncat = db_select_int(driver, fi->table, fi->key, where_opt->answer, &cats); db_close_database(driver); db_shutdown_driver(driver); Vect_array_to_cat_list(cats, ncat, Clist); } } else if (cat_opt->answer) { if (Clist->field < 1) G_fatal_error(_("'layer' must be > 0 for 'cats'.")); chcat = 1; ret = Vect_str_to_cat_list(cat_opt->answer, Clist); if (ret > 0) G_warning(_("%d errors in cat option"), ret); } type = Vect_option_to_types(type_opt); i = 0; display = 0; while (display_opt->answers[i]) { switch (display_opt->answers[i][0]) { case 's': display |= DISP_SHAPE; break; case 'c': display |= DISP_CAT; break; case 't': display |= DISP_TOPO; break; case 'd': display |= DISP_DIR; break; case 'a': display |= DISP_ATTR; break; case 'z': display |= DISP_ZCOOR; break; } i++; } /* Read label options */ if (lfield_opt->answer != NULL) lattr.field = atoi(lfield_opt->answer); else lattr.field = Clist->field; lattr.color.R = lattr.color.G = lattr.color.B = 255; if (G_str_to_color(lcolor_opt->answer, &r, &g, &b)) { lattr.color.R = r; lattr.color.G = g; lattr.color.B = b; } lattr.has_bgcolor = 0; if (G_str_to_color(bgcolor_opt->answer, &r, &g, &b) == 1) { lattr.has_bgcolor = 1; lattr.bgcolor.R = r; lattr.bgcolor.G = g; lattr.bgcolor.B = b; } lattr.has_bcolor = 0; if (G_str_to_color(bcolor_opt->answer, &r, &g, &b) == 1) { lattr.has_bcolor = 1; lattr.bcolor.R = r; lattr.bcolor.G = g; lattr.bcolor.B = b; } lattr.size = atoi(lsize_opt->answer); lattr.font = font_opt->answer; switch (xref_opt->answer[0]) { case 'l': lattr.xref = LLEFT; break; case 'c': lattr.xref = LCENTER; break; case 'r': lattr.xref = LRIGHT; break; } switch (yref_opt->answer[0]) { case 't': lattr.yref = LTOP; break; case 'c': lattr.yref = LCENTER; break; case 'b': lattr.yref = LBOTTOM; break; } D_setup(0); G_setup_plot(D_get_d_north(), D_get_d_south(), D_get_d_west(), D_get_d_east(), D_move_abs, D_cont_abs); if (verbose) G_message(_("Plotting ...")); if (level >= 2) Vect_get_map_box(&Map, &box); if (level >= 2 && (window.north < box.S || window.south > box.N || window.east < box.W || window.west > G_adjust_easting(box.E, &window))) { G_message(_("The bounding box of the map is outside the current region, " "nothing drawn.")); stat = 0; } else { overlap = G_window_percentage_overlap(&window, box.N, box.S, box.E, box.W); G_debug(1, "overlap = %f \n", overlap); if (overlap < 1) Vect_set_constraint_region(&Map, window.north, window.south, window.east, window.west, PORT_DOUBLE_MAX, -PORT_DOUBLE_MAX); /* default line width */ if (!wcolumn_opt->answer) D_line_width(default_width); if (type & GV_AREA) { if (level >= 2) { if (display & DISP_SHAPE) { stat = darea(&Map, Clist, has_color ? &color : NULL, has_fcolor ? &fcolor : NULL, chcat, (int)id_flag->answer, table_acolors_flag->answer, cats_acolors_flag->answer, &window, rgbcol_opt->answer, default_width, wcolumn_opt->answer, width_scale, zcol_flag->answer, zcol_opt->answer); } if (wcolumn_opt->answer) D_line_width(default_width); } else G_warning(_("Unable to display areas, topology not available")); } if (display & DISP_SHAPE) { if (id_flag->answer && level < 2) { G_warning(_("Unable to display lines by id, topology not available")); } else { stat = plot1(&Map, type, Clist, has_color ? &color : NULL, has_fcolor ? &fcolor : NULL, chcat, icon_opt->answer, size, sizecolumn_opt->answer, rotcolumn_opt->answer, (int)id_flag->answer, table_acolors_flag->answer, cats_acolors_flag->answer, rgbcol_opt->answer, default_width, wcolumn_opt->answer, width_scale, zcol_flag->answer, zcol_opt->answer); if (wcolumn_opt->answer) D_line_width(default_width); } } if (has_color) { R_RGB_color(color.r, color.g, color.b); if (display & DISP_DIR) stat = dir(&Map, type, Clist, chcat, size); } /* reset line width: Do we need to get line width from display * driver (not implemented)? It will help restore previous line * width (not just 0) determined by another module (e.g., * d.linewidth). */ if (!wcolumn_opt->answer) R_line_width(0); if (display & DISP_CAT) stat = label(&Map, type, Clist, &lattr, chcat); if (display & DISP_ATTR) stat = attr(&Map, type, attrcol_opt->answer, Clist, &lattr, chcat); if (display & DISP_ZCOOR) stat = zcoor(&Map, type, &lattr); if (display & DISP_TOPO) { if (level >= 2) stat = topo(&Map, type, &lattr); else G_warning(_("Unable to display topology, not available")); } } if (!x_flag->answer) { D_add_to_list(G_recreate_command()); D_set_dig_name(G_fully_qualified_name(map_name, mapset)); D_add_to_dig_list(G_fully_qualified_name(map_name, mapset)); } R_close_driver(); if (verbose) G_done_msg(" "); Vect_close(&Map); Vect_destroy_cat_list(Clist); exit(stat); }