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
KennethVanhoey
CGoGN
Commits
c6d8c4e1
Commit
c6d8c4e1
authored
Jun 15, 2011
by
Kenneth Vanhoey
Browse files
Merge cgogn:~cgogn/CGoGN
parents
4e5e69b1
695d8500
Changes
29
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/viewer.cpp
View file @
c6d8c4e1
...
...
@@ -186,7 +186,6 @@ void Viewer::importMesh(std::string& filename)
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
gPosObj
=
bb
.
center
()
;
normalBaseSize
=
bb
.
diagSize
()
/
100.0
f
;
vertexBaseSize
=
normalBaseSize
*
2.0
f
;
...
...
@@ -198,7 +197,7 @@ void Viewer::importMesh(std::string& filename)
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
setParamObject
(
bb
.
maxSize
(),
gPosObj
.
data
())
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
()
.
data
())
;
updateGLMatrices
()
;
}
...
...
Apps/Examples/viewer.h
View file @
c6d8c4e1
...
...
@@ -78,7 +78,6 @@ public:
float
shininess
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
;
Geom
::
Vec3f
gPosObj
;
float
normalBaseSize
;
float
normalScaleFactor
;
float
vertexBaseSize
;
...
...
include/Algo/Decimation/edgeSelector.h
View file @
c6d8c4e1
...
...
@@ -27,6 +27,11 @@
#include
"Algo/Decimation/selector.h"
#include
"Container/fakeAttribute.h"
#include
"Utils/qem.h"
#include
"Utils/quadricRGBfunctions.h"
#include
"Algo/Geometry/curvature.h"
namespace
CGoGN
{
...
...
@@ -246,12 +251,17 @@ private:
}
CurvatureEdgeInfo
;
typedef
NoMathIOAttribute
<
CurvatureEdgeInfo
>
EdgeInfo
;
Geom
::
BoundingBox
<
VEC3
>
bb
;
REAL
radius
;
typename
PFP
::
TVEC3
normal
;
AttributeHandler
<
EdgeInfo
>
edgeInfo
;
typename
PFP
::
TREAL
k1
;
typename
PFP
::
TREAL
k2
;
typename
PFP
::
TVEC3
K1
;
typename
PFP
::
TVEC3
K2
;
typename
PFP
::
TREAL
edgeangle
;
typename
PFP
::
TREAL
kmax
;
typename
PFP
::
TREAL
kmin
;
typename
PFP
::
TVEC3
Kmax
;
typename
PFP
::
TVEC3
Kmin
;
typename
PFP
::
TVEC3
Knormal
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
...
...
@@ -266,6 +276,9 @@ public:
EdgeSelector_Curvature
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
m
,
pos
)
;
radius
=
bb
.
diagSize
()
*
0.003
;
normal
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"normal"
)
;
if
(
!
normal
.
isValid
())
{
...
...
@@ -273,29 +286,40 @@ public:
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
m
,
pos
,
normal
)
;
}
k1
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"k1"
)
;
k2
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"k2"
)
;
K1
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"K1"
)
;
K2
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"K2"
)
;
edgeangle
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"edgeangle"
)
;
if
(
!
edgeangle
.
isValid
())
{
edgeangle
=
m
.
template
addAttribute
<
REAL
>(
EDGE
,
"edgeangle"
)
;
Algo
::
Geometry
::
computeAnglesBetweenNormalsOnEdges
<
PFP
>
(
m
,
pos
,
edgeangle
)
;
}
kmax
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"kmax"
)
;
kmin
=
m
.
template
getAttribute
<
REAL
>(
VERTEX
,
"kmin"
)
;
Kmax
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"Kmax"
)
;
Kmin
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"Kmin"
)
;
Knormal
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX
,
"Knormal"
)
;
// as all these attributes are computed simultaneously by computeCurvatureVertices
// one can assume that if one of them is not valid, the others must be created too
if
(
!
k
1
.
isValid
())
if
(
!
k
max
.
isValid
())
{
k1
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"k1"
)
;
k2
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"k2"
)
;
K1
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"K1"
)
;
K2
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"K2"
)
;
Algo
::
Geometry
::
computeCurvatureVertices
<
PFP
>
(
m
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
kmax
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"kmax"
)
;
kmin
=
m
.
template
addAttribute
<
REAL
>(
VERTEX
,
"kmin"
)
;
Kmax
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"Kmax"
)
;
Kmin
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"Kmin"
)
;
Knormal
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX
,
"Knormal"
)
;
Algo
::
Geometry
::
computeCurvatureVertices_NormalCycles
<
PFP
>
(
m
,
radius
,
pos
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
}
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
>(
EDGE
,
"edgeInfo"
)
;
}
~
EdgeSelector_Curvature
()
{
this
->
m_map
.
removeAttribute
(
k1
)
;
this
->
m_map
.
removeAttribute
(
k2
)
;
this
->
m_map
.
removeAttribute
(
K1
)
;
this
->
m_map
.
removeAttribute
(
K2
)
;
this
->
m_map
.
removeAttribute
(
edgeangle
)
;
this
->
m_map
.
removeAttribute
(
kmax
)
;
this
->
m_map
.
removeAttribute
(
kmin
)
;
this
->
m_map
.
removeAttribute
(
Kmax
)
;
this
->
m_map
.
removeAttribute
(
Kmin
)
;
this
->
m_map
.
removeAttribute
(
Knormal
)
;
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_Curvature
;
}
...
...
include/Algo/Decimation/edgeSelector.hpp
View file @
c6d8c4e1
...
...
@@ -795,14 +795,14 @@ void EdgeSelector_Curvature<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
MAP
&
m
=
this
->
m_map
;
normal
[
d2
]
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
m
,
d2
,
this
->
m_position
)
;
Algo
::
Geometry
::
computeCurvatureVertex
<
PFP
>
(
m
,
d2
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
Algo
::
Geometry
::
computeCurvatureVertex
_NormalCycles
<
PFP
>
(
m
,
d2
,
radius
,
this
->
m_position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
Dart
vit
=
d2
;
do
{
Dart
nVert
=
m
.
phi1
(
vit
)
;
normal
[
nVert
]
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
m
,
nVert
,
this
->
m_position
)
;
Algo
::
Geometry
::
computeCurvatureVertex
<
PFP
>
(
m
,
nVert
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
Algo
::
Geometry
::
computeCurvatureVertex
_NormalCycles
<
PFP
>
(
m
,
nVert
,
radius
,
this
->
m_position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
updateEdgeInfo
(
m
.
phi1
(
vit
),
false
)
;
// must recompute some edge infos in the
if
(
vit
==
d2
||
vit
==
dd2
)
// neighborhood of the collapsed edge
...
...
@@ -891,11 +891,11 @@ void EdgeSelector_Curvature<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
// compute things on the coarse version of the mesh
normal
[
newV
]
=
Algo
::
Geometry
::
vertexNormal
<
PFP
>
(
m
,
d2
,
this
->
m_position
)
;
Algo
::
Geometry
::
computeCurvatureVertex
<
PFP
>
(
m
,
d2
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
Algo
::
Geometry
::
computeCurvatureVertex
_NormalCycles
<
PFP
>
(
m
,
d2
,
radius
,
this
->
m_position
,
normal
,
edgeangle
,
kmax
,
kmin
,
Kmax
,
Kmin
,
Knormal
)
;
VEC3
norm
=
normal
[
newV
]
;
REAL
mCurv
=
(
k1
[
newV
]
+
k
2
[
newV
]
)
/
REAL
(
2
)
;
VEC3
cDir1
=
K
1
[
newV
]
;
//
VEC3 norm = normal[newV] ;
REAL
mCurv
=
(
kmax
[
newV
]
+
k
min
[
newV
])
/
REAL
(
2
)
;
//
VEC3 cDir1 = K
max
[newV] ;
// vertex split to reset the initial connectivity and embeddings
m
.
insertTrianglePair
(
d
,
d2
,
dd2
)
;
...
...
@@ -904,17 +904,17 @@ void EdgeSelector_Curvature<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
REAL
err
=
0
;
REAL
norm_deviation_1
=
REAL
(
1
)
/
abs
(
norm
*
normal
[
v1
])
;
REAL
norm_deviation_2
=
REAL
(
1
)
/
abs
(
norm
*
normal
[
v2
])
;
err
+=
norm_deviation_1
+
norm_deviation_2
;
//
REAL norm_deviation_1 = REAL(1) / abs(norm * normal[v1]) ;
//
REAL norm_deviation_2 = REAL(1) / abs(norm * normal[v2]) ;
//
err += norm_deviation_1 + norm_deviation_2 ;
REAL
mCurv_deviation_1
=
abs
(
mCurv
-
(
k
1
[
v1
]
+
k
2
[
v1
]
/
REAL
(
2
)))
;
REAL
mCurv_deviation_2
=
abs
(
mCurv
-
(
k
1
[
v2
]
+
k
2
[
v2
]
/
REAL
(
2
)))
;
REAL
mCurv_deviation_1
=
abs
(
mCurv
-
(
k
max
[
v1
]
+
k
min
[
v1
]
/
REAL
(
2
)))
;
REAL
mCurv_deviation_2
=
abs
(
mCurv
-
(
k
max
[
v2
]
+
k
min
[
v2
]
/
REAL
(
2
)))
;
err
+=
mCurv_deviation_1
+
mCurv_deviation_2
;
REAL
cDir1_deviation_1
=
REAL
(
1
)
/
abs
(
cDir1
*
K
1
[
v1
])
;
REAL
cDir1_deviation_2
=
REAL
(
1
)
/
abs
(
cDir1
*
K
1
[
v2
])
;
err
+=
cDir1_deviation_1
+
cDir1_deviation_2
;
//
REAL cDir1_deviation_1 = REAL(1) / abs(cDir1 * K
max
[v1]) ;
//
REAL cDir1_deviation_2 = REAL(1) / abs(cDir1 * K
max
[v2]) ;
//
err += cDir1_deviation_1 + cDir1_deviation_2 ;
einfo
.
it
=
edges
.
insert
(
std
::
make_pair
(
err
,
d
))
;
einfo
.
valid
=
true
;
...
...
include/Algo/Decimation/selector.h
View file @
c6d8c4e1
...
...
@@ -25,11 +25,6 @@
#ifndef __SELECTOR_H__
#define __SELECTOR_H__
#include
"Utils/qem.h"
#include
"Utils/quadricRGBfunctions.h"
#include
"Container/fakeAttribute.h"
#include
"Algo/Geometry/curvature.h"
namespace
CGoGN
{
...
...
@@ -39,7 +34,6 @@ namespace Algo
namespace
Decimation
{
enum
SelectorType
{
S_MapOrder
,
...
...
@@ -53,11 +47,9 @@ enum SelectorType
S_hLightfield
}
;
template
<
typename
PFP
>
class
ApproximatorGen
;
template
<
typename
PFP
,
typename
T
>
class
Approximator
;
template
<
typename
PFP
>
class
EdgeSelector
{
...
...
@@ -91,5 +83,4 @@ public:
}
// namespace CGoGN
#endif
include/Algo/Filter
s2D
/average_normals.h
pp
→
include/Algo/Filter
ing
/average_normals.h
View file @
c6d8c4e1
...
...
@@ -30,7 +30,7 @@ namespace CGoGN
namespace
Algo
{
namespace
Filter
s2D
namespace
Filter
ing
{
/**
...
...
@@ -48,7 +48,6 @@ void computeNewPositionsFromFaceNormals(
const
typename
PFP
::
TVEC3
&
faceNewNormal
,
const
FunctorSelect
&
select
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -70,9 +69,7 @@ void computeNewPositionsFromFaceNormals(
{
sumAreas
+=
faceArea
[
dd
]
;
VEC3
vT
=
faceCentroid
[
dd
]
-
pos_d
;
const
VEC3
&
normal
=
faceNewNormal
[
dd
]
;
REAL
scal
=
vT
*
normal
;
vT
=
scal
*
faceNormal
[
dd
]
;
vT
=
(
vT
*
faceNewNormal
[
dd
])
*
faceNormal
[
dd
]
;
displ
+=
faceArea
[
dd
]
*
vT
;
dd
=
map
.
phi1
(
map
.
phi2
(
dd
))
;
}
while
(
dd
!=
d
)
;
...
...
@@ -84,9 +81,8 @@ void computeNewPositionsFromFaceNormals(
template
<
typename
PFP
>
void
filterAverageNormals
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
)
void
filterAverageNormals
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -148,9 +144,8 @@ void filterAverageNormals(typename PFP::MAP& map, const typename PFP::TVEC3& pos
}
template
<
typename
PFP
>
void
filterMMSE
(
typename
PFP
::
MAP
&
map
,
float
sigmaN2
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
)
void
filterMMSE
(
typename
PFP
::
MAP
&
map
,
float
sigmaN2
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -252,9 +247,8 @@ void filterMMSE(typename PFP::MAP& map, float sigmaN2, const typename PFP::TVEC3
}
template
<
typename
PFP
>
void
filterTNBA
(
typename
PFP
::
MAP
&
map
,
float
sigmaN2
,
float
SUSANthreshold
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
)
void
filterTNBA
(
typename
PFP
::
MAP
&
map
,
float
sigmaN2
,
float
SUSANthreshold
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -392,9 +386,8 @@ void filterTNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
}
template
<
typename
PFP
>
void
filterVNBA
(
typename
PFP
::
MAP
&
map
,
float
sigmaN2
,
float
SUSANthreshold
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
)
void
filterVNBA
(
typename
PFP
::
MAP
&
map
,
float
sigmaN2
,
float
SUSANthreshold
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -550,7 +543,7 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
// CGoGNout <<" adaptive rate = "<< float(nbAdapt)/float(nbTot)<<CGoGNendl;
}
}
//namespace Filter
s2D
}
//namespace Filter
ing
}
//namespace Algo
...
...
include/Algo/Filter
s2D
/average.h
pp
→
include/Algo/Filter
ing
/average
_positions
.h
View file @
c6d8c4e1
...
...
@@ -22,20 +22,26 @@
* *
*******************************************************************************/
#include
"Algo/Filtering/functors.h"
#include
"Algo/Selection/collector.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Filter
s2D
namespace
Filter
ing
{
template
<
typename
PFP
>
void
filterAverage
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
)
void
filterAverage
Positions
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
MAP
,
typename
PFP
::
VEC3
>
fa
(
map
,
position
)
;
Algo
::
Selection
::
Collector_OneRing
<
PFP
>
c
(
map
)
;
CellMarker
markV
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
...
...
@@ -43,30 +49,16 @@ void filterAverage(typename PFP::MAP& map, const typename PFP::TVEC3& position,
{
markV
.
mark
(
d
);
// get position of vertex
const
VEC3
&
pos_d
=
position
[
d
]
;
// traversal of neighbour vertices
VEC3
l
(
0
)
;
int
nbE
=
0
;
Dart
dd
=
d
;
do
{
Dart
e
=
map
.
phi2
(
dd
)
;
l
+=
position
[
e
]
-
pos_d
;
nbE
++
;
dd
=
map
.
phi1
(
e
)
;
}
while
(
dd
!=
d
)
;
l
/=
float
(
nbE
)
;
position2
[
d
]
=
pos_d
+
l
;
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
position2
[
d
]
=
fa
.
getAverage
()
;
}
}
}
}
//namespace Filter
s2D
}
//
namespace Filter
ing
}
//namespace Algo
}
//
namespace Algo
}
//namespace CGoGN
}
//
namespace CGoGN
include/Algo/Filter
s2D
/bilateral.h
pp
→
include/Algo/Filter
ing
/bilateral.h
View file @
c6d8c4e1
...
...
@@ -30,7 +30,7 @@ namespace CGoGN
namespace
Algo
{
namespace
Filter
s2D
namespace
Filter
ing
{
...
...
@@ -57,8 +57,7 @@ void sigmaBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position,
Dart
e
=
map
.
phi2
(
dd
)
;
if
(
!
mv
.
isMarked
(
e
))
{
VEC3
vec
=
Algo
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
dd
,
position
)
;
sumLengths
+=
vec
.
norm
()
;
sumLengths
+=
Algo
::
Geometry
::
edgeLength
<
PFP
>
(
map
,
dd
,
position
)
;
sumAngles
+=
Geom
::
angle
(
normal
[
d
],
normal
[
e
])
;
++
nbEdges
;
}
...
...
@@ -74,7 +73,7 @@ void sigmaBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position,
}
template
<
typename
PFP
>
void
filterBilateral
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
)
void
filterBilateral
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
...
...
@@ -112,7 +111,7 @@ void filterBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position
}
template
<
typename
PFP
>
void
filterSUSAN
(
typename
PFP
::
MAP
&
map
,
float
SUSANthreshold
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
)
void
filterSUSAN
(
typename
PFP
::
MAP
&
map
,
float
SUSANthreshold
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
...
...
@@ -171,7 +170,7 @@ void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const typename PF
// CGoGNout <<" susan rate = "<< float(nbSusan)/float(nbTot)<<CGoGNendl;
}
}
//namespace Filter
s2D
}
//namespace Filter
ing
}
//namespace Algo
...
...
include/Algo/Filter
s2D
/taubin.h
pp
→
include/Algo/Filter
ing
/taubin.h
View file @
c6d8c4e1
...
...
@@ -22,50 +22,92 @@
* *
*******************************************************************************/
#include
"Algo/Filtering/functors.h"
#include
"Algo/Selection/collector.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Filters2D
namespace
Filtering
{
template
<
typename
PFP
>
void
filterTaubin
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
())
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
MAP
,
typename
PFP
::
VEC3
>
fa
(
map
,
position
)
;
Algo
::
Selection
::
Collector_OneRing
<
PFP
>
c
(
map
)
;
const
float
lambda
=
0.6307
;
const
float
mu
=
-
0.6732
;
CellMarkerNoUnmark
mv
(
map
,
VERTEX
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
mv
.
isMarked
(
d
))
{
mv
.
mark
(
d
);
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
VEC3
p
=
position
[
d
]
;
VEC3
displ
=
fa
.
getAverage
()
-
p
;
displ
*=
lambda
;
position2
[
d
]
=
p
+
displ
;
}
}
// unshrinking step
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
mv
.
isMarked
(
d
))
{
mv
.
unmark
(
d
);
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
VEC3
p
=
position2
[
d
]
;
VEC3
displ
=
fa
.
getAverage
()
-
p
;
displ
*=
mu
;
position
[
d
]
=
p
+
displ
;
}
}
}
/**
* Taubin filter modified as proposed by [Lav09]
*/
template
<
typename
PFP
>
void
filterTaubin
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
)
void
filterTaubin
_modified
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
MAP
,
typename
PFP
::
VEC3
>
fa
(
map
,
position
)
;
Algo
::
Selection
::
Collector_OneRing
<
PFP
>
c
(
map
)
;
const
float
lambda
=
0.6307
;
const
float
mu
=
-
0.6732
;
CellMarkerNoUnmark
mv
(
map
,
VERTEX
);
CellMarkerNoUnmark
mv
(
map
,
VERTEX
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
mv
.
isMarked
(
d
))
{
mv
.
mark
(
d
);
// get pos of vertex
const
VEC3
&
pos_d
=
position
[
d
]
;
// traversal of vertices neighborhood
VEC3
l
(
0
)
;
int
nbE
=
0
;
Dart
dd
=
d
;
do
{
Dart
e
=
map
.
phi2
(
dd
)
;
l
+=
position
[
e
]
-
pos_d
;
nbE
++
;
dd
=
map
.
phi1
(
e
)
;
}
while
(
dd
!=
d
)
;
l
/=
float
(
nbE
)
;
l
*=
lambda
;
position2
[
d
]
=
pos_d
+
l
;
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
VEC3
p
=
position
[
d
]
;
VEC3
displ
=
fa
.
getAverage
()
-
p
;
displ
*=
lambda
;
position2
[
d
]
=
p
+
displ
;
}
}
...
...
@@ -76,31 +118,19 @@ void filterTaubin(typename PFP::MAP& map, typename PFP::TVEC3& position, typenam
{
mv
.
unmark
(
d
);
// get pos of vertex
const
VEC3
&
pos_d
=
position2
[
d
]
;
// traversal of vertices neighborhood
VEC3
l
(
0
)
;
int
nbE
=
0
;
Dart
dd
=
d
;
do
{
Dart
e
=
map
.
phi2
(
dd
)
;
l
+=
position2
[
e
]
-
pos_d
;
nbE
++
;
dd
=
map
.
phi1
(
e
)
;
}
while
(
dd
!=
d
)
;
l
/=
float
(
nbE
)
;
l
*=
mu
;
position
[
d
]
=
pos_d
+
l
;
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
VEC3
p
=
position2
[
d
]
;
VEC3
displ
=
fa
.
getAverage
()
-
p
;
displ
*=
mu
;
position
[
d
]
=
p
+
displ
;
}
}
}
}
//namespace Filter
s2D
}
//
namespace Filter
ing
}
//namespace Algo
}
//
namespace Algo
}
//namespace CGoGN
}
//
namespace CGoGN
include/Algo/Filter
s2D
/tools.h
pp
→
include/Algo/Filter
ing
/tools.h
View file @
c6d8c4e1
...
...
@@ -34,11 +34,11 @@ namespace CGoGN
namespace
Algo
{
namespace
Filter
s2D
namespace
Filter
ing
{
template
<
typename
PFP
>
float
computeHaussdorf
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
originalPosition
,
const
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
)
float
computeHaussdorf
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
originalPosition
,
const
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
...
...
@@ -92,7 +92,7 @@ float computeHaussdorf(typename PFP::MAP& map, const typename PFP::TVEC3& origin
}
template
<
typename
PFP
>
void
computeNoise
(
typename
PFP
::
MAP
&
map
,
long
amount
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
)
void
computeNoise
(
typename
PFP
::
MAP
&
map
,
long
amount
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
=
SelectorTrue
()
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
...
...
@@ -143,7 +143,7 @@ void computeNoise(typename PFP::MAP& map, long amount, const typename PFP::TVEC3