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
f74b0ffe
Commit
f74b0ffe
authored
Oct 15, 2012
by
David Cazier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge avec le nouveau CGoGN
parent
816beba3
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
310 additions
and
319 deletions
+310
-319
include/env_generator.h
include/env_generator.h
+13
-13
include/env_generator.hpp
include/env_generator.hpp
+24
-24
include/env_map.h
include/env_map.h
+30
-20
include/env_render.h
include/env_render.h
+1
-1
include/exportObstacles.h
include/exportObstacles.h
+1
-1
include/exportObstacles.hpp
include/exportObstacles.hpp
+2
-2
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
+1
-1
include/spatialHashing.h
include/spatialHashing.h
+10
-10
include/viewer.h
include/viewer.h
+1
-1
src/agent.cpp
src/agent.cpp
+40
-9
src/env_map.cpp
src/env_map.cpp
+78
-27
src/simulator.cpp
src/simulator.cpp
+91
-194
src/viewer.cpp
src/viewer.cpp
+11
-9
No files found.
include/env_generator.h
View file @
f74b0ffe
...
...
@@ -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,12 +21,12 @@ 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
>
...
...
@@ -34,17 +34,17 @@ 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, typename PFP::TVEC3& 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, typename PFP::TVEC3& 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
)
;
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
,
...
...
@@ -53,8 +53,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
)
;
/*******************************************************************************/
...
...
@@ -66,15 +66,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 @
f74b0ffe
...
...
@@ -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
;
...
...
@@ -289,8 +289,8 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
{
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
;
...
...
@@ -398,8 +398,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 +414,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,8 +517,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
)
{
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim
(
map
,
position
)
;
prim
.
cylinder_topo
(
nbSquares
,
nbSquares
,
true
,
true
)
;
...
...
@@ -528,19 +528,19 @@ void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellM
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
))
...
...
@@ -737,7 +737,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 +763,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 +836,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 @
f74b0ffe
...
...
@@ -38,8 +38,9 @@ struct PFP : public PFP_STANDARD
typedef
std
::
vector
<
Obstacle
*>
OBSTACLES
;
typedef
NoMathIONameAttribute
<
AGENTS
>
AGENTVECT
;
typedef
NoMathIONameAttribute
<
OBSTACLES
>
OBSTACLEVECT
;
typedef
AttributeHandler
<
AGENTVECT
>
TAB_AGENTVECT
;
typedef
AttributeHandler
<
OBSTACLEVECT
>
TAB_OBSTACLEVECT
;
typedef
VertexAttribute
<
PFP
::
VEC3
>
TVEC3
;
typedef
FaceAttribute
<
AGENTVECT
>
TAB_AGENTVECT
;
typedef
FaceAttribute
<
OBSTACLEVECT
>
TAB_OBSTACLEVECT
;
typedef
NoMathIONameAttribute
<
std
::
pair
<
bool
,
bool
>
>
BOOLATTRIB
;
}
;
...
...
@@ -108,13 +109,13 @@ public:
PFP
::
MAP
mapScenary
;
PFP
::
TVEC3
positionScenary
;
PFP
::
TVEC3
normalScenary
;
CellMarker
obstacleMarkS
;
CellMarker
buildingMarkS
;
CellMarker
<
EDGE
>
obstacleMarkS
;
CellMarker
<
FACE
>
buildingMarkS
;
std
::
vector
<
Dart
>
newBuildings
;
#ifndef SPATIAL_HASHING
AttributeHandler
<
PFP
::
BOOLATTRIB
>
subdivisableFace
;
FaceAttribute
<
PFP
::
BOOLATTRIB
>
subdivisableFace
;
PFP
::
TAB_AGENTVECT
agentvect
;
PFP
::
TAB_AGENTVECT
neighborAgentvect
;
...
...
@@ -122,16 +123,16 @@ public:
PFP
::
TAB_OBSTACLEVECT
obstvect
;
CellMarker
obstacleMark
;
CellMarker
buildingMark
;
CellMarker
pedWayMark
;
CellMarker
<
EDGE
>
obstacleMark
;
CellMarker
<
FACE
>
buildingMark
;
CellMarker
<
FACE
>
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
;
...
...
@@ -149,22 +150,30 @@ 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<Agent*> > ht_neighbor_agents ;
HashTable2D
<
std
::
vector
<
Obstacle
*>
>
ht_obstacles
;
#endif
}
;
...
...
@@ -174,7 +183,7 @@ public:
**************************************/
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
)
...
...
@@ -183,9 +192,10 @@ inline void removeElementFromVector(std::vector<T>& a, T ag)
{
*
it
=
a
.
back
()
;
a
.
pop_back
()
;
return
;
return
true
;
}
}
return
false
;
}
#ifndef SPATIAL_HASHING
...
...
include/env_render.h
View file @
f74b0ffe
...
...
@@ -51,7 +51,7 @@ inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
#ifdef SPATIAL_HASHING
const
VEC3
&
pos
=
agent
->
pos
;
#else
VEC3
pos
=
agent
->
part_
.
m_position
;
VEC3
pos
=
agent
->
part_
.
getPosition
()
;
#endif
float
radius
=
agent
->
radius_
;
...
...
include/exportObstacles.h
View file @
f74b0ffe
...
...
@@ -9,7 +9,7 @@ namespace ExportScene
template
<
typename
PFP
>
bool
exportSceneToFile
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
std
::
string
&
filename
)
;
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
,
std
::
string
&
filename
)
;
}
...
...
include/exportObstacles.hpp
View file @
f74b0ffe
...
...
@@ -8,7 +8,7 @@ namespace ExportScene
template
<
typename
PFP
>
bool
exportSceneToFile
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
obstacleMark
,
CellMarker
&
buildingMark
,
std
::
string
&
filename
)
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>
&
buildingMark
,
std
::
string
&
filename
)
{
std
::
ofstream
out
(
filename
.
c_str
(),
std
::
ios
::
out
)
;
if
(
!
out
.
good
())
...
...
@@ -17,7 +17,7 @@ bool exportSceneToFile(typename PFP::MAP& map, const typename PFP::TVEC3& positi
return
false
;
}
CellMarker
f
(
map
,
FACE
)
;
CellMarker
<
FACE
>
f
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
...
...
include/path_finder.h
View file @
f74b0ffe
...
...
@@ -9,11 +9,11 @@ namespace PathFinder
template
<
typename
PFP
>
float
pathCostSqr
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
Dart
startPos
,
Dart
stopPos
,
CellMarker
&
bad
)
;
Dart
stopPos
,
CellMarker
<
FACE
>
&
bad
)
;
template
<
typename
PFP
>
std
::
vector
<
Dart
>
pathFindAStar
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
Dart
startPos
,
Dart
stopPos
,
CellMarker
&
bad
)
;
Dart
startPos
,
Dart
stopPos
,
CellMarker
<
FACE
>
&
bad
)
;
}
...
...
include/path_finder.hpp
View file @
f74b0ffe
...
...
@@ -10,7 +10,7 @@ namespace PathFinder
template
<
typename
PFP
>
float
pathCostSqr
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
Dart
startPos
,
Dart
stopPos
,
CellMarker
&
bad
)
Dart
stopPos
,
CellMarker
<
FACE
>
&
bad
)
{
// float penalty=100000000.0f;
// Dart dd = startPos;
...
...
@@ -32,16 +32,16 @@ float pathCostSqr(typename PFP::MAP& map, const typename PFP::TVEC3& position, D
template
<
typename
PFP
>
std
::
vector
<
Dart
>
pathFindAStar
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
Dart
startPos
,
Dart
stopPos
,
CellMarker
&
bad
)
Dart
startPos
,
Dart
stopPos
,
CellMarker
<
FACE
>
&
bad
)
{
std
::
vector
<
Dart
>
path
;
AutoAttributeHandler
<
float
>
tablePathCost
(
map
,
FACE
)
;
AutoAttributeHandler
<
Dart
>
tablePred
(
map
,
FACE
)
;
FaceAutoAttribute
<
float
>
tablePathCost
(
map
)
;
FaceAutoAttribute
<
Dart
>
tablePred
(
map
)
;
std
::
multimap
<
float
,
Dart
>
vToDev
;
CellMarker
m
(
map
,
FACE
)
;
CellMarker
<
FACE
>
m
(
map
)
;
vToDev
.
insert
(
std
::
make_pair
(
0
,
stopPos
))
;
...
...
include/simulator.h
View file @
f74b0ffe
...
...
@@ -88,7 +88,7 @@ public:
void
init
(
unsigned
int
config
,
int
minSize
,
float
dimension
,
bool
enablePathFinding
=
false
)
;
void
setupCircleScenario
(
unsigned
int
nbMaxAgent
)
;
void
setupCorridorScenario
(
unsigned
int
nbMaxAgent
)
;
void
setupCityScenario
(
float
startX
,
float
startY
,
int
nbLines
,
int
nbRank
)
;
void
setupCityScenario
(
int
nbLines
,
int
nbRank
)
;
void
setupScenario
(
unsigned
int
nbMaxAgent
)
;
void
doStep
()
;
...
...
include/spatialHashing.h
View file @
f74b0ffe
...
...
@@ -93,16 +93,15 @@ public:
return
m_table
[
c
].
back
().
second
;
}
// TODO : pas de valeur de retour si la valeur n'est pas trouvée
// const DATA& operator[](const Geom::Vec2ui& k) const
// {
// unsigned int c = hash(k) ;
//
// for (typename cell_type::iterator it = m_table[c].begin(); it != m_table[c].end(); ++it)
// {
// if (it->first == k) return it->second ;
// }
// }
const
DATA
&
operator
[](
const
Geom
::
Vec2ui
&
k
)
const
{
unsigned
int
c
=
hash
(
k
)
;
for
(
typename
cell_type
::
iterator
it
=
m_table
[
c
].
begin
();
it
!=
m_table
[
c
].
end
();
++
it
)
{
if
(
it
->
first
==
k
)
return
it
->
second
;
}
}
bool
hasData
(
const
Geom
::
Vec2ui
&
k
)
{
...
...
@@ -127,6 +126,7 @@ public:
return
;
}
}
std
::
cout
<<
"HashTable2D: Suppression impossible"
<<
std
::
endl
;
}
private:
...
...
include/viewer.h
View file @
f74b0ffe
...
...
@@ -77,7 +77,7 @@ public:
int
maxIterations
;
// to count fps
int
frames
;
clock_t
nex
tUpdate
;
clock_t
las
tUpdate
;
Simulator
sim
;
SelectorTrue
allDarts
;
...
...
src/agent.cpp
View file @
f74b0ffe
...
...
@@ -51,7 +51,7 @@ VEC3 Agent::getPosition()
#ifdef SPATIAL_HASHING
return
pos
;
#else
return
part_
.
m_position
;
return
part_
.
getPosition
()
;
#endif
}
...
...
@@ -70,15 +70,13 @@ void Agent::updateAgentNeighbors()
agentNeighbors_
.
clear
()
;
#ifdef SPATIAL_HASHING
Geom
::
Vec2ui
c
=
sim_
->
envMap_
.
agentPositionCell
(
pos
)
;
const
std
::
vector
<
Agent
*>&
agents
=
sim_
->
envMap_
.
ht_agents
[
c
]
;
const
std
::
vector
<
Agent
*>&
neighborAgents
=
sim_
->
envMap_
.
ht_neighbor_agents
[
c
]
;
const
std
::
vector
<
Agent
*>&
agents
=
sim_
->
envMap_
.
getNeighbors
(
this
)
;
#else
const
std
::
vector
<
Agent
*>&
agents
=
sim_
->
envMap_
.
agentvect
[
part_
.
d
]
;
const
std
::
vector
<
Agent
*>&
neighborAgents
=
sim_
->
envMap_
.
neighborAgentvect
[
part_
.
d
]
;
#endif
float
maxDist
=
0.0
f
;
for
(
std
::
vector
<
Agent
*>::
const_iterator
it
=
agents
.
begin
();
it
!=
agents
.
end
();
++
it
)
{
if
(
*
it
!=
this
)
...
...
@@ -93,6 +91,37 @@ void Agent::updateAgentNeighbors()
}
}
int
nbNeighborAgents
=
0
;
#ifdef SPATIAL_HASHING
Geom
::
Vec2ui
c
=
sim_
->
envMap_
.
agentPositionCell
(
this
)
;
for
(
int
ii
=
-
1
;
ii
<=
1
;
++
ii
)
{
for
(
int
jj
=
-
1
;
jj
<=
1
;
++
jj
)
{
if
(
ii
!=
0
||
jj
!=
0
)
{
Geom
::
Vec2ui
cc
=
c
+
Geom
::
Vec2ui
(
ii
,
jj
)
;
if
(
sim_
->
envMap_
.
ht_agents
.
hasData
(
cc
))
{
const
std
::
vector
<
Agent
*>&
neighborAgents
=
sim_
->
envMap_
.
getNeighbors
(
cc
)
;
nbNeighborAgents
+=
neighborAgents
.
size
()
;
for
(
std
::
vector
<
Agent
*>::
const_iterator
it
=
neighborAgents
.
begin
();
it
!=
neighborAgents
.
end
();
++
it
)
{
float
distSq
=
(
getPosition
()
-
(
*
it
)
->
getPosition
()).
norm2
()
;
if
((
agentNeighbors_
.
size
()
<
maxNeighbors_
||
distSq
<
maxDist
)
&&
distSq
<
neighborDistSq_
)
{
if
(
distSq
>
maxDist
)
maxDist
=
distSq
;
agentNeighbors_
.
push_back
(
std
::
make_pair
(
distSq
,
*
it
))
;
}
}
}
}
}
}
#else
const
std
::
vector
<
Agent
*>&
neighborAgents
=
sim_
->
envMap_
.
neighborAgentvect
[
part_
.
d
]
;
for
(
std
::
vector
<
Agent
*>::
const_iterator
it
=
neighborAgents
.
begin
();
it
!=
neighborAgents
.
end
();
++
it
)
{
...
...
@@ -104,10 +133,12 @@ void Agent::updateAgentNeighbors()
agentNeighbors_
.
push_back
(
std
::
make_pair
(
distSq
,
*
it
))
;
}
}
nbNeighborAgents
=
neighborAgents
.
size
()
;
#endif
sim_
->
nbUpdates
++
;
sim_
->
nearNeighbors
+=
agentNeighbors_
.
size
()
;
sim_
->
totalNeighbors
+=
agents
.
size
()
+
n
eighborAgents
.
size
()
;
sim_
->
totalNeighbors
+=
agents
.
size
()
+
n
bNeighborAgents
;
if
(
agentNeighbors_
.
size
()
>
maxNeighbors_
)
{
...
...
@@ -139,10 +170,10 @@ void Agent::updateObstacleNeighbors()
std
::
vector
<
Obstacle
*>&
obst
=
sim_
->
envMap_
.
obstvect
[
part_
.
d
]
;
for
(
std
::
vector
<
Obstacle
*>::
const_iterator
it
=
obst
.
begin
();
it
!=
obst
.
end
();
++
it
)
{
float
distSq
=
distSqPointLineSegment
((
*
it
)
->
p1
,
(
*
it
)
->
p2
,
part_
.
m_position
)
;
float
distSq
=
distSqPointLineSegment
((
*
it
)
->
p1
,
(
*
it
)
->
p2
,
part_
.
getPosition
()
)
;
if
(
distSq
<
rangeSq_
)
{
if
(
Geom
::
testOrientation2D
(
part_
.
m_position
,
(
*
it
)
->
p1
,
(
*
it
)
->
p2
)
==
Geom
::
RIGHT
)
obstacleNeighbors_
.
push_back
(
if
(
Geom
::
testOrientation2D
(
part_
.
getPosition
()
,
(
*
it
)
->
p1
,
(
*
it
)
->
p2
)
==
Geom
::
RIGHT
)
obstacleNeighbors_
.
push_back
(
std
::
make_pair
(
distSq
,
*
it
))
;
}
}
...
...
@@ -160,7 +191,7 @@ void Agent::update()
#ifdef SPATIAL_HASHING
pos
=
pos
+
(
velocity_
*
timeStep
)
;
#else
VEC3
target
=
part_
.
m_position
+
(
velocity_
*
timeStep
)
;
VEC3
target
=
part_
.
getPosition
()
+
(
velocity_
*
timeStep
)
;
#endif
meanSpeed_
*=
3.0
f
;
...
...
src/env_map.cpp
View file @
f74b0ffe
...
...
@@ -16,28 +16,27 @@ using namespace CGoGN ;
EnvMap
::
EnvMap
()
:
obstacleDistance
(
Agent
::
range_
),
obstacleMarkS
(
mapScenary
,
EDGE
),
buildingMarkS
(
mapScenary
,
FACE
),
obstacleMark
(
map
,
EDGE
),
buildingMark
(
map
,
FACE
),
pedWayMark
(
map
,
FACE
),
obstacleMarkS
(
mapScenary
),
buildingMarkS
(
mapScenary
),
obstacleMark
(
map
),
buildingMark
(
map
),
pedWayMark
(
map
),
#ifndef SPATIAL_HASHING
refineMark
(
map
,
FACE
),
coarsenMark
(
map
,
FACE
)
refineMark
(
map
),
coarsenMark
(
map
)
#else
ht_agents
(
1024
),
ht_neighbor_agents
(
1024
),
ht_obstacles
(
1024
)
#endif
{
position
=
map
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
)
;
normal
=
map
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"normal"
)
;
position
=
map
.
addAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"position"
)
;
normal
=
map
.
addAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"normal"
)
;
#ifndef SPATIAL_HASHING