Commit b009736c authored by Sylvain Thery's avatar Sylvain Thery

more compil testing

parent b4155a6f
......@@ -5,14 +5,14 @@ project(testing_algo)
#add_subdirectory(BooleanOperator)
add_subdirectory(Decimation)
#add_subdirectory(Export)
#add_subdirectory(Filtering)
add_subdirectory(Filtering)
add_subdirectory(Geometry)
#add_subdirectory(Histogram)
#add_subdirectory(ImplicitHierarchicalMesh)
#add_subdirectory(Import)
#add_subdirectory(LinearSolving)
#add_subdirectory(MC)
#add_subdirectory(Modelisation)
add_subdirectory(Modelisation)
#add_subdirectory(MovingObjects)
#add_subdirectory(Multiresolution)
add_subdirectory(ProgressiveMesh)
......
......@@ -3,9 +3,10 @@
#include "Topology/gmap/embeddedGMap2.h"
using namespace CGoGN;
#include "Algo/Decimation/halfEdgeSelector.h"
using namespace CGoGN;
struct PFP1 : public PFP_STANDARD
{
......
......@@ -2,9 +2,9 @@
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/Decimation/predictor.h"
using namespace CGoGN;
#include "Algo/Decimation/predictor.h"
struct PFP1 : public PFP_STANDARD
......
cmake_minimum_required(VERSION 2.6)
project(testing_algo_filtering)
add_executable( test_algo_filtering
algo_filtering.cpp
average.cpp
average_normals.cpp
bilateral.cpp
taubin.cpp
tools.cpp
)
target_link_libraries( test_algo_filtering
${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
#include <iostream>
extern int test_average();
extern int test_average_normals();
extern int test_bilateral();
extern int test_taubin();
extern int test_tools();
int main()
{
test_average();
test_average_normals();
test_bilateral();
test_taubin();
test_tools();
return 0;
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Topology/generic/traversor/traversorCell.h"
#include "Algo/Filtering/functors.h"
#include "Algo/Selection/collector.h"
namespace CGoGN
{
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/Filtering/average.h"
namespace Algo
using namespace CGoGN;
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
namespace Surface
struct PFP2 : public PFP_DOUBLE
{
typedef EmbeddedMap2 MAP;
};
namespace Filtering
struct PFP3 : public PFP_DOUBLE
{
typedef EmbeddedGMap2 MAP;
};
enum neighborhood { INSIDE = 1, BORDER = 2 };
template <typename PFP, typename T>
void filterAverageAttribute_OneRing(
typename PFP::MAP& map,
const VertexAttribute<T, typename PFP::MAP>& attIn,
VertexAttribute<T, typename PFP::MAP>& attOut,
int neigh)
{
FunctorAverage<VertexAttribute<T, typename PFP::MAP> > fa(attIn) ;
Algo::Surface::Selection::Collector_OneRing<PFP> col(map) ;
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(!map.isBoundaryVertex(d))
{
if (neigh & INSIDE)
col.collectAll(d) ;
else
col.collectBorder(d) ;
fa.reset() ;
if (neigh & INSIDE)
{
switch (attIn.getOrbit())
{
case VERTEX :
col.applyOnInsideVertices(fa) ;
break;
case EDGE :
col.applyOnInsideEdges(fa) ;
break;
case FACE :
col.applyOnInsideFaces(fa) ;
break;
}
}
if (neigh & BORDER)
col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
else
attOut[d] = attIn[d] ;
}
}
template <typename PFP, typename T>
void filterAverageVertexAttribute_WithinSphere(
typename PFP::MAP& map,
const VertexAttribute<T, typename PFP::MAP>& attIn,
VertexAttribute<T, typename PFP::MAP>& attOut,
int neigh,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
typename PFP::REAL radius)
{
FunctorAverage<VertexAttribute<T, typename PFP::MAP> > faInside(attIn) ;
FunctorAverageOnSphereBorder<PFP, T> faBorder(map, attIn, position) ;
Algo::Surface::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(!map.isBoundaryVertex(d))
{
if (neigh & INSIDE)
col.collectAll(d) ;
else
col.collectBorder(d) ;
attOut[d] = T(0);
if (neigh & INSIDE){
faInside.reset() ;
col.applyOnInsideVertices(faInside) ;
attOut[d] += faInside.getSum();
}
if (neigh & BORDER){
faBorder.reset(position[d], radius);
col.applyOnBorder(faBorder) ;
attOut[d] += faBorder.getSum();
}
attOut[d] /= faInside.getCount() + faBorder.getCount() ;
}
else
attOut[d] = attIn[d] ;
}
}
template <typename PFP, typename T>
void filterAverageEdgeAttribute_WithinSphere(
typename PFP::MAP& map,
const EdgeAttribute<T, typename PFP::MAP>& attIn,
EdgeAttribute<T, typename PFP::MAP>& attOut,
int neigh,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
typename PFP::REAL radius)
{
FunctorAverage<EdgeAttribute<T, typename PFP::MAP> > fa(attIn) ;
Algo::Surface::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
TraversorE<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if (neigh & INSIDE)
col.collectAll(d) ;
else
col.collectBorder(d) ;
fa.reset() ;
if (neigh & INSIDE) col.applyOnInsideEdges(fa) ;
if (neigh & BORDER) col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
}
template <typename PFP, typename T>
void filterAverageFaceAttribute_WithinSphere(
typename PFP::MAP& map,
const FaceAttribute<T, typename PFP::MAP>& attIn,
FaceAttribute<T, typename PFP::MAP>& attOut,
int neigh,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
typename PFP::REAL radius)
{
FunctorAverage<FaceAttribute<T, typename PFP::MAP> > fa(attIn) ;
Algo::Surface::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
template void Algo::Surface::Filtering::filterAverageAttribute_OneRing<PFP1, Geom::Vec3d>(PFP1::MAP& map,
const VertexAttribute<Geom::Vec3d, PFP1::MAP>& attIn, VertexAttribute<Geom::Vec3d, PFP1::MAP>& attOut, int neigh);
template void Algo::Surface::Filtering::filterAverageVertexAttribute_WithinSphere<PFP1, Geom::Vec3d>(PFP1::MAP& map,
const VertexAttribute<Geom::Vec3d, PFP1::MAP>& attIn, VertexAttribute<Geom::Vec3d, PFP1::MAP>& attOut, int neigh,
VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, PFP1::REAL radius);
template void Algo::Surface::Filtering::filterAverageEdgeAttribute_WithinSphere<PFP1, Geom::Vec3d>(PFP1::MAP& map,
const EdgeAttribute<Geom::Vec3d, PFP1::MAP>& attIn, EdgeAttribute<Geom::Vec3d, PFP1::MAP>& attOut, int neigh,
VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, PFP1::REAL radius);
TraversorF<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if (neigh & INSIDE)
col.collectAll(d) ;
else
col.collectBorder(d) ;
template void Algo::Surface::Filtering::filterAverageFaceAttribute_WithinSphere<PFP1, Geom::Vec3d>(PFP1::MAP& map,
const FaceAttribute<Geom::Vec3d, PFP1::MAP>& attIn, FaceAttribute<Geom::Vec3d, PFP1::MAP>& attOut, int neigh,
VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, PFP1::REAL radius);
fa.reset() ;
if (neigh & INSIDE) col.applyOnInsideFaces(fa) ;
if (neigh & BORDER) col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
}
} // namespace Filtering
} // namespace Surface
template void Algo::Surface::Filtering::filterAverageAttribute_OneRing<PFP2, Geom::Vec3f>(PFP2::MAP& map,
const VertexAttribute<Geom::Vec3f, PFP2::MAP>& attIn, VertexAttribute<Geom::Vec3f, PFP2::MAP>& attOut, int neigh);
} // namespace Algo
template void Algo::Surface::Filtering::filterAverageVertexAttribute_WithinSphere<PFP2, Geom::Vec3f>(PFP2::MAP& map,
const VertexAttribute<Geom::Vec3f, PFP2::MAP>& attIn, VertexAttribute<Geom::Vec3f, PFP2::MAP>& attOut, int neigh,
VertexAttribute<PFP2::VEC3, PFP2::MAP>& position, PFP2::REAL radius);
template void Algo::Surface::Filtering::filterAverageEdgeAttribute_WithinSphere<PFP2, Geom::Vec3f>(PFP2::MAP& map,
const EdgeAttribute<Geom::Vec3f, PFP2::MAP>& attIn, EdgeAttribute<Geom::Vec3f, PFP2::MAP>& attOut, int neigh,
VertexAttribute<PFP2::VEC3, PFP2::MAP>& position, PFP2::REAL radius);
template void Algo::Surface::Filtering::filterAverageFaceAttribute_WithinSphere<PFP2, Geom::Vec3f>(PFP2::MAP& map,
const FaceAttribute<Geom::Vec3f, PFP2::MAP>& attIn, FaceAttribute<Geom::Vec3f, PFP2::MAP>& attOut, int neigh,
VertexAttribute<PFP2::VEC3, PFP2::MAP>& position, PFP2::REAL radius);
template void Algo::Surface::Filtering::filterAverageAttribute_OneRing<PFP3, Geom::Vec3f>(PFP3::MAP& map,
const VertexAttribute<Geom::Vec3f, PFP3::MAP>& attIn, VertexAttribute<Geom::Vec3f, PFP3::MAP>& attOut, int neigh);
template void Algo::Surface::Filtering::filterAverageVertexAttribute_WithinSphere<PFP3, Geom::Vec3f>(PFP3::MAP& map,
const VertexAttribute<Geom::Vec3f, PFP3::MAP>& attIn, VertexAttribute<Geom::Vec3f, PFP3::MAP>& attOut, int neigh,
VertexAttribute<PFP3::VEC3, PFP3::MAP>& position, PFP3::REAL radius);
template void Algo::Surface::Filtering::filterAverageEdgeAttribute_WithinSphere<PFP3, Geom::Vec3f>(PFP3::MAP& map,
const EdgeAttribute<Geom::Vec3f, PFP3::MAP>& attIn, EdgeAttribute<Geom::Vec3f, PFP3::MAP>& attOut, int neigh,
VertexAttribute<PFP3::VEC3, PFP3::MAP>& position, PFP3::REAL radius);
template void Algo::Surface::Filtering::filterAverageFaceAttribute_WithinSphere<PFP3, Geom::Vec3f>(PFP3::MAP& map,
const FaceAttribute<Geom::Vec3f, PFP3::MAP>& attIn, FaceAttribute<Geom::Vec3f, PFP3::MAP>& attOut, int neigh,
VertexAttribute<PFP3::VEC3, PFP3::MAP>& position, PFP3::REAL radius);
int test_average()
{
} // namespace CGoGN
return 0;
}
\ No newline at end of file
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <cmath>
#include "Topology/generic/traversor/traversorCell.h"
namespace CGoGN
{
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
namespace Algo
{
namespace Surface
{
#include "Algo/Filtering/bilateral.h"
namespace Filtering
using namespace CGoGN;
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
template <typename PFP>
void sigmaBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal, float& sigmaC, float& sigmaS)
struct PFP2 : public PFP_DOUBLE
{
typedef typename PFP::VEC3 VEC3 ;
float sumLengths = 0.0f ;
float sumAngles = 0.0f ;
long nbEdges = 0 ;
TraversorE<typename PFP::MAP> t(map);
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
sumLengths += Algo::Surface::Geometry::edgeLength<PFP>(map, d, position) ;
sumAngles += Geom::angle(normal[d], normal[map.phi1(d)]) ;
++nbEdges ;
}
// update of returned values
sigmaC = 1.0f * ( sumLengths / float(nbEdges) ) ;
sigmaS = 2.5f * ( sumAngles / float(nbEdges) ) ;
}
/**
* \brief Function applying a bilateral filter smoothing on the mesh.
* \param map the map of the mesh
* \param positionIn the current positions container of the mesh
* \param positionOut the smoothed positions after the function call
* \param normal the normals
*/
template <typename PFP>
void filterBilateral(
typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3,typename PFP::MAP>& positionIn,
VertexAttribute<typename PFP::VEC3,typename PFP::MAP>& positionOut,
const VertexAttribute<typename PFP::VEC3,typename PFP::MAP>& normal)
typedef EmbeddedMap2 MAP;
};
struct PFP3 : public PFP_DOUBLE
{
typedef typename PFP::VEC3 VEC3 ;
float sigmaC, sigmaS ;
sigmaBilateral<PFP>(map, positionIn, normal, sigmaC, sigmaS) ;
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(!map.isBoundaryVertex(d))
{
// get normal of vertex
const VEC3& normal_d = normal[d] ;
// traversal of incident edges
float sum = 0.0f, normalizer = 0.0f ;
Traversor2VE<typename PFP::MAP> te(map, d) ;
for(Dart it = te.begin(); it != te.end(); it = te.next())
{
VEC3 vec = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map, it, positionIn) ;
float h = normal_d * vec ;
float t = vec.norm() ;
float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) ) ;
sum += wcs * h ;
normalizer += wcs ;
}
positionOut[d] = positionIn[d] + ((sum / normalizer) * normal_d) ;
}
else
positionOut[d] = positionIn[d] ;
}
}
template <typename PFP>
void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position2, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal)
typedef EmbeddedGMap2 MAP;
};
template void Algo::Surface::Filtering::filterBilateral<PFP1>( PFP1::MAP& map,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& positionIn,VertexAttribute<PFP1::VEC3, PFP1::MAP>& positionOut,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& normal);
template void Algo::Surface::Filtering::filterSUSAN<PFP1>(PFP1::MAP& map, float SUSANthreshold,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, VertexAttribute<PFP1::VEC3, PFP1::MAP>& position2,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& normal);
template void Algo::Surface::Filtering::filterBilateral<PFP1>(PFP1::MAP& map,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& positionIn, VertexAttribute<PFP1::VEC3, PFP1::MAP>& positionOut,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& normal);
template void Algo::Surface::Filtering::filterSUSAN<PFP1>(PFP1::MAP& map, float SUSANthreshold,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, VertexAttribute<PFP1::VEC3, PFP1::MAP>& position2,
const VertexAttribute<PFP1::VEC3, PFP1::MAP>& normal);
template void Algo::Surface::Filtering::filterBilateral<PFP3>(PFP3::MAP& map,
const VertexAttribute<PFP3::VEC3, PFP3::MAP>& positionIn, VertexAttribute<PFP3::VEC3, PFP3::MAP>& positionOut,
const VertexAttribute<PFP3::VEC3, PFP3::MAP>& normal);
template void Algo::Surface::Filtering::filterSUSAN<PFP3>(PFP3::MAP& map, float SUSANthreshold,
const VertexAttribute<PFP3::VEC3, PFP3::MAP>& position, VertexAttribute<PFP3::VEC3, PFP3::MAP>& position2,
const VertexAttribute<PFP3::VEC3, PFP3::MAP>& normal);
int test_bilateral()
{
typedef typename PFP::VEC3 VEC3 ;
float sigmaC, sigmaS ;
sigmaBilateral<PFP>(map, position, normal, sigmaC, sigmaS) ;
long nbTot = 0 ;
long nbSusan = 0 ;
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(!map.isBoundaryVertex(d))
{
// get position & normal of vertex
const VEC3& pos_d = position[d] ;
const VEC3& normal_d = normal[d] ;
// traversal of incident edges
float sum = 0.0f, normalizer = 0.0f ;
bool SUSANregion = false ;
Traversor2VE<typename PFP::MAP> te(map, d) ;
for(Dart it = te.begin(); it != te.end(); it = te.next())
{
const VEC3& neighborNormal = normal[map.phi1(it)] ;
float angle = Geom::angle(normal_d, neighborNormal) ;
if( angle <= SUSANthreshold )
{
VEC3 vec = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map, it, position) ;
float h = normal_d * vec ;
float t = vec.norm() ;
float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) );
sum += wcs * h ;
normalizer += wcs ;
}
else
SUSANregion = true ;
}
if(SUSANregion)
nbSusan++ ;
nbTot++ ;
if (normalizer != 0.0f)
position2[d] = pos_d + ((sum / normalizer) * normal_d) ;
else
position2[d] = pos_d ;
}
else
position2[d] = position[d] ;
}
// CGoGNout <<" susan rate = "<< float(nbSusan)/float(nbTot)<<CGoGNendl;
}
} //namespace Filtering
}
} //namespace Algo
} //namespace CGoGN
return 0;
}
\ No newline at end of file
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __FILTERING_FUNCTORS_H__
#define __FILTERING_FUNCTORS_H__
#include "Topology/generic/functor.h"
#include "Algo/Geometry/intersection.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Filtering
{
template <typename ATTR_TYPE>
class FunctorAverage : public virtual FunctorType
{
typedef typename ATTR_TYPE::DATA_TYPE T ;
protected:
const ATTR_TYPE& attr ;
T sum ;
unsigned int count ;
public:
FunctorAverage(const ATTR_TYPE& a) : FunctorType(), attr(a), sum(0), count(0)
{}
bool operator()(Dart d)
{
sum += attr[d] ;
++count ;
return false ;
}
inline void reset() { sum = T(0) ; count = 0 ; }
inline T getSum() { return sum ; }
inline unsigned int getCount() { return count ; }
inline T getAverage() { return sum / typename T::DATA_TYPE(count) ; }
} ;
template <typename PFP, typename T>
class FunctorAverageOnSphereBorder : public FunctorMap<typename PFP::MAP>
{
typedef typename PFP::VEC3 VEC3;
protected:
const VertexAttribute<T, typename PFP::MAP>& attr ;
const VertexAttribute<VEC3, typename PFP::MAP>& position ;
VEC3 center;
typename PFP::REAL radius;
T sum ;
unsigned int count ;
public:
FunctorAverageOnSphereBorder(typename PFP::MAP& map, const VertexAttribute<T, typename PFP::MAP>& a, const VertexAttribute<VEC3, typename PFP::MAP>& p) :
FunctorMap<typename PFP::MAP>(map), attr(a), position(p), sum(0), count(0)
{
center = VEC3(0);
radius = 0;
}
bool operator()(Dart d)
{
typename PFP::REAL alpha = 0;
Geometry::intersectionSphereEdge<PFP>(this->m_map, center, radius, d, position, alpha);
sum += (1 - alpha) * attr[d] + alpha * attr[this->m_map.phi1(d)] ;
++count ;
return false ;
}
inline void reset(VEC3& c, typename PFP::REAL r) { center = c; radius = r; sum = T(0) ; count = 0 ; }
inline T getSum() { return sum ; }
inline unsigned int getCount() { return count ; }
inline T getAverage() { return sum / typename T::DATA_TYPE(count) ; }
} ;
} // namespace Filtering
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
#endif
///*******************************************************************************
//* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
//* version 0.1 *
//* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
//* *
//* This library is free software; you can redistribute it and/or modify it *
//* under the terms of the GNU Lesser General Public License as published by the *