PedDistributor.h 3.39 KB
Newer Older
1
/**
2 3
 * \file        PedDistributor.h
 * \date        Oct 12, 2010
4 5
 * \version     v0.7
 * \copyright   <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
Ulrich Kemloh's avatar
Ulrich Kemloh committed
6
 *
7
 * \section License
8 9 10
 * This file is part of JuPedSim.
 *
 * JuPedSim is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Lesser General Public License as published by
12 13 14 15 16 17 18 19
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * JuPedSim is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
20
 * You should have received a copy of the GNU Lesser General Public License
21 22
 * along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
 *
23
 * \section Description
24 25
 *
 *
26 27
 **/

Ulrich Kemloh's avatar
Ulrich Kemloh committed
28
#ifndef _PEDDISTRIBUTOR_H
Mohcine Chraibi's avatar
Mohcine Chraibi committed
29
#define _PEDDISTRIBUTOR_H
Ulrich Kemloh's avatar
Ulrich Kemloh committed
30 31 32

#include <vector>
#include <string>
33
#include <memory>
Ulrich Kemloh's avatar
Ulrich Kemloh committed
34

35
#include "../routing/Router.h"
Ulrich Kemloh's avatar
Ulrich Kemloh committed
36
#include "../geometry/Building.h"
37
#include "AgentsParameters.h"
38 39
#include "AgentsSource.h"
#include "StartDistribution.h"
40
#include "../general/ArgumentParser.h"
Ulrich Kemloh's avatar
Ulrich Kemloh committed
41

42 43
//typedef vector<Point> tPoints;
//typedef vector<tPoints> GridPoints;
44 45


GrgrLmml's avatar
GrgrLmml committed
46
class PedDistributor {
47
private:
GrgrLmml's avatar
GrgrLmml committed
48 49 50 51 52
    std::vector<std::shared_ptr<StartDistribution> > _start_dis; // ID startraum, subroom und Anz
    std::vector<std::shared_ptr<StartDistribution> > _start_dis_sub; // ID startraum, subroom und Anz
    std::vector<std::shared_ptr<AgentsSource> > _start_dis_sources; // contain the sources
    //std::string _projectFilename; // store the file for later user
    //std::map<int, AgentsParameters*> _agentsParameters;
53

GrgrLmml's avatar
GrgrLmml committed
54 55 56 57 58 59 60
    static std::vector<Point> PositionsOnFixX(double max_x, double min_x, double max_y,
                                              double min_y, const SubRoom &r, double bufx, double bufy, double dy);

    static std::vector<Point> PositionsOnFixY(double max_x, double min_x, double max_y,
                                              double min_y, const SubRoom &r, double bufx, double bufy, double dx);

    const Configuration * _configuration;
61
public:
GrgrLmml's avatar
GrgrLmml committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    /**
     * constructor
     */
    PedDistributor(const Configuration *configuration);

    /**
     * desctructor
     */
    virtual ~PedDistributor();

    /**
     * Return the possible positions for distributing the agents in the subroom
     */
    static vector<Point> PossiblePositions(const SubRoom &r);

    /**
     * Distribute the pedestrians in the Subroom with the given parameters
     */
80
    void DistributeInSubRoom(int N, std::vector<Point> &positions, int *pid,
GrgrLmml's avatar
GrgrLmml committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
                             StartDistribution *parameters, Building *building) const;

    /**
     *
     *Distribute all agents based on the configuration (ini) file
     * @return true if everything went fine
     */
    bool Distribute(Building *building) const;

    /**
     * provided for convenience
     */

    const std::vector<std::shared_ptr<AgentsSource> > &GetAgentsSources() const;

Mohcine Chraibi's avatar
Mohcine Chraibi committed
96 97 98 99 100 101
    /**
     * Get positions from filename
     * Only for frame's position for every id is given
     * WARNING: It is assumed that positions should be in the corresponding room/subroom. 
     * checks with n if the file delivers the right number of peds
     */
Mohcine Chraibi's avatar
Mohcine Chraibi committed
102
    const vector<Point>  GetPositionsFromFile(std::string filename, int n, std::string unit) const;
Mohcine Chraibi's avatar
Mohcine Chraibi committed
103

Ulrich Kemloh's avatar
Ulrich Kemloh committed
104 105
};

Mohcine Chraibi's avatar
Mohcine Chraibi committed
106
#endif  /* _PEDDISTRIBUTOR_H */
Ulrich Kemloh's avatar
Ulrich Kemloh committed
107