Commit 0390a0a5 authored by Ulrich Kemloh's avatar Ulrich Kemloh

More control over the triangulation: minimum_distance_between_edges and

minimum_angle_in_triangle

Usage: <navigation_mesh method="triangulation"
minimum_distance_between_edges="0.5" minimum_angle_in_triangles="0"
use_for_local_planning="true" />
parent c2ff49a3
......@@ -9,7 +9,8 @@ All notable changes to this project will be documented in this file.
- Boost testcases for geometry functions
- risk tolerance factor (value in [0 1]) for pedestrian. Pedestrians with high values are likely to take more risks.
- 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">)
- Option to color the pedestrians by group,spotlight,velocity,group,knowledge,router,final_goal,intermediate_goal. Usage: ( <trajectories format="xml-plain" fps="8" color_mode="group"> )
- More control over the triangulation specially to avoid skinny triangles. Usage: <navigation_mesh method="triangulation" minimum_distance_between_edges="0.5" minimum_angle_in_triangles="20" use_for_local_planning="true" />
#### JPSVIS
- Display the geometry structure individual room/subroom
......
......@@ -49,7 +49,7 @@
using namespace std;
GlobalRouter::GlobalRouter() :
Router()
Router()
{
_accessPoints = map<int, AccessPoint*>();
_map_id_to_index = std::map<int, int>();
......@@ -1039,12 +1039,12 @@ void GlobalRouter::GetRelevantRoutesTofinalDestination(Pedestrian *ped, vector<A
}
}
}
// if(relevantAPS.size()==2){
// cout<<"alternative wege: "<<relevantAPS.size()<<endl;
// cout<<"ap1: "<<relevantAPS[0]->GetID()<<endl;
// cout<<"ap2: "<<relevantAPS[1]->GetID()<<endl;
// getc(stdin);
// }
// if(relevantAPS.size()==2){
// cout<<"alternative wege: "<<relevantAPS.size()<<endl;
// cout<<"ap1: "<<relevantAPS[0]->GetID()<<endl;
// cout<<"ap2: "<<relevantAPS[1]->GetID()<<endl;
// getc(stdin);
// }
}
SubRoom* GlobalRouter::GetCommonSubRoom(Crossing* c1, Crossing* c2)
......@@ -1265,9 +1265,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
)
if (MinDistanceToHlines(line.GetCentre(),
*subroom)
< _minDistanceBetweenTriangleEdges)
continue;
if (MinAngle(P0, P1, P2) < _minAngleInTriangles)
continue;
if((IsWall(line)==false) && (IsCrossing(line)==false)
......@@ -1295,106 +1298,106 @@ void GlobalRouter::TriangulateGeometry()
bool GlobalRouter::GenerateNavigationMesh()
{
// //Navigation mesh implementation
// NavMesh* nv= new NavMesh(_building);
// nv->BuildNavMesh();
// _building->SaveGeometry("test_geometry.xml");
// exit(0);
// //nv->WriteToFileTraVisTo()
//
// const std::vector<NavMesh::JEdge*>& edges = nv->GetEdges();
//
// for(const auto & edge: edges)
// {
// //construct and add a new navigation line if non existing
// Line line(edge->pStart.pPos,edge->pEnd.pPos);
// bool isEdge=false;
//
// //check if it is already a crossing
// const map<int, Crossing*>& crossings = _building->GetAllCrossings();
// for (const auto & crossing: crossings)
// {
// Crossing* cross=crossing.second;
// if(line.operator ==(*cross))
// {
// isEdge=true;
// break;
// }
// }
// if(isEdge) continue;
//
//
// //check if it is already a transition
// const map<int, Transition*>& transitions = _building->GetAllTransitions();
// for (const auto & transition: transitions)
// {
// Transition* trans=transition.second;
// if(line.operator ==(*trans))
// {
// isEdge=true;
// break;
// }
// }
// if(isEdge) continue;
//
// //check if it is already a
// const map<int, Hline*>& hlines = _building->GetAllHlines();
// for (const auto & hline: hlines)
// {
// Hline* navLine=hline.second;
// if(line.operator ==(*navLine))
// {
// isEdge=true;
// break;
// }
// }
// if(isEdge) continue;
//
//
// Hline* h = new Hline();
// h->SetID(hlines.size());
// int assigned=0;
//
// //look for the room/subroom containing the new edge
// const vector<Room*>& rooms=_building->GetAllRooms();
// for(const auto & room: rooms)
// {
// const vector<SubRoom*>& subrooms= room->GetAllSubRooms();
//
// for(const auto & subroom: subrooms)
// {
// if(subroom->IsInSubRoom(line.GetCentre()))
// {
// h->SetRoom1(room);
// h->SetSubRoom1(subroom);
// assigned++;
// }
// }
// }
//
// if(assigned!=1)
// {
// Log->Write("WARNING:\t a navigation line from the mesh was not correctly assigned");
// return false;
// }
// //add the new edge as navigation line
//
// h->SetPoint1(edge->pStart.pPos);
// h->SetPoint2(edge->pEnd.pPos);
// h->GetSubRoom1()->AddHline(h); //double linked ??
// _building->AddHline(h);
//
// }
//
// //string geometry;
// //nv->WriteToString(geometry);
// //Write("<geometry>");
// //Write(geometry);
// //Write("</geometry>");
// //nv->WriteToFile(building->GetProjectFilename()+".full.nav");
//
// //cout<<"bye"<<endl;
// delete nv;
// //Navigation mesh implementation
// NavMesh* nv= new NavMesh(_building);
// nv->BuildNavMesh();
// _building->SaveGeometry("test_geometry.xml");
// exit(0);
// //nv->WriteToFileTraVisTo()
//
// const std::vector<NavMesh::JEdge*>& edges = nv->GetEdges();
//
// for(const auto & edge: edges)
// {
// //construct and add a new navigation line if non existing
// Line line(edge->pStart.pPos,edge->pEnd.pPos);
// bool isEdge=false;
//
// //check if it is already a crossing
// const map<int, Crossing*>& crossings = _building->GetAllCrossings();
// for (const auto & crossing: crossings)
// {
// Crossing* cross=crossing.second;
// if(line.operator ==(*cross))
// {
// isEdge=true;
// break;
// }
// }
// if(isEdge) continue;
//
//
// //check if it is already a transition
// const map<int, Transition*>& transitions = _building->GetAllTransitions();
// for (const auto & transition: transitions)
// {
// Transition* trans=transition.second;
// if(line.operator ==(*trans))
// {
// isEdge=true;
// break;
// }
// }
// if(isEdge) continue;
//
// //check if it is already a
// const map<int, Hline*>& hlines = _building->GetAllHlines();
// for (const auto & hline: hlines)
// {
// Hline* navLine=hline.second;
// if(line.operator ==(*navLine))
// {
// isEdge=true;
// break;
// }
// }
// if(isEdge) continue;
//
//
// Hline* h = new Hline();
// h->SetID(hlines.size());
// int assigned=0;
//
// //look for the room/subroom containing the new edge
// const vector<Room*>& rooms=_building->GetAllRooms();
// for(const auto & room: rooms)
// {
// const vector<SubRoom*>& subrooms= room->GetAllSubRooms();
//
// for(const auto & subroom: subrooms)
// {
// if(subroom->IsInSubRoom(line.GetCentre()))
// {
// h->SetRoom1(room);
// h->SetSubRoom1(subroom);
// assigned++;
// }
// }
// }
//
// if(assigned!=1)
// {
// Log->Write("WARNING:\t a navigation line from the mesh was not correctly assigned");
// return false;
// }
// //add the new edge as navigation line
//
// h->SetPoint1(edge->pStart.pPos);
// h->SetPoint2(edge->pEnd.pPos);
// h->GetSubRoom1()->AddHline(h); //double linked ??
// _building->AddHline(h);
//
// }
//
// //string geometry;
// //nv->WriteToString(geometry);
// //Write("<geometry>");
// //Write(geometry);
// //Write("</geometry>");
// //nv->WriteToFile(building->GetProjectFilename()+".full.nav");
//
// //cout<<"bye"<<endl;
// delete nv;
return true;
}
......@@ -1450,6 +1453,8 @@ string GlobalRouter::GetRoutingInfoFile()
{
Log->Write("WARNING:\t only triangulation is supported for the mesh. You supplied [%s]",method.c_str());
}
_minDistanceBetweenTriangleEdges=xmltof(para->Attribute("minimum_distance_between_edges"),-FLT_MAX);
_minAngleInTriangles=xmltof(para->Attribute("minimum_angle_in_triangles"),-FLT_MAX);
}
......
......@@ -213,7 +213,10 @@ private:
//via the routing file. The mesh will only be used for computing the distance.
bool _useMeshForLocalNavigation=true;
bool _generateNavigationMesh=false;
std::vector< int > _tmpPedPath;
//used to filter skinny edges in triangulation
double _minDistanceBetweenTriangleEdges=-FLT_MAX;
double _minAngleInTriangles=-FLT_MAX;
std::vector<int> _tmpPedPath;
std::map<int,int> _map_id_to_index;
std::map<int,int> _map_index_to_id;
///map the internal crossings/transition id to
......
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