本文整理汇总了C++中MyMesh::fv_iter方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMesh::fv_iter方法的具体用法?C++ MyMesh::fv_iter怎么用?C++ MyMesh::fv_iter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMesh
的用法示例。
在下文中一共展示了MyMesh::fv_iter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RasterizeMesh
/*rasterize the model to 2R*2R*2R voxel grid*/
void RasterizeMesh(MyMesh &mesh,vector<Point> &grid_points)
{
//reserve space
grid_points.reserve(10000);
//create grid
int grid_size = 2*RADIUS*2*RADIUS*2*RADIUS;
bool *grid;
grid = new bool [grid_size];
memset(grid,false,grid_size*sizeof(bool));
for(MyMesh::FaceIter f_it=mesh.faces_begin();f_it!=mesh.faces_end();++f_it)
{
vector<Point> face_points;
for(MyMesh::FaceVertexIter v_it=mesh.fv_iter(f_it);v_it;++v_it)
{
Point temp_face_point;
//scale back from range [0,1] to [0,2R]
temp_face_point.x() = *(mesh.point(v_it).data()+0)*2*RADIUS;
temp_face_point.y() = *(mesh.point(v_it).data()+1)*2*RADIUS;
temp_face_point.z() = *(mesh.point(v_it).data()+2)*2*RADIUS;
face_points.push_back(temp_face_point);
//get grid coordinate
int grid_coordinate = int(temp_face_point.x()*2*RADIUS*2*RADIUS + temp_face_point.y()*2*RADIUS + temp_face_point.z());
//discard points out of range
if(grid_coordinate>(2*RADIUS*2*RADIUS*2*RADIUS-1) || grid_coordinate<0) continue;
//if not registered
if(*(grid+grid_coordinate)!=true)
{
*(grid+grid_coordinate) = true;
grid_points.push_back(temp_face_point);
}
}
//fill the edges for a triangle face
vector<Point> inter12,inter23,inter13;
int n_points12 = fillGridLine(face_points.at(0),face_points.at(1),inter12,grid,grid_points);
int n_points23 = fillGridLine(face_points.at(1),face_points.at(2),inter23,grid,grid_points);
int n_points13 = fillGridLine(face_points.at(0),face_points.at(2),inter13,grid,grid_points);
//fill in the face
if(n_points12>=n_points13 && n_points13>0)
{
for(unsigned int n=0;n<n_points13;n++)
{
vector<Point> temp_inter;
fillGridLine(inter12.at(n),inter13.at(n),temp_inter,grid,grid_points);
}
for(unsigned int n=n_points13;n<n_points12;n++)
{
vector<Point> temp_inter;
fillGridLine(inter12.at(n),inter13.at(inter13.size()-1),temp_inter,grid,grid_points);
}
}
else if(n_points13>=n_points12 && n_points12>0)
{
for(unsigned int n=0;n<n_points12;n++)
{
vector<Point> temp_inter;
fillGridLine(inter12.at(n),inter13.at(n),temp_inter,grid,grid_points);
}
for(unsigned int n=n_points12;n<n_points13;n++)
{
vector<Point> temp_inter;
fillGridLine(inter12.at(inter12.size()-1),inter13.at(n),temp_inter,grid,grid_points);
}
}
}
//get centroid again
Point centroid_after(0.0,0.0,0.0);
for(unsigned int p_it = 0;p_it<grid_points.size();p_it++)
{
centroid_after.x()+=grid_points.at(p_it).x();
centroid_after.y()+=grid_points.at(p_it).y();
centroid_after.z()+=grid_points.at(p_it).z();
}
centroid_after.x()/=double(grid_points.size());
centroid_after.y()/=double(grid_points.size());
centroid_after.z()/=double(grid_points.size());
//move grid to the origin
for(unsigned int p_it = 0;p_it<grid_points.size();p_it++)
{
grid_points.at(p_it).x() -= centroid_after.x();
grid_points.at(p_it).y() -= centroid_after.y();
grid_points.at(p_it).z() -= centroid_after.z();
}
delete [] grid;
RASTERIZE_CONTROL = FALSE;
}