Commit 374662d2 authored by untereiner's avatar untereiner
Browse files

some modifications

parent aecae76d
......@@ -40,7 +40,8 @@ namespace DecimationVolumes
enum ApproximatorType
{
A_QEM,
A_MidEdge
A_MidEdge,
A_hHalfCollapse
};
template <typename PFP>
......
......@@ -163,10 +163,14 @@ private:
public:
EdgeSelector_SG98(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select) :
Selector<PFP>(m, pos, approx, select)
{}
Selector<PFP>(m, pos, approx, select), m_positionApproximator(NULL)
{
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
}
~EdgeSelector_SG98()
{}
{
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_SG98 ; }
bool init() ;
bool nextEdge(Dart& d) ;
......
......@@ -23,6 +23,7 @@
*******************************************************************************/
#include "Algo/DecimationVolumes/geometryApproximator.h"
#include "Algo/Geometry/volume.h"
#include <time.h>
namespace CGoGN
......@@ -255,6 +256,58 @@ void EdgeSelector_SG98<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
MAP& m = this->m_map ;
Dart dd = m.phi2(d) ;
typename PFP::REAL vol_icells = 0.0;
typename PFP::REAL vol_ncells = 0.0;
m_positionApproximator->approximate(d) ;
typename PFP::VEC3 approx = m_positionApproximator->getApprox(d)) ;
DartMarkerStore mv(m);
Traversor3EW<TOPO_MAP> t3EW(m,d);
for(Dart dit = t3EW.begin() ; dit != t3EW.end() ; dit = t3EW.next())
{
vol_icells += Algo::Geometry::tetrahedronSignedVolume<PFP>(m,dit,this->pos);
mv.markOrbit<VOLUME>(dit);
}
Traversor3WWaV<TOPO_MAP> t3VVaE_v1(m,d);
for(Dart dit = t3VVaE_v1.begin() ; dit != t3VVaE_v1.end() ; dit = t3VVaE_v1.next())
{
if(!mv.isMarked(dit))
{
typename PFP::VEC3 p2 = position[map.phi1(dit)] ;
typename PFP::VEC3 p3 = position[map.phi_1(dit)] ;
typename PFP::VEC3 p4 = position[map.phi_1(map.phi2(dit))] ;
typename PFP::REAL voli = Geom::tetraSignedVolume(approx, p2, p3, p4) ;
vol_ncells += Algo::Geometry::tetrahedronSignedVolume<PFP>(m,dit,this->pos) - voli ;
mv.mark(dit);
}
}
Traversor3WWaV<TOPO_MAP> t3VVaE_v2(m,phi2(d));
for(Dart dit = t3VVaE_v2.begin() ; dit != t3VVaE_v2.end() ; dit = t3VVaE_v2.next())
{
if(!mv.isMarked(dit))
{
typename PFP::VEC3 p2 = position[map.phi1(dit)] ;
typename PFP::VEC3 p3 = position[map.phi_1(dit)] ;
typename PFP::VEC3 p4 = position[map.phi_1(map.phi2(dit))] ;
typename PFP::REAL voli = Geom::tetraSignedVolume(approx, p2, p3, p4) ;
vol_ncells += Algo::Geometry::tetrahedronSignedVolume<PFP>(m,dit,this->pos) - voli ;
mv.mark(dit);
}
}
// Quadric<REAL> quad ;
// quad += quadric[d] ; // compute the sum of the
// quad += quadric[dd] ; // two vertices quadrics
......
......@@ -54,6 +54,27 @@ public:
void approximate(Dart d) ;
} ;
template <typename PFP>
class Approximator_HalfCollapse : public Approximator<PFP, typename PFP::VEC3>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
Approximator_HalfCollapse(MAP& m, VertexAttribute<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3>(m, pos, pred)
{
assert(pos.size() > 0 || !"Approximator_HalfCollapse: attribute vector is empty") ;
}
~Approximator_HalfCollapse()
{}
ApproximatorType getType() const { return A_hHalfCollapse ; }
bool init() ;
void approximate(Dart d) ;
} ;
} //namespace DecimationVolumes
} //namespace Algo
......
......@@ -59,11 +59,66 @@ void Approximator_MidEdge<PFP>::approximate(Dart d)
// Compute the approximated position
this->m_approx[d] = (v1 + v2) / REAL(2) ;
if(this->m_predictor)
{
// if(this->m_predictor)
// {
//
// }
}
/************************************************************************************
* HALF COLLAPSE *
************************************************************************************/
}
template <typename PFP>
bool Approximator_HalfCollapse<PFP>::init()
{
// if(this->m_predictor)
// {
// if(! ( this->m_predictor->getType() == P_HalfCollapse ) )
// {
// return false ;
// }
// }
return true ;
}
template <typename PFP>
void Approximator_HalfCollapse<PFP>::approximate(Dart d)
{
MAP& m = this->m_map ;
this->m_approx[d] = this->m_attrV[d];
// if(this->m_predictor)
// {
// Dart dd = m.phi2(d) ;
// Dart d2 = m.phi2(m.phi_1(d)) ;
// Dart dd2 = m.phi2(m.phi_1(dd)) ;
//
// VEC3 v2 = this->m_attrV[0]->operator[](dd) ;
//
// // temporary edge collapse
// m.extractTrianglePair(d) ;
// unsigned int newV = m.template embedNewCell<VERTEX>(d2) ;
// for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i)
// {
// this->m_attrV[i]->operator[](newV) = this->m_approx[i][d] ;
// }
//
// // compute the detail vector
// this->m_predictor->predict(d2, dd2) ;
// for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i)
// {
// this->m_detail[i][d] = v2 - this->m_predictor->getPredict(1) ;
// }
//
// // vertex split to reset the initial connectivity and embeddings
// m.insertTrianglePair(d, d2, dd2) ;
// m.template embedOrbit<VERTEX>(d, m.template getEmbedding<VERTEX>(d)) ;
// m.template embedOrbit<VERTEX>(dd, m.template getEmbedding<VERTEX>(dd)) ;
// }
}
} //end namespace DecimationVolumes
} //end namespace Algo
......
......@@ -106,6 +106,50 @@ public:
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())
{
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() ;
}
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() ;
}
}
} ;
// s-lift(a)
......@@ -158,7 +202,6 @@ public:
ev /= count;
ev *= 4 * m_a;
m_position[d] += fv + ev;
}
}
......@@ -191,6 +234,85 @@ public:
}
}
}
void operator() (bool filtering)
{
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;
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())
{
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;
if(filtering)
m_position[d] = fv;// + ev;
else
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)
......@@ -227,6 +349,28 @@ public:
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())
{
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() ;
}
}
} ;
//
......@@ -246,6 +390,11 @@ 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)
{}
void operator() (bool filtering)
{
}
void operator() ()
{
TraversorE<typename PFP::MAP> travE(m_map) ;
......@@ -260,7 +409,6 @@ public:
m_map.decCurrentLevel() ;
}
TraversorF<typename PFP::MAP> travF(m_map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{
......@@ -288,7 +436,6 @@ public:
m_position[midF] -= vf + ef ;
m_map.decCurrentLevel() ;
}
}
};
......@@ -305,6 +452,11 @@ 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)
{}
void operator() (bool filtering)
{
}
void operator() ()
{
TraversorE<typename PFP::MAP> travE(m_map);
......@@ -391,6 +543,11 @@ 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)
{}
void operator() (bool filtering)
{
}
void operator() ()
{
TraversorV<typename PFP::MAP> travV(m_map) ;
......@@ -415,206 +572,6 @@ public:
};
///*************************************************************************************
// * With features preserving
// *************************************************************************************/
//
////
//// 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() ;
// }
// }
// }
//} ;
//
////
//// Analysis
////