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
Etienne Schmitt
CGoGN
Commits
7ceecc0e
Commit
7ceecc0e
authored
Mar 07, 2011
by
Pierre Kraemer
Browse files
remeshing -> feature preservation v1
parent
48c2a09d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/miniTest.cpp
View file @
7ceecc0e
...
...
@@ -44,8 +44,7 @@
#include
"Algo/Modelisation/subdivision.h"
#include
"Algo/Decimation/decimation.h"
#include
"Algo/Remeshing/pliant.h"
#include
"Algo/Selection/raySelector.h"
#include
"Algo/Geometry/feature.h"
using
namespace
CGoGN
;
...
...
@@ -98,8 +97,6 @@ public:
Algo
::
Render
::
VBO
::
topo_VBORenderMapD
*
topo_render
;
GLuint
dl_norm
,
dl_lapl
;
Dart
selectedDart
;
MyGlutWin
(
int
*
argc
,
char
**
argv
,
int
winX
,
int
winY
)
;
void
init
()
;
...
...
@@ -310,8 +307,6 @@ MyGlutWin::MyGlutWin(int* argc, char **argv, int winX, int winY) :
shaders
[
0
].
loadShaders
(
"phong_vs.txt"
,
"phong_ps.txt"
)
;
shaders
[
1
].
loadShaders
(
"flat_vs.txt"
,
"flat_ps.txt"
,
"flat_gs.txt"
)
;
}
selectedDart
=
Dart
::
nil
()
;
}
void
MyGlutWin
::
init
()
...
...
@@ -359,22 +354,6 @@ void MyGlutWin::myRedraw()
glScalef
(
sc
,
sc
,
sc
)
;
glTranslatef
(
-
gPosObj
[
0
],
-
gPosObj
[
1
],
-
gPosObj
[
2
])
;
if
(
!
selectedDart
.
isNil
())
{
glDisable
(
GL_LIGHTING
)
;
glColor3f
(
1.0
f
,
0.0
f
,
0.0
f
)
;
glLineWidth
(
3.0
f
)
;
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
myMap
,
selectedDart
,
position
)
;
PFP
::
VEC3
p1
=
position
[
selectedDart
]
;
PFP
::
VEC3
p2
=
position
[
myMap
.
phi1
(
selectedDart
)]
;
p1
+=
PFP
::
REAL
(
0.1
)
*
(
c
-
p1
)
;
p2
+=
PFP
::
REAL
(
0.1
)
*
(
c
-
p2
)
;
glBegin
(
GL_LINES
)
;
glVertex3fv
(
p1
.
data
())
;
glVertex3fv
(
p2
.
data
())
;
glEnd
()
;
}
if
(
renderTopo
)
{
glDisable
(
GL_LIGHTING
);
...
...
@@ -668,31 +647,6 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break
;
}
case
'0'
:
{
GLint
t1
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
Algo
::
Modelisation
::
reverseOrientation
<
PFP
>
(
myMap
)
;
GLint
t2
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
GLfloat
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
"pliant remeshing: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
t1
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
updateVBOprimitives
(
Algo
::
Render
::
VBO
::
TRIANGLES
|
Algo
::
Render
::
VBO
::
LINES
|
Algo
::
Render
::
VBO
::
POINTS
)
;
updateVBOdata
(
Algo
::
Render
::
VBO
::
POSITIONS
|
Algo
::
Render
::
VBO
::
NORMALS
)
;
topo_render
->
updateData
<
PFP
>
(
myMap
,
position
,
0.9
f
,
0.9
f
)
;
t2
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
"display update: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
glutPostRedisplay
()
;
break
;
}
case
'9'
:
{
CellMarker
markVisit
(
myMap
,
VERTEX_CELL
)
;
...
...
@@ -752,37 +706,6 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break
;
}
case
'i'
:
{
glPushMatrix
();
float
sc
=
50.0
f
/
gWidthObj
;
glScalef
(
sc
,
sc
,
sc
)
;
glTranslatef
(
-
gPosObj
[
0
],
-
gPosObj
[
1
],
-
gPosObj
[
2
])
;
PFP
::
VEC3
rayA
,
rayB
;
getOrthoScreenRay
(
x
,
y
,
rayA
,
rayB
)
;
PFP
::
VEC3
AB
=
rayB
-
rayA
;
std
::
vector
<
Dart
>
darts
;
Algo
::
Selection
::
dartsRaySelection
<
PFP
>
(
myMap
,
position
,
rayA
,
AB
,
darts
)
;
glPopMatrix
();
if
(
!
darts
.
empty
())
{
selectedDart
=
darts
[
0
]
;
std
::
cout
<<
"selected dart -> "
<<
selectedDart
<<
std
::
endl
;
std
::
cout
<<
" phi1 -> "
<<
myMap
.
phi1
(
selectedDart
)
<<
" / phi2 -> "
<<
myMap
.
phi2
(
selectedDart
)
<<
std
::
endl
;
std
::
cout
<<
" emb0 -> "
<<
myMap
.
getDartEmbedding
(
VERTEX_ORBIT
,
selectedDart
)
<<
std
::
endl
;
}
else
selectedDart
=
Dart
::
nil
()
;
glutPostRedisplay
()
;
break
;
}
case
'a'
:
{
Algo
::
Geometry
::
computeLaplacianVertices
<
PFP
>
(
myMap
,
Algo
::
Geometry
::
TOPOLOGICAL
,
position
,
laplacian
)
;
...
...
include/Algo/Geometry/centroid.hpp
View file @
7ceecc0e
...
...
@@ -119,7 +119,7 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at
Dart
it
=
d
;
do
{
center
+=
attributs
[
map
.
phi
2
(
it
)];
center
+=
attributs
[
map
.
phi
1
(
it
)];
++
count
;
it
=
map
.
alpha1
(
it
)
;
}
while
(
it
!=
d
)
;
...
...
include/Algo/Geometry/localFrame.h
View file @
7ceecc0e
...
...
@@ -44,8 +44,8 @@ namespace Geometry
template
<
typename
PFP
>
void
vertexLocalFrame
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
VEC3
&
X
,
typename
PFP
::
VEC3
&
Y
,
typename
PFP
::
VEC3
&
Z
)
{
Z
=
vertexNormal
<
PFP
>
(
map
,
d
,
position
)
;
X
=
vectorOutOfDart
<
PFP
>
(
map
,
d
,
position
)
;
Z
=
vertexNormal
<
PFP
>
(
map
,
d
,
position
)
;
X
=
vectorOutOfDart
<
PFP
>
(
map
,
d
,
position
)
;
Y
=
Z
^
X
;
Y
.
normalize
()
;
X
=
Y
^
Z
;
...
...
@@ -56,7 +56,7 @@ template <typename PFP>
typename
PFP
::
MATRIX33
vertexLocalFrame
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
{
typename
PFP
::
VEC3
X
,
Y
,
Z
;
vertexLocalFrame
<
PFP
>
(
map
,
d
,
position
,
X
,
Y
,
Z
)
;
vertexLocalFrame
<
PFP
>
(
map
,
d
,
position
,
X
,
Y
,
Z
)
;
typename
PFP
::
MATRIX33
frame
;
frame
(
0
,
0
)
=
X
[
0
]
;
frame
(
0
,
1
)
=
X
[
1
]
;
frame
(
0
,
2
)
=
X
[
2
]
;
frame
(
1
,
0
)
=
Y
[
0
]
;
frame
(
1
,
1
)
=
Y
[
1
]
;
frame
(
1
,
2
)
=
Y
[
2
]
;
...
...
@@ -70,7 +70,7 @@ template <typename PFP>
void
vertexLocalFrame
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
VEC3
&
normal
,
typename
PFP
::
VEC3
&
X
,
typename
PFP
::
VEC3
&
Y
,
typename
PFP
::
VEC3
&
Z
)
{
Z
=
normal
;
X
=
vectorOutOfDart
<
PFP
>
(
map
,
d
,
position
)
;
X
=
vectorOutOfDart
<
PFP
>
(
map
,
d
,
position
)
;
Y
=
Z
^
X
;
Y
.
normalize
()
;
X
=
Y
^
Z
;
...
...
@@ -81,7 +81,7 @@ template <typename PFP>
typename
PFP
::
MATRIX33
vertexLocalFrame
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
VEC3
&
normal
)
{
typename
PFP
::
VEC3
X
,
Y
,
Z
;
vertexLocalFrame
<
PFP
>
(
map
,
d
,
position
,
normal
,
X
,
Y
,
Z
)
;
vertexLocalFrame
<
PFP
>
(
map
,
d
,
position
,
normal
,
X
,
Y
,
Z
)
;
typename
PFP
::
MATRIX33
frame
;
frame
(
0
,
0
)
=
X
[
0
]
;
frame
(
0
,
1
)
=
X
[
1
]
;
frame
(
0
,
2
)
=
X
[
2
]
;
frame
(
1
,
0
)
=
Y
[
0
]
;
frame
(
1
,
1
)
=
Y
[
1
]
;
frame
(
1
,
2
)
=
Y
[
2
]
;
...
...
include/Algo/Remeshing/pliant.h
View file @
7ceecc0e
...
...
@@ -22,6 +22,9 @@
* *
*******************************************************************************/
#ifndef __ALGO_GEOMETRY_REMESHING_H__
#define __ALGO_GEOMETRY_REMESHING_H__
namespace
CGoGN
{
...
...
@@ -42,3 +45,4 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
#include
"Algo/Remeshing/pliant.hpp"
#endif
include/Algo/Remeshing/pliant.hpp
View file @
7ceecc0e
...
...
@@ -23,6 +23,7 @@
*******************************************************************************/
#include
"Algo/Geometry/basic.h"
#include
"Algo/Geometry/feature.h"
namespace
CGoGN
{
...
...
@@ -73,65 +74,102 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
map
.
cutEdge
(
d
)
;
position
[
map
.
phi1
(
d
)]
=
p
;
map
.
splitFace
(
map
.
phi1
(
d
),
map
.
phi_1
(
d
))
;
map
.
splitFace
(
map
.
phi1
(
dd
),
map
.
phi_1
(
dd
))
;
if
(
dd
!=
d
)
map
.
splitFace
(
map
.
phi1
(
dd
),
map
.
phi_1
(
dd
))
;
}
}
}
// collapse short edges
// compute feature edges
DartMarker
featureEdge
(
map
)
;
Algo
::
Geometry
::
featureEdgeDetection
<
PFP
>
(
map
,
position
,
featureEdge
)
;
// compute feature vertices
CellMarker
featureVertex
(
map
,
VERTEX_ORBIT
)
;
CellMarker
cornerVertex
(
map
,
VERTEX_ORBIT
)
;
DartMarker
m3
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
m3
.
isMarked
(
d
))
{
m3
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
REAL
length
=
Algo
::
Geometry
::
edgeLength
<
PFP
>
(
map
,
d
,
position
)
;
if
(
length
<
edgeLengthInf
&&
map
.
edgeCanCollapse
(
d
))
m3
.
markOrbit
(
VERTEX_ORBIT
,
d
)
;
unsigned
int
nbFeatureEdges
=
0
;
Dart
vit
=
d
;
do
{
bool
collapse
=
true
;
Dart
dd
=
map
.
phi2
(
d
)
;
VEC3
p
=
position
[
dd
]
;
Dart
vit
=
map
.
alpha1
(
d
)
;
do
{
VEC3
vec
=
position
[
dd
]
-
position
[
map
.
phi1
(
vit
)]
;
if
(
vec
.
norm
()
>
edgeLengthSup
)
collapse
=
false
;
vit
=
map
.
alpha1
(
vit
)
;
}
while
(
vit
!=
d
&&
collapse
)
;
if
(
collapse
)
if
(
featureEdge
.
isMarked
(
vit
))
++
nbFeatureEdges
;
vit
=
map
.
alpha1
(
vit
)
;
}
while
(
vit
!=
d
)
;
if
(
nbFeatureEdges
>
0
)
{
if
(
nbFeatureEdges
==
2
)
featureVertex
.
mark
(
d
)
;
else
cornerVertex
.
mark
(
d
)
;
}
}
}
// collapse short
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
m3
.
isMarked
(
d
))
{
m3
.
unmarkOrbit
(
EDGE_ORBIT
,
d
)
;
Dart
d1
=
map
.
phi1
(
d
)
;
if
(
!
cornerVertex
.
isMarked
(
d
)
&&
!
cornerVertex
.
isMarked
(
d1
)
&&
(
(
featureVertex
.
isMarked
(
d
)
&&
featureVertex
.
isMarked
(
d1
))
||
(
!
featureVertex
.
isMarked
(
d
)
&&
!
featureVertex
.
isMarked
(
d1
))
))
{
REAL
length
=
Algo
::
Geometry
::
edgeLength
<
PFP
>
(
map
,
d
,
position
)
;
if
(
length
<
edgeLengthInf
&&
map
.
edgeCanCollapse
(
d
))
{
Dart
v
=
map
.
collapseEdge
(
d
)
;
position
[
v
]
=
p
;
bool
collapse
=
true
;
VEC3
p
=
position
[
d1
]
;
Dart
vit
=
map
.
alpha1
(
d
)
;
do
{
VEC3
vec
=
position
[
d1
]
-
position
[
map
.
phi1
(
vit
)]
;
if
(
vec
.
norm
()
>
edgeLengthSup
)
collapse
=
false
;
vit
=
map
.
alpha1
(
vit
)
;
}
while
(
vit
!=
d
&&
collapse
)
;
if
(
collapse
)
{
Dart
v
=
map
.
collapseEdge
(
d
)
;
position
[
v
]
=
p
;
}
}
}
}
}
// equalize valences with edge flips
DartMarker
m4
(
map
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
m
4
.
isMarked
(
d
))
if
(
!
m
3
.
isMarked
(
d
))
{
m
4
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
m
3
.
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
>
1
)
if
(
!
featureEdge
.
isMarked
(
d
)
&&
e
!=
d
)
{
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
))
;
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
>
1
)
{
map
.
flipEdge
(
d
)
;
m3
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi1
(
d
))
;
m3
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi_1
(
d
))
;
m3
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi1
(
e
))
;
m3
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi_1
(
e
))
;
}
}
}
}
...
...
@@ -149,10 +187,13 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
if
(
!
vm
.
isMarked
(
d
))
{
vm
.
mark
(
d
)
;
VEC3
l
=
position
[
d
]
-
centroid
[
d
]
;
REAL
e
=
l
*
normal
[
d
]
;
VEC3
displ
=
e
*
normal
[
d
]
;
position
[
d
]
=
centroid
[
d
]
+
displ
;
if
(
!
cornerVertex
.
isMarked
(
d
)
&&
!
featureVertex
.
isMarked
(
d
)
&&
!
map
.
isBoundaryVertex
(
d
))
{
VEC3
l
=
position
[
d
]
-
centroid
[
d
]
;
REAL
e
=
l
*
normal
[
d
]
;
VEC3
displ
=
e
*
normal
[
d
]
;
position
[
d
]
=
centroid
[
d
]
+
displ
;
}
}
}
...
...
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