本文整理汇总了C++中MyMesh::request_vertex_normals方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMesh::request_vertex_normals方法的具体用法?C++ MyMesh::request_vertex_normals怎么用?C++ MyMesh::request_vertex_normals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMesh
的用法示例。
在下文中一共展示了MyMesh::request_vertex_normals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BilateralDenoise
/*Get normal vectors from OpenMesh library
-> bilateral filter denoising of vertices*/
void BilateralDenoise(MyMesh &mesh)
{
/*ANN kd-tree find nearest point*/
ANNpointArray meshArray; // mesh points array
ANNpoint Pt; // point
ANNkd_tree* kdTree; // search structure
int PtNum = mesh.n_vertices();
meshArray = annAllocPts(PtNum, dim);
Pt = annAllocPt(dim);
//assign mesh points to ANN array
for (auto it = mesh.vertices_begin(); it != mesh.vertices_end(); ++it)
{
//Pt get the space of data array
double getPt[3] = {};
//Pt get the coordinates of mesh point
int index = it->idx();
Pt = meshArray[index];
for(int d = 0;d < dim; d++)
{
getPt[d] = *(mesh.point(it).data()+d);
Pt[d] = getPt[d];
}
//assign Pt coordinates to data array
meshArray[index] = Pt;
}
//build kd-tree
kdTree = new ANNkd_tree( // build search structure
meshArray, // the data points
PtNum, // number of points
dim); // dimension of space
/*Request vertex normal*/
// request vertex normals, so the mesh reader can use normal information
// if available
mesh.request_vertex_normals();
OpenMesh::IO::Options opt;
// If the file did not provide vertex normals, then calculate them
if ( !opt.check( OpenMesh::IO::Options::VertexNormal ) )
{
// we need face normals to update the vertex normals
mesh.request_face_normals();
// let the mesh update the normals
mesh.update_normals();
// dispose the face normals, as we don't need them anymore
mesh.release_face_normals();
}
/*Bilateral filtering*/
//initial parameters for denoising
double radius = 0.0;
double sigma_c = 0.05; //depend on the distance of the points
double sigma_s = 0.0;
int neighbour_num = 12;
//get certain neighbour and denoise
for (auto it = mesh.vertices_begin(); it != mesh.vertices_end(); ++it)
{
//Pt get the coordinates from mesh array
int index = it->idx();
Pt = meshArray[index];
std::vector<MyMesh::Point> neighbours;
vector<double> distVector;
//Find K(neighbours for normal calculation) nearest neighbours,
//return neighbours,distVector,radius
FindNeighbours(neighbour_num,kdTree,meshArray,Pt,
neighbours,distVector,radius);
//get height from current vertex to tangent plane
//update neighbour number
neighbour_num = neighbours.size();
vector<double> height;
double mean_height = 0.0;
for(int i=0;i<neighbour_num;i++)
{
MyMesh::Point current_neighbour;
current_neighbour = neighbours.at(i);
//get normal vector from normal mesh
double normal_vector[3]={};
normal_vector[0]= *mesh.normal(it).data();
normal_vector[1]= *(mesh.normal(it).data()+1);
normal_vector[2]= *(mesh.normal(it).data()+2);
//calculate height
height.push_back((Pt[0]-current_neighbour.data()[0])*normal_vector[0]+(Pt[1]-current_neighbour.data()[1])*normal_vector[1]+(Pt[2]-current_neighbour.data()[2])*normal_vector[2]);
mean_height += height.at(i);
}
//Calculate standard deviation(sigma_s)
mean_height /= neighbour_num;
//.........这里部分代码省略.........