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
Etienne Schmitt
CGoGN
Commits
b636d120
Commit
b636d120
authored
Oct 02, 2012
by
untereiner
Browse files
Merge cgogn:~vanhoey/CGoGN
Conflicts: CMakeLists.txt
parents
4d0c2298
62aec045
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
README_ECLIPSE.TXT
View file @
b636d120
Pour utiliser Eclipse (testé avec la version Helios, Galileo & Indigo)
English version bellow
*** English version below ***
Pour utiliser Eclipse (testé avec la version Helios, Galileo, Indigo & Juno)
* Configurer un projet dans Eclipse :
- Faire un nouveau projet C++
- Choisir Makefile project -> Empty Project
...
...
@@ -31,8 +31,8 @@ Projet X -> Properties -> Project references : cocher le projet dont il dépend.
Afin d'éviter qu'Eclipse ne rejette les syntaxes Qt (les includes de Qt, les Q_OBJECT, les callbacks) :
- Télécharger le plugin Qt "eclipse-integration" http://qt.nokia.com/developer/eclipse-integration/
- Décompresser l'archive et copier son contenu dans le répertoire d'installation d'Eclipse (plugins et features)
- Relancer Eclipse au moins une fois avec l'option
-
-clean (relecture des répertoires locaux)
Normalement, dans Window->Preferences de Eclipse, Qt apparait dans le menu.
- Relancer Eclipse au moins une fois avec l'option
"
-clean
"
(relecture des répertoires locaux)
Normalement, dans Window
-
->
Preferences de Eclipse, Qt apparait dans le menu.
- Y ajouter le répertoire de Qt (/usr/bin sur Debian/Ubuntu) et le répertoire d'include (/usr/include/qt4).
Ensuite, pour chaque projet, ajouter les includes suivants dans Properties -> C/C++ general -> Paths and Symbols
parmi les includes de C++ :
...
...
@@ -63,7 +63,7 @@ Dans Preferences -> Shaders Preferences, on peut désormais configurer certaines
ENGLISH VERSION
=========================================================================================
To use Eclipse (tested with version Helios, Galileo
&
Indigo)
To use Eclipse (tested with version Helios, Galileo
i,
Indigo
& Juno
)
* Setting up a project in Eclipse:
- Make a new C + + project
...
...
@@ -84,18 +84,18 @@ In the project properties:
Tutorial: Build / Apps / Tutorial (compiles tutorials)
etc. ..
This add
ed to the directory of CGoGN
a .project. and .cproject files.
This add
s
a .project. and .cproject files
to the CGoGN directory
.
*
I
nter-dependencies
projects
and autocompletion
If
the
project X depends on another project, then:
*
Project i
nter-dependencies and autocompletion
If project X depends on another project, then:
Project X -> Properties -> Project references: check the project which it depends.
* Qt dependencies:
To avoid Eclipse reject
s
the Qt syntax (
the Qt
includes
the
Q_OBJECT, callbacks):
To avoid Eclipse reject
ing
the Qt syntax (includes
,
Q_OBJECT, callbacks):
- Download the Qt plugin "eclipse-integration" http://qt.nokia.com/developer/eclipse-integration/
- Unzip the archive and copy its contents into the installation directory of Eclipse (plugins and features)
- Restart Eclipse at least once with the -
clean (proofreading local directories)
Normally in Window-> Preferences of Eclipse, Qt appears in the menu.
- Restart Eclipse at least once with the
"
-clean
"
(proofreading local directories)
Normally in Window
-
-> Preferences of Eclipse, Qt appears in the menu.
- Add the Qt directory (/ usr / bin on Debian / Ubuntu) and the directory include (/ usr/include/qt4).
Then, for each project, add the following includes in Properties -> C / C + + general -> Paths and Symbols
among the C + + includes:
...
...
include/Algo/Decimation/approximator.h
View file @
b636d120
...
...
@@ -39,14 +39,17 @@ namespace Decimation
enum
ApproximatorType
{
A_QEM
,
A_QEMhalfEdge
,
A_MidEdge
,
A_HalfCollapse
,
A_CornerCutting
,
A_TangentPredict1
,
A_TangentPredict2
,
A_LightfieldHalf
,
A_LightfieldFull
A_ColorNaive
,
A_ColorQEMext
,
A_Lightfield
,
// note: the following "h" prefix means that half-edges are prioritized instead of edges.
A_hHalfCollapse
,
A_hQEM
// A_hLightfieldHalf,
}
;
template
<
typename
PFP
>
...
...
@@ -65,8 +68,10 @@ 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
unsigned
int
getNbApproximated
()
const
=
0
;
virtual
bool
init
()
=
0
;
virtual
void
approximate
(
Dart
d
)
=
0
;
virtual
void
saveApprox
(
Dart
d
)
=
0
;
...
...
@@ -87,52 +92,95 @@ 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 attribute
s
to be approximated
std
::
vector
<
EdgeAttribute
<
T
>
>
m_approx
;
// attribute
s
to store approximation result
std
::
vector
<
EdgeAttribute
<
T
>
>
m_detail
;
// attribute
s
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
>
*
>
v
a
,
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
())
;
const
unsigned
int
&
size
=
m_attrV
.
size
()
;
assert
(
size
>
0
||
!
"Approximator: no attributes provided"
)
;
m_approx
.
resize
(
size
)
;
m_detail
.
resize
(
size
)
;
m_app
.
resize
(
size
)
;
for
(
unsigned
int
i
=
0
;
i
<
size
;
++
i
)
{
if
(
!
m_attrV
[
i
]
->
isValid
())
std
::
cerr
<<
"Approximator Warning: attribute number "
<<
i
<<
" is not valid"
<<
std
::
endl
;
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
// {
// 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 ;
// }
unsigned
int
getNbApproximated
()
const
{
return
m_attrV
.
nam
e
()
;
return
m_attrV
.
siz
e
()
;
}
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
,
unsigned
int
index
=
0
)
const
{
return
m_approx
[
index
][
d
]
;
}
const
T
&
getApprox
(
Dart
d
)
const
std
::
vector
<
T
>
getA
llA
pprox
(
Dart
d
)
const
{
return
m_approx
[
d
]
;
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 +188,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
,
unsigned
int
index
,
T
&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
m_detail
[
index
][
d
]
=
val
;
}
void
setDetail
(
Dart
d
,
T
&
val
)
void
setDetail
(
Dart
d
,
std
::
vector
<
T
>
&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
m_detail
[
d
]
=
val
;
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 +230,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/colorPerVertexApproximator.h
0 → 100644
View file @
b636d120
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __COLOR_APPROXIMATOR_H__
#define __COLOR_APPROXIMATOR_H__
#include
"Algo/Decimation/approximator.h"
#include
"Topology/generic/mapBrowser.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Decimation
{
template
<
typename
PFP
>
class
Approximator_ColorNaive
:
public
Approximator
<
PFP
,
typename
PFP
::
VEC3
>
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
protected:
VertexAttribute
<
VEC3
>
m_position
;
EdgeAttribute
<
VEC3
>
m_approxposition
;
VertexAttribute
<
VEC3
>
*
m_color
;
public:
Approximator_ColorNaive
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
VEC3
>*
>&
attr
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
VEC3
>
(
m
,
attr
,
pred
)
{
m_color
=
this
->
m_attrV
[
0
]
;
}
~
Approximator_ColorNaive
()
{}
ApproximatorType
getType
()
const
{
return
A_ColorNaive
;
}
bool
init
()
{
assert
(
m_color
->
isValid
()
||
!
"Approximator_ColorNaive: the approximated attribute is not valid"
)
;
m_position
=
this
->
m_map
.
template
getAttribute
<
VEC3
,
VERTEX
>(
"position"
)
;
assert
(
m_position
.
isValid
()
||
!
"Approximator_ColorNaive::init: the position attribute is not valid"
)
;
m_approxposition
=
this
->
m_map
.
template
getAttribute
<
VEC3
,
EDGE
>(
"approx_position"
)
;
assert
(
m_approxposition
.
isValid
()
||
!
"Approximator_ColorNaive::init: the approx_position attribute is not valid"
)
;
return
m_color
->
isValid
()
&&
m_position
.
isValid
()
&&
m_approxposition
.
isValid
()
;
}
void
approximate
(
Dart
d
)
;
}
;
template
<
typename
PFP
>
class
Approximator_ColorQEMext
:
public
Approximator
<
PFP
,
typename
PFP
::
VEC3
>
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
Geom
::
Vector
<
6
,
REAL
>
VEC6
;
protected:
VertexAttribute
<
QuadricNd
<
REAL
,
6
>
>
m_quadric
;
VertexAttribute
<
VEC3
>
*
m_position
;
VertexAttribute
<
VEC3
>
*
m_color
;
public:
Approximator_ColorQEMext
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
VEC3
>*
>&
attr
,
Predictor
<
PFP
,
VEC3
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
VEC3
>
(
m
,
attr
,
pred
)
{
assert
(
attr
.
size
()
>
1
||
!
"Approximator_ColorQEMext: there are not sufficient attributes provided"
)
;
m_position
=
this
->
m_attrV
[
0
]
;
m_color
=
this
->
m_attrV
[
1
]
;
}
~
Approximator_ColorQEMext
()
{}
ApproximatorType
getType
()
const
{
return
A_ColorQEMext
;
}
bool
init
()
;
void
approximate
(
Dart
d
)
;
}
;
}
//namespace Decimation
}
//namespace Algo
}
//namespace CGoGN
#include
"Algo/Decimation/colorPerVertexApproximator.hpp"
#endif
include/Algo/Decimation/colorPerVertexApproximator.hpp
0 → 100644
View file @
b636d120
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace
CGoGN
{
namespace
Algo
{
namespace
Decimation
{
/************************************************************************************
* NAIVE COLOR METRIC *
************************************************************************************/
template
<
typename
PFP
>
void
Approximator_ColorNaive
<
PFP
>::
approximate
(
Dart
d
)
{
Dart
dd
=
this
->
m_map
.
phi1
(
d
)
;
const
VEC3
&
p1
=
m_position
.
operator
[](
d
)
;
const
VEC3
&
p2
=
m_position
.
operator
[](
dd
)
;
const
VEC3
&
p
=
m_approxposition
.
operator
[](
d
)
;
const
VEC3
&
edge
=
p2
-
p1
;
const
REAL
&
ratio
=
std
::
max
(
std
::
min
(((
p
-
p1
)
*
edge
)
/
edge
.
norm2
(),
REAL
(
1
)),
REAL
(
0
))
;
this
->
m_approx
[
0
][
d
]
=
m_color
->
operator
[](
d
)
*
ratio
+
m_color
->
operator
[](
dd
)
*
(
1
-
ratio
)
;
}
/************************************************************************************
* EXTENDED QUADRIC ERROR METRIC *
************************************************************************************/
template
<
typename
PFP
>
bool
Approximator_ColorQEMext
<
PFP
>::
init
()
{
m_quadric
=
this
->
m_map
.
template
getAttribute
<
QuadricNd
<
REAL
,
6
>,
VERTEX
>
(
"QEMext-quadric"
)
;
// Does not require to be valid (if it is not, altenatives will be used).
if
(
this
->
m_predictor
)
{
return
false
;
}
return
m_position
->
isValid
()
&&
m_color
->
isValid
()
;
}
template
<
typename
PFP
>
void
Approximator_ColorQEMext
<
PFP
>::
approximate
(
Dart
d
)
{
MAP
&
m
=
this
->
m_map
;
// get some darts
Dart
dd
=
m
.
phi2
(
d
)
;
QuadricNd
<
REAL
,
6
>
q1
,
q2
;
if
(
!
m_quadric
.
isValid
())
// if the selector is not QEM, compute local error quadrics
{
// compute the error quadric associated to v1
Dart
it
=
d
;
do
{
VEC6
p0
,
p1
,
p2
;
for
(
unsigned
int
i
=
0
;
i
<
3
;
++
i
)
{
p0
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
it
)[
i
]
;
p0
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
it
)[
i
]
;
p1
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
))[
i
]
;
p1
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
m
.
phi1
(
it
))[
i
]
;
p2
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi_1
(
it
))[
i
]
;
p2
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
m
.
phi_1
(
it
))[
i
]
;
}
QuadricNd
<
REAL
,
6
>
q
(
p0
,
p1
,
p2
)
;
q1
+=
q
;
it
=
m
.
phi2_1
(
it
)
;
}
while
(
it
!=
d
)
;
// compute the error quadric associated to v2
it
=
dd
;
do
{
VEC6
p0
,
p1
,
p2
;
for
(
unsigned
int
i
=
0
;
i
<
3
;
++
i
)
{
p0
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
it
)[
i
]
;
p0
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
it
)[
i
]
;
p1
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi1
(
it
))[
i
]
;
p1
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
m
.
phi1
(
it
))[
i
]
;
p2
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
m
.
phi_1
(
it
))[
i
]
;
p2
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
m
.
phi_1
(
it
))[
i
]
;
}
QuadricNd
<
REAL
,
6
>
q
(
p0
,
p1
,
p2
)
;
q2
+=
q
;
it
=
m
.
phi2_1
(
it
)
;
}
while
(
it
!=
dd
)
;
}
else
// if the selector is QEM, use the error quadrics computed by the selector
{
q1
=
m_quadric
[
d
]
;
q2
=
m_quadric
[
dd
]
;
}
QuadricNd
<
REAL
,
6
>
quad
;
quad
+=
q1
;
// compute the sum of the
quad
+=
q2
;
// two vertices quadrics
VEC6
res
;
bool
opt
=
quad
.
findOptimizedVec
(
res
)
;
// try to compute an optimized position for the contraction of this edge
if
(
!
opt
)
{
VEC6
p1
,
p2
;
for
(
unsigned
int
i
=
0
;
i
<
3
;
++
i
)
{
p1
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
d
)[
i
]
;
// let the new vertex lie
p1
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
d
)[
i
]
;
// on either one
p2
[
i
]
=
this
->
m_attrV
[
0
]
->
operator
[](
dd
)[
i
]
;
// of the two
p2
[
i
+
3
]
=
this
->
m_attrV
[
1
]
->
operator
[](
dd
)[
i
]
;
// endpoints
}
VEC6
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
)
res
=
p12
;
// which the error is minimal
else
if
(
minerr
==
e1
)
res
=
p1
;
else
res
=
p2
;
}
// copy res into m_approx
for
(
unsigned
int
i
=
0
;
i
<
3
;
++
i
)
{
this
->
m_approx
[
0
][
d
][
i
]
=
res
[
i
]
;
this
->
m_approx
[
1
][
d
][
i
]
=
res
[
i
+
3
]
;
}
}
}
//namespace Decimation
}
//namespace Algo
}
//namespace CGoGN
include/Algo/Decimation/decimation.h
View file @
b636d120
...
...
@@ -28,6 +28,7 @@
#include
"Algo/Decimation/edgeSelector.h"
#include
"Algo/Decimation/halfEdgeSelector.h"
#include
"Algo/Decimation/geometryApproximator.h"
#include
"Algo/Decimation/colorPerVertexApproximator.h"
#include
"Algo/Decimation/lightfieldApproximator.h"
namespace
CGoGN
...
...
@@ -44,9 +45,10 @@ void decimate(
typename
PFP
::
MAP
&
map
,
SelectorType
s
,
ApproximatorType
a
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
std
::
vector
<
VertexAttribute
<
typename
PFP
::
VEC3
>
*>
&
position
,
unsigned
int
nbWantedVertices
,
const
FunctorSelect
&
selected
=
allDarts
const
FunctorSelect
&
selected
=
allDarts
,
void
(
*
callback_wrapper
)(
void
*
,
const
void
*
)
=
NULL
,
void
*
callback_object
=
NULL
)
;