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

Selector in Traversor

parent 307472d9
......@@ -62,10 +62,8 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ;
TraversorF<MAP> t(map) ;
TraversorF<MAP> t(map, good) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d))
{
std::vector<unsigned int> fidx ;
fidx.reserve(8) ;
......@@ -86,7 +84,6 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
}
}
out << "ply" << std::endl ;
out << "format ascii 1.0" << std::endl ;
......@@ -140,10 +137,8 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
vertices.reserve(nbDarts/6) ;
CellMarker markV(map, VERTEX) ;
TraversorF<MAP> t(map) ;
TraversorF<MAP> t(map, good) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(good(d))
{
std::vector<unsigned int> fidx ;
fidx.reserve(8) ;
......@@ -164,7 +159,6 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
}
}
out << "OFF" << std::endl ;
out << vertices.size() << " " << facesSize.size() << " " << 0 << std::endl ;
......@@ -201,12 +195,10 @@ bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
verticesBuffer.reserve(nbDarts/5); // TODO non optimal reservation
indicesBuffer.reserve(nbDarts/3);
CellMarker markV(map,VERTEX);
TraversorF<MAP> t(map) ;
CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map, good) ;
unsigned int lab = 0;
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())
......@@ -223,7 +215,6 @@ bool exportCTM(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
indicesBuffer.push_back(tableVertLab[it]);
}
}
}
// Save the file using the OpenCTM API
CTMexporter ctm;
......@@ -274,12 +265,10 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
faces.reserve(nbDarts/3);
CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map) ;
TraversorF<MAP> t(map, good) ;
unsigned int lab = 0;
unsigned int nbf = 0;
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) ;
......@@ -300,7 +289,6 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
++nbf;
}
}
TVEC3 frame[3] ;
TVEC3 colorPTM[15] ;
......@@ -415,12 +403,10 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
faces.reserve(nbDarts/3);
CellMarker markV(map, VERTEX);
TraversorF<MAP> t(map) ;
TraversorF<MAP> t(map, good) ;
unsigned int lab = 0;
unsigned int nbf = 0;
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) ;
......@@ -441,7 +427,6 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
++nbf;
}
}
out << "ply" << std::endl ;
out << "format ascii 1.0" << std::endl ;
......
......@@ -48,10 +48,8 @@ void filterAverageAttribute_OneRing(
FunctorAverage<T> fa(attIn) ;
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())
{
if(select(d))
{
if (neigh & INSIDE)
col.collectAll(d) ;
......@@ -78,7 +76,6 @@ void filterAverageAttribute_OneRing(
col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
}
}
template <typename PFP, typename T>
......@@ -95,10 +92,8 @@ void filterAverageVertexAttribute_WithinSphere(
FunctorAverageOnSphereBorder<PFP, T> faBorder(map, attIn, position) ;
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())
{
if(select(d))
{
if (neigh & INSIDE)
col.collectAll(d) ;
......@@ -118,7 +113,6 @@ void filterAverageVertexAttribute_WithinSphere(
}
attOut[d] /= faInside.getCount() + faBorder.getCount() ;
}
}
}
template <typename PFP, typename T>
......@@ -134,10 +128,8 @@ void filterAverageEdgeAttribute_WithinSphere(
FunctorAverage<T> fa(attIn) ;
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())
{
if(select(d))
{
if (neigh & INSIDE)
col.collectAll(d) ;
......@@ -149,7 +141,6 @@ void filterAverageEdgeAttribute_WithinSphere(
if (neigh & BORDER) col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
}
}
template <typename PFP, typename T>
......@@ -165,10 +156,8 @@ void filterAverageFaceAttribute_WithinSphere(
FunctorAverage<T> fa(attIn) ;
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())
{
if(select(d))
{
if (neigh & INSIDE)
col.collectAll(d) ;
......@@ -180,7 +169,6 @@ void filterAverageFaceAttribute_WithinSphere(
if (neigh & BORDER) col.applyOnBorder(fa) ;
attOut[d] = fa.getAverage() ;
}
}
}
} // namespace Filtering
......
......@@ -52,10 +52,8 @@ void computeNewPositionsFromFaceNormals(
typedef typename PFP::VEC3 VEC3 ;
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())
{
if(select(d))
{
const VEC3& pos_d = position[d] ;
......@@ -74,7 +72,6 @@ void computeNewPositionsFromFaceNormals(
displ /= sumAreas ;
position2[d] = pos_d + displ ;
}
}
}
template <typename PFP>
......@@ -94,10 +91,8 @@ void filterAverageNormals(typename PFP::MAP& map, const typename PFP::TVEC3& pos
AutoAttributeHandler<VEC3> faceNewNormal(map, FACE, "faceNewNormal") ;
// 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())
{
if(select(d))
{
REAL sumArea = 0 ;
VEC3 meanFilter(0) ;
......@@ -116,7 +111,6 @@ void filterAverageNormals(typename PFP::MAP& map, const typename PFP::TVEC3& pos
// and store it
faceNewNormal[d] = meanFilter ;
}
}
// Compute new vertices position
computeNewPositionsFromFaceNormals<PFP>(
......@@ -141,10 +135,8 @@ void filterMMSE(typename PFP::MAP& map, float sigmaN2, const typename PFP::TVEC3
AutoAttributeHandler<VEC3> faceNewNormal(map, FACE, "faceNewNormal") ;
// 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())
{
if( select(d))
{
// traversal of neighbour vertices
REAL sumArea = 0 ;
......@@ -204,7 +196,6 @@ void filterMMSE(typename PFP::MAP& map, float sigmaN2, const typename PFP::TVEC3
newNormal.normalize() ;
faceNewNormal[d] = newNormal ;
}
}
// Compute new vertices position
computeNewPositionsFromFaceNormals<PFP>(
......@@ -233,10 +224,8 @@ void filterTNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
long nbAdapt = 0 ;
long nbSusan = 0 ;
TraversorF<typename PFP::MAP> tf(map) ;
TraversorF<typename PFP::MAP> tf(map, select) ;
for(Dart d = tf.begin(); d != tf.end(); d = tf.next())
{
if( select(d))
{
const VEC3& normF = faceNormal[d] ;
......@@ -323,7 +312,6 @@ void filterTNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
faceNewNormal[d] = normF ;
}
}
}
// Compute new vertices position
computeNewPositionsFromFaceNormals<PFP>(
......@@ -358,10 +346,8 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
std::cout << "compute new vertices normals.." << std::endl ;
TraversorV<typename PFP::MAP> tv(map) ;
TraversorV<typename PFP::MAP> tv(map, select) ;
for(Dart d = tv.begin(); d != tv.end(); d = tv.next())
{
if(select(d))
{
const VEC3& normV = normal[d] ;
......@@ -447,15 +433,12 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
vertexNewNormal[d] = normV ;
}
}
}
std::cout << "update face normals.." << std::endl ;
// Compute face normals from vertex 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())
{
if (select(d))
{
VEC3 newNormal(0) ;
REAL totArea = 0 ;
......@@ -471,7 +454,6 @@ void filterVNBA(typename PFP::MAP& map, float sigmaN2, float SUSANthreshold, con
newNormal.normalize() ;
faceNewNormal[d] = newNormal ;
}
}
std::cout << "update vertices positions.." << std::endl ;
......
......@@ -43,16 +43,13 @@ void sigmaBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position,
float sumAngles = 0.0f ;
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())
{
if(select(d))
{
sumLengths += Algo::Geometry::edgeLength<PFP>(map, d, position) ;
sumAngles += Geom::angle(normal[d], normal[map.phi1(d)]) ;
++nbEdges ;
}
}
// update of returned values
sigmaC = 1.0f * ( sumLengths / float(nbEdges) ) ;
......@@ -67,10 +64,8 @@ void filterBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position
float sigmaC, sigmaS ;
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())
{
if(select(d))
{
// get position & normal of vertex
const VEC3& pos_d = position[d] ;
......@@ -91,7 +86,6 @@ void filterBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position
position2[d] = pos_d + ((sum / normalizer) * normal_d) ;
}
}
}
template <typename PFP>
......@@ -105,10 +99,8 @@ void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const typename PF
long nbTot = 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())
{
if(select(d))
{
// get position & normal of vertex
const VEC3& pos_d = position[d] ;
......@@ -144,7 +136,6 @@ void filterSUSAN(typename PFP::MAP& map, float SUSANthreshold, const typename PF
else
position2[d] = pos_d ;
}
}
// CGoGNout <<" susan rate = "<< float(nbSusan)/float(nbTot)<<CGoGNendl;
}
......
......@@ -72,12 +72,9 @@ template <typename PFP>
typename PFP::REAL totalArea(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& select, unsigned int thread)
{
typename PFP::REAL area(0) ;
TraversorF<typename PFP::MAP> t(map) ;
TraversorF<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d))
area += convexFaceArea<PFP>(map, d, position) ;
}
return area ;
}
......@@ -132,45 +129,33 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typen
template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& face_area, const FunctorSelect& select)
{
TraversorF<typename PFP::MAP> t(map) ;
TraversorF<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d))
face_area[d] = convexFaceArea<PFP>(map, d, position) ;
}
}
template <typename PFP>
void computeOneRingAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& 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())
{
if(select(d))
vertex_area[d] = vertexOneRingArea<PFP>(map, d, position) ;
}
}
template <typename PFP>
void computeBarycentricAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& 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())
{
if(select(d))
vertex_area[d] = vertexBarycentricArea<PFP>(map, d, position) ;
}
}
template <typename PFP>
void computeVoronoiAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& 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())
{
if(select(d))
vertex_area[d] = vertexVoronoiArea<PFP>(map, d, position) ;
}
}
} // namespace Geometry
......
......@@ -42,12 +42,9 @@ template <typename PFP>
Geom::BoundingBox<typename PFP::VEC3> computeBoundingBox(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& select = SelectorTrue())
{
Geom::BoundingBox<typename PFP::VEC3> bb ;
TraversorV<typename PFP::MAP> t(map) ;
TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d))
bb.addPoint(position[d]) ;
}
return bb ;
}
......
......@@ -128,34 +128,25 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at
template <typename PFP>
void computeCentroidVolumes(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vol_centroid, const FunctorSelect& select)
{
TraversorW<typename PFP::MAP> t(map) ;
TraversorW<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d))
vol_centroid[d] = volumeCentroid<PFP>(map, d, position) ;
}
}
template <typename PFP>
void computeCentroidFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_centroid, const FunctorSelect& select)
{
TraversorF<typename PFP::MAP> t(map) ;
TraversorF<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d))
face_centroid[d] = faceCentroid<PFP>(map, d, position) ;
}
}
template <typename PFP>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vertex_centroid, const FunctorSelect& 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())
{
if(select(d))
vertex_centroid[d] = vertexNeighborhoodCentroid<PFP>(map, d, position) ;
}
}
} // namespace Geometry
......
......@@ -56,12 +56,9 @@ void computeCurvatureVertices_QuadraticFitting(
typename PFP::TVEC3& Kmin,
const FunctorSelect& 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())
{
if(select(d))
computeCurvatureVertex_QuadraticFitting<PFP>(map, d, position, normal, kmax, kmin, Kmax, Kmin) ;
}
}
template <typename PFP>
......@@ -292,14 +289,11 @@ void computeCurvatureVertices_NormalCycles(
typename PFP::TVEC3& Kmax,
typename PFP::TVEC3& Kmin,
typename PFP::TVEC3& Knormal,
const FunctorSelect& select = SelectorTrue())
const FunctorSelect& 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())
{
if(select(d))
computeCurvatureVertex_NormalCycles<PFP>(map, d, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal) ;
}
}
template <typename PFP>
......
......@@ -88,12 +88,9 @@ void computeLaplacianTopoVertices(
AttributeHandler<ATTR_TYPE>& laplacian,
const FunctorSelect& 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())
{
if(select(d))
laplacian[d] = computeLaplacianTopoVertex<PFP, ATTR_TYPE>(map, d, attr) ;
}
}
template <typename PFP, typename ATTR_TYPE>
......@@ -105,12 +102,9 @@ void computeLaplacianCotanVertices(
AttributeHandler<ATTR_TYPE>& laplacian,
const FunctorSelect& 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())
{
if(select(d))
laplacian[d] = computeLaplacianCotanVertex<PFP, ATTR_TYPE>(map, d, edgeWeight, vertexArea, attr) ;
}
}
template <typename PFP>
......@@ -150,12 +144,9 @@ void computeCotanWeightEdges(
typename PFP::TREAL& edgeWeight,
const FunctorSelect& select = SelectorTrue())
{
TraversorE<typename PFP::MAP> t(map) ;
TraversorE<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d))
edgeWeight[d] = computeCotanWeightEdge<PFP>(map, d, position) ;
}
}
} // namespace Geometry
......
......@@ -116,23 +116,17 @@ typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const typename P
template <typename PFP>
void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_normal, const FunctorSelect& select, unsigned int thread)
{
TraversorF<typename PFP::MAP> trav(map, thread);
TraversorF<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
if (select(d))
face_normal[d] = faceNormal<PFP>(map, d, position) ;
}
}
template <typename PFP>
void computeNormalVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& normal, const FunctorSelect& select, unsigned int thread)
{
TraversorV<typename PFP::MAP> trav(map, thread);
TraversorV<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
if (select(d))
normal[d] = vertexNormal<PFP>(map, d, position) ;
}
}
template <typename PFP>
......@@ -169,12 +163,9 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart
template <typename PFP>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, typename PFP::TVEC3& position, typename PFP::TREAL& angles, const FunctorSelect& select, unsigned int thread)
{
TraversorE<typename PFP::MAP> trav(map, thread);
TraversorE<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
if (select(d))
angles[d] = computeAngleBetweenNormalsOnEdge<PFP>(map, d, position) ;
}
}
} // namespace Geometry
......
......@@ -117,12 +117,9 @@ template <typename PFP>
float totalVolume(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& select)
{
typename PFP::REAL vol = 0 ;
TraversorW<typename PFP::MAP> t(map) ;
TraversorW<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(select(d))
vol += convexPolyhedronVolume<PFP>(map, d, position) ;
}
return vol ;
}
......