Commit 6ab5a4b4 authored by Pierre Kraemer's avatar Pierre Kraemer

correctifs traversor2 + filters OK

parent 88f32610
...@@ -356,14 +356,15 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con ...@@ -356,14 +356,15 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
long nbAdapt = 0 ; long nbAdapt = 0 ;
long nbSusan = 0 ; long nbSusan = 0 ;
std::cout << "compute new vertices normals.." << std::endl ;
TraversorV<typename PFP::MAP> tv(map) ; TraversorV<typename PFP::MAP> tv(map) ;
for(Dart d = tv.begin(); d != tv.end(); d = tv.next()) for(Dart d = tv.begin(); d != tv.end(); d = tv.next())
{ {
if( select(d)) if(select(d))
{ {
const VEC3& normV = normal[d] ; const VEC3& normV = normal[d] ;
// traversal of neighbour vertices
REAL sumArea = 0 ; REAL sumArea = 0 ;
REAL sigmaX2 = 0 ; REAL sigmaX2 = 0 ;
REAL sigmaY2 = 0 ; REAL sigmaY2 = 0 ;
...@@ -373,6 +374,7 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con ...@@ -373,6 +374,7 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
bool SUSANregion = false ; bool SUSANregion = false ;
// traversal of neighbour vertices
Traversor2VVaE<typename PFP::MAP> tav(map, d) ; Traversor2VVaE<typename PFP::MAP> tav(map, d) ;
for(Dart it = tav.begin(); it != tav.end(); it = tav.next()) for(Dart it = tav.begin(); it != tav.end(); it = tav.next())
{ {
...@@ -447,6 +449,8 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con ...@@ -447,6 +449,8 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
} }
} }
std::cout << "update face normals.." << std::endl ;
// Compute face normals from vertex normals // Compute face normals from vertex normals
TraversorF<typename PFP::MAP> tf(map) ; TraversorF<typename PFP::MAP> tf(map) ;
for(Dart d = tf.begin(); d != tf.end(); d = tf.next()) for(Dart d = tf.begin(); d != tf.end(); d = tf.next())
...@@ -469,6 +473,8 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con ...@@ -469,6 +473,8 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
} }
} }
std::cout << "update vertices positions.." << std::endl ;
// Compute new vertices position // Compute new vertices position
computeNewPositionsFromFaceNormals<PFP>( computeNewPositionsFromFaceNormals<PFP>(
map, position, position2, faceArea, faceCentroid, faceNormal, faceNewNormal, select map, position, position2, faceArea, faceCentroid, faceNormal, faceNewNormal, select
......
...@@ -95,12 +95,9 @@ template <typename PFP> ...@@ -95,12 +95,9 @@ template <typename PFP>
typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
Dart it = d ; Traversor2VF<typename PFP::MAP> t(map, d) ;
do for(Dart it = t.begin(); it != t.end(); it = t.next())
{
area += convexFaceArea<PFP>(map, it, position) / 3 ; area += convexFaceArea<PFP>(map, it, position) / 3 ;
it = map.alpha1(it) ;
} while(it != d) ;
return area ; return area ;
} }
...@@ -108,8 +105,8 @@ template <typename PFP> ...@@ -108,8 +105,8 @@ template <typename PFP>
typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{ {
typename PFP::REAL area(0) ; typename PFP::REAL area(0) ;
Dart it = d ; Traversor2VF<typename PFP::MAP> t(map, d) ;
do for(Dart it = t.begin(); it != t.end(); it = t.next())
{ {
const typename PFP::VEC3& p1 = position[it] ; const typename PFP::VEC3& p1 = position[it] ;
const typename PFP::VEC3& p2 = position[map.phi1(it)] ; const typename PFP::VEC3& p2 = position[map.phi1(it)] ;
...@@ -128,64 +125,51 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typen ...@@ -128,64 +125,51 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typen
else else
area += tArea / 4 ; area += tArea / 4 ;
} }
it = map.alpha1(it) ; }
} while(it != d) ;
return area ; return area ;
} }
template <typename PFP> template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& face_area, const FunctorSelect& select) void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& face_area, const FunctorSelect& select)
{ {
CellMarker marker(map, FACE); TraversorF<typename PFP::MAP> t(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d) && !marker.isMarked(d)) if(select(d))
{
marker.mark(d);
face_area[d] = convexFaceArea<PFP>(map, d, position) ; face_area[d] = convexFaceArea<PFP>(map, d, position) ;
}
} }
} }
template <typename PFP> template <typename PFP>
void computeOneRingAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select) void computeOneRingAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select)
{ {
CellMarker marker(map, VERTEX); TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d) && !marker.isMarked(d)) if(select(d))
{
marker.mark(d);
vertex_area[d] = vertexOneRingArea<PFP>(map, d, position) ; vertex_area[d] = vertexOneRingArea<PFP>(map, d, position) ;
}
} }
} }
template <typename PFP> template <typename PFP>
void computeBarycentricAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select) void computeBarycentricAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select)
{ {
CellMarker marker(map, VERTEX); TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d) && !marker.isMarked(d)) if(select(d))
{
marker.mark(d);
vertex_area[d] = vertexBarycentricArea<PFP>(map, d, position) ; vertex_area[d] = vertexBarycentricArea<PFP>(map, d, position) ;
}
} }
} }
template <typename PFP> template <typename PFP>
void computeVoronoiAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select) void computeVoronoiAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select)
{ {
CellMarker marker(map, VERTEX); TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d) && !marker.isMarked(d)) if(select(d))
{
marker.mark(d);
vertex_area[d] = vertexVoronoiArea<PFP>(map, d, position) ; vertex_area[d] = vertexVoronoiArea<PFP>(map, d, position) ;
}
} }
} }
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Topology/generic/cellmarker.h" #include "Topology/generic/cellmarker.h"
namespace CGoGN namespace CGoGN
...@@ -98,13 +100,12 @@ EMB faceCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs) ...@@ -98,13 +100,12 @@ EMB faceCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs)
{ {
EMB center = AttribOps::zero<EMB,PFP>(); EMB center = AttribOps::zero<EMB,PFP>();
unsigned int count = 0 ; unsigned int count = 0 ;
Dart it = d ; Traversor2FV<typename PFP::MAP> t(map, d) ;
do for(Dart it = t.begin(); it != t.end(); it = t.next())
{ {
center += attributs[it]; center += attributs[it];
++count ; ++count ;
it = map.phi1(it) ; }
} while(it != d) ;
center /= double(count); center /= double(count);
return center ; return center ;
} }
...@@ -114,13 +115,12 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at ...@@ -114,13 +115,12 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at
{ {
EMB center = AttribOps::zero<EMB,PFP>(); EMB center = AttribOps::zero<EMB,PFP>();
unsigned int count = 0 ; unsigned int count = 0 ;
Dart it = d ; Traversor2VVaE<typename PFP::MAP> t(map, d) ;
do for(Dart it = t.begin(); it != t.end(); it = t.next())
{ {
center += attributs[map.phi1(it)]; center += attributs[it];
++count ; ++count ;
it = map.alpha1(it) ; }
} while(it != d) ;
center /= count ; center /= count ;
return center ; return center ;
} }
...@@ -128,42 +128,33 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at ...@@ -128,42 +128,33 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at
template <typename PFP> template <typename PFP>
void computeCentroidVolumes(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vol_centroid, const FunctorSelect& select) void computeCentroidVolumes(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vol_centroid, const FunctorSelect& select)
{ {
CellMarker marker(map, VOLUME) ; TraversorW<typename PFP::MAP> t(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d) && !marker.isMarked(d)) if(select(d))
{
marker.mark(d);
vol_centroid[d] = volumeCentroid<PFP>(map, d, position) ; vol_centroid[d] = volumeCentroid<PFP>(map, d, position) ;
}
} }
} }
template <typename PFP> template <typename PFP>
void computeCentroidFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_centroid, const FunctorSelect& select) void computeCentroidFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_centroid, const FunctorSelect& select)
{ {
CellMarker marker(map, FACE) ; TraversorF<typename PFP::MAP> t(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d) && !marker.isMarked(d)) if(select(d))
{
marker.mark(d);
face_centroid[d] = faceCentroid<PFP>(map, d, position) ; face_centroid[d] = faceCentroid<PFP>(map, d, position) ;
}
} }
} }
template <typename PFP> template <typename PFP>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vertex_centroid, const FunctorSelect& select) void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vertex_centroid, const FunctorSelect& select)
{ {
CellMarker marker(map, VERTEX) ; TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d) && !marker.isMarked(d)) if(select(d))
{
marker.mark(d);
vertex_centroid[d] = vertexNeighborhoodCentroid<PFP>(map, d, position) ; vertex_centroid[d] = vertexNeighborhoodCentroid<PFP>(map, d, position) ;
}
} }
} }
......
...@@ -72,15 +72,12 @@ private: ...@@ -72,15 +72,12 @@ private:
public: public:
Traversor2VF(MAP& map, Dart dart) : m(map), start(dart) Traversor2VF(MAP& map, Dart dart) : m(map), start(dart)
{}
Dart begin()
{ {
current = start ; if(m.isBoundaryMarked(start)) // jump over a boundary face
if(m.isBoundaryMarked(current)) // jump over a boundary face start = m.alpha1(start) ;
current = m.alpha1(current) ;
return current ;
} }
Dart begin() { current = start ; return current ; }
Dart end() { return NIL ; } Dart end() { return NIL ; }
Dart next() Dart next()
{ {
...@@ -213,7 +210,10 @@ private: ...@@ -213,7 +210,10 @@ private:
public: public:
Traversor2EF(MAP& map, Dart dart) : m(map), start(dart) Traversor2EF(MAP& map, Dart dart) : m(map), start(dart)
{} {
if(m.isBoundaryMarked(start))
start = m.phi2(current) ;
}
Dart begin() { current = start ; return current ; } Dart begin() { current = start ; return current ; }
Dart end() { return NIL ; } Dart end() { return NIL ; }
......
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