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
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
ab4545fa
Commit
ab4545fa
authored
Feb 15, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn:~vanhoey/CGoGN
parents
bac3af1b
277688bd
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1407 additions
and
85 deletions
+1407
-85
include/Algo/Decimation/decimation.hpp
include/Algo/Decimation/decimation.hpp
+9
-3
include/Algo/Decimation/halfEdgeSelector.h
include/Algo/Decimation/halfEdgeSelector.h
+194
-2
include/Algo/Decimation/halfEdgeSelector.hpp
include/Algo/Decimation/halfEdgeSelector.hpp
+864
-5
include/Algo/Decimation/selector.h
include/Algo/Decimation/selector.h
+3
-1
include/Geometry/plane_3d.h
include/Geometry/plane_3d.h
+2
-0
include/Utils/colourConverter.h
include/Utils/colourConverter.h
+33
-5
include/Utils/colourConverter.hpp
include/Utils/colourConverter.hpp
+302
-69
No files found.
include/Algo/Decimation/decimation.hpp
View file @
ab4545fa
...
...
@@ -196,6 +196,12 @@ void decimate(
case
S_hLightfieldKCL
:
selector
=
new
HalfEdgeSelector_LightfieldKCL
<
PFP
>
(
map
,
position
,
approximators
)
;
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 @
ab4545fa
...
...
@@ -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 @
ab4545fa
...
...
@@ -1710,19 +1710,19 @@ typename PFP::REAL HalfEdgeSelector_LightfieldKCL<PFP>::computeLightfieldError(D
err += computeSquaredLightfieldDifference(v1,vi) ;
}
}
return err ;
*/
return err ;
*/
// return computeSquaredLightfieldDifference(v0,v1) ;
Traversor2VVaE
<
MAP
>
tv
(
this
->
m_map
,
v1
)
;
// all vertices surrounding vertex v0
for
(
Dart
vi
=
tv
.
begin
()
;
vi
!=
tv
.
end
()
;
vi
=
tv
.
next
())
{
VEC3
edgeL
=
this
->
m_position
[
v1
]
-
this
->
m_position
[
vi
]
;
err
+=
sqrt
(
computeSquaredLightfieldDifference
(
v1
,
vi
))
;
//
* edgeL.norm() ;
err
+=
sqrt
(
computeSquaredLightfieldDifference
(
v1
,
vi
))
*
edgeL
.
norm
()
;
//std::cout << "1 : " << edgeL.norm() << std::endl ;
edgeL
=
this
->
m_position
[
v0
]
-
this
->
m_position
[
vi
]
;
//std::cout << "2 : " << edgeL.norm() << std::endl ;
err
-=
sqrt
(
computeSquaredLightfieldDifference
(
v0
,
vi
))
;
//
* edgeL.norm() ;
err
-=
sqrt
(
computeSquaredLightfieldDifference
(
v0
,
vi
))
*
edgeL
.
norm
()
;
}
return
fabs
(
err
)
;
}
...
...
@@ -1791,12 +1791,871 @@ typename PFP::REAL HalfEdgeSelector_LightfieldKCL<PFP>::computeSquaredLightfield
}
/************************************************************************************
* COLOR EXPERIMENTAL *
************************************************************************************/
template
<
typename
PFP
>
bool
HalfEdgeSelector_ColorExperimental
<
PFP
>::
init
()
{
MAP
&
m
=
this
->
m_map
;
}
// namespace Decimation
// Verify availability of required approximators
unsigned
int
ok
=
0
;
for
(
unsigned
int
approxindex
=
0
;
approxindex
<
this
->
m_approximators
.
size
()
;
++
approxindex
)
{
assert
(
this
->
m_approximators
[
approxindex
]
->
getType
()
==
A_hQEM
||
this
->
m_approximators
[
approxindex
]
->
getType
()
==
A_hHalfCollapse
||
!
"Approximator for selector (HalfEdgeSelector_ColorExperimental) must be of a half-edge approximator"
)
;
bool
saved
=
false
;
for
(
unsigned
int
attrindex
=
0
;
attrindex
<
this
->
m_approximators
[
approxindex
]
->
getNbApproximated
()
;
++
attrindex
)
{
// constraint : 2 approximators in specific order
if
(
ok
==
0
&&
this
->
m_approximators
[
approxindex
]
->
getApproximatedAttributeName
(
attrindex
)
==
"position"
)
{
++
ok
;
m_approxindex_pos
=
approxindex
;
m_attrindex_pos
=
attrindex
;
m_pos
=
this
->
m_position
;
if
(
!
saved
)
{
m_approx
.
push_back
(
reinterpret_cast
<
Approximator
<
PFP
,
VEC3
,
DART
>*
>
(
this
->
m_approximators
[
approxindex
]))
;
saved
=
true
;
}
}
else
if
(
ok
==
1
&&
this
->
m_approximators
[
approxindex
]
->
getApproximatedAttributeName
(
attrindex
)
==
"color"
)
{
++
ok
;
m_approxindex_color
=
approxindex
;
m_attrindex_color
=
attrindex
;
m_color
=
m
.
template
getAttribute
<
typename
PFP
::
VEC3
,
VERTEX
>(
"color"
)
;
assert
(
m_color
.
isValid
()
||
!
"EdgeSelector_QEMextColor: color attribute is not valid"
)
;
if
(
!
saved
)
{
m_approx
.
push_back
(
reinterpret_cast
<
Approximator
<
PFP
,
VEC3
,
DART
>*
>
(
this
->
m_approximators
[
approxindex
]))
;
saved
=
true
;
}
}
}
}
if
(
ok
!=
2
)
return
false
;
CellMarker
<
VERTEX
>
vMark
(
m
)
;
for
(
Dart
d
=
m
.
begin
();
d
!=
m
.
end
();
m
.
next
(
d
))
{
if
(
!
vMark
.
isMarked
(
d
))
{
Utils
::
Quadric
<
REAL
>
q
;
// create one quadric
m_quadric
[
d
]
=
q
;
// per vertex
vMark
.
mark
(
d
)
;
}
}
DartMarker
mark
(
m
)
;
for
(
Dart
d
=
m
.
begin
();
d
!=
m
.
end
();
m
.
next
(
d
))
{
if
(
!
mark
.
isMarked
(
d
))
{
Dart
d1
=
m
.
phi1
(
d
)
;
// for each triangle,
Dart
d_1
=
m
.
phi_1
(
d
)
;
// initialize the quadric of the triangle
Utils
::
Quadric
<
REAL
>
q
(
this
->
m_position
[
d
],
this
->
m_position
[
d1
],
this
->
m_position
[
d_1
])
;
m_quadric
[
d
]
+=
q
;
// and add the contribution of
m_quadric
[
d1
]
+=
q
;
// this quadric to the ones
m_quadric
[
d_1
]
+=
q
;
// of the 3 incident vertices
mark
.
markOrbit
<
FACE
>
(
d
)
;
}
}
// Init multimap for each Half-edge
halfEdges
.
clear
()
;
for
(
Dart
d
=
m
.
begin
();
d
!=
m
.
end
();
m
.
next
(
d
))
{
initHalfEdgeInfo
(
d
)
;
// init the edges with their optimal info
}
// and insert them in the multimap according to their error
cur
=
halfEdges
.
begin
()
;
// init the current edge to the first one
return
true
;
}
template
<
typename
PFP
>
bool
HalfEdgeSelector_ColorExperimental
<
PFP
>::
nextEdge
(
Dart
&
d
)
{
if
(
cur
==
halfEdges
.
end
()
||
halfEdges
.
empty
())
return
false
;
d
=
(
*
cur
).
second
;
return
true
;
}
template
<
typename
PFP
>
void
HalfEdgeSelector_ColorExperimental
<
PFP
>::
updateBeforeCollapse
(
Dart
d
)
{
MAP
&
m
=
this
->
m_map
;
const
Dart
&
v0
=
m
.
phi1
(
d
)
;
Traversor2VVaE
<
MAP
>
tv
(
m
,
v0
)
;
for
(
Dart
v
=
tv
.
begin
()
;
v
!=
tv
.
end
()
;
v
=
tv
.
next
())
{
Traversor2VE
<
MAP
>
te
(
m
,
v
)
;
for
(
Dart
he
=
te
.
begin
()
;
he
!=
te
.
end
()
;
he
=
te
.
next
())
{
HalfEdgeInfo
*
edgeE
=
&
(
halfEdgeInfo
[
he
])
;
if
(
edgeE
->
valid
)
{
edgeE
->
valid
=
false
;
halfEdges
.
erase
(
edgeE
->
it
)
;
}
Dart
de
=
m
.
phi2
(
he
)
;
edgeE
=
&
(
halfEdgeInfo
[
de
])
;
if
(
edgeE
->
valid
)
{
edgeE
->
valid
=
false
;
halfEdges
.
erase
(
edgeE
->
it
)
;
}
}
}
// HalfEdgeInfo* edgeE = &(halfEdgeInfo[d]) ;
// if(edgeE->valid)
// halfEdges.erase(edgeE->it) ;
//
// edgeE = &(halfEdgeInfo[m.phi1(d)]) ;
// if(edgeE->valid) // remove all
// halfEdges.erase(edgeE->it) ;
//
// edgeE = &(halfEdgeInfo[m.phi_1(d)]) ; // the halfedges that will disappear
// if(edgeE->valid)
// halfEdges.erase(edgeE->it) ;
// // from the multimap
// Dart dd = m.phi2(d) ;
// assert(dd != d) ;
// if(dd != d)
// {
// edgeE = &(halfEdgeInfo[dd]) ;
// if(edgeE->valid)
// halfEdges.erase(edgeE->it) ;
//
// edgeE = &(halfEdgeInfo[m.phi1(dd)]) ;
// if(edgeE->valid)
// halfEdges.erase(edgeE->it) ;
//
// edgeE = &(halfEdgeInfo[m.phi_1(dd)]) ;
// if(edgeE->valid)
// halfEdges.erase(edgeE->it) ;
// }
}
/**
* Update quadric of a vertex
* Discards quadrics of d and assigns freshly calculated
* quadrics depending on the actual planes surrounding d
* @param dart d
*/
template
<
typename
PFP
>
void
HalfEdgeSelector_ColorExperimental
<
PFP
>::
recomputeQuadric
(
const
Dart
d
)
{
Dart
dFront
,
dBack
;
Dart
dInit
=
d
;
// Init Front
dFront
=
dInit
;
m_quadric
[
d
].
zero
()
;
do
{
// Make step
dBack
=
this
->
m_map
.
phi1
(
dFront
)
;
dFront
=
this
->
m_map
.
phi2_1
(
dFront
)
;
if
(
this
->
m_map
.
phi2
(
dFront
)
!=
dFront
)
{
// if dFront is no border
m_quadric
[
d
]
+=
Utils
::
Quadric
<
REAL
>
(
this
->
m_position
[
d
],
this
->
m_position
[
dBack
],
this
->
m_position
[
this
->
m_map
.
phi1
(
dFront
)])
;
}
}
while
(
dFront
!=
dInit
)
;
}
///**
// * Update quadric of a vertex
// * Discards quadrics of d and assigns freshly calculated
// * quadrics depending on the actual planes surrounding d
// * @param dart d
// */
//template <typename PFP>
//void HalfEdgeSelector_ColorExperimental<PFP>::recomputeQuadric(const Dart d, const bool recomputeNeighbors)
//{
// Dart dFront,dBack ;
// Dart dInit = d ;
//
// // Init Front
// dFront = dInit ;
//
// m_quadric[d].zero() ;
//
// do {
// // Make step
// dBack = this->m_map.phi1(dFront) ;
// dFront = this->m_map.phi2_1(dFront) ;
//
// if (this->m_map.phi2(dFront) != dFront) { // if dFront is no border
// m_quadric[d] += Utils::Quadric<REAL>(this->m_position[d],this->m_position[dBack],this->m_position[this->m_map.phi1(dFront)]) ;
// }
//
// if (recomputeNeighbors)
// recomputeQuadric(dBack, false) ;
//
// } while(dFront != dInit) ;
//}
template
<
typename
PFP
>
void
HalfEdgeSelector_ColorExperimental
<
PFP
>::
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
{
MAP
&
m
=
this
->
m_map
;
const
Dart
&
v1
=
d2
;
recomputeQuadric
(
v1
)
;
Traversor2VVaE
<
MAP
>
tv
(
m
,
v1
)
;
for
(
Dart
v
=
tv
.
begin
()
;
v
!=
tv
.
end
()
;
v
=
tv
.
next
())
{
recomputeQuadric
(
v
)
;
}
for
(
Dart
v
=
tv
.
begin
()
;
v
!=
tv
.
end
()
;
v
=
tv
.
next
())
{
Traversor2VE
<
MAP
>
te
(
m
,
v
)
;
for
(
Dart
e
=
te
.
begin
()
;
e
!=
te
.
end
()
;
e
=
te
.
next
())
{
updateHalfEdgeInfo
(
e
)
;
updateHalfEdgeInfo
(
m
.
phi2
(
e
))
;
}
}
// MAP& m = this->m_map ;
//
// recomputeQuadric(d2, true) ;
//
// Dart vit = d2 ;
// do
// {
// updateHalfEdgeInfo(vit, true) ;
// Dart d = m.phi2(vit) ;
// if (d != vit)
// updateHalfEdgeInfo(d, true) ;
//
// updateHalfEdgeInfo(m.phi1(vit), true) ;
// d = m.phi2(m.phi1(vit)) ;
// if (d != m.phi1(vit))
// updateHalfEdgeInfo(d, true) ;
//
// Dart stop = m.phi2(vit) ;
// assert (stop != vit) ;
// Dart vit2 = m.phi12(m.phi1(vit)) ;
// do {
// updateHalfEdgeInfo(vit2, true) ;
// d = m.phi2(vit2) ;
// if (d != vit2)
// updateHalfEdgeInfo(d, true) ;
//
// updateHalfEdgeInfo(m.phi1(vit2), false) ;
// d = m.phi2(m.phi1(vit2)) ;
// if (d != m.phi1(vit2))
// updateHalfEdgeInfo(d, false) ;
//
// vit2 = m.phi12(vit2) ;
// } while (stop != vit2) ;
// vit = m.phi2_1(vit) ;
// } while(vit != d2) ;
cur
=
halfEdges
.
begin
()
;
// set the current edge to the first one
}
template
<
typename
PFP
>
void
HalfEdgeSelector_ColorExperimental
<
PFP
>::
initHalfEdgeInfo
(
Dart
d
)
{
MAP
&
m
=
this
->
m_map
;
HalfEdgeInfo
heinfo
;
if
(
m
.
edgeCanCollapse
(
d
))
computeHalfEdgeInfo
(
d
,
heinfo
)
;
else
heinfo
.
valid
=
false
;
halfEdgeInfo
[
d
]
=
heinfo
;
}
template
<
typename
PFP
>
void
HalfEdgeSelector_ColorExperimental
<
PFP
>::
updateHalfEdgeInfo
(
Dart
d
)
{
MAP
&
m
=
this
->
m_map
;
HalfEdgeInfo
&
heinfo
=
halfEdgeInfo
[
d
]
;
if
(
!
heinfo
.
valid
&&
m
.
edgeCanCollapse
(
d
))
computeHalfEdgeInfo
(
d
,
heinfo
)
;
}
template
<
typename
PFP
>
void
HalfEdgeSelector_ColorExperimental
<
PFP
>::
computeHalfEdgeInfo
(
Dart
d
,
HalfEdgeInfo
&
heinfo
)
{
MAP
&
m
=
this
->
m_map
;
Dart
dd
=
m
.
phi1
(
d
)
;
Utils
::
Quadric
<
REAL
>
quad
;
quad
+=
m_quadric
[
d
]
;
// compute the sum of the
quad
+=
m_quadric
[
dd
]
;
// two vertices quadrics
// compute all approximated attributes
for
(
typename
std
::
vector
<
ApproximatorGen
<
PFP
>*>::
iterator
it
=
this
->
m_approximators
.
begin
()
;
it
!=
this
->
m_approximators
.
end
()
;
++
it
)
{
(
*
it
)
->
approximate
(
d
)
;
}
// Get all approximated attributes
// New position
const
VEC3
&
newPos
=
this
->
m_approx
[
m_approxindex_pos
]
->
getApprox
(
d
,
m_attrindex_pos
)
;
// get newPos
// New normal
const
VEC3
&
newColor
=
this
->
m_approx
[
m_approxindex_color
]
->
getApprox
(
d
,
m_attrindex_color
)
;
// get new color
const
Dart
&
v0
=
dd
;
const
Dart
&
v1
=
d
;
assert
(
newPos
==
m_pos
[
v1
])
;
assert
(
newColor
==
m_color
[
v1
])
;
// Compute errors
// Position
Utils
::
Quadric
<
REAL
>
quadGeom
;
quadGeom
+=