Commit ece4b07f authored by Thomas's avatar Thomas

Merge branch 'master' of cgogn:~kraemer/CGoGN

+ correction in particle_cell_2D
Conflicts:

	Apps/Examples/SocialAgents/include/env_generator.hpp
	Apps/Examples/SocialAgents/src/env_map.cpp
parents de0cd3b6 90704e8e
......@@ -148,7 +148,7 @@ void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& close
// sideSize *= 0.2f;
unsigned int nbBuilding=1000;
float height = sideSize/2.0f;
unsigned int side = 3;
unsigned int side = 5;
generateGrid<PFP,EMBV>(map,position,side,side,sideSize,closeMark);
Dart dEnd = map.end();
......
......@@ -218,7 +218,6 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d)
{
map.setCurrentLevel(map.getMinLevel()) ;
Dart dd =d;
do {
if(closeMark.isMarked(dd) /*&& (position[map.phi2(dd)][2]==0.0 || position[map.phi1(map.phi2(dd))][2] ==0.0f)*/) {
......@@ -231,8 +230,6 @@ void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d)
}
dd = map.phi1(dd);
} while (dd!=d);
map.setCurrentLevel(map.getMaxLevel()) ;
}
void EnvMap::getAllFacesOfAgents(Dart d)
......@@ -342,29 +339,6 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo)
void EnvMap::updateMap()
{
// simplifyFaces();
CellMarker m(map, FACE_CELL) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!m.isMarked(d))
{
m.mark(d) ;
std::vector<Agent*>& agents = agentvect[d] ;
for(std::vector<Agent*>::iterator it = agents.begin(); it != agents.end(); ++it)
{
if(!map.sameFace(d, (*it)->part->d))
{
std::cout << "aaaaaaaaaaaaaaaaaaa" << std::endl ;
std::cout << (*it)->part->state << std::endl ;
if(map.sameFace(map.phi2(d), (*it)->part->d))
{
std::cout << "saucisse" << std::endl ;
}
}
}
}
}
subdivideFaces() ;
map.setCurrentLevel(map.getMaxLevel()) ;
}
......@@ -377,7 +351,7 @@ void EnvMap::subdivideFaces()
if(!m.isMarked(d))
{
m.mark(d) ;
if(!closeMark.isMarked(d) && agentvect[d].size() > 5)
if(!closeMark.isMarked(d) && agentvect[d].size() > 3)
{
if(!map.faceIsSubdivided(d))
{
......@@ -389,16 +363,6 @@ void EnvMap::subdivideFaces()
unsigned int cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(d) ;
// std::cout << "cur -> " << cur << " / fLevel -> " << fLevel << " :" ;
// Dart fit = d ;
// do
// {
// unsigned int e = map.getDartEmbedding(FACE_ORBIT, fit) ;
// if(e == EMBNULL) std::cout << " -" ; else std::cout << " " << e ;
// fit = map.phi1(fit) ;
// } while(fit != d) ;
// std::cout << std::endl ;
map.setCurrentLevel(fLevel) ;
std::vector<Dart> marked ;
Dart fit = d ;
......@@ -412,30 +376,10 @@ void EnvMap::subdivideFaces()
Algo::IHM::subdivideFace<PFP>(map, d, position) ;
map.setCurrentLevel(fLevel + 1) ;
// Dart cv = map.phi2(map.phi1(d)) ;
// Dart vit = cv ;
// unsigned int i = 1 ;
// do
// {
// std::cout << " face " << i << " -> " ;
// Dart f = vit ;
// do
// {
// unsigned int e = map.getDartEmbedding(FACE_ORBIT, f) ;
// if(e == EMBNULL) std::cout << " -" ; else std::cout << " " << e ;
// f = map.phi1(f) ;
// } while(f != vit) ;
// std::cout << std::endl ;
// vit = map.alpha1(vit) ;
// ++i ;
// } while(vit != cv) ;
for(std::vector<Dart>::iterator it = marked.begin(); it != marked.end(); ++it)
closeMark.mark(map.phi2(*it)) ;
map.setCurrentLevel(map.getMaxLevel()) ;
for(PFP::AGENTS::iterator it = agents.begin(); it != agents.end(); ++it)
{
resetAgentInFace(*it) ;
......
......@@ -20,7 +20,7 @@ Simulator::Simulator() : agents_(), defaultAgent_(0), globalTime_(0.0f), timeSte
// CGoGN::CityGenerator::generateToboggan<PFP>(envMap.map,envMap.position,envMap.closeMark,100,0.25,200,10);
// std::cout << "simplify" << std::endl;
// envMap.simplify();
envMap.simplify();
envMap.map.init();
std::cout << "setup scenario" << std::endl;
setupScenario();
......
......@@ -87,7 +87,7 @@ void MyGlutWin::initGUI()
bool MyGlutWin::reachedGoal(Simulator* sim)
{
if((int(sim->globalTime_)%1000)==0)
if((int(sim->globalTime_)%500)==0)
std::random_shuffle( sim->goals.begin(), sim->goals.end() );
// /* Check if all agents have reached their goals. */
// for (size_t i = 0; i < sim->getNumAgents(); ++i) {
......@@ -381,7 +381,7 @@ void updateVisualization(Simulator* sim)
void MyGlutWin::animate(void)
{
// if(int(sim->globalTime_)%2)
// CGoGN::CityGenerator::animateCity<PFP,PFP::TVEC3,PFP::TAB_AGENTVECT>(sim->envMap.map,sim->envMap.position,sim->envMap.agentvect,sim->envMap.closeMark,sim->envMap.newBuildings);
// CGoGN::CityGenerator::animateCity<PFP,PFP::TVEC3,PFP::TAB_AGENTVECT>(sim->envMap.map,sim->envMap.position,sim->envMap.agentvect,sim->envMap.closeMark,sim->envMap.newBuildings);
// sim->envMap.map.check();
// posToReach[0] += sin(rand());
// posToReach[1] += cos(rand());
......
......@@ -174,6 +174,14 @@ public:
*/
bool edgeIsSubdivided(Dart d) ;
/**
* Return true if the edge of d in the current level map
* is subdivided to the next level,
* none of its resulting edges is in turn subdivided to the next level
* and the middle vertex is of degree 2
*/
bool edgeCanBeCoarsened(Dart d) ;
/**
* Return true if the face of d in the current level map
* has already been subdivided to the next level
......@@ -183,7 +191,7 @@ public:
/**
* Return true if the face of d in the current level map
* is subdivided to the next level
* and none of these resulting faces is in turn subdivided to the next level
* and none of its resulting faces is in turn subdivided to the next level
*/
bool faceIsSubdividedOnce(Dart d) ;
} ;
......
......@@ -144,6 +144,8 @@ template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(map.edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ;
}
template <typename PFP>
......
......@@ -131,18 +131,10 @@ Dart ImplicitHierarchicalMap::faceOldestDart(Dart d)
bool ImplicitHierarchicalMap::edgeIsSubdivided(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
// Dart d2 = phi2(d) ;
// ++m_curLevel ;
// Dart d2_l = phi2(d) ;
// --m_curLevel ;
// if(d2 != d2_l)
// return true ;
// else
// return false ;
Dart d1 = phi1(d) ;
++m_curLevel ;
// Dart d2_l = phi2(d) ;
Dart d1_l = phi1(d) ;
--m_curLevel ;
if(d1 != d1_l)
......@@ -151,6 +143,28 @@ bool ImplicitHierarchicalMap::edgeIsSubdivided(Dart d)
return false ;
}
bool ImplicitHierarchicalMap::edgeCanBeCoarsened(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
bool subd = false ;
bool subdOnce = true ;
bool degree2 = false ;
if(edgeIsSubdivided(d))
{
subd = true ;
Dart d2 = phi2(d) ;
++m_curLevel ;
if(vertexDegree(phi1(d)) == 2)
{
degree2 = true ;
if(edgeIsSubdivided(d) || edgeIsSubdivided(d2))
subdOnce = false ;
}
--m_curLevel ;
}
return subd && degree2 && subdOnce ;
}
bool ImplicitHierarchicalMap::faceIsSubdivided(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
......
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