void ofxCvBlobTracker::doBlobOff( const ofxCvTrackedBlob& b ) { if( listener != NULL ) { listener->blobOff( b.centroid.x, b.centroid.y, b.id, findOrder(b.id) ); } else { cout << "doBlobOff() event for blob: " << b.id << endl; } }
void ofxCvBlobTracker::draw( float x, float y, float sw, float sh ) { ofEnableAlphaBlending(); ofSetColor( 255,0,200,100 ); glPushMatrix(); glTranslatef( x, y, 0.0 ); glScalef( sw, sh, 1); ofFill(); for( int i=0; i<blobs.size(); i++ ) { ofRect( blobs[i].boundingRect.x, blobs[i].boundingRect.y, blobs[i].boundingRect.width, blobs[i].boundingRect.height ); } ofDisableAlphaBlending(); ofSetColor(0xffffff); for( int i=0; i<blobs.size(); i++ ) { glBegin(GL_LINE_LOOP); for( int j=0; j<blobs[i].pts.size(); j++ ) { glVertex2f( blobs[i].pts[j].x, blobs[i].pts[j].y ); } glEnd(); } ofSetColor( 0xffffff ); for( int i=0; i<blobs.size(); i++ ) { ostringstream docstring; //docstring << blobs[i].id << endl; docstring << findOrder(blobs[i].id) << endl; ofDrawBitmapString( docstring.str(), blobs[i].centroid.x, blobs[i].centroid.y ); } glPopMatrix(); }
void ofCvBlobTracker::draw( float x, float y ) { ofEnableAlphaBlending(); ofSetColor( 0,255,190,100 ); glPushMatrix(); glTranslatef( x, y, 0.0 ); ofFill(); for( int i=0; i<blobs.size(); i++ ) { ofRect( blobs[i].box.x, blobs[i].box.y, blobs[i].box.width, blobs[i].box.height ); } ofDisableAlphaBlending(); ofSetColor(0xffffff); for( int i=0; i<blobs.size(); i++ ) { glBegin(GL_LINE_LOOP); for( int j=0; j<blobs[i].contour.size(); j++ ) { glVertex2f( blobs[i].contour[j].x, blobs[i].contour[j].y ); } glEnd(); } ofSetColor( 0xffffff ); for( int i=0; i<blobs.size(); i++ ) { ostringstream docstring; //docstring << blobs[i].id << endl; docstring << findOrder(blobs[i].id) << endl; ofDrawBitmapString( docstring.str(), blobs[i].center.x, blobs[i].center.y ); } glPopMatrix(); }
void ofCvBlobTracker::draw( float x, float y ) { ofEnableAlphaBlending(); ofSetColor( 255,0, 0,100 ); glPushMatrix(); glTranslatef( x, y, 0.0 ); ofFill(); /* for( int i=0; i<blobs.size(); i++ ) { ofRect( blobs[i].boundingRect.x, blobs[i].boundingRect.y, blobs[i].boundingRect.width, blobs[i].boundingRect.height ); } */ ofDisableAlphaBlending(); ofSetColor(255, 255, 0); for( int i=0; i<blobs.size(); i++ ) { ofBeginShape(); for( int j=0; j<blobs[i].pts.size(); j++ ) { ofVertex( blobs[i].pts[j].x, blobs[i].pts[j].y ); } ofEndShape(); } ofSetColor( 0x000000 ); for( int i=0; i<blobs.size(); i++ ) { ostringstream docstring; //docstring << blobs[i].id << endl; docstring << findOrder(blobs[i].id) << endl; ofDrawBitmapStringHighlight( ofToString(blobs[i].id), blobs[i].centroid.x, blobs[i].centroid.y, ofColor::darkCyan, ofColor::white); } glPopMatrix(); }
bool ObjectCache::findOrder(Id order_id, Order& order) { Order* object = findOrder(order_id); if (object == NULL) return false; order = *object; return true; }
int TheGrigorchukGroupAlgorithms::findOrder( const Word& w ) { if( w.length( )<=1 ) return w.length( )+1; Word r = reduce( w ); triple< int , int , int > A = abelianImage( w ); if( A.first==1 ) r = reduce( r*r ); pair< Word , Word > S = split( r ); int O1 = findOrder( S.first ); int O2 = findOrder( S.second ); int O = O1>O2 ? O1 : O2; O = A.first==1 ? 2*O : O; return O; }
void ofxCvBlobTracker::drawWData( float x, float y, float sw, float sh ) { ofEnableAlphaBlending(); glPushMatrix(); glTranslatef( x, y, 0.0 ); glScalef( sw, sh, 1); ofFill(); for( int i=0; i<blobs.size(); i++ ) { // draw with lifespan as alpha float lifeAlpha = MIN(.5*blobs[i].lifeSpan,255); ofxVec2f delta = ofxVec2f(blobs[i].deltaLoc.x,blobs[i].deltaLoc.y); float lenD = delta.lengthSquared(); ofSetColor( 255,0 ,200,lifeAlpha ); ofRect( blobs[i].boundingRect.x, blobs[i].boundingRect.y, blobs[i].boundingRect.width, blobs[i].boundingRect.height ); } ofDisableAlphaBlending(); // contours ofSetColor(0xffffff); for( int i=0; i<blobs.size(); i++ ) { glBegin(GL_LINE_LOOP); for( int j=0; j<blobs[i].pts.size(); j++ ) { glVertex2f( blobs[i].pts[j].x, blobs[i].pts[j].y ); } glEnd(); } // labels ofSetColor( 0xffffff ); for( int i=0; i<blobs.size(); i++ ) { ostringstream docstring; //docstring << blobs[i].id << endl; docstring << findOrder(blobs[i].id) << endl; ofDrawBitmapString( docstring.str(), blobs[i].centroid.x, blobs[i].centroid.y ); } // directions for( int i=0; i<blobs.size(); i++ ) { ofLine(blobs[i].centroid.x,blobs[i].centroid.y,blobs[i].predictedPos.x,blobs[i].predictedPos.y); } glPopMatrix(); }
int main(void) { int numCourses = 10; int outSize = 0; int **p = NULL; int *seq = findOrder(numCourses, p, 0, 0, &outSize); for(int i = 0; i < outSize; i++) { printf("%d", seq[i]); if(i < outSize-1) printf(" "); else printf("\n"); } if(seq != NULL) free(seq); return 0; }
int main(void) { int N; scanf("%d", &N); while (N > 0) { int M, K; long int minPages = 0; long int maxPages = 0; long int *pages; long int *workerPages; int i; long int solution = 0; scanf("%d %d", &M, &K); pages = (long int*) malloc(sizeof(long int) * M); for (i = 0; i < M; i++) { scanf("%ld", &pages[i]); if (pages[i] > minPages) { minPages = pages[i]; } maxPages += pages[i]; } solution = findMaxPages(pages, M, K, minPages, maxPages); workerPages = (long int*) malloc(sizeof(long int) * K); // printf("Here\n"); findOrder(&workerPages, K, pages, M, solution); // printf("There\n"); printSolution(pages, M, workerPages, K); // printf("Now\n"); free(workerPages); free(pages); N--; } return 0; }
int main() { int** prerequsites=(int**)malloc(4*sizeof(int*)); for(int i=0;i<4;++i) prerequsites[i]=(int*)malloc(2*sizeof(int)); prerequsites[0][0]=1; prerequsites[0][1]=0; prerequsites[1][0]=2; prerequsites[1][1]=0; prerequsites[2][0]=3; prerequsites[2][1]=1; prerequsites[3][0]=3; prerequsites[3][1]=2; int returnSize; int* result=findOrder(4,prerequsites,4,2,&returnSize); return 0; }
int main() { srand(time(NULL)); int n = 0; vector<pair<int,int> > req; // req.push_back(pair<int,int>(1,0)); // req.push_back(pair<int,int>(0,2)); // req.push_back(pair<int,int>(0,2)); // req.push_back(pair<int,int>(2,0)); // req.push_back(pair<int,int>(3,1)); // req.push_back(pair<int,int>(3,2)); // req.push_back(pair<int,int>(2,3)); vector<int> ans = findOrder(n, req); printVector(ans); return 0; }
void StrikeBalanceWidget::createActions() { // Add tool tar actions for order list. m_addAct = new QAction(QIcon(":/add"), tr("Add"), this); m_deleteAct = new QAction(QIcon(":/delete"), tr("Delete"), this); m_saveAct = new QAction(QIcon(":/ok"), tr("Save"), this); m_cancelAct = new QAction(QIcon(":/cancel"), tr("Cancel"), this); m_findAct = new QAction(QIcon(":/find"), tr("Find"), this); m_findClientAct = new QAction(QIcon(":/find"), tr("Find Client"), this); m_deleteAct->setDisabled(true); m_saveAct->setDisabled(true); m_cancelAct->setDisabled(true); connect(m_addAct, SIGNAL(triggered()), this, SLOT(addOrder())); connect(m_deleteAct, SIGNAL(triggered()), this, SLOT(deleteOrder())); connect(m_saveAct, SIGNAL(triggered()), this, SLOT(saveOrder())); connect(m_cancelAct, SIGNAL(triggered()), this, SLOT(cancelModifiedOrder())); connect(m_findAct, SIGNAL(triggered()), this, SLOT(findOrder())); connect(m_findClientAct, SIGNAL(triggered()), this, SLOT(findClient())); }
DataObject* ObjectCache::find(Id object_id, bool cacheOnly) { if (object_id == INVALID_ID) return NULL; if (_objects.find(object_id) != _objects.end()) return _objects[object_id]; if (cacheOnly) return NULL; DataObject object; if (!_db->lookup(object_id, object)) return NULL; switch (object.dataType()) { case DataObject::ACCOUNT: return findAccount(object_id); case DataObject::ADJUST_REASON: return findAdjustReason(object_id); case DataObject::CARD_ADJUST: return findCardAdjust(object_id); case DataObject::CHARGE: return findCharge(object_id); case DataObject::CHEQUE: return findCheque(object_id); case DataObject::CLAIM: return findReceive(object_id); case DataObject::COMPANY: return findCompany(object_id); case DataObject::COUNT: return findCount(object_id); case DataObject::CUSTOMER: return findCustomer(object_id); case DataObject::CUST_TYPE: return findCustomerType(object_id); case DataObject::DEPT: return findDept(object_id); case DataObject::DISCOUNT: return findDiscount(object_id); case DataObject::EMPLOYEE: return findEmployee(object_id); case DataObject::EXPENSE: return findExpense(object_id); case DataObject::EXTRA: return findExtra(object_id); case DataObject::GENERAL: return findGeneral(object_id); case DataObject::GROUP: return findGroup(object_id); case DataObject::INVOICE: return findInvoice(object_id); case DataObject::ITEM: return findItem(object_id); case DataObject::ITEM_ADJUST: return findItemAdjust(object_id); case DataObject::ITEM_PRICE: return findItemPrice(object_id); case DataObject::LABEL_BATCH: return findLabelBatch(object_id); case DataObject::LOCATION: return findLocation(object_id); case DataObject::NOSALE: return findNosale(object_id); case DataObject::ORDER: return findOrder(object_id); case DataObject::PO_TEMPLATE: return findOrderTemplate(object_id); case DataObject::PAT_GROUP: return findPatGroup(object_id); case DataObject::PAT_WS: return findPatWorksheet(object_id); case DataObject::PAYOUT: return findPayout(object_id); case DataObject::PERSONAL: return findPersonal(object_id); case DataObject::PLU: assert("Invalid data type: PLU"); case DataObject::PRICE_BATCH: return findPriceBatch(object_id); case DataObject::PROMO_BATCH: return findPromoBatch(object_id); case DataObject::QUOTE: return findQuote(object_id); case DataObject::RECEIPT: return findReceipt(object_id); case DataObject::RECEIVE: return findReceive(object_id); case DataObject::RECONCILE: return findReconcile(object_id); case DataObject::RECURRING: return findRecurring(object_id); case DataObject::REPORT: assert("Invalid data type: REPORT"); case DataObject::RETURN: return findInvoice(object_id); case DataObject::SECURITY_TYPE: return findSecurityType(object_id); case DataObject::SHIFT: return findShift(object_id); case DataObject::SLIP: return findSlip(object_id); case DataObject::STATION: return findStation(object_id); case DataObject::STORE: return findStore(object_id); case DataObject::SUBDEPT: return findSubdept(object_id); case DataObject::TAX: return findTax(object_id); case DataObject::TENDER: return findTender(object_id); case DataObject::TEND_COUNT: return findTenderCount(object_id); case DataObject::TEND_ADJUST: return findTenderAdjust(object_id); case DataObject::TERM: return findTerm(object_id); case DataObject::TODO: return findTodo(object_id); case DataObject::USER: return findUser(object_id); case DataObject::VENDOR: return findVendor(object_id); case DataObject::WITHDRAW: return findWithdraw(object_id); } qWarning("Unknown object type: " + object.dataTypeName()); return NULL; }
FindDeliveryOrderDialog::FindDeliveryOrderDialog( data::AbstractResourceManager * resourceManager , QWidget *parent) : QDialog(parent), m_resourceManager(resourceManager) { m_startDateEdit = new QDateEdit; m_startDateEdit->setCalendarPopup(true); m_startDateEdit->setDate(QDate::currentDate()); m_startDateEdit->setEnabled(false); QLabel * startDateLabel = new QLabel(tr("From") + ":"); startDateLabel->setBuddy(m_startDateEdit); m_endDateEdit = new QDateEdit; m_endDateEdit->setCalendarPopup(true); m_endDateEdit->setDate(QDate::currentDate()); m_endDateEdit->setEnabled(false); m_startDateCheck = new QCheckBox(tr("Ignore")); m_startDateCheck->setChecked(true); connect(m_startDateCheck, SIGNAL(stateChanged(int)), this, SLOT(startDateEnabled(int))); QLabel * endDateLabel = new QLabel(tr("To") + ":"); endDateLabel->setBuddy(m_endDateEdit); m_endDateCheck = new QCheckBox(tr("Ignore")); m_endDateCheck->setChecked(true); connect(m_endDateCheck, SIGNAL(stateChanged(int)), this, SLOT(endDateEnabled(int))); m_idEdit = new QLineEdit; QLabel * idLabel = new QLabel(tr("Id") + ":"); idLabel->setBuddy(m_idEdit); QVector<data::Driver> drivers = m_resourceManager->getDriverList(); m_driverEdit = new QComboBox; for (int i = 0; i < drivers.size(); ++i) m_driverEdit->addItem(drivers.at(i).name); m_driverEdit->setCurrentIndex(-1); QLabel * driverLabel = new QLabel(tr("Driver") + ":"); driverLabel->setBuddy(m_driverEdit); m_orderView = new QTreeView; m_orderView->setSelectionBehavior(QAbstractItemView::SelectRows); m_orderView->setSelectionMode(QAbstractItemView::SingleSelection); m_orderView->setAlternatingRowColors(true); m_orderView->setRootIsDecorated(false); QStringList headers; headers << tr("Date") << tr("Id") << tr("Driver") << tr("Posted"); m_orderModel = new QStandardItemModel(this); m_orderModel->setHorizontalHeaderLabels(headers); initModel(m_resourceManager, m_orderModel); m_proxyModel = new DeliveryOrderSortFilterProxyModel(this); m_proxyModel->setSourceModel(m_orderModel); m_orderView->setModel(m_proxyModel); m_orderView->setSortingEnabled(true); m_proxyModel->sort(0); QPushButton * findButton = new QPushButton(tr("Find")); connect(findButton, SIGNAL(clicked()), this, SLOT(findOrder())); m_buttonBox = new QDialogButtonBox(Qt::Vertical); m_buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Reset); m_buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); connect(m_buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()) , this, SLOT(revert())); connect(m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()) , this, SLOT(accept())); QGridLayout * fLayout = new QGridLayout; fLayout->addWidget(startDateLabel, 0, 0); fLayout->addWidget(m_startDateEdit, 0, 1); fLayout->addWidget(m_startDateCheck, 0, 2); fLayout->addWidget(endDateLabel, 1, 0); fLayout->addWidget(m_endDateEdit, 1, 1); fLayout->addWidget(m_endDateCheck, 1, 2); fLayout->addWidget(idLabel, 2, 0); fLayout->addWidget(m_idEdit, 2, 1); fLayout->addWidget(driverLabel, 3, 0); fLayout->addWidget(m_driverEdit, 3, 1); QHBoxLayout * topLeftLayout = new QHBoxLayout; topLeftLayout->addLayout(fLayout); topLeftLayout->addStretch(1); QVBoxLayout * leftLayout = new QVBoxLayout; leftLayout->addLayout(topLeftLayout); leftLayout->addWidget(m_orderView); QHBoxLayout * mainLayout = new QHBoxLayout; mainLayout->addLayout(leftLayout); mainLayout->addWidget(m_buttonBox); mainLayout->setSizeConstraint(QLayout::SetFixedSize); this->setLayout(mainLayout); m_orderView->setFixedWidth(100 * m_orderModel->columnCount()); }