void pawsBorder::UseBorder( const char* name ) { csString stylestr( name ); // If the type is line then this is a simple border drawn using lines. if (name && stylestr != "line") { BorderDefinition* def = PawsManager::GetSingleton().GetPrefs()->GetBorderDefinition( name ); if ( def ) { // For each border area create the image for it based on the // border definition. for ( int x = 0; x < PAWS_BORDER_MAX; x++ ) { borderImages[x] = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(def->descriptions[x]); if (!borderImages[x]) { Warning2(LOG_PAWS, "Could not retrieve border drawable: >%s<", def->descriptions[x].GetData()); return; } if (borderImages[x]->GetWidth() == 0 || borderImages[x]->GetHeight() == 0) { Warning2(LOG_PAWS, "Invalid dimensions on border drawable: >%s<", def->descriptions[x].GetData()); return; } } usingGraphics = true; } else { Warning2(LOG_PAWS, "Could not retrieve border definiton: >%s<", name); } } style = BORDER_BUMP; }
csPtr<iPawsImage> pawsTextureManager::GetOrAddPawsImage(const char * name) { csRef<iPawsImage> image = elementList.Get(name, 0); if(!image.IsValid()) //if the image wasn't found { //try adding and reloading. This works only with full paths so you should still use //imagelist.xml for faster performance. if(AddImage(name)) //if this is a success we can now load it. { image = csPtr<iPawsImage>(elementList.Get(name, 0)); Warning2(LOG_PAWS, "ART ERROR: PawsTextureManager loaded the image %s which was missing from the imagelist.xml and was loaded on demand. Add the image there!", name); } else //if it wasn't a success warn the user. Warning2(LOG_PAWS, "ART ERROR: PawsTextureManager wasn't able to load the requested image: %s", name); } return csPtr<iPawsImage>(image); //we return regardless the caller must be able to handle null, which is failure. }
void CheckArea( void ) { Elem_type *pe; ResetHashTable(HEL); while( (pe=VisitHashTableE(HEL)) != NULL ) { if( AreaElement(HNN,pe) <= 0. ) { Warning2("CheckArea: area is negative in element " ,itos(pe->number)); } } }
int CheckInput( void ) /*\ * here we should also check for : * - counter-clockwise line turning * - no nodes out of external line * - internal lines are really internal of external line * - lines closed * ... \*/ { int i; int ntot=0; int next=0; int nint=0; int nbound=0; int turn; int ndim; int error; Node_type *pn; Elem_type *pe; Line_type *pl; StackTable backg; float *xe, *ye; float area; float areamax = 0.; Line_type *plmax = NULL; /* biggest line */ Line_type *plext = NULL; /* external line */ /* set all nodes to NONE */ ResetHashTable(HNN); while( (pn=VisitHashTableN(HNN)) != NULL ) { SetNtype(pn, N_NONE ); } /* look for lines */ ResetHashTable(HLI); while( (pl=VisitHashTableL(HLI)) != NULL ) { area = ABS( AreaLine(HNN,pl) ); if( area > areamax ) { areamax = area; plmax = pl; } if( pl->type == L_EXTERNAL ) { /* HACK *//* FIXME */ plext = pl; SetLtype(pl, L_EXTERNAL ); } else if( pl->type == L_INTERNAL ) { SetLtype(pl, L_INTERNAL ); } else if( pl->type == L_FAULT ) { SetLtype(pl, L_FAULT ); } else if( pl->type == L_NONE ) { if( IsLineClosed(pl) ) { SetLtype(pl, L_INTERNAL ); } else { SetLtype(pl, L_FAULT ); } } else { Error2("Unknown line type in line ",itos(pl->number)); } ntot++; if( IsLtype(pl, L_EXTERNAL ) ) next++; if( IsLtype(pl, L_INTERNAL ) ) nint++; } /* look for boundary lines */ if( next > 1 ) { Error("More than one line marked external"); } else if( ntot == 0 ) { Warning("No line found: using hull as boundary"); ResetHashTable(HNN); while( (pn=VisitHashTableN(HNN)) != NULL ) { SetNtype(pn, N_BOUNDARY ); } } else if( next == 0 ) { Warning("No external line found... using biggest one"); Warning2(" external line is ",itos(plmax->number)); plext = plmax; SetLtype(plmax, L_EXTERNAL ); next++; } /* check if external line is closed and all other lines are inside */ if( plext != NULL ) { if( ! IsLineClosed(plext) ) { Error2("External line is not closed: ",itos(plext->number)); } ResetHashTable(HLI); while( (pl=VisitHashTableL(HLI)) != NULL ) { if( pl == plext ) continue; if( ! IsLineInLine(plext,pl) ) { Error2("Line not inside external line: ",itos(pl->number)); } } } /* check lines and set node type */ error = 0; ResetHashTable(HLI); while( (pl=VisitHashTableL(HLI)) != NULL ) { if( IsLtype(pl, L_EXTERNAL ) || IsLtype(pl, L_INTERNAL ) ) { /* check for closed line */ /* FIXME */ /* -> close line */ if( ! IsLineClosed(pl) ) { Error2("Line is not closed: ",itos(pl->number)); } ndim = pl->vertex; MakeCoordsFromLine(pl,&xe,&ye); /* check for not unique coordinates */ for(i=1;i<ndim;i++) { if( pl->index[i-1] == pl->index[i] ) { printf("*** Line %d: identical node %d\n" ,pl->number,pl->index[i]); error++; } else if( xe[i-1] == xe[i] && ye[i-1] == ye[i] ) { printf("*** Line %d: Identical coordinates - ",pl->number); printf("nodes %d and %d\n",pl->index[i-1],pl->index[i]); error++; } } /* check for counter-clockwise turning */ turn = TurnClosedLine(pl->vertex,xe,ye); if( turn == 1 ) { /* ok */; } else if( turn == -1 ) { printf("Line %d in clockwise sense -> inverting\n" ,pl->number); InvertIndex(pl->index,pl->vertex); } else { printf("*** Line %d: turning number %d\n", pl->number,turn); printf(" (the line might turn on itself)\n"); error++; } free(xe); free(ye); /* set node type for nodes on boundary */ for(i=0;i<pl->vertex;i++) { pn = RetrieveByNodeNumber(HNN,pl->index[i]); SetNtype(pn, N_BOUNDARY ); } } } if( error ) { Error("Errors found in lines"); } /* look for background grid */ if( OpBackGround >= 0 ) { backg = MakeStackTable(); BCK = MakeListTable(); ResetHashTable(HEL); while( (pe=VisitHashTableE(HEL)) != NULL ) { if( pe->type == OpBackGround ) { Push(backg,(void *)pe); } else { SetEtype(pe, E_EXTERNAL ); /* tentativly... */ } } while( (pe=(Elem_type *)Pop(backg)) != NULL ) { DeleteHashByNumber(HEL,pe->number); InsertListTable(BCK,(void *)pe); for(i=0;i<3;i++) { pn = RetrieveByNodeNumber(HNN,pe->index[i]); SetNtype(pn, N_EXTERNAL ); if( pn->depth == NULLDEPTH ) { Error2("Null resolution in background grid at node : ", itos(pn->number)); } } } FreeStackTable(backg); } /* count all nodes of boundary type */ ResetHashTable(HNN); while( (pn=VisitHashTableN(HNN)) != NULL ) { if( IsNtype(pn, N_BOUNDARY ) ) nbound++; } return nbound; }