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

corrections average + delete averagePositions

parent 73576e31
...@@ -33,26 +33,28 @@ namespace Algo ...@@ -33,26 +33,28 @@ namespace Algo
namespace Filtering namespace Filtering
{ {
enum neighborhood {INSIDE = 1, BORDER = 2};
enum neighborhood { INSIDE = 1, BORDER = 2 };
template <typename PFP, typename T> template <typename PFP, typename T>
void filterAverageAttribute_OneRing(typename PFP::MAP& map, void filterAverageAttribute_OneRing(
const typename AttributeHandler<T>& attIn, typename PFP::MAP& map,
typename AttributeHandler<T>& attOut, const AttributeHandler<T>& attIn,
neighborhood neigh, AttributeHandler<T>& attOut,
const FunctorSelect& select = SelectorTrue()) neighborhood neigh,
const FunctorSelect& select = SelectorTrue())
{ {
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> fa(attIn) ; FunctorAverage<VEC3> fa(attIn) ;
Algo::Selection::Collector_OneRing<PFP> col(map) ; 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)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if(select(d) && !markV.isMarked(d)) if(select(d) && !markV.isMarked(d))
{ {
markV.mark(d); markV.mark(d) ;
if (neigh & INSIDE) if (neigh & INSIDE)
col.collectAll(d) ; col.collectAll(d) ;
...@@ -60,8 +62,10 @@ void filterAverageAttribute_OneRing(typename PFP::MAP& map, ...@@ -60,8 +62,10 @@ void filterAverageAttribute_OneRing(typename PFP::MAP& map,
col.collectBorder(d) ; col.collectBorder(d) ;
fa.reset() ; fa.reset() ;
if (neigh & INSIDE){ if (neigh & INSIDE)
switch (attIn.getOrbit()) { {
switch (attIn.getOrbit())
{
case VERTEX : case VERTEX :
col.applyOnInsideVertices(fa) ; col.applyOnInsideVertices(fa) ;
break; break;
...@@ -80,25 +84,26 @@ void filterAverageAttribute_OneRing(typename PFP::MAP& map, ...@@ -80,25 +84,26 @@ void filterAverageAttribute_OneRing(typename PFP::MAP& map,
} }
template <typename PFP, typename T> template <typename PFP, typename T>
void filterAverageEdgesAttribute_WithinSphere(typename PFP::MAP& map, void filterAverageEdgesAttribute_WithinSphere(
const typename AttributeHandler<T>& attIn, typename PFP::MAP& map,
typename AttributeHandler<T>& attOut, const AttributeHandler<T>& attIn,
neighborhood neigh, AttributeHandler<T>& attOut,
typename PFP::TVEC3 & position, neighborhood neigh,
typename PFP::REAL radius, typename PFP::TVEC3 & position,
const FunctorSelect& select = SelectorTrue()) typename PFP::REAL radius,
const FunctorSelect& select = SelectorTrue())
{ {
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> fa(attIn) ; FunctorAverage<VEC3> fa(attIn) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ; 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)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if(select(d) && !markV.isMarked(d)) if(select(d) && !markV.isMarked(d))
{ {
markV.mark(d); markV.mark(d) ;
if (neigh & INSIDE) if (neigh & INSIDE)
col.collectAll(d) ; col.collectAll(d) ;
...@@ -114,25 +119,26 @@ void filterAverageEdgesAttribute_WithinSphere(typename PFP::MAP& map, ...@@ -114,25 +119,26 @@ void filterAverageEdgesAttribute_WithinSphere(typename PFP::MAP& map,
} }
template <typename PFP, typename T> template <typename PFP, typename T>
void filterAverageFacesAttribute_WithinSphere(typename PFP::MAP& map, void filterAverageFacesAttribute_WithinSphere(
const typename AttributeHandler<T>& attIn, typename PFP::MAP& map,
typename AttributeHandler<T>& attOut, const AttributeHandler<T>& attIn,
neighborhood neigh, AttributeHandler<T>& attOut,
typename PFP::TVEC3 & position, neighborhood neigh,
typename PFP::REAL radius, typename PFP::TVEC3 & position,
const FunctorSelect& select = SelectorTrue()) typename PFP::REAL radius,
const FunctorSelect& select = SelectorTrue())
{ {
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> fa(attIn) ; FunctorAverage<VEC3> fa(attIn) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ; 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)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if(select(d) && !markV.isMarked(d)) if(select(d) && !markV.isMarked(d))
{ {
markV.mark(d); markV.mark(d) ;
if (neigh & INSIDE) if (neigh & INSIDE)
col.collectAll(d) ; col.collectAll(d) ;
...@@ -148,26 +154,27 @@ void filterAverageFacesAttribute_WithinSphere(typename PFP::MAP& map, ...@@ -148,26 +154,27 @@ void filterAverageFacesAttribute_WithinSphere(typename PFP::MAP& map,
} }
template <typename PFP, typename T> template <typename PFP, typename T>
void filterAverageVertexAttribute_WithinSphere(typename PFP::MAP& map, void filterAverageVertexAttribute_WithinSphere(
const typename AttributeHandler<T>& attIn, typename PFP::MAP& map,
typename AttributeHandler<T>& attOut, const AttributeHandler<T>& attIn,
neighborhood neigh, AttributeHandler<T>& attOut,
typename PFP::TVEC3 & position, neighborhood neigh,
typename PFP::REAL radius, typename PFP::TVEC3 & position,
const FunctorSelect& select = SelectorTrue()) typename PFP::REAL radius,
const FunctorSelect& select = SelectorTrue())
{ {
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
FunctorAverage<typename PFP::VEC3> faInside(attIn) ; FunctorAverage<VEC3> faInside(attIn) ;
FunctorAverageOnSphereBorder<PFP, typename PFP::VEC3> faBorder(map, attIn, position) ; FunctorAverageOnSphereBorder<PFP, typename PFP::VEC3> faBorder(map, attIn, position) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ; 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)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if(select(d) && !markV.isMarked(d)) if(select(d) && !markV.isMarked(d))
{ {
markV.mark(d); markV.mark(d) ;
if (neigh & INSIDE) if (neigh & INSIDE)
col.collectAll(d) ; 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 @@ ...@@ -26,7 +26,7 @@
#define __FILTERING_FUNCTORS_H__ #define __FILTERING_FUNCTORS_H__
#include "Topology/generic/functor.h" #include "Topology/generic/functor.h"
#include "Utils/intersection.h" #include "Algo/Geometry/intersection.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -38,7 +38,7 @@ namespace Filtering ...@@ -38,7 +38,7 @@ namespace Filtering
{ {
template <typename T> template <typename T>
class FunctorAverage : public FunctorType class FunctorAverage : public virtual FunctorType
{ {
protected: protected:
const AttributeHandler<T>& attr ; const AttributeHandler<T>& attr ;
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
// Base Class for Functors that need access to the map // Base Class for Functors that need access to the map
/********************************************************/ /********************************************************/
template <typename MAP> template <typename MAP>
class FunctorMap: public virtual FunctorType class FunctorMap : public virtual FunctorType
{ {
protected: protected:
MAP& m_map ; 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