Une nouvelle version du portail de gestion des comptes externes sera mise en production lundi 09 août. Elle permettra d'allonger la validité d'un compte externe jusqu'à 3 ans. Pour plus de détails sur cette version consulter : https://doc-si.inria.fr/x/FCeS

Commit c363bda1 authored by Javad AMIRIAN's avatar Javad AMIRIAN Committed by Fabien Grzeskowiak
Browse files

Resolve "Test-folder"

parent a2ac9bbb
......@@ -36,3 +36,6 @@ build/
*.exe
*.out
*.app
#QtCreator Cmake
CMakeLists.txt.user*
......@@ -25,7 +25,7 @@
cmake_minimum_required( VERSION 2.8 )
project( CrowdSimulator )
set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})
#set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})
include_directories( ./include )
......@@ -35,6 +35,7 @@ if (WIN32)
include_directories( C:/local )
endif (WIN32)
file( GLOB_RECURSE source_files src/* include/* )
file( GLOB_RECURSE source_files src/* include/*)
add_executable( my_app ${source_files} )
add_executable( my_app main.cpp ${source_files} )
add_executable(test_xmlparser ./test/test_xmlparser.cpp ${source_files})
......@@ -42,7 +42,7 @@ public:
/**
* Loads the world from a configuration file
*/
void loadInitFile();
void loadInitFile(const std::string& filename);
/**
* Writes the result of the simulation to disk
......
......@@ -32,8 +32,7 @@ int main( int argc, char * argv[] )
{
CrowdSimulator cs;
//cs.loadInitFile("/home/jamirian/workspace/crowd_sim/ocsr/test_b1.xml");
//cs.world_
cs.loadInitFile("/home/jamirian/workspace/crowd_sim/ocsr/test_b1.xml");
std::cout << "---------------" << std::endl;
......
......@@ -24,11 +24,21 @@
*/
#include <core/crowdSimulator.h>
#include "tools/xmlparser.h"
CrowdSimulator::CrowdSimulator() {
CrowdSimulator::CrowdSimulator()
{
createNewWorld();
}
void CrowdSimulator::loadInitFile(const std::string &filename)
{
XMLParser parser;
parser.load(filename);
world_->setAgents(parser.agents);
world_->setObstacles(parser.obstacles);
}
void CrowdSimulator::AppendPosInOutput(std::ofstream &outfile, double time, Agent* agent)
{
if(outfile.is_open())
......
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program 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.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
**
**
** Authors: Axel Lopez Gandia, Javad Amirian, Florian Berton,
** Julien Legros, Lucas Pelerin, Beatriz Cabrero Daniel, Fabien Grzeskowiak
**
** Contact: crowd_group@inria.fr
*/
//========================================================================
/*!
@file xmlparsertest.cpp
@class XMLParserTest
@date 29/6/2018
@brief
@author Javad Amirian, (C) 2018
*/
//========================================================================
#ifndef _XMLPARSER_TEST_H
#define _XMLPARSER_TEST_H
#include <math.h>
#include <assert.h>
#include <boost/timer.hpp>
#include "../include/tools/xmlparser.h"
#include "../include/core/agent.h"
#include "../include/core/obstacle.h"
int main(int argc, char * argv[])
{
std::string filename;
XMLParser xml_parser_write;
XMLParser xml_parser_read;
float eps = 10E-8;
size_t Nped = 1000;
for(size_t i=0; i<Nped; i++)
{
Agent *agent_i = new Agent;
agent_i->setID(i);
agent_i->setRadius(0.25);
agent_i->setPosition((rand()%100)/10., (rand()%100)/10.);
agent_i->setGoal(-(rand()%100)/10., -(rand()%100)/10.);
//agent_i->setGoalType((rand()%2)? Agent::eGoalLoc : Agent::eGoalDir);
xml_parser_write.agents.push_back(agent_i);
}
size_t Nobs = 5;
for(size_t i=0; i<Nobs; i++)
{
Obstacle *obs_i = new Obstacle;
Vector2D p1(rand()%100,rand()%100);
Vector2D p2(rand()%100,rand()%100);
obs_i->appendVertex(p1);
obs_i->appendVertex(p2);
xml_parser_write.obstacles.push_back(obs_i);
}
xml_parser_write.save(filename);
xml_parser_read.load(filename);
assert(xml_parser_read.agents.size() == Nped);
assert(xml_parser_read.obstacles.size() == Nobs);
for(size_t i=0; i<Nped; i++)
{
assert(fabs(xml_parser_read.agents[i]->getPosition().x() - xml_parser_write.agents[i]->getPosition().x()) < eps);
assert(fabs(xml_parser_read.agents[i]->getPosition().y() - xml_parser_write.agents[i]->getPosition().y()) < eps);
assert(fabs(xml_parser_read.agents[i]->getGoal().x() - xml_parser_write.agents[i]->getGoal().x()) < eps);
assert(fabs(xml_parser_read.agents[i]->getGoal().y() - xml_parser_write.agents[i]->getGoal().y()) < eps);
//assert(xml_parser_read.agents[i]->getGoalType() == xml_parser_write.agents[i]->getGoalType());
}
for(size_t i=0; i<Nobs; i++)
{
assert(fabs(xml_parser_read.obstacles[i]->vertex(0).x() - xml_parser_write.obstacles[i]->vertex(0).x()) < eps);
assert(fabs(xml_parser_read.obstacles[i]->vertex(0).y() - xml_parser_write.obstacles[i]->vertex(0).y()) < eps);
assert(fabs(xml_parser_read.obstacles[i]->vertex(1).x() - xml_parser_write.obstacles[i]->vertex(1).x()) < eps);
assert(fabs(xml_parser_read.obstacles[i]->vertex(1).y() - xml_parser_write.obstacles[i]->vertex(1).y()) < eps);
}
std::cout << "Testing XML Parser finished successfully" << std::endl;
for(int i=0; i<xml_parser_read.agents.size(); i++)
delete xml_parser_read.agents[i];
for(int i=0; i<xml_parser_read.obstacles.size(); i++)
delete xml_parser_read.obstacles[i];
for(int i=0; i<xml_parser_write.agents.size(); i++)
delete xml_parser_write.agents[i];
for(int i=0; i<xml_parser_write.obstacles.size(); i++)
delete xml_parser_write.obstacles[i];
}
#endif // XMLPARSERTEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment