Commit 48b7797e authored by Pierre Kraemer's avatar Pierre Kraemer

Test commit

parent af5763f3
...@@ -2,14 +2,12 @@ cmake_minimum_required(VERSION 2.6) ...@@ -2,14 +2,12 @@ cmake_minimum_required(VERSION 2.6)
project(SocialAgents) project(SocialAgents)
SET(CMAKE_BUILD_TYPE Debug) SET(CMAKE_BUILD_TYPE Release)
link_directories( link_directories(
${CGoGN_ROOT_DIR}/lib/Debug/ ${CGoGN_ROOT_DIR}/lib/Debug/
${CGoGN_ROOT_DIR}/lib/Release/) ${CGoGN_ROOT_DIR}/lib/Release/)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3")
# define includes path # define includes path
include_directories( include_directories(
/usr/include/libxml2/ /usr/include/libxml2/
...@@ -22,8 +20,6 @@ include_directories( ...@@ -22,8 +20,6 @@ include_directories(
${CGoGN_ROOT_DIR}/ThirdParty/Zinri ${CGoGN_ROOT_DIR}/ThirdParty/Zinri
) )
#define exec to compile #define exec to compile
add_executable(socialAgents ./src/viewer.cpp ./src/env_map.cpp ./src/agent.cpp ./src/simulator.cpp ) add_executable(socialAgents ./src/viewer.cpp ./src/env_map.cpp ./src/agent.cpp ./src/simulator.cpp )
target_link_libraries( socialAgents container topology utils algo ${COMMON_LIBS} ) target_link_libraries( socialAgents container topology utils algo ${COMMON_LIBS} )
......
...@@ -34,7 +34,7 @@ void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& close ...@@ -34,7 +34,7 @@ void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& close
// sideSize *= 0.2f; // sideSize *= 0.2f;
unsigned int nbBuilding=1000; unsigned int nbBuilding=1000;
float height = sideSize/2.0f; float height = sideSize/2.0f;
unsigned int side = 40; unsigned int side = 25;
generateGrid<PFP,EMBV>(map,position,side,side,sideSize,closeMark); generateGrid<PFP,EMBV>(map,position,side,side,sideSize,closeMark);
Dart dEnd = map.end(); Dart dEnd = map.end();
...@@ -568,4 +568,4 @@ void generateBridge(typename PFP::MAP& map, EMBV& position, unsigned int cX, uns ...@@ -568,4 +568,4 @@ void generateBridge(typename PFP::MAP& map, EMBV& position, unsigned int cX, uns
} }
} }
\ No newline at end of file
...@@ -227,7 +227,7 @@ void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d) ...@@ -227,7 +227,7 @@ void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d)
(*it)->insertObstacleNeighbor(dd); (*it)->insertObstacleNeighbor(dd);
// } // }
} }
return; // return;
} }
dd = map.phi1(dd); dd = map.phi1(dd);
} while (dd!=d); } while (dd!=d);
...@@ -340,7 +340,7 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo) ...@@ -340,7 +340,7 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo)
void EnvMap::updateMap() void EnvMap::updateMap()
{ {
// simplifyFaces(); // simplifyFaces();
subdivideFaces(); subdivideFaces() ;
map.setCurrentLevel(map.getMaxLevel()) ; map.setCurrentLevel(map.getMaxLevel()) ;
} }
...@@ -352,18 +352,38 @@ void EnvMap::subdivideFaces() ...@@ -352,18 +352,38 @@ void EnvMap::subdivideFaces()
if(!m.isMarked(d)) if(!m.isMarked(d))
{ {
m.mark(d) ; m.mark(d) ;
if(!closeMark.isMarked(d) && agentvect[d].size() > 10) if(!closeMark.isMarked(d) && agentvect[d].size() > 8)
{ {
if(!map.faceIsSubdivided(d)) if(!map.faceIsSubdivided(d))
{ {
std::vector<Agent*> agents ; std::vector<Agent*> agents ;
agents.swap(agentvect[d]) ; agents.swap(agentvect[d]) ;
unsigned int cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(d) ;
map.setCurrentLevel(fLevel) ;
std::vector<Dart> marked ;
Dart fit = d ;
do
{
if(closeMark.isMarked(map.phi2(fit)))
marked.push_back(fit) ;
fit = map.phi1(fit) ;
} while(fit != d) ;
Algo::IHM::subdivideFace<PFP>(map, d, position) ; Algo::IHM::subdivideFace<PFP>(map, d, position) ;
map.setCurrentLevel(fLevel + 1) ;
for(std::vector<Dart>::iterator it = marked.begin(); it != marked.end(); ++it)
closeMark.mark(map.phi2(*it)) ;
for(PFP::AGENTS::iterator it = agents.begin(); it != agents.end(); ++it) for(PFP::AGENTS::iterator it = agents.begin(); it != agents.end(); ++it)
{ {
this->resetAgentInFace(*it) ; resetAgentInFace(*it) ;
agentvect[(*it)->part->d].push_back(*it) ; agentvect[(*it)->part->d].push_back(*it) ;
} }
map.setCurrentLevel(cur) ;
} }
} }
} }
......
...@@ -14,16 +14,17 @@ Simulator::Simulator() : agents_(), defaultAgent_(0), globalTime_(0.0f), timeSte ...@@ -14,16 +14,17 @@ Simulator::Simulator() : agents_(), defaultAgent_(0), globalTime_(0.0f), timeSte
// CGoGN::CityGenerator::generateGrid<PFP,PFP::TVEC3>(envMap.map,envMap.position,100,100,50.0f,envMap.closeMark); // CGoGN::CityGenerator::generateGrid<PFP,PFP::TVEC3>(envMap.map,envMap.position,100,100,50.0f,envMap.closeMark);
envMap.sideSize = 70.0f; envMap.sideSize = 70.0f;
// CGoGN::CityGenerator::generateSmallCity<PFP,PFP::TVEC3>(envMap.map,envMap.position,envMap.closeMark,envMap.sideSize); CGoGN::CityGenerator::generateSmallCity<PFP,PFP::TVEC3>(envMap.map,envMap.position,envMap.closeMark,envMap.sideSize);
CGoGN::CityGenerator::generateAbsolutSpiralOfDeath<PFP>(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100); // CGoGN::CityGenerator::generateAbsolutSpiralOfDeath<PFP>(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100);
std::cout << "simplify" << std::endl; // std::cout << "simplify" << std::endl;
// envMap.simplify(); // envMap.simplify();
envMap.map.init(); envMap.map.init();
std::cout << "setup scenario" << std::endl; std::cout << "setup scenario" << std::endl;
setupHelicoidScenario(1,50); // setupHelicoidScenario(1,50);
setupScenario();
// Dart dStop=envMap.map.begin(); // Dart dStop=envMap.map.begin();
// for(unsigned int i=0;i<5000;++i) envMap.map.next(dStop); // for(unsigned int i=0;i<5000;++i) envMap.map.next(dStop);
......
...@@ -223,13 +223,13 @@ void MyGlutWin::myRedraw() ...@@ -223,13 +223,13 @@ void MyGlutWin::myRedraw()
// } // }
// glEnd(); // glEnd();
glBegin(GL_POINTS); // glBegin(GL_POINTS);
for(unsigned int i = 0; i<4;++i) { // for(unsigned int i = 0; i<4;++i) {
for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) { // for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) {
glVertex3fv(&(*it)[0]); // glVertex3fv(&(*it)[0]);
} // }
} // }
glEnd(); // glEnd();
unsigned int i=0; unsigned int i=0;
for(std::vector<Agent * >::iterator it = sim->agents_.begin() ; it != sim->agents_.end() ; ++ it, ++i) { for(std::vector<Agent * >::iterator it = sim->agents_.begin() ; it != sim->agents_.end() ; ++ it, ++i) {
...@@ -244,7 +244,7 @@ void MyGlutWin::myRedraw() ...@@ -244,7 +244,7 @@ void MyGlutWin::myRedraw()
//draw containing center face //draw containing center face
glColor3f(0,0,1); glColor3f(0,0,1);
glLineWidth(4.0f); glLineWidth(4.0f);
renderFace(sim->envMap,(*it)->nearestDart); renderFace(sim->envMap,(*it)->part->d);
glLineWidth(1.0f); glLineWidth(1.0f);
// //draw displacement // //draw displacement
...@@ -254,18 +254,18 @@ void MyGlutWin::myRedraw() ...@@ -254,18 +254,18 @@ void MyGlutWin::myRedraw()
// glEnd(); // glEnd();
// //and prediction triangle // //and prediction triangle
// glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0); glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0);
// glLineWidth(5.0f); glLineWidth(5.0f);
// renderPredictionTriangle(sim->envMap,(*it)->nearestDart,(*it)->part->m_position); renderPredictionTriangle(sim->envMap,(*it)->part->d,(*it)->part->m_position);
// glLineWidth(1.0f); glLineWidth(1.0f);
//draw next goal //draw next goal
glBegin(GL_LINES); // glBegin(GL_LINES);
glVertex3f((*it)->part->m_position[0],(*it)->part->m_position[1],(*it)->part->m_position[2]); // glVertex3f((*it)->part->m_position[0],(*it)->part->m_position[1],(*it)->part->m_position[2]);
glVertex3f((*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][0], // glVertex3f((*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][0],
(*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][1], // (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][1],
(*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][2]); // (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][2]);
glEnd(); // glEnd();
} }
// glCircle3i((*it)->position_[0],(*it)->position_[1],(*it)->neighborDist_); // glCircle3i((*it)->position_[0],(*it)->position_[1],(*it)->neighborDist_);
...@@ -403,8 +403,8 @@ void MyGlutWin::animate(void) ...@@ -403,8 +403,8 @@ void MyGlutWin::animate(void)
// std::cout << "pos to reach : " << posToReach << std::endl; // std::cout << "pos to reach : " << posToReach << std::endl;
// std::cout << sim->getGlobalTime() << " " << std::endl; // std::cout << sim->getGlobalTime() << " " << std::endl;
updateVisualization(sim); updateVisualization(sim);
// sim->setPreferredVelocities(posToReach); sim->setPreferredVelocities(posToReach);
sim->setPreferredPathVelocities(); // sim->setPreferredPathVelocities();
sim->doStep(); sim->doStep();
// sim->envMap.simplify(); // sim->envMap.simplify();
glutPostRedisplay(); glutPostRedisplay();
...@@ -628,6 +628,10 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -628,6 +628,10 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
render_anim=!render_anim; render_anim=!render_anim;
} }
break; break;
case 'c': {
sim->envMap.map.check();
}
break;
} }
updateUI(); updateUI();
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/map_glRender.h" #include "Algo/Render/map_glRender.h"
#include "Algo/Render/vbo_MapRender.h" #include "Algo/Render/vbo_MapRender.h"
#include "Topology/generic/ecell.h"
#include "Algo/Render/topo_vboRender.h" #include "Algo/Render/topo_vboRender.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -531,7 +531,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -531,7 +531,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
unsigned int nbVertices = myMap.getNbOrbits(VERTEX_ORBIT) ; unsigned int nbVertices = myMap.getNbOrbits(VERTEX_ORBIT) ;
GLint t1 = glutGet(GLUT_ELAPSED_TIME); GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Decimation::decimate<PFP>(myMap, Algo::Decimation::S_EdgeLength, Algo::Decimation::A_QEM, position, nbVertices * 0.95) ; Algo::Decimation::decimate<PFP>(myMap, Algo::Decimation::S_QEM, Algo::Decimation::A_QEM, position, nbVertices * 0.75) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME); GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f; GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "decimation: "<< seconds << "sec" << std::endl; std::cout << "decimation: "<< seconds << "sec" << std::endl;
......
...@@ -84,11 +84,7 @@ inline Dart ImplicitHierarchicalMap::phi1(Dart d) ...@@ -84,11 +84,7 @@ inline Dart ImplicitHierarchicalMap::phi1(Dart d)
else else
{ {
while(m_edgeId[it] != edgeId) while(m_edgeId[it] != edgeId)
{
if(Map2::phi2(it) == it)
std::cout << "fix point in the middle" << std::endl ;
it = Map2::alpha_1(it) ; it = Map2::alpha_1(it) ;
}
} }
} while(!finished) ; } while(!finished) ;
return it ; return it ;
...@@ -100,7 +96,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d) ...@@ -100,7 +96,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d)
bool finished = false ; bool finished = false ;
Dart it = Map2::phi_1(d) ; Dart it = Map2::phi_1(d) ;
unsigned int edgeId = m_edgeId[it] ; unsigned int edgeId = m_edgeId[it] ;
do do
{ {
if(m_dartLevel[it] <= m_curLevel) if(m_dartLevel[it] <= m_curLevel)
...@@ -112,21 +107,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d) ...@@ -112,21 +107,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d)
it = Map2::phi_1(Map2::phi2(it)) ; it = Map2::phi_1(Map2::phi2(it)) ;
} }
} while(!finished) ; } while(!finished) ;
// do
// {
// if(m_dartLevel[it] <= m_curLevel)
// finished = true ;
// else
// {
// do
// {
// it = Map2::alpha1(it) ;
// } while(m_edgeId[it] != edgeId) ;
// it = Map2::phi2(it) ;
// }
// } while(!finished) ;
return it ; return it ;
} }
...@@ -329,8 +309,6 @@ inline unsigned int ImplicitHierarchicalMap::edgeLevel(Dart d) ...@@ -329,8 +309,6 @@ inline unsigned int ImplicitHierarchicalMap::edgeLevel(Dart d)
return ld < ldd ? ldd : ld ; // insertion levels of its two darts return ld < ldd ? ldd : ld ; // insertion levels of its two darts
} }
template <typename T> template <typename T>
T& AttributeHandler_IHM<T>::operator[](Dart d) T& AttributeHandler_IHM<T>::operator[](Dart d)
{ {
......
...@@ -128,7 +128,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position ...@@ -128,7 +128,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
while(dd != ne) // turn around the face and insert new edges while(dd != ne) // turn around the face and insert new edges
{ // linked to the central vertex { // linked to the central vertex
Dart next = map.phi1(map.phi1(dd)) ; Dart next = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, map.phi1(ne)) ; map.splitFace(map.phi1(ne), dd) ;
Dart nne = map.alpha1(dd) ; Dart nne = map.alpha1(dd) ;
id = map.getNewEdgeId() ; id = map.getNewEdgeId() ;
map.setEdgeId(nne, id) ; map.setEdgeId(nne, id) ;
......
#ifndef __MULTIATTRIB_CONTAINER__ /*******************************************************************************
#define __MULTIATTRIB_CONTAINER__ * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
#include "sizeblock.h" * Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
#include "holeblockref.h" * *
#include "attribmv.h" * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library 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 Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __ATTRIB_CONTAINER__
#define __ATTRIB_CONTAINER__
#include "Container/sizeblock.h"
#include "Container/holeblockref.h"
#include "Container/attribmv.h"
#include <vector> #include <vector>
#include <map> #include <map>
...@@ -105,7 +129,6 @@ protected: ...@@ -105,7 +129,6 @@ protected:
std::map< std::string, RegisteredBaseAttribute* >* m_attributes_registry_map; std::map< std::string, RegisteredBaseAttribute* >* m_attributes_registry_map;
public: public:
/** /**
* constante d'attribut inconnu * constante d'attribut inconnu
*/ */
...@@ -232,8 +255,8 @@ public: ...@@ -232,8 +255,8 @@ public:
unsigned int getNbAttributes() unsigned int getNbAttributes()
{ {
for (unsigned int i =0; i<m_tableAttribs.size(); ++i) for (unsigned int i = 0; i < m_tableAttribs.size(); ++i)
std::cout <<" table ptr:"<< m_tableAttribs[i] << std::endl; std::cout << "table ptr:" << m_tableAttribs[i] << std::endl;
return m_tableAttribs.size(); return m_tableAttribs.size();
} }
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library 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 Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __HOLE_BLOCK_REF__ #ifndef __HOLE_BLOCK_REF__
#define __HOLE_BLOCK_REF__ #define __HOLE_BLOCK_REF__
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include "sizeblock.h" #include "Container/sizeblock.h"
namespace CGoGN namespace CGoGN
{ {
//WARNING WE USED SHORT INT BLOCK_SIZE MUST BE < 65536
//WARNING WE USE SHORT INT BLOCK_SIZE MUST BE < 65536
class HoleBlockRef class HoleBlockRef
{ {
protected: protected:
/** /**
* Table of free index * Table of free index
*/ */
uint* m_tableFree; unsigned int* m_tableFree;
uint m_nbfree; unsigned int m_nbfree;
/** /**
* Reference counter (if 0 it is a hole) * Reference counter (if 0 it is a hole)
*/ */
uint* m_refCount; unsigned int* m_refCount;
uint m_nbref; unsigned int m_nbref;
/** /**
* nb element in block * nb element in block
*/ */
uint m_nb; unsigned int m_nb;
public: public:
/** /**
...@@ -50,16 +76,16 @@ public: ...@@ -50,16 +76,16 @@ public:
* @param nbEltsMax (IN/OUT) max number of element stored * @param nbEltsMax (IN/OUT) max number of element stored
* @return index on new element * @return index on new element
*/ */
uint newRefElt(uint& nbEltsMax); unsigned int newRefElt(unsigned int& nbEltsMax);
/** /**
* remove an element * remove an element
*/ */
inline void removeElt(uint idx) inline void removeElt(unsigned int idx)
{ {
m_nb--; m_nb--;
m_tableFree[m_nbfree++]=idx; m_tableFree[m_nbfree++] = idx;
m_refCount[idx]=0; m_refCount[idx] = 0;
} }
/** /**
...@@ -109,12 +135,12 @@ public: ...@@ -109,12 +135,12 @@ public:
* @param bf ptr on the block of other line * @param bf ptr on the block of other line
* @param j index of the other line in bf * @param j index of the other line in bf
*/ */
void overwrite(int i, HoleBlockRef *bf, int j); void overwrite(unsigned int i, HoleBlockRef *bf, unsigned int j);
/** /**
* increment ref counter of element i * increment ref counter of element i
*/ */
inline void ref(uint i) inline void ref(unsigned int i)
{ {
m_refCount[i]++; m_refCount[i]++;
} }
...@@ -123,7 +149,7 @@ public: ...@@ -123,7 +149,7 @@ public:
* decrement ref counter of element i * decrement ref counter of element i
* @return true if ref=0 and element has been destroyed * @return true if ref=0 and element has been destroyed
*/ */
inline bool unref(uint i) inline bool unref(unsigned int i)
{ {
m_refCount[i]--;