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
C
CGoGN
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
658baf8f
Commit
658baf8f
authored
Feb 03, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
suppression SocialAgents
correction unsewFaces + edgeCollapse dans embeddedMap2 ajout simplif faces IHM
parent
ea07242a
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
68 additions
and
3809 deletions
+68
-3809
Apps/CMakeLists.txt
Apps/CMakeLists.txt
+0
-2
Apps/Examples/SocialAgents/Debug/CMakeLists.txt
Apps/Examples/SocialAgents/Debug/CMakeLists.txt
+0
-26
Apps/Examples/SocialAgents/Release/CMakeLists.txt
Apps/Examples/SocialAgents/Release/CMakeLists.txt
+0
-25
Apps/Examples/SocialAgents/include/agent.h
Apps/Examples/SocialAgents/include/agent.h
+0
-82
Apps/Examples/SocialAgents/include/env_generator.h
Apps/Examples/SocialAgents/include/env_generator.h
+0
-51
Apps/Examples/SocialAgents/include/env_generator.hpp
Apps/Examples/SocialAgents/include/env_generator.hpp
+0
-685
Apps/Examples/SocialAgents/include/env_map.h
Apps/Examples/SocialAgents/include/env_map.h
+0
-130
Apps/Examples/SocialAgents/include/env_render.h
Apps/Examples/SocialAgents/include/env_render.h
+0
-65
Apps/Examples/SocialAgents/include/mainwindow.h
Apps/Examples/SocialAgents/include/mainwindow.h
+0
-8
Apps/Examples/SocialAgents/include/path_finder.h
Apps/Examples/SocialAgents/include/path_finder.h
+0
-21
Apps/Examples/SocialAgents/include/path_finder.hpp
Apps/Examples/SocialAgents/include/path_finder.hpp
+0
-78
Apps/Examples/SocialAgents/include/simulator.h
Apps/Examples/SocialAgents/include/simulator.h
+0
-80
Apps/Examples/SocialAgents/include/utils.h
Apps/Examples/SocialAgents/include/utils.h
+0
-95
Apps/Examples/SocialAgents/include/viewer.h
Apps/Examples/SocialAgents/include/viewer.h
+0
-90
Apps/Examples/SocialAgents/src/agent.cpp
Apps/Examples/SocialAgents/src/agent.cpp
+0
-511
Apps/Examples/SocialAgents/src/env_map.cpp
Apps/Examples/SocialAgents/src/env_map.cpp
+0
-733
Apps/Examples/SocialAgents/src/simulator.cpp
Apps/Examples/SocialAgents/src/simulator.cpp
+0
-411
Apps/Examples/SocialAgents/src/viewer.cpp
Apps/Examples/SocialAgents/src/viewer.cpp
+0
-702
include/Topology/generic/embeddedMap2.hpp
include/Topology/generic/embeddedMap2.hpp
+26
-12
src/Algo/ImplicitHierarchicalMesh/ihm.cpp
src/Algo/ImplicitHierarchicalMesh/ihm.cpp
+42
-2
No files found.
Apps/CMakeLists.txt
View file @
658baf8f
...
...
@@ -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
)
...
...
Apps/Examples/SocialAgents/Debug/CMakeLists.txt
deleted
100644 → 0
View file @
ea07242a
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
}
)
Apps/Examples/SocialAgents/Release/CMakeLists.txt
deleted
100644 → 0
View file @
ea07242a
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
}
)
Apps/Examples/SocialAgents/include/agent.h
deleted
100644 → 0
View file @
ea07242a
#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
Apps/Examples/SocialAgents/include/env_generator.h
deleted
100644 → 0
View file @
ea07242a
#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
Apps/Examples/SocialAgents/include/env_generator.hpp
deleted
100644 → 0
View file @
ea07242a
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
)
{
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim
(
map
,
position
);
prim
.
grid_topo
(
side
,
1
);
// prim.embedCircle(rMin,rMax);
prim
.
embedHelicoid
(
rMin
,
rMax
,
nbTurns
*
20.0
f
,
nbTurns
);
// prim.embedGrid(100,100);
CellMarker
traite
(
map
,
FACE_CELL
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
()
;
map
.
next
(
d
))
{
if
(
!
traite
.
isMarked
(
d
))
{
traite
.
mark
(
d
);
map
.
splitFace
(
d
,
map
.
phi1
(
map
.
phi1
(
d
)));
}
}
map
.
closeMap
(
closeMark
)
;
map
.
initOrbitEmbedding
(
FACE_ORBIT
);
}
template
<
typename
PFP
>
void
generateToboggan
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
DartMarker
&
closeMark
,
unsigned
int
side
,
float
rMin
,
float
rMax
,
float
nbTurns
)
{
//the stairs
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim
(
map
,
position
);
prim
.
grid_topo
(
side
,
3
);
//the slide
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim2
(
map
,
position
);
prim2
.
grid_topo
(
side
/
4
,
3
);
float
height
=
150
;
prim2
.
embedHelicoid
(
rMin
*
4
,
rMax
,
-
1
*
height
,
0.5
f
,
-
1
);
// typename PFP::VEC3 transl(0,2*rMax,height);
typename
PFP
::
VEC3
transl
(
-
rMax
/
2
,
0
,
height
);
CellMarker
m
(
map
,
VERTEX_CELL
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
m
.
isMarked
(
d
))
{
m
.
mark
(
d
);
position
[
d
]
+=
transl
;
position
[
d
][
0
]
*=
2.0
f
;
}
}
prim
.
embedHelicoid
(
rMin
,
rMax
,
height
,
nbTurns
-
0.5
f
);
Dart
dStairsDown
=
map
.
phi_1
(
prim
.
getDart
());
Dart
dStairsUp
=
dStairsDown
;
do
{
closeMark
.
markOrbit
(
FACE_ORBIT
,
dStairsUp
);
closeMark
.
markOrbit
(
FACE_ORBIT
,
map
.
phi2
(
map
.
phi1
(
map
.
phi1
(
map
.
phi2
(
map
.
phi_1
(
dStairsUp
))))));
dStairsUp
=
map
.
phi2
(
map
.
phi1
(
map
.
phi1
(
dStairsUp
)));
}
while
(
map
.
phi2
(
dStairsUp
)
!=
dStairsUp
);
Dart
dSlideUp
=
map
.
phi_1
(
prim2
.
getDart
());
Dart
dSlideDown
=
dSlideUp
;
do
{
closeMark
.
markOrbit
(
FACE_ORBIT
,
dSlideDown
);
closeMark
.
markOrbit
(
FACE_ORBIT
,
map
.
phi2
(
map
.
phi1
(
map
.
phi1
(
map
.
phi2
(
map
.
phi_1
(
dSlideDown
))))));
dSlideDown
=
map
.
phi2
(
map
.
phi1
(
map
.
phi1
(
dSlideDown
)));
}
while
(
map
.
phi2
(
dSlideDown
)
!=
dSlideDown
);
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
primPathUp
(
map
,
position
);
primPathUp
.
grid_topo
(
1
,
3
);
Dart
dPathUp
=
map
.
phi_1
(
primPathUp
.
getDart
());
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
primPathDown
(
map
,
position
);
primPathDown
.
grid_topo
(
1
,
3
);
Dart
dPathDown
=
map
.
phi_1
(
primPathDown
.
getDart
());
closeMark
.
markOrbit
(
FACE_ORBIT
,
dPathUp
);
closeMark
.
markOrbit
(
FACE_ORBIT
,
dPathDown
);
map
.
sewFaces
(
dStairsUp
,
dPathUp
);
map
.
sewFaces
(
dSlideUp
,
map
.
phi1
(
map
.
phi1
(
dPathUp
)));
map
.
sewFaces
(
dSlideDown
,
dPathDown
);
map
.
sewFaces
(
dStairsDown
,
map
.
phi1
(
map
.
phi1
(
dPathDown
)));
dPathUp
=
map
.
phi_1
(
map
.
alpha1
(
dPathUp
));
dPathDown
=
map
.
phi_1
(
map
.
alpha1
(
dPathDown
));
dSlideUp
=
map
.
phi_1
(
map
.
alpha1
(
dSlideUp
));
dSlideDown
=
map
.
alpha_1
(
map
.
phi1
(
dSlideDown
));
dStairsUp
=
map
.
alpha_1
(
map
.
phi1
(
dStairsUp
));
dStairsDown
=
map
.
phi_1
(
map
.
alpha1
(
dStairsDown
));
// Dart dPathUp = map.newOrientedFace(4);
// Dart dPathDown = map.newOrientedFace(4);
map
.
sewFaces
(
dStairsUp
,
dPathUp
);
map
.
sewFaces
(
dSlideUp
,
map
.
phi1
(
map
.
phi1
(
dPathUp
)));
map
.
sewFaces
(
dSlideDown
,
dPathDown
);
map
.
sewFaces
(
dStairsDown
,
map
.
phi1
(
map
.
phi1
(
dPathDown
)));
dPathUp
=
map
.
phi_1
(
map
.
alpha1
(
dPathUp
));
dPathDown
=
map
.
phi_1
(
map
.
alpha1
(
dPathDown
));
dSlideUp
=
map
.
phi_1
(
map
.
alpha1
(
dSlideUp
));
dStairsUp
=
map
.
alpha_1
(
map
.
phi1
(
dStairsUp
));
dSlideDown
=
map
.
alpha_1
(
map
.
phi1
(
dSlideDown
));
dStairsDown
=
map
.
phi_1
(
map
.
alpha1
(
dStairsDown
));
closeMark
.
markOrbit
(
FACE_ORBIT
,
dPathUp
);
closeMark
.
markOrbit
(
FACE_ORBIT
,
dPathDown
);
map
.
sewFaces
(
dStairsUp
,
dPathUp
);
map
.
sewFaces
(
dSlideUp
,
map
.
phi1
(
map
.
phi1
(
dPathUp
)));
map
.
sewFaces
(
dSlideDown
,
dPathDown
);
map
.
sewFaces
(
dStairsDown
,
map
.
phi1
(
map
.
phi1
(
dPathDown
)));
// map.sewFaces(dStairsDown,dPathDown);
// map.sewFaces(dSlideDown,map.phi1(map.phi1(dPathDown)));
// map.sewFaces(dStairs,dSlide);
map
.
closeMap
(
closeMark
)
;
CellMarker
traite
(
map
,
FACE_CELL
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
()
;
map
.
next
(
d
))
{
if
(
!
traite
.
isMarked
(
d
))
{
traite
.
mark
(
d
);
map
.
splitFace
(
d
,
map
.
phi1
(
map
.
phi1
(
d
)));
}
}
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
()
;
map
.
next
(
d
))
{
if
(
closeMark
.
isMarked
(
d
))
{
closeMark
.
markOrbit
(
FACE_ORBIT
,
d
);
}
}
map
.
initOrbitEmbedding
(
FACE_ORBIT
);
}
template
<
typename
PFP
,
typename
EMBV
>
void
generateSmallCity
(
typename
PFP
::
MAP
&
map
,
EMBV
&
position
,
DartMarker
&
closeMark
,
float
sideSize
)
{
DartMarkerStore
obj
(
map
);
// sideSize *= 0.2f;
unsigned
int
nbBuilding
=
1000
;
float
height
=
sideSize
/
2.0
f
;
unsigned
int
side
=
5
;
generateGrid
<
PFP
,
EMBV
>
(
map
,
position
,
side
,
side
,
sideSize
,
closeMark
);
Dart
dEnd
=
map
.
end
();
for
(
Dart
d
=
map
.
begin
();
d
!=
dEnd
&&
nbBuilding
>
0
;
map
.
next
(
d
))
{
if
(
!
obj
.
isMarked
(
d
)
&&
(
rand
()
%
20
==
0
)
&&
notEightAdjacentToAnObstacle
<
PFP
,
EMBV
>
(
map
,
d
,
closeMark
))
{
typename
PFP
::
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
map
,
d
,
position
);
typename
PFP
::
VEC3
n2
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
map
,
map
.
phi2
(
d
),
position
);
if
(
position
[
d
][
2
]
==
0.0
f
&&
position
[
map
.
phi1
(
d
)][
2
]
==
0.0
f
&&
position
[
map
.
phi_1
(
d
)][
2
]
==
0.0
f
&&
n1
[
0
]
==
0.0
f
&&
n1
[
1
]
==
0.0
f
&&
n1
[
2
]
==
1.0
f
&&
n1
[
0
]
==
n2
[
0
]
&&
n1
[
1
]
==
n2
[
1
]
&&
n1
[
2
]
==
n2
[
2
]
&&
map
.
faceDegree
(
d
)
==
4
)
{
obj
.
markOrbit
(
FACE_ORBIT
,
d
);
generateBuilding
<
PFP
,
EMBV
>
(
map
,
position
,
d
,
obj
,(
1
+
(
rand
()
%
3
))
*
height
/
2.0
f
,
side
,
rand
()
%
2
,
closeMark
);
--
nbBuilding
;
}
}
}
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
closeMark
.
isMarked
(
d
)
&&
map
.
faceDegree
(
d
)
>
4
)
{
Dart
dd
=
d
;
do
{
closeMark
.
markOrbit
(
DART_ORBIT
,
dd
);
dd
=
map
.
phi1
(
dd
);
}
while
(
position
[
dd
][
2
]
==
0.0
f
&&
position
[
map
.
phi1
(
dd
)][
2
]
==
0.0
f
&&
dd
!=
d
);
dd
=
d
;
do
{
closeMark
.
markOrbit
(
DART_ORBIT
,
dd
);
dd
=
map
.
phi_1
(
dd
);
}
while
(
position
[
dd
][
2
]
==
0.0
f
&&
position
[
map
.
phi1
(
dd
)][
2
]
==
0.0
f
&&
dd
!=
d
);
}
}
map
.
closeMap
(
closeMark
);
}
template
<
typename
PFP
,
typename
EMBV
>
void
generateCity
(
typename
PFP
::
MAP
&
map
,
EMBV
&
position
,
DartMarker
&
closeMark
,
float
sideSize
)
{
DartMarkerStore
obj
(
map
);
unsigned
int
nbBuilding
=
100
;
// unsigned int nbBuilding=20;
float
height
=
sideSize
;
// unsigned int side = 50;
unsigned
int
side
=
40
;
// unsigned int side = 20;
// unsigned int side = 10;
generateGrid
<
PFP
,
EMBV
>
(
map
,
position
,
side
,
side
,
height
,
closeMark
);
Dart
dEnd
=
map
.
end
();
for
(
Dart
d
=
map
.
begin
();
d
!=
dEnd
&&
nbBuilding
>
0
;
map
.
next
(
d
))
{
if
(
!
obj
.
isMarked
(
d
)
&&
(
rand
()
%
20
==
0
)
&&
notEightAdjacentToAnObstacle
<
PFP
,
EMBV
>
(
map
,
d
,
closeMark
))
{
typename
PFP
::
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
map
,
d
,
position
);
typename
PFP
::
VEC3
n2
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
map
,
map
.
phi2
(
d
),
position
);
if
(
position
[
d
][
2
]
==
0.0
f
&&
position
[
map
.
phi1
(
d
)][
2
]
==
0.0
f
&&
position
[
map
.
phi_1
(
d
)][
2
]
==
0.0
f
&&
n1
[
0
]
==
0.0
f
&&
n1
[
1
]
==
0.0
f
&&
n1
[
2
]
==
1.0
f
&&
n1
[
0
]
==
n2
[
0
]
&&
n1
[
1
]
==
n2
[
1
]
&&
n1
[
2
]
==
n2
[
2
]
&&
map
.
faceDegree
(
d
)
==
4
)
{
obj
.
markOrbit
(
FACE_ORBIT
,
d
);
generateBuilding
<
PFP
,
EMBV
>
(
map
,
position
,
d
,
obj
,(
1
+
(
rand
()
%
3
))
*
height
/
2.0
f
,
side
,
rand
()
%
4
,
closeMark
);
--
nbBuilding
;
}
}
}
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
closeMark
.
isMarked
(
d
)
&&
map
.
faceDegree
(
d
)
>
4
)
{
Dart
dd
=
d
;
do
{
closeMark
.
markOrbit
(
DART_ORBIT
,
dd
);
dd
=
map
.
phi1
(
dd
);
}
while
(
position
[
dd
][
2
]
==
0.0
f
&&
position
[
map
.
phi1
(
dd
)][
2
]
==
0.0
f
&&
dd
!=
d
);
dd
=
d
;
do
{
closeMark
.
markOrbit
(
DART_ORBIT
,
dd
);
dd
=
map
.
phi_1
(
dd
);
}
while
(
position
[
dd
][
2
]
==
0.0
f
&&
position
[
map
.
phi1
(
dd
)][
2
]
==
0.0
f
&&
dd
!=
d
);
}
}
map
.
closeMap
(
closeMark
);
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMBAGENT
>
void
animateCity
(
typename
PFP
::
MAP
&
map
,
EMBV
&
position
,
EMBAGENT
&
agents
,
DartMarker
&
closeMark
,
std
::
vector
<
Dart
>&
newBuildings
)
{
unsigned
int
state
=
rand
()
%
10
;
if
(
state
<
3
)
{
//generate new building
bool
found
=
false
;
Dart
d
;
for
(
d
=
map
.
begin
()
;
!
found
&&
d
!=
map
.
end
()
;
map
.
next
(
d
))
{
if
(
!
closeMark
.
isMarked
(
d
)
&&
agents
[
d
].
size
()
==
0
&&
notEightAdjacentToAnObstacle
<
PFP
,
EMBV
>
(
map
,
d
,
closeMark
))
{
typename
PFP
::
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
map
,
d
,
position
);
typename
PFP
::
VEC3
n2
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
map
,
map
.
phi2
(
d
),
position
);
bool
groundZero
=
true
;
Dart
dd
=
d
;
do
{
if
(
position
[
dd
][
2
]
!=
0.0
f
)
groundZero
=
false
;
dd
=
map
.
phi1
(
dd
);
}
while
(
groundZero
&&
dd
!=
d
);
if
(
groundZero
&&
n1
[
0
]
==
0.0
f
&&
n1
[
1
]
==
0.0
f
&&
n1
[
2
]
==
1.0
f
&&
n1
[
0
]
==
n2
[
0
]
&&
n1
[
1
]
==
n2
[
1
]
&&
n1
[
2
]
==
n2
[
2
])
{
found
=
true
;
break
;
}
}
}
if
(
found
)
{
if
(
map
.
faceDegree
(
d
)
>
16
)
{
}
closeMark
.
markOrbit
(
FACE_ORBIT
,
d
);
d
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
d
,
2.0
f
);
newBuildings
.
push_back
(
d
);
}
}
else
if
(
newBuildings
.
size
()
>
0
)
{
//take a newBuilding and make it higher
state
=
rand
()
%
newBuildings
.
size
();
Dart
d
=
newBuildings
[
state
];
//decide if we create a new floor, or just make it higher
unsigned
int
typeOfUpdate
=
rand
()
%
10
;
if
(
typeOfUpdate
<
9
)
{
Dart
dd
=
d
;
do
{
position
[
dd
][
2
]
+=
2.0
f
;
dd
=
map
.
phi1
(
dd
);
}
while
(
dd
!=
d
);
if
(
position
[
dd
][
2
]
>
((
10
+
rand
()
%
10
)
*
10.0
f
))
newBuildings
.
erase
(
newBuildings
.
begin
()
+
state
);
}
else
{
typename
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
d
,
position
);
Dart
dRoofSmall
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
d
,
0.0
f
);
Dart
dd
=
dRoofSmall
;
do
{
position
[
dd
]
=
position
[
dd
]
+
(
c
-
position
[
dd
])
/
3.0
f
;
dd
=
map
.
phi1
(
dd
);
}
while
(
dd
!=
dRoofSmall
);
Dart
dRoof
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
dRoofSmall
,
2.0
f
);
newBuildings
.
erase
(
newBuildings
.
begin
()
+
state
);
newBuildings
.
push_back
(
dRoof
);
}
}
}
template
<
typename
PFP
,
typename
EMBV
>
bool
notEightAdjacentToAnObstacle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
DartMarker
&
closeMark
)
{
Dart
dd
=
d
;
do
{
if
(
closeMark
.
isMarked
(
map
.
alpha1
(
map
.
alpha1
(
dd
))))
return
false
;
dd
=
map
.
phi1
(
dd
);
}
while
(
dd
!=
d
);
return
true
;
}
template
<
typename
PFP
,
typename
EMBV
>
void
generateGrid
(
typename
PFP
::
MAP
&
map
,
EMBV
&
position
,
unsigned
int
cX
,
unsigned
int
cY
,
float
sideLength
,
DartMarker
&
closeMark
)
{
Algo
::
Modelisation
::
Polyhedron
<
PFP
>
prim
(
map
,
position
);
prim
.
grid_topo
(
cX
,
cY
);
map
.
closeMap
(
closeMark
)
;
prim
.
embedGrid
(
sideLength
*
cX
,
sideLength
*
cY
);
map
.
initOrbitEmbedding
(
FACE_ORBIT
);
}
template
<
typename
PFP
,
typename
EMBV
>
void
markObstacleSteepFaces
(
typename
PFP
::
MAP
&
map
,
EMBV
&
position
,
float
steepness
,
DartMarker
&
closeMark
)
{
DartMarkerStore
treated
(
map
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
closeMark
.
isMarked
(
d
)
&&
!
treated
.
isMarked
(
d
))
{
treated
.
markOrbit
(
FACE_ORBIT
,
d
);
typename
PFP
::
VEC3
n
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
map
,
d
,
position
);
if
(
fabs
(
n
*
typename
PFP
::
VEC3
(
1
,
1
,
0
))
>
steepness
&&
!
(
n
[
2
]
<-
0.5
f
))
{
closeMark
.
markOrbit
(
FACE_ORBIT
,
d
);
}
}
if
(
closeMark
.
isMarked
(
d
)
&&
closeMark
.
isMarked
(
map
.
phi2
(
d
)))
{
closeMark
.
unmarkOrbit
(
EDGE_ORBIT
,
d
);
}
}
}
//void EnvMap::generateStairs(Dart d, float stepSize, float maxHeight)
//{
// for(float currentHeight=0.0f; currentHeight<maxHeight ; currentHeight += stepSize) {
// //create one step
// Dart dStep = Algo::Modelisation::extrudeFace<PFP>(map,position,d,stepSize);
// typename PFP::VEC3 vecStep = position[map.phi1(map.phi1(d))]-position[map.phi1(d)];
// vecStep.normalize();
// vecStep *= stepSize;
// map.cutEdge(map.phi1(dStep));
// map.cutEdge(map.phi_1(dStep));
// position[map.phi1(map.phi1(dStep))] = position[map.phi1(dStep)] + vecStep;
// position[map.phi_1(dStep)] = position[dStep] + vecStep;
// map.splitFace(map.phi_1(dStep),map.phi1(map.phi1(dStep)));
// d = map.phi2(map.phi1(map.phi1(dStep)));
// }
//}
template
<
typename
PFP
,
typename
EMBV
>
void
generatePathToUpperStair
(
typename
PFP
::
MAP
&
map
,
EMBV
&
position
,
Dart
dLower
,
Dart
dUpper
)
{
if
(
dLower
!=
map
.
phi2
(
dLower
)
||
dUpper
!=
map
.
phi2
(
dUpper
))
{
std
::
cout
<<
"generatePathToUpperStair : lower and upper stair darts must be fixpoint in phi2"
<<
std
::
endl
;
return
;
}
//create the path
Dart
dPathUp
=
map
.
newOrientedFace
(
4
);
Dart
dInBetween
=
map
.
newOrientedFace
(
4
);
map
.
cutEdge
(
dInBetween
);
map
.
cutEdge
(
dInBetween
);
Dart
dPathDown
=
map
.
newOrientedFace
(
4
);
//sew the path
map
.
sewFaces
(
dLower
,
dPathUp
);
map
.
sewFaces
(
map
.
phi1
(
map
.
phi1
(
dPathUp
)),
map
.
phi1
(
map
.
phi1
(
dInBetween
)));
map
.
sewFaces
(
map
.
phi1
(
map
.
phi1
(
dPathDown
)),
dInBetween
);
map
.
sewFaces
(
dUpper
,
dPathDown
);
//embed the inBetween floor
float
z
=
(
position
[
dLower
][
2
]
+
position
[
dUpper
][
2
])
/
2.0
f
;
//from lower path
position
[
dInBetween
]
=
position
[
dLower
]
+
(
position
[
dLower
]
-
position
[
map
.
phi_1
(
dLower
)]);
position
[
map
.
phi1
(
dInBetween
)]
=
position
[
map
.
phi1
(
dLower
)]
+
(
position
[
map
.
phi1
(
dLower
)]
-
position
[
map
.
phi1
(
map
.
phi1
(
dLower
))]);
//from upper path
position
[
map
.
phi1
(
map
.
phi1
(
dInBetween
))]
=
position
[
dUpper
]
+
(
position
[
dUpper
]
-
position
[
map
.
phi_1
(
dUpper
)]);
position
[
map
.
phi1
(
map
.
phi1
(
map
.
phi1
(
dInBetween
)))]
=
position
[
map
.
phi1
(
dU