Commit 8f014cc6 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:/home/cgogn/CGoGN

Conflicts:
	include/Topology/generic/cellmarker.h
parents d66d638a 44019bb7
......@@ -9,8 +9,6 @@ ELSE(WIN32)
add_subdirectory(Examples/Release)
add_subdirectory(Examples/Debug)
add_subdirectory(Examples/Tests)
add_subdirectory(Examples/SocialAgents/Release)
add_subdirectory(Examples/SocialAgents/Debug)
add_subdirectory(Tuto)
ENDIF(WIN32)
......
......@@ -33,14 +33,6 @@ add_executable( ViewerD ../Viewer.cpp)
target_link_libraries( ViewerD
containerD topologyD utilsD algoD ${COMMON_LIBS} )
add_executable( FilterExamplesD ../FilterExamples.cpp)
target_link_libraries( FilterExamplesD
containerD topologyD utilsD algoD ${COMMON_LIBS} )
add_executable( linearTestD ../linearTest.cpp)
target_link_libraries( linearTestD
containerD topologyD utilsD algoD numerical lapack blas f2c ${COMMON_LIBS} )
add_executable( simpleGMap2D ../simpleGMap2.cpp)
target_link_libraries( simpleGMap2D
containerD topologyD utilsD algoD ${COMMON_LIBS} Zinri)
......@@ -49,10 +41,6 @@ target_link_libraries( simpleGMap2D
#target_link_libraries( SimpleEMap3D
# containerD topologyD utilsD algoD ${COMMON_LIBS} )
add_executable( ihmViewD ../ihmView.cpp)
target_link_libraries( ihmViewD
containerD topologyD utilsD algoD ${COMMON_LIBS} Zinri)
add_executable( triangulationD ../triangulation.cpp)
target_link_libraries( triangulationD
containerD topologyD utilsD algoD ${COMMON_LIBS} )
......
This diff is collapsed.
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#include <iostream>
#include "Utils/os_spec.h"
#include "Utils/glutwin_atb.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Algo/Import/import.h"
#include "Algo/Render/map_glRender.h"
#include "Algo/Render/vbo_MapRender.h"
#include "Algo/Geometry/boundingbox.h"
#include "Topology/generic/ecell.h"
//#include "Algo/Geometry/curvature.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Filters2D/filters2D.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef Map2 MAP;
};
typedef PFP::MAP MAP ;
MAP myMap ;
SelectorTrue allDarts;
class MyGlutWin: public Utils::GlutWin_ATB
{
public:
TwBar* viewer_bar ;
enum renderMode { FLAT, GOURAUD, PHONG, NORMAL } ;
Geom::Vec4f colDif ;
Geom::Vec4f colSpec ;
Geom::Vec4f colClear ;
Geom::Vec4f colNormal ;
float shininess ;
Geom::Vec3f gPosObj ;
float gWidthObj ;
float normalBaseSize ;
float normalScaleFactor ;
float faceShrinkage ;
int renderStyle ;
bool renderObject ;
bool renderLines ;
bool renderNormals ;
PFP::TVEC3 position ;
PFP::TVEC3 position2 ;
PFP::TVEC3 originalPosition ;
PFP::TVEC3 normal ;
PFP::TREAL faceArea ;
PFP::TVEC3 faceNormal ;
PFP::TVEC3 faceCentroid ;
Algo::Render::VBO::MapRender_VBO* vbo_render ;
GLuint dl_norm ;
MyGlutWin(int* argc, char **argv, int winX, int winY) ;
void init() ;
void initGUI() ;
void myRedraw() ;
// void myKeyboard(unsigned char keycode, int x, int y) ;
void updateVBOdata(int upType) ;
void initDLNormals() ;
void render(int renderMode) ;
void loadOriginalPositions()
{
myMap.copyAttribute(position, originalPosition) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
}
void addNoise()
{
Algo::Filters2D::computeNoise<PFP>(myMap, 33, position, position2, normal) ;
myMap.swapAttributes(position, position2) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
}
void filter(int type)
{
switch(type)
{
case Algo::Filters2D::AVERAGE :
Algo::Filters2D::filterAverage<PFP>(myMap, position, position2) ;
myMap.swapAttributes(position, position2) ;
break ;
case Algo::Filters2D::TAUBIN :
Algo::Filters2D::filterTaubin<PFP>(myMap, position, position2) ;
break ;
case Algo::Filters2D::BILATERAL :
Algo::Filters2D::filterBilateral<PFP>(myMap, position, position2, normal) ;
myMap.swapAttributes(position, position2) ;
break ;
case Algo::Filters2D::AVERAGE_NORMAL :
Algo::Filters2D::filterAverageNormals<PFP>(myMap, position, position2) ;
myMap.swapAttributes(position, position2) ;
break ;
case Algo::Filters2D::MMSE :
Algo::Filters2D::filterMMSE<PFP>(myMap, 0.1f, position, position2) ;
myMap.swapAttributes(position, position2) ;
break ;
case Algo::Filters2D::SUSAN :
Algo::Filters2D::filterSUSAN<PFP>(myMap, 0.35f, position, position2, normal) ;
myMap.swapAttributes(position, position2) ;
break ;
case Algo::Filters2D::TNBA :
Algo::Filters2D::filterTNBA<PFP>(myMap, 0.1f, 0.35f, position, position2) ;
myMap.swapAttributes(position, position2) ;
break ;
case Algo::Filters2D::VNBA :
Algo::Filters2D::filterVNBA<PFP>(myMap, 0.01f, 0.35f, position, position2, normal) ;
myMap.swapAttributes(position, position2) ;
break ;
}
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
}
};
......@@ -34,14 +34,6 @@ add_executable( Viewer ../Viewer.cpp)
target_link_libraries( Viewer
container topology utils algo ${COMMON_LIBS} )
add_executable( FilterExamples ../FilterExamples.cpp)
target_link_libraries( FilterExamples
container topology utils algo numerical lapack blas f2c ${COMMON_LIBS} )
add_executable( linearTest ../linearTest.cpp)
target_link_libraries( linearTest
container topology utils algo numerical lapack blas f2c ${COMMON_LIBS} )
add_executable( simpleGMap2 ../simpleGMap2.cpp)
target_link_libraries( simpleGMap2
container topology utils algo ${COMMON_LIBS} Zinri)
......@@ -58,10 +50,6 @@ add_executable( decimationVolumique ../decimationVolumique.cpp)
target_link_libraries( decimationVolumique
container topology utils algo numerical lapack blas f2c ${COMMON_LIBS} )
add_executable( ihmView ../ihmView.cpp)
target_link_libraries( ihmView
container topology utils algo numerical lapack blas f2c ${COMMON_LIBS} )
add_executable( triangulation ../triangulation.cpp)
target_link_libraries( triangulation
container topology utils algo ${COMMON_LIBS} )
......
cmake_minimum_required(VERSION 2.6)
project(SocialAgents)
SET(CMAKE_BUILD_TYPE Debug)
link_directories(
${CGoGN_ROOT_DIR}/lib/Debug/
${CGoGN_ROOT_DIR}/lib/Release/
)
# define includes path
include_directories(
/usr/include/libxml2/
${CGoGN_ROOT_DIR}/Apps/Examples/SocialAgents/include
${CGoGN_ROOT_DIR}/include
${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include
${CGoGN_ROOT_DIR}/ThirdParty/Numerical
${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig
${CGoGN_ROOT_DIR}/ThirdParty/gzstream
${CGoGN_ROOT_DIR}/ThirdParty/Zinri
)
#define exec to compile
add_executable(socialAgentsD ../src/viewer.cpp ../src/env_map.cpp ../src/agent.cpp ../src/simulator.cpp )
target_link_libraries( socialAgentsD containerD topologyD utilsD algoD ${COMMON_LIBS} )
cmake_minimum_required(VERSION 2.6)
project(SocialAgents)
SET(CMAKE_BUILD_TYPE Release)
link_directories(
${CGoGN_ROOT_DIR}/lib/Release/
)
# define includes path
include_directories(
/usr/include/libxml2/
${CGoGN_ROOT_DIR}/Apps/Examples/SocialAgents/include
${CGoGN_ROOT_DIR}/include
${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include
${CGoGN_ROOT_DIR}/ThirdParty/Numerical
${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig
${CGoGN_ROOT_DIR}/ThirdParty/gzstream
${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} )
#ifndef M_AGENT_H
#define M_AGENT_H
// #include "Definitions.h"
#include <iostream>
#include "utils.h"
#include "env_map.h"
#include "Algo/MovingObjects/particle_cell_2D.h"
class Simulator;
class Agent
{
public:
// typedef RVO::Vector2 VEC_A;
typedef VEC3 VEC_A;
explicit Agent(Simulator* sim, size_t agentNo);
Agent(Simulator* sim, const VEC_A& position, size_t agentNo);
Agent(Simulator* sim, const VEC_A& position, size_t agentNo, Dart d);
Agent(Simulator* sim, const VEC_A& position, float neighborDist,
size_t maxNeighbors, float timeHorizon, float timeHorizonObst,
float radius, const VEC_A& velocity, float maxSpeed, size_t agentNo);
~Agent();
void setGoalNo(size_t goal);
void computeNewVelocity();
void insertAgentNeighbor(size_t agentNo, float& rangeSq);
// void insertObstacleNeighbor(size_t obstacleNo, float rangeSq);
void insertObstacleNeighbor(Dart d);
void update();
std::vector<std::pair<float, size_t> > agentNeighbors_;
size_t maxNeighbors_;
float maxSpeed_;
float neighborDist_;
// RVO::Vector2 newVelocity_;
VEC_A newVelocity_;
// std::vector<std::pair<float, size_t> > obstacleNeighbors_;
std::vector<std::pair<float, Dart> > obstacleNeighbors_;
std::vector<Line> orcaLines_;
// RVO::Vector2 position_;
// RVO::Vector2 prefVelocity_;
VEC_A position_;
VEC_A prefVelocity_;
float radius_;
Simulator* sim_;
float timeHorizon_;
float timeHorizonObst_;
// RVO::Vector2 velocity_;
VEC_A velocity_;
size_t agentNo_;
size_t goalNo_;
// Dart nearestDart;
// std::vector<Dart> includingFaces;
CGoGN::Algo::MovingObjects::ParticleCell2D<PFP> * part;
float rangeSq;
bool treated;
};
bool linearProgram1(const std::vector<Line>& lines, size_t lineNo,
float radius, const Agent::VEC_A& optVelocity,
bool directionOpt, Agent::VEC_A& result);
bool linearProgram2(const std::vector<Line>& lines, size_t num, float radius,
const Agent::VEC_A& optVelocity, bool directionOpt,
Agent::VEC_A& result);
void linearProgram3(const std::vector<Line>& lines, size_t numObstLines,
float radius, Agent::VEC_A& result);
#endif
#ifndef ENV_GENERATOR
#define ENV_GENERATOR
namespace CGoGN
{
namespace CityGenerator
{
template <typename PFP>
void generateAbsolutSpiralOfDeath(typename PFP::MAP& map,typename PFP::TVEC3& position, DartMarker& closeMark, unsigned int side, float rMin, float rMax,float nbTurns);
template <typename PFP>
void generateToboggan(typename PFP::MAP& map,typename PFP::TVEC3& position, DartMarker& closeMark, unsigned int side, float rMin, float rMax,float nbTurns);
template <typename PFP, typename EMBV>
void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& closeMark, float sideSize);
template <typename PFP, typename EMBV>
void generateCity(typename PFP::MAP& map, EMBV& position, DartMarker& closeMark, float sideSize);
template <typename PFP, typename EMBV, typename EMBAGENT>
void animateCity(typename PFP::MAP& map, EMBV& position, EMBAGENT& agents, DartMarker& closeMark, std::vector<Dart>& newBuilding);
template <typename PFP, typename EMBV>
bool notEightAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, DartMarker& closeMark);
template <typename PFP, typename EMBV>
void generateGrid(typename PFP::MAP& map, EMBV& position, unsigned int cX,unsigned int cY,float sideLength, DartMarker& closeMark);
template <typename PFP, typename EMBV>
void markObstacleSteepFaces(typename PFP::MAP& map, EMBV& position, float steepness, DartMarker& closeMark);
template <typename PFP, typename EMBV>
void generatePathToUpperStair(typename PFP::MAP& map, EMBV& position, Dart dLower, Dart dUpper, DartMarker& closeMark);
template <typename PFP, typename EMBV>
void generateBuilding(typename PFP::MAP& map, EMBV& position, Dart d,DartMarkerStore& build, float height, float side, unsigned int buildingType, DartMarker& closeMark);
template <typename PFP, typename EMBV>
static void generateBridge(typename PFP::MAP& map, EMBV& position, Dart dStart, Dart dStop,float bridgeHeight, DartMarker& closeMark);
template <typename PFP, typename EMBV>
void generateBridge(typename PFP::MAP& map, EMBV& position, unsigned int cX, unsigned int cY,float sideLength, DartMarker& closeMark);
}
}
#include "env_generator.hpp"
#endif
\ No newline at end of file
This diff is collapsed.
#ifndef ENVMap_H
#define ENVMap_H
#include <iostream>
// #include "Definitions.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
#include "Algo/ImplicitHierarchicalMesh/ihm.h"
#include "Algo/ImplicitHierarchicalMesh/subdivision.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/extrusion.h"
#include "Algo/Modelisation/subdivision.h"
#include "Algo/Geometry/centroid.h"
#include "Container/fakeAttribute.h"
#include "env_generator.h"
using namespace CGoGN;
class Agent;
struct PFP: public PFP_STANDARD
{
// definition de la carte
// typedef EmbeddedMap2<Map2> MAP;
typedef Algo::IHM::ImplicitHierarchicalMap MAP;
// definition des listes d'agent
// typedef std::vector<Agent *> AGENTS;
typedef std::vector<Agent * > AGENTS;
typedef NoMathIONameAttribute<AGENTS > AGENTVECT;
typedef AttributeHandler<AGENTVECT> TAB_AGENTVECT;
};
typedef PFP::VEC3 VEC3 ;
class EnvMap
{
public :
PFP::MAP map;
//SelectorTrue<PFP::MAP::Dart> allDarts;
//identifier for the position attribute
// unsigned int idPos;
PFP::TVEC3 position;
//identifier for the normal attribute
// unsigned int idNorm;
PFP::TVEC3 normal;
// unsigned int idAgent;
PFP::TAB_AGENTVECT agentvect;
float sideSize;
// PFP::POSITION tablePosition;
// PFP::TAB_AGENTVECT tableAgent;
DartMarker closeMark;
// DartMarker subdivMarker;
std::vector<Dart> newBuildings;
// std::vector<Dart> subdividedDarts;
Dart dSimplify;
Dart dSubdivide;
EnvMap();
bool simplifiable(Dart d);
bool simplifiableDart(Dart d);
bool collapsableEdge(Dart& d,Dart& dStop);
bool simplifyVertex(Dart& d);
bool simplifyEdge(Dart& d);
void simplify();
VEC3 faceCenter(Dart d);
// const PFP::VEC3& getPosition(const Dart& d);
// RVO::Vector2 getPosition2(Dart d);
unsigned int getNbFaces();
Dart getDart(unsigned int i);
Dart getBelongingCell(const PFP::VEC3& pos);
bool noAgentSurroundingVertex(Dart d);
void findAgentContactInFace(Dart d, PFP::VEC3 pos, float radius, std::vector<Dart>& l_contact_Dart,DartMarker& m);
// void insertObstacleOfFace(Agent * agent, const Dart d);
void insertObstacleOfFace(PFP::AGENTS agents,const Dart d);
// void getAllFacesOfAgent(Agent * agent, Dart d, PFP::VEC3 pos, float radius);
void getAllFacesOfAgents(Dart d);
void linkAgentWithCells(Agent* agent);
void addObstacle(std::vector<VEC3> points);
bool subdivideSquare(Dart d);
bool subdivideFace(Dart d);
void resetAgentInFace(Agent * agent);
bool checkForSubdivision(Dart d);
void updateMap();
void subdivideFaces();
void simplifyFaces();
void pushAgentInCell(Agent * agent, Dart d);
void popAgentInCell(Agent * agent, Dart d);
// void addNeighborAgents(size_t agentno, Agent * agent);
void addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo);
};
#endif
#ifndef ENVMAP_RENDER
#define ENVMAP_RENDER
#include "env_map.h"
#include <GL/glut.h>
//static void renderPoint(EnvMap& m, Dart& d)
//{
// PFP::VEC3 p = m.position[d];
// glBegin(GL_POINTS);
// glVertex3f(p[0],p[1],p[2]);
// glEnd();
//}
static void renderDart(EnvMap& m, Dart d)
{
PFP::VEC3 p1 = m.position[d];
PFP::VEC3 p2 = m.position[m.map.phi1(d)];
glBegin(GL_LINES);
glVertex3f(p1[0],p1[1],p1[2]);
glVertex3f(p2[0],p2[1],p2[2]);
glEnd();
}
static void renderFace(EnvMap& m, Dart& d)
{
Dart dd=d;
do {
renderDart(m,dd);
dd = m.map.phi1(dd);
}while(dd!=d);
}
//static void renderCellOfDim(EnvMap& m,Dart d, unsigned int dim)
//{
// switch(dim) {
// case 0 : renderPoint(m,d); break;
// case 1 : renderDart(m,d); break;
// case 2 : renderFace(m,d); break;
// }
//}
//
//static void renderAllPoints(EnvMap& m)
//{
// glBegin(GL_POINTS);
// for(Dart d=m.map.begin();d!=m.map.end();m.map.next(d)) {
// PFP::VEC3 p = m.position[d];
// glVertex3f(p[0],p[1],p[2]);
// }
// glEnd();
//}
static void renderPredictionTriangle(EnvMap& m, Dart d, PFP::VEC3 p)
{
glBegin(GL_LINE_LOOP);
glVertex3fv(&p[0]);
glVertex3fv(& m.position[d][0]);
glVertex3fv(& m.position[m.map.phi1(d)][0]);
glEnd();
}
#endif
/****************************************************************************
** Form interface generated from reading ui file 'mainwindow.ui'
**
** Created: Thu Sep 30 11:00:52 2010
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef PATH_FINDER
#define PATH_FINDER
namespace CGoGN
{
namespace PathFinder
{
template <typename PFP>
float pathCostSqr(typename PFP::MAP& map,const typename PFP::TVEC3& position, Dart startPos, Dart stopPos);
template <typename PFP>
std::vector<Dart> pathFindAStar(typename PFP::MAP& map,const typename PFP::TVEC3& position, Dart startPos, Dart stopPos, FunctorSelect& bad = FunctorType());
}
}
#include "path_finder.hpp"
#endif
\ No newline at end of file
#include "Algo/Geometry/centroid.h"
#include <limits>
#include <iostream>
namespace CGoGN
{
namespace PathFinder
{
template <typename PFP>
float pathCostSqr(typename PFP::MAP& map,const typename PFP::TVEC3& position, Dart startPos, Dart stopPos)
{
return VEC3(Algo::Geometry::faceCentroid<PFP>(map,stopPos,position)-Algo::Geometry::faceCentroid<PFP>(map,startPos,position)).norm2();
}
template <typename PFP>