本文整理汇总了C++中MyMesh::faces_end方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMesh::faces_end方法的具体用法?C++ MyMesh::faces_end怎么用?C++ MyMesh::faces_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMesh
的用法示例。
在下文中一共展示了MyMesh::faces_end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_curvature_error_domain
void KnotsViewer::draw_curvature_error_domain()
{
if(surfacedata==NULL)
return;
if ((surfacedata->get_domain()).empty())
return;
MyMesh polymesh = surfacedata->get_polymesh();
if (polymesh.edges_empty()==true)
return;
MyMesh::ConstFaceIter f_it(polymesh.faces_begin()),f_end(polymesh.faces_end());
MyMesh::ConstFaceVertexIter fv_it;
//glLineWidth(0.5);
for (; f_it!=f_end; ++f_it)
{
glColor3ubv(polymesh.color(*f_it).data());
glBegin(GL_POLYGON);
fv_it = polymesh.cfv_iter(*f_it);
glVertex3dv(&polymesh.point(fv_it)[0]);
++fv_it;
glVertex3dv(&polymesh.point(fv_it)[0]);
++fv_it;
glVertex3dv(&polymesh.point(fv_it)[0]);
++fv_it;
glVertex3dv(&polymesh.point(fv_it)[0]);
glEnd();
}
}
示例2: setMesh
void MyGL::setMesh(MyMesh mesh)
{
petal_mesh = mesh;
points.clear();
//点
for (auto it = mesh.vertices_begin(); it != mesh.vertices_end(); ++it){
auto point = mesh.point(it.handle());
coor t = { point.data()[0], point.data()[1], point.data()[2] };
points.push_back(t);
}
//面
face.clear();
for (auto it = mesh.faces_begin(); it != mesh.faces_end(); ++it){
OpenMesh::FaceHandle fh = it.handle();
coor facet;//当前面索引
int count = 0;//标记第几个点
for (auto it1 = mesh.fv_begin(fh); it1 != mesh.fv_end(fh); ++it1){
auto point = mesh.point(it1.handle());
t = { point.data()[0], point.data()[1], point.data()[2] };
//find
vector<coor>::iterator itv;//记录该点对应Points中的位置
itv = find_if(points.begin(), points.end(), [](coor const& obj){
return (fabs(obj.x - t.x) < 0.01) && (fabs(obj.y - t.y) < 0.01) && (fabs(obj.z - t.z) < 0.01);
});
if (itv != points.end())//写入面facet
{
if (count == 0){
facet.x = itv - points.begin();
}
else if (count == 1){
facet.y = itv - points.begin();
}
else
facet.z = itv - points.begin();
}
else
break;
count++;
}
face.push_back(facet);
}
return;
}
示例3: 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;
}