Corrected missing template and typename keyword and added function to just select the points
This commit is contained in:
parent
12c1495bb0
commit
d15745b128
|
@ -21,7 +21,7 @@
|
|||
* *
|
||||
****************************************************************************/
|
||||
#ifndef VCG_TRI_OUTLIERS__H
|
||||
#define VCG_TRI_OUTLIERS_H
|
||||
#define VCG_TRI_OUTLIERS__H
|
||||
|
||||
#include <vcg/space/index/kdtree/kdtree.h>
|
||||
|
||||
|
@ -53,9 +53,9 @@ class OutlierRemoval
|
|||
static void ComputeLoOPScore(MeshType& mesh, KdTreeType& kdTree, int kNearest)
|
||||
{
|
||||
vcg::tri::RequireCompactness(mesh);
|
||||
CMesh::PerVertexAttributeHandle<ScalarType> outlierScore = vcg::tri::Allocator<MeshType>::GetPerVertexAttribute<ScalarType>(mesh, std::string("outlierScore"));
|
||||
CMesh::PerVertexAttributeHandle<ScalarType> sigma = vcg::tri::Allocator<MeshType>::GetPerVertexAttribute<ScalarType>(mesh, std::string("sigma"));
|
||||
CMesh::PerVertexAttributeHandle<ScalarType> plof = vcg::tri::Allocator<MeshType>::GetPerVertexAttribute<ScalarType>(mesh, std::string("plof"));
|
||||
typename MeshType::template PerVertexAttributeHandle<ScalarType> outlierScore = tri::Allocator<MeshType>:: template GetPerVertexAttribute<ScalarType>(mesh, std::string("outlierScore"));
|
||||
typename MeshType::template PerVertexAttributeHandle<ScalarType> sigma = tri::Allocator<MeshType>:: template GetPerVertexAttribute<ScalarType>(mesh, std::string("sigma"));
|
||||
typename MeshType::template PerVertexAttributeHandle<ScalarType> plof = tri::Allocator<MeshType>:: template GetPerVertexAttribute<ScalarType>(mesh, std::string("plof"));
|
||||
|
||||
#pragma omp parallel for schedule(dynamic, 10)
|
||||
for (int i = 0; i < mesh.vert.size(); i++)
|
||||
|
@ -98,31 +98,45 @@ class OutlierRemoval
|
|||
outlierScore[i] = op;
|
||||
}
|
||||
|
||||
vcg::tri::Allocator<CMesh>::DeletePerVertexAttribute(mesh, std::string("sigma"));
|
||||
vcg::tri::Allocator<CMesh>::DeletePerVertexAttribute(mesh, std::string("plof"));
|
||||
tri::Allocator<MeshType>::DeletePerVertexAttribute(mesh, std::string("sigma"));
|
||||
tri::Allocator<MeshType>::DeletePerVertexAttribute(mesh, std::string("plof"));
|
||||
};
|
||||
|
||||
/**
|
||||
Select all the vertex of the mesh with an outlier probability above the input threshold [0.0, 1.0].
|
||||
*/
|
||||
static int SelectLoOPOutliers(MeshType& mesh, KdTreeType& kdTree, int kNearest, float threshold)
|
||||
{
|
||||
ComputeLoOPScore(mesh, kdTree, kNearest);
|
||||
int count = 0;
|
||||
typename MeshType:: template PerVertexAttributeHandle<ScalarType> outlierScore = tri::Allocator<MeshType>::template GetPerVertexAttribute<ScalarType>(mesh, std::string("outlierScore"));
|
||||
for (int i = 0; i < mesh.vert.size(); i++)
|
||||
{
|
||||
if (outlierScore[i] > threshold)
|
||||
{
|
||||
mesh.vert[i].SetS();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Delete all the vertex of the mesh with an outlier probability above the input threshold [0.0, 1.0].
|
||||
*/
|
||||
static int DeleteLoOPOutliers(MeshType& mesh, KdTreeType& kdTree, int kNearest, float threshold)
|
||||
static int DeleteLoOPOutliers(MeshType& m, KdTreeType& kdTree, int kNearest, float threshold)
|
||||
{
|
||||
ComputeLoOPScore(mesh, kdTree, kNearest);
|
||||
int count = 0;
|
||||
CMesh::PerVertexAttributeHandle<ScalarType> outlierScore = vcg::tri::Allocator<MeshType>::GetPerVertexAttribute<ScalarType>(mesh, std::string("outlierScore"));
|
||||
for (int i = 0; i < mesh.vert.size(); i++)
|
||||
{
|
||||
if (outlierScore[i] > threshold)
|
||||
{
|
||||
vcg::tri::Allocator<CMesh>::DeleteVertex(mesh, mesh.vert[i]);
|
||||
count++;
|
||||
SelectLoOPOutliers(m,kdTree,kNearest,threshold);
|
||||
int ovn = m.vn;
|
||||
|
||||
for(typename MeshType::VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||
if((*vi).IsS() ) tri::Allocator<MeshType>::DeleteVertex(m,*vi);
|
||||
tri::Allocator<MeshType>::CompactVertexVector(m);
|
||||
tri::Allocator<MeshType>::DeletePerVertexAttribute(m, std::string("outlierScore"));
|
||||
return m.vn - ovn;
|
||||
}
|
||||
}
|
||||
vcg::tri::Allocator<CMesh>::CompactVertexVector(mesh);
|
||||
vcg::tri::Allocator<CMesh>::DeletePerVertexAttribute(mesh, std::string("outlierScore"));
|
||||
return count;
|
||||
};
|
||||
};
|
||||
|
||||
} // end namespace tri
|
||||
|
|
Loading…
Reference in New Issue