コード例 #1
0
ファイル: Builder.cpp プロジェクト: eric-casellas/vle
    void use_1d_regular_graph_generator(const vle::devs::InitEventList& events)
    {
        vle::translator::regular_graph_generator::parameter param{
            std::bind(&Builder::regular_graph_generator_make_model,
                      this,
                      std::placeholders::_1,
                      std::placeholders::_2,
                      std::placeholders::_3),
            regular_graph_generator_connectivity()
        };

        vle::translator::regular_graph_generator rgg(param);

        const auto& v = events.getSet("mask").value();
        std::vector<std::string> mask;

        std::transform(v.begin(),
                       v.end(),
                       std::back_inserter(mask),
                       [](const auto& v) { return v->toString().value(); });

        rgg.make_1d(*this,
                    events.getInt("lenght"),
                    events.getBoolean("graph-wrap"),
                    mask,
                    events.getInt("x-mask"));
    }
コード例 #2
0
ファイル: Builder.cpp プロジェクト: eric-casellas/vle
    void use_2d_regular_graph_generator(const vle::devs::InitEventList& events)
    {
        vle::translator::regular_graph_generator::parameter param{
            std::bind(&Builder::regular_graph_generator_make_model,
                      this,
                      std::placeholders::_1,
                      std::placeholders::_2,
                      std::placeholders::_3),
            regular_graph_generator_connectivity()
        };

        vle::translator::regular_graph_generator rgg(param);

        int width_mask = events.getInt("mask-width");
        int height_mask = events.getInt("mask-height");
        vle::utils::Array<std::string> mask(width_mask, height_mask);

        const auto& v = events.getSet("mask").value();

        {
            if (vle::utils::numeric_cast<int>(mask.size()) !=
                width_mask * height_mask)
                throw vle::utils::ModellingError("mask definition error");

            int i = 0, j = 0;

            for (const auto& str : v) {
                mask(i, j) = str->toString().value();
                ++j;

                if (j >= height_mask) {
                    i++;
                    j = 0;
                }
            }
        }

        rgg.make_2d(*this,
                    { { events.getInt("width"), events.getInt("height") } },
                    { { events.getBoolean("wrap-width"),
                        events.getBoolean("wrap-height") } },
                    mask,
                    events.getInt("x-mask"),
                    events.getInt("y-mask"));
    }