本文整理汇总了C++中Polyhedron::is_closed方法的典型用法代码示例。如果您正苦于以下问题:C++ Polyhedron::is_closed方法的具体用法?C++ Polyhedron::is_closed怎么用?C++ Polyhedron::is_closed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polyhedron
的用法示例。
在下文中一共展示了Polyhedron::is_closed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: polyhedron_to_cgal
Nef_polyhedron polyhedron_to_cgal( const polyhedron &p ){
polyhedron tmp = p.triangulate();
Polyhedron P;
polyhedron_builder<HalfedgeDS> builder( tmp );
P.delegate( builder );
if( P.is_closed() )
return Nef_polyhedron( P );
else
std::cout << "input polyhedron is not closed!" << std::endl;
return Nef_polyhedron();
}
示例2: operator
void operator()(std::string filename)
{
std::cout << filename << std::endl;
std::list<Weighted_point> l;
std::ifstream in(filename.c_str());
assert(in.is_open());
Weighted_point wp;
while (in >> wp) l.push_front(wp);
Skin_surface_3 skin_surface(l.begin(), l.end(), s);
Polyhedron p;
CGAL::mesh_skin_surface_3(skin_surface, p);
assert(p.is_valid() && p.is_closed());
//std::cout << p << std::endl;
}
示例3: mexFunction
/*
* mexFunction(): entry point for the mex function
*/
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]) {
// interface to deal with input arguments from Matlab
enum InputIndexType {IN_TRI, IN_X, IN_METHOD, IN_ITER, InputIndexType_MAX};
MatlabImportFilter::Pointer matlabImport = MatlabImportFilter::New();
matlabImport->ConnectToMatlabFunctionInput(nrhs, prhs);
// check that we have all input arguments
matlabImport->CheckNumberOfArguments(2, InputIndexType_MAX);
// register the inputs for this function at the import filter
MatlabInputPointer inTRI = matlabImport->RegisterInput(IN_TRI, "TRI");
MatlabInputPointer inX = matlabImport->RegisterInput(IN_X, "X");
MatlabInputPointer inMETHOD = matlabImport->RegisterInput(IN_METHOD, "METHOD");
MatlabInputPointer inITER = matlabImport->RegisterInput(IN_ITER, "ITER");
// interface to deal with outputs to Matlab
enum OutputIndexType {OUT_TRI, OUT_N, OutputIndexType_MAX};
MatlabExportFilter::Pointer matlabExport = MatlabExportFilter::New();
matlabExport->ConnectToMatlabFunctionOutput(nlhs, plhs);
// check number of outputs the user is asking for
matlabExport->CheckNumberOfArguments(0, OutputIndexType_MAX);
// register the outputs for this function at the export filter
typedef MatlabExportFilter::MatlabOutputPointer MatlabOutputPointer;
MatlabOutputPointer outTRI = matlabExport->RegisterOutput(OUT_TRI, "TRI");
MatlabOutputPointer outN = matlabExport->RegisterOutput(OUT_N, "N");
// if any of the inputs is empty, the output is empty too
if (mxIsEmpty(prhs[IN_TRI]) || mxIsEmpty(prhs[IN_X])) {
matlabExport->CopyEmptyArrayToMatlab(outTRI);
matlabExport->CopyEmptyArrayToMatlab(outN);
return;
}
// polyhedron to contain the input mesh
Polyhedron mesh;
PolyhedronBuilder<Polyhedron> builder(matlabImport, inTRI, inX);
mesh.delegate(builder);
// get size of input matrix with the points
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
//.........这里部分代码省略.........
示例4: meshSimplification
TrianglesList meshSimplification(TrianglesList &triangles, int stopPredicate) {
#ifdef MESHSIMPLIFICATION_LOG
CGAL::Timer timer;
timer.start();
#endif
TrianglesList result;
try
{
Polyhedron P;
#ifdef MESHSIMPLIFICATION_LOG
std::cout << "Start Building Polyhedron surface... " << std::endl;
#endif
Build_triangle_mesh_coherent_surface<HalfedgeDS> triangle(triangles);
P.delegate(triangle);
P.normalize_border();
#ifdef MESHSIMPLIFICATION_LOG
std::cout << "Completed Building Polyhedron surface:" << std::endl;
std::cout << "Polyhedron is_pure_triangle: " << P.is_pure_triangle() << std::endl;
std::cout << "Polyhedron is_closed: " << P.is_closed() << std::endl;
std::cout << "Polyhedron is_pure_bivalent : " << P.is_pure_bivalent () << std::endl;
std::cout << "Polyhedron is_pure_trivalent: " << P.is_pure_trivalent() << std::endl;
std::cout << "Polyhedron is_valid 0: " << P.is_valid(false, 0) << std::endl;
std::cout << "Polyhedron is_valid 1: " << P.is_valid(false, 1) << std::endl;
std::cout << "Polyhedron is_valid 2: " << P.is_valid(false, 2) << std::endl;
std::cout << "Polyhedron is_valid 3: " << P.is_valid(false, 3) << std::endl;
std::cout << "Polyhedron is_valid 4: " << P.is_valid(false, 4) << std::endl;
std::cout << "Polyhedron normalized_border_is_valid : " << P.normalized_border_is_valid(false) << std::endl;
#endif
#ifdef MESHSIMPLIFICATION_LOG
std::cout << "Start edge_collapse... " << std::endl;
#endif
SMS::Count_stop_predicate<Polyhedron> stop(stopPredicate);
int removedEdges = SMS::edge_collapse(P, stop,
CGAL::vertex_index_map(boost::get(CGAL::vertex_external_index, P)).edge_index_map(boost::get(CGAL::edge_external_index ,P))
);
#ifdef MESHSIMPLIFICATION_LOG
std::cout << "Completed edge_collapse:" << std::endl;
std::cout << "Finished with: " << removedEdges << " edges removed and " << (P.size_of_halfedges()/2) << " final edges." << std::endl;
#endif
//Build output result
for ( Polyhedron::Facet_iterator fit( P.facets_begin() ), fend( P.facets_end() ); fit != fend; ++fit )
{
if ( fit->is_triangle() )
{
PointCGAL verts[3];
int tick = 0;
Polyhedron::Halfedge_around_facet_circulator hit( fit->facet_begin() ), hend( hit );
do
{
if ( tick < 3 )
{
verts[tick++] = PointCGAL( hit->vertex()->point().x(), hit->vertex()->point().y(), hit->vertex()->point().z() );
}
else
{
std::cout << "meshSimplification: We've got facets with more than 3 vertices even though the facet reported to be triangular..." << std::endl;
}
} while( ++hit != hend );
result.push_back( Triangle(verts[0], verts[1], verts[2]) );
}
else
{
std::cout << "meshSimplification: Skipping non-triangular facet" << std::endl;
}
}
}
catch (CGAL::Assertion_exception e)
{
std::cout << "ERROR: meshSimplification CGAL::Assertion_exception" << e.message() << std::endl;
}
#ifdef MESHSIMPLIFICATION_LOG
timer.stop();
std::cout << "meshSimplification result with: " << result.size() << " triangles." << std::endl;
std::cout << "Total meshSimplification time: " << timer.time() << std::endl;
#endif
return result;
}