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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KennethVanhoey
CGoGN
Commits
96810274
Commit
96810274
authored
Apr 03, 2013
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integ numérique des LF + corrections bug
parent
acc2e1e2
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
427 additions
and
136 deletions
+427
-136
include/Algo/Decimation/edgeSelector.h
include/Algo/Decimation/edgeSelector.h
+4
-4
include/Algo/Decimation/edgeSelector.hpp
include/Algo/Decimation/edgeSelector.hpp
+9
-2
include/Algo/Decimation/halfEdgeSelector.h
include/Algo/Decimation/halfEdgeSelector.h
+41
-25
include/Algo/Decimation/halfEdgeSelector.hpp
include/Algo/Decimation/halfEdgeSelector.hpp
+341
-103
include/Algo/Decimation/selector.h
include/Algo/Decimation/selector.h
+1
-1
include/Utils/qem.h
include/Utils/qem.h
+11
-1
include/Utils/qem.hpp
include/Utils/qem.hpp
+20
-0
No files found.
include/Algo/Decimation/edgeSelector.h
View file @
96810274
...
...
@@ -151,7 +151,7 @@ public:
void
updateWithoutCollapse
();
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
const
{
assert
(
errors
!=
NULL
||
!
"EdgeSelector::setColorMap requires non null vertexattribute argument"
)
;
if
(
!
errors
->
isValid
())
...
...
@@ -659,7 +659,7 @@ public:
void
updateWithoutCollapse
()
{
}
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
const
{
assert
(
errors
!=
NULL
||
!
"EdgeSelector::setColorMap requires non null vertexattribute argument"
)
;
if
(
!
errors
->
isValid
())
...
...
@@ -740,7 +740,7 @@ public:
void
updateWithoutCollapse
()
{
}
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
const
{
assert
(
errors
!=
NULL
||
!
"EdgeSelector::setColorMap requires non null vertexattribute argument"
)
;
if
(
!
errors
->
isValid
())
...
...
@@ -830,7 +830,7 @@ public:
void
updateWithoutCollapse
()
{
}
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
const
{
assert
(
errors
!=
NULL
||
!
"EdgeSelector::setColorMap requires non null vertexattribute argument"
)
;
if
(
!
errors
->
isValid
())
...
...
include/Algo/Decimation/edgeSelector.hpp
View file @
96810274
...
...
@@ -2183,6 +2183,7 @@ EdgeSelector_GeomColOptGradient<PFP>::computeHalfEdgeGradientColorError(const Da
const VEC3& c0 = m_color[v0] ;
VEC3 count ;
REAL areaSum = 0 ;
for (Dart fi = tf.begin() ; fi != tf.end() ; fi = tf.next()) // foreach "blue" face
{
// get the data
...
...
@@ -2199,6 +2200,8 @@ EdgeSelector_GeomColOptGradient<PFP>::computeHalfEdgeGradientColorError(const Da
//const VEC3 e0 = Pj - Pi ;
const VEC3 d = P - P0 ; // displacement vector
areaSum += (ei ^ ej).norm() / REAL(2) ;
// per-channel treatment
for (unsigned int i = 0 ; i < 3 ; ++i)
{
...
...
@@ -2215,12 +2218,16 @@ EdgeSelector_GeomColOptGradient<PFP>::computeHalfEdgeGradientColorError(const Da
const REAL displacementE = (0.5*(ei ^ ej).norm()) * fabs(d*grad) ; // area x <disp,grad>
// color change error for channel i
const REAL colChangeE = fabs(c[i]-c0[i]) * (ei ^ ej).norm() / REAL(2) ;
//
const REAL colChangeE = fabs(c[i]-c0[i]) * (ei ^ ej).norm() / REAL(2) ;
count[i] += displacementE
+ colChangeE
;
count[i] += displacementE ;
}
}
const VEC3 colDiff = c - c0 ;
for (unsigned int i = 0 ; i < 3 ; ++i)
count[i] += fabs(colDiff[i]) * areaSum ;
return count ;
}
...
...
include/Algo/Decimation/halfEdgeSelector.h
View file @
96810274
...
...
@@ -26,6 +26,7 @@
#define __HALFEDGESELECTOR_H__
#include "Algo/Decimation/selector.h"
#include "Utils/SphericalFunctionIntegratorCartesian.h"
namespace CGoGN
{
...
...
@@ -156,7 +157,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -251,7 +252,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -348,7 +349,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -420,8 +421,8 @@ private:
void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo) ;
void recomputeQuadric(const Dart d, const bool recomputeNeighbors = false) ;
REAL computeLightfieldError(Dart v0) ;
REAL computeSquaredLightfieldDifference(Dart d1, Dart d2) ;
REAL computeLightfieldError(Dart v0)
const
;
REAL computeSquaredLightfieldDifference(Dart d1, Dart d2)
const
;
public:
HalfEdgeSelector_LightfieldKCL(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
...
...
@@ -456,7 +457,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -520,7 +521,7 @@ private:
//void recomputeQuadric(const Dart d, const bool recomputeNeighbors = false) ;
void recomputeQuadric(const Dart d) ;
typename PFP::VEC3 computeExperimentalColorError(const Dart& v0, const Dart& v1) ;
typename PFP::VEC3 computeExperimentalColorError(const Dart& v0, const Dart& v1)
const
;
public:
...
...
@@ -547,7 +548,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -611,7 +612,7 @@ private:
//void recomputeQuadric(const Dart d, const bool recomputeNeighbors = false) ;
void recomputeQuadric(const Dart d) ;
typename PFP::VEC3 computeGradientColorError(const Dart& v0, const Dart& v1) ;
typename PFP::VEC3 computeGradientColorError(const Dart& v0, const Dart& v1)
const
;
public:
...
...
@@ -638,7 +639,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -709,8 +710,8 @@ private:
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) ;
REAL computeLightfieldError(const Dart& v0, const Dart& v1)
const
;
REAL computeSquaredLightfieldDifference(const Dart& d1, const Dart& d2)
const
;
public:
HalfEdgeSelector_LFexperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
...
...
@@ -744,7 +745,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -771,7 +772,7 @@ public:
} ;
/*****************************************************************************************************************
* HALF-EDGE LF
EXPERIMENTAL METRIC
*
* HALF-EDGE LF
GRADIENT METRIC
*
*****************************************************************************************************************/
template <typename PFP>
class HalfEdgeSelector_LFgradient : public EdgeSelector<PFP>
...
...
@@ -794,7 +795,6 @@ private:
VertexAttribute<Utils::Quadric<REAL> > m_quadric ;
VertexAttribute<REAL> m_visualImportance ;
VertexAttribute<VEC3> m_avgColor ;
int m_approxindex_pos, m_attrindex_pos ;
...
...
@@ -804,6 +804,10 @@ private:
std::vector<unsigned int> m_approxindex_HF, m_attrindex_HF ;
unsigned int m_K ;
SphericalFunctionIntegratorCartesian m_integrator ;
double *m_n ;
double *m_workspace ;
std::vector<Approximator<PFP, typename PFP::VEC3,DART>* > m_approx ;
std::multimap<float,Dart> halfEdges ;
...
...
@@ -814,8 +818,15 @@ private:
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) ;
VEC3 computeGradientLFerror(const Dart& v0, const Dart& v1) const ;
VEC3 computeSquaredLightfieldDifferenceAnalytical(const Dart& d1, const Dart& d2) const ;
VEC3 computeSquaredLightfieldDifferenceNumerical(const Dart& d1, const Dart& d2) const ;
VEC3 computeGradient(const VEC3& P0, const VEC3& Pi, const VEC3& Pj, const Dart& v0, const Dart& v1, const Dart& vi, const Dart& vj, unsigned int channel) const ;
REAL computeIntegral(const double *avgi, const VEC3& ti, const VEC3& bi, const VEC3& ni, unsigned int nbCoefs, const std::vector<double>& coefs) const ;
static bool isInDomain(double x, double y, double z, void *data) ;
static double CartesianFunction (double x, double y, double z, void* data) ;
static double SquaredDifferenceOfCartesianFunctions (double x, double y, double z, void* data) ;
public:
HalfEdgeSelector_LFgradient(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
...
...
@@ -828,20 +839,26 @@ public:
m_attrindex_FB(-1),
m_approxindex_FN(-1),
m_attrindex_FN(-1),
m_K(0)
m_K(0),
m_n(NULL),
m_workspace(NULL)
{
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") ;
m_n = new double[3] ;
assert(m_avgColor.isValid()) ;
}
~HalfEdgeSelector_LFgradient()
{
this->m_map.removeAttribute(m_quadric) ;
this->m_map.removeAttribute(halfEdgeInfo) ;
m_integrator.Release() ;
delete[] m_workspace ;
delete[] m_n ;
}
SelectorType getType() { return S_hLF
experimental
; }
SelectorType getType() { return S_hLF
gradient
; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
...
...
@@ -849,7 +866,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"HalfEdgeSelector_LFgradient::getEdgeErrors requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -875,7 +892,6 @@ public:
}
} ;
/*****************************************************************************************************************
* HALF-EDGE COLOR PER FACE *
*****************************************************************************************************************/
...
...
@@ -939,7 +955,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
@@ -1009,8 +1025,8 @@ private:
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) ;
REAL computeLightfieldError(const Dart& v0, const Dart& v1)
const
;
REAL computeSquaredLightfieldDifference(const Dart& d1, const Dart& d2)
const
;
public:
HalfEdgeSelector_LFperFace(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
...
...
@@ -1044,7 +1060,7 @@ public:
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
const
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
...
...
include/Algo/Decimation/halfEdgeSelector.hpp
View file @
96810274
This diff is collapsed.
Click to expand it.
include/Algo/Decimation/selector.h
View file @
96810274
...
...
@@ -96,7 +96,7 @@ public:
virtual
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
=
0
;
virtual
void
updateWithoutCollapse
()
=
0
;
virtual
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
virtual
void
getEdgeErrors
(
EdgeAttribute
<
typename
PFP
::
REAL
>
*
errors
)
const
{
std
::
cout
<<
"WARNING:: getEdgeErrors was not overridden"
<<
std
::
endl
;
}
...
...
include/Utils/qem.h
View file @
96810274
...
...
@@ -501,6 +501,16 @@ public:
*/
REAL
operator
()
(
const
std
::
vector
<
VEC3
>&
coefs
)
const
;
/*!
* \brief method to evaluate the error for a given lightfield function
*
* \param coefs the given function
*
* \return the squared error per color channel
*/
VEC3
evalR3
(
const
std
::
vector
<
VEC3
>&
coefs
)
const
;
/*!
* \brief Write to stream operator
*
...
...
@@ -591,7 +601,7 @@ private:
*
* \param coefs the given function
*
* \return the
error
* \return the
norm of the squared error per color channel
*/
REAL
evaluate
(
const
std
::
vector
<
VEC3
>&
coefs
)
const
;
...
...
include/Utils/qem.hpp
View file @
96810274
...
...
@@ -517,6 +517,26 @@ QuadricHF<REAL>::evaluate(const std::vector<VEC3>& coefs) const
return (res[0] + res[1] + res[2]) / 3. ;
}
template <typename REAL>
typename QuadricHF<REAL>::VEC3
QuadricHF<REAL>::evalR3(const std::vector<VEC3>& coefs) const
{
VEC3 res ;
for (unsigned int c = 0 ; c < 3 ; ++c)
{
Eigen::VectorXd tmp(coefs.size()) ;
for (unsigned int i = 0 ; i < coefs.size() ; ++i)
tmp[i] = coefs[i][c] ;
res[c] = tmp.transpose() * m_A * tmp ; // A
res[c] -= 2. * (m_b[c]).transpose() * tmp ; // - 2b
res[c] += m_c[c] ; // + c
}
res /= 2*M_PI ; // max integral value over hemisphere
return res ;
}
template <typename REAL>
Geom::Matrix33d
QuadricHF<REAL>::buildRotateMatrix(const REAL& gamma)
...
...
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