Commit 21f73349 authored by Pierre Kraemer's avatar Pierre Kraemer

corrections average + delete averagePositions

parent 73576e31
......@@ -33,26 +33,28 @@ namespace Algo
namespace Filtering
{
enum neighborhood {INSIDE = 1, BORDER = 2};
enum neighborhood { INSIDE = 1, BORDER = 2 };
template <typename PFP, typename T>
void filterAverageAttribute_OneRing(typename PFP::MAP& map,
const typename AttributeHandler<T>& attIn,
typename AttributeHandler<T>& attOut,
void filterAverageAttribute_OneRing(
typename PFP::MAP& map,
const AttributeHandler<T>& attIn,
AttributeHandler<T>& attOut,
neighborhood neigh,
const FunctorSelect& select = SelectorTrue())
{
typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> fa(attIn) ;
FunctorAverage<VEC3> fa(attIn) ;
Algo::Selection::Collector_OneRing<PFP> col(map) ;
CellMarker markV(map, VERTEX);
CellMarker markV(map, VERTEX) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(select(d) && !markV.isMarked(d))
{
markV.mark(d);
markV.mark(d) ;
if (neigh & INSIDE)
col.collectAll(d) ;
......@@ -60,8 +62,10 @@ void filterAverageAttribute_OneRing(typename PFP::MAP& map,
col.collectBorder(d) ;
fa.reset() ;
if (neigh & INSIDE){
switch (attIn.getOrbit()) {
if (neigh & INSIDE)
{
switch (attIn.getOrbit())
{
case VERTEX :
col.applyOnInsideVertices(fa) ;
break;
......@@ -80,9 +84,10 @@ void filterAverageAttribute_OneRing(typename PFP::MAP& map,
}
template <typename PFP, typename T>
void filterAverageEdgesAttribute_WithinSphere(typename PFP::MAP& map,
const typename AttributeHandler<T>& attIn,
typename AttributeHandler<T>& attOut,
void filterAverageEdgesAttribute_WithinSphere(
typename PFP::MAP& map,
const AttributeHandler<T>& attIn,
AttributeHandler<T>& attOut,
neighborhood neigh,
typename PFP::TVEC3 & position,
typename PFP::REAL radius,
......@@ -90,15 +95,15 @@ void filterAverageEdgesAttribute_WithinSphere(typename PFP::MAP& map,
{
typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> fa(attIn) ;
FunctorAverage<VEC3> fa(attIn) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
CellMarker markV(map, VERTEX);
CellMarker markV(map, VERTEX) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(select(d) && !markV.isMarked(d))
{
markV.mark(d);
markV.mark(d) ;
if (neigh & INSIDE)
col.collectAll(d) ;
......@@ -114,9 +119,10 @@ void filterAverageEdgesAttribute_WithinSphere(typename PFP::MAP& map,
}
template <typename PFP, typename T>
void filterAverageFacesAttribute_WithinSphere(typename PFP::MAP& map,
const typename AttributeHandler<T>& attIn,
typename AttributeHandler<T>& attOut,
void filterAverageFacesAttribute_WithinSphere(
typename PFP::MAP& map,
const AttributeHandler<T>& attIn,
AttributeHandler<T>& attOut,
neighborhood neigh,
typename PFP::TVEC3 & position,
typename PFP::REAL radius,
......@@ -124,15 +130,15 @@ void filterAverageFacesAttribute_WithinSphere(typename PFP::MAP& map,
{
typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> fa(attIn) ;
FunctorAverage<VEC3> fa(attIn) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
CellMarker markV(map, VERTEX);
CellMarker markV(map, VERTEX) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(select(d) && !markV.isMarked(d))
{
markV.mark(d);
markV.mark(d) ;
if (neigh & INSIDE)
col.collectAll(d) ;
......@@ -148,9 +154,10 @@ void filterAverageFacesAttribute_WithinSphere(typename PFP::MAP& map,
}
template <typename PFP, typename T>
void filterAverageVertexAttribute_WithinSphere(typename PFP::MAP& map,
const typename AttributeHandler<T>& attIn,
typename AttributeHandler<T>& attOut,
void filterAverageVertexAttribute_WithinSphere(
typename PFP::MAP& map,
const AttributeHandler<T>& attIn,
AttributeHandler<T>& attOut,
neighborhood neigh,
typename PFP::TVEC3 & position,
typename PFP::REAL radius,
......@@ -158,16 +165,16 @@ void filterAverageVertexAttribute_WithinSphere(typename PFP::MAP& map,
{
typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> faInside(attIn) ;
FunctorAverage<VEC3> faInside(attIn) ;
FunctorAverageOnSphereBorder<PFP, typename PFP::VEC3> faBorder(map, attIn, position) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
CellMarker markV(map, VERTEX);
CellMarker markV(map, VERTEX) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(select(d) && !markV.isMarked(d))
{
markV.mark(d);
markV.mark(d) ;
if (neigh & INSIDE)
col.collectAll(d) ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, 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.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Algo/Filtering/functors.h"
#include "Algo/Selection/collector.h"
namespace CGoGN
{
namespace Algo
{
namespace Filtering
{
template <typename PFP>
void filterAveragePositions(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& position2, const FunctorSelect& select = SelectorTrue())
{
typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> fa(position) ;
Algo::Selection::Collector_OneRing<PFP> c(map) ;
CellMarker markV(map, VERTEX);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(select(d) && !markV.isMarked(d))
{
markV.mark(d);
c.collectBorder(d) ;
fa.reset() ;
c.applyOnBorder(fa) ;
position2[d] = fa.getAverage() ;
}
}
}
} // namespace Filtering
} // namespace Algo
} // namespace CGoGN
......@@ -26,7 +26,7 @@
#define __FILTERING_FUNCTORS_H__
#include "Topology/generic/functor.h"
#include "Utils/intersection.h"
#include "Algo/Geometry/intersection.h"
namespace CGoGN
{
......@@ -38,7 +38,7 @@ namespace Filtering
{
template <typename T>
class FunctorAverage : public FunctorType
class FunctorAverage : public virtual FunctorType
{
protected:
const AttributeHandler<T>& attr ;
......
......@@ -45,7 +45,7 @@ public:
// Base Class for Functors that need access to the map
/********************************************************/
template <typename MAP>
class FunctorMap: public virtual FunctorType
class FunctorMap : public virtual FunctorType
{
protected:
MAP& m_map ;
......
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