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
CGoGN
CGoGN
Commits
2a8275df
Commit
2a8275df
authored
Nov 13, 2012
by
Kenneth Vanhoey
Browse files
Temporary modification of halfEdgeSelector for merge
parent
256936a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/Algo/Decimation/halfEdgeSelector.h
View file @
2a8275df
...
...
@@ -152,6 +152,25 @@ public:
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
())
{
if
(
halfEdgeInfo
[
d
].
valid
)
{
(
*
errors
)[
d
]
=
halfEdgeInfo
[
d
].
it
->
first
;
}
else
(
*
errors
)[
d
]
=
-
1
;
}
}
}
;
/*****************************************************************************************************************
...
...
@@ -222,205 +241,31 @@ public:
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
void
updateWithoutCollapse
()
{
}
}
;
///*****************************************************************************************************************
// * HALF-EDGE LIGHTFIELD METRIC *
// *****************************************************************************************************************/
//template <typename PFP>
//class HalfEdgeSelector_Lightfield : public EdgeSelector<PFP>
//{
//public:
// typedef typename PFP::MAP MAP ;
// typedef typename PFP::VEC3 VEC3 ;
// typedef typename PFP::REAL REAL ;
//
//private:
// typedef struct
// {
// typename std::multimap<float,Dart>::iterator it ;
// bool valid ;
// static std::string CGoGNnameOfType() { return "LightfieldHalfEdgeInfo" ; }
// } QEMhalfEdgeInfo ;
// typedef NoMathIOAttribute<QEMhalfEdgeInfo> HalfEdgeInfo ;
//
// DartAttribute<HalfEdgeInfo> halfEdgeInfo ;
//
// VertexAttribute<VEC3> m_pos, m_frameT, m_frameB, m_frameN ;
// //VertexAttribute<VEC3> *m_HF ;
// int m_approxindex_pos, m_attrindex_pos ;
// int m_approxindex_FN, m_attrindex_FN ;
//
// VertexAttribute<Utils::Quadric<REAL> > m_quadricGeom ;
// VertexAttribute<Utils::QuadricHF<REAL> > m_quadricHF ;
//
// std::multimap<float,Dart> halfEdges ;
// typename std::multimap<float,Dart>::iterator cur ;
//
// std::vector<Approximator<PFP, typename PFP::VEC3>* > m_approx ;
//
// void initHalfEdgeInfo(Dart d) ;
// void updateHalfEdgeInfo(Dart d, bool recompute) ;
// void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo) ;
// void recomputeQuadric(const Dart d, const bool recomputeNeighbors = false) ;
//
//public:
// HalfEdgeSelector_Lightfield(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
// EdgeSelector<PFP>(m, pos, approx, select),
//// m_positionApproximator(NULL),
//// m_frameApproximator(NULL),
//// m_hfcoefsApproximator(NULL),
//// m_pos(NULL),
//// m_frameB(NULL),
//// m_frameN(NULL),
//// m_frameT(NULL),
// m_approxindex_pos(-1),
// m_attrindex_pos(-1),
// m_approxindex_FN(-1),
// m_attrindex_FN(-1)
// {
// halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART>("halfEdgeInfo") ;
// m_quadricGeom = m.template addAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
// m_quadricHF = m.template addAttribute<Utils::QuadricHF<REAL>, VERTEX>("HFquadric") ;
// }
// ~HalfEdgeSelector_Lightfield()
// {
// this->m_map.removeAttribute(halfEdgeInfo) ;
// this->m_map.removeAttribute(m_quadricGeom) ;
// this->m_map.removeAttribute(m_quadricHF) ;
// }
// SelectorType getType() { return S_hLightfield ; }
// bool init() ;
// bool nextEdge(Dart& d) ;
// void updateBeforeCollapse(Dart d) ;
// void updateAfterCollapse(Dart d2, Dart dd2) ;
//} ;
/*template <typename PFP>
class HalfEdgeSelector_Lightfield_deprecated : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
typedef Geom::Matrix<3,3,REAL> MATRIX33 ;
typedef Geom::Matrix<3,6,REAL> MATRIX36 ;
private:
typedef struct
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "LightfieldHalfEdgeInfo_deprecated" ; }
} LightfieldHalfEdgeInfo ;
typedef NoMathIOAttribute<LightfieldHalfEdgeInfo> HalfEdgeInfo ;
VertexAttribute<MATRIX33> m_frame ;
DartAttribute<HalfEdgeInfo> halfEdgeInfo ;
VertexAttribute<Utils::Quadric<REAL> > quadric ;
EdgeAttribute<Utils::QuadricRGBfunctions<REAL> > quadricRGBfunctions ;
std::multimap<float,Dart> halfEdges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, VEC3>* m_positionApproximator ;
Approximator<PFP, MATRIX33 >* m_frameApproximator ;
Approximator<PFP, MATRIX36 >* m_RGBfunctionsApproximator ;
void initHalfEdgeInfo(Dart d) ;
void updateHalfEdgeInfo(Dart d, bool recompute) ;
void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo) ;
void recomputeQuadric(const Dart d, const bool recomputeNeighbors) ;
public:
HalfEdgeSelector_Lightfield_deprecated(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select)
{
m_frame = m.template getAttribute<MATRIX33, VERTEX>("frame") ;
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART>("halfEdgeInfo") ;
quadric = m.template addAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
quadricRGBfunctions = m.template addAttribute<Utils::QuadricRGBfunctions<REAL>, EDGE>("quadricRGBfunctions") ;
}
~HalfEdgeSelector_Lightfield_deprecated()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(quadricRGBfunctions) ;
this->m_map.removeAttribute(halfEdgeInfo) ;
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
[
d
].
it
->
first
<
(
*
errors
)[
d
])
{
(
*
errors
)[
d
]
=
halfEdgeInfo
[
dd
].
it
->
first
;
}
}
}
SelectorType getType() { return S_hLightfield_deprecated ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
}
;
/ *
template <typename PFP>
class EdgeSelector_Lightfield : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
typedef Geom::Matrix<3,3,REAL> MATRIX33 ;
typedef MATRIX33 FRAME ;
typedef Geom::Matrix<3,6,REAL> MATRIX36 ;
typedef MATRIX36 RGBFUNCTIONS ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "LightfieldEdgeInfo" ; }
} LightfieldEdgeInfo ;
typedef NoMathIOAttribute<LightfieldEdgeInfo> EdgeInfo ;
AttributeHandler<FRAME > m_frame ;
AttributeHandler<EdgeInfo, EDGE> edgeInfo ;
AttributeHandler<Utils::Quadric<REAL>, VERTEX> quadric ;
AttributeHandler<Utils::QuadricRGBfunctions<REAL>, EDGE> quadricRGBfunctions ;
Utils::Quadric<REAL> tmpQ ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, VEC3>* m_positionApproximator ;
Approximator<PFP, FRAME >* m_frameApproximator ;
Approximator<PFP, RGBFUNCTIONS >* m_RGBfunctionsApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
public:
EdgeSelector_Lightfield(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select)
{
m_frame = m.template getAttribute<FRAME, VERTEX>("frame") ;
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
quadric = m.template addAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
quadricRGBfunctions = m.template addAttribute<Utils::QuadricRGBfunctions<REAL>, EDGE>("quadricRGBfunctions") ;
}
~EdgeSelector_Lightfield()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(quadricRGBfunctions) ;
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_Lightfield ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;*/
}
// namespace Decimation
}
// namespace Algo
...
...
include/Algo/Decimation/halfEdgeSelector.hpp
View file @
2a8275df
...
...
@@ -51,6 +51,7 @@ bool HalfEdgeSelector_QEMml<PFP>::init()
{
if
((
*
it
)
->
getApproximatedAttributeName
()
==
"position"
)
{
assert
((
*
it
)
->
getType
()
==
A_hQEM
||
(
*
it
)
->
getType
()
==
A_hHalfCollapse
||
(
*
it
)
->
getType
()
!=
A_Lightfield
||
!
"Approximator for selector (HalfEdgeSelector_QEMml) must be of a half-edge approximator"
)
;
m_positionApproximator
=
reinterpret_cast
<
Approximator
<
PFP
,
VEC3
,
DART
>*
>
(
*
it
)
;
ok
=
true
;
}
...
...
@@ -290,6 +291,11 @@ bool HalfEdgeSelector_QEMextColor<PFP>::init()
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
||
this
->
m_approximators
[
approxindex
]
->
getType
()
!=
A_Lightfield
||
!
"Approximator for selector (HalfEdgeSelector_QEMextColor) must be of a half-edge approximator"
)
;
bool
saved
=
false
;
for
(
unsigned
int
attrindex
=
0
;
attrindex
<
this
->
m_approximators
[
approxindex
]
->
getNbApproximated
()
;
++
attrindex
)
{
...
...
@@ -602,6 +608,11 @@ bool HalfEdgeSelector_Lightfield<PFP>::init()
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
||
this
->
m_approximators
[
approxindex
]
->
getType
()
!=
A_Lightfield
||
!
"Approximator for selector (HalfEdgeSelector_Lightfield) must be of a half-edge approximator"
)
;
unsigned
int
k
=
0
;
bool
saved
=
false
;
for
(
unsigned
int
attrindex
=
0
;
attrindex
<
this
->
m_approximators
[
approxindex
]
->
getNbApproximated
()
;
++
attrindex
)
...
...
@@ -934,17 +945,20 @@ void HalfEdgeSelector_Lightfield<PFP>::computeHalfEdgeInfo(Dart d, HalfEdgeInfo&
assert
(
m_quadricHF
.
isValid
()
|
!
"EdgeSelector_Lightfield<PFP>::computeEdgeInfo: quadricHF is not valid"
)
;
Utils
::
QuadricHF
<
REAL
>
quadHF
=
m_quadricHF
[
d
]
;
//std::cout << quadGeom(newPos)
<< " vs " << alpha/M_PI << " vs " <<
quadHF(newHF) << std::endl ;
//std::cout << quadGeom(newPos)
/ (alpha/M_PI +
quadHF(newHF)
)
<< std::endl ;
// sum of QEM metric and frame orientation difference
const
REAL
&
err
=
quadGeom
(
newPos
)
// geom
+
alpha
/
M_PI
// frame
+
quadHF
(
newHF
)
// function coefficients
//
quadGeom(newPos)
+
// geom
alpha
/
M_PI
+
// frame
quadHF
(
newHF
)
// function coefficients
;
// Check if errated values appear
if
(
err
<
-
1e-6
)
{
heinfo
.
valid
=
false
;
std
::
cout
<<
err
<<
std
::
endl
;
}
else
{
heinfo
.
it
=
this
->
halfEdges
.
insert
(
std
::
make_pair
(
std
::
max
(
err
,
REAL
(
0
)),
d
))
;
...
...
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