Commit aecae76d authored by untereiner's avatar untereiner
Browse files

correction bertram filter

parent d7f201ae
......@@ -45,10 +45,6 @@ namespace Primal
namespace Filters
{
/*******************************************************************************
* Without features preserving
*******************************************************************************/
//
// Synthesis
//
......@@ -120,79 +116,58 @@ protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
typename PFP::VEC3::DATA_TYPE m_a;
bool m_threshold;
unsigned int m_current;
unsigned int percentWanted;
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), m_threshold(false)
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 activateThreshold(bool b) { m_threshold = b; percentWanted = m_map.getMaxLevel() * 30 / 100 ; }
void operator() ()
{
TraversorV<typename PFP::MAP> travV(m_map);
for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next())
{
// if(m_threshold && m_current > percentWanted)
// {
// m_position[d] += typename PFP::VEC3(0.0);
// }
// else
// {
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)]);
m_map.decCurrentLevel() ;
ev *= m_a;
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[d] += 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())
{
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() ;
m_map.incCurrentLevel() ;
Dart midEdgeV = m_map.phi1(dit);
ev += m_position[midEdgeV];
fv += m_position[m_map.phi1(midEdgeV)];
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;
m_map.decCurrentLevel() ;
++count;
}
fv /= count;
fv *= 4 * m_a * m_a;
ev /= count;
ev *= 4 * m_a;
ev /= count;
ev *= 4 * m_a;
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_threshold && m_current > percentWanted)
// {
// m_map.incCurrentLevel() ;
// Dart midF = m_map.phi1(d);
// m_position[midF] += typename PFP::VEC3(0.0);
// m_map.decCurrentLevel() ;
// }
// else
// {
if(!m_map.isBoundaryEdge(d))
{
unsigned int count = 0;
typename PFP::VEC3 fe(0.0);
......@@ -213,13 +188,8 @@ public:
Dart midF = m_map.phi1(d);
m_position[midF] += fe;
m_map.decCurrentLevel() ;
// }
}
}
// if(m_threshold && m_current < percentWanted)
// {
// ++m_current;
// }
}
} ;
......@@ -446,203 +416,203 @@ public:
/*************************************************************************************
* With features preserving
*************************************************************************************/
///*************************************************************************************
// * With features preserving
// *************************************************************************************/
//
// Synthesis
////
//// Synthesis
////
//
//w-lift(a)
template <typename PFP>
class Ber02OddSynthesisFilterFeatures : public Ber02OddSynthesisFilter<PFP>
{
protected:
const VertexAttribute<unsigned int>& m_Vfeature;
const EdgeAttribute<unsigned int>& m_Efeature;
public:
Ber02OddSynthesisFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
Ber02OddSynthesisFilter<PFP>(m, p, a), m_Vfeature(v), m_Efeature(e)
{}
} ;
// s-lift(a)
template <typename PFP>
class Ber02EvenSynthesisFilterFeatures : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
const VertexAttribute<unsigned int>& m_Vfeature;
const EdgeAttribute<unsigned int>& m_Efeature;
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02EvenSynthesisFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
m_map(m), m_position(p), m_Vfeature(v), m_Efeature(e), 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_Vfeature[d] == 2) //is a part of a face-feature
{
unsigned int count = 0;
typename PFP::VEC3 ev(0.0);
typename PFP::VEC3 fv(0.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;
}
else if(m_Vfeature[d] == 1) //is a part of an edge-feature
{
unsigned int count = 0;
typename PFP::VEC3 ev(0.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);
if(m_Vfeature[midEdgeV] == 1)
{
ev += m_position[midEdgeV];
++count;
}
m_map.decCurrentLevel() ;
}
ev /= count;
ev *= 2 * m_a;
m_position[d] += ev;
}
else
{
m_position[d] += 0.0;
}
}
TraversorE<typename PFP::MAP> travE(m_map);
for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next())
{
if(m_Efeature[d] == 2)
{
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() ;
}
else
{
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(d);
m_position[midF] += 0.0;
m_map.decCurrentLevel() ;
}
}
}
} ;
// s-scale(a)
template <typename PFP>
class Ber02ScaleFilterFeatures : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
const VertexAttribute<unsigned int>& m_Vfeature;
const EdgeAttribute<unsigned int>& m_Efeature;
typename PFP::VEC3::DATA_TYPE m_a;
public:
Ber02ScaleFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
m_map(m), m_position(p), m_Vfeature(v), m_Efeature(e), m_a(a)
{}
void operator() ()
{
TraversorV<typename PFP::MAP> travV(m_map) ;
for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
{
m_position[d] *= pow(m_a, m_Vfeature[d]);
}
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
if(m_Efeature[d] == 2)
{
m_map.incCurrentLevel() ;
Dart midE = m_map.phi1(d);
m_position[midE] *= m_a ;
m_map.decCurrentLevel() ;
}
}
}
} ;
////w-lift(a)
//template <typename PFP>
//class Ber02OddSynthesisFilterFeatures : public Ber02OddSynthesisFilter<PFP>
//{
//protected:
// const VertexAttribute<unsigned int>& m_Vfeature;
// const EdgeAttribute<unsigned int>& m_Efeature;
//
// Analysis
//public:
// Ber02OddSynthesisFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
// const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
// Ber02OddSynthesisFilter<PFP>(m, p, a), m_Vfeature(v), m_Efeature(e)
// {}
//} ;
//
//w-lift(a)
template <typename PFP>
class Ber02OddAnalysisFilterFeatures : public Ber02OddAnalysisFilter<PFP>
{
protected:
const VertexAttribute<unsigned int>& m_Vfeature;
const EdgeAttribute<unsigned int>& m_Efeature;
public:
Ber02OddAnalysisFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
Ber02OddAnalysisFilter<PFP>(m, p, a), m_Vfeature(v), m_Efeature(e)
{}
} ;
//// s-lift(a)
//template <typename PFP>
//class Ber02EvenSynthesisFilterFeatures : public Filter
//{
//protected:
// typename PFP::MAP& m_map ;
// VertexAttribute<typename PFP::VEC3>& m_position ;
// const VertexAttribute<unsigned int>& m_Vfeature;
// const EdgeAttribute<unsigned int>& m_Efeature;
// typename PFP::VEC3::DATA_TYPE m_a;
//
//public:
// Ber02EvenSynthesisFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
// const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
// m_map(m), m_position(p), m_Vfeature(v), m_Efeature(e), 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_Vfeature[d] == 2) //is a part of a face-feature
// {
// unsigned int count = 0;
// typename PFP::VEC3 ev(0.0);
// typename PFP::VEC3 fv(0.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;
// }
// else if(m_Vfeature[d] == 1) //is a part of an edge-feature
// {
// unsigned int count = 0;
// typename PFP::VEC3 ev(0.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);
//
// if(m_Vfeature[midEdgeV] == 1)
// {
// ev += m_position[midEdgeV];
// ++count;
// }
//
// m_map.decCurrentLevel() ;
// }
//
// ev /= count;
// ev *= 2 * m_a;
//
// m_position[d] += ev;
// }
// else
// {
// m_position[d] += 0.0;
// }
// }
//
// TraversorE<typename PFP::MAP> travE(m_map);
// for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next())
// {
// if(m_Efeature[d] == 2)
// {
// 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() ;
// }
// else
// {
// m_map.incCurrentLevel() ;
// Dart midF = m_map.phi1(d);
// m_position[midF] += 0.0;
// m_map.decCurrentLevel() ;
// }
// }
//
// }
//} ;
//
//// s-scale(a)
//template <typename PFP>
//class Ber02ScaleFilterFeatures : public Filter
//{
//protected:
// typename PFP::MAP& m_map ;
// VertexAttribute<typename PFP::VEC3>& m_position ;
// const VertexAttribute<unsigned int>& m_Vfeature;
// const EdgeAttribute<unsigned int>& m_Efeature;
// typename PFP::VEC3::DATA_TYPE m_a;
//
//public:
// Ber02ScaleFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
// const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
// m_map(m), m_position(p), m_Vfeature(v), m_Efeature(e), m_a(a)
// {}
//
// void operator() ()
// {
// TraversorV<typename PFP::MAP> travV(m_map) ;
// for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
// {
// m_position[d] *= pow(m_a, m_Vfeature[d]);
// }
//
// TraversorE<typename PFP::MAP> travE(m_map) ;
// for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
// {
// if(m_Efeature[d] == 2)
// {
// m_map.incCurrentLevel() ;
// Dart midE = m_map.phi1(d);
// m_position[midE] *= m_a ;
// m_map.decCurrentLevel() ;
// }
// }
// }
//} ;
//
////
//// Analysis
////
//
////w-lift(a)
//template <typename PFP>
//class Ber02OddAnalysisFilterFeatures : public Ber02OddAnalysisFilter<PFP>
//{
//protected:
// const VertexAttribute<unsigned int>& m_Vfeature;
// const EdgeAttribute<unsigned int>& m_Efeature;
//
//public:
// Ber02OddAnalysisFilterFeatures(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p,
// const VertexAttribute<unsigned int> v, const EdgeAttribute<unsigned int> e, typename PFP::VEC3::DATA_TYPE a) :
// Ber02OddAnalysisFilter<PFP>(m, p, a), m_Vfeature(v), m_Efeature(e)
// {}
//} ;
} // namespace Filters
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment