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
5b4f36f2
Commit
5b4f36f2
authored
Sep 10, 2012
by
Basile Sauvage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
voronoi centroidaux
parent
c7cbc8fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
21 deletions
+32
-21
include/Algo/Geometry/voronoiDiagrams.h
include/Algo/Geometry/voronoiDiagrams.h
+5
-2
include/Algo/Geometry/voronoiDiagrams.hpp
include/Algo/Geometry/voronoiDiagrams.hpp
+27
-19
No files found.
include/Algo/Geometry/voronoiDiagrams.h
View file @
5b4f36f2
...
...
@@ -67,6 +67,8 @@ private :
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
double
globalEnergy
;
VertexAttribute
<
REAL
>&
distances
;
// distances from the seed
VertexAttribute
<
Dart
>&
pathOrigins
;
// previous vertex on the shortest path from origin
VertexAttribute
<
REAL
>&
areaElts
;
// area element attached to each vertex
...
...
@@ -80,13 +82,14 @@ public :
VertexAttribute
<
REAL
>&
a
);
~
CentroidalVoronoiDiagram
();
void
cumulate
Distances
OnPaths
();
void
cumulate
Energy
OnPaths
();
unsigned
int
moveSeeds
();
// returns the number of seeds that did move
REAL
getGlobalEnergy
()
{
return
globalEnergy
;}
protected
:
void
clear
();
void
collectVertexFromFront
(
Dart
e
);
REAL
cumulate
Distances
FromRoot
(
Dart
e
);
REAL
cumulate
Energy
FromRoot
(
Dart
e
);
unsigned
int
moveSeed
(
unsigned
int
numSeed
);
};
...
...
include/Algo/Geometry/voronoiDiagrams.hpp
View file @
5b4f36f2
...
...
@@ -172,39 +172,43 @@ void CentroidalVoronoiDiagram<PFP>::collectVertexFromFront(Dart e){
}
template
<
typename
PFP
>
void
CentroidalVoronoiDiagram
<
PFP
>::
cumulateDistancesOnPaths
(){
void
CentroidalVoronoiDiagram
<
PFP
>::
cumulateEnergyOnPaths
(){
globalEnergy
=
0.0
;
for
(
unsigned
int
i
=
0
;
i
<
this
->
seeds
.
size
();
i
++
)
{
cumulateDistancesFromRoot
(
this
->
seeds
[
i
]);
cumulateEnergyFromRoot
(
this
->
seeds
[
i
]);
globalEnergy
+=
distances
[
this
->
seeds
[
i
]];
}
}
template
<
typename
PFP
>
unsigned
int
CentroidalVoronoiDiagram
<
PFP
>::
moveSeeds
(){
unsigned
int
m
=
0
;
globalEnergy
=
0.0
;
for
(
unsigned
int
i
=
0
;
i
<
this
->
seeds
.
size
();
i
++
)
{
m
+=
moveSeed
(
i
);
globalEnergy
+=
distances
[
this
->
seeds
[
i
]];
}
return
m
;
}
template
<
typename
PFP
>
typename
PFP
::
REAL
CentroidalVoronoiDiagram
<
PFP
>::
cumulate
Distances
FromRoot
(
Dart
e
){
REAL
area
=
areaElt
s
[
e
];
distances
[
e
]
*=
areaElt
s
[
e
];
typename
PFP
::
REAL
CentroidalVoronoiDiagram
<
PFP
>::
cumulate
Energy
FromRoot
(
Dart
e
){
REAL
distArea
=
areaElts
[
e
]
*
distance
s
[
e
];
distances
[
e
]
=
areaElts
[
e
]
*
distances
[
e
]
*
distance
s
[
e
];
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
))
{
area
+=
cumulateDistances
FromRoot
(
f
);
distArea
+=
cumulateEnergy
FromRoot
(
f
);
distances
[
e
]
+=
distances
[
f
];
}
}
return
a
rea
;
return
distA
rea
;
}
template
<
typename
PFP
>
...
...
@@ -215,10 +219,9 @@ unsigned int CentroidalVoronoiDiagram<PFP>::moveSeed(unsigned int numSeed){
std
::
vector
<
Dart
>
v
;
v
.
reserve
(
8
);
std
::
vector
<
float
>
a
;
a
.
reserve
(
8
);
std
::
vector
<
float
>
d
a
;
d
a
.
reserve
(
8
);
float
regionArea
=
areaElts
[
e
];
distances
[
e
]
=
0.0
;
Traversor2VVaE
<
typename
PFP
::
MAP
>
tv
(
this
->
map
,
e
);
...
...
@@ -226,46 +229,51 @@ unsigned int CentroidalVoronoiDiagram<PFP>::moveSeed(unsigned int numSeed){
{
if
(
pathOrigins
[
f
]
==
this
->
map
.
phi2
(
f
))
{
float
area
=
cumulateDistancesFromRoot
(
f
);
float
distArea
=
cumulateEnergyFromRoot
(
f
);
da
.
push_back
(
distArea
);
distances
[
e
]
+=
distances
[
f
];
v
.
push_back
(
f
);
a
.
push_back
(
area
);
regionArea
+=
area
;
}
}
/* second attempt */
// TODO : check if the computation of grad and proj is still valid for other edgeCost than geodesic distances
VEC3
grad
(
0.0
);
const
VertexAttribute
<
VEC3
>&
pos
=
this
->
map
.
template
getAttribute
<
VEC3
,
VERTEX
>(
"position"
);
// compute the gradient
for
(
unsigned
int
j
=
0
;
j
<
v
.
size
();
++
j
)
{
Dart
f
=
v
[
j
];
// VEC3 edgeV = Algo::Geometry::vectorOutOfDart<PFP>(this->map,this->map.phi2(f),pos);
VEC3
edgeV
=
pos
[
f
]
-
pos
[
this
->
map
.
phi2
(
f
)];
edgeV
.
normalize
();
grad
+=
d
istances
[
f
]
*
edgeV
;
grad
+=
d
a
[
j
]
*
edgeV
;
}
grad
/=
2.0
;
float
maxProj
=
0.0
;
// float memoForTest = 0.0;
for
(
unsigned
int
j
=
0
;
j
<
v
.
size
();
++
j
)
{
Dart
f
=
v
[
j
];
// VEC3 edgeV = Algo::Geometry::vectorOutOfDart<PFP>(this->map,this->map.phi2(f),pos);
VEC3
edgeV
=
pos
[
f
]
-
pos
[
this
->
map
.
phi2
(
f
)];
// edgeV.normalize();
float
proj
=
edgeV
*
grad
;
proj
-=
areaElts
[
e
]
*
this
->
edgeCost
[
f
]
*
this
->
edgeCost
[
f
];
//
proj -= areaElts[e] * this->edgeCost[f] * this->edgeCost[f];
if
(
proj
>
maxProj
)
{
if
(
numSeed
==
1
&&
j
==
0
)
CGoGNout
<<
(
edgeV
*
grad
)
/
(
areaElts
[
e
]
*
this
->
edgeCost
[
f
]
*
this
->
edgeCost
[
f
])
*
this
->
seeds
.
size
()
<<
CGoGNendl
;
// if (numSeed==1) memoForTest = (edgeV * grad) / (areaElts[e] * this->edgeCost[f] * this->edgeCost[f]);
//
CGoGNout << (edgeV * grad) / (areaElts[e] * this->edgeCost[f] * this->edgeCost[f]) * this->seeds.size() << CGoGNendl;
// CGoGNout << edgeV * grad << "\t - \t" << areaElts[e] * this->edgeCost[f] * this->edgeCost[f] << CGoGNendl;
maxProj
=
proj
;
seedMoved
=
1
;
this
->
seeds
[
numSeed
]
=
v
[
j
];
}
}
// if (numSeed==1 && seedMoved==1)
// CGoGNout << memoForTest * this->seeds.size() << CGoGNendl;
/* end second attempt */
/* first attempt by approximating the energy change
...
...
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