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

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() ;
}
} }
} }
......
...@@ -52,28 +52,25 @@ void computeNewPositionsFromFaceNormals( ...@@ -52,28 +52,25 @@ void computeNewPositionsFromFaceNormals(
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ; typedef typename PFP::REAL REAL ;
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)) const VEC3& pos_d = position[d] ;
{
const VEC3& pos_d = position[d] ;
VEC3 displ(0) ; VEC3 displ(0) ;
REAL sumAreas = 0 ; REAL sumAreas = 0 ;
Traversor2VF<typename PFP::MAP> tvf(map, d) ; Traversor2VF<typename PFP::MAP> tvf(map, d) ;
for(Dart it = tvf.begin(); it != tvf.end(); it = tvf.next()) for(Dart it = tvf.begin(); it != tvf.end(); it = tvf.next())
{ {
sumAreas += faceArea[it] ; sumAreas += faceArea[it] ;
VEC3 vT = faceCentroid[it] - pos_d ; VEC3 vT = faceCentroid[it] - pos_d ;
vT = (vT * faceNewNormal[it]) * faceNormal[it] ; vT = (vT * faceNewNormal[it]) * faceNormal[it] ;
displ += faceArea[it] * vT ; displ += faceArea[it] * vT ;
}
displ /= sumAreas ;
position2[d] = pos_d + displ ;
} }
displ /= sumAreas ;
position2[d] = pos_d + displ ;
} }
} }
...@@ -94,28 +91,25 @@ void filterAverageNormals(typename PFP::MAP& map, const typename PFP::TVEC3& pos ...@@ -94,28 +91,25 @@ void filterAverageNormals(typename PFP::MAP& map, const typename PFP::TVEC3& pos
AutoAttributeHandler<VEC3> faceNewNormal(map, FACE, "faceNewNormal") ; AutoAttributeHandler<VEC3> faceNewNormal(map, FACE, "faceNewNormal") ;
// Compute new normals // Compute new normals
TraversorF<typename PFP::MAP> tf(map) ; TraversorF<typename PFP::MAP> tf(map, select) ;
for(Dart d = tf.begin(); d != tf.end(); d = tf.next()) for(Dart d = tf.begin(); d != tf.end(); d = tf.next())
{ {
if(select(d)) REAL sumArea = 0 ;
{ VEC3 meanFilter(0) ;
REAL sumArea = 0 ;
VEC3 meanFilter(0) ;
// traversal of adjacent faces (by edges and vertices)
Traversor2FFaV<typename PFP::MAP> taf(map, d) ;
for(Dart it = taf.begin(); it != taf.end(); it = taf.next())
{
sumArea += faceArea[it] ;
meanFilter += faceArea[it] * faceNormal[it] ;
}
// finalize the computation of meanFilter normal // traversal of adjacent faces (by edges and vertices)
meanFilter /= sumArea ; Traversor2FFaV<typename PFP::MAP> taf(map, d) ;
meanFilter.normalize() ; for(Dart it = taf.begin(); it != taf.end(); it = taf.next())
// and store it {
faceNewNormal[d] = meanFilter ; sumArea += faceArea[it] ;
meanFilter += faceArea[it] * faceNormal[it] ;
} }
// finalize the computation of meanFilter normal
meanFilter /= sumArea ;
meanFilter.normalize() ;
// and store it
faceNewNormal[d] = meanFilter ;
} }
// Compute new vertices position // Compute new vertices position
...@@ -141,69 +135,66 @@ void filterMMSE(typename PFP::MAP& map, float sigmaN2, const typename PFP::TVEC3 ...@@ -141,69 +135,66 @@ void filterMMSE(typename PFP::MAP& map, float sigmaN2, const typename PFP::TVEC3
AutoAttributeHandler<VEC3> faceNewNormal(map, FACE, "faceNewNormal") ; AutoAttributeHandler<VEC3> faceNewNormal(map, FACE, "faceNewNormal") ;
// Compute new normals // Compute new normals
TraversorF<typename PFP::MAP> tf(map) ; TraversorF<typename PFP::MAP> tf(map, select) ;
for(Dart d = tf.begin(); d != tf.end(); d = tf.next()) for(Dart d = tf.begin(); d != tf.end(); d = tf.next())
{ {
if( select(d)) // traversal of neighbour vertices
{ REAL sumArea = 0 ;
// traversal of neighbour vertices REAL sigmaX2 = 0 ;
REAL sumArea = 0 ; REAL sigmaY2 = 0 ;
REAL sigmaX2 = 0 ; REAL sigmaZ2 = 0 ;
REAL sigmaY2 = 0 ;
REAL sigmaZ2 = 0 ;
VEC3 meanFilter(0) ; VEC3 meanFilter(0) ;
// traversal of adjacent faces (by edges and vertices) // traversal of adjacent faces (by edges and vertices)
Traversor2FFaV<typename PFP::MAP> taf(map, d) ; Traversor2FFaV<typename PFP::MAP> taf(map, d) ;
for(Dart it = taf.begin(); it != taf.end(); it = taf.next()) for(Dart it = taf.begin(); it != taf.end(); it = taf.next())
{