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

Test commit

parent af5763f3
......@@ -2,14 +2,12 @@ cmake_minimum_required(VERSION 2.6)
project(SocialAgents)
SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_BUILD_TYPE Release)
link_directories(
${CGoGN_ROOT_DIR}/lib/Debug/
${CGoGN_ROOT_DIR}/lib/Release/)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3")
# define includes path
include_directories(
/usr/include/libxml2/
......@@ -22,8 +20,6 @@ include_directories(
${CGoGN_ROOT_DIR}/ThirdParty/Zinri
)
#define exec to compile
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} )
......
......@@ -34,7 +34,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 = 40;
unsigned int side = 25;
generateGrid<PFP,EMBV>(map,position,side,side,sideSize,closeMark);
Dart dEnd = map.end();
......@@ -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)
(*it)->insertObstacleNeighbor(dd);
// }
}
return;
// return;
}
dd = map.phi1(dd);
} while (dd!=d);
......@@ -340,7 +340,7 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo)
void EnvMap::updateMap()
{
// simplifyFaces();
subdivideFaces();
subdivideFaces() ;
map.setCurrentLevel(map.getMaxLevel()) ;
}
......@@ -352,18 +352,38 @@ void EnvMap::subdivideFaces()
if(!m.isMarked(d))
{
m.mark(d) ;
if(!closeMark.isMarked(d) && agentvect[d].size() > 10)
if(!closeMark.isMarked(d) && agentvect[d].size() > 8)
{
if(!map.faceIsSubdivided(d))
{
std::vector<Agent*> agents ;
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) ;
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)
{
this->resetAgentInFace(*it) ;
resetAgentInFace(*it) ;
agentvect[(*it)->part->d].push_back(*it) ;
}
map.setCurrentLevel(cur) ;
}
}
}
......
......@@ -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);
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.map.init();
std::cout << "setup scenario" << std::endl;
setupHelicoidScenario(1,50);
// setupHelicoidScenario(1,50);
setupScenario();
// Dart dStop=envMap.map.begin();
// for(unsigned int i=0;i<5000;++i) envMap.map.next(dStop);
......
......@@ -223,13 +223,13 @@ void MyGlutWin::myRedraw()
// }
// glEnd();
glBegin(GL_POINTS);
for(unsigned int i = 0; i<4;++i) {
for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) {
glVertex3fv(&(*it)[0]);
}
}
glEnd();
// glBegin(GL_POINTS);
// for(unsigned int i = 0; i<4;++i) {
// for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) {
// glVertex3fv(&(*it)[0]);
// }
// }
// glEnd();
unsigned int i=0;
for(std::vector<Agent * >::iterator it = sim->agents_.begin() ; it != sim->agents_.end() ; ++ it, ++i) {
......@@ -244,7 +244,7 @@ void MyGlutWin::myRedraw()
//draw containing center face
glColor3f(0,0,1);
glLineWidth(4.0f);
renderFace(sim->envMap,(*it)->nearestDart);
renderFace(sim->envMap,(*it)->part->d);
glLineWidth(1.0f);
// //draw displacement
......@@ -254,18 +254,18 @@ void MyGlutWin::myRedraw()
// glEnd();
// //and prediction triangle
// glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0);
// glLineWidth(5.0f);
// renderPredictionTriangle(sim->envMap,(*it)->nearestDart,(*it)->part->m_position);
// glLineWidth(1.0f);
glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0);
glLineWidth(5.0f);
renderPredictionTriangle(sim->envMap,(*it)->part->d,(*it)->part->m_position);
glLineWidth(1.0f);
//draw next goal
glBegin(GL_LINES);
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],
(*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][1],
(*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][2]);
glEnd();
// glBegin(GL_LINES);
// 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],
// (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][1],
// (*sim->pathToFollow[sim->pathPointer[i].first])[sim->pathPointer[i].second][2]);
// glEnd();
}
// glCircle3i((*it)->position_[0],(*it)->position_[1],(*it)->neighborDist_);
......@@ -403,8 +403,8 @@ void MyGlutWin::animate(void)
// std::cout << "pos to reach : " << posToReach << std::endl;
// std::cout << sim->getGlobalTime() << " " << std::endl;
updateVisualization(sim);
// sim->setPreferredVelocities(posToReach);
sim->setPreferredPathVelocities();
sim->setPreferredVelocities(posToReach);
// sim->setPreferredPathVelocities();
sim->doStep();
// sim->envMap.simplify();
glutPostRedisplay();
......@@ -628,6 +628,10 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
render_anim=!render_anim;
}
break;
case 'c': {
sim->envMap.map.check();
}
break;
}
updateUI();
......
......@@ -39,7 +39,6 @@
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/map_glRender.h"
#include "Algo/Render/vbo_MapRender.h"
#include "Topology/generic/ecell.h"
#include "Algo/Render/topo_vboRender.h"
using namespace CGoGN ;
......
......@@ -531,7 +531,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
unsigned int nbVertices = myMap.getNbOrbits(VERTEX_ORBIT) ;
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);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "decimation: "<< seconds << "sec" << std::endl;
......
......@@ -84,11 +84,7 @@ inline Dart ImplicitHierarchicalMap::phi1(Dart d)
else
{
while(m_edgeId[it] != edgeId)
{
if(Map2::phi2(it) == it)
std::cout << "fix point in the middle" << std::endl ;
it = Map2::alpha_1(it) ;
}
}
} while(!finished) ;
return it ;
......@@ -100,7 +96,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d)
bool finished = false ;
Dart it = Map2::phi_1(d) ;
unsigned int edgeId = m_edgeId[it] ;
do
{
if(m_dartLevel[it] <= m_curLevel)
......@@ -112,21 +107,6 @@ inline Dart ImplicitHierarchicalMap::phi_1(Dart d)
it = Map2::phi_1(Map2::phi2(it)) ;
}
} 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 ;
}
......@@ -329,8 +309,6 @@ inline unsigned int ImplicitHierarchicalMap::edgeLevel(Dart d)
return ld < ldd ? ldd : ld ; // insertion levels of its two darts
}
template <typename T>
T& AttributeHandler_IHM<T>::operator[](Dart d)
{
......
......@@ -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
{ // linked to the central vertex
Dart next = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, map.phi1(ne)) ;
map.splitFace(map.phi1(ne), dd) ;
Dart nne = map.alpha1(dd) ;
id = map.getNewEdgeId() ;
map.setEdgeId(nne, id) ;
......
#ifndef __MULTIATTRIB_CONTAINER__
#define __MULTIATTRIB_CONTAINER__
#include "sizeblock.h"
#include "holeblockref.h"
#include "attribmv.h"
/*******************************************************************************
* 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 __ATTRIB_CONTAINER__
#define __ATTRIB_CONTAINER__
#include "Container/sizeblock.h"
#include "Container/holeblockref.h"
#include "Container/attribmv.h"
#include <vector>
#include <map>
......@@ -105,7 +129,6 @@ protected:
std::map< std::string, RegisteredBaseAttribute* >* m_attributes_registry_map;
public:
/**
* constante d'attribut inconnu
*/
......@@ -232,8 +255,8 @@ public:
unsigned int getNbAttributes()
{
for (unsigned int i =0; i<m_tableAttribs.size(); ++i)
std::cout <<" table ptr:"<< m_tableAttribs[i] << std::endl;
for (unsigned int i = 0; i < m_tableAttribs.size(); ++i)
std::cout << "table ptr:" << m_tableAttribs[i] << std::endl;
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__
#define __HOLE_BLOCK_REF__
#include <fstream>
#include <iostream>
#include "sizeblock.h"
#include "Container/sizeblock.h"
namespace CGoGN
{
//WARNING WE USED SHORT INT BLOCK_SIZE MUST BE < 65536
//WARNING WE USE SHORT INT BLOCK_SIZE MUST BE < 65536
class HoleBlockRef
{
protected:
/**
* Table of free index
*/
uint* m_tableFree;
uint m_nbfree;
unsigned int* m_tableFree;
unsigned int m_nbfree;
/**
* Reference counter (if 0 it is a hole)
*/
uint* m_refCount;
uint m_nbref;
unsigned int* m_refCount;
unsigned int m_nbref;
/**
* nb element in block
*/
uint m_nb;
unsigned int m_nb;
public:
/**
......@@ -50,16 +76,16 @@ public:
* @param nbEltsMax (IN/OUT) max number of element stored
* @return index on new element
*/
uint newRefElt(uint& nbEltsMax);
unsigned int newRefElt(unsigned int& nbEltsMax);
/**
* remove an element
*/
inline void removeElt(uint idx)
inline void removeElt(unsigned int idx)
{
m_nb--;
m_tableFree[m_nbfree++]=idx;
m_refCount[idx]=0;
m_tableFree[m_nbfree++] = idx;
m_refCount[idx] = 0;
}
/**
......@@ -109,12 +135,12 @@ public:
* @param bf ptr on the block of other line
* @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
*/
inline void ref(uint i)
inline void ref(unsigned int i)
{
m_refCount[i]++;
}
......@@ -123,7 +149,7 @@ public:
* decrement ref counter of element i
* @return true if ref=0 and element has been destroyed
*/
inline bool unref(uint i)
inline bool unref(unsigned int i)
{
m_refCount[i]--;
if (m_refCount[i] == 1)
......@@ -137,22 +163,21 @@ public:
/**
* set ref counter of element i with j
*/
inline void setNbRefs(uint i, uint nb) { m_refCount[i] = nb; }
inline void setNbRefs(unsigned int i, unsigned int nb) { m_refCount[i] = nb; }
/**
* number of references of element i
* @return the number of references (0 = no elements)
*/
inline uint nbRefs(uint i) { return m_refCount[i]; }
inline unsigned int nbRefs(unsigned int i) { return m_refCount[i]; }
bool updateHoles(uint nb);
bool updateHoles(unsigned int nb);
void saveBin(CGoGNostream& fs);
bool loadBin(CGoGNistream& fs);
};
}
} // namespace CGoGN
#endif
/*
* sizeblock.h
*
* Created on: Jun 10, 2010
* Author: thery
*/
/*******************************************************************************
* 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 SIZEBLOCK_H_
#define SIZEBLOCK_H_
#ifndef _SIZEBLOCK_H_
#define _SIZEBLOCK_H_
#include "gzstream.h"
#define _BLOCKSIZE_ 4096
typedef unsigned int uint;
//typedef std::ifstream CGoGNistream;
//typedef std::ofstream CGoGNostream;
/// use everywhere in save/load compressed stream
typedef igzstream CGoGNistream;
typedef ogzstream CGoGNostream;
......
......@@ -120,39 +120,6 @@ public:
}
};
class FunctorGetLazyEmb: public FunctorType
{
protected:
AttribMultiVect<unsigned int>& m_emb;
unsigned int m_val;
std::vector<Dart> m_darts;
public:
FunctorGetLazyEmb(AttribMultiVect<unsigned int>& emb): m_emb(emb), m_val(EMBNULL)
{
m_darts.reserve(8) ;
}
bool operator()(Dart d)
{
if (m_emb[d.index] != EMBNULL)
{
m_val = m_emb[d.index];
return true;
}
m_darts.push_back(d);
return false;
}
unsigned int getVal()
{
for(std::vector<Dart>::iterator it = m_darts.begin(); it != m_darts.end(); ++it)
m_emb[it->index] = m_val;
return m_val;
}
};
// Search Functor: look for a given dart when applied
/********************************************************/
......
......@@ -127,7 +127,7 @@ protected:
/**
* Add a dart to the map
*/
Dart newDart();
virtual Dart newDart();
/**
* Erase a dart of the map
......@@ -154,6 +154,12 @@ public:
*/
bool isOrbitEmbedded(unsigned int orbit) const;
/**
* return a pointer to the Dart attribute vector that store the embedding of the given orbit
* (may be NULL if the orbit is not embedded)
*/
AttribMultiVect<unsigned int>* getEmbeddingAttributeVector(unsigned int orbit) const;
/**
* return the number of embedded orbits (including DART_ORBIT)
*/
......
......@@ -42,13 +42,21 @@ inline Dart GenericMap::newDart()
for(unsigned int i = 0; i < NB_ORBITS; ++i)
if (m_embeddings[i])
(*m_embeddings[i])[d.index] = EMBNULL ;
return d ;
}
inline void GenericMap::deleteDart(Dart d)
{
m_attribs[DART_ORBIT].removeLine(d.index) ;
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
if (m_embeddings[orbit])
{
unsigned int emb = (*m_embeddings[orbit])[d.index] ;
if(emb != EMBNULL)
m_attribs[orbit].unrefLine(emb) ;
}
}
}
inline bool GenericMap::isDartValid(Dart d)
......@@ -70,6 +78,11 @@ inline bool GenericMap::isOrbitEmbedded(unsigned int orbit) const
return (orbit == DART_ORBIT) || (m_embeddings[orbit] != NULL) ;
}
inline AttribMultiVect<unsigned int>* GenericMap::getEmbeddingAttributeVector(unsigned int orbit) const
{
return m_embeddings[orbit] ;
}
inline unsigned int GenericMap::nbEmbeddings() const
{
unsigned int nb = 0;
......@@ -90,7 +103,51 @@ inline unsigned int GenericMap::getEmbedding(Dart d, unsigned int orbit)
if(emb != EMBNULL)
return emb ;
FunctorGetLazyEmb fle(*m_embeddings[orbit]);
class FunctorGetLazyEmb: public FunctorType
{
protected:
GenericMap& m_map;
unsigned int m_orbit;
AttribMultiVect<unsigned int>* m_emb;
unsigned int m_val;
std::vector<Dart> m_darts;
public:
FunctorGetLazyEmb(GenericMap& map, unsigned int orbit):
<