Commit 72d6f882 authored by Pierre Kraemer's avatar Pierre Kraemer

Selector in Traversor

parent 307472d9
...@@ -62,30 +62,27 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons ...@@ -62,30 +62,27 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ; vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ; CellMarker markV(map, VERTEX) ;
TraversorF<MAP> t(map) ; TraversorF<MAP> t(map, good) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(good(d)) std::vector<unsigned int> fidx ;
fidx.reserve(8) ;
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
std::vector<unsigned int> fidx ; ++degree ;
fidx.reserve(8) ; unsigned int vNum = map.getEmbedding(VERTEX, it) ;
unsigned int degree = 0 ; if(!markV.isMarked(it))
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
++degree ; markV.mark(it) ;
unsigned int vNum = map.getEmbedding(VERTEX, it) ; vIndex[vNum] = vCpt++ ;
if(!markV.isMarked(it)) vertices.push_back(vNum) ;
{
markV.mark(it) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
} }
facesSize.push_back(degree) ; fidx.push_back(vIndex[vNum]) ;
facesIdx.push_back(fidx) ;
} }
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
} }
out << "ply" << std::endl ; out << "ply" << std::endl ;
...@@ -140,30 +137,27 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons ...@@ -140,30 +137,27 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ; vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ; CellMarker markV(map, VERTEX) ;
TraversorF<MAP> t(map) ; TraversorF<MAP> t(map, good) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(good(d)) std::vector<unsigned int> fidx ;
fidx.reserve(8) ;
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
std::vector<unsigned int> fidx ; ++degree ;
fidx.reserve(8) ; unsigned int vNum = map.getEmbedding(VERTEX, it) ;
unsigned int degree = 0 ; if(!markV.isMarked(it))
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
++degree ; markV.mark(it) ;
unsigned int vNum = map.getEmbedding(VERTEX, it) ; vIndex[vNum] = vCpt++ ;
if(!markV.isMarked(it)) vertices.push_back(vNum) ;
{
markV.mark(it) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
} }
facesSize.push_back(degree) ; fidx.push_back(vIndex[vNum]) ;
facesIdx.push_back(fidx) ;
} }
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
} }
out << "OFF" << std::endl ; out << "OFF" << std::endl ;
...@@ -201,27 +195,24 @@ bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons ...@@ -201,27 +195,24 @@ bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
verticesBuffer.reserve(nbDarts/5); // TODO non optimal reservation verticesBuffer.reserve(nbDarts/5); // TODO non optimal reservation
indicesBuffer.reserve(nbDarts/3); indicesBuffer.reserve(nbDarts/3);
CellMarker markV(map,VERTEX); CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map) ; TraversorF<MAP> t(map, good) ;
unsigned int lab = 0; unsigned int lab = 0;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(good(d)) Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
Traversor2FV<typename PFP::MAP> tfv(map, d) ; if (!markV.isMarked(it))
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
if (!markV.isMarked(it)) markV.mark(it);
{ tableVertLab[it] = lab++;
markV.mark(it); const VEC3& vert = position[it];
tableVertLab[it] = lab++; verticesBuffer.push_back(vert[0]);
const VEC3& vert = position[it]; verticesBuffer.push_back(vert[1]);
verticesBuffer.push_back(vert[0]); verticesBuffer.push_back(vert[2]);
verticesBuffer.push_back(vert[1]);
verticesBuffer.push_back(vert[2]);
}
indicesBuffer.push_back(tableVertLab[it]);
} }
indicesBuffer.push_back(tableVertLab[it]);
} }
} }
...@@ -274,32 +265,29 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ ...@@ -274,32 +265,29 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
faces.reserve(nbDarts/3); faces.reserve(nbDarts/3);
CellMarker markV(map, VERTEX); CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map) ; TraversorF<MAP> t(map, good) ;
unsigned int lab = 0; unsigned int lab = 0;
unsigned int nbf = 0; unsigned int nbf = 0;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(good(d)) std::vector<unsigned int> face ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
std::vector<unsigned int> face ; if (!markV.isMarked(it))
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
if (!markV.isMarked(it)) markV.mark(it);
{ tableVertLab[it] = lab++;
markV.mark(it); vertices.push_back(map.getEmbedding(VERTEX, it));
tableVertLab[it] = lab++;
vertices.push_back(map.getEmbedding(VERTEX, it));
}
face.push_back(tableVertLab[it]);
} }
face.push_back(tableVertLab[it]);
}
faces.push_back(face.size()) ; faces.push_back(face.size()) ;
for (unsigned int i = 0 ; i < face.size() ; ++i) for (unsigned int i = 0 ; i < face.size() ; ++i)
faces.push_back(face.at(i)) ; faces.push_back(face.at(i)) ;
++nbf; ++nbf;
}
} }
TVEC3 frame[3] ; TVEC3 frame[3] ;
...@@ -415,32 +403,29 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P ...@@ -415,32 +403,29 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
faces.reserve(nbDarts/3); faces.reserve(nbDarts/3);
CellMarker markV(map, VERTEX); CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map) ; TraversorF<MAP> t(map, good) ;
unsigned int lab = 0; unsigned int lab = 0;
unsigned int nbf = 0; unsigned int nbf = 0;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(good(d)) std::vector<unsigned int> face ;
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
std::vector<unsigned int> face ; if (!markV.isMarked(it))
Traversor2FV<typename PFP::MAP> tfv(map, d) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{ {
if (!markV.isMarked(it)) markV.mark(it);
{ tableVertLab[it] = lab++;
markV.mark(it); vertices.push_back(map.getEmbedding(VERTEX, it));
tableVertLab[it] = lab++;
vertices.push_back(map.getEmbedding(VERTEX, it));
}
face.push_back(tableVertLab[it]);
} }
face.push_back(tableVertLab[it]);
}
faces.push_back(face.size()) ; faces.push_back(face.size()) ;
for (unsigned int i = 0 ; i < face.size() ; ++i) for (unsigned int i = 0 ; i < face.size() ; ++i)
faces.push_back(face.at(i)) ; faces.push_back(face.at(i)) ;
++nbf; ++nbf;
}
} }
out << "ply" << std::endl ; out << "ply" << std::endl ;
......
...@@ -48,36 +48,33 @@ void filterAverageAttribute_OneRing( ...@@ -48,36 +48,33 @@ void filterAverageAttribute_OneRing(
FunctorAverage<T> fa(attIn) ; FunctorAverage<T> fa(attIn) ;
Algo::Selection::Collector_OneRing<PFP> col(map) ; Algo::Selection::Collector_OneRing<PFP> col(map) ;
TraversorV<typename PFP::MAP> t(map) ; TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d)) if (neigh & INSIDE)
{ col.collectAll(d) ;
if (neigh & INSIDE) else
col.collectAll(d) ; col.collectBorder(d) ;
else
col.collectBorder(d) ;
fa.reset() ; fa.reset() ;
if (neigh & INSIDE) if (neigh & INSIDE)
{
switch (attIn.getOrbit())
{ {
switch (attIn.getOrbit()) case VERTEX :
{ col.applyOnInsideVertices(fa) ;
case VERTEX : break;
col.applyOnInsideVertices(fa) ; case EDGE :
break; col.applyOnInsideEdges(fa) ;
case EDGE : break;
col.applyOnInsideEdges(fa) ; case FACE :
break; col.applyOnInsideFaces(fa) ;
case FACE : break;
col.applyOnInsideFaces(fa) ;
break;
}
} }
if (neigh & BORDER)
col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
} }
if (neigh & BORDER)
col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
} }
} }
...@@ -95,29 +92,26 @@ void filterAverageVertexAttribute_WithinSphere( ...@@ -95,29 +92,26 @@ void filterAverageVertexAttribute_WithinSphere(
FunctorAverageOnSphereBorder<PFP, T> faBorder(map, attIn, position) ; FunctorAverageOnSphereBorder<PFP, T> faBorder(map, attIn, position) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ; Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
TraversorV<typename PFP::MAP> t(map) ; TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d)) if (neigh & INSIDE)
{ col.collectAll(d) ;
if (neigh & INSIDE) else
col.collectAll(d) ; col.collectBorder(d) ;
else
col.collectBorder(d) ; attOut[d] = T(0);
if (neigh & INSIDE){
attOut[d] = T(0); faInside.reset() ;
if (neigh & INSIDE){ col.applyOnInsideVertices(faInside) ;
faInside.reset() ; attOut[d] += faInside.getSum();
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() ;
} }
if (neigh & BORDER){
faBorder.reset(position[d], radius);
col.applyOnBorder(faBorder) ;
attOut[d] += faBorder.getSum();
}
attOut[d] /= faInside.getCount() + faBorder.getCount() ;
} }
} }
...@@ -134,21 +128,18 @@ void filterAverageEdgeAttribute_WithinSphere( ...@@ -134,21 +128,18 @@ void filterAverageEdgeAttribute_WithinSphere(
FunctorAverage<T> fa(attIn) ; FunctorAverage<T> fa(attIn) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ; Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
TraversorV<typename PFP::MAP> t(map) ; TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d)) if (neigh & INSIDE)
{ col.collectAll(d) ;
if (neigh & INSIDE) else
col.collectAll(d) ; col.collectBorder(d) ;
else
col.collectBorder(d) ; fa.reset() ;
if (neigh & INSIDE) col.applyOnInsideEdges(fa) ;
fa.reset() ; if (neigh & BORDER) col.applyOnBorder(fa) ;
if (neigh & INSIDE) col.applyOnInsideEdges(fa) ; attOut[d] = fa.getAverage() ;
if (neigh & BORDER) col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
} }
} }
...@@ -165,21 +156,18 @@ void filterAverageFaceAttribute_WithinSphere( ...@@ -165,21 +156,18 @@ void filterAverageFaceAttribute_WithinSphere(
FunctorAverage<T> fa(attIn) ; FunctorAverage<T> fa(attIn) ;
Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ; Algo::Selection::Collector_WithinSphere<PFP> col(map, position, radius) ;
TraversorV<typename PFP::MAP> t(map) ; TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d)) if (neigh & INSIDE)
{ col.collectAll(d) ;
if (neigh & INSIDE) else
col.collectAll(d) ; col.collectBorder(d) ;
else
col.collectBorder(d) ; fa.reset() ;
if (neigh & INSIDE) col.applyOnInsideFaces(fa) ;
fa.reset() ; if (neigh & BORDER) col.applyOnBorder(fa) ;
if (neigh & INSIDE) col.applyOnInsideFaces(fa) ; attOut[d] = fa.getAverage() ;
if (neigh & BORDER) col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
} }
} }
......
This diff is collapsed.
...@@ -43,15 +43,12 @@ void sigmaBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position, ...@@ -43,15 +43,12 @@ void sigmaBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position,
float sumAngles = 0.0f ; float sumAngles = 0.0f ;
long nbEdges = 0 ; long nbEdges = 0 ;
TraversorE<typename PFP::MAP> t(map) ; TraversorE<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(d)) sumLengths += Algo::Geometry::edgeLength<PFP>(map, d, position) ;
{ sumAngles += Geom::angle(normal[d], normal[map.phi1(d)]) ;
sumLengths += Algo::Geometry::edgeLength<PFP>(map, d, position) ; ++nbEdges ;
sumAngles += Geom::angle(normal[d], normal[map.phi1(d)]) ;
++nbEdges ;
}
} }
// update of returned values // update of returned values
...@@ -67,30 +64,27 @@ void filterBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position ...@@ -67,30 +64,27 @@ void filterBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position
float sigmaC, sigmaS ; float sigmaC, sigmaS ;
sigmaBilateral<PFP>(map, position, normal, sigmaC, sigmaS, select) ; sigmaBilateral<PFP>(map, position, normal, sigmaC, sigmaS, select) ;
TraversorV<typename PFP::MAP> t(map) ; TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(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 ;
Traversor2VE<typename PFP::MAP> te(map, d) ;
for(Dart it = te.begin(); it != te.end(); it = te.next())
{ {
// get position & normal of vertex VEC3 vec = Algo::Geometry::vectorOutOfDart<PFP>(map, it, position) ;
const VEC3& pos_d = position[d] ; float h = normal_d * vec ;
const VEC3& normal_d = normal[d] ; float t = vec.norm() ;
float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) ) ;
// traversal of incident edges sum += wcs * h ;
float sum = 0.0f, normalizer = 0.0f ; normalizer += wcs ;
Traversor2VE<typename PFP::MAP> te(map, d) ;
for(Dart it = te.begin(); it != te.end(); it = te.next())
{
VEC3 vec = Algo::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 ;
}
position2[d] = pos_d + ((sum / normalizer) * normal_d) ;
} }
position2[d] = pos_d + ((sum / normalizer) * normal_d) ;
} }
} }
...@@ -105,45 +99,42 @@ void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const typename PF ...@@ -105,45 +99,42 @@ void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const typename PF
long nbTot = 0 ; long nbTot = 0 ;
long nbSusan = 0 ; long nbSusan = 0 ;
TraversorV<typename PFP::MAP> t(map) ; TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) for(Dart d = t.begin(); d != t.end(); d = t.next())
{ {
if(select(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())
{ {
// get position & normal of vertex const VEC3& neighborNormal = normal[map.phi1(it)] ;
const VEC3& pos_d = position[d] ; float angle = Geom::angle(normal_d, neighborNormal) ;
const VEC3& normal_d = normal[d] ; if( angle <= SUSANthreshold )
// 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)] ; VEC3 vec = Algo::Geometry::vectorOutOfDart<PFP>(map, it, position) ;
float angle = Geom::angle(normal_d, neighborNormal) ; float h = normal_d * vec ;
if( angle <= SUSANthreshold ) float t = vec.norm() ;
{ float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) );
VEC3 vec = Algo::Geometry::vectorOutOfDart<PFP>(map, it, position) ; sum += wcs * h ;
float h = normal_d * vec ; normalizer += wcs ;
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 else
position2[d] = pos_d ; SUSANregion = true ;
} }
if(SUSANregion)
nbSusan++ ;
nbTot++ ;