Commit c2ff49a3 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Merge branch 'local_changes' into v0.7

parents f704b79e b8468c5e
......@@ -11,6 +11,10 @@ All notable changes to this project will be documented in this file.
- Sources for generating agents at runtime. Parameter are frequency(agents per seconds) and maximum number
- Option to color the pedestrians by group,spotlight,velocity,group,knowledge,router,final_goal,intermediate_goal ( <trajectories format="xml-plain" fps="8" color_mode="group">)
#### JPSVIS
- Display the geometry structure individual room/subroom
- Now build on OSX
### Changed
-
-
......
......@@ -890,7 +890,8 @@ bool ArgumentParser::ParseStrategyNodeToObject(const TiXmlNode &strategyNode)
if( ! strategyNode.FirstChild(query.c_str()))
{
query="exitCrossingStrategy";
Log->Write("WARNING:\t exitCrossingStrategy is deprecated. Please consider using \"exit_crossing_strategy\" ");
Log->Write("ERROR:\t the keyword exitCrossingStrategy is deprecated. Please consider using \"exit_crossing_strategy\" in the ini file");
return false;
}
if (strategyNode.FirstChild(query.c_str())) {
......
......@@ -119,7 +119,7 @@ string Hline::GetDescription() const
{
string geometry;
char tmp[CLENGTH] = "";
sprintf(tmp,"\t\t<hline ID=\"%d\" color = \"250\" caption=\"h_%d_%d\">\n",GetUniqueID(),GetID(),GetUniqueID());
sprintf(tmp,"\t\t<hline ID=\"%d\" room_id=\"%d\" subroom_id=\"%d\" color = \"250\" caption=\"h_%d_%d\">\n",GetUniqueID(),_room1->GetID(),_subRoom1->GetSubRoomID(),GetID(),GetUniqueID());
geometry.append(tmp);
//geometry.append("\t\t<door color=\"250\">\n");
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\" zPos=\"%.2f\"/>\n",
......
......@@ -535,14 +535,14 @@ double SubRoom::GetCosAngleWithHorizontal() const
}
void SubRoom::CheckObstacles()
bool SubRoom::CheckObstacles()
{
for(unsigned int i = 0; i<_walls.size(); i++) {
for(unsigned int j = 0; j<_obstacles.size(); j++) {
if(_obstacles[j]->IntersectWithLine(_walls[i])) {
Log->Write("INFO: \tthe obstacle id [%d] is intersection with subroom [%d]",_obstacles[j]->GetId(),_id);
Log->Write("INFO: \tthe triangulation will not work.");
exit(EXIT_FAILURE);
Log->Write("ERROR: \tthe obstacle id [%d] is intersection with subroom [%d]",_obstacles[j]->GetId(),_id);
Log->Write(" : \tthe triangulation will not work.");
return false;
}
}
}
......
......@@ -236,7 +236,7 @@ public:
* e.g. simple polygons
* no intersection between the walls and the obstacles.
*/
void CheckObstacles();
bool CheckObstacles();
/**
* Check the subroom for possible errors and
......
......@@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<max_sim_time>900</max_sim_time>
<events_file>events.xml</events_file>
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<trajectories format="xml-plain" fps="8" color_mode="group">
<file location="testSchulTrajectories.xml" />
<socket hostname="127.0.0.1" port="8989"/>
</trajectories>
......@@ -69,16 +69,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
</agents_distribution>
<agents_sources><!-- frequency in persons/minute -->
<source id="1" frequency="60" agents_max="150" router_id="1" goal_id="" route_id="" caption="source 1">
<polygon>
<vertex px="6.0" py="2.0" />
<vertex px="6.0" py="0.0" />
<vertex px="0.0" py="0.0" />
<vertex px="0.0" py="6.0" />
<vertex px="6.0" py="6.0" />
<vertex px="6.0" py="4.0" />
</polygon>
</source>
<source id="1" group_id="0" frequency="60" agents_max="150" router_id="1" goal_id="" route_id="" caption="source 1"/>
</agents_sources>
</agents>
......
......@@ -34,7 +34,7 @@ xsi:noNamespaceSchemaLocation="http://xsd.jupedsim.org/0.6/jps_ini_core.xsd">
<!--persons information and distribution -->
<agents operational_model_id="2">
<agents_distribution>
<group group_id="0" agent_parameter_id="1" room_id="0" subroom_id="0" number="1" goal_id="-1" router_id="1" />
<group group_id="0" agent_parameter_id="1" room_id="0" subroom_id="0" number="1" goal_id="-1" router_id="1" pre_movement_mean="15" pre_movement_sigma="0.4"/>
</agents_distribution>
</agents>
......
......@@ -198,7 +198,12 @@ void GompertzModel::ComputeNextTimeStep(double current, double deltaT, Building*
//if they are in the same subroom
Point p1 = ped->GetPos();
Point p2 = ped1->GetPos();
//subrooms to consider when looking for neighbour for the 3d visibility
vector<SubRoom*> emptyVector;
emptyVector.push_back(subroom);
emptyVector.push_back(building->GetRoom(ped1->GetRoomID())->GetSubRoom(ped1->GetSubRoomID()));
bool isVisible = building->IsVisible(p1, p2, emptyVector, false);
if (!isVisible)
continue;
......
......@@ -112,6 +112,7 @@ double AccessPoint::GetDistanceTo(int UID)
Log->Write("ERROR:\tNo route to destination [ %d ]",UID);
Log->Write("ERROR:\tCheck your configuration file");
Dump();
//return 0;
exit(EXIT_FAILURE);
}
return _mapDestToDist[UID];
......
......@@ -490,10 +490,11 @@ bool GlobalRouter::Init(Building* building)
}
//dumping the complete system
//DumpAccessPoints(20); //exit(0);
//DumpAccessPoints(4817);
//DumpAccessPoints(4912); //exit(0);
//DumpAccessPoints(-1); exit(0);
//vector<string> rooms;
//rooms.push_back("Verteilerebene_001");
//rooms.push_back("Verteilerebene");
//WriteGraphGV("routing_graph.gv",FINAL_DEST_OUT,rooms); exit(0);
//WriteGraphGV("routing_graph.gv",4,rooms);exit(0);
Log->Write("INFO:\tDone with the Global Router Engine!");
......@@ -774,8 +775,8 @@ int GlobalRouter::FindExit(Pedestrian* ped)
// ped->Dump(2);
// //exit(0);
// }
if (nextDestination == -1) {
return GetBestDefaultRandomExit(ped);
} else {
......@@ -1075,11 +1076,11 @@ void GlobalRouter::WriteGraphGV(string filename, int finalDestination,
}
//header
graph_file << "## Produced by OPS_GCFM" << endl;
graph_file << "## Produced by JuPedSim" << endl;
//graph_file << "##comand: \" sfdp -Goverlap=prism -Gcharset=latin1"<<filename <<"| gvmap -e | neato -Ecolor=\"#55555522\" -n2 -Tpng > "<< filename<<".png \""<<endl;
graph_file << "##Command to produce the output: \"neato -n -s -Tpng "
<< filename << " > " << filename << ".png\"" << endl;
graph_file << "digraph OPS_GCFM_ROUTING {" << endl;
graph_file << "digraph JUPEDSIM_ROUTING {" << endl;
graph_file << "overlap=scale;" << endl;
graph_file << "splines=false;" << endl;
graph_file << "fontsize=20;" << endl;
......@@ -1089,16 +1090,26 @@ void GlobalRouter::WriteGraphGV(string filename, int finalDestination,
vector<int> rooms_ids = vector<int>();
if (rooms_captions.empty()) {
if (rooms_captions.empty())
{
// then all rooms should be printed
for (int i = 0; i < _building->GetNumberOfRooms(); i++) {
rooms_ids.push_back(i);
for(auto && itroom:_building->GetAllRooms())
{
for(const auto & it_sub:itroom.second->GetAllSubRooms())
{
rooms_ids.push_back(it_sub.second->GetUID());
}
}
} else {
for (unsigned int i = 0; i < rooms_captions.size(); i++) {
rooms_ids.push_back(
_building->GetRoom(rooms_captions[i])->GetID());
for (auto && caption: rooms_captions)
{
for(const auto & it_sub:_building->GetRoom(caption)->GetAllSubRooms())
{
rooms_ids.push_back(it_sub.second->GetUID());
cout <<"adding: "<<it_sub.second->GetUID()<<endl;
}
}
}
......@@ -1111,10 +1122,10 @@ void GlobalRouter::WriteGraphGV(string filename, int finalDestination,
// check for valid room
int room_id = from_AP->GetConnectingRoom1();
int room_id1=from_AP->GetConnectingRoom2();
if (IsElementInVector(rooms_ids, room_id) == false)
if ( (IsElementInVector(rooms_ids, room_id) == false) and (IsElementInVector(rooms_ids, room_id1) == false) )
continue;
double px = from_AP->GetCentre().GetX();
double py = from_AP->GetCentre().GetY();
//graph_file << from_door <<" [shape=ellipse, pos=\""<<px<<", "<<py<<" \"] ;"<<endl;
......@@ -1253,6 +1264,12 @@ void GlobalRouter::TriangulateGeometry()
for (const auto & line: edges)
{
//reduce edge that are too close 50 cm is assumed
if ( (MinDistanceToHlines(line.GetCentre(),*subroom)<0.5)
//and MinAngle(P0,P1,P2)<20.0
)
continue;
if((IsWall(line)==false) && (IsCrossing(line)==false)
&& (IsTransition(line)==false) && (IsHline(line)==false))
{
......@@ -1577,3 +1594,69 @@ bool GlobalRouter::IsHline(const Line& line) const
}
return false;
}
double GlobalRouter::MinDistanceToHlines(const Point& point, const SubRoom& sub)
{
double minDist=FLT_MAX;
for(const auto & hline: sub.GetAllHlines())
{
double dist=hline->DistTo(point);
if (dist<minDist)
minDist=dist;
}
for(const auto & cross: sub.GetAllCrossings())
{
double dist=cross->DistTo(point);
if (dist<minDist)
minDist=dist;
}
for(const auto & trans: sub.GetAllTransitions())
{
double dist=trans->DistTo(point);
if (dist<minDist)
minDist=dist;
}
for(const auto & wall: sub.GetAllWalls())
{
double dist=wall.DistTo(point);
if (dist<minDist)
minDist=dist;
}
//also to the obstacles
for (const auto& obst: sub.GetAllObstacles())
{
for(const auto & wall: obst->GetAllWalls())
{
double dist=wall.DistTo(point);
if (dist<minDist)
minDist=dist;
}
}
return minDist;
}
double GlobalRouter::MinAngle(const Point& p1, const Point& p2, const Point& p3)
{
double a = (p1 - p2).NormSquare();
double b = (p1 - p3).NormSquare();
double c = (p3 - p2).NormSquare();
double alpha=acos((a+b-c)/(2*sqrt(a)*sqrt(b)));
double beta=acos((a+c-b)/(2*sqrt(a)*sqrt(c)));
double gamma=acos((c+b-a)/(2*sqrt(c)*sqrt(b)));
//cout <<"minimum angle: " <<std::min({alpha, beta, gamma}) * (180.0 / M_PI)<<endl;
if(fabs(alpha+beta+gamma-M_PI)<J_EPS)
{
return std::min({alpha, beta, gamma}) * (180.0 / M_PI);
}
else
{
Log->Write("ERROR:\t Error in angle calculation");
exit(EXIT_FAILURE);
}
return 0;
}
......@@ -194,6 +194,17 @@ private:
*/
bool IsHline(const Line& line) const;
/**
* @return the minimum distance between the point and any line in the subroom.
* This include walls,hline,crossings,transitions,obstacles
*/
double MinDistanceToHlines(const Point& point, const SubRoom& sub);
/**
* @return the minimal angle in the the triangle formed by the three points
*/
double MinAngle(const Point& p1, const Point& p2, const Point& p3);
private:
int **_pathsMatrix;
double **_distMatrix;
......
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