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
2504d16e
Commit
2504d16e
authored
Sep 07, 2012
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change approximators for having a vector of attributes to approximate
parent
2aa9ef9a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
162 additions
and
91 deletions
+162
-91
include/Algo/Decimation/approximator.h
include/Algo/Decimation/approximator.h
+95
-37
include/Algo/Decimation/geometryApproximator.h
include/Algo/Decimation/geometryApproximator.h
+20
-10
include/Algo/Decimation/geometryApproximator.hpp
include/Algo/Decimation/geometryApproximator.hpp
+28
-28
include/Algo/Decimation/geometryPredictor.hpp
include/Algo/Decimation/geometryPredictor.hpp
+6
-6
include/Algo/ProgressiveMesh/pmesh.hpp
include/Algo/ProgressiveMesh/pmesh.hpp
+13
-10
No files found.
include/Algo/Decimation/approximator.h
View file @
2504d16e
...
...
@@ -46,7 +46,8 @@ enum ApproximatorType
A_TangentPredict1
,
A_TangentPredict2
,
A_LightfieldHalf
,
A_LightfieldFull
A_LightfieldHalf_deprecated
,
A_LightfieldFull_deprecated
}
;
template
<
typename
PFP
>
...
...
@@ -65,7 +66,8 @@ public:
{}
virtual
~
ApproximatorGen
()
{}
virtual
const
std
::
string
&
getApproximatedAttributeName
()
const
=
0
;
virtual
const
std
::
string
&
getApproximatedAttributeName
(
unsigned
int
index
=
0
)
const
=
0
;
virtual
std
::
vector
<
std
::
string
>
getApproximatedAttributeNames
()
const
=
0
;
virtual
ApproximatorType
getType
()
const
=
0
;
virtual
bool
init
()
=
0
;
virtual
void
approximate
(
Dart
d
)
=
0
;
...
...
@@ -87,52 +89,84 @@ public:
protected:
Predictor
<
PFP
,
T
>*
m_predictor
;
VertexAttribute
<
T
>&
m_attrV
;
// vertex attribute
to be approximated
EdgeAttribute
<
T
>
m_approx
;
// attribute
to store approximation result
EdgeAttribute
<
T
>
m_detail
;
// attribute
to store detail information for reconstruction
T
m_app
;
std
::
vector
<
VertexAttribute
<
T
>*
>
m_attrV
;
// vertex attributes
to be approximated
std
::
vector
<
EdgeAttribute
<
T
>
>
m_approx
;
// attributes
to store approximation result
std
::
vector
<
EdgeAttribute
<
T
>
>
m_detail
;
// attributes
to store detail information for reconstruction
std
::
vector
<
T
>
m_app
;
public:
Approximator
(
MAP
&
m
,
VertexAttribute
<
T
>&
a
,
Predictor
<
PFP
,
T
>
*
predictor
)
:
ApproximatorGen
<
PFP
>
(
m
),
m_predictor
(
predictor
),
m_attrV
(
a
)
Approximator
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
T
>*
>
va
,
Predictor
<
PFP
,
T
>
*
predictor
)
:
ApproximatorGen
<
PFP
>
(
m
),
m_predictor
(
predictor
),
m_attrV
(
v
a
)
{
std
::
stringstream
aname
;
aname
<<
"approx_"
<<
m_attrV
.
name
()
;
m_approx
=
this
->
m_map
.
template
addAttribute
<
T
,
EDGE
>(
aname
.
str
())
;
if
(
m_predictor
)
// if a predictor is associated to the approximator
{
// create an attribute to store the detail needed for reconstruction
std
::
stringstream
dname
;
dname
<<
"detail_"
<<
m_attrV
.
name
()
;
m_detail
=
this
->
m_map
.
template
addAttribute
<
T
,
EDGE
>(
dname
.
str
())
;
m_approx
.
resize
(
m_attrV
.
size
())
;
m_detail
.
resize
(
m_attrV
.
size
())
;
m_app
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
std
::
stringstream
aname
;
aname
<<
"approx_"
<<
m_attrV
[
i
]
->
name
()
;
m_approx
[
i
]
=
this
->
m_map
.
template
addAttribute
<
T
,
EDGE
>(
aname
.
str
())
;
if
(
m_predictor
)
// if predictors are associated to the approximator
{
// create attributes to store the details needed for reconstruction
std
::
stringstream
dname
;
dname
<<
"detail_"
<<
m_attrV
[
i
]
->
name
()
;
m_detail
[
i
]
=
this
->
m_map
.
template
addAttribute
<
T
,
EDGE
>(
dname
.
str
())
;
}
}
}
virtual
~
Approximator
()
{
this
->
m_map
.
template
removeAttribute
(
m_approx
)
;
if
(
m_predictor
)
this
->
m_map
.
template
removeAttribute
(
m_detail
)
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
this
->
m_map
.
template
removeAttribute
(
m_approx
[
i
])
;
if
(
m_predictor
)
this
->
m_map
.
template
removeAttribute
(
m_detail
[
i
])
;
}
}
const
std
::
string
&
getApproximatedAttributeName
(
unsigned
int
index
=
0
)
const
{
return
m_attrV
[
index
]
->
name
()
;
}
const
std
::
string
&
getApproximatedAttributeName
()
const
std
::
vector
<
std
::
string
>
getApproximatedAttributeNames
()
const
{
return
m_attrV
.
name
()
;
std
::
vector
<
std
::
string
>
names
;
names
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
names
[
i
]
=
m_attrV
[
i
]
->
name
()
;
return
names
;
}
void
saveApprox
(
Dart
d
)
{
m_app
=
m_approx
[
d
]
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
m_app
[
i
]
=
m_approx
[
i
][
d
]
;
}
void
affectApprox
(
Dart
d
)
{
m_attrV
[
d
]
=
m_app
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
m_attrV
[
i
]
->
operator
[](
d
)
=
m_app
[
i
]
;
}
const
T
&
getApprox
(
Dart
d
)
const
const
T
&
getApprox
(
Dart
d
,
unsigned
int
index
=
0
)
const
{
return
m_approx
[
d
]
;
return
m_approx
[
index
][
d
]
;
}
std
::
vector
<
T
>
getAllApprox
(
Dart
d
)
const
{
std
::
vector
<
T
>
res
;
res
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
res
[
i
]
=
m_approx
[
i
][
d
]
;
return
res
;
}
const
Predictor
<
PFP
,
T
>*
getPredictor
()
const
...
...
@@ -140,18 +174,38 @@ public:
return
m_predictor
;
}
const
T
&
getDetail
(
Dart
d
)
const
const
T
&
getDetail
(
Dart
d
,
unsigned
int
index
=
0
)
const
{
assert
(
m_predictor
||
!
"Trying to get detail on a non-predictive scheme"
)
;
return
m_detail
[
index
][
d
]
;
}
std
::
vector
<
T
>
getAllDetail
(
Dart
d
)
const
{
assert
(
m_predictor
||
!
"Trying to get detail on a non-predictive scheme"
)
;
return
m_detail
[
d
]
;
std
::
vector
<
T
>
res
;
res
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
res
[
i
]
=
m_detail
[
i
][
d
]
;
return
res
;
}
void
setDetail
(
Dart
d
,
T
&
val
)
void
setDetail
(
Dart
d
,
unsigned
int
index
,
T
&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
m_detail
[
d
]
=
val
;
m_detail
[
index
][
d
]
=
val
;
}
void
setDetail
(
Dart
d
,
std
::
vector
<
T
>&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
m_detail
[
index
][
d
]
=
val
[
i
]
;
}
// // TODO works only for vector types !!
// REAL detailMagnitude(Dart d)
// {
...
...
@@ -162,13 +216,17 @@ public:
void
addDetail
(
Dart
d
,
double
amount
,
bool
sign
,
typename
PFP
::
MATRIX33
*
detailTransform
)
{
assert
(
m_predictor
||
!
"Trying to add detail on a non-predictive scheme"
)
;
T
det
=
m_detail
[
d
]
;
if
(
detailTransform
)
det
=
(
*
detailTransform
)
*
det
;
det
*=
amount
;
if
(
!
sign
)
det
*=
REAL
(
-
1
)
;
m_attrV
[
d
]
+=
det
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
T
det
=
m_detail
[
i
][
d
]
;
if
(
detailTransform
)
det
=
(
*
detailTransform
)
*
det
;
det
*=
amount
;
if
(
!
sign
)
det
*=
REAL
(
-
1
)
;
m_attrV
[
i
]
->
operator
[](
d
)
+=
det
;
}
}
}
;
...
...
include/Algo/Decimation/geometryApproximator.h
View file @
2504d16e
...
...
@@ -48,9 +48,11 @@ protected:
VertexAttribute
<
Quadric
<
REAL
>
>
m_quadric
;
public:
Approximator_QEM
(
MAP
&
m
,
VertexAttribute
<
VEC3
>&
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator_QEM
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
VEC3
>*
>
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
VEC3
>
(
m
,
pos
,
pred
)
{}
{
assert
(
pos
.
size
()
>
0
||
!
"Approximator_QEM: attribute vector is empty"
)
;
}
~
Approximator_QEM
()
{}
ApproximatorType
getType
()
const
{
return
A_QEM
;
}
...
...
@@ -70,9 +72,11 @@ protected:
VertexAttribute
<
Quadric
<
REAL
>
>
m_quadric
;
public:
Approximator_QEMhalfEdge
(
MAP
&
m
,
VertexAttribute
<
VEC3
>&
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator_QEMhalfEdge
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
VEC3
>*
>
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
VEC3
>
(
m
,
pos
,
pred
)
{}
{
assert
(
pos
.
size
()
>
0
||
!
"Approximator_QEMhalfEdge: attribute vector is empty"
)
;
}
~
Approximator_QEMhalfEdge
()
{}
ApproximatorType
getType
()
const
{
return
A_QEMhalfEdge
;
}
...
...
@@ -88,9 +92,11 @@ public:
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
Approximator_MidEdge
(
MAP
&
m
,
VertexAttribute
<
VEC3
>&
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator_MidEdge
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
VEC3
>*
>
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
VEC3
>
(
m
,
pos
,
pred
)
{}
{
assert
(
pos
.
size
()
>
0
||
!
"Approximator_MidEdge: attribute vector is empty"
)
;
}
~
Approximator_MidEdge
()
{}
ApproximatorType
getType
()
const
{
return
A_MidEdge
;
}
...
...
@@ -106,9 +112,11 @@ public:
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
Approximator_HalfCollapse
(
MAP
&
m
,
VertexAttribute
<
VEC3
>&
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator_HalfCollapse
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
VEC3
>*
>
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
VEC3
>
(
m
,
pos
,
pred
)
{}
{
assert
(
pos
.
size
()
>
0
||
!
"Approximator_HalfCollapse: attribute vector is empty"
)
;
}
~
Approximator_HalfCollapse
()
{}
ApproximatorType
getType
()
const
{
return
A_HalfCollapse
;
}
...
...
@@ -124,9 +132,11 @@ public:
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
Approximator_CornerCutting
(
MAP
&
m
,
VertexAttribute
<
VEC3
>&
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator_CornerCutting
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
VEC3
>*
>
pos
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
VEC3
>
(
m
,
pos
,
pred
)
{}
{
assert
(
pos
.
size
()
>
0
||
!
"Approximator_CornerCutting: attribute vector is empty"
)
;
}
~
Approximator_CornerCutting
()
{}
ApproximatorType
getType
()
const
{
return
A_CornerCutting
;
}
...
...
include/Algo/Decimation/geometryApproximator.hpp
View file @
2504d16e
...
...
@@ -62,7 +62,7 @@ void Approximator_QEM<PFP>::approximate(Dart d)
Dart
it
=
d
;
do
{
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
it
],
this
->
m_attrV
[
m
.
phi1
(
it
)],
this
->
m_attrV
[
m
.
phi_1
(
it
)]
)
;
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
0
]
->
operator
[](
it
),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
)),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi_1
(
it
))
)
;
q1
+=
q
;
it
=
m
.
phi2_1
(
it
)
;
}
while
(
it
!=
d
)
;
...
...
@@ -71,7 +71,7 @@ void Approximator_QEM<PFP>::approximate(Dart d)
it
=
dd
;
do
{
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
it
],
this
->
m_attrV
[
m
.
phi1
(
it
)],
this
->
m_attrV
[
m
.
phi_1
(
it
)]
)
;
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
0
]
->
operator
[](
it
),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
)),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi_1
(
it
))
)
;
q2
+=
q
;
it
=
m
.
phi2_1
(
it
)
;
}
while
(
it
!=
dd
)
;
...
...
@@ -90,19 +90,19 @@ void Approximator_QEM<PFP>::approximate(Dart d)
bool
opt
=
quad
.
findOptimizedPos
(
res
)
;
// try to compute an optimized position for the contraction of this edge
if
(
!
opt
)
{
VEC3
p1
=
this
->
m_attrV
[
d
]
;
// let the new vertex lie
VEC3
p2
=
this
->
m_attrV
[
dd
]
;
// on either one of the two endpoints
VEC3
p1
=
this
->
m_attrV
[
0
]
->
operator
[](
d
)
;
// let the new vertex lie
VEC3
p2
=
this
->
m_attrV
[
0
]
->
operator
[](
dd
)
;
// on either one of the two endpoints
VEC3
p12
=
(
p1
+
p2
)
/
2.0
f
;
// or the middle of the edge
REAL
e1
=
quad
(
p1
)
;
REAL
e2
=
quad
(
p2
)
;
REAL
e12
=
quad
(
p12
)
;
REAL
minerr
=
std
::
min
(
std
::
min
(
e1
,
e2
),
e12
)
;
// consider only the one for
if
(
minerr
==
e12
)
this
->
m_approx
[
d
]
=
p12
;
// which the error is minimal
else
if
(
minerr
==
e1
)
this
->
m_approx
[
d
]
=
p1
;
else
this
->
m_approx
[
d
]
=
p2
;
if
(
minerr
==
e12
)
this
->
m_approx
[
0
][
d
]
=
p12
;
// which the error is minimal
else
if
(
minerr
==
e1
)
this
->
m_approx
[
0
][
d
]
=
p1
;
else
this
->
m_approx
[
0
][
d
]
=
p2
;
}
else
this
->
m_approx
[
d
]
=
res
;
this
->
m_approx
[
0
][
d
]
=
res
;
}
/************************************************************************************
...
...
@@ -136,7 +136,7 @@ void Approximator_QEMhalfEdge<PFP>::approximate(Dart d)
Dart
it
=
d
;
do
{
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
it
],
this
->
m_attrV
[
m
.
phi1
(
it
)],
this
->
m_attrV
[
m
.
phi_1
(
it
)]
)
;
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
0
]
->
operator
[](
it
),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
)),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi_1
(
it
))
)
;
q1
+=
q
;
it
=
m
.
phi2_1
(
it
)
;
}
while
(
it
!=
d
)
;
...
...
@@ -145,7 +145,7 @@ void Approximator_QEMhalfEdge<PFP>::approximate(Dart d)
it
=
dd
;
do
{
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
it
],
this
->
m_attrV
[
m
.
phi1
(
it
)],
this
->
m_attrV
[
m
.
phi_1
(
it
)]
)
;
Quadric
<
REAL
>
q
(
this
->
m_attrV
[
0
]
->
operator
[](
it
),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
)),
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi_1
(
it
))
)
;
q2
+=
q
;
it
=
m
.
phi2_1
(
it
)
;
}
while
(
it
!=
dd
)
;
...
...
@@ -163,9 +163,9 @@ void Approximator_QEMhalfEdge<PFP>::approximate(Dart d)
VEC3
res
;
bool
opt
=
quad
.
findOptimizedPos
(
res
)
;
// try to compute an optimized position for the contraction of this edge
if
(
!
opt
)
this
->
m_approx
[
d
]
=
this
->
m_attrV
[
d
]
;
this
->
m_approx
[
0
][
d
]
=
this
->
m_attrV
[
0
]
->
operator
[](
d
)
;
else
this
->
m_approx
[
d
]
=
res
;
this
->
m_approx
[
0
][
d
]
=
res
;
}
/************************************************************************************
...
...
@@ -195,11 +195,11 @@ void Approximator_MidEdge<PFP>::approximate(Dart d)
Dart
dd
=
m
.
phi2
(
d
)
;
// get the contracted edge vertices positions
VEC3
v1
=
this
->
m_attrV
[
d
]
;
VEC3
v2
=
this
->
m_attrV
[
dd
]
;
VEC3
v1
=
this
->
m_attrV
[
0
]
->
operator
[](
d
)
;
VEC3
v2
=
this
->
m_attrV
[
0
]
->
operator
[](
dd
)
;
// Compute the approximated position
this
->
m_approx
[
d
]
=
(
v1
+
v2
)
/
REAL
(
2
)
;
this
->
m_approx
[
0
][
d
]
=
(
v1
+
v2
)
/
REAL
(
2
)
;
if
(
this
->
m_predictor
)
{
...
...
@@ -207,16 +207,16 @@ void Approximator_MidEdge<PFP>::approximate(Dart d)
Dart
d2
=
m
.
phi2
(
m
.
phi_1
(
d
))
;
Dart
dd2
=
m
.
phi2
(
m
.
phi_1
(
dd
))
;
// VEC3 v2 = this->m_attrV[
dd]
;
// VEC3 v2 = this->m_attrV[
0]->operator[](dd)
;
// temporary edge collapse
m
.
extractTrianglePair
(
d
)
;
unsigned
int
newV
=
m
.
template
embedNewCell
<
VERTEX
>(
d2
)
;
this
->
m_attrV
[
newV
]
=
this
->
m_approx
[
d
]
;
this
->
m_attrV
[
0
]
->
operator
[](
newV
)
=
this
->
m_approx
[
0
]
[
d
]
;
// compute the detail vector
this
->
m_predictor
->
predict
(
d2
,
dd2
)
;
this
->
m_detail
[
d
]
=
v1
-
this
->
m_predictor
->
getPredict
(
0
)
;
this
->
m_detail
[
0
][
d
]
=
v1
-
this
->
m_predictor
->
getPredict
(
0
)
;
// vertex split to reset the initial connectivity and embeddings
m
.
insertTrianglePair
(
d
,
d2
,
dd2
)
;
...
...
@@ -247,7 +247,7 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d)
{
MAP
&
m
=
this
->
m_map
;
this
->
m_approx
[
d
]
=
this
->
m_attrV
[
d
]
;
this
->
m_approx
[
0
][
d
]
=
this
->
m_attrV
[
0
]
->
operator
[](
d
)
;
if
(
this
->
m_predictor
)
{
...
...
@@ -255,16 +255,16 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d)
Dart
d2
=
m
.
phi2
(
m
.
phi_1
(
d
))
;
Dart
dd2
=
m
.
phi2
(
m
.
phi_1
(
dd
))
;
VEC3
v2
=
this
->
m_attrV
[
dd
]
;
VEC3
v2
=
this
->
m_attrV
[
0
]
->
operator
[](
dd
)
;
// temporary edge collapse
m
.
extractTrianglePair
(
d
)
;
unsigned
int
newV
=
m
.
template
embedNewCell
<
VERTEX
>(
d2
)
;
this
->
m_attrV
[
newV
]
=
this
->
m_approx
[
d
]
;
this
->
m_attrV
[
0
]
->
operator
[](
newV
)
=
this
->
m_approx
[
0
]
[
d
]
;
// compute the detail vector
this
->
m_predictor
->
predict
(
d2
,
dd2
)
;
this
->
m_detail
[
d
]
=
v2
-
this
->
m_predictor
->
getPredict
(
1
)
;
this
->
m_detail
[
0
][
d
]
=
v2
-
this
->
m_predictor
->
getPredict
(
1
)
;
// vertex split to reset the initial connectivity and embeddings
m
.
insertTrianglePair
(
d
,
d2
,
dd2
)
;
...
...
@@ -303,8 +303,8 @@ void Approximator_CornerCutting<PFP>::approximate(Dart d)
Dart
dd2
=
m
.
phi2
(
m
.
phi_1
(
dd
))
;
// get the contracted edge vertices positions
VEC3
v1
=
this
->
m_attrV
[
d
]
;
VEC3
v2
=
this
->
m_attrV
[
dd
]
;
VEC3
v1
=
this
->
m_attrV
[
0
]
->
operator
[](
d
)
;
VEC3
v2
=
this
->
m_attrV
[
0
]
->
operator
[](
dd
)
;
// compute the alpha value according to vertices valences
REAL
k1
=
0
;
...
...
@@ -329,7 +329,7 @@ void Approximator_CornerCutting<PFP>::approximate(Dart d)
it
=
d2
;
do
{
m1
+=
this
->
m_attrV
[
m
.
phi1
(
it
)]
;
m1
+=
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
))
;
it
=
m
.
phi2_1
(
it
)
;
++
count
;
}
while
(
it
!=
d
)
;
...
...
@@ -341,7 +341,7 @@ void Approximator_CornerCutting<PFP>::approximate(Dart d)
it
=
dd2
;
do
{
m2
+=
this
->
m_attrV
[
m
.
phi1
(
it
)]
;
m2
+=
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
))
;
it
=
m
.
phi2_1
(
it
)
;
++
count
;
}
while
(
it
!=
dd
)
;
...
...
@@ -353,11 +353,11 @@ void Approximator_CornerCutting<PFP>::approximate(Dart d)
VEC3
a2
=
(
REAL
(
1
)
/
(
REAL
(
1
)
-
alpha
)
)
*
(
v2
-
(
alpha
*
m2
)
)
;
// Compute the final approximated position
this
->
m_approx
[
d
]
=
(
a1
+
a2
)
/
REAL
(
2
)
;
this
->
m_approx
[
0
][
d
]
=
(
a1
+
a2
)
/
REAL
(
2
)
;
if
(
this
->
m_predictor
)
{
this
->
m_detail
[
d
]
=
(
REAL
(
1
)
-
alpha
)
*
(
(
a1
-
a2
)
/
REAL
(
2
)
)
;
this
->
m_detail
[
0
][
d
]
=
(
REAL
(
1
)
-
alpha
)
*
(
(
a1
-
a2
)
/
REAL
(
2
)
)
;
}
}
...
...
include/Algo/Decimation/geometryPredictor.hpp
View file @
2504d16e
...
...
@@ -43,8 +43,8 @@ void Predictor_HalfCollapse<PFP>::predict(Dart d2, Dart dd2)
this
->
m_predict
.
clear
()
;
// get some darts
Dart
d1
=
m
.
phi2
(
d2
)
;
Dart
dd1
=
m
.
phi2
(
dd2
)
;
//
Dart d1 = m.phi2(d2) ;
//
Dart dd1 = m.phi2(dd2) ;
REAL
k2
=
REAL
(
1
)
;
VEC3
s2_1
(
0
)
;
...
...
@@ -75,8 +75,8 @@ typename PFP::REAL Predictor_CornerCutting<PFP>::autoAlpha(Dart d2, Dart dd2)
MAP
&
m
=
this
->
m_map
;
// get some darts
Dart
d1
=
m
.
phi2
(
d2
)
;
Dart
dd1
=
m
.
phi2
(
dd2
)
;
//
Dart d1 = m.phi2(d2) ;
//
Dart dd1 = m.phi2(dd2) ;
REAL
k1
=
2
;
// compute the alpha
REAL
k2
=
2
;
// value according to
...
...
@@ -102,8 +102,8 @@ void Predictor_CornerCutting<PFP>::predict(Dart d2, Dart dd2)
this
->
m_predict
.
clear
()
;
// get some darts
Dart
d1
=
m
.
phi2
(
d2
)
;
Dart
dd1
=
m
.
phi2
(
dd2
)
;
//
Dart d1 = m.phi2(d2) ;
//
Dart dd1 = m.phi2(dd2) ;
REAL
alpha
=
autoAlpha
(
d2
,
dd2
)
;
...
...
include/Algo/ProgressiveMesh/pmesh.hpp
View file @
2504d16e
...
...
@@ -42,33 +42,36 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
m_map
(
map
),
positionsTable
(
position
),
inactiveMarker
(
inactive
),
dartSelect
(
inactiveMarker
)
{
CGoGNout
<<
" creating approximator and predictor.."
<<
CGoGNflush
;
std
::
vector
<
VertexAttribute
<
typename
PFP
::
VEC3
>*
>
pos_v
;
pos_v
.
push_back
(
&
positionsTable
)
;
switch
(
a
)
{
case
Algo
::
Decimation
::
A_QEM
:
{
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_QEM
<
PFP
>
(
m_map
,
pos
itionsTable
))
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_QEM
<
PFP
>
(
m_map
,
pos
_v
))
;
break
;
}
case
Algo
::
Decimation
::
A_MidEdge
:
{
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_MidEdge
<
PFP
>
(
m_map
,
pos
itionsTable
))
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_MidEdge
<
PFP
>
(
m_map
,
pos
_v
))
;
break
;
}
case
Algo
::
Decimation
::
A_HalfCollapse
:
{
Algo
::
Decimation
::
Predictor_HalfCollapse
<
PFP
>*
pred
=
new
Algo
::
Decimation
::
Predictor_HalfCollapse
<
PFP
>
(
m_map
,
positionsTable
)
;
m_predictors
.
push_back
(
pred
)
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_HalfCollapse
<
PFP
>
(
m_map
,
pos
itionsTable
,
pred
))
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_HalfCollapse
<
PFP
>
(
m_map
,
pos
_v
,
pred
))
;
break
;
}
case
Algo
::
Decimation
::
A_CornerCutting
:
{
Algo
::
Decimation
::
Predictor_CornerCutting
<
PFP
>*
pred
=
new
Algo
::
Decimation
::
Predictor_CornerCutting
<
PFP
>
(
m_map
,
positionsTable
)
;
m_predictors
.
push_back
(
pred
)
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_CornerCutting
<
PFP
>
(
m_map
,
pos
itionsTable
,
pred
))
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_CornerCutting
<
PFP
>
(
m_map
,
pos
_v
,
pred
))
;
break
;
}
case
Algo
::
Decimation
::
A_TangentPredict1
:
{
Algo
::
Decimation
::
Predictor_TangentPredict1
<
PFP
>*
pred
=
new
Algo
::
Decimation
::
Predictor_TangentPredict1
<
PFP
>
(
m_map
,
positionsTable
)
;
m_predictors
.
push_back
(
pred
)
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_MidEdge
<
PFP
>
(
m_map
,
pos
itionsTable
,
pred
))
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_MidEdge
<
PFP
>
(
m_map
,
pos
_v
,
pred
))
;
break
;
}
case
Algo
::
Decimation
::
A_TangentPredict2
:
{
Algo
::
Decimation
::
Predictor_TangentPredict2
<
PFP
>*
pred
=
new
Algo
::
Decimation
::
Predictor_TangentPredict2
<
PFP
>
(
m_map
,
positionsTable
)
;
m_predictors
.
push_back
(
pred
)
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_MidEdge
<
PFP
>
(
m_map
,
pos
itionsTable
,
pred
))
;
m_approximators
.
push_back
(
new
Algo
::
Decimation
::
Approximator_MidEdge
<
PFP
>
(
m_map
,
pos
_v
,
pred
))
;
break
;
}
}
CGoGNout
<<
"..done"
<<
CGoGNendl
;
...
...
@@ -230,8 +233,8 @@ void ProgressiveMesh<PFP>::coarsen()
VSplit
<
PFP
>*
vs
=
m_splits
[
m_cur
]
;
// get the split node
++
m_cur
;
Dart
d
=
vs
->
getEdge
()
;
Dart
dd
=
m_map
.
phi2
(
d
)
;
// get some darts
//
Dart d = vs->getEdge() ;
//
Dart dd = m_map.phi2(d) ; // get some darts
Dart
d2
=
vs
->
getLeftEdge
()
;
Dart
dd2
=
vs
->
getRightEdge
()
;
...
...
@@ -429,7 +432,7 @@ void ProgressiveMesh<PFP>::initQuantization()
gotoLevel
(
nbSplits
())
;
originalDetailVectors
.
resize
(
m_splits
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_splits
.
size
();
++
i
)
originalDetailVectors
[
i
]
=
m_positionApproximator
->
getDetail
(
m_splits
[
i
]
->
getEdge
())
;
originalDetailVectors
[
i
]
=
m_positionApproximator
->
getDetail
(
m_splits
[
i
]
->
getEdge
()
,
0
)
;
q
=
new
Quantization
<
VEC3
>
(
originalDetailVectors
)
;
quantizationInitialized
=
true
;
CGoGNout
<<
" Differential Entropy -> "
<<
q
->
getDifferentialEntropy
()
<<
CGoGNendl
;
...
...
@@ -446,7 +449,7 @@ void ProgressiveMesh<PFP>::quantizeDetailVectors(unsigned int nbClasses)
std
::
vector
<
VEC3
>
resultat
;
q
->
vectorQuantizationNbRegions
(
nbClasses
,
resultat
)
;
for
(
unsigned
int
i
=
0
;
i
<
m_splits
.
size
();
++
i
)
m_positionApproximator
->
setDetail
(
m_splits
[
i
]
->
getEdge
(),
resultat
[
i
])
;
m_positionApproximator
->
setDetail
(
m_splits
[
i
]
->
getEdge
(),
0
,
resultat
[
i
])
;
quantizationApplied
=
true
;
gotoLevel
(
0
)
;
CGoGNout
<<
"Discrete Entropy -> "
<<
q
->
getDiscreteEntropy
()
<<
" (codebook size : "
<<
q
->
getNbCodeVectors
()
<<
")"
<<
CGoGNendl
;
...
...
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