void DBVPolyIF::FourColoring () { char nameStr [DBStringLength]; DBInt symbol, maxSymbol = 0, line, index; DBObjRecord *polyRec,*searchPoly, *neighborPolyRec, *lineRec, *symRec; for (polyRec = FirstItem ();polyRec != (DBObjRecord *) NULL;polyRec = NextItem ()) SymbolFLD->Record (polyRec,(DBObjRecord *) NULL); ListSort (LineNumFLD); for (searchPoly = FirstItem ();searchPoly != (DBObjRecord *) NULL;searchPoly = NextItem ()) { if (((DBInt) (SymbolFLD->Record (searchPoly) - (DBObjRecord *) NULL)) != 0) continue; DBPause (searchPoly->RowID () * 100 / ItemNum ()); symbol = 1; Restart: for (polyRec = ItemTable->First (&index);polyRec != (DBObjRecord *) NULL;polyRec = ItemTable->Next (&index)) { if (strcmp (polyRec->Name (),searchPoly->Name ()) != 0) continue; lineRec = FirstLine (polyRec); for (line = 0;line <= LineNum (polyRec);++line) { if (LineRightPoly (lineRec) == polyRec) { neighborPolyRec = LineLeftPoly (lineRec); lineRec = LineNextLine (lineRec); } else { neighborPolyRec = LineRightPoly (lineRec); lineRec = LinePrevLine (lineRec); } if (neighborPolyRec == (DBObjRecord *) NULL) continue; if (SymbolFLD->Record (neighborPolyRec) == (DBObjRecord *) symbol) { symbol++; goto Restart; } } } for (polyRec = ItemTable->First (&index);polyRec != (DBObjRecord *) NULL;polyRec = ItemTable->Next (&index)) if (strcmp (polyRec->Name (),searchPoly->Name ()) == 0) SymbolFLD->Record (polyRec,(DBObjRecord *) symbol); maxSymbol = maxSymbol > symbol ? maxSymbol : symbol; } while (maxSymbol < SymbolTable->ItemNum ()) SymbolTable->Remove (SymbolTable->ItemNum () - 1); while (maxSymbol > SymbolTable->ItemNum ()) SymbolTable->Add (); for (symbol = 0;symbol < SymbolTable->ItemNum ();++symbol) { symRec = SymbolTable->Item (symbol); sprintf (nameStr,"Symbol:%2d",symbol); symRec->Name (nameStr); StyleFLD->Int (symRec,0); ForegroundFLD->Int (symRec,1); BackgroundFLD->Int (symRec,0); } for (polyRec = FirstItem ();polyRec != (DBObjRecord *) NULL;polyRec = NextItem ()) SymbolFLD->Record (polyRec,SymbolTable->Item ((DBInt) (SymbolFLD->Record (polyRec) - (DBObjRecord *) NULL) - 1)); ListReset (); }
DBObjRecord *DBVectorIF::Item (DBCoordinate coord) const { DBObjRecord *record, *retRecord = (DBObjRecord *) NULL; switch (DataPTR->Type ()) { case DBTypeVectorPoint: { DBFloat dist, minDist = DBHugeVal; DBObjTableField *coordFLD = ItemTable->Field (DBrNCoord); DBMathDistanceFunction distFunc = DBMathGetDistanceFunction (DataPTR); for (record = FirstItem ();record != (DBObjRecord *) NULL;record = NextItem ()) { dist = DBMathCoordinateDistance (distFunc,coord,coordFLD->Coordinate (record)); if (dist < minDist) { minDist = dist; retRecord = record; } } } break; case DBTypeVectorLine: break; case DBTypeVectorPolygon: break; default: CMmsgPrint (CMmsgAppError, "Unknown Vector Data Type in: %s %d",__FILE__,__LINE__); break; } return (retRecord); }
void BListView::_FixupScrollBar() { BScrollBar* vertScroller = ScrollBar(B_VERTICAL); if (!vertScroller) return; BRect bounds = Bounds(); int32 count = CountItems(); float itemHeight = 0.0; if (CountItems() > 0) itemHeight = ItemAt(CountItems() - 1)->Bottom(); if (bounds.Height() > itemHeight) { // no scrolling vertScroller->SetRange(0.0, 0.0); vertScroller->SetValue(0.0); // also scrolls ListView to the top } else { vertScroller->SetRange(0.0, itemHeight - bounds.Height() - 1.0); vertScroller->SetProportion(bounds.Height () / itemHeight); // scroll up if there is empty room on bottom if (itemHeight < bounds.bottom) ScrollBy(0.0, bounds.bottom - itemHeight); } if (count != 0) vertScroller->SetSteps(ceilf(FirstItem()->Height()), bounds.Height()); }
int32 MyListView::GetMaxPages (BRect printArea) { // assume pages always fit horizontally int32 maxItems = CountItems(); BListItem *item = FirstItem(); if (item == NULL) return 0; return (int32)ceil(maxItems*item->Height()/printArea.Height()); }
DBVPolyIF::DBVPolyIF(DBObjData *data) : DBVLineIF(data, data->Table(DBrNContours)) { DBObjTable *items = data->Table(DBrNItems); LineTable = data->Table(DBrNContours); DBObjRecord *polyRec; FirstLineFLD = items->Field(DBrNFirstLine); LineNumFLD = items->Field(DBrNLineNum); ExtentFLD = items->Field(DBrNRegion); LeftPolyFLD = LineTable->Field(DBrNLeftPoly); RightPolyFLD = LineTable->Field(DBrNRightPoly); NextLineFLD = LineTable->Field(DBrNNextLine); PrevLineFLD = LineTable->Field(DBrNPrevLine); VertexNumFLD = items->Field(DBrNVertexNum); AreaFLD = items->Field(DBrNArea); MaxVertexNumVAR = 0; for (polyRec = FirstItem(); polyRec != (DBObjRecord *) NULL; polyRec = NextItem()) MaxVertexNumVAR = MaxVertexNumVAR > VertexNum(polyRec) ? MaxVertexNumVAR : VertexNum(polyRec); if ((CoordsPTR = (DBCoordinate *) malloc(MaxVertexNumVAR * sizeof(DBCoordinate))) == (DBCoordinate *) NULL) { CMmsgPrint(CMmsgSysError, "Memory Allocation Error in: %s %d", __FILE__, __LINE__); } }
void MakeRing(long ptr) { long first, last; /* Check pointer */ CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); /* Close list */ CloseList(ptr); /* Get pointer to first and last */ first = FirstItem(ptr); last = LastItem(ptr); /* Combine pointers */ WDB[first + LIST_PTR_PREV] = (double)last; WDB[last + LIST_PTR_NEXT] = (double)first; }
CObject* Search::FindFirstObjectOfType( Lst::Head< CObject >& head, sint type ) { Dbg_AssertType( &head, Lst::Head< CObject > ); CObject* obj = FirstItem( head ); obj_type = type; while ( obj ) { Dbg_AssertType( obj, CObject ); if ( obj->GetType() == obj_type ) { return obj; } obj = NextItem(); } return obj; }
void GetBankedPrecursors() { long ptr, next, id, loc0; /***************************************************************************/ if ((long)RDB[DATA_PRECURSOR_TRANSPORT_MODE] == PREC_MODE_NONE) return; /* Get pointer to precursor detector */ if ((loc0 = (long)RDB[DATA_PTR_PREC_DET]) < VALID_PTR) return; #ifdef DNPRINT fprintf(out, "getbankedprecursors.c -->\n"); #endif /***** Move banked precursors to source ************************************/ /* Loop over threads */ for (id = 0; id < (long)RDB[DATA_OMP_MAX_THREADS]; id++) { /* Get pointer */ ptr = (long)RDB[OMPPtr(DATA_PART_PTR_BANK, id)]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); /* Get pointer to first item */ ptr = FirstItem(ptr); CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); /* Check type */ if ((long)RDB[ptr + PARTICLE_TYPE] != PARTICLE_TYPE_DUMMY) Die(FUNCTION_NAME, "Error in list"); /* Get pointer to first item after dummy*/ next = NextItem(ptr); /* Loop over bank */ while (next > VALID_PTR) { ptr = next; next = NextItem(ptr); if ((long)RDB[ptr + PARTICLE_TYPE] == PARTICLE_TYPE_PRECURSOR) { /* Remove precursor from bank */ RemoveItem(ptr); /* Put precursor to precursor source (will be sorted later) */ AddItem(DATA_PART_PTR_PSOURCE, ptr); } } } #ifdef DNPRINT fprintf(out, "<-- getbankedprecursors.c\n\n"); #endif /***************************************************************************/ }
/* Must mutate original if changes required for consistency */ GLOBAL void FunctionConflict(Node *orig, Node *create) { Node *ofdcl, *nfdcl; assert(orig); assert(create); assert(orig->typ == Decl); assert(create->typ == Decl); ofdcl = NodeDataType(orig); nfdcl = NodeDataType(create); if (ofdcl->typ != Fdcl || nfdcl->typ != Fdcl) goto Mismatch; /* * Check if one declaration is T_PROCEDURE and the other is not. * BUG: I think the whole way we treat 'cilk' and 'inlet' keywords * is broken. We treat 'cilk' like 'const', but * * const int foo() * * is not the same as * * cilk int foo() * * The former returns a 'const int', but the latter does not return a * 'cilk int' ! - athena * * BTW, the following line is a hack :-) * ((ofdcl->u.fdcl.tq ^ nfdcl->u.fdcl.tq) & (T_PROCEDURE | T_INLET)) * Bradley rewrote it has follows: */ if ((tq_has_procedure(ofdcl->u.fdcl.tq) != tq_has_procedure(nfdcl->u.fdcl.tq)) || (tq_has_inlet(ofdcl->u.fdcl.tq) != tq_has_inlet(nfdcl->u.fdcl.tq))) goto Mismatch; /* The Result Type must be equal */ if (!TypeEqual(ofdcl->u.fdcl.returns, nfdcl->u.fdcl.returns)) goto Mismatch; /* Inspect the parameter lists */ { List *optr = ofdcl->u.fdcl.args, *nptr = nfdcl->u.fdcl.args; /* Are both definitions in prototype form? */ if (optr && nptr) { /* Then every parameter must be compatible */ for (; optr && nptr; optr = Rest(optr), nptr = Rest(nptr)) { Node *oitem = FirstItem(optr), *otype = NodeDataType(oitem), *nitem = FirstItem(nptr), *ntype = NodeDataType(nitem); if (!TypeEqualFormals(otype, ntype)) { SetItem(optr, nitem); goto Mismatch; } } /* And the parameter lists must be of the same length */ if (optr || nptr) goto Mismatch; } /* Check for <Type> f(void) vs <Type> f() */ else if (IsVoidArglist(optr)); /* Check for <Type> f() vs <Type> f(void) */ else if (IsVoidArglist(nptr)) ofdcl->u.fdcl.args = MakeNewList(PrimVoid); /* Else the provided types must be the "usual unary conversions" */ else { /* Either this loop will run */ for (; optr; optr = Rest(optr)) { Node *oitem = FirstItem(optr), *otype = NodeDataType(oitem); if (!TypeEqual(otype, UsualUnaryConversionType(otype)) || IsEllipsis(otype)) goto Mismatch; } /* Or this one will */ for (; nptr; nptr = Rest(nptr)) { Node *nitem = FirstItem(nptr), *ntype = NodeDataType(nitem); if (!TypeEqual(ntype, UsualUnaryConversionType(ntype)) || IsEllipsis(ntype)) goto Mismatch; } } } return; Mismatch: SyntaxErrorCoord(create->coord, "identifier `%s' redeclared", VAR_NAME(orig)); fprintf(stderr, "\tPrevious declaration: "); PRINT_COORD(stderr, orig->coord); fputc('\n', stderr); return; }
/* DEAD CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ GLOBAL Bool IsCompatibleFdcls(Node *node1, Node *node2) { assert(node1->typ == Fdcl); assert(node2->typ == Fdcl); #if 0 printf("IsCompatibleFdcls\n"); PrintNode(stdout, node1, 0); printf("\n"); PrintNode(stdout, node2, 0); printf("\n"); #endif /* The Result Type must be equal */ if (!TypeEqual(node1->u.fdcl.returns, node2->u.fdcl.returns)) return FALSE; /* Inspect the parameter lists */ { List *optr = node1->u.fdcl.args, *nptr = node2->u.fdcl.args; /* Are both definitions in prototype form? */ if (optr && nptr) { /* Then every parameter must be compatible */ for (; optr && nptr; optr = Rest(optr), nptr = Rest(nptr)) { Node *oitem = FirstItem(optr), *otype = NodeDataType(oitem), *nitem = FirstItem(nptr), *ntype = NodeDataType(nitem); if (!TypeEqual(otype, ntype)) { #if 0 PrintNode(stdout, otype, 0); printf("\n"); PrintNode(stdout, ntype, 0); printf("\n"); #endif return FALSE; } } /* And the parameter lists must be of the same length */ if (optr || nptr) return FALSE; else return TRUE; } /* Check for <Type> f(void) vs <Type> f() */ else if (IsVoidArglist(optr)) return TRUE; /* Check for <Type> f() vs <Type> f(void) */ else if (IsVoidArglist(nptr)) return TRUE; /* Else the provided types must be the "usual unary conversions" */ else { /* Either this loop will run */ for (; optr; optr = Rest(optr)) { Node *oitem = FirstItem(optr), *otype = NodeDataType(oitem); if (!TypeEqual(otype, UsualUnaryConversionType(otype)) || IsEllipsis(otype)) return FALSE; } /* Or this one will */ for (; nptr; nptr = Rest(nptr)) { Node *nitem = FirstItem(nptr), *ntype = NodeDataType(nitem); if (!TypeEqual(ntype, UsualUnaryConversionType(ntype)) || IsEllipsis(ntype)) return FALSE; } return TRUE; } } }