本文整理汇总了C++中Facet_iterator::facet_degree方法的典型用法代码示例。如果您正苦于以下问题:C++ Facet_iterator::facet_degree方法的具体用法?C++ Facet_iterator::facet_degree怎么用?C++ Facet_iterator::facet_degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facet_iterator
的用法示例。
在下文中一共展示了Facet_iterator::facet_degree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mexFunction
//.........这里部分代码省略.........
mwSize nrowsTri = mxGetM(inTRI->pm);
mwSize nrowsX = mxGetM(inX->pm);
#ifdef DEBUG
std::cout << "Number of facets read = " << mesh.size_of_facets() << std::endl;
std::cout << "Number of vertices read = " << mesh.size_of_vertices() << std::endl;
#endif
if (nrowsTri != mesh.size_of_facets()) {
mexErrMsgTxt(("Input " + inTRI->name + ": Number of triangles read into mesh different from triangles provided at the input").c_str());
}
if (nrowsX != mesh.size_of_vertices()) {
mexErrMsgTxt(("Input " + inX->name + ": Number of vertices read into mesh different from vertices provided at the input").c_str());
}
// sort halfedges such that the non-border edges precede the
// border edges. We need to do this before any halfedge iterator
// operations are valid
mesh.normalize_border();
#ifdef DEBUG
std::cout << "Number of border halfedges = " << mesh.size_of_border_halfedges() << std::endl;
#endif
// number of holes we have filled
mwIndex n = 0;
// a closed mesh with no holes will have no border edges. What we do
// is grab a border halfedge and close the associated hole. This
// makes the rest of the iterators invalid, so we have to normalize
// the mesh again. Then we iterate, looking for a new border
// halfedge, filling the hole, etc.
//
// Note that confusingly, mesh.border_halfedges_begin() gives a
// pointer to the halfedge that is NOT a border in a border
// edge. The border halfedge is instead
// mesh.border_halfedges_begin()->opposite()
while (!mesh.is_closed()) {
// exit if user pressed Ctrl+C
ctrlcCheckPoint(__FILE__, __LINE__);
// get the first hole we can find, and close it
mesh.fill_hole(mesh.border_halfedges_begin()->opposite());
// increase the counter of number of holes we have filled
n++;
// renormalize mesh so that halfedge iterators are again valid
mesh.normalize_border();
}
// split all facets to triangles
CGAL::triangulate_polyhedron<Polyhedron>(mesh);
// copy output with number of holes filled
std::vector<double> nout(1, n);
matlabExport->CopyVectorOfScalarsToMatlab<double, std::vector<double> >(outN, nout, 1);
// allocate memory for Matlab outputs
double *tri = matlabExport->AllocateMatrixInMatlab<double>(outTRI, mesh.size_of_facets(), 3);
// extract the triangles of the solution
// snippet adapted from CgalMeshSegmentation.cpp
// vertices coordinates. Assign indices to the vertices by defining
// a map between their handles and the index
std::map<Vertex_handle, int> V;
int inum = 0;
for(Vertex_iterator vit = mesh.vertices_begin(); vit != mesh.vertices_end(); ++vit) {
// save to internal list of vertices
V[vit] = inum++;
}
// triangles given as (i,j,k), where each index corresponds to a vertex in x
mwIndex row = 0;
for (Facet_iterator fit = mesh.facets_begin(); fit != mesh.facets_end(); ++fit, ++row) {
if (fit->facet_degree() != 3) {
std::cerr << "Facet has " << fit->facet_degree() << " edges" << std::endl;
mexErrMsgTxt("Facet does not have 3 edges");
}
// go around the half-edges of the facet, to extract the vertices
Halfedge_around_facet_circulator heit = fit->facet_begin();
int idx = 0;
do {
// extract triangle indices and save to Matlab output
// note that Matlab indices go like 1, 2, 3..., while C++ indices go like 0, 1, 2...
tri[row + idx * mesh.size_of_facets()] = 1 + V[heit->vertex()];
idx++;
} while (++heit != fit->facet_begin());
}
}