Commit 575a88ae authored by David Cazier's avatar David Cazier
Browse files

Quelques adaptations

parent af4b0a5f
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
project(SocialAgents)
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../CGoGN CACHE STRING "CGoGN root dir")
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/../CGoGN CACHE STRING "CGoGN root dir")
include(${CGoGN_ROOT_DIR}/apps_cmake.txt)
add_subdirectory(${CMAKE_SOURCE_DIR}/Release Release)
......
......@@ -10,20 +10,29 @@ namespace CGoGN
namespace CityGenerator
{
template <typename PFP>
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark);
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
template <typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& buildingMark, float height);
template <typename PFP>
bool animateCity(EnvMap* envMap);
template<typename PFP>
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark) ;
template<typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map,
typename PFP::TVEC3& position, unsigned int cX,
unsigned int cY, float sideLength,
CellMarker& obstacleMark,
CellMarker& buildingMark) ;
template<typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map,
typename PFP::TVEC3& position,
unsigned int cX, unsigned int cY,
float sideLength, CellMarker& obstacleMark,
CellMarker& buildingMark) ;
template<typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d,
CellMarker& buildingMark, float height) ;
template<typename PFP>
bool animateCity(EnvMap* envMap) ;
//template <typename PFP>
//Dart generateBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker& buildingMark);
......@@ -31,40 +40,45 @@ bool animateCity(EnvMap* envMap);
//template <typename PFP>
//void generateCity(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize, unsigned int nbSquares);
template <typename PFP>
Dart generateBuilding(EnvMap* envMap, Dart d, float height, unsigned int buildingType);
template<typename PFP>
Dart generateBuilding(EnvMap* envMap, Dart d, float height, unsigned int buildingType) ;
template <typename PFP>
void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares);
template<typename PFP>
void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares) ;
template <typename PFP>
void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize);
template<typename PFP>
void generateMall(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark,
CellMarker& buildingMark, float sideSize) ;
template <typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& position, Dart dLower,Dart dUpper);
template<typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dLower,
Dart dUpper) ;
/*******************************************************************************/
template <typename PFP>
void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float radius, unsigned int nbSquares);
template<typename PFP>
void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark,
CellMarker& buildingMark, float radius, unsigned int nbSquares) ;
/*******************************************************************************/
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position);
template<typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position) ;
template <typename PFP>
bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, float& area);
template<typename PFP>
bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, float& area) ;
template <typename PFP>
bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& obstacleMark);
template<typename PFP>
bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d,
CellMarker& obstacleMark) ;
template <typename PFP>
void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark);
template<typename PFP>
void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position,
CellMarker& obstacleMark, CellMarker& buildingMark) ;
template <typename PFP>
void installGuardRail(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float height);
template<typename PFP>
void installGuardRail(typename PFP::MAP& map, typename PFP::TVEC3& position,
CellMarker& obstacleMark, CellMarker& buildingMark, float height) ;
}
......
This diff is collapsed.
......@@ -21,168 +21,161 @@
#include "Algo/Parallel/parallel_foreach.h"
using namespace CGoGN;
using namespace CGoGN ;
class Agent;
class Obstacle;
class Agent ;
class Obstacle ;
struct PFP: public PFP_STANDARD
struct PFP : public PFP_STANDARD
{
// definition de la carte
// typedef EmbeddedMap2 MAP;
typedef Algo::IHM::ImplicitHierarchicalMap MAP;
typedef Algo::IHM::ImplicitHierarchicalMap MAP ;
// definition des listes d'agent
typedef std::vector<Agent*> AGENTS;
typedef std::vector<Obstacle*> OBSTACLES;
typedef NoMathIONameAttribute<AGENTS> AGENTVECT;
typedef NoMathIONameAttribute<OBSTACLES> OBSTACLEVECT;
typedef AttributeHandler<AGENTVECT> TAB_AGENTVECT;
typedef AttributeHandler<OBSTACLEVECT> TAB_OBSTACLEVECT;
typedef std::vector<Agent*> AGENTS ;
typedef std::vector<Obstacle*> OBSTACLES ;
typedef NoMathIONameAttribute<AGENTS> AGENTVECT ;
typedef NoMathIONameAttribute<OBSTACLES> OBSTACLEVECT ;
typedef AttributeHandler<AGENTVECT> TAB_AGENTVECT ;
typedef AttributeHandler<OBSTACLEVECT> TAB_OBSTACLEVECT ;
typedef NoMathIONameAttribute<std::pair<bool,bool> > BOOLATTRIB;
};
typedef NoMathIONameAttribute<std::pair<bool, bool> > BOOLATTRIB ;
} ;
typedef PFP::VEC3 VEC3;
typedef PFP::VEC3 VEC3 ;
class EnvMap
{
public :
EnvMap();
void markPedWay();
public:
EnvMap() ;
unsigned int mapMemoryCost();
void scale(float scaleVal);
void markPedWay() ;
Dart getBelongingCell(const PFP::VEC3& pos);
unsigned int mapMemoryCost() ;
void scale(float scaleVal) ;
void subdivideAllToMaxLevel();
void subdivideToProperLevel();
Dart getBelongingCell(const PFP::VEC3& pos) ;
void init(unsigned int config);
void foreach_neighborFace(Dart d, FunctorType& f);
void subdivideAllToMaxLevel() ;
void subdivideToProperLevel() ;
void registerObstaclesInFaces();
void addNeighborObstacles(PFP::OBSTACLES& obst, Dart d, bool edgeNeighbor);
void pushObstacleInCells(Obstacle* o, Dart d);
void popObstacleInCells(Obstacle* o, Dart d);
void obstacleChangeFace(Obstacle* agent, Dart newFace, Dart oldFace);
void init(unsigned int config) ;
void foreach_neighborFace(Dart d, FunctorType& f) ;
void registerObstaclesInFaces() ;
void addNeighborObstacles(PFP::OBSTACLES& obst, Dart d, bool edgeNeighbor) ;
void pushObstacleInCells(Obstacle* o, Dart d) ;
void popObstacleInCells(Obstacle* o, Dart d) ;
void obstacleChangeFace(Obstacle* agent, Dart newFace, Dart oldFace) ;
void setAgentNeighborsAndObstacles(Agent* agent) ;
void setAgentNeighborsAndObstacles(Agent* agent);
// void agentChangeFaceThroughEdge(Agent* agent);
void agentChangeFace(Agent* agent, Dart oldFace);
void agentChangeFace(Agent* agent, Dart oldFace) ;
void pushAgentInCells(Agent* agent, Dart d) ;
void popAgentInCells(Agent* agent, Dart d) ;
template<typename T>
inline void removeElementFromVector(std::vector<T>& a, T ag) ;
void pushAgentInCells(Agent* agent, Dart d);
void popAgentInCells(Agent* agent, Dart d);
template <typename T>
inline void removeElementFromVector(std::vector<T>& a, T ag);
void clearUpdateCandidates() ;
void updateMap() ;
void clearUpdateCandidates();
void updateMap();
void resetAgentInFace(Agent* agent) ;
void resetAgentInFace(Agent* agent);
PFP::MAP map;
PFP::MAP map ;
PFP::TVEC3 position;
PFP::TVEC3 normal;
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
PFP::MAP mapScenary;
PFP::TVEC3 positionScenary;
PFP::TVEC3 normalScenary;
CellMarker obstacleMarkS;
CellMarker buildingMarkS;
PFP::MAP mapScenary ;
PFP::TVEC3 positionScenary ;
PFP::TVEC3 normalScenary ;
CellMarker obstacleMarkS ;
CellMarker buildingMarkS ;
AttributeHandler<PFP::BOOLATTRIB> subdivisableFace;
AttributeHandler<PFP::BOOLATTRIB> subdivisableFace ;
std::vector<Dart> newBuildings;
std::vector<Dart> newBuildings ;
PFP::TAB_AGENTVECT agentvect;
PFP::TAB_AGENTVECT neighborAgentvect;
PFP::TAB_OBSTACLEVECT obstvect;
PFP::TAB_AGENTVECT agentvect ;
PFP::TAB_AGENTVECT neighborAgentvect ;
CellMarker obstacleMark;
CellMarker buildingMark;
CellMarker pedWayMark;
PFP::TAB_OBSTACLEVECT obstvect ;
static const unsigned int nbAgentsToSubdivide = 5;
static const unsigned int nbAgentsToSimplify = 4;
CellMarker obstacleMark ;
CellMarker buildingMark ;
CellMarker pedWayMark ;
CellMarker refineMark;
CellMarker coarsenMark;
std::vector<Dart> refineCandidate;
std::vector<Dart> coarsenCandidate;
};
static const unsigned int nbAgentsToSubdivide = 5 ;
static const unsigned int nbAgentsToSimplify = 4 ;
CellMarker refineMark ;
CellMarker coarsenMark ;
std::vector<Dart> refineCandidate ;
std::vector<Dart> coarsenCandidate ;
} ;
/**************************************
* INLINE FUNCTIONS *
**************************************/
* INLINE FUNCTIONS *
**************************************/
inline void EnvMap::pushAgentInCells(Agent* agent, Dart d)
{
assert(map.getCurrentLevel() == map.getMaxLevel());
assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) == agentvect[d].end());
agentvect[d].push_back(agent);
Dart dd = d;
do
{
Dart ddd = map.alpha1(map.alpha1(dd));
while(ddd != dd)
{
neighborAgentvect[ddd].push_back(agent);
ddd = map.alpha1(ddd);
assert(map.getCurrentLevel() == map.getMaxLevel()) ;
assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) == agentvect[d].end()) ;
agentvect[d].push_back(agent) ;
Dart dd = d ;
do {
Dart ddd = map.alpha1(map.alpha1(dd)) ;
while (ddd != dd) {
neighborAgentvect[ddd].push_back(agent) ;
ddd = map.alpha1(ddd) ;
}
dd = map.phi1(dd);
} while(dd != d);
dd = map.phi1(dd) ;
} while (dd != d) ;
}
inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
{
assert(map.getCurrentLevel() == map.getMaxLevel());
assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) != agentvect[d].end());
removeElementFromVector<Agent* >(agentvect[d], agent);
Dart dd = d;
do
{
Dart ddd = map.alpha1(map.alpha1(dd));
while(ddd != dd)
{
removeElementFromVector<Agent* >(neighborAgentvect[ddd], agent);
ddd = map.alpha1(ddd);
assert(map.getCurrentLevel() == map.getMaxLevel()) ;
assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) != agentvect[d].end()) ;
removeElementFromVector<Agent*>(agentvect[d], agent) ;
Dart dd = d ;
do {
Dart ddd = map.alpha1(map.alpha1(dd)) ;
while (ddd != dd) {
removeElementFromVector<Agent*>(neighborAgentvect[ddd], agent) ;
ddd = map.alpha1(ddd) ;
}
dd = map.phi1(dd);
} while(dd != d);
dd = map.phi1(dd) ;
} while (dd != d) ;
}
template <typename T>
template<typename T>
inline void EnvMap::removeElementFromVector(std::vector<T>& a, T ag)
{
typename std::vector<T>::iterator end = a.template end();
for(typename std::vector<T>::iterator it = a.begin(); it != end; ++it)
{
if(*it == ag)
{
*it = a.back();
a.pop_back();
return;
typename std::vector<T>::iterator end = a.template end() ;
for (typename std::vector<T>::iterator it = a.begin(); it != end; ++it) {
if (*it == ag) {
*it = a.back() ;
a.pop_back() ;
return ;
}
}
}
inline void EnvMap::clearUpdateCandidates()
{
refineCandidate.clear();
coarsenCandidate.clear();
refineCandidate.clear() ;
coarsenCandidate.clear() ;
}
#endif
This diff is collapsed.
......@@ -31,7 +31,7 @@ SocialAgents::SocialAgents() :
drawEnvLines(true),
drawEnvFaces(false),
drawEnvTopo(false),
drawObstacles(false),
drawObstacles(true),
drawAgents(true),
drawAgentsNeighborDist(false),
drawAgentsObstacleDist(false),
......
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