// API function: evaluate a given model over the data, and fill a mask with the // inliers (according to the given allowed error). This function returns the // number of inliers. int ransac_trial( // output bool *out_mask, // array mask identifying the inliers // input data float *data, // array of input data float *model, // parameters of the model float max_error, // maximum allowed error // input context int datadim, // dimension of each data point int n, // number of data points ransac_error_evaluation_function *mev, // decoration void *usr ) { int cx = 0; for (int i = 0; i < n; i++) { float *datai = data + i*datadim; float e = mev(model, datai, usr); if (!(e >= 0)) fprintf(stderr, "WARNING e = %g\n", e); assert(e >= 0); out_mask[i] = e < max_error; if (out_mask[i]) cx += 1; } return cx; }
Z3_ast Z3_API Z3_model_extrapolate (Z3_context c, Z3_model m, Z3_ast fml) { Z3_TRY; LOG_Z3_model_extrapolate (c, m, fml); RESET_ERROR_CODE(); model_ref model (to_model_ref (m)); expr_ref_vector facts (mk_c(c)->m ()); facts.push_back (to_expr (fml)); flatten_and (facts); spacer::model_evaluator_util mev (mk_c(c)->m()); mev.set_model (*model); expr_ref_vector lits (mk_c(c)->m()); spacer::compute_implicant_literals (mev, facts, lits); expr_ref result (mk_c(c)->m ()); result = mk_and (lits); mk_c(c)->save_ast_trail (result.get ()); return of_expr (result.get ()); Z3_CATCH_RETURN(0); }
/* *平移扫成 *@param[in] face 要平移的面 *@param[in] dir 平移方向 *@param[in] distance 平移方向上的位移 */ void EulerOperator::sweep(Face *face, double dir[3], double distance) { Loop* outerLoop = NULL; for(Loop* loop = face->loop;loop!=NULL;loop=loop->next) { Loop* loop2 = loop->he->getAdjacent()->loop; Half_Edge* head = loop2->he; Half_Edge* he = head; Half_Edge* next = head->next; Vertex* end; Vertex *ve1=NULL,*ve2=NULL; do { Vertex *ve = he->ve1; Point pt1 = ve->point; pt1.multiple(dir,distance); pt1.index = Point::indexIncrement(); if(ve1==NULL) { ve1 = mev(ve,pt1,loop2)->ve2; end = ve1; } else ve2 = mev(ve,pt1,loop2)->ve2; if(ve1&&ve2) { mef(ve1,ve2,loop2); ve1 = ve2; ve2 = NULL; } he = next; next = next->next; }while(he->ve1!=head->ve1); mef(ve1,end,loop2); if(outerLoop!=NULL) kfmrh(outerLoop,loop2); else outerLoop = loop2; } }
//--------------------------------------------------------------------------- void QBBoxTest::buttonClicked( void ) { QBrowserBox *browserbox = new QBrowserBox( 7, 4 ); browserbox->resize( 100, 100 ); browserbox->insertItem( "A", 0, 0 ); browserbox->insertItem( "B", 0, 1 ); browserbox->insertItem( "C", 0, 2 ); browserbox->insertItem( "D", 0, 3 ); QPixmap pixmap( 32, 32 ); pixmap.fill( white ); browserbox->insertItem( pixmap, 1, 0 ); pixmap.fill( red ); browserbox->insertItem( pixmap, 1, 1 ); pixmap.fill( green ); browserbox->insertItem( pixmap, 1, 2 ); pixmap.fill( yellow ); browserbox->insertItem( pixmap, 1, 3 ); browserbox->insertItem( "I", 2, 0 ); pixmap.fill( magenta ); browserbox->insertItem( pixmap, 2, 0 ); browserbox->insertItem( "J", 2, 1 ); pixmap.fill( cyan ); browserbox->insertItem( pixmap, 2, 1 ); browserbox->insertItem( "K", 2, 2 ); pixmap.fill( blue ); browserbox->insertItem( pixmap, 2, 2 ); browserbox->insertItem( "L", 2, 3 ); pixmap.fill( darkYellow ); browserbox->insertItem( pixmap, 2, 3 ); browserbox->insertItem( "M", 3, 0 ); browserbox->insertItem( "N", 3, 1 ); browserbox->insertItem( "O", 3, 2 ); browserbox->insertItem( "P", 3, 3 ); browserbox->insertItem( "Q", 4, 0 ); browserbox->insertItem( "R", 4, 1 ); browserbox->insertItem( "S", 4, 2 ); browserbox->insertItem( "T", 4, 3 ); browserbox->insertItem( "U", 5, 0 ); browserbox->insertItem( "V", 5, 1 ); browserbox->insertItem( "W", 5, 2 ); browserbox->insertItem( "X", 5, 3 ); browserbox->insertItem( "Y", 6, 0 ); browserbox->insertItem( "Z", 6, 1 ); browserbox->insertItem( "!", 6, 2 ); browserbox->insertItem( "?", 6, 3 ); int ret = browserbox->exec( quit ); debug( "Item chosen: %d\n", ret ); QEvent ev( QEvent::Leave ); QMouseEvent mev( QEvent::MouseButtonRelease, QCursor::pos(), LeftButton, LeftButton ); QApplication::sendEvent( quit, &ev ); QApplication::sendEvent( quit, &mev ); delete browserbox; }
void PanelBrowserMenu::dragMoveEvent(QDragMoveEvent *ev) { QMouseEvent mev(QEvent::MouseMove, ev->pos(), Qt::NoButton, Qt::LeftButton, Qt::NoModifier); QMenu::mouseMoveEvent(&mev); }
void AQWebApplication::handleWebEvent(const QString &msgEvent) { QStringList args(QStringList::split(AQ_MSG_SEP, msgEvent, true)); AQ::EventType evT = webEventTypeToAQEventType(args[0]); QWidget *w; AQWidgetInfo *wInfo; if (evT != AQ::XProgressDialog) { w = AQ_WIDGET(args[1].toULongLong(0, 36)); wInfo = createdWidgets_.find(w); if (!wInfo) return; } switch (evT) { case AQ::MouseButtonPress: { QWidget *popup = activePopupWidget(); if (popup && popup != w->topLevelWidget()) popup->close(); w->raise(); w->setActiveWindow(); QPoint local(args[2].toInt(), args[3].toInt()); QPoint global(w->mapToGlobal(local)); QCursor::setPos(global); QMouseEvent mev(QEvent::MouseButtonPress, local, global, toQtButton(args[4]), toQtButtonState(args[5])); qt_sendSpontaneousEvent(w, &mev); break; } case AQ::MouseButtonRelease: { QPoint local(args[2].toInt(), args[3].toInt()); QPoint global(w->mapToGlobal(local)); QCursor::setPos(global); QMouseEvent mev(QEvent::MouseButtonRelease, local, global, toQtButton(args[4]), toQtButtonState(args[5])); qt_sendSpontaneousEvent(w, &mev); break; } case AQ::MouseButtonDblClick: { QPoint local(args[2].toInt(), args[3].toInt()); QPoint global(w->mapToGlobal(local)); QCursor::setPos(global); QMouseEvent mev(QEvent::MouseButtonDblClick, local, global, toQtButton(args[4]), toQtButtonState(args[5])); qt_sendSpontaneousEvent(w, &mev); break; } case AQ::MouseMove: { QPoint local(args[2].toInt(), args[3].toInt()); QPoint global(w->mapToGlobal(local)); QCursor::setPos(global); QMouseEvent mev(QEvent::MouseMove, local, global, toQtButton(args[4]), toQtButtonState(args[5])); qt_sendSpontaneousEvent(w, &mev); break; } case AQ::KeyPress: case AQ::KeyRelease: { int keyCode = args[2].toInt(); QWidget *keywidget = QWidget::keyboardGrabber(); bool grabbed = false; if (keywidget) { grabbed = true; } else { keywidget = focusWidget(); if (!keywidget) { keywidget = activePopupWidget(); if (!keywidget) { keywidget = activeWindow(); if (!keywidget) keywidget = w->topLevelWidget(); } } } if (keyCode < 0) { QKeyEvent kev((QEvent::Type) evT, 0, keyCode, toQtButtonState(args[3]), QChar(-keyCode)); qt_sendSpontaneousEvent(keywidget, &kev); } else { if (evT == AQ::KeyPress && !grabbed) { QKeyEvent a((QEvent::Type) evT, toQtKey(keyCode), keyCode, toQtButtonState(args[3])); if (qt_tryAccelEvent(keywidget, &a)) return; } QKeyEvent kev((QEvent::Type) evT, toQtKey(keyCode), keyCode, toQtButtonState(args[3])); qt_sendSpontaneousEvent(keywidget, &kev); } break; } case AQ::Move: if (w != desktop_) { ignoreEvents_ = true; w->move(args[2].toInt(), args[3].toInt()); ignoreEvents_ = false; } break; case AQ::Resize: if (w != desktop_) { //ignoreEvents_ = true; w->resize(args[2].toInt(), args[3].toInt()); //ignoreEvents_ = false; } else { int wt = args[2].toInt(); int ht = args[3].toInt(); desktopGeometry_.setRect(0, 0, wt, ht); desktop()->resize(wt, ht); postAQEvent(new AQEvent(w, new QResizeEvent(QSize(wt, ht), QSize()))); emit desktop()->resized(0); if (!initDone_) QTimer::singleShot(0, this, SLOT(init())); } break; case AQ::XUpload: { QFileDialog *fd = ::qt_cast<QFileDialog *>(w); if (fd) fd->rereadDir(); break; } case AQ::XProgressDialog: { uint pid = args[1].toUInt(); if (args.size() == 2) { QProgressDialog *pd = progressDialogs_.take(pid); if (pd) { pd->close(); pd->deleteLater(); } } else { QProgressDialog *pd = progressDialogs_.find(pid); if (!pd) { pd = new QProgressDialog(args[2], QString(), args[3].section(';', 1, 1).toInt()); progressDialogs_.insert(pid, pd); } pd->setProgress(args[3].section(';', 0, 0).toInt()); } break; } case AQ::WindowStateChange: { w->setWindowState(args[2].toInt()); break; } default: { QEvent ev((QEvent::Type) evT); qt_sendSpontaneousEvent(w, &ev); } } }
void point_serial_transfer(Mesh &srcrend, Interp::UserFunc *ufunc, UInt num_fields, MEField<> *const *sfields, _field *const *dfields, int *iflag, SearchResult &sres) { Trace __trace("point_serial_transfer(Interp::UserFunc *ufunc, UInt num_fields, MEField<> *const *sfields, _field *const *dfields, int *iflag, SearchResult &sres)"); if (num_fields == 0) return; SearchResult::iterator sb = sres.begin(), se = sres.end(); for (; sb != se; sb++) { Search_result &sres = **sb; // Trick: Gather the data from the source field so we may call interpolate point const MeshObj &elem = *(*sb)->elem; UInt pdim = GetMeshObjTopo(elem)->parametric_dim; // Inner loop through fields for (UInt i = 0; i < num_fields; i++) { if (iflag[i] != Interp::INTERP_STD) continue; MEField<> &sfield = *sfields[i]; _field &dfield = *dfields[i]; // Load Parametric coords UInt npts = sres.nodes.size(); // number of points to interpolate std::vector<double> pcoord(pdim*npts); for (UInt np = 0; np < npts; np++) { for (UInt pd = 0; pd < pdim; pd++) pcoord[np*pdim+pd] = sres.nodes[np].pcoord[pd]; } std::vector<double> ires(npts*sfield.dim()); if (!ufunc) { MEValues<> mev(sfield.GetMEFamily()); arbq pintg(pdim, npts, &pcoord[0]); mev.Setup(elem, MEV::update_sf, &pintg); mev.ReInit(elem); mev.GetFunctionValues(sfield, &ires[0]); } else { ufunc->evaluate(srcrend, elem, sfield, npts, &pcoord[0], &ires[0]); } // Copy data to nodes for (UInt n = 0; n < npts; n++) { const MeshObj &node = *sres.nodes[n].node; for (UInt d = 0; d < dfield.dim(node); d++) ((double*)dfield.data(node))[d] = ires[n*dfield.dim(node)+d]; } } // for fields } // for searchresult }