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
73576e31
Commit
73576e31
authored
Jul 12, 2011
by
Basile Sauvage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajout des filtres taubin et moyenneur avec les collector + foncteurs
parent
6923415d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
258 additions
and
28 deletions
+258
-28
include/Algo/Filtering/average.h
include/Algo/Filtering/average.h
+197
-0
include/Algo/Filtering/average_positions.h
include/Algo/Filtering/average_positions.h
+1
-1
include/Algo/Filtering/functors.h
include/Algo/Filtering/functors.h
+34
-3
include/Algo/Filtering/taubin.h
include/Algo/Filtering/taubin.h
+24
-22
include/Algo/Geometry/intersection.h
include/Algo/Geometry/intersection.h
+2
-2
No files found.
include/Algo/Filtering/average.h
0 → 100644
View file @
73576e31
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Algo/Filtering/functors.h"
#include "Algo/Selection/collector.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Filtering
{
enum
neighborhood
{
INSIDE
=
1
,
BORDER
=
2
};
template
<
typename
PFP
,
typename
T
>
void
filterAverageAttribute_OneRing
(
typename
PFP
::
MAP
&
map
,
const
typename
AttributeHandler
<
T
>&
attIn
,
typename
AttributeHandler
<
T
>&
attOut
,
neighborhood
neigh
,
const
FunctorSelect
&
select
=
SelectorTrue
())
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
VEC3
>
fa
(
attIn
)
;
Algo
::
Selection
::
Collector_OneRing
<
PFP
>
col
(
map
)
;
CellMarker
markV
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
markV
.
isMarked
(
d
))
{
markV
.
mark
(
d
);
if
(
neigh
&
INSIDE
)
col
.
collectAll
(
d
)
;
else
col
.
collectBorder
(
d
)
;
fa
.
reset
()
;
if
(
neigh
&
INSIDE
){
switch
(
attIn
.
getOrbit
())
{
case
VERTEX
:
col
.
applyOnInsideVertices
(
fa
)
;
break
;
case
EDGE
:
col
.
applyOnInsideEdges
(
fa
)
;
break
;
case
FACE
:
col
.
applyOnInsideFaces
(
fa
)
;
break
;
}
}
if
(
neigh
&
BORDER
)
col
.
applyOnBorder
(
fa
)
;
attOut
[
d
]
=
fa
.
getAverage
()
;
}
}
}
template
<
typename
PFP
,
typename
T
>
void
filterAverageEdgesAttribute_WithinSphere
(
typename
PFP
::
MAP
&
map
,
const
typename
AttributeHandler
<
T
>&
attIn
,
typename
AttributeHandler
<
T
>&
attOut
,
neighborhood
neigh
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
REAL
radius
,
const
FunctorSelect
&
select
=
SelectorTrue
())
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
VEC3
>
fa
(
attIn
)
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
col
(
map
,
position
,
radius
)
;
CellMarker
markV
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
markV
.
isMarked
(
d
))
{
markV
.
mark
(
d
);
if
(
neigh
&
INSIDE
)
col
.
collectAll
(
d
)
;
else
col
.
collectBorder
(
d
)
;
fa
.
reset
()
;
if
(
neigh
&
INSIDE
)
col
.
applyOnInsideEdges
(
fa
)
;
if
(
neigh
&
BORDER
)
col
.
applyOnBorder
(
fa
)
;
attOut
[
d
]
=
fa
.
getAverage
()
;
}
}
}
template
<
typename
PFP
,
typename
T
>
void
filterAverageFacesAttribute_WithinSphere
(
typename
PFP
::
MAP
&
map
,
const
typename
AttributeHandler
<
T
>&
attIn
,
typename
AttributeHandler
<
T
>&
attOut
,
neighborhood
neigh
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
REAL
radius
,
const
FunctorSelect
&
select
=
SelectorTrue
())
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
VEC3
>
fa
(
attIn
)
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
col
(
map
,
position
,
radius
)
;
CellMarker
markV
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
markV
.
isMarked
(
d
))
{
markV
.
mark
(
d
);
if
(
neigh
&
INSIDE
)
col
.
collectAll
(
d
)
;
else
col
.
collectBorder
(
d
)
;
fa
.
reset
()
;
if
(
neigh
&
INSIDE
)
col
.
applyOnInsideFaces
(
fa
)
;
if
(
neigh
&
BORDER
)
col
.
applyOnBorder
(
fa
)
;
attOut
[
d
]
=
fa
.
getAverage
()
;
}
}
}
template
<
typename
PFP
,
typename
T
>
void
filterAverageVertexAttribute_WithinSphere
(
typename
PFP
::
MAP
&
map
,
const
typename
AttributeHandler
<
T
>&
attIn
,
typename
AttributeHandler
<
T
>&
attOut
,
neighborhood
neigh
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
REAL
radius
,
const
FunctorSelect
&
select
=
SelectorTrue
())
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
VEC3
>
faInside
(
attIn
)
;
FunctorAverageOnSphereBorder
<
PFP
,
typename
PFP
::
VEC3
>
faBorder
(
map
,
attIn
,
position
)
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
col
(
map
,
position
,
radius
)
;
CellMarker
markV
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
markV
.
isMarked
(
d
))
{
markV
.
mark
(
d
);
if
(
neigh
&
INSIDE
)
col
.
collectAll
(
d
)
;
else
col
.
collectBorder
(
d
)
;
attOut
[
d
]
=
T
(
0
);
if
(
neigh
&
INSIDE
){
faInside
.
reset
()
;
col
.
applyOnInsideVertices
(
faInside
)
;
attOut
[
d
]
+=
faInside
.
getSum
();
}
if
(
neigh
&
BORDER
){
faBorder
.
reset
(
position
[
d
],
radius
);
col
.
applyOnBorder
(
faBorder
)
;
attOut
[
d
]
+=
faBorder
.
getSum
();
}
attOut
[
d
]
/=
faInside
.
getCout
()
+
faBorder
.
getCount
()
;
}
}
}
}
// namespace Filtering
}
// namespace Algo
}
// namespace CGoGN
include/Algo/Filtering/average_positions.h
View file @
73576e31
...
...
@@ -39,7 +39,7 @@ void filterAveragePositions(typename PFP::MAP& map, const typename PFP::TVEC3& p
{
typedef
typename
PFP
::
VEC3
VEC3
;
FunctorAverage
<
typename
PFP
::
MAP
,
typename
PFP
::
VEC3
>
fa
(
map
,
position
)
;
FunctorAverage
<
typename
PFP
::
VEC3
>
fa
(
position
)
;
Algo
::
Selection
::
Collector_OneRing
<
PFP
>
c
(
map
)
;
CellMarker
markV
(
map
,
VERTEX
);
...
...
include/Algo/Filtering/functors.h
View file @
73576e31
...
...
@@ -26,6 +26,7 @@
#define __FILTERING_FUNCTORS_H__
#include "Topology/generic/functor.h"
#include "Utils/intersection.h"
namespace
CGoGN
{
...
...
@@ -36,15 +37,15 @@ namespace Algo
namespace
Filtering
{
template
<
typename
MAP
,
typename
T
>
class
FunctorAverage
:
public
Functor
Map
<
MAP
>
template
<
typename
T
>
class
FunctorAverage
:
public
Functor
Type
{
protected:
const
AttributeHandler
<
T
>&
attr
;
T
sum
;
unsigned
int
count
;
public:
FunctorAverage
(
MAP
&
map
,
const
AttributeHandler
<
T
>&
a
)
:
FunctorMap
<
MAP
>
(
map
),
attr
(
a
),
sum
(
0
),
count
(
0
)
FunctorAverage
(
const
AttributeHandler
<
T
>&
a
)
:
FunctorType
(
),
attr
(
a
),
sum
(
0
),
count
(
0
)
{}
bool
operator
()(
Dart
d
)
{
...
...
@@ -54,6 +55,36 @@ public:
}
inline
void
reset
()
{
sum
=
T
(
0
)
;
count
=
0
;
}
inline
T
getSum
()
{
return
sum
;
}
inline
unsigned
int
getCount
()
{
return
count
;
}
inline
T
getAverage
()
{
return
sum
/
typename
T
::
DATA_TYPE
(
count
)
;
}
}
;
template
<
typename
PFP
,
typename
T
>
class
FunctorAverageOnSphereBorder
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
typedef
typename
PFP
::
VEC3
VEC3
;
protected:
const
AttributeHandler
<
T
>&
attr
;
const
AttributeHandler
<
VEC3
>&
position
;
VEC3
center
;
typename
PFP
::
REAL
radius
;
T
sum
;
unsigned
int
count
;
public:
FunctorAverageOnSphereBorder
(
typename
PFP
::
MAP
&
map
,
const
AttributeHandler
<
T
>&
a
,
const
AttributeHandler
<
VEC3
>&
p
,
VEC3
&
c
=
VEC3
(
0
),
typename
PFP
::
REAL
r
=
0
)
:
FunctorMap
<
typename
PFP
::
MAP
>
(
map
),
attr
(
a
),
position
(
p
),
center
(
c
),
radius
(
r
),
sum
(
0
),
count
(
0
)
{}
bool
operator
()(
Dart
d
)
{
typename
PFP
::
REAL
alpha
=
0
;
Algo
::
Geometry
::
intersectionSphereEdge
<
PFP
>
(
this
->
map
,
center
,
radius
,
d
,
position
,
alpha
);
sum
+=
(
1
-
alpha
)
*
attr
[
d
]
+
alpha
*
attr
[
this
->
map
.
phi1
(
d
)]
;
++
count
;
return
false
;
}
inline
void
reset
(
VEC3
&
c
,
typename
PFP
::
REAL
r
)
{
center
=
c
;
radius
=
r
;
sum
=
T
(
0
)
;
count
=
0
;
}
inline
T
getSum
()
{
return
sum
;
}
inline
unsigned
int
getCount
()
{
return
count
;
}
inline
T
getAverage
()
{
return
sum
/
typename
T
::
DATA_TYPE
(
count
)
;
}
}
;
...
...
include/Algo/Filtering/taubin.h
View file @
73576e31
...
...
@@ -39,13 +39,14 @@ void filterTaubin(typename PFP::MAP& map, typename PFP::TVEC3& position, typenam
{
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
)
;
FunctorAverage
<
VEC3
>
fa1
(
position
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
mv
.
isMarked
(
d
))
...
...
@@ -53,16 +54,17 @@ void filterTaubin(typename PFP::MAP& map, typename PFP::TVEC3& position, typenam
mv
.
mark
(
d
);
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
fa
1
.
reset
()
;
c
.
applyOnBorder
(
fa
1
)
;
VEC3
p
=
position
[
d
]
;
VEC3
displ
=
fa
.
getAverage
()
-
p
;
VEC3
displ
=
fa
1
.
getAverage
()
-
p
;
displ
*=
lambda
;
position2
[
d
]
=
p
+
displ
;
}
}
// unshrinking step
FunctorAverage
<
VEC3
>
fa2
(
position
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
mv
.
isMarked
(
d
))
...
...
@@ -70,10 +72,10 @@ void filterTaubin(typename PFP::MAP& map, typename PFP::TVEC3& position, typenam
mv
.
unmark
(
d
);
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
fa
2
.
reset
()
;
c
.
applyOnBorder
(
fa
2
)
;
VEC3
p
=
position2
[
d
]
;
VEC3
displ
=
fa
.
getAverage
()
-
p
;
VEC3
displ
=
fa
2
.
getAverage
()
-
p
;
displ
*=
mu
;
position
[
d
]
=
p
+
displ
;
}
...
...
@@ -84,16 +86,15 @@ void filterTaubin(typename PFP::MAP& map, typename PFP::TVEC3& position, typenam
* Taubin filter modified as proposed by [Lav09]
*/
template
<
typename
PFP
>
void
filterTaubin_modified
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
const
FunctorSelect
&
select
=
SelectorTrue
())
void
filterTaubin_modified
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
position2
,
typename
PFP
::
REAL
radius
,
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
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
c1
(
map
,
position
,
radius
)
;
CellMarkerNoUnmark
mv
(
map
,
VERTEX
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
...
...
@@ -101,30 +102,31 @@ void filterTaubin_modified(typename PFP::MAP& map, typename PFP::TVEC3& position
{
mv
.
mark
(
d
);
c
.
collectBorder
(
d
)
;
fa
.
reset
()
;
c
.
applyOnBorder
(
fa
)
;
VEC3
p
=
position
[
d
]
;
VEC3
displ
=
fa
.
getAverage
()
-
p
;
c
1
.
collectBorder
(
d
)
;
VEC3
center
=
position
[
d
]
;
FunctorAverageOnSphereBorder
<
PFP
,
typename
PFP
::
VEC3
>
fa
(
map
,
position
,
position
,
center
,
radius
)
;
c1
.
applyOnBorder
(
fa
)
;
VEC3
displ
=
fa
.
getAverage
()
-
center
;
displ
*=
lambda
;
position2
[
d
]
=
p
+
displ
;
position2
[
d
]
=
center
+
displ
;
}
}
// unshrinking step
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
c2
(
map
,
position2
,
radius
)
;
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
;
c
2
.
collectBorder
(
d
)
;
VEC3
center
=
position2
[
d
]
;
FunctorAverageOnSphereBorder
<
PFP
,
typename
PFP
::
VEC3
>
fa
(
map
,
position2
,
position2
,
center
,
radius
)
;
c2
.
applyOnBorder
(
fa
)
;
VEC3
displ
=
fa
.
getAverage
()
-
center
;
displ
*=
mu
;
position
[
d
]
=
p
+
displ
;
position
[
d
]
=
center
+
displ
;
}
}
}
...
...
include/Algo/Geometry/intersection.h
View file @
73576e31
...
...
@@ -79,8 +79,8 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Dart tri1, Dart tri2, co
/**
* alpha = coef d'interpolation dans [0 ,1] tel que v = (1-alpha)*pin + alpha*pout
* est le point d'intersection entre la sphère et le segment [pin, pout]
* avec pin = position[d
in
] à l'intérieur de la sphère
* avec pout = position[
dout
] à l'extérieur de la sphère
* avec pin = position[d] à l'intérieur de la sphère
* avec pout = position[
phi1(d)
] à l'extérieur de la sphère
*/
template
<
typename
PFP
>
bool
intersectionSphereEdge
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
VEC3
&
center
,
typename
PFP
::
REAL
radius
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
REAL
&
alpha
)
;
...
...
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