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
Thomas Pitiot
CGoGN
Commits
3a3ca21f
Commit
3a3ca21f
authored
Jan 29, 2013
by
Kenneth Vanhoey
Browse files
implemented decimation with experimental color and lf crit
parent
42e522b2
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
include/Algo/Decimation/decimation.hpp
View file @
3a3ca21f
...
...
@@ -196,6 +196,12 @@ void decimate(
case
S_hLightfieldKCL
:
selector
=
new
HalfEdgeSelector_LightfieldKCL
<
PFP
>
(
map
,
position
,
approximators
,
selected
)
;
break
;
case
S_hColorExperimental
:
selector
=
new
HalfEdgeSelector_ColorExperimental
<
PFP
>
(
map
,
position
,
approximators
,
selected
)
;
break
;
case
S_hLFexperimental
:
selector
=
new
HalfEdgeSelector_LFexperimental
<
PFP
>
(
map
,
position
,
approximators
,
selected
)
;
break
;
}
for
(
typename
std
::
vector
<
ApproximatorGen
<
PFP
>*>::
iterator
it
=
approximators
.
begin
();
it
!=
approximators
.
end
();
++
it
)
...
...
@@ -213,9 +219,6 @@ void decimate(
return
;
}
if
(
edgeErrors
!=
NULL
)
selector
->
getEdgeErrors
(
edgeErrors
)
;
unsigned
int
nbVertices
=
map
.
template
getNbOrbits
<
VERTEX
>()
;
bool
finished
=
false
;
Dart
d
;
...
...
@@ -257,6 +260,9 @@ void decimate(
callback_wrapper
(
callback_object
,
&
nbVertices
)
;
}
if
(
edgeErrors
!=
NULL
)
selector
->
getEdgeErrors
(
edgeErrors
)
;
delete
selector
;
for
(
typename
std
::
vector
<
ApproximatorGen
<
PFP
>*>::
iterator
it
=
approximators
.
begin
();
it
!=
approximators
.
end
();
++
it
)
...
...
include/Algo/Decimation/halfEdgeSelector.h
View file @
3a3ca21f
...
...
@@ -466,7 +466,7 @@ public:
(
*
errors
)[
d
]
=
halfEdgeInfo
[
d
].
it
->
first
;
}
Dart
dd
=
this
->
m_map
.
phi2
(
d
)
;
if
(
halfEdgeInfo
[
dd
].
valid
&&
halfEdgeInfo
[
dd
].
it
->
first
>
(
*
errors
)[
d
])
if
(
halfEdgeInfo
[
dd
].
valid
&&
halfEdgeInfo
[
dd
].
it
->
first
<
(
*
errors
)[
d
])
{
(
*
errors
)[
dd
]
=
halfEdgeInfo
[
dd
].
it
->
first
;
}
...
...
@@ -475,10 +475,202 @@ public:
}
}
;
/*****************************************************************************************************************
* HALF-EDGE COLOR EXPERIMENTAL *
*****************************************************************************************************************/
template
<
typename
PFP
>
class
HalfEdgeSelector_ColorExperimental
:
public
EdgeSelector
<
PFP
>
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
private:
typedef
struct
{
typename
std
::
multimap
<
float
,
Dart
>::
iterator
it
;
bool
valid
;
static
std
::
string
CGoGNnameOfType
()
{
return
"ColorExperimentalHalfEdgeInfo"
;
}
}
QEMextColorHalfEdgeInfo
;
typedef
NoMathIOAttribute
<
QEMextColorHalfEdgeInfo
>
HalfEdgeInfo
;
DartAttribute
<
HalfEdgeInfo
>
halfEdgeInfo
;
VertexAttribute
<
Utils
::
Quadric
<
REAL
>
>
m_quadric
;
VertexAttribute
<
VEC3
>
m_pos
,
m_color
;
int
m_approxindex_pos
,
m_attrindex_pos
;
int
m_approxindex_color
,
m_attrindex_color
;
std
::
vector
<
Approximator
<
PFP
,
typename
PFP
::
VEC3
,
DART
>*
>
m_approx
;
std
::
multimap
<
float
,
Dart
>
halfEdges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
void
initHalfEdgeInfo
(
Dart
d
)
;
void
updateHalfEdgeInfo
(
Dart
d
)
;
void
computeHalfEdgeInfo
(
Dart
d
,
HalfEdgeInfo
&
einfo
)
;
//void recomputeQuadric(const Dart d, const bool recomputeNeighbors = false) ;
void
recomputeQuadric
(
const
Dart
d
)
;
typename
PFP
::
REAL
computeExperimentalColorError
(
const
Dart
&
v0
,
const
Dart
&
v1
)
;
public:
HalfEdgeSelector_ColorExperimental
(
MAP
&
m
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
allDarts
)
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
),
m_approxindex_pos
(
-
1
),
m_attrindex_pos
(
-
1
),
m_approxindex_color
(
-
1
),
m_attrindex_color
(
-
1
)
{
halfEdgeInfo
=
m
.
template
addAttribute
<
HalfEdgeInfo
,
DART
>(
"halfEdgeInfo"
)
;
m_quadric
=
m
.
template
addAttribute
<
Utils
::
Quadric
<
REAL
>,
VERTEX
>
(
"QEMquadric"
)
;
}
~
HalfEdgeSelector_ColorExperimental
()
{
this
->
m_map
.
removeAttribute
(
m_quadric
)
;
this
->
m_map
.
removeAttribute
(
halfEdgeInfo
)
;
}
SelectorType
getType
()
{
return
S_hColorExperimental
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
void
updateWithoutCollapse
()
{
}
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
{
assert
(
errors
!=
NULL
||
!
"EdgeSelector::setColorMap requires non null vertexattribute argument"
)
;
if
(
!
errors
->
isValid
())
std
::
cerr
<<
"EdgeSelector::setColorMap requires valid edgeattribute argument"
<<
std
::
endl
;
assert
(
halfEdgeInfo
.
isValid
())
;
TraversorE
<
typename
PFP
::
MAP
>
travE
(
this
->
m_map
)
;
for
(
Dart
d
=
travE
.
begin
()
;
d
!=
travE
.
end
()
;
d
=
travE
.
next
())
{
(
*
errors
)[
d
]
=
-
1
;
if
(
halfEdgeInfo
[
d
].
valid
)
{
(
*
errors
)[
d
]
=
halfEdgeInfo
[
d
].
it
->
first
;
}
Dart
dd
=
this
->
m_map
.
phi2
(
d
)
;
if
(
halfEdgeInfo
[
dd
].
valid
&&
halfEdgeInfo
[
dd
].
it
->
first
<
(
*
errors
)[
d
])
{
(
*
errors
)[
d
]
=
halfEdgeInfo
[
dd
].
it
->
first
;
}
}
}
}
;
/*****************************************************************************************************************
* HALF-EDGE LF EXPERIMENTAL METRIC *
*****************************************************************************************************************/
template
<
typename
PFP
>
class
HalfEdgeSelector_LFexperimental
:
public
EdgeSelector
<
PFP
>
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
private:
typedef
struct
{
typename
std
::
multimap
<
float
,
Dart
>::
iterator
it
;
bool
valid
;
static
std
::
string
CGoGNnameOfType
()
{
return
"LightfieldExpHalfEdgeInfo"
;
}
}
LightfieldHalfEdgeInfo
;
typedef
NoMathIOAttribute
<
LightfieldHalfEdgeInfo
>
HalfEdgeInfo
;
DartAttribute
<
HalfEdgeInfo
>
halfEdgeInfo
;
VertexAttribute
<
Utils
::
Quadric
<
REAL
>
>
m_quadric
;
VertexAttribute
<
REAL
>
m_visualImportance
;
VertexAttribute
<
VEC3
>
m_avgColor
;
int
m_approxindex_pos
,
m_attrindex_pos
;
int
m_approxindex_FT
,
m_attrindex_FT
;
int
m_approxindex_FB
,
m_attrindex_FB
;
int
m_approxindex_FN
,
m_attrindex_FN
;
std
::
vector
<
unsigned
int
>
m_approxindex_HF
,
m_attrindex_HF
;
unsigned
int
m_K
;
std
::
vector
<
Approximator
<
PFP
,
typename
PFP
::
VEC3
,
DART
>*
>
m_approx
;
std
::
multimap
<
float
,
Dart
>
halfEdges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
void
initHalfEdgeInfo
(
Dart
d
)
;
void
updateHalfEdgeInfo
(
Dart
d
)
;
void
computeHalfEdgeInfo
(
Dart
d
,
HalfEdgeInfo
&
einfo
)
;
void
recomputeQuadric
(
const
Dart
d
)
;
REAL
computeLightfieldError
(
const
Dart
&
v0
,
const
Dart
&
v1
)
;
REAL
computeSquaredLightfieldDifference
(
const
Dart
&
d1
,
const
Dart
&
d2
)
;
public:
HalfEdgeSelector_LFexperimental
(
MAP
&
m
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
allDarts
)
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
),
m_approxindex_pos
(
-
1
),
m_attrindex_pos
(
-
1
),
m_approxindex_FT
(
-
1
),
m_attrindex_FT
(
-
1
),
m_approxindex_FB
(
-
1
),
m_attrindex_FB
(
-
1
),
m_approxindex_FN
(
-
1
),
m_attrindex_FN
(
-
1
),
m_K
(
0
)
{
halfEdgeInfo
=
m
.
template
addAttribute
<
HalfEdgeInfo
,
DART
>(
"halfEdgeInfo"
)
;
m_quadric
=
m
.
template
addAttribute
<
Utils
::
Quadric
<
REAL
>,
VERTEX
>
(
"QEMquadric"
)
;
m_avgColor
=
m
.
template
getAttribute
<
typename
PFP
::
VEC3
,
VERTEX
>(
"color"
)
;
assert
(
m_avgColor
.
isValid
())
;
}
~
HalfEdgeSelector_LFexperimental
()
{
this
->
m_map
.
removeAttribute
(
m_quadric
)
;
this
->
m_map
.
removeAttribute
(
halfEdgeInfo
)
;
}
SelectorType
getType
()
{
return
S_hLFexperimental
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
void
updateWithoutCollapse
()
{
}
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
{
assert
(
errors
!=
NULL
||
!
"EdgeSelector::setColorMap requires non null vertexattribute argument"
)
;
if
(
!
errors
->
isValid
())
std
::
cerr
<<
"EdgeSelector::setColorMap requires valid edgeattribute argument"
<<
std
::
endl
;
assert
(
halfEdgeInfo
.
isValid
())
;
TraversorE
<
typename
PFP
::
MAP
>
travE
(
this
->
m_map
)
;
for
(
Dart
d
=
travE
.
begin
()
;
d
!=
travE
.
end
()
;
d
=
travE
.
next
())
{
(
*
errors
)[
d
]
=
-
1
;
if
(
halfEdgeInfo
[
d
].
valid
)
{
(
*
errors
)[
d
]
=
halfEdgeInfo
[
d
].
it
->
first
;
}
Dart
dd
=
this
->
m_map
.
phi2
(
d
)
;
if
(
halfEdgeInfo
[
dd
].
valid
&&
halfEdgeInfo
[
dd
].
it
->
first
<
(
*
errors
)[
d
])
{
(
*
errors
)[
d
]
=
halfEdgeInfo
[
dd
].
it
->
first
;
}
}
}
}
;
}
// namespace Decimation
}
}
// namespace Surface
}
// namespace Algo
...
...
include/Algo/Decimation/halfEdgeSelector.hpp
View file @
3a3ca21f
This diff is collapsed.
Click to expand it.
include/Algo/Decimation/selector.h
View file @
3a3ca21f
...
...
@@ -56,7 +56,9 @@ enum SelectorType
S_hQEMml
,
S_hLightfield
,
S_hLightfieldExp
,
S_hLightfieldKCL
S_hLightfieldKCL
,
S_hColorExperimental
,
S_hLFexperimental
}
;
template
<
typename
PFP
>
class
ApproximatorGen
;
...
...
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