Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
b515ee2c
Commit
b515ee2c
authored
Mar 04, 2011
by
Pierre Kraemer
Browse files
pliant remeshing premiere version
parent
38f0a625
Changes
6
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/miniTest.cpp
View file @
b515ee2c
...
...
@@ -583,15 +583,29 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break
;
}
case
'
r
'
:
case
'
d
'
:
{
AttributeHandler
<
PFP
::
VEC3
>
positionF
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
FACE_ORBIT
,
"position"
)
;
if
(
!
positionF
.
isValid
())
positionF
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
FACE_ORBIT
,
"position"
)
;
Algo
::
Geometry
::
computeCentroidFaces
<
PFP
>
(
myMap
,
position
,
positionF
)
;
GLint
t1
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
Algo
::
Remeshing
::
pliantRemeshing
<
PFP
>
(
myMap
,
position
)
;
Algo
::
Modelisation
::
computeDual
<
PFP
>
(
myMap
)
;
GLint
t2
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
GLfloat
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
"pliant remeshing: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
std
::
cout
<<
"dual computation: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
position
=
positionF
;
normal
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
)
;
if
(
!
normal
.
isValid
())
normal
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
)
;
laplacian
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"laplacian"
)
;
if
(
!
laplacian
.
isValid
())
laplacian
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"laplacian"
)
;
t1
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
...
...
@@ -607,29 +621,16 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break
;
}
case
'
d
'
:
case
'
r
'
:
{
AttributeHandler
<
PFP
::
VEC3
>
positionF
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
FACE_ORBIT
,
"position"
)
;
if
(
!
positionF
.
isValid
())
positionF
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
FACE_ORBIT
,
"position"
)
;
Algo
::
Geometry
::
computeCentroidFaces
<
PFP
>
(
myMap
,
position
,
positionF
)
;
GLint
t1
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
Algo
::
Modelisation
::
computeDual
<
PFP
>
(
myMap
)
;
Algo
::
Remeshing
::
pliantRemeshing
<
PFP
>
(
myMap
,
position
,
normal
)
;
GLint
t2
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
GLfloat
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
"dual computation: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
position
=
positionF
;
normal
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
)
;
if
(
!
normal
.
isValid
())
normal
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
)
;
laplacian
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"laplacian"
)
;
if
(
!
laplacian
.
isValid
())
laplacian
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"laplacian"
)
;
std
::
cout
<<
"pliant remeshing: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
t1
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
...
...
include/Algo/Geometry/centroid.hpp
View file @
b515ee2c
...
...
@@ -121,7 +121,7 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at
{
center
+=
attributs
[
map
.
phi2
(
it
)];
++
count
;
it
=
map
.
phi1
(
map
.
phi2
(
it
)
)
;
it
=
map
.
alpha1
(
it
)
;
}
while
(
it
!=
d
)
;
center
/=
count
;
return
center
;
...
...
include/Algo/Remeshing/pliant.h
View file @
b515ee2c
...
...
@@ -32,7 +32,7 @@ namespace Remeshing
{
template
<
typename
PFP
>
void
pliantRemeshing
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
)
;
void
pliantRemeshing
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
)
;
}
// namespace Remeshing
...
...
@@ -41,3 +41,4 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position) ;
}
// namespace CGoGN
#include
"Algo/Remeshing/pliant.hpp"
include/Algo/Remeshing/pliant.hpp
View file @
b515ee2c
...
...
@@ -34,34 +34,37 @@ namespace Remeshing
{
template
<
typename
PFP
>
void
pliantRemeshing
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
)
void
pliantRemeshing
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
DartMarker
m
(
map
)
;
// compute the mean edge length
DartMarker
m1
(
map
)
;
REAL
meanEdgeLength
=
0
;
unsigned
int
nbEdges
=
0
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
m
.
isMarked
(
d
))
if
(
!
m
1
.
isMarked
(
d
))
{
m
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
m
1
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
meanEdgeLength
+=
Algo
::
Geometry
::
edgeLength
<
PFP
>
(
map
,
d
,
position
)
;
++
nbEdges
;
}
}
meanEdgeLength
/=
REAL
(
nbEdges
)
;
REAL
edgeLengthInf
=
REAL
(
4
)
/
REAL
(
5
)
*
meanEdgeLength
;
// compute the min and max edge lengths
REAL
edgeLengthInf
=
REAL
(
3
)
/
REAL
(
4
)
*
meanEdgeLength
;
REAL
edgeLengthSup
=
REAL
(
4
)
/
REAL
(
3
)
*
meanEdgeLength
;
// split long edges
DartMarker
m2
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
m
.
isMarked
(
d
))
if
(
!
m2
.
isMarked
(
d
))
{
m
.
un
markOrbit
(
EDGE_ORBIT
,
d
)
;
m
2
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
REAL
length
=
Algo
::
Geometry
::
edgeLength
<
PFP
>
(
map
,
d
,
position
)
;
if
(
length
>
edgeLengthSup
)
{
...
...
@@ -75,11 +78,13 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position)
}
}
// collapse short edges
DartMarker
m3
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
m
.
isMarked
(
d
))
if
(
!
m
3
.
isMarked
(
d
))
{
m
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
m
3
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
REAL
length
=
Algo
::
Geometry
::
edgeLength
<
PFP
>
(
map
,
d
,
position
)
;
if
(
length
<
edgeLengthInf
)
{
...
...
@@ -102,6 +107,54 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position)
}
}
}
// equalize valences with edge flips
DartMarker
m4
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
m4
.
isMarked
(
d
))
{
m4
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
Dart
e
=
map
.
phi2
(
d
)
;
unsigned
int
w
=
map
.
vertexDegree
(
d
)
;
unsigned
int
x
=
map
.
vertexDegree
(
e
)
;
unsigned
int
y
=
map
.
vertexDegree
(
map
.
phi1
(
map
.
phi1
(
d
)))
;
unsigned
int
z
=
map
.
vertexDegree
(
map
.
phi1
(
map
.
phi1
(
e
)))
;
int
flip
=
0
;
flip
+=
w
>
6
?
1
:
(
w
<
6
?
-
1
:
0
)
;
flip
+=
x
>
6
?
1
:
(
x
<
6
?
-
1
:
0
)
;
flip
+=
y
<
6
?
1
:
(
y
>
6
?
-
1
:
0
)
;
flip
+=
z
<
6
?
1
:
(
z
>
6
?
-
1
:
0
)
;
if
(
flip
>
2
)
{
map
.
flipEdge
(
d
)
;
m4
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi1
(
d
))
;
m4
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi_1
(
d
))
;
m4
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi1
(
e
))
;
m4
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi_1
(
e
))
;
}
}
}
// update vertices normals
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
map
,
position
,
normal
)
;
// tangential relaxation
AttributeHandler
<
VEC3
>
newPosition
=
map
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"newPosition"
)
;
Algo
::
Geometry
::
computeNeighborhoodCentroidVertices
<
PFP
>
(
map
,
position
,
newPosition
)
;
CellMarker
vm
(
map
,
VERTEX_CELL
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
vm
.
isMarked
(
d
))
{
vm
.
mark
(
d
)
;
VEC3
l
=
position
[
d
]
-
newPosition
[
d
]
;
newPosition
[
d
]
=
newPosition
[
d
]
+
((
normal
[
d
]
*
l
)
*
normal
[
d
])
;
}
}
map
.
template
swapAttributes
<
VEC3
>(
position
,
newPosition
)
;
map
.
template
removeAttribute
<
VEC3
>(
newPosition
)
;
}
}
// namespace Remeshing
...
...
include/Topology/generic/embeddedMap2.hpp
View file @
b515ee2c
...
...
@@ -205,6 +205,26 @@ Dart EmbeddedMap2<MAP2>::collapseEdge(Dart d, bool delDegenerateFaces)
template
<
typename
MAP2
>
bool
EmbeddedMap2
<
MAP2
>::
flipEdge
(
Dart
d
)
{
// unsigned int dVEmb = EMBNULL ;
// unsigned int eVEmb = EMBNULL ;
//
// Dart e = MAP2::phi2(d) ;
//
// if(MAP2::isOrbitEmbedded(VERTEX_ORBIT))
// {
// dVEmb = MAP2::getDartEmbedding(VERTEX_ORBIT, d) ;
// if(dVEmb != EMBNULL)
// MAP2::setDartEmbedding(VERTEX_ORBIT, MAP2::alpha1(d), dVEmb) ;
// MAP2::setDartEmbedding(VERTEX_ORBIT, d, EMBNULL) ;
//
// eVEmb = MAP2::getDartEmbedding(VERTEX_ORBIT, e) ;
// if(eVEmb != EMBNULL)
// MAP2::setDartEmbedding(VERTEX_ORBIT, MAP2::alpha1(e), eVEmb) ;
// MAP2::setDartEmbedding(VERTEX_ORBIT, e, EMBNULL) ;
// }
//
// return MAP2::flipEdge(d) ;
if
(
MAP2
::
flipEdge
(
d
))
{
Dart
e
=
MAP2
::
phi2
(
d
)
;
...
...
@@ -221,7 +241,6 @@ bool EmbeddedMap2<MAP2>::flipEdge(Dart d)
MAP2
::
setDartEmbedding
(
VERTEX_ORBIT
,
MAP2
::
phi_1
(
e
),
eVEmb
)
;
MAP2
::
setDartEmbedding
(
VERTEX_ORBIT
,
e
,
EMBNULL
)
;
}
if
(
MAP2
::
isOrbitEmbedded
(
FACE_ORBIT
))
{
unsigned
int
dFEmb
=
MAP2
::
getDartEmbedding
(
FACE_ORBIT
,
MAP2
::
phi_1
(
e
))
;
...
...
@@ -467,6 +486,7 @@ bool EmbeddedMap2<MAP2>::check()
bool
topo
=
MAP2
::
check
()
;
if
(
!
topo
)
return
false
;
std
::
cout
<<
"Check: embedding begin"
<<
std
::
endl
;
for
(
Dart
d
=
MAP2
::
begin
();
d
!=
MAP2
::
end
();
MAP2
::
next
(
d
))
{
...
...
include/Topology/map/map2.h
View file @
b515ee2c
...
...
@@ -143,7 +143,7 @@ public:
virtual
Dart
collapseEdge
(
Dart
d
,
bool
delDegenerateFaces
=
true
);
/**
* Flip the edge of d
.
(rotation in phi1 order)
* Flip the edge of d (rotation in phi1 order)
* WARNING : Works only for non-border edges.
* @param d a dart of the edge to flip
* @return true if the flip has been executed, false otherwise
...
...
@@ -151,7 +151,7 @@ public:
virtual
bool
flipEdge
(
Dart
d
);
/**
* Flip the edge of d
.
(rotation in phi_1 order)
* Flip the edge of d (rotation in phi_1 order)
* WARNING : Works only for non-border edges.
* @param d a dart of the edge to flip
* @return true if the flip has been executed, false otherwise
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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