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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
72d6f882
Commit
72d6f882
authored
Nov 09, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selector in Traversor
parent
307472d9
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
469 additions
and
589 deletions
+469
-589
include/Algo/Export/export.hpp
include/Algo/Export/export.hpp
+70
-85
include/Algo/Filtering/average.h
include/Algo/Filtering/average.h
+58
-70
include/Algo/Filtering/average_normals.h
include/Algo/Filtering/average_normals.h
+233
-251
include/Algo/Filtering/bilateral.h
include/Algo/Filtering/bilateral.h
+50
-59
include/Algo/Geometry/area.hpp
include/Algo/Geometry/area.hpp
+10
-25
include/Algo/Geometry/boundingbox.h
include/Algo/Geometry/boundingbox.h
+2
-5
include/Algo/Geometry/centroid.hpp
include/Algo/Geometry/centroid.hpp
+6
-15
include/Algo/Geometry/curvature.hpp
include/Algo/Geometry/curvature.hpp
+5
-11
include/Algo/Geometry/laplacian.hpp
include/Algo/Geometry/laplacian.hpp
+6
-15
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+6
-15
include/Algo/Geometry/volume.hpp
include/Algo/Geometry/volume.hpp
+2
-5
include/Algo/Render/GL2/mapRender.hpp
include/Algo/Render/GL2/mapRender.hpp
+9
-18
include/Topology/generic/traversorCell.h
include/Topology/generic/traversorCell.h
+9
-8
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+3
-7
No files found.
include/Algo/Export/export.hpp
View file @
72d6f882
...
...
@@ -62,30 +62,27 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices
.
reserve
(
nbDarts
/
6
)
;
CellMarker
markV
(
map
,
VERTEX
)
;
TraversorF
<
MAP
>
t
(
map
)
;
TraversorF
<
MAP
>
t
(
map
,
good
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
good
(
d
))
std
::
vector
<
unsigned
int
>
fidx
;
fidx
.
reserve
(
8
)
;
unsigned
int
degree
=
0
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
{
std
::
vector
<
unsigned
int
>
fidx
;
fidx
.
reserve
(
8
)
;
unsigned
int
degree
=
0
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
++
degree
;
unsigned
int
vNum
=
map
.
getEmbedding
(
VERTEX
,
it
)
;
if
(
!
markV
.
isMarked
(
it
))
{
++
degree
;
unsigned
int
vNum
=
map
.
getEmbedding
(
VERTEX
,
it
)
;
if
(
!
markV
.
isMarked
(
it
))
{
markV
.
mark
(
it
)
;
vIndex
[
vNum
]
=
vCpt
++
;
vertices
.
push_back
(
vNum
)
;
}
fidx
.
push_back
(
vIndex
[
vNum
])
;
markV
.
mark
(
it
)
;
vIndex
[
vNum
]
=
vCpt
++
;
vertices
.
push_back
(
vNum
)
;
}
facesSize
.
push_back
(
degree
)
;
facesIdx
.
push_back
(
fidx
)
;
fidx
.
push_back
(
vIndex
[
vNum
])
;
}
facesSize
.
push_back
(
degree
)
;
facesIdx
.
push_back
(
fidx
)
;
}
out
<<
"ply"
<<
std
::
endl
;
...
...
@@ -140,30 +137,27 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices
.
reserve
(
nbDarts
/
6
)
;
CellMarker
markV
(
map
,
VERTEX
)
;
TraversorF
<
MAP
>
t
(
map
)
;
TraversorF
<
MAP
>
t
(
map
,
good
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
good
(
d
))
std
::
vector
<
unsigned
int
>
fidx
;
fidx
.
reserve
(
8
)
;
unsigned
int
degree
=
0
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
{
std
::
vector
<
unsigned
int
>
fidx
;
fidx
.
reserve
(
8
)
;
unsigned
int
degree
=
0
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
++
degree
;
unsigned
int
vNum
=
map
.
getEmbedding
(
VERTEX
,
it
)
;
if
(
!
markV
.
isMarked
(
it
))
{
++
degree
;
unsigned
int
vNum
=
map
.
getEmbedding
(
VERTEX
,
it
)
;
if
(
!
markV
.
isMarked
(
it
))
{
markV
.
mark
(
it
)
;
vIndex
[
vNum
]
=
vCpt
++
;
vertices
.
push_back
(
vNum
)
;
}
fidx
.
push_back
(
vIndex
[
vNum
])
;
markV
.
mark
(
it
)
;
vIndex
[
vNum
]
=
vCpt
++
;
vertices
.
push_back
(
vNum
)
;
}
facesSize
.
push_back
(
degree
)
;
facesIdx
.
push_back
(
fidx
)
;
fidx
.
push_back
(
vIndex
[
vNum
])
;
}
facesSize
.
push_back
(
degree
)
;
facesIdx
.
push_back
(
fidx
)
;
}
out
<<
"OFF"
<<
std
::
endl
;
...
...
@@ -201,27 +195,24 @@ bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
verticesBuffer
.
reserve
(
nbDarts
/
5
);
// TODO non optimal reservation
indicesBuffer
.
reserve
(
nbDarts
/
3
);
CellMarker
markV
(
map
,
VERTEX
);
TraversorF
<
MAP
>
t
(
map
)
;
CellMarker
markV
(
map
,
VERTEX
);
TraversorF
<
MAP
>
t
(
map
,
good
)
;
unsigned
int
lab
=
0
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
good
(
d
))
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
{
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
if
(
!
markV
.
isMarked
(
it
))
{
if
(
!
markV
.
isMarked
(
it
))
{
markV
.
mark
(
it
);
tableVertLab
[
it
]
=
lab
++
;
const
VEC3
&
vert
=
position
[
it
];
verticesBuffer
.
push_back
(
vert
[
0
]);
verticesBuffer
.
push_back
(
vert
[
1
]);
verticesBuffer
.
push_back
(
vert
[
2
]);
}
indicesBuffer
.
push_back
(
tableVertLab
[
it
]);
markV
.
mark
(
it
);
tableVertLab
[
it
]
=
lab
++
;
const
VEC3
&
vert
=
position
[
it
];
verticesBuffer
.
push_back
(
vert
[
0
]);
verticesBuffer
.
push_back
(
vert
[
1
]);
verticesBuffer
.
push_back
(
vert
[
2
]);
}
indicesBuffer
.
push_back
(
tableVertLab
[
it
]);
}
}
...
...
@@ -274,32 +265,29 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
faces
.
reserve
(
nbDarts
/
3
);
CellMarker
markV
(
map
,
VERTEX
);
TraversorF
<
MAP
>
t
(
map
)
;
TraversorF
<
MAP
>
t
(
map
,
good
)
;
unsigned
int
lab
=
0
;
unsigned
int
nbf
=
0
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
good
(
d
))
std
::
vector
<
unsigned
int
>
face
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
{
std
::
vector
<
unsigned
int
>
face
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
if
(
!
markV
.
isMarked
(
it
))
{
if
(
!
markV
.
isMarked
(
it
))
{
markV
.
mark
(
it
);
tableVertLab
[
it
]
=
lab
++
;
vertices
.
push_back
(
map
.
getEmbedding
(
VERTEX
,
it
));
}
face
.
push_back
(
tableVertLab
[
it
]);
markV
.
mark
(
it
);
tableVertLab
[
it
]
=
lab
++
;
vertices
.
push_back
(
map
.
getEmbedding
(
VERTEX
,
it
));
}
face
.
push_back
(
tableVertLab
[
it
]);
}
faces
.
push_back
(
face
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
face
.
size
()
;
++
i
)
faces
.
push_back
(
face
.
at
(
i
))
;
faces
.
push_back
(
face
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
face
.
size
()
;
++
i
)
faces
.
push_back
(
face
.
at
(
i
))
;
++
nbf
;
}
++
nbf
;
}
TVEC3
frame
[
3
]
;
...
...
@@ -415,32 +403,29 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
faces
.
reserve
(
nbDarts
/
3
);
CellMarker
markV
(
map
,
VERTEX
);
TraversorF
<
MAP
>
t
(
map
)
;
TraversorF
<
MAP
>
t
(
map
,
good
)
;
unsigned
int
lab
=
0
;
unsigned
int
nbf
=
0
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
good
(
d
))
std
::
vector
<
unsigned
int
>
face
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
{
std
::
vector
<
unsigned
int
>
face
;
Traversor2FV
<
typename
PFP
::
MAP
>
tfv
(
map
,
d
)
;
for
(
Dart
it
=
tfv
.
begin
();
it
!=
tfv
.
end
();
it
=
tfv
.
next
())
if
(
!
markV
.
isMarked
(
it
))
{
if
(
!
markV
.
isMarked
(
it
))
{
markV
.
mark
(
it
);
tableVertLab
[
it
]
=
lab
++
;
vertices
.
push_back
(
map
.
getEmbedding
(
VERTEX
,
it
));
}
face
.
push_back
(
tableVertLab
[
it
]);
markV
.
mark
(
it
);
tableVertLab
[
it
]
=
lab
++
;
vertices
.
push_back
(
map
.
getEmbedding
(
VERTEX
,
it
));
}
face
.
push_back
(
tableVertLab
[
it
]);
}
faces
.
push_back
(
face
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
face
.
size
()
;
++
i
)
faces
.
push_back
(
face
.
at
(
i
))
;
faces
.
push_back
(
face
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
face
.
size
()
;
++
i
)
faces
.
push_back
(
face
.
at
(
i
))
;
++
nbf
;
}
++
nbf
;
}
out
<<
"ply"
<<
std
::
endl
;
...
...
include/Algo/Filtering/average.h
View file @
72d6f882
...
...
@@ -48,36 +48,33 @@ void filterAverageAttribute_OneRing(
FunctorAverage
<
T
>
fa
(
attIn
)
;
Algo
::
Selection
::
Collector_OneRing
<
PFP
>
col
(
map
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
select
(
d
))
{
if
(
neigh
&
INSIDE
)
col
.
collectAll
(
d
)
;
else
col
.
collectBorder
(
d
)
;
if
(
neigh
&
INSIDE
)
col
.
collectAll
(
d
)
;
else
col
.
collectBorder
(
d
)
;
fa
.
reset
()
;
if
(
neigh
&
INSIDE
)
fa
.
reset
()
;
if
(
neigh
&
INSIDE
)
{
switch
(
attIn
.
getOrbit
())
{
switch
(
attIn
.
getOrbit
())
{
case
VERTEX
:
col
.
applyOnInsideVertices
(
fa
)
;
break
;
case
EDGE
:
col
.
applyOnInsideEdges
(
fa
)
;
break
;
case
FACE
:
col
.
applyOnInsideFaces
(
fa
)
;
break
;
}
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
()
;
}
if
(
neigh
&
BORDER
)
col
.
applyOnBorder
(
fa
)
;
attOut
[
d
]
=
fa
.
getAverage
()
;
}
}
...
...
@@ -95,29 +92,26 @@ void filterAverageVertexAttribute_WithinSphere(
FunctorAverageOnSphereBorder
<
PFP
,
T
>
faBorder
(
map
,
attIn
,
position
)
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
col
(
map
,
position
,
radius
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
select
(
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
.
getCount
()
+
faBorder
.
getCount
()
;
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
.
getCount
()
+
faBorder
.
getCount
()
;
}
}
...
...
@@ -134,21 +128,18 @@ void filterAverageEdgeAttribute_WithinSphere(
FunctorAverage
<
T
>
fa
(
attIn
)
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
col
(
map
,
position
,
radius
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
select
(
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
()
;
}
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
()
;
}
}
...
...
@@ -165,21 +156,18 @@ void filterAverageFaceAttribute_WithinSphere(
FunctorAverage
<
T
>
fa
(
attIn
)
;
Algo
::
Selection
::
Collector_WithinSphere
<
PFP
>
col
(
map
,
position
,
radius
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
select
(
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
()
;
}
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
()
;
}
}
...
...
include/Algo/Filtering/average_normals.h
View file @
72d6f882
...
...
@@ -52,28 +52,25 @@ void computeNewPositionsFromFaceNormals(
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
)
;
TraversorV
<
typename
PFP
::
MAP
>
t
(
map
,
select
)
;
for
(
Dart
d
=
t
.
begin
();
d
!=
t
.
end
();
d
=
t
.
next
())
{
if
(
select
(
d
))
{
const
VEC3
&
pos_d
=
position
[
d
]
;
const
VEC3
&
pos_d
=
position
[
d
]
;
VEC3
displ
(
0
)
;
REAL
sumAreas
=
0
;
VEC3
displ
(
0
)
;
REAL
sumAreas
=
0
;
Traversor2VF
<
typename
PFP
::
MAP
>
tvf
(
map
,
d
)
;
for
(
Dart
it
=
tvf
.
begin
();
it
!=
tvf
.
end
();
it
=
tvf
.
next
())
{
sumAreas
+=
faceArea
[
it
]
;
VEC3
vT
=
faceCentroid
[
it
]
-
pos_d
;
vT
=
(
vT
*
faceNewNormal
[
it
])
*
faceNormal
[
it
]
;
displ
+=
faceArea
[
it
]
*
vT
;
}
displ
/=
sumAreas
;
position2
[
d
]
=
pos_d
+
displ
;
Traversor2VF
<
typename
PFP
::
MAP
>
tvf
(
map
,
d
)
;
for
(
Dart
it
=
tvf
.
begin
();
it
!=
tvf
.
end
();
it
=
tvf
.
next
())
{
sumAreas
+=
faceArea
[
it
]
;
VEC3
vT
=
faceCentroid
[
it
]
-
pos_d
;
vT
=
(
vT
*
faceNewNormal
[
it
])
*
faceNormal
[
it
]
;
displ
+=
faceArea
[
it
]
*
vT
;
}
displ
/=
sumAreas
;
position2
[
d
]
=
pos_d
+
displ
;
}
}
...
...
@@ -94,28 +91,25 @@ void filterAverageNormals(typename PFP::MAP& map, const typename PFP::TVEC3& pos
AutoAttributeHandler
<
VEC3
>
faceNewNormal
(
map
,
FACE
,
"faceNewNormal"
)
;
// Compute new normals
TraversorF
<
typename
PFP
::
MAP
>
tf
(
map
)
;
TraversorF
<
typename
PFP
::
MAP
>
tf
(
map
,
select
)
;
for
(
Dart
d
=
tf
.
begin
();
d
!=
tf
.
end
();
d
=
tf
.
next
())
{
if
(
select
(
d
))
{
REAL
sumArea
=
0
;
VEC3
meanFilter
(
0
)
;
// traversal of adjacent faces (by edges and vertices)
Traversor2FFaV
<
typename
PFP
::
MAP
>
taf
(
map
,
d
)
;
for
(
Dart
it
=
taf
.
begin
();
it
!=
taf
.
end
();
it
=
taf
.
next
())
{
sumArea
+=
faceArea
[
it
]
;
meanFilter
+=
faceArea
[
it
]
*
faceNormal
[
it
]
;
}
REAL
sumArea
=
0
;
VEC3
meanFilter
(
0
)
;
// finalize the computation of meanFilter normal
meanFilter
/=
sumArea
;
meanFilter
.
normalize
()
;
// and store it
faceNewNormal
[
d
]
=
meanFilter
;
// traversal of adjacent faces (by edges and vertices)
Traversor2FFaV
<
typename
PFP
::
MAP
>
taf
(
map
,
d
)
;
for
(
Dart
it
=
taf
.
begin
();
it
!=
taf
.
end
();
it
=
taf
.
next
())
{
sumArea
+=
faceArea
[
it
]
;
meanFilter
+=
faceArea
[
it
]
*
faceNormal
[
it
]
;
}
// finalize the computation of meanFilter normal
meanFilter
/=
sumArea
;
meanFilter
.
normalize
()
;
// and store it
faceNewNormal
[
d
]
=
meanFilter
;
}
// Compute new vertices position
...
...
@@ -141,69 +135,66 @@ void filterMMSE(typename PFP::MAP& map, float sigmaN2, const typename PFP::TVEC3
AutoAttributeHandler
<
VEC3
>
faceNewNormal
(
map
,
FACE
,
"faceNewNormal"
)
;
// Compute new normals
TraversorF
<
typename
PFP
::
MAP
>
tf
(
map
)
;
TraversorF
<
typename
PFP
::
MAP
>
tf
(
map
,
select
)
;
for
(
Dart
d
=
tf
.
begin
();
d
!=
tf
.
end
();
d
=
tf
.
next
())
{
if
(
select
(
d
))
{
// traversal of neighbour vertices
REAL
sumArea
=
0
;
REAL
sigmaX2
=
0
;
REAL
sigmaY2
=
0
;
REAL
sigmaZ2
=
0
;
// traversal of neighbour vertices
REAL
sumArea
=
0
;
REAL
sigmaX2
=
0
;
REAL
sigmaY2
=
0
;
REAL
sigmaZ2
=
0
;
VEC3
meanFilter
(
0
)
;
VEC3
meanFilter
(
0
)
;
// traversal of adjacent faces (by edges and vertices)
Traversor2FFaV
<
typename
PFP
::
MAP
>
taf
(
map
,
d
)
;
for
(
Dart
it
=
taf
.
begin
();
it
!=
taf
.
end
();
it
=
taf
.
next
())
{
// get info from face embedding and sum
REAL
area
=
faceArea
[
it
]
;
sumArea
+=
area
;
VEC3
normal
=
faceNormal
[
it
]
;
meanFilter
+=
area
*
normal
;
sigmaX2
+=
area
*
normal
[
0
]
*
normal
[
0
]
;
sigmaY2
+=
area
*
normal
[
1
]
*
normal
[
1
]
;
sigmaZ2
+=
area
*
normal
[
2
]
*
normal
[
2
]
;
}
// traversal of adjacent faces (by edges and vertices)
Traversor2FFaV
<
typename
PFP
::
MAP
>
taf
(
map
,
d
)
;
for
(
Dart
it
=
taf
.
begin
();
it
!=
taf
.
end
();
it
=
taf
.
next
())
{
// get info from face embedding and sum
REAL
area
=
faceArea
[
it
]
;
sumArea
+=
area
;
VEC3
normal
=
faceNormal
[
it
]
;
meanFilter
+=
area
*
normal
;
sigmaX2
+=
area
*
normal
[
0
]
*
normal
[
0
]
;
sigmaY2
+=
area
*
normal
[
1
]
*
normal
[
1
]
;
sigmaZ2
+=
area
*
normal
[
2
]
*
normal
[
2
]
;
}
meanFilter
/=
sumArea
;
sigmaX2
/=
sumArea
;
sigmaX2
-=
meanFilter
[
0
]
*
meanFilter
[
0
]
;
sigmaY2
/=
sumArea
;
sigmaY2
-=
meanFilter
[
1
]
*
meanFilter
[
1
]
;
sigmaZ2
/=
sumArea
;
sigmaZ2
-=
meanFilter
[
2
]
*
meanFilter
[
2
]
;
meanFilter
/=
sumArea
;
sigmaX2
/=
sumArea
;
sigmaX2
-=
meanFilter
[
0
]
*
meanFilter
[
0
]
;
sigmaY2
/=
sumArea
;
sigmaY2
-=
meanFilter
[
1
]
*
meanFilter
[
1
]
;
sigmaZ2
/=
sumArea
;
sigmaZ2
-=
meanFilter
[
2
]
*
meanFilter
[
2
]
;
VEC3
&
oldNormal
=
faceNormal
[
d
]
;
VEC3
newNormal
;
VEC3
&
oldNormal
=
faceNormal
[
d
]
;
VEC3
newNormal
;
if
(
sigmaX2
<
sigmaN2
)
newNormal
[
0
]
=
meanFilter
[
0
]
;
else
{
newNormal
[
0
]
=
(
1
-
(
sigmaN2
/
sigmaX2
))
*
oldNormal
[
0
]
;
newNormal
[
0
]
+=
(
sigmaN2
/
sigmaX2
)
*
meanFilter
[
0
]
;
}
if
(
sigmaY2
<
sigmaN2
)
newNormal
[
1
]
=
meanFilter
[
1
]
;
else
{
newNormal
[
1
]
=
(
1
-
(
sigmaN2
/
sigmaY2
))
*
oldNormal
[
1
]
;
newNormal
[
1
]
+=
(
sigmaN2
/
sigmaY2
)
*
meanFilter
[
1
]
;
}
if
(
sigmaZ2
<
sigmaN2
)
newNormal
[
2
]
=
meanFilter
[
2
]
;
else
{
newNormal
[
2
]
=
(
1
-
(
sigmaN2
/
sigmaZ2
))
*
oldNormal
[
2
]
;
newNormal
[
2
]
+=
(
sigmaN2
/
sigmaZ2
)
*
meanFilter
[
2
]
;
}
newNormal
.
normalize
()
;
faceNewNormal
[
d
]
=
newNormal
;
if
(
sigmaX2
<
sigmaN2
)
newNormal
[
0
]
=
meanFilter
[
0
]
;
else
{
newNormal
[
0
]
=
(
1
-
(
sigmaN2
/
sigmaX2
))
*
oldNormal
[
0
]
;
newNormal
[
0
]
+=
(
sigmaN2
/
sigmaX2
)
*
meanFilter
[
0
]
;
}
if
(
sigmaY2
<
sigmaN2
)
newNormal
[
1
]
=
meanFilter
[
1
]
;
else
{
newNormal
[
1
]
=
(
1
-
(
sigmaN2
/
sigmaY2
))
*
oldNormal
[
1
]
;
newNormal
[
1
]
+=
(
sigmaN2
/
sigmaY2
)
*
meanFilter
[
1
]
;
}
if
(
sigmaZ2
<
sigmaN2
)
newNormal
[
2
]
=
meanFilter
[
2
]
;
else
{
newNormal
[
2
]
=
(
1
-
(
sigmaN2
/
sigmaZ2
))
*
oldNormal
[
2
]
;
newNormal
[
2
]
+=
(
sigmaN2
/
sigmaZ2
)
*
meanFilter
[
2
]
;
}
newNormal
.
normalize
()
;
faceNewNormal
[
d
]
=
newNormal
;
}
// Compute new vertices position
...
...
@@ -233,95 +224,92 @@ void filterTNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
long
nbAdapt
=
0
;
long
nbSusan
=
0
;
TraversorF
<
typename
PFP
::
MAP
>
tf
(
map
)
;
TraversorF
<
typename
PFP
::
MAP
>
tf
(
map
,
select
)
;
for
(
Dart
d
=
tf
.
begin
();
d
!=
tf
.
end
();
d
=
tf
.
next
())
{
if
(
select
(
d
))
{
const
VEC3
&
normF
=
faceNormal
[
d
]
;