Commit 374662d2 authored by untereiner's avatar untereiner

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
......
......@@ -46,6 +46,14 @@ namespace Primal
namespace Regular
{
enum FilterType
{
F_HighPass = 0,
F_LowPass,
F_BandPass,
F_None,
} ;
template <typename PFP>
class Map2MR
{
......@@ -59,6 +67,10 @@ protected:
std::vector<Filter*> synthesisFilters ;
std::vector<Filter*> analysisFilters ;
FilterType filter;
unsigned int thresholdLow;
unsigned int thresholdHigh;
public:
Map2MR(MAP& map);
......@@ -80,9 +92,11 @@ public:
void analysis() ;
void synthesis() ;
//threshold
void lowPassFiltering(unsigned int cutoff) { thresholdHigh = cutoff; filter = F_LowPass; }
void highPassFiltering(unsigned int cutoff) { thresholdLow = cutoff; filter = F_HighPass; }
void bandPassFiltering(unsigned int cutoffLow, unsigned int cutoffHigh) { thresholdLow = cutoffLow; thresholdHigh = cutoffHigh; filter = F_BandPass; }
void resetFiltering() { thresholdLow = 0; thresholdHigh = 0; filter = F_None; }
void filtering();
} ;
} // namespace Regular
......
......@@ -40,7 +40,8 @@ namespace Regular
template <typename PFP>
Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
m_map(map),
shareVertexEmbeddings(true)
shareVertexEmbeddings(true),
filter(F_None)
{
}
......@@ -271,6 +272,16 @@ void Map2MR<PFP>::synthesis()
for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
(*synthesisFilters[i])() ;
// for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
// {
// if((filter == F_LowPass && m_map.getCurrentLevel() <= thresholdHigh) ||
// (filter == F_HighPass && m_map.getCurrentLevel() >= thresholdLow) ||
// (filter == F_BandPass && (thresholdLow >= m_map.getCurrentLevel() && m_map.getCurrentLevel() <= thresholdHigh)))
// (*synthesisFilters[i])(true) ;
// else
// (*synthesisFilters[i])(false) ;
// }
m_map.incCurrentLevel() ;
}
......
......@@ -43,6 +43,7 @@ public:
Filter() {}
virtual ~Filter() {}
virtual void operator() () = 0 ;
//virtual void operator() (bool filtering) = 0 ;
} ;
......
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