Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SocialAgents3D
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
6db3ac1c
Commit
6db3ac1c
authored
Nov 07, 2012
by
pitiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maj
parent
4508afde
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
2008 additions
and
1084 deletions
+2008
-1084
CMakeLists.txt
CMakeLists.txt
+2
-2
Debug/CMakeLists.txt
Debug/CMakeLists.txt
+2
-0
Release/CMakeLists.txt
Release/CMakeLists.txt
+2
-0
include/agent.h
include/agent.h
+12
-8
include/env_generator.h
include/env_generator.h
+11
-14
include/env_generator.hpp
include/env_generator.hpp
+51
-32
include/env_map.h
include/env_map.h
+168
-27
include/env_render.h
include/env_render.h
+19
-14
include/exportObstacles.h
include/exportObstacles.h
+1
-1
include/exportObstacles.hpp
include/exportObstacles.hpp
+2
-2
include/moving_obstacle.h
include/moving_obstacle.h
+69
-40
include/obstacle.h
include/obstacle.h
+14
-10
include/path_finder.h
include/path_finder.h
+2
-2
include/path_finder.hpp
include/path_finder.hpp
+5
-5
include/simulator.h
include/simulator.h
+20
-9
include/socialAgents.ui
include/socialAgents.ui
+18
-1
include/spatialHashing.h
include/spatialHashing.h
+10
-10
include/viewer.h
include/viewer.h
+20
-1
src/agent.cpp
src/agent.cpp
+213
-130
src/env_map.cpp
src/env_map.cpp
+281
-142
src/moving_obstacle.cpp
src/moving_obstacle.cpp
+502
-104
src/simulator.cpp
src/simulator.cpp
+273
-358
src/viewer.cpp
src/viewer.cpp
+311
-172
No files found.
CMakeLists.txt
View file @
6db3ac1c
...
...
@@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 2.8)
project
(
SocialAgents
)
add_definitions
(
-DSPATIAL_HASHING
)
#
add_definitions(-DSPATIAL_HASHING)
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
)
...
...
Debug/CMakeLists.txt
View file @
6db3ac1c
...
...
@@ -26,7 +26,9 @@ add_executable( socialAgentsD
../src/agent.cpp
../src/moving_obstacle.cpp
../src/simulator.cpp
../src/moving_mesh.cpp
../src/gl2ps.c
../src/ShapeMatching/rigidXfComputation.cpp
${
socialAgents_moc
}
${
socialAgents_ui
}
)
...
...
Release/CMakeLists.txt
View file @
6db3ac1c
...
...
@@ -24,7 +24,9 @@ add_executable( socialAgents
../src/agent.cpp
../src/moving_obstacle.cpp
../src/simulator.cpp
../src/moving_mesh.cpp
../src/gl2ps.c
../src/ShapeMatching/rigidXfComputation.cpp
${
socialAgents_moc
}
${
socialAgents_ui
}
)
...
...
include/agent.h
View file @
6db3ac1c
...
...
@@ -24,10 +24,10 @@ public:
void
updateAgentNeighbors
()
;
void
updateObstacleNeighbors
()
;
void
update
()
;
void
computePrefVelocity
()
;
void
computeNewVelocity
()
;
void
update
();
void
obstacle_priority
(
PFP
::
VEC3
*
goalVector
);
//ajout moving obst
void
computePrefVelocity
();
void
computeNewVelocity
();
void
computeNewVelocity2
()
;
...
...
@@ -42,6 +42,7 @@ public:
std
::
vector
<
std
::
pair
<
float
,
Agent
*>
>
agentNeighbors_
;
std
::
vector
<
std
::
pair
<
float
,
Obstacle
*>
>
obstacleNeighbors_
;
std
::
vector
<
std
::
pair
<
float
,
Obstacle
*>
>
movingObstacleNeighbors_
;
#ifdef SPATIAL_HASHING
VEC3
pos
;
...
...
@@ -66,9 +67,11 @@ public:
static
float
range_
;
static
float
rangeSq_
;
static
float
timeStep
;
static
unsigned
int
cptAgent
;
float
color1
;
float
color2
;
float
color3
;
unsigned
int
agentNo
;
VEC3
velocity_
;
...
...
@@ -78,7 +81,8 @@ public:
VEC3
meanSpeed_
;
// VEC3 meanPos_;
Simulator
*
sim_
;
}
;
Simulator
*
sim_
;
bool
alive
;
};
#endif
include/env_generator.h
View file @
6db3ac1c
...
...
@@ -11,7 +11,7 @@ namespace CityGenerator
{
template
<
typename
PFP
>
bool
notDiagonalAdjacentToAnObstacle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
CellMarker
&
buildingMark
)
;
bool
notDiagonalAdjacentToAnObstacle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
CellMarker
<
FACE
>
&
buildingMark
)
;
template
<
typename
PFP
>
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
generateGrid
(
EnvMap
&
envMap
)
;
...
...
@@ -21,27 +21,25 @@ 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
)
;
float
sideLength
,
CellMarker
<
EDGE
>
&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
)
;
template
<
typename
PFP
>
Dart
extrudeFaceAndMark
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
d
,
CellMarker
&
buildingMark
,
float
height
)
;
CellMarker
<
FACE
>
&
buildingMark
,
float
height
)
;
#ifndef SPATIAL_HASHING
template
<
typename
PFP
>
bool
animateCity
(
EnvMap
*
envMap
)
;
#endif
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
generateMall
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
float
sideSize
)
;
void
generateMall
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
<
EDGE
>
&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
,
float
sideSize
)
;
template
<
typename
PFP
>
void
generatePathToUpperStair
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
dLower
,
...
...
@@ -50,8 +48,8 @@ void generatePathToUpperStair(typename PFP::MAP& map, typename PFP::TVEC3& posit
/*******************************************************************************/
template
<
typename
PFP
>
void
generatePlanet
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
float
radius
,
unsigned
int
nbSquares
)
;
void
generatePlanet
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
<
EDGE
>
&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
,
float
radius
,
unsigned
int
nbSquares
)
;
/*******************************************************************************/
...
...
@@ -63,16 +61,15 @@ bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, flo
template
<
typename
PFP
>
bool
canRemoveEdgeConvex
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
d
,
CellMarker
&
obstacleMark
)
;
CellMarker
<
EDGE
>
&
obstacleMark
)
;
template
<
typename
PFP
>
void
convexifyFreeSpace
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
)
;
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
)
;
template
<
typename
PFP
>
void
installGuardRail
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
float
height
)
;
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>&
buildingMark
,
float
height
)
;
}
}
...
...
include/env_generator.hpp
View file @
6db3ac1c
...
...
@@ -10,7 +10,7 @@ namespace CityGenerator
{
template
<
typename
PFP
>
bool
notAdjacentToAnObstacle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
CellMarker
&
buildingMark
)
bool
notAdjacentToAnObstacle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
CellMarker
<
FACE
>
&
buildingMark
)
{
Dart
dd
=
d
;
do
...
...
@@ -23,7 +23,7 @@ bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildin
}
template
<
typename
PFP
>
bool
notDiagonalAdjacentToAnObstacle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
CellMarker
&
buildingMark
)
bool
notDiagonalAdjacentToAnObstacle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
CellMarker
<
FACE
>
&
buildingMark
)
{
Dart
dd
=
d
;
do
...
...
@@ -86,8 +86,8 @@ 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
)
float
sideLength
,
CellMarker
<
EDGE
>
&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
)
{
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim
(
map
,
position
)
;
prim
.
grid_topo
(
cX
,
cY
)
;
...
...
@@ -185,7 +185,7 @@ Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map,
template
<
typename
PFP
>
Dart
extrudeFaceAndMark
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
d
,
CellMarker
&
buildingMark
,
float
height
)
CellMarker
<
FACE
>
&
buildingMark
,
float
height
)
{
Dart
dRoof
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
d
,
height
)
;
buildingMark
.
mark
(
dRoof
)
;
...
...
@@ -206,8 +206,8 @@ bool animateCity(EnvMap* envMap)
typename
PFP
::
TVEC3
&
position
=
envMap
->
position
;
typename
PFP
::
TAB_AGENTVECT
&
agents
=
envMap
->
agentvect
;
typename
PFP
::
TAB_AGENTVECT
&
agentNeighbors
=
envMap
->
neighborAgentvect
;
CellMarker
&
obstacleMark
=
envMap
->
obstacleMark
;
CellMarker
&
buildingMark
=
envMap
->
buildingMark
;
CellMarker
<
EDGE
>
&
obstacleMark
=
envMap
->
obstacleMark
;
CellMarker
<
FACE
>
&
buildingMark
=
envMap
->
buildingMark
;
std
::
vector
<
Dart
>&
newBuildings
=
envMap
->
newBuildings
;
unsigned
int
state
=
rand
()
%
10
;
...
...
@@ -279,18 +279,18 @@ bool animateCity(EnvMap* envMap)
#endif
//template <typename PFP>
//Dart generateBuilding(typename PFP::MAP& map,
typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker
& buildingMark)
//Dart generateBuilding(typename PFP::MAP& map,
VertexAttribute<typename PFP::VEC3>& position, Dart d, float height, unsigned int buildingType, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>
& buildingMark)
//template <typename PFP>
//void generateCity(typename PFP::MAP& map,
typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker
& buildingMark, float sideSize, unsigned int nbSquares)
//void generateCity(typename PFP::MAP& map,
VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>
& buildingMark, float sideSize, unsigned int nbSquares)
template
<
typename
PFP
>
Dart
generateBuilding
(
EnvMap
&
envMap
,
Dart
d
,
float
height
,
unsigned
int
buildingType
)
{
typename
PFP
::
MAP
&
map
=
envMap
.
map
;
typename
PFP
::
TVEC3
&
position
=
envMap
.
position
;
CellMarker
&
obstacleMark
=
envMap
.
obstacleMark
;
CellMarker
&
buildingMark
=
envMap
.
buildingMark
;
CellMarker
<
EDGE
>
&
obstacleMark
=
envMap
.
obstacleMark
;
CellMarker
<
FACE
>
&
buildingMark
=
envMap
.
buildingMark
;
// mark the face as obstacle before extrusion
Dart
dd
=
d
;
...
...
@@ -302,7 +302,7 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
Dart
next
=
map
.
phi1
(
dd
)
;
Dart
previous
=
map
.
phi_1
(
dd
)
;
Obstacle
*
o
=
new
Obstacle
(
position
[
dd
],
position
[
next
],
position
[
previous
],
position
[
map
.
phi1
(
next
)]
)
;
position
[
map
.
phi1
(
next
)]
,
NULL
,
0
)
;
#ifdef SPATIAL_HASHING
VEC3
ov
=
o
->
p2
-
o
->
p1
;
...
...
@@ -329,7 +329,18 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
pos
+=
step
;
}
#else
envMap
.
pushObstacleInCells
(
o
,
map
.
phi2
(
dd
))
;
// David
// envMap.pushObstacleInCells(o, map.phi2(dd)) ;
// Thomas's team
Dart
x
=
map
.
phi2
(
dd
);
if
(
!
map
.
isBoundaryMarked
(
x
))
{
envMap
.
pushObstacleInCells
(
o
,
x
);
if
(
!
map
.
isBoundaryMarked
(
map
.
phi2
(
map
.
phi1
(
x
))))
envMap
.
pushObstacleInCells
(
o
,
map
.
phi2
(
map
.
phi1
(
x
)));
if
(
!
map
.
isBoundaryMarked
(
map
.
phi2
(
map
.
phi_1
(
x
))))
envMap
.
pushObstacleInCells
(
o
,
map
.
phi2
(
map
.
phi_1
(
x
)));
}
#endif
dd
=
map
.
phi1
(
dd
)
;
...
...
@@ -398,8 +409,8 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
}
template
<
typename
PFP
>
void
generateMall
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
float
sideSize
)
void
generateMall
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
<
EDGE
>
&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
,
float
sideSize
)
{
unsigned
int
side
=
5
;
std
::
vector
<
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
>
floors
;
...
...
@@ -414,7 +425,7 @@ void generateMall(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMar
{
float
floorHeight
=
100
;
typename
PFP
::
VEC3
transl
(
0
,
0
,
floorHeight
)
;
CellMarker
m
(
map
,
VERTEX
)
;
CellMarker
<
VERTEX
>
m
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
...
...
@@ -517,30 +528,38 @@ void generatePathToUpperStair(typename PFP::MAP& map, typename PFP::TVEC3& posit
}
template
<
typename
PFP
>
void
generatePlanet
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
float
radius
,
unsigned
int
nbSquares
)
void
generatePlanet
(
EnvMap
&
envMap
)
{
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim
(
map
,
position
)
;
prim
.
cylinder_topo
(
nbSquares
,
nbSquares
,
true
,
true
)
;
unsigned
int
nx
=
envMap
.
geometry
.
size
(
0
)
/
envMap
.
maxCellSize
;
unsigned
int
ny
=
envMap
.
geometry
.
size
(
1
)
/
envMap
.
maxCellSize
;
if
(
nx
<
1
)
nx
=
1
;
if
(
ny
<
1
)
ny
=
1
;
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim
(
envMap
.
map
,
envMap
.
position
)
;
prim
.
cylinder_topo
(
nx
,
ny
,
true
,
true
)
;
double
pi
=
3.14159265358979323846
f
;
double
xRadius
=
envMap
.
geometry
.
size
(
0
)
/
2
*
pi
;
double
yRadius
=
envMap
.
geometry
.
size
(
1
)
/
2
*
pi
;
prim
.
embedSphere
(
radius
)
;
prim
.
embedSphere
(
(
xRadius
+
yRadius
)
/
2.0
f
)
;
}
template
<
typename
PFP
>
void
simplifyFreeSpace
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
)
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
std
::
multimap
<
float
,
Dart
>
VEC_D_A
;
AutoAttributeHandler
<
float
>
tableArea
(
map
,
FACE
)
;
AutoAttributeHandler
<
CGoGN
::
NoMathIONameAttribute
<
VEC_D_A
::
iterator
>
>
tableIt
(
map
,
EDGE
)
;
FaceAutoAttribute
<
float
>
tableArea
(
map
)
;
EdgeAutoAttribute
<
CGoGN
::
NoMathIONameAttribute
<
VEC_D_A
::
iterator
>
>
tableIt
(
map
)
;
VEC_D_A
orderedD
;
// compute all heuristic and construct multimap
Algo
::
Geometry
::
computeAreaFaces
<
PFP
>
(
map
,
position
,
tableArea
)
;
CellMarker
eM
(
map
,
EDGE
)
;
CellMarker
<
EDGE
>
eM
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
eM
.
isMarked
(
d
)
&&
!
obstacleMark
.
isMarked
(
d
)
&&
!
buildingMark
.
isMarked
(
d
))
...
...
@@ -699,7 +718,7 @@ 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
)
bool
isAnEar
(
typename
PFP
::
MAP
&
map
,
VertexAttribute
<
typename
PFP
::
VEC3
>
&
position
,
Dart
dd
,
float
&
area
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
...
...
@@ -737,7 +756,7 @@ bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, flo
template
<
typename
PFP
>
bool
canRemoveEdgeConvex
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
d
,
CellMarker
&
obstacleMark
)
CellMarker
<
EDGE
>
&
obstacleMark
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
...
...
@@ -763,12 +782,12 @@ bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position,
template
<
typename
PFP
>
void
convexifyFreeSpace
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
)
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
float
area
;
CellMarker
m
(
map
,
FACE
)
;
CellMarker
<
FACE
>
m
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
...
...
@@ -836,10 +855,10 @@ void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position,
template
<
typename
PFP
>
void
installGuardRail
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
float
height
)
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
,
float
height
)
{
CellMarker
cm
(
map
,
EDGE
)
;
CellMarkerNoUnmark
railVert
(
map
,
EDGE
)
;
CellMarker
<
EDGE
>
cm
(
map
)
;
CellMarkerNoUnmark
<
EDGE
>
railVert
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
cm
.
isMarked
(
d
))
...
...
include/env_map.h
View file @
6db3ac1c
...
...
@@ -25,8 +25,9 @@
using
namespace
CGoGN
;
class
Agent
;
class
Obstacle
;
class
Agent
;
class
Obstacle
;
class
MovingObstacle
;
struct
PFP
:
public
PFP_STANDARD
{
...
...
@@ -36,10 +37,15 @@ struct PFP : public PFP_STANDARD
// definition des listes d'agent
typedef
std
::
vector
<
Agent
*>
AGENTS
;
typedef
std
::
vector
<
Obstacle
*>
OBSTACLES
;
typedef
std
::
vector
<
MovingObstacle
*>
MOVINGOBSTACLES
;
typedef
NoMathIONameAttribute
<
AGENTS
>
AGENTVECT
;
typedef
NoMathIONameAttribute
<
OBSTACLES
>
OBSTACLEVECT
;
typedef
AttributeHandler
<
AGENTVECT
>
TAB_AGENTVECT
;
typedef
AttributeHandler
<
OBSTACLEVECT
>
TAB_OBSTACLEVECT
;
typedef
NoMathIONameAttribute
<
MOVINGOBSTACLES
>
MOVINGOBSTACLEVECT
;
typedef
VertexAttribute
<
PFP
::
VEC3
>
TVEC3
;
typedef
FaceAttribute
<
AGENTVECT
>
TAB_AGENTVECT
;
typedef
FaceAttribute
<
OBSTACLEVECT
>
TAB_OBSTACLEVECT
;
typedef
NoMathIONameAttribute
<
std
::
pair
<
bool
,
bool
>
>
BOOLATTRIB
;
}
;
...
...
@@ -76,12 +82,11 @@ public:
void
subdivideAllToMaxLevel
()
;
void
subdivideToProperLevel
()
;
#endif
#ifndef SPATIAL_HASHING
void
foreach_neighborFace
(
Dart
d
,
FunctorType
&
f
)
;
void
registerObstaclesInFaces
()
;
void
registerWallInFaces
();
void
addNeighborObstacles
(
PFP
::
OBSTACLES
&
obst
,
Dart
d
,
bool
edgeNeighbor
)
;
void
setAgentNeighborsAndObstacles
(
Agent
*
agent
)
;
...
...
@@ -91,7 +96,6 @@ public:
void
nbAgentsDecrease
(
Dart
d
)
;
void
pushAgentInCells
(
Agent
*
agent
,
Dart
d
)
;
void
popAgentInCells
(
Agent
*
agent
,
Dart
d
)
;
// void agentChangeFaceThroughEdge(Agent* agent);
void
agentChangeFace
(
Agent
*
agent
,
Dart
oldFace
)
;
void
pushObstacleInCells
(
Obstacle
*
o
,
Dart
d
)
;
...
...
@@ -108,29 +112,39 @@ public:
PFP
::
MAP
mapScenary
;
PFP
::
TVEC3
positionScenary
;
PFP
::
TVEC3
normalScenary
;
CellMarker
obstacleMarkS
;
CellMarker
buildingMarkS
;
CellMarker
<
EDGE
>
obstacleMarkS
;
CellMarker
<
FACE
>
buildingMarkS
;
CellMarker
<
EDGE
>
obstacleMark
;
CellMarker
<
FACE
>
buildingMark
;
CellMarker
<
FACE
>
pedWayMark
;
// ajout moving obst
void
addObstAsNeighbor
(
Obstacle
*
o
,
const
std
::
list
<
Dart
>&
belonging_cells
,
std
::
list
<
Dart
>
*
nieghbor_cells
);
// void addMovingObstAsNeighbor (MovingObstacle * mo,std::list<Dart> belonging_cells, std::list<Dart> *neighbor_cells);
void
pushObstNeighborInCells
(
Obstacle
*
o
,
Dart
d
);
void
popObstNeighborInCells
(
Obstacle
*
o
,
Dart
d
);
void
find_next
(
Obstacle
*
o
,
Dart
*
d
,
CellMarkerStore
<
FACE
>&
cms
);
std
::
vector
<
Dart
>
newBuildings
;
#ifndef SPATIAL_HASHING
AttributeHandler
<
PFP
::
BOOLATTRIB
>
subdivisableFace
;
PFP
::
TAB_AGENTVECT
agentvect
;
PFP
::
TAB_AGENTVECT
neighborAgentvect
;
FaceAttribute
<
PFP
::
BOOLATTRIB
>
subdivisableFace
;
PFP
::
TAB_AGENTVECT
agentvect
;
PFP
::
TAB_AGENTVECT
neighborAgentvect
;
PFP
::
TAB_OBSTACLEVECT
neighborObstvect
;
#endif
PFP
::
TAB_OBSTACLEVECT
obstvect
;
CellMarker
obstacleMark
;
CellMarker
buildingMark
;
CellMarker
pedWayMark
;
#ifndef SPATIAL_HASHING
static
const
unsigned
int
nbAgentsToSubdivide
=
10
;
static
const
unsigned
int
nbAgentsToSimplify
=
4
;
CellMarker
refineMark
;
CellMarker
coarsenMark
;
CellMarker
<
FACE
>
refineMark
;
CellMarker
<
FACE
>
coarsenMark
;
std
::
vector
<
Dart
>
refineCandidate
;
std
::
vector
<
Dart
>
coarsenCandidate
;
...
...
@@ -148,32 +162,47 @@ public:
return
geometry
.
size
(
i
)
/
obstacleDistance
;
}
Geom
::
Vec2ui
agentPositionCell
(
VEC3
&
pos
)
{
VEC3
relativePos
=
pos
-
geometry
.
min
()
;
relativePos
/=
minCellSize
;
return
Geom
::
Vec2ui
(
relativePos
[
0
],
relativePos
[
1
])
;
}
Geom
::
Vec2ui
agentPositionCell
(
Agent
*
a
)
;
Geom
::
Vec2ui
obstaclePositionCell
(
VEC3
&
pos
)
Geom
::
Vec2ui
obstaclePositionCell
(
VEC3
pos
)
{
VEC3
relativePos
=
pos
-
geometry
.
min
()
;
relativePos
/=
obstacleDistance
;
return
Geom
::
Vec2ui
(
relativePos
[
0
],
relativePos
[
1
])
;
}
const
std
::
vector
<
Agent
*>&
getNeighbors
(
Geom
::
Vec2ui
c
)
{
assert
(
ht_agents
.
hasData
(
c
))
;
return
ht_agents
[
c
];
}
const
std
::
vector
<
Agent
*>&
getNeighbors
(
Agent
*
a
)
;
void
getOneRingNeighbors
(
Agent
*
a
,
std
::
vector
<
Agent
*>&
neighbors
)
;
void
addAgentInGrid
(
Agent
*
a
)
;
void
addAgentInGrid
(
Agent
*
a
,
Geom
::
Vec2ui
c
)
;
void
removeAgentFromGrid
(
Agent
*
a
)
;
void
removeAgentFromGrid
(
Agent
*
a
,
Geom
::
Vec2ui
c
)
;
HashTable2D
<
std
::
vector
<
Agent
*>
>
ht_agents
;
HashTable2D
<
std
::
vector
<
Agent
*>
>
ht_neighbor_agents
;
HashTable2D
<
std
::
vector
<
Obstacle
*>
>
ht_obstacles
;
#endif
}
;
void
update_registration
(
Obstacle
*
o
);
void
register_pop
(
Obstacle
*
o
,
int
n
);
void
resetObstInFace
(
Obstacle
*
o
);
void
resetObstPartInFace
(
Obstacle
*
o
,
Dart
d
);
void
resetPart
(
MovingObstacle
*
mo
,
Dart
d
);
void
displayMO
(
Obstacle
*
o
);
/**************************************
* INLINE FUNCTIONS *
**************************************/
template
<
typename
T
>
inline
void
removeElementFromVector
(
std
::
vector
<
T
>&
a
,
T
ag
)
inline
bool
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
)
...
...
@@ -182,9 +211,10 @@ inline void removeElementFromVector(std::vector<T>& a, T ag)
{
*
it
=
a
.
back
()
;
a
.
pop_back
()
;
return
;
return
true
;
}
}
return
false
;
}
#ifndef SPATIAL_HASHING
...
...
@@ -218,6 +248,7 @@ inline void EnvMap::nbAgentsDecrease(Dart d)
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
)
;
// nbAgentsIncrease(d);
...
...
@@ -257,9 +288,116 @@ inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
}
while
(
dd
!=
d
)
;
}
//ajout moving obst///////////////////////////////////////////////////////////////////////////////////////////////////////
inline
void
EnvMap
::
addObstAsNeighbor
(
Obstacle
*
o
,
const
std
::
list
<
Dart
>&
belonging_cells
,
std
::
list
<
Dart
>
*
neighbor_cells
)
{
assert
(
map
.
getCurrentLevel
()
==
map
.
getMaxLevel
());
neighbor_cells
->
clear
();
CellMarkerStore
<
FACE
>
MovingObstMark
(
map
);
CellMarkerStore
<
FACE
>
OneRingMark
(
map
);
for
(
std
::
list
<
Dart
>::
const_iterator
it
=
belonging_cells
.
begin
();
it
!=
belonging_cells
.
end
();
++
it
)
{
assert
(
!
buildingMark
.
isMarked
(
*
it
))
;
MovingObstMark
.
mark
(
*
it
);
}
std
::
list
<
Dart
>::
const_iterator
it
=
belonging_cells
.
begin
();
Dart
beg
=
NIL
;
Dart
first
=
NIL
;
Dart
d
=
NIL
;
Dart
dd
=
NIL
;
//boucle pour trouver une face du voisinage de l'obstacle ne contenant pas l'obstacle
do
{
beg
=
*
it
;
first
=
NIL
;
d
=
beg
;
do
{
dd
=
map
.
alpha1
(
map
.
alpha1
(
d
));
do
{
if
(
!
MovingObstMark
.
isMarked
(
dd
))
{
first
=
dd
;
}
dd
=
map
.
alpha1
(
dd
);
}
while
(
first
==
NIL
&&
dd
!=
d
);
d
=
map
.
phi1
(
d
);
}
while
(
first
==
NIL
&&
d
!=
beg
);
++
it
;
}
while
(
first
==
NIL
&&
it
!=
belonging_cells
.
end
());
assert
(
!
buildingMark
.
isMarked
(
d
))
;
d
=
first
;
do
{
if
(
!
OneRingMark
.
isMarked
(
d
))
{
OneRingMark
.
mark
(
d
);
(
*
neighbor_cells
).
push_back
(
d
);
}
find_next
(
o
,
&
d
,
MovingObstMark
);
}
while
(
!
map
.
sameFace
(
d
,
first
));
}
// find_next cherche la prochaine case "voisine" d'un obstacle faisant parti d'un movingobstacle (algo de parcours du one-ring )