void ShaderSystemInterface::foreachShader(shaders::ShaderVisitor& visitor) { // Note: foreachShader only traverses the loaded materials, use a small adaptor to traverse all known ShaderNameToShaderWrapper adaptor(visitor); GlobalMaterialManager().foreachShaderName(boost::bind(&ShaderNameToShaderWrapper::visit, &adaptor, _1)); }
void MeshViewController::addMesh(float label) { LOG_USER(meshviewcontrollerlog) << "showing label " << label << std::endl; if (_meshCache.count(label)) { _meshes->add(label, _meshCache[label]); return; } typedef ExplicitVolumeLabelAdaptor<ExplicitVolume<float>> Adaptor; Adaptor adaptor(*_labels, label); sg_gui::MarchingCubes<Adaptor> marchingCubes; std::shared_ptr<sg_gui::Mesh> mesh = marchingCubes.generateSurface( adaptor, sg_gui::MarchingCubes<Adaptor>::AcceptAbove(0), optionCubeSize, optionCubeSize, optionCubeSize); _meshes->add(label, mesh); _meshCache[label] = mesh; }
SkStreamRewindable* CopyJavaInputStream(JNIEnv* env, jobject stream, jbyteArray storage) { SkAutoTUnref<SkStream> adaptor(CreateJavaInputStreamAdaptor(env, stream, storage)); if (NULL == adaptor.get()) { return NULL; } return adaptor_to_mem_stream(adaptor.get()); }
bool match(match_state<BidiIter> &state, Next const &next) const { // regex_matcher is used for embeding a dynamic regex in a static regex. As such, // Next will always point to a static regex. BOOST_MPL_ASSERT((is_static_xpression<Next>)); // wrap the static xpression in a matchable interface xpression_adaptor<reference_wrapper<Next const>, matchable<BidiIter> > adaptor(boost::cref(next)); return push_context_match(this->impl_, state, adaptor); }
SkStreamRewindable* CopyJavaInputStream( /* [in] */ IInputStream* stream, /* [in] */ ArrayOf<Byte>* storage) { SkAutoTUnref<SkStream> adaptor(CreateInputStreamAdaptor(stream, storage)); if (NULL == adaptor.get()) { return NULL; } return adaptor_to_mem_stream(adaptor.get()); }
double curveLengthBetweenParams(const Handle_Geom_Curve& curve, double firstU, double lastU) { try { GeomAdaptor_Curve adaptor(curve); return GCPnts_AbscissaPoint::Length(adaptor, firstU, lastU); } catch(...) { return 0.; } }
double curveLength(const Handle_Geom_Curve& curve) { try { GeomAdaptor_Curve adaptor(curve); return GCPnts_AbscissaPoint::Length(adaptor); } catch(...) { return 0.; } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QFileSystemModel dir; dir.setRootPath("/"); QtTreeModelAdaptor adaptor(&dir); QtTreeWidgetNG widget; widget.controller()->setModel(&adaptor); widget.show(); return app.exec(); }
int main( int argc, char ** argv ) { ImgSequence seq("/data/seq/original4"); SeqAdaptor adaptor(seq); RouteManager manager(adaptor); // for (int p=0; p<seq.getLength(); p++) { for (int p=0; p<5; p++) { cout << "seqRoute: idealP: " << p << endl; bool arrived = false; bool routeComplete = false; double homeAngle = manager.getHomeAngle(1, arrived, routeComplete); } return 0; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QCommandLineOption raiseOption("raise", "raise the main window."); QCommandLineOption quitOption("quit", "quit all dde-lowpower instances."); // command line parser QCommandLineParser parser; parser.addHelpOption(); parser.addOption(raiseOption); parser.addOption(quitOption); parser.process(a); Window w; LowPowerAdaptor adaptor(&w); QDBusInterface iface(DBUS_SERV, DBUS_PATH, DBUS_IFCE, QDBusConnection::sessionBus()); bool result = QDBusConnection::sessionBus().registerService(DBUS_SERV); if (result) { if (parser.isSet(quitOption)) { return 0; } else { w.show(); w.grabMouse(); w.grabKeyboard(); QDBusConnection::sessionBus().registerObject(DBUS_PATH, &w); } } else { if (parser.isSet(raiseOption)) { iface.call("Raise"); } else if (parser.isSet(quitOption)) { iface.call("Quit"); } QTimer::singleShot(500, &a, SLOT(quit())); } return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setOrganizationName("kylin"); a.setApplicationName("Kylin Weather (indication-china-weather)"); a.setApplicationVersion("3.0.1"); a.setQuitOnLastWindowClosed(false);//Avoid that after hiding mainwindow, close the sub window would cause the program exit QString locale = QLocale::system().name(); QTranslator translator; if(locale == "zh_CN") { if(!translator.load("indicator-china-weather_" + locale + ".qm", ":/qm/translation/")) qDebug() << "Load translation file:"<< "indicator-china-weather_" + locale + ".qm" << " failed!"; else a.installTranslator(&translator); } // QTranslator qtTranslator; // qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); // a.installTranslator(&qtTranslator); MainWindow w; DbusAdaptor adaptor(&w); Q_UNUSED(adaptor); auto connection = QDBusConnection::sessionBus(); if (!connection.registerService("com.kylin.weather") || !connection.registerObject("/com/kylin/weather", &w/*, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals*/)) { //qCritical() << "QDbus register service failed reason:" << connection.lastError(); QDBusInterface iface("com.kylin.weather", "/com/kylin/weather", "com.kylin.weather", connection); iface.call("showMainWindow"); return 0; }//QDBusConnection::sessionBus().unregisterService("com.kylin.weather"); //w.show(); return a.exec(); }
StatusWith<CompactStats> Collection::compact( OperationContext* txn, const CompactOptions* compactOptions ) { if ( !_recordStore->compactSupported() ) return StatusWith<CompactStats>( ErrorCodes::BadValue, str::stream() << "cannot compact collection with record store: " << _recordStore->name() ); if ( _indexCatalog.numIndexesInProgress() ) return StatusWith<CompactStats>( ErrorCodes::BadValue, "cannot compact when indexes in progress" ); // same data, but might perform a little different after compact? _infoCache.reset(); vector<BSONObj> indexSpecs; { IndexCatalog::IndexIterator ii( _indexCatalog.getIndexIterator( false ) ); while ( ii.more() ) { IndexDescriptor* descriptor = ii.next(); const BSONObj spec = _compactAdjustIndexSpec(descriptor->infoObj()); const BSONObj key = spec.getObjectField("key"); const Status keyStatus = validateKeyPattern(key); if (!keyStatus.isOK()) { return StatusWith<CompactStats>( ErrorCodes::CannotCreateIndex, str::stream() << "Cannot compact collection due to invalid index " << spec << ": " << keyStatus.reason() << " For more info see" << " http://dochub.mongodb.org/core/index-validation"); } indexSpecs.push_back(spec); } } // note that the drop indexes call also invalidates all clientcursors for the namespace, // which is important and wanted here log() << "compact dropping indexes" << endl; Status status = _indexCatalog.dropAllIndexes(txn, true); if ( !status.isOK() ) { return StatusWith<CompactStats>( status ); } txn->checkForInterrupt(); CompactStats stats; MultiIndexBlock multiIndexBlock(txn, this); status = multiIndexBlock.init( indexSpecs ); if ( !status.isOK() ) return StatusWith<CompactStats>( status ); MyCompactAdaptor adaptor(this, &multiIndexBlock); _recordStore->compact( txn, &adaptor, compactOptions, &stats ); log() << "starting index commits"; status = multiIndexBlock.commit(); if ( !status.isOK() ) return StatusWith<CompactStats>( status ); return StatusWith<CompactStats>( stats ); }
//有上下界的最大流 static bool MaxFlow_Bound(Digraph& dg, ArcFilter& arc_filter, Digraph::Node s, Digraph::Node t, double Q, Capacity& low, Capacity& high, Flow& flow, bool fixTotalQ=false) { typedef FilterArcs<Digraph, ArcFilter> Adaptor; typedef Adaptor::ArcMap<double> CapMap; typedef Adaptor::ArcMap<Digraph::Arc> LowUpArcMap; typedef Preflow<Adaptor,CapMap> FastPreFlow; //过滤后的图 Adaptor adaptor(dg, arc_filter); //在源点s之前再添加一条分支,用来限制总流量Q Digraph::Node s0 = adaptor.addNode(); Digraph::Arc e0 = adaptor.addArc(s0, s); low[e0] = (fixTotalQ?Q:0); high[e0] = Q; arc_filter[e0] = true; // 注:ArcFilter默认false //添加一条t->s的分支,下界0,上界无穷大 Digraph::Arc ts = adaptor.addArc(t, s0); low[ts] = 0; high[ts] = DBL_MAX; arc_filter[ts] = true; //分支容量(默认无穷大) CapMap cap(adaptor, DBL_MAX); //上界分支拆分后的分支映射记录 //e --> e=(u->v), ee1=(ss->v), e22=(u->tt) //lu[ee1] = e; lu[ee2] = e; LowUpArcMap lu(adaptor, INVALID); //添加超级源汇 Digraph::Node ss = adaptor.addNode(); Digraph::Node tt = adaptor.addNode(); //注:后续新增的节点和分支属性map不会自动更新,需要手动设置 //例如cap[e0]、cap[ts]、arc_filter、lu等 //为了减少重复代码,将属性初始化声明转移到添加节点和分支之后 //拆分有上下界的分支,其它分支上界默认无穷大 for(Adaptor::ArcIt e(adaptor);e!=INVALID;++e) { if(low[e] > 0 && high[e] >= low[e]) { Digraph::Node u = adaptor.source(e); Digraph::Node v = adaptor.target(e); Digraph::Arc ee1 = adaptor.addArc(ss, v); Digraph::Arc ee2 = adaptor.addArc(u, tt); cap[e] = high[e] - low[e]; cap[ee1] = low[e]; cap[ee2] = low[e]; // 更新cap low[ee1] = 0; low[ee2] = 0; // 更新low lu[ee1] = e; lu[ee2] = e; // 更新lu arc_filter[ee1] = true; arc_filter[ee2] = true; } //cout<<"e"<<g .id(e)<<" low:"<<low[e]<<", high:"<<high[e]<<", cap:"<<cap[e]<<endl; } //执行一次最大流计算 FastPreFlow preflow(adaptor, cap, ss, tt); preflow.run(); //最大流值 double max_flow = preflow.flowValue(); //计算得到的分支流量 const FastPreFlow::FlowMap& flow_map = preflow.flowMap(); //判断是否可行流(即额外添加的分支满流,满足下界low) //2种方法:1) 所有的流量的下界之和是否等于最大流 2) 所有分支的下界是否满流 //使用第1种方法判定: 计算所有分支的下界之和 //用于后续判断是否可行流(满足下界,且下界之和等于最大流) double S = 0; for(Adaptor::ArcIt e(adaptor);e!=INVALID;++e) { S += low[e]; } const double PRE_VNC_EPSILON=0.01; bool ret = (fabs(S-max_flow) < PRE_VNC_EPSILON); if(ret) { //有上下界的最大流分配成功!!! //得到计算的流量值,并记录拆分的分支 EdgeArray edges; for(Adaptor::ArcIt ee(adaptor);ee!=INVALID;++ee) { flow[ee] = flow_map[ee]; if(lu[ee] != INVALID) { edges.push_back(ee); } } typedef std::set<Digraph::Arc> ArcSet; //记录已处理的分支 ArcSet aset; for(EdgeArray::iterator itr=edges.begin();itr!=edges.end();++itr) { Digraph::Arc ee = *itr; Digraph::Arc e = lu[ee]; // 如果分支已处理,则添加到aset集合中,避免重复流量叠加 if(aset.find(e) == aset.end()) { flow[e] = low[e] + flow_map[e]; aset.insert(e); } } } // erase(node)函数会自动删除节点以及节点的流入流出分支 // erase(arc)函数则只会删除分支 adaptor.erase(ss); adaptor.erase(tt); adaptor.erase(s0); return ret; }
void Choice::add_choice( std::unique_ptr<Link> fresh ) { std::unique_ptr< LinkAdaptor > adaptor( new LinkAdaptor(std::move(fresh)) ); adaptor->connect( *this ); choices.addChoice( std::move(adaptor) ); }
void MainWindow::parameterize(const Parameterization_method method) { QApplication::setOverrideCursor(Qt::WaitCursor); // get active polyhedron int index = getSelectedSceneItemIndex(); Polyhedron* pMesh = scene->polyhedron(index); if(pMesh == NULL) { QApplication::restoreOverrideCursor(); return; } // parameterize QTime time; time.start(); typedef CGAL::Parameterization_polyhedron_adaptor_3<Polyhedron> Adaptor; Adaptor adaptor(*pMesh); bool success = false; switch(method) { case PARAM_MVC: { std::cout << "Parameterize (MVC)..."; typedef CGAL::Mean_value_coordinates_parameterizer_3<Adaptor> Parameterizer; Parameterizer::Error_code err = CGAL::parameterize(adaptor,Parameterizer()); success = err == Parameterizer::OK; break; } case PARAM_DCP: { std::cout << "Parameterize (DCP)..."; typedef CGAL::Discrete_conformal_map_parameterizer_3<Adaptor> Parameterizer; Parameterizer::Error_code err = CGAL::parameterize(adaptor,Parameterizer()); success = err == Parameterizer::OK; } } if(success) std::cout << "ok (" << time.elapsed() << " ms)" << std::endl; else { std::cout << "failure" << std::endl; QApplication::restoreOverrideCursor(); return; } // add textured polyhedon to the scene Textured_polyhedron *pTex_polyhedron = new Textured_polyhedron(); Textured_polyhedron_builder<Polyhedron,Textured_polyhedron,Kernel> builder; builder.run(*pMesh,*pTex_polyhedron); pTex_polyhedron->compute_normals(); Polyhedron::Vertex_iterator it1; Textured_polyhedron::Vertex_iterator it2; for(it1 = pMesh->vertices_begin(), it2 = pTex_polyhedron->vertices_begin(); it1 != pMesh->vertices_end(), it2 != pTex_polyhedron->vertices_end(); it1++, it2++) { // (u,v) pair is stored per halfedge FT u = adaptor.info(it1->halfedge())->uv().x(); FT v = adaptor.info(it1->halfedge())->uv().y(); it2->u() = u; it2->v() = v; } scene->addTexPolyhedron(pTex_polyhedron, tr("%1 (parameterized)").arg(scene->polyhedronName(index)), Qt::white, scene->isPolyhedronVisible(index), scene->polyhedronRenderingMode(index)); QApplication::restoreOverrideCursor(); }
void alpha_memory::store( tuple_handle const& th) { th->_cons.push_back( _items.connect( adaptor( th) ) ); }