本文整理汇总了C++中Facet_iterator::center方法的典型用法代码示例。如果您正苦于以下问题:C++ Facet_iterator::center方法的具体用法?C++ Facet_iterator::center怎么用?C++ Facet_iterator::center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facet_iterator
的用法示例。
在下文中一共展示了Facet_iterator::center方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renewAttrs
void renewAttrs( Polyhedron & poly )
{
// assign IDs to vertices
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->nCuts() = 0;
}
// assign IDs to faces: the dual vertex and the dual coordinates-the center coordinates
for ( Facet_iterator fi = poly.facets_begin(); fi != poly.facets_end(); ++fi ) {
fi->piece() = NO_INDEX;
Vector3 sum( 0.0, 0.0, 0.0 );
Halfedge_facet_circulator hfc = fi->facet_begin();
do {
sum = sum + ( hfc->vertex()->point() - CGAL::ORIGIN );
} while ( ++hfc != fi->facet_begin() );
sum = sum / ( double )CGAL::circulator_size( hfc );
fi->center() = CGAL::ORIGIN + sum;
}
// assign the same IDs to the identical/ opposite halfedges
for ( Halfedge_iterator hi = poly.halfedges_begin(); hi != poly.halfedges_end(); ++hi ) {
hi->label() = DEFAULT_LABEL;
hi->match() = DEFAULT_LABEL;
hi->cycle() = NO_INDEX;
hi->connect() = true;
hi->visit() = false;
hi->path() = NO_INDEX;
hi->orient() = true;
// We individually handle hi->fixed
}
}
示例2: initAttrs
//------------------------------------------------------------------------------
// Initialize the dual center
//------------------------------------------------------------------------------
void initAttrs( Polyhedron & poly )
{
// assign IDs to vertices
int vID = 0;
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->id() = vID++;
vi->label() = DEFAULT_LABEL;
vi->nCuts() = 0;
}
cerr << "Total number of vertices = " << vID << endl;
// assign IDs to faces: the dual vertex and the dual coordinates-the center coordinates
int fID = 0;
for ( Facet_iterator fi = poly.facets_begin(); fi != poly.facets_end(); ++fi ) {
fi->id() = fID++;
// fi->label() = DEFAULT_LABEL;
fi->piece() = NO_INDEX;
Vector3 sum( 0.0, 0.0, 0.0 );
Halfedge_facet_circulator hfc = fi->facet_begin();
do {
sum = sum + ( hfc->vertex()->point() - CGAL::ORIGIN );
} while ( ++hfc != fi->facet_begin() );
sum = sum / ( double )CGAL::circulator_size( hfc );
fi->center() = CGAL::ORIGIN + sum;
// cerr << " Barycenter No. " << fid-1 << " : " << bary[ fid-1 ] << endl;
}
cerr << "Total number of facets = " << fID << endl;
// initialize the halfedge IDs
for ( Halfedge_iterator hi = poly.halfedges_begin(); hi != poly.halfedges_end(); ++hi ) {
hi->id() = NO_INDEX;
}
// assign the same IDs to the identical/ opposite halfedges
int eID = 0;
for ( Halfedge_iterator hi = poly.halfedges_begin(); hi != poly.halfedges_end(); ++hi ) {
if ( hi->id() == NO_INDEX ) {
assert( hi->opposite()->id() == NO_INDEX );
hi->id() = eID;
hi->opposite()->id() = eID;
eID++;
hi->label() = hi->opposite()->label() = DEFAULT_LABEL;
hi->match() = hi->opposite()->match() = DEFAULT_LABEL;
hi->cycle() = hi->opposite()->cycle() = NO_INDEX;
hi->weight() = hi->opposite()->weight() = 0.0;
hi->connect() = hi->opposite()->connect() = true;
hi->visit() = hi->opposite()->visit() = false;
// We individually handle hi->fixed
}
}
cerr << "Total number of edges = " << eID << endl;
}
示例3: computeDual
//------------------------------------------------------------------------------
// Compute and store the results of dual graphs into appropriate variables
//
// computeDual( mesh, whole, bary, mid );
//------------------------------------------------------------------------------
void computeDual( Polyhedron & poly, Graph & dual,
vector< Point3 > & bary, vector< Point3 > & mid )
{
// initialize the array of face barycenters: refer to the point at which the gravitational forces exerted by 2 objects are equal
bary.clear();
bary.resize( poly.size_of_facets() );
// initialize the dual graph with dual vertices
dual.clear();
int fid = 0;
for ( Facet_iterator fi = poly.facets_begin(); fi != poly.facets_end(); ++fi ) {
// add a vertex: each face equals to each dual vertex
add_vertex( dual );
bary[ fid++ ] = fi->center();
// cerr << " Barycenter No. " << fid-1 << " : " << bary[ fid-1 ] << endl;
}
int size_of_edges = poly.size_of_halfedges() / 2; //redundant
// initialize the array of midpoints
mid.clear();
mid.resize( size_of_edges );
// initialize the array of lengths
// length.clear();
// length.resize( size_of_edges );
// construct the connecitivity of the dual graph
for ( Halfedge_iterator hi = poly.halfedges_begin(); hi != poly.halfedges_end(); ++hi ) {
int origID = hi->facet()->id(); // the face
int destID = hi->opposite()->facet()->id(); // the neighbor face
Point3 origCoord = hi->vertex()->point();
Point3 destCoord = hi->opposite()->vertex()->point();
Vector3 dispVec = origCoord - destCoord;
Point3 midCoord = destCoord + 0.5 * dispVec;
// double curLength = sqrt( dispVec.squared_length() ); // the length between two connected vertices
#ifdef DEBUG
cerr << origID << " -- " << destID << endl;
#endif // DEBUG
if ( origID < destID )
add_edge( origID, destID, hi->id(), dual );
mid[ hi->id() ] = midCoord;
hi->mid() = hi->opposite()->mid() = midCoord;
hi->weight() = hi->opposite()->weight() = 1.0;
}
}