Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
6a8e9fff
Commit
6a8e9fff
authored
May 26, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bientot la simplif remarche !
parent
fe22bd55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
35 deletions
+74
-35
include/env_map.h
include/env_map.h
+6
-8
src/env_map.cpp
src/env_map.cpp
+68
-27
No files found.
include/env_map.h
View file @
6a8e9fff
...
...
@@ -90,14 +90,12 @@ public :
CellMarker
buildingMark
;
static
const
unsigned
int
nbAgentsToSubdivide
=
7
;
static
const
unsigned
int
nbAgentsToSimplify
=
7
;
// std::map<unsigned int, Dart> refineCandidate;
// std::map<unsigned int, Dart> coarsenCandidate;
static
const
unsigned
int
nbAgentsToSimplify
=
5
;
CellMarker
refineMark
;
std
::
vector
<
Dart
>
refineCandidate
;
// std::vector<Dart> coarsenCandidate;
CellMarker
coarsenMark
;
std
::
vector
<
Dart
>
coarsenCandidate
;
};
/**************************************
...
...
@@ -128,10 +126,10 @@ inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
{
assert
(
map
.
getCurrentLevel
()
==
map
.
getMaxLevel
());
assert
(
std
::
find
(
agentvect
[
d
].
begin
(),
agentvect
[
d
].
end
(),
agent
)
!=
agentvect
[
d
].
end
());
bool
found
=
false
;
PFP
::
AGENTS
&
a
=
agentvect
[
d
];
PFP
::
AGENTS
::
iterator
end
=
a
.
end
();
bool
found
=
false
;
for
(
PFP
::
AGENTS
::
iterator
it
=
a
.
begin
();
it
!=
end
&&
!
found
;
++
it
)
{
if
(
*
it
==
agent
)
...
...
@@ -169,7 +167,7 @@ inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
inline
void
EnvMap
::
clearUpdateCandidates
()
{
refineCandidate
.
clear
();
//
coarsenCandidate.clear();
coarsenCandidate
.
clear
();
}
#endif
src/env_map.cpp
View file @
6a8e9fff
...
...
@@ -9,7 +9,11 @@
using
namespace
CGoGN
;
EnvMap
::
EnvMap
()
:
obstacleMark
(
map
,
EDGE_CELL
),
buildingMark
(
map
,
FACE_CELL
),
refineMark
(
map
,
FACE_CELL
)
EnvMap
::
EnvMap
()
:
obstacleMark
(
map
,
EDGE_CELL
),
buildingMark
(
map
,
FACE_CELL
),
refineMark
(
map
,
FACE_CELL
),
coarsenMark
(
map
,
FACE_CELL
)
{
position
=
map
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"position"
);
normal
=
map
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
);
...
...
@@ -29,10 +33,11 @@ unsigned int EnvMap::mapMemoryCost()
Dart
EnvMap
::
getBelongingCell
(
const
PFP
::
VEC3
&
pos
)
{
CellMarkerStore
m
(
map
,
FACE_ORBIT
);
CellMarkerStore
m
(
map
,
FACE_ORBIT
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
m
.
isMarked
(
d
))
{
if
(
!
m
.
isMarked
(
d
))
{
m
.
mark
(
d
);
if
(
!
buildingMark
.
isMarked
(
d
)
&&
Algo
::
Geometry
::
isPointInConvexFace2D
<
PFP
>
(
map
,
d
,
position
,
pos
,
true
))
return
d
;
...
...
@@ -46,7 +51,7 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
void
EnvMap
::
init
()
{
float
sideSize
=
70.0
f
;
unsigned
int
nbSquares
=
2
5
;
unsigned
int
nbSquares
=
5
;
CityGenerator
::
generateCity
<
PFP
>
(
map
,
position
,
obstacleMark
,
buildingMark
,
sideSize
,
nbSquares
);
// CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
CityGenerator
::
simplifyFreeSpace
<
PFP
>
(
map
,
position
,
obstacleMark
,
buildingMark
);
...
...
@@ -108,9 +113,8 @@ void EnvMap::registerObstaclesInFaces()
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
m
.
isMarked
(
d
)
&&
!
buildingMark
.
isMarked
(
d
))
{
if
(
m
.
isMarked
(
d
)
&&
!
buildingMark
.
isMarked
(
d
))
m
.
unmark
(
d
);
}
}
}
...
...
@@ -218,12 +222,21 @@ void EnvMap::agentChangeFace(Agent* agent, Dart oldFace)
{
Dart
newFace
=
agent
->
part_
.
d
;
if
(
!
map
.
isDartValid
(
oldFace
))
std
::
cout
<<
"agentChangeFace : oldFace INVALID"
<<
std
::
endl
;
if
(
!
map
.
isDartValid
(
newFace
))
std
::
cout
<<
"agentChangeFace : newFace INVALID"
<<
std
::
endl
;
popAgentInCells
(
agent
,
oldFace
);
pushAgentInCells
(
agent
,
newFace
);
// coarsenCandidate.insert(std::pair<unsigned int, Dart>(map.getEmbedding(FACE_ORBIT, oldFace), oldFace));
if
(
!
coarsenMark
.
isMarked
(
oldFace
)
&&
agentvect
[
oldFace
].
size
()
<
nbAgentsToSimplify
)
{
coarsenMark
.
mark
(
oldFace
);
coarsenCandidate
.
push_back
(
oldFace
);
}
if
(
!
refineMark
.
isMarked
(
newFace
)
&&
agentvect
[
newFace
].
size
()
>
nbAgentsToSubdivide
)
if
(
!
refineMark
.
isMarked
(
newFace
)
&&
!
coarsenMark
.
isMarked
(
newFace
)
&&
agentvect
[
newFace
].
size
()
>
nbAgentsToSubdivide
)
{
std
::
pair
<
bool
,
bool
>&
sf
=
subdivisableFace
[
newFace
];
if
(
sf
.
first
==
false
||
(
sf
.
first
==
true
&&
sf
.
second
))
...
...
@@ -241,6 +254,10 @@ void EnvMap::updateMap()
for
(
std
::
vector
<
Dart
>::
iterator
it
=
refineCandidate
.
begin
();
it
!=
refineCandidate
.
end
();
++
it
)
{
Dart
d
=
(
*
it
)
;
if
(
!
map
.
isDartValid
(
d
))
{
std
::
cout
<<
"refine INVALID"
<<
std
::
endl
;
}
refineMark
.
unmark
(
d
);
if
(
agentvect
[
d
].
size
()
>
nbAgentsToSubdivide
)
...
...
@@ -267,7 +284,7 @@ void EnvMap::updateMap()
PFP
::
VEC3
edge
=
Algo
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
fd
,
position
)
;
PFP
::
VEC3
proj
=
fCenter
-
(
p
+
(
edge
*
(
fCenter
-
p
)
/
edge
.
norm2
())
*
edge
)
;
if
(
proj
.
norm2
()
<
maxEdgeSize
)
// if(Algo::Geometry::vectorOutOfDart<PFP>(map, fd, position).norm2() < maxEdgeSize)
//
if(Algo::Geometry::vectorOutOfDart<PFP>(map, fd, position).norm2() < maxEdgeSize)
{
subdivisable
=
false
;
break
;
...
...
@@ -355,11 +372,16 @@ void EnvMap::updateMap()
}
}
}
/*
for(std::
map<unsigned int,
Dart>::iterator it = coarsenCandidate.begin(); it != coarsenCandidate.end(); ++it)
for
(
std
::
vector
<
Dart
>::
iterator
it
=
coarsenCandidate
.
begin
();
it
!=
coarsenCandidate
.
end
();
++
it
)
{
unsigned int face = (*it).first ;
Dart d = (*it).second ;
Dart
d
=
(
*
it
)
;
if
(
!
map
.
isDartValid
(
d
))
{
std
::
cout
<<
"coarsen INVALID"
<<
std
::
endl
;
continue
;
}
coarsenMark
.
unmark
(
d
)
;
unsigned
int
fLevel
=
map
.
faceLevel
(
d
)
;
Dart
old
=
map
.
faceOldestDart
(
d
)
;
...
...
@@ -395,14 +417,22 @@ void EnvMap::updateMap()
do
{
map
.
setCurrentLevel
(
fLevel
)
;
unsigned int fEmb = map.getEmbedding(fit, FACE_ORBIT) ;
if(fEmb != face)
coarsenCandidate.erase(fEmb) ;
coarsenMark
.
unmark
(
fit
)
;
for
(
std
::
vector
<
Dart
>::
iterator
r
=
it
+
1
;
r
!=
coarsenCandidate
.
end
();
++
r
)
{
if
(
*
r
==
fit
)
{
std
::
vector
<
Dart
>::
iterator
last
=
coarsenCandidate
.
end
()
;
--
last
;
std
::
swap
(
last
,
r
)
;
coarsenCandidate
.
pop_back
()
;
}
}
PFP
::
AGENTS
a
(
agentvect
[
fit
])
;
agents
.
insert
(
agents
.
end
(),
a
.
begin
(),
a
.
end
())
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
for(PFP::AGENTS::iterator it = a.begin(); it != a.end(); ++it)
popAgentInCells(*it, fit);
for
(
PFP
::
AGENTS
::
iterator
a
it
=
a
.
begin
();
a
it
!=
a
.
end
();
++
a
it
)
popAgentInCells
(
*
a
it
,
fit
);
map
.
setCurrentLevel
(
fLevel
-
1
)
;
Dart
nf
=
map
.
phi2
(
fit
)
;
if
(
!
map
.
faceIsSubdivided
(
nf
))
...
...
@@ -411,8 +441,8 @@ void EnvMap::updateMap()
PFP
::
AGENTS
&
an
=
agentvect
[
nf
]
;
for
(
PFP
::
AGENTS
::
iterator
ait
=
an
.
begin
();
ait
!=
an
.
end
();
++
ait
)
{
if((*ait)->part_.d == nf)
(*ait)->part_.d =
map.phi1(
nf
)
;
if
((
*
ait
)
->
part_
.
d
==
map
.
phi1
(
nf
)
)
(
*
ait
)
->
part_
.
d
=
nf
;
}
map
.
setCurrentLevel
(
fLevel
-
1
)
;
}
...
...
@@ -422,20 +452,30 @@ void EnvMap::updateMap()
{
map
.
setCurrentLevel
(
fLevel
)
;
Dart
centerFace
=
map
.
phi2
(
map
.
phi1
(
old
))
;
unsigned int fEmb = map.getEmbedding(centerFace, FACE_ORBIT) ;
if(fEmb != face)
coarsenCandidate.erase(fEmb) ;
coarsenMark
.
unmark
(
centerFace
)
;
for
(
std
::
vector
<
Dart
>::
iterator
r
=
it
+
1
;
r
!=
coarsenCandidate
.
end
();
++
r
)
{
if
(
*
r
==
centerFace
)
{
std
::
vector
<
Dart
>::
iterator
last
=
coarsenCandidate
.
end
()
;
--
last
;
std
::
swap
(
last
,
r
)
;
coarsenCandidate
.
pop_back
()
;
}
}
PFP
::
AGENTS
a
(
agentvect
[
centerFace
])
;
agents
.
insert
(
agents
.
end
(),
a
.
begin
(),
a
.
end
())
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
());
for(PFP::AGENTS::iterator it = a.begin(); it != a.end(); ++it)
popAgentInCells(*it, centerFace);
for
(
PFP
::
AGENTS
::
iterator
a
it
=
a
.
begin
();
a
it
!=
a
.
end
();
++
a
it
)
popAgentInCells
(
*
a
it
,
centerFace
);
map
.
setCurrentLevel
(
fLevel
-
1
)
;
}
Algo
::
IHM
::
coarsenFace
<
PFP
>
(
map
,
old
,
position
)
;
// gestion des obstacles !!
std
::
pair
<
bool
,
bool
>&
sf
=
subdivisableFace
[
old
]
;
sf
.
first
=
true
;
sf
.
second
=
true
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
());
...
...
@@ -457,12 +497,13 @@ void EnvMap::updateMap()
}
dd
=
map
.
phi1
(
dd
);
}
while
(
dd
!=
old
);
}
}
map
.
setCurrentLevel
(
cur
)
;
}
}
*/
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment