当前位置: 首页>>代码示例>>C++>>正文


C++ Simulator::allObjectsSize方法代码示例

本文整理汇总了C++中Simulator::allObjectsSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Simulator::allObjectsSize方法的具体用法?C++ Simulator::allObjectsSize怎么用?C++ Simulator::allObjectsSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Simulator的用法示例。


在下文中一共展示了Simulator::allObjectsSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
        else if (arg.find(HANDLER_ARG) != std::string::npos) {
            handler_type = arg.substr(HANDLER_ARG.size());
        }
        else if (arg.find(BRANCH_ARG) != std::string::npos) {
            std::string branch_arg = arg.substr(BRANCH_ARG.size());
            branching = boost::lexical_cast<int>(branch_arg);
        }

        else if (arg.find(NQUERIES_ARG) != std::string::npos) {
            std::string nqueries_arg = arg.substr(NQUERIES_ARG.size());
            nqueries = boost::lexical_cast<int>(nqueries_arg);
        }
        else if (arg.find(STATIC_QUERIES_ARG) != std::string::npos) {
            std::string static_arg = arg.substr(STATIC_QUERIES_ARG.size());
            static_queries = convert_bool(static_arg);
        }

    }

    srand(seed);

#ifndef LIBPROX_RTREE_DATA
# error "You must define LIBPROX_RTREE_DATA to either LIBPROX_RTREE_DATA_BOUNDS or LIBPROX_RTREE_DATA_MAXSIZE"
#endif
#if LIBPROX_RTREE_DATA == LIBPROX_RTREE_DATA_BOUNDS
    typedef Prox::BoundingSphereData<Prox::DefaultSimulationTraits> NodeData;
#elif LIBPROX_RTREE_DATA == LIBPROX_RTREE_DATA_MAXSIZE
    typedef Prox::MaxSphereData<Prox::DefaultSimulationTraits> NodeData;
#elif LIBPROX_RTREE_DATA == LIBPROX_RTREE_DATA_SIMILARMAXSIZE
    typedef Prox::SimilarMaxSphereData<Prox::DefaultSimulationTraits> NodeData;
#else
# error "Invalid setting for LIBPROX_RTREE_DATA"
#endif

    ManualQueryHandler* handler = NULL;
    if (handler_type == "rtree") {
        handler = new Prox::RTreeManualQueryHandler<Prox::DefaultSimulationTraits, NodeData>(branching);
    }

    Simulator* simulator = new Simulator(handler, duration, Duration::milliseconds((unsigned int)timestep), iterations, realtime);
    GLRenderer* renderer = new GLRenderer(simulator, handler, display);

    BoundingBox3 random_region( Vector3(-100.f, -100.f, -100.f), Vector3(100.f, 100.f, 100.f) );

    int nobjects_moving = nobjects * moving_frac;
    int nobjects_static = nobjects - nobjects_moving;

    // There are various combinations of sources of objects we might need to get
    // to the target number with the right mix. When we need random objects and
    // we've loaded some from another source, we need to make sure we get the
    // region to generate them over correct.

    bool got_static = false;
    bool got_moving = false;

    // First, get objects from csv files.
    if (!csvfile.empty()) {
        simulator->createStaticCSVObjects(csvfile, nobjects_static);
        got_static = true;
    }
    // note: this should be second so that
    if (!csvmotionfile.empty()) {
        assert(!csvfile.empty()); // FIXME we'd like to support this, need to
                                  // figure out bounding box issues for
                                  // generating starting positions
        simulator->createMotionCSVObjects(csvmotionfile, nobjects_moving);
        got_moving = true;
    }

    // Next, take care of leftovers with random objects. Note that we use the
    // existing bounds if some other objects were already loaded.
    if (!got_static && !got_moving)
        simulator->createRandomObjects(random_region, nobjects, moving_frac);
    else if (!got_static && got_moving)
        simulator->createRandomObjects(simulator->region(), nobjects_static, 0.0);
    else if (got_static && !got_moving)
        simulator->createRandomObjects(simulator->region(), nobjects_moving, 1.0);
    // else we don't need any random objects

    // Sometimes we're not perfect, but let's aim for 99% of the target objects.
    assert(simulator->allObjectsSize() >= .99f * nobjects);

    simulator->initialize(/*churn_rate*/0);

    if (!csvmotionfile.empty() && !static_queries)
        simulator->createCSVQueries(nqueries, csvmotionfile);
    else
        simulator->createRandomQueries(nqueries, static_queries);

    simulator->run();

    renderer->run();
    simulator->shutdown();

    delete renderer;
    delete simulator;


    return 0;
}
开发者ID:sirikata,项目名称:prox,代码行数:101,代码来源:main.cpp


注:本文中的Simulator::allObjectsSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。