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
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
a45828d3
Commit
a45828d3
authored
Sep 07, 2012
by
Basile Sauvage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diag centroidaux
parent
cb8f4fc5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
7 deletions
+74
-7
include/Algo/Geometry/voronoiDiagrams.h
include/Algo/Geometry/voronoiDiagrams.h
+10
-2
include/Algo/Geometry/voronoiDiagrams.hpp
include/Algo/Geometry/voronoiDiagrams.hpp
+64
-5
No files found.
include/Algo/Geometry/voronoiDiagrams.h
View file @
a45828d3
...
@@ -68,17 +68,25 @@ private :
...
@@ -68,17 +68,25 @@ private :
VertexAttribute
<
REAL
>&
distances
;
// distances from the seed
VertexAttribute
<
REAL
>&
distances
;
// distances from the seed
VertexAttribute
<
Dart
>&
pathOrigins
;
// previous vertex on the shortest path from origin
VertexAttribute
<
Dart
>&
pathOrigins
;
// previous vertex on the shortest path from origin
VertexAttribute
<
REAL
>&
areaElts
;
// area element attached to each vertex
public
:
public
:
CentroidalVoronoiDiagram
(
typename
PFP
::
MAP
&
m
,
const
EdgeAttribute
<
REAL
>&
c
,
VertexAttribute
<
unsigned
int
>&
r
,
VertexAttribute
<
REAL
>&
d
,
VertexAttribute
<
Dart
>&
o
);
CentroidalVoronoiDiagram
(
typename
PFP
::
MAP
&
m
,
const
EdgeAttribute
<
REAL
>&
c
,
VertexAttribute
<
unsigned
int
>&
r
,
VertexAttribute
<
REAL
>&
d
,
VertexAttribute
<
Dart
>&
o
,
VertexAttribute
<
REAL
>&
a
);
~
CentroidalVoronoiDiagram
();
~
CentroidalVoronoiDiagram
();
void
cumulateDistancesOnPaths
();
void
cumulateDistancesOnPaths
();
unsigned
int
moveSeeds
();
// returns the number of seeds that did move
protected
:
protected
:
void
clear
();
void
clear
();
void
collectVertexFromFront
(
Dart
e
);
void
collectVertexFromFront
(
Dart
e
);
void
cumulateDistancesFromSeed
(
Dart
e
);
REAL
cumulateDistancesFromRoot
(
Dart
e
);
unsigned
int
moveSeed
(
unsigned
int
i
);
};
};
...
...
include/Algo/Geometry/voronoiDiagrams.hpp
View file @
a45828d3
...
@@ -143,8 +143,8 @@ void VoronoiDiagram<PFP>::computeDiagram ()
...
@@ -143,8 +143,8 @@ void VoronoiDiagram<PFP>::computeDiagram ()
***********************************************************/
***********************************************************/
template
<
typename
PFP
>
template
<
typename
PFP
>
CentroidalVoronoiDiagram
<
PFP
>::
CentroidalVoronoiDiagram
(
typename
PFP
::
MAP
&
m
,
const
EdgeAttribute
<
REAL
>&
c
,
VertexAttribute
<
unsigned
int
>&
r
,
VertexAttribute
<
REAL
>&
d
,
VertexAttribute
<
Dart
>&
o
)
:
CentroidalVoronoiDiagram
<
PFP
>::
CentroidalVoronoiDiagram
(
typename
PFP
::
MAP
&
m
,
const
EdgeAttribute
<
REAL
>&
c
,
VertexAttribute
<
unsigned
int
>&
r
,
VertexAttribute
<
REAL
>&
d
,
VertexAttribute
<
Dart
>&
o
,
VertexAttribute
<
REAL
>&
a
)
:
VoronoiDiagram
<
PFP
>
(
m
,
c
,
r
),
distances
(
d
),
pathOrigins
(
o
)
VoronoiDiagram
<
PFP
>
(
m
,
c
,
r
),
distances
(
d
),
pathOrigins
(
o
)
,
areaElts
(
a
)
{
{
}
}
...
@@ -172,21 +172,80 @@ template <typename PFP>
...
@@ -172,21 +172,80 @@ template <typename PFP>
void
CentroidalVoronoiDiagram
<
PFP
>::
cumulateDistancesOnPaths
(){
void
CentroidalVoronoiDiagram
<
PFP
>::
cumulateDistancesOnPaths
(){
for
(
unsigned
int
i
=
0
;
i
<
this
->
seeds
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
this
->
seeds
.
size
();
i
++
)
{
{
cumulateDistancesFrom
Seed
(
this
->
seeds
[
i
]);
cumulateDistancesFrom
Root
(
this
->
seeds
[
i
]);
}
}
}
}
template
<
typename
PFP
>
template
<
typename
PFP
>
void
CentroidalVoronoiDiagram
<
PFP
>::
cumulateDistancesFromSeed
(
Dart
e
){
unsigned
int
CentroidalVoronoiDiagram
<
PFP
>::
moveSeeds
(){
unsigned
int
m
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
this
->
seeds
.
size
();
i
++
)
{
m
+=
moveSeed
(
i
);
}
return
m
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
CentroidalVoronoiDiagram
<
PFP
>::
cumulateDistancesFromRoot
(
Dart
e
){
REAL
area
=
areaElts
[
e
];
distances
[
e
]
*=
areaElts
[
e
];
Traversor2VVaE
<
typename
PFP
::
MAP
>
tv
(
this
->
map
,
e
);
Traversor2VVaE
<
typename
PFP
::
MAP
>
tv
(
this
->
map
,
e
);
for
(
Dart
f
=
tv
.
begin
();
f
!=
tv
.
end
();
f
=
tv
.
next
())
for
(
Dart
f
=
tv
.
begin
();
f
!=
tv
.
end
();
f
=
tv
.
next
())
{
{
if
(
pathOrigins
[
f
]
==
this
->
map
.
phi2
(
f
))
if
(
pathOrigins
[
f
]
==
this
->
map
.
phi2
(
f
))
{
{
cumulateDistancesFromSeed
(
f
);
area
+=
cumulateDistancesFromRoot
(
f
);
distances
[
e
]
+=
distances
[
f
];
distances
[
e
]
+=
distances
[
f
];
}
}
}
}
return
area
;
}
template
<
typename
PFP
>
unsigned
int
CentroidalVoronoiDiagram
<
PFP
>::
moveSeed
(
unsigned
int
i
){
Dart
e
=
this
->
seeds
[
i
];
unsigned
int
res
=
0
;
std
::
vector
<
Dart
>
v
;
v
.
reserve
(
8
);
std
::
vector
<
float
>
a
;
a
.
reserve
(
8
);
float
regionArea
=
areaElts
[
e
];
distances
[
e
]
=
0.0
;
Traversor2VVaE
<
typename
PFP
::
MAP
>
tv
(
this
->
map
,
e
);
for
(
Dart
f
=
tv
.
begin
();
f
!=
tv
.
end
();
f
=
tv
.
next
())
{
if
(
pathOrigins
[
f
]
==
this
->
map
.
phi2
(
f
))
{
float
area
=
cumulateDistancesFromRoot
(
f
);
distances
[
e
]
+=
distances
[
f
];
v
.
push_back
(
f
);
a
.
push_back
(
area
);
regionArea
+=
area
;
}
}
float
minDE
=
0.0
;
for
(
unsigned
int
j
=
0
;
j
<
v
.
size
();
++
j
)
{
float
c
=
this
->
edgeCost
[
v
[
j
]];
float
de
=
regionArea
*
c
*
c
;
de
+=
2
*
c
*
(
distances
[
e
]
-
2
*
distances
[
v
[
j
]]
);
if
(
de
<
minDE
)
{
minDE
=
de
;
res
=
1
;
this
->
seeds
[
i
]
=
v
[
j
];
}
}
return
res
;
}
}
}
// end namespace Geometry
}
// end namespace Geometry
...
...
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