Commit d54866c0 authored by untereiner's avatar untereiner

MR filtering

parent fc45ade8
......@@ -134,7 +134,7 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute<typ
} //namespace Filtering
}
} //namespace Surface
} //namespace Algo
......
......@@ -48,55 +48,30 @@ namespace Primal
namespace Filters
{
//
// Synthesis
//
/*********************************************************************************
* ANALYSIS FILTERS
*********************************************************************************/
//w-lift(a)
template <typename PFP>
class Ber02OddSynthesisFilter : public Algo::MR::Filter
class Ber02OddAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
Ber02OddAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
{}
void operator() ()
{
TraversorF<typename PFP::MAP> travF(m_map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{
typename PFP::VEC3 vf(0.0);
typename PFP::VEC3 ef(0.0);
unsigned int count = 0;
Traversor2FE<typename PFP::MAP> travFE(m_map, d);
for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next())
{
vf += m_position[dit];
m_map.incCurrentLevel();
ef += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel();
++count;
}
ef /= count;
ef *= 4.0 * m_a;
vf /= count;
vf *= 4.0 * m_a * m_a;
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(m_map.phi1(d));
m_position[midF] += vf + ef ;
m_map.decCurrentLevel() ;
}
}
void operator() (bool filtering)
{
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
......@@ -105,13 +80,10 @@ public:
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(d) ;
m_position[midV] += ve;
m_position[midV] -= ve;
m_map.decCurrentLevel() ;
}
}
void operator() (bool filtering)
{
TraversorF<typename PFP::MAP> travF(m_map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{
......@@ -136,46 +108,15 @@ public:
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(m_map.phi1(d));
if(filtering)
{
std::cout << "sans +=" << std::endl;
m_position[midF] = vf + ef ;
}
else
{
std::cout << "avec +=" << std::endl;
m_position[midF] += vf + ef ;
}
m_map.decCurrentLevel() ;
}
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
ve *= 2.0 * m_a;
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(d) ;
if(filtering)
{
std::cout << "sans +=" << std::endl;
m_position[midV] = ve;
}
else
{
std::cout << "avec +=" << std::endl;
m_position[midV] += ve;
}
m_position[midF] -= vf + ef ;
m_map.decCurrentLevel() ;
}
}
} ;
};
// s-lift(a)
template <typename PFP>
class Ber02EvenSynthesisFilter : public Algo::MR::Filter
class Ber02EvenAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -183,50 +124,16 @@ protected:
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02EvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
Ber02EvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
{}
void operator() ()
{
TraversorV<typename PFP::MAP> travV(m_map);
for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next())
{
typename PFP::VEC3 ev(0.0);
typename PFP::VEC3 fv(0.0);
if(m_map.isBoundaryVertex(d))
{
Dart db = m_map.findBoundaryEdgeOfVertex(d);
m_map.incCurrentLevel() ;
ev += (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]) * typename PFP::REAL(0.5);
m_map.decCurrentLevel() ;
ev *= 2 * m_a;
m_position[db] += ev;
}
else
{
unsigned int count = 0;
Traversor2VF<typename PFP::MAP> travVF(m_map,d);
for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next())
{
m_map.incCurrentLevel() ;
Dart midEdgeV = m_map.phi1(dit);
ev += m_position[midEdgeV];
fv += m_position[m_map.phi1(midEdgeV)];
m_map.decCurrentLevel() ;
++count;
}
fv /= count;
fv *= 4 * m_a * m_a;
ev /= count;
ev *= 4 * m_a;
m_position[d] += fv + ev;
}
}
}
void operator() (bool filtering)
{
TraversorE<typename PFP::MAP> travE(m_map);
for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next())
{
......@@ -234,7 +141,7 @@ public:
{
unsigned int count = 0;
typename PFP::VEC3 fe(0.0);
typename PFP::VEC3 fe(0);
Traversor2EF<typename PFP::MAP> travEF(m_map, d);
for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
{
......@@ -250,14 +157,11 @@ public:
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(d);
m_position[midF] += fe;
m_position[midF] -= fe;
m_map.decCurrentLevel() ;
}
}
}
void operator() (bool filtering)
{
TraversorV<typename PFP::MAP> travV(m_map);
for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next())
{
......@@ -267,24 +171,16 @@ public:
{
Dart db = m_map.findBoundaryEdgeOfVertex(d);
m_map.incCurrentLevel() ;
ev += (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]) * typename PFP::REAL(0.5);
ev = (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]);
m_map.decCurrentLevel() ;
ev *= 2 * m_a;
ev *= m_a;
if(filtering)
{
std::cout << "sans +=" << std::endl;
m_position[db] = ev;
}
else
{
std::cout << "avec +=" << std::endl;
m_position[db] += ev;
}
m_position[d] -= ev;
}
else
{
unsigned int count = 0;
Traversor2VF<typename PFP::MAP> travVF(m_map,d);
for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next())
{
......@@ -302,61 +198,16 @@ public:
ev /= count;
ev *= 4 * m_a;
if(filtering)
{
std::cout << "sans +=" << std::endl;
m_position[d] = fv + ev;
}
else
{
std::cout << "avec +=" << std::endl;
m_position[d] += fv + ev;
}
}
}
TraversorE<typename PFP::MAP> travE(m_map);
for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next())
{
if(!m_map.isBoundaryEdge(d))
{
unsigned int count = 0;
typename PFP::VEC3 fe(0.0);
Traversor2EF<typename PFP::MAP> travEF(m_map, d);
for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
{
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(m_map.phi1(dit));
fe += m_position[midV];
m_map.decCurrentLevel() ;
++count;
}
fe /= count;
fe *= 2 * m_a;
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(d);
if(filtering)
{
std::cout << "sans +=" << std::endl;
m_position[midF] = fe;
}
else
{
std::cout << "avec +=" << std::endl;
m_position[midF] += fe;
}
m_map.decCurrentLevel() ;
m_position[d] -= fv + ev;
}
}
}
} ;
};
// s-scale(a)
template <typename PFP>
class Ber02ScaleSynthesisFilter : public Algo::MR::Filter
class Ber02ScaleAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -364,29 +215,12 @@ protected:
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02ScaleSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
Ber02ScaleAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
{}
void operator() ()
{
TraversorV<typename PFP::MAP> travV(m_map) ;
for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
{
if(m_map.isBoundaryVertex(d))
m_position[d] *= m_a;
else
m_position[d] *= m_a * m_a;
}
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
m_map.incCurrentLevel() ;
Dart midE = m_map.phi1(d);
if(!m_map.isBoundaryVertex(midE))
m_position[midE] *= m_a ;
m_map.decCurrentLevel() ;
}
}
void operator() (bool filtering)
......@@ -395,9 +229,9 @@ public:
for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
{
if(m_map.isBoundaryVertex(d))
m_position[d] *= m_a;
m_position[d] /= m_a;
else
m_position[d] *= m_a * m_a;
m_position[d] /= m_a * m_a;
}
TraversorE<typename PFP::MAP> travE(m_map) ;
......@@ -406,48 +240,39 @@ public:
m_map.incCurrentLevel() ;
Dart midE = m_map.phi1(d);
if(!m_map.isBoundaryVertex(midE))
m_position[midE] *= m_a ;
m_position[midE] /= m_a ;
m_map.decCurrentLevel() ;
}
}
} ;
};
//
// Analysis
//
/*********************************************************************************
* SYNTHESIS FILTERS
*********************************************************************************/
//w-lift(a)
template <typename PFP>
class Ber02OddAnalysisFilter : public Algo::MR::Filter
class Ber02OddSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02OddAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
Ber02OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
{}
void operator() (bool filtering)
void operator() ()
{
}
void operator() ()
void operator() (bool filtering)
{
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
ve *= 2.0 * m_a;
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(d) ;
m_position[midV] -= ve;
m_map.decCurrentLevel() ;
}
TraversorF<typename PFP::MAP> travF(m_map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{
......@@ -472,15 +297,42 @@ public:
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(m_map.phi1(d));
m_position[midF] -= vf + ef ;
if(filtering)
{
m_position[midF] = vf + ef ;
}
else
{
m_position[midF] += vf + ef ;
}
m_map.decCurrentLevel() ;
}
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
ve *= 2.0 * m_a;
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(d) ;
if(filtering)
{
m_position[midV] = ve;
}
else
{
m_position[midV] += ve;
}
m_map.decCurrentLevel() ;
}
}
};
} ;
// s-lift(a)
template <typename PFP>
class Ber02EvenAnalysisFilter : public Algo::MR::Filter
class Ber02EvenSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -488,44 +340,16 @@ protected:
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02EvenAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
Ber02EvenSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
{}
void operator() (bool filtering)
void operator() ()
{
}
void operator() ()
void operator() (bool filtering)
{
TraversorE<typename PFP::MAP> travE(m_map);
for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next())
{
if(!m_map.isBoundaryEdge(d))
{
unsigned int count = 0;
typename PFP::VEC3 fe(0);
Traversor2EF<typename PFP::MAP> travEF(m_map, d);
for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
{
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(m_map.phi1(dit));
fe += m_position[midV];
m_map.decCurrentLevel() ;
++count;
}
fe /= count;
fe *= 2 * m_a;
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(d);
m_position[midF] -= fe;
m_map.decCurrentLevel() ;
}
}
TraversorV<typename PFP::MAP> travV(m_map);
for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next())
{
......@@ -535,16 +359,22 @@ public:
{
Dart db = m_map.findBoundaryEdgeOfVertex(d);
m_map.incCurrentLevel() ;
ev = (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]);
ev += (m_position[m_map.phi1(db)] + m_position[m_map.phi_1(db)]) * typename PFP::REAL(0.5);
m_map.decCurrentLevel() ;
ev *= m_a;
ev *= 2 * m_a;
m_position[d] -= ev;
if(filtering)
{
m_position[db] = ev;
}
else
{
m_position[db] += ev;
}
}
else
{
unsigned int count = 0;
Traversor2VF<typename PFP::MAP> travVF(m_map,d);
for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next())
{
......@@ -562,16 +392,57 @@ public:
ev /= count;
ev *= 4 * m_a;
if(filtering)
{
m_position[d] = fv + ev;
}
else
{
m_position[d] += fv + ev;
}
}
}
m_position[d] -= fv + ev;
TraversorE<typename PFP::MAP> travE(m_map);
for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next())
{
if(!m_map.isBoundaryEdge(d))
{
unsigned int count = 0;
typename PFP::VEC3 fe(0.0);
Traversor2EF<typename PFP::MAP> travEF(m_map, d);
for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
{
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(m_map.phi1(dit));
fe += m_position[midV];
m_map.decCurrentLevel() ;
++count;
}
fe /= count;
fe *= 2 * m_a;
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(d);
if(filtering)
{
m_position[midF] = fe;
}
else
{
m_position[midF] += fe;
}
m_map.decCurrentLevel() ;
}
}
}
};
} ;
// s-scale(a)
template <typename PFP>
class Ber02ScaleAnalysisFilter : public Algo::MR::Filter
class Ber02ScaleSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -579,23 +450,23 @@ protected:
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02ScaleAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
Ber02ScaleSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p, typename PFP::VEC3::DATA_TYPE a) : m_map(m), m_position(p), m_a(a)
{}
void operator() (bool filtering)
void operator() ()
{
}
void operator() ()
void operator() (bool filtering)
{
TraversorV<typename PFP::MAP> travV(m_map) ;
for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
{
if(m_map.isBoundaryVertex(d))