本文整理汇总了C++中Polyhedron::vertices_end方法的典型用法代码示例。如果您正苦于以下问题:C++ Polyhedron::vertices_end方法的具体用法?C++ Polyhedron::vertices_end怎么用?C++ Polyhedron::vertices_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polyhedron
的用法示例。
在下文中一共展示了Polyhedron::vertices_end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smoothMesh
void smoothMesh( Polyhedron & poly, unsigned int nTimes )
{
int nV = poly.size_of_vertices();
const double lambda = SMOOTHING_LAMBDA;
const double mu = SMOOTHING_MU;
vector< Point3 > shrink ( nV );
vector< Point3 > expand ( nV );
for ( unsigned int k = 0; k < nTimes; ++k ) {
// copy the vertex coordinates
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
shrink [ vi->id() ] = vi->point();
}
// shrinking stage
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
moveVertex( vi, shrink[ vi->id() ], lambda );
}
// copy back the vertex coordinates
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = shrink[ vi->id() ];
expand[ vi->id() ] = shrink[ vi->id() ];
}
// expanding stage
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
moveVertex( vi, expand[ vi->id() ], mu );
}
// copy back the vertex coordinates
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = expand[ vi->id() ];
}
}
}
示例2: subdivide
void geometryUtils::subdivide(Polyhedron& P) {
if (P.size_of_facets() == 0)
return;
// We use that new vertices/halfedges/facets are appended at the end.
std::size_t nv = P.size_of_vertices();
Vertex_iterator last_v = P.vertices_end();
--last_v; // the last of the old vertices
Edge_iterator last_e = P.edges_end();
--last_e; // the last of the old edges
Facet_iterator last_f = P.facets_end();
--last_f; // the last of the old facets
Facet_iterator f = P.facets_begin(); // create new center vertices
do {
geometryUtils::subdivide_create_center_vertex(P, f);
} while (f++ != last_f);
std::vector<Point_3> pts; // smooth the old vertices
pts.reserve(nv); // get intermediate space for the new points
++last_v; // make it the past-the-end position again
std::transform(P.vertices_begin(), last_v, std::back_inserter(pts),
Smooth_old_vertex());
std::copy(pts.begin(), pts.end(), P.points_begin());
Edge_iterator e = P.edges_begin(); // flip the old edges
++last_e; // make it the past-the-end position again
while (e != last_e) {
Halfedge_handle h = e;
++e; // careful, incr. before flip since flip destroys current edge
geometryUtils::subdivide_flip_edge(P, h);
};
CGAL_postcondition(P.is_valid());
};
示例3: 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
}
}
示例4: transformMesh
void transformMesh( Polyhedron & poly, Transformation3 & map )
{
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
Point3 store = vi->point().transform( map );
vi->point() = store;
}
}
示例5: cgal_to_polyhedron
polyhedron cgal_to_polyhedron( const Nef_polyhedron &NP ){
Polyhedron P;
polyhedron ret;
if( NP.is_simple() ){
NP.convert_to_polyhedron(P);
std::vector<double> coords;
std::vector<int> tris;
int next_id = 0;
std::map< Polyhedron::Vertex*, int > vid;
for( Polyhedron::Vertex_iterator iter=P.vertices_begin(); iter!=P.vertices_end(); iter++ ){
coords.push_back( CGAL::to_double( (*iter).point().x() ) );
coords.push_back( CGAL::to_double( (*iter).point().y() ) );
coords.push_back( CGAL::to_double( (*iter).point().z() ) );
vid[ &(*iter) ] = next_id++;
}
for( Polyhedron::Facet_iterator iter=P.facets_begin(); iter!=P.facets_end(); iter++ ){
Polyhedron::Halfedge_around_facet_circulator j = iter->facet_begin();
tris.push_back( CGAL::circulator_size(j) );
do {
tris.push_back( std::distance(P.vertices_begin(), j->vertex()) );
} while ( ++j != iter->facet_begin());
}
ret.initialize_load_from_mesh( coords, tris );
} else {
std::cout << "resulting polyhedron is not simple!" << std::endl;
}
return ret;
}
示例6: 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;
}
示例7: normalizeMesh
//------------------------------------------------------------------------------
// Normalize the 3D triangulated mesh with the display window
//------------------------------------------------------------------------------
void normalizeMesh( Polyhedron & poly, vector< Segment3 > & bone )
{
Vector3 sum, ave;
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
sum = sum + ( vi->point() - CGAL::ORIGIN );
}
ave = sum / ( double )poly.size_of_vertices();
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = vi->point() - ave;
}
cerr << " ave = " << ave << endl;
Transformation3 translate( CGAL::TRANSLATION, -ave );
// fabs:absolute values-no negative values
double sideMax = 0.0;
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
if ( fabs( vi->point().x() ) > sideMax ) sideMax = fabs( vi->point().x() );
if ( fabs( vi->point().y() ) > sideMax ) sideMax = fabs( vi->point().y() );
if ( fabs( vi->point().z() ) > sideMax ) sideMax = fabs( vi->point().z() );
}
// sideMax: the largest number
for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
vi->point() = CGAL::ORIGIN + ( vi->point() - CGAL::ORIGIN ) / sideMax;
}
Transformation3 scale( CGAL::SCALING, 1.0/sideMax );
Transformation3 composite = scale * translate;
for ( unsigned int k = 0; k < bone.size(); ++k ) {
bone[ k ] = bone[ k ].transform( composite );
}
}
示例8: modify_vertex_position
void modify_vertex_position()
{
Polyhedron P;
Halfedge_handle h = P.make_tetrahedron();
if ( P.is_tetrahedron(h))
{
int i(0);
for(Vertex_iterator vi = P.vertices_begin(); vi != P.vertices_end(); ++vi,++i)
{
std::cout << "before changing vertex " << i << ": " << vi->point().x() << vi->point().y() << vi->point().z() << endl;
Point_3 pt(1, 0, 0);
vi->point() = pt;
std::cout << "after changing vertex " << i << ": " << vi->point().x() << vi->point().y() << vi->point().z() << endl;
}
}
}
示例9: V
IGL_INLINE void igl::copyleft::cgal::polyhedron_to_mesh(
const Polyhedron & poly,
Eigen::MatrixXd & V,
Eigen::MatrixXi & F)
{
using namespace std;
V.resize(poly.size_of_vertices(),3);
F.resize(poly.size_of_facets(),3);
typedef typename Polyhedron::Vertex_const_iterator Vertex_iterator;
std::map<Vertex_iterator,size_t> vertex_to_index;
{
size_t v = 0;
for(
typename Polyhedron::Vertex_const_iterator p = poly.vertices_begin();
p != poly.vertices_end();
p++)
{
V(v,0) = p->point().x();
V(v,1) = p->point().y();
V(v,2) = p->point().z();
vertex_to_index[p] = v;
v++;
}
}
{
size_t f = 0;
for(
typename Polyhedron::Facet_const_iterator facet = poly.facets_begin();
facet != poly.facets_end();
++facet)
{
typename Polyhedron::Halfedge_around_facet_const_circulator he =
facet->facet_begin();
// Facets in polyhedral surfaces are at least triangles.
assert(CGAL::circulator_size(he) == 3 && "Facets should be triangles");
size_t c = 0;
do {
//// This is stooopidly slow
// F(f,c) = std::distance(poly.vertices_begin(), he->vertex());
F(f,c) = vertex_to_index[he->vertex()];
c++;
} while ( ++he != facet->facet_begin());
f++;
}
}
}
示例10: calcCurvature
scalarField calcCurvature(const triSurface& surf)
{
scalarField k(surf.points().size(), 0);
Polyhedron P;
buildCGALPolyhedron convert(surf);
P.delegate(convert);
// Info<< "Created CGAL Polyhedron with " << label(P.size_of_vertices())
// << " vertices and " << label(P.size_of_facets())
// << " facets. " << endl;
// The rest of this function adapted from
// CGAL-3.7/examples/Jet_fitting_3/Mesh_estimation.cpp
//Vertex property map, with std::map
typedef std::map<Vertex*, int> Vertex2int_map_type;
typedef boost::associative_property_map< Vertex2int_map_type >
Vertex_PM_type;
typedef T_PolyhedralSurf_rings<Polyhedron, Vertex_PM_type > Poly_rings;
typedef CGAL::Monge_via_jet_fitting<Kernel> Monge_via_jet_fitting;
typedef Monge_via_jet_fitting::Monge_form Monge_form;
std::vector<Point_3> in_points; //container for data points
// default parameter values and global variables
unsigned int d_fitting = 2;
unsigned int d_monge = 2;
unsigned int min_nb_points = (d_fitting + 1)*(d_fitting + 2)/2;
//initialize the tag of all vertices to -1
Vertex_iterator vitb = P.vertices_begin();
Vertex_iterator vite = P.vertices_end();
Vertex2int_map_type vertex2props;
Vertex_PM_type vpm(vertex2props);
CGAL_For_all(vitb, vite)
{
put(vpm, &(*vitb), -1);
}
示例11: MinCoord
//**********************************************************************************
//returns min coordinates
Vector3r MinCoord(const shared_ptr<Shape>& cm1,const State& state1){
const Se3r& se3=state1.se3;
Polyhedra* A = static_cast<Polyhedra*>(cm1.get());
//move and rotate CGAL structure Polyhedron
Matrix3r rot_mat = (se3.orientation).toRotationMatrix();
Vector3r trans_vec = se3.position;
Transformation t_rot_trans(rot_mat(0,0),rot_mat(0,1),rot_mat(0,2), trans_vec[0],rot_mat(1,0),rot_mat(1,1),rot_mat(1,2),trans_vec[1],rot_mat(2,0),rot_mat(2,1),rot_mat(2,2),trans_vec[2],1.);
Polyhedron PA = A->GetPolyhedron();
std::transform( PA.points_begin(), PA.points_end(), PA.points_begin(), t_rot_trans);
Vector3r minccord = trans_vec;
for(Polyhedron::Vertex_iterator vi = PA.vertices_begin(); vi != PA.vertices_end(); ++vi){
if (vi->point()[0]<minccord[0]) minccord[0]=vi->point()[0];
if (vi->point()[1]<minccord[1]) minccord[1]=vi->point()[1];
if (vi->point()[2]<minccord[2]) minccord[2]=vi->point()[2];
}
return minccord;
}
示例12: skin_surface
ofMesh & ofxCGALSkinSurface::makeSkinSurfaceMesh() {
std::list<Weighted_point> l;
FT shrinkfactor = shrinkFactor;
for(int i=0; i<points.size(); i++) {
float px = points[i].point.x;
float py = points[i].point.y;
float pz = points[i].point.z;
float radius = points[i].radius;
l.push_front(Weighted_point(Bare_point(px, py, pz), radius * radius));
}
Skin_surface_3 skin_surface(l.begin(), l.end(), shrinkfactor);
Polyhedron p;
CGAL::mesh_skin_surface_3(skin_surface, p);
if(bSubdiv == true) {
CGAL::subdivide_skin_surface_mesh_3(skin_surface, p);
}
mesh.clear();
map<Point_3, int> point_indices;
int count = 0;
for (auto it=p.vertices_begin(); it!=p.vertices_end(); ++it) {
auto& p = it->point();
mesh.addVertex(ofVec3f(p.x(), p.y(), p.z()));
point_indices[p] = count++;
}
for (auto it=p.facets_begin(); it!=p.facets_end(); ++it) {
mesh.addIndex(point_indices[it->halfedge()->vertex()->point()]);
mesh.addIndex(point_indices[it->halfedge()->next()->vertex()->point()]);
mesh.addIndex(point_indices[it->halfedge()->prev()->vertex()->point()]);
}
}
示例13: ComputeGaussCurvature
void ComputeGaussCurvature(Polyhedron &P)
{
Polyhedron::Vertex_iterator vit;
for(vit=P.vertices_begin(); vit!=P.vertices_end(); vit++)
ComputeGaussCurvature(vit);
}
示例14: parameterize
void MainWindow::parameterize(const Parameterization_method method)
{
QApplication::setOverrideCursor(Qt::WaitCursor);
// get active polyhedron
int index = getSelectedSceneItemIndex();
Polyhedron* pMesh = scene->polyhedron(index);
if(pMesh == NULL)
{
QApplication::restoreOverrideCursor();
return;
}
// parameterize
QTime time;
time.start();
typedef CGAL::Parameterization_polyhedron_adaptor_3<Polyhedron> Adaptor;
Adaptor adaptor(*pMesh);
bool success = false;
switch(method)
{
case PARAM_MVC:
{
std::cout << "Parameterize (MVC)...";
typedef CGAL::Mean_value_coordinates_parameterizer_3<Adaptor> Parameterizer;
Parameterizer::Error_code err = CGAL::parameterize(adaptor,Parameterizer());
success = err == Parameterizer::OK;
break;
}
case PARAM_DCP:
{
std::cout << "Parameterize (DCP)...";
typedef CGAL::Discrete_conformal_map_parameterizer_3<Adaptor> Parameterizer;
Parameterizer::Error_code err = CGAL::parameterize(adaptor,Parameterizer());
success = err == Parameterizer::OK;
}
}
if(success)
std::cout << "ok (" << time.elapsed() << " ms)" << std::endl;
else
{
std::cout << "failure" << std::endl;
QApplication::restoreOverrideCursor();
return;
}
// add textured polyhedon to the scene
Textured_polyhedron *pTex_polyhedron = new Textured_polyhedron();
Textured_polyhedron_builder<Polyhedron,Textured_polyhedron,Kernel> builder;
builder.run(*pMesh,*pTex_polyhedron);
pTex_polyhedron->compute_normals();
Polyhedron::Vertex_iterator it1;
Textured_polyhedron::Vertex_iterator it2;
for(it1 = pMesh->vertices_begin(),
it2 = pTex_polyhedron->vertices_begin();
it1 != pMesh->vertices_end(),
it2 != pTex_polyhedron->vertices_end();
it1++, it2++)
{
// (u,v) pair is stored per halfedge
FT u = adaptor.info(it1->halfedge())->uv().x();
FT v = adaptor.info(it1->halfedge())->uv().y();
it2->u() = u;
it2->v() = v;
}
scene->addTexPolyhedron(pTex_polyhedron,
tr("%1 (parameterized)").arg(scene->polyhedronName(index)),
Qt::white,
scene->isPolyhedronVisible(index),
scene->polyhedronRenderingMode(index));
QApplication::restoreOverrideCursor();
}
示例15: DefineSkin
void ElPoly::DefineSkin(int NSample){
std::list<Weighted_point> l;
FT shrinkfactor = 0.5;
double *Plot = new double[pNType()*CUBE(NSample)];
double *Count = new double[CUBE(NSample)];
double Thre = 10.;
double Radius = pEdge(0)/(double)NSample;
for(int p=0;p<pNPart();p++){
int t = pType(p);
int vx = (int)(pPos(p,0)/pEdge(0)*NSample);
int vy = (int)(pPos(p,1)/pEdge(1)*NSample);
int vz = (int)(pPos(p,2)/pEdge(2)*NSample);
int vTot = (vz*NSample+vy)*NSample+vx;
Plot[vTot*pNType()+t] += 1.;
}
double *Norm = (double *)calloc(pNType(),sizeof(double));
for(int t=0;t<pNType();t++){
for(int v=0;v<CUBE(NSample);v++){
if(Norm[t] < Plot[v*pNType()+t])
Norm[t] = Plot[v*pNType()+t];
}
Norm[t] = Norm[t] <= 0. ? 1. : Norm[t];
}
for(int vx=0;vx<NSample;vx++){
double x = vx*pEdge(0)/(double)NSample;
for(int vy=0;vy<NSample;vy++){
double y = vy*pEdge(1)/(double)NSample;
for(int vz=0;vz<NSample;vz++){
double z = vz*pEdge(2)/(double)NSample;
int vTot = (vz*NSample+vy)*NSample+vx;
if(Plot[vTot*pNType()] > Thre){
l.push_front(Weighted_point(Bare_point(x,y,z),Radius));
}
}
}
}
Polyhedron Polyhe;
Skin_surface_3 skin_surface(l.begin(), l.end(), shrinkfactor);
CGAL::mesh_skin_surface_3(skin_surface, Polyhe);
// CGAL::subdivide_skin_surface_mesh_3(skin_surface, Polyhe);
// std::ofstream out("mesh.off");
// out << Polyhe;
glDeleteLists(Dr->Particles,1);
Dr->Particles = glGenLists(1);
glNewList(Dr->Particles,GL_COMPILE);
// Polyhedron::Facet_iterator fcUp = Polyhe.facets_begin();
// for(;fcUp != Polyhe.facets_end(); ++fcUp){
// Polyhedron::Supports_facet_halfedge = fcUp.halfedge();
// //Halfedge_around_facet_circulator heUp = fcUp.halfedge();
// }
// for (Vertex_iterator vit = Polyhe.vertices_begin();vit != Polyhe.vertices_end(); vit++){
// // Vector n = policy.normal(vit);
// // n = n/sqrt(n*n);
// cout << vit->point() << std::endl;
// Halfedge_iterator heUp = Polyhe.halfedges_begin();
// for(;heUp != Polyhe.halfedges_end(); ++heUp){
// //Polyhedron::Halfedge_handle Half = *heUp;
// Vertex_handle veUp = heUp->vertex();
// K::Point_3 pf1 = vit->point();
// }
// }
CGAL::Inverse_index<Vertex_handle> index(Polyhe.vertices_begin(),
Polyhe.vertices_end());
for(Facet_iterator fi = Polyhe.facets_begin();fi != Polyhe.facets_end(); ++fi) {
HFC hc = fi->facet_begin();
HFC hc_end = hc;
Polyhedron::Vertex_handle vf1 = (*hc).vertex();
hc++;
Polyhedron::Vertex_handle vf2 = (*hc).vertex();
hc++;
Polyhedron::Vertex_handle vf3 = (*hc).vertex();
hc++;
K::Point_3 pf1 = vf1->point();
K::Point_3 pf2 = vf2->point();
K::Point_3 pf3 = vf3->point();
Vettore v1(pf1.x(),pf1.y(),pf1.z());
Vettore v2(pf2.x(),pf2.y(),pf2.z());
Vettore v3(pf3.x(),pf3.y(),pf3.z());
Vettore vN(3);
v1.Mult(InvScaleUn);
v2.Mult(InvScaleUn);
v3.Mult(InvScaleUn);
vN = (v1-v2) ^ (v3-v2);
//if(vN.Norm() > 2.*AreaMean) continue;
double Sfumatura = .3*Mat->Casuale();
glColor4f(0.1,.4+Sfumatura,0.2,1.);
//glColor4f(HueUp[p].r,HueUp[p].g,HueUp[p].b,HueUp[p].a);
DrTria(&v1,&v2,&v3,&vN);
glColor4f(1.,.0,0.,1.);
DrTriaContour(&v1,&v2,&v3);
//.........这里部分代码省略.........