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
Hurstel
CGoGN
Commits
cbbaa4c7
Commit
cbbaa4c7
authored
Sep 05, 2012
by
Basile Sauvage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
amélioration des diag de Voronoi
parent
dd9c8ce0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
30 deletions
+47
-30
include/Algo/Geometry/voronoiDiagrams.h
include/Algo/Geometry/voronoiDiagrams.h
+5
-2
include/Algo/Geometry/voronoiDiagrams.hpp
include/Algo/Geometry/voronoiDiagrams.hpp
+42
-28
No files found.
include/Algo/Geometry/voronoiDiagrams.h
View file @
cbbaa4c7
...
...
@@ -25,14 +25,14 @@ private :
{
typename
std
::
multimap
<
float
,
Dart
>::
iterator
it
;
bool
valid
;
unsigned
int
region
;
// unsigned int region;
Dart
pathOrigin
;
static
std
::
string
CGoGNnameOfType
()
{
return
"VoronoiVertexInfo"
;
}
}
VoronoiVertexInfo
;
typedef
NoMathIOAttribute
<
VoronoiVertexInfo
>
VertexInfo
;
typename
PFP
::
MAP
&
map
;
const
EdgeAttribute
<
REAL
>&
edgeCost
;
// weights on the graph edges
// const VertexAttribute<VEC3>& position; // positions
VertexAttribute
<
unsigned
int
>&
regions
;
// region labels
std
::
vector
<
Dart
>
border
;
std
::
vector
<
Dart
>
seeds
;
...
...
@@ -56,6 +56,9 @@ public :
private
:
void
clear
();
void
initFrontWithSeeds
();
void
collectVertexFromFront
(
Dart
e
);
void
addVertexToFront
(
Dart
f
,
float
d
);
void
updateVertexInFront
(
Dart
f
,
float
d
);
};
}
// end namespace Geometry
...
...
include/Algo/Geometry/voronoiDiagrams.hpp
View file @
cbbaa4c7
...
...
@@ -66,7 +66,9 @@ void VoronoiDiagram<PFP>::initFrontWithSeeds ()
vmReached
.
mark
(
d
);
vertexInfo
[
d
].
it
=
front
.
insert
(
std
::
pair
<
float
,
Dart
>
(
0.0
,
d
));
vertexInfo
[
d
].
valid
=
true
;
vertexInfo
[
d
].
region
=
i
;
// vertexInfo[d].region = i;
regions
[
d
]
=
i
;
vertexInfo
[
d
].
pathOrigin
=
d
;
}
}
...
...
@@ -75,6 +77,36 @@ void VoronoiDiagram<PFP>::setCost (const EdgeAttribute<typename PFP::REAL>& c){
edgeCost
=
c
;
}
template
<
typename
PFP
>
void
VoronoiDiagram
<
PFP
>::
collectVertexFromFront
(
Dart
e
){
front
.
erase
(
vertexInfo
[
e
].
it
);
vertexInfo
[
e
].
valid
=
false
;
// regions[e] = vertexInfo[e].region;
regions
[
e
]
=
regions
[
vertexInfo
[
e
].
pathOrigin
];
}
template
<
typename
PFP
>
void
VoronoiDiagram
<
PFP
>::
addVertexToFront
(
Dart
f
,
float
d
){
VertexInfo
&
vi
(
vertexInfo
[
f
]);
vi
.
it
=
front
.
insert
(
std
::
pair
<
float
,
Dart
>
(
d
+
edgeCost
[
f
],
f
));
vi
.
valid
=
true
;
// vi.region = regions[map.phi2(f)];
vi
.
pathOrigin
=
map
.
phi2
(
f
);
vmReached
.
mark
(
f
);
}
template
<
typename
PFP
>
void
VoronoiDiagram
<
PFP
>::
updateVertexInFront
(
Dart
f
,
float
d
){
VertexInfo
&
vi
(
vertexInfo
[
f
]);
float
dist
=
d
+
edgeCost
[
f
];
if
(
dist
<
vi
.
it
->
first
)
{
front
.
erase
(
vi
.
it
);
vi
.
it
=
front
.
insert
(
std
::
pair
<
float
,
Dart
>
(
dist
,
f
));
// vi.region = regions[map.phi2(f)];
vi
.
pathOrigin
=
map
.
phi2
(
f
);
}
}
template
<
typename
PFP
>
void
VoronoiDiagram
<
PFP
>::
computeDiagram
()
...
...
@@ -85,40 +117,22 @@ void VoronoiDiagram<PFP>::computeDiagram ()
{
Dart
e
=
front
.
begin
()
->
second
;
float
d
=
front
.
begin
()
->
first
;
front
.
erase
(
vertexInfo
[
e
].
it
);
vertexInfo
[
e
].
valid
=
false
;
regions
[
e
]
=
vertexInfo
[
e
].
region
;
collectVertexFromFront
(
e
);
Traversor2VVaE
<
typename
PFP
::
MAP
>
tv
(
map
,
e
);
for
(
Dart
f
=
tv
.
begin
();
f
!=
tv
.
end
();
f
=
tv
.
next
())
{
VertexInfo
&
vi
(
vertexInfo
[
f
]);
if
(
vmReached
.
isMarked
(
f
))
{
if
(
vi
.
valid
)
// probably useless (because of distance test) but faster
{
// float dist = d + Algo::Geometry::edgeLength<PFP>(map,f,position);
float
dist
=
d
+
edgeCost
[
f
];
if
(
dist
<
vi
.
it
->
first
)
{
front
.
erase
(
vi
.
it
);
vi
.
it
=
front
.
insert
(
std
::
pair
<
float
,
Dart
>
(
dist
,
f
));
vi
.
region
=
regions
[
e
];
}
}
else
{
if
(
regions
[
f
]
!=
regions
[
e
]
)
border
.
push_back
(
f
);
}
{
// f has been reached
if
(
vertexInfo
[
f
].
valid
)
// f is in the front : update
updateVertexInFront
(
f
,
d
);
else
// f is not in the front any more (already collected) : detect a border edge
if
(
regions
[
f
]
!=
regions
[
e
]
)
border
.
push_back
(
f
);
}
else
{
// vi.it = front.insert(std::pair<float,Dart>(d + Algo::Geometry::edgeLength<PFP>(map,f,position), f));
vi
.
it
=
front
.
insert
(
std
::
pair
<
float
,
Dart
>
(
d
+
edgeCost
[
f
],
f
));
vi
.
valid
=
true
;
vi
.
region
=
regions
[
e
];
vmReached
.
mark
(
f
);
{
// f has not been reached : add it to the front
addVertexToFront
(
f
,
d
);
}
}
}
...
...
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