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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KennethVanhoey
CGoGN
Commits
7631797f
Commit
7631797f
authored
Mar 04, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pliant remeshing : la suite..
parent
ba8c6802
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
18 deletions
+88
-18
Apps/Examples/miniTest.cpp
Apps/Examples/miniTest.cpp
+54
-1
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+10
-7
include/Algo/Remeshing/pliant.hpp
include/Algo/Remeshing/pliant.hpp
+10
-8
include/Geometry/vector_gen.h
include/Geometry/vector_gen.h
+2
-0
include/Geometry/vector_gen.hpp
include/Geometry/vector_gen.hpp
+12
-2
No files found.
Apps/Examples/miniTest.cpp
View file @
7631797f
...
...
@@ -45,6 +45,8 @@
#include "Algo/Decimation/decimation.h"
#include "Algo/Remeshing/pliant.h"
#include "Algo/Selection/raySelector.h"
using
namespace
CGoGN
;
struct
PFP
:
public
PFP_STANDARD
...
...
@@ -96,6 +98,8 @@ 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
()
;
...
...
@@ -306,6 +310,8 @@ 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
()
...
...
@@ -349,10 +355,26 @@ void MyGlutWin::myRedraw()
glPushMatrix
()
;
float
sc
=
50.
/
gWidthObj
;
float
sc
=
50.
0
f
/
gWidthObj
;
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
);
...
...
@@ -705,6 +727,37 @@ 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/normal.hpp
View file @
7631797f
...
...
@@ -40,9 +40,9 @@ typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const typename
{
typedef
typename
PFP
::
VEC3
VEC3
;
VEC3
p1
=
position
[
d
];
VEC3
p2
=
position
[
map
.
phi1
(
d
)];
VEC3
p3
=
position
[
map
.
phi_1
(
d
)];
const
VEC3
&
p1
=
position
[
d
];
const
VEC3
&
p2
=
position
[
map
.
phi1
(
d
)];
const
VEC3
&
p3
=
position
[
map
.
phi_1
(
d
)];
VEC3
N
=
Geom
::
triangleNormal
(
p1
,
p2
,
p3
)
;
N
.
normalize
()
;
...
...
@@ -84,10 +84,13 @@ typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const typename P
do
{
VEC3
n
=
faceNormal
<
PFP
>
(
map
,
it
,
position
)
;
VEC3
v1
=
vectorOutOfDart
<
PFP
>
(
map
,
it
,
position
)
;
VEC3
v2
=
vectorOutOfDart
<
PFP
>
(
map
,
map
.
phi_1
(
it
),
position
)
;
n
*=
convexFaceArea
<
PFP
>
(
map
,
it
,
position
)
/
(
v1
.
norm2
()
*
v2
.
norm2
())
;
N
+=
n
;
if
(
!
n
.
hasNan
())
{
VEC3
v1
=
vectorOutOfDart
<
PFP
>
(
map
,
it
,
position
)
;
VEC3
v2
=
vectorOutOfDart
<
PFP
>
(
map
,
map
.
phi_1
(
it
),
position
)
;
n
*=
convexFaceArea
<
PFP
>
(
map
,
it
,
position
)
/
(
v1
.
norm2
()
*
v2
.
norm2
())
;
N
+=
n
;
}
it
=
map
.
phi1
(
map
.
phi2
(
it
))
;
}
while
(
it
!=
d
)
;
N
.
normalize
()
;
...
...
include/Algo/Remeshing/pliant.hpp
View file @
7631797f
...
...
@@ -86,7 +86,7 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
{
m3
.
markOrbit
(
EDGE_ORBIT
,
d
)
;
REAL
length
=
Algo
::
Geometry
::
edgeLength
<
PFP
>
(
map
,
d
,
position
)
;
if
(
length
<
edgeLengthInf
)
if
(
length
<
edgeLengthInf
&&
map
.
edgeCanCollapse
(
d
)
)
{
bool
collapse
=
true
;
Dart
dd
=
map
.
phi2
(
d
)
;
...
...
@@ -125,7 +125,7 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
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
)
if
(
flip
>
1
)
{
map
.
flipEdge
(
d
)
;
m4
.
markOrbit
(
EDGE_ORBIT
,
map
.
phi1
(
d
))
;
...
...
@@ -140,8 +140,8 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
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
)
;
AttributeHandler
<
VEC3
>
centroid
=
map
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"centroid
"
)
;
Algo
::
Geometry
::
computeNeighborhoodCentroidVertices
<
PFP
>
(
map
,
position
,
centroid
)
;
CellMarker
vm
(
map
,
VERTEX_CELL
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
...
...
@@ -149,12 +149,14 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
if
(
!
vm
.
isMarked
(
d
))
{
vm
.
mark
(
d
)
;
VEC3
l
=
position
[
d
]
-
newPosition
[
d
]
;
newPosition
[
d
]
=
newPosition
[
d
]
+
((
normal
[
d
]
*
l
)
*
normal
[
d
])
;
VEC3
l
=
position
[
d
]
-
centroid
[
d
]
;
REAL
e
=
l
*
normal
[
d
]
;
VEC3
displ
=
e
*
normal
[
d
]
;
position
[
d
]
=
centroid
[
d
]
+
displ
;
}
}
map
.
template
swapAttributes
<
VEC3
>(
position
,
newPosition
)
;
map
.
template
removeAttribute
<
VEC3
>(
newPosition
)
;
map
.
template
removeAttribute
<
VEC3
>(
centroid
)
;
}
}
// namespace Remeshing
...
...
include/Geometry/vector_gen.h
View file @
7631797f
...
...
@@ -132,6 +132,8 @@ public:
// Equal
bool
operator
==
(
const
Vector
<
DIM
,
T
>&
v
)
const
;
bool
hasNan
()
const
;
/**********************************************/
/* STREAM OPERATORS */
/**********************************************/
...
...
include/Geometry/vector_gen.hpp
View file @
7631797f
...
...
@@ -270,11 +270,21 @@ inline Vector<DIM,T> Vector<DIM,T>::operator^(const Vector<DIM,T> v) const
template
<
unsigned
int
DIM
,
typename
T
>
inline
bool
Vector
<
DIM
,
T
>::
operator
==
(
const
Vector
<
DIM
,
T
>&
v
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
DIM
;
++
i
)
if
(
v
[
i
]
!=
m_data
[
i
])
return
false
;
for
(
unsigned
int
i
=
0
;
i
<
DIM
;
++
i
)
if
(
v
[
i
]
!=
m_data
[
i
])
return
false
;
return
true
;
}
template
<
unsigned
int
DIM
,
typename
T
>
inline
bool
Vector
<
DIM
,
T
>::
hasNan
()
const
{
for
(
unsigned
int
i
=
0
;
i
<
DIM
;
++
i
)
if
(
isnan
(
m_data
[
i
]))
return
true
;
return
false
;
}
/**********************************************/
/* STREAM OPERATORS */
/**********************************************/
...
...
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