本文整理汇总了C++中Polyhedron::points_end方法的典型用法代码示例。如果您正苦于以下问题:C++ Polyhedron::points_end方法的具体用法?C++ Polyhedron::points_end怎么用?C++ Polyhedron::points_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polyhedron
的用法示例。
在下文中一共展示了Polyhedron::points_end方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_Polyhedras_Intersect
//**********************************************************************************
//test of polyhedron intersection callable from python shell
bool do_Polyhedras_Intersect(const shared_ptr<Shape>& cm1,const shared_ptr<Shape>& cm2,const State& state1,const State& state2){
const Se3r& se31=state1.se3;
const Se3r& se32=state2.se3;
Polyhedra* A = static_cast<Polyhedra*>(cm1.get());
Polyhedra* B = static_cast<Polyhedra*>(cm2.get());
//move and rotate 1st the CGAL structure Polyhedron
Matrix3r rot_mat = (se31.orientation).toRotationMatrix();
Vector3r trans_vec = se31.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);
//move and rotate 2st the CGAL structure Polyhedron
rot_mat = (se32.orientation).toRotationMatrix();
trans_vec = se32.position;
t_rot_trans = Transformation(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 PB = B->GetPolyhedron();
std::transform( PB.points_begin(), PB.points_end(), PB.points_begin(), t_rot_trans);
//calculate plane equations
std::transform( PA.facets_begin(), PA.facets_end(), PA.planes_begin(),Plane_equation());
std::transform( PB.facets_begin(), PB.facets_end(), PB.planes_begin(),Plane_equation());
//call test
return do_intersect(PA,PB);
}
示例2: on_actionConvexHull_triggered
void Polyhedron_demo_convex_hull_plugin::on_actionConvexHull_triggered()
{
const Scene_interface::Item_id index = scene->mainSelectionIndex();
Scene_polyhedron_item* poly_item =
qobject_cast<Scene_polyhedron_item*>(scene->item(index));
Scene_points_with_normal_item* pts_item =
qobject_cast<Scene_points_with_normal_item*>(scene->item(index));
Scene_polylines_item* lines_item =
qobject_cast<Scene_polylines_item*>(scene->item(index));
if(poly_item || pts_item || lines_item)
{
// wait cursor
QApplication::setOverrideCursor(Qt::WaitCursor);
QTime time;
time.start();
std::cout << "Convex hull...";
// add convex hull as new polyhedron
Polyhedron *pConvex_hull = new Polyhedron;
if ( poly_item ){
Polyhedron* pMesh = poly_item->polyhedron();
CGAL::convex_hull_3(pMesh->points_begin(),pMesh->points_end(),*pConvex_hull);
}
else{
if (pts_item)
CGAL::convex_hull_3(pts_item->point_set()->begin(),pts_item->point_set()->end(),*pConvex_hull);
else{
std::size_t nb_points=0;
for(std::list<std::vector<Kernel::Point_3> >::const_iterator it = lines_item->polylines.begin();
it != lines_item->polylines.end();
++it) nb_points+=it->size();
std::vector<Kernel::Point_3> all_points;
all_points.reserve( nb_points );
for(std::list<std::vector<Kernel::Point_3> >::const_iterator it = lines_item->polylines.begin();
it != lines_item->polylines.end();
++it) std::copy(it->begin(), it->end(),std::back_inserter( all_points ) );
CGAL::convex_hull_3(all_points.begin(),all_points.end(),*pConvex_hull);
}
}
std::cout << "ok (" << time.elapsed() << " ms)" << std::endl;
Scene_polyhedron_item* new_item = new Scene_polyhedron_item(pConvex_hull);
new_item->setName(tr("%1 (convex hull)").arg(scene->item(index)->name()));
new_item->setColor(Qt::magenta);
new_item->setRenderingMode(FlatPlusEdges);
scene->addItem(new_item);
// default cursor
QApplication::restoreOverrideCursor();
}
}
示例3: test_impl
void test_impl(Tree& tree, Polyhedron& p, const double duration)
{
tree.accelerate_distance_queries(p.points_begin(),p.points_end());
typedef Tree_vs_naive<Tree, Polyhedron, K, Type> Tester;
Tester tester(tree, p);
tester.test_all_distance_methods(duration);
}
示例4: PrintPolyhedraActualPos
//**********************************************************************************
//print polyhedron in actual position
void PrintPolyhedraActualPos(const shared_ptr<Shape>& cm1,const State& state1){
const Se3r& se3=state1.se3;
Polyhedra* A = static_cast<Polyhedra*>(cm1.get());
A->Initialize();
//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);
PrintPolyhedron(PA);
}
示例5: main
int main(int argc, const char **argv )
{
std::vector<Point> points;
CGAL::Random_points_on_sphere_3<Point> g;
size_t N = 0;
if (argc > 1)
N = atof(argv[1]);
N = std::max(size_t(100), N);
for (size_t i = 0; i < N; ++i)
points.push_back(rescale(*g++));
for (size_t n = 0; n < 100; ++n)
{
std::cerr << "step " << n << ":\n\t";
lloyd_step(points);
}
Polyhedron P;
CGAL::convex_hull_3(points.begin(), points.end(), P);
CGAL::set_ascii_mode( std::cout);
std::cout << "OFF" << std::endl << P.size_of_vertices() << ' '
<< P.size_of_facets() << " 0" << std::endl;
std::copy( P.points_begin(), P.points_end(),
std::ostream_iterator<Point>( std::cout, "\n"));
for ( Facet_iterator i = P.facets_begin(); i != P.facets_end(); ++i) {
Halfedge_facet_circulator j = i->facet_begin();
// Facets in polyhedral surfaces are at least triangles.
CGAL_assertion( CGAL::circulator_size(j) >= 3);
std::cout << CGAL::circulator_size(j) << ' ';
do {
std::cout << ' ' << std::distance(P.vertices_begin(), j->vertex());
} while ( ++j != i->facet_begin());
std::cout << std::endl;
}
std::ofstream os ("test.cloud");
std::copy(points.begin(), points.end(),
std::ostream_iterator<Point>(os, "\n"));
}
示例6: 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;
}
示例7: main
//.........这里部分代码省略.........
E = p.Draw();
P = n.Draw();
Morph Mor(E,50);
Mor.Do(P);*/
//Noise No(5,0.3,0,s.Center,Z_ax);
//No.Do(P);
//Skew Sk(30,s.Center,Z_ax,false,20,-20);
//Sk.Do(P);
//Smooth Sm(1);
//Sm.Do(P);
//Spherify Sph(50);
//Sph.Do(P);
//Squeeze Sq(-30,s.Center,Z_ax,false,10,0);
//Sq.Do(P);
//Stretch St(-20,s.Center,Z_ax,true,50,-50);
//St.Do(P);
//Taper Ta(3,s.Center,X_ax,false,20,-20);
//Ta.Do(P);
//Twist Tw(270,s.Center,Z_ax,true,-5,15);
//Tw.Do(P);
/*Box_3 B(20, 30, 60, 20, 30, 30);
Polyhedron P = B.Draw();
Twist Tw1(270, B.Center, Z_ax, true, 30, 10);
Twist Tw2(-270, B.Center, Z_ax, true, -10, -30);
Stretch St(30, B.Center, Z_ax, true, 20,-20);
Squeeze Sq(15, B.Center, Z_ax);
Tw1.Do(P);
Tw2.Do(P);
Sq.Do(P);
St.Do(P);*/
std::ofstream of("C:\\123.off");
Box_3 B(20, 30, 60, 20, 30, 30);
Polyhedron P = B.Draw();
Twist Tw1(270, B.Center, Z_ax, true, 30, 10);
Twist Tw2(-270, B.Center, Z_ax, true, -10, -30);
Stretch St(30, B.Center, Z_ax, true, 20,-20);
Squeeze Sq(15, B.Center, Z_ax);
Tw1.Do(P);
Tw2.Do(P);
Sq.Do(P);
St.Do(P);
//// Write polyhedron in Object File Format (OFF).
CGAL::set_ascii_mode( of );
of << "OFF" << std::endl << P.size_of_vertices() << ' ' << P.size_of_facets() << " 0" << std::endl;
std::copy( P.points_begin(), P.points_end(), std::ostream_iterator<Point_3>( of, "\n"));
for ( Facet_iterator i = P.facets_begin(); i != P.facets_end(); ++i)
{
Halfedge_facet_circulator j = i->facet_begin();
// Facets in polyhedral surfaces are at least triangles.
CGAL_assertion( CGAL::circulator_size(j) >= 3);
of << CGAL::circulator_size(j) << ' ';
do
{
of << ' ' << std::distance(P.vertices_begin(), j->vertex());
} while ( ++j != i->facet_begin());
of << std::endl;
}
/* Write polyhedron in (OBJ).
CGAL::set_ascii_mode( oof );
oof << "# " << P.size_of_vertices() << ' ' << std::endl <<"# "<< P.size_of_facets() << std::endl;
oof<<"v ";
std::copy( P.points_begin(), P.points_end(), std::ostream_iterator<Point_3>( oof, "\nv "));
oof<<"_ _ _\n";
for ( Facet_iterator i = P.facets_begin(); i != P.facets_end(); ++i)
{
Halfedge_facet_circulator j = i->facet_begin();
// Facets in polyhedral surfaces are at least triangles.
//CGAL_assertion( CGAL::circulator_size(j) >= 3);
oof << 'f' << ' ';
do
{
oof << ' ' << std::distance(P.vertices_begin(), j->vertex())+1;
} while ( ++j != i->facet_begin());
oof << std::endl;
}
*/
return 0;
}
示例8: reconstruct
void PoissonSurfaceReconstruction::reconstruct(std::vector<Eigen::Vector3d> &points, std::vector<Eigen::Vector3d> &normals, TriangleMesh &mesh){
assert(points.size() == normals.size());
std::cout << "creating points with normal..." << std::endl;
std::vector<Point_with_normal> points_with_normal;
points_with_normal.resize((int)points.size());
for(int i=0; i<(int)points.size(); i++){
Vector vec(normals[i][0], normals[i][1], normals[i][2]);
//Point_with_normal pwn(points[i][0], points[i][1], points[i][2], vec);
//points_with_normal[i] = pwn;
points_with_normal[i] = Point_with_normal(points[i][0], points[i][1], points[i][2], vec);
}
std::cout << "constructing poisson reconstruction function..." << std::endl;
Poisson_reconstruction_function function(points_with_normal.begin(), points_with_normal.end(),
CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()));
std::cout << "computing implicit function..." << std::endl;
if( ! function.compute_implicit_function() ) {
std::cout << "compute implicit function is failure" << std::endl;
return;
}
//return EXIT_FAILURE;
// Computes average spacing
std::cout << "compute average spacing..." << std::endl;
FT average_spacing = CGAL::compute_average_spacing(points_with_normal.begin(), points_with_normal.end(),
6 /* knn = 1 ring */);
// Gets one point inside the implicit surface
// and computes implicit function bounding sphere radius.
Point inner_point = function.get_inner_point();
Sphere bsphere = function.bounding_sphere();
FT radius = std::sqrt(bsphere.squared_radius());
// Defines the implicit surface: requires defining a
// conservative bounding sphere centered at inner point.
FT sm_sphere_radius = 5.0 * radius;
FT sm_dichotomy_error = distance_criteria*average_spacing/1000.0; // Dichotomy error must be << sm_distance
//FT sm_dichotomy_error = distance_criteria*average_spacing/10.0; // Dichotomy error must be << sm_distance
std::cout << "reconstructed surface" << std::endl;
Surface_3 reconstructed_surface(function,
Sphere(inner_point,sm_sphere_radius*sm_sphere_radius),
sm_dichotomy_error/sm_sphere_radius);
// Defines surface mesh generation criteria
CGAL::Surface_mesh_default_criteria_3<STr> criteria(angle_criteria, // Min triangle angle (degrees)
radius_criteria*average_spacing, // Max triangle size
distance_criteria*average_spacing); // Approximation error
std::cout << "generating surface mesh..." << std::endl;
// Generates surface mesh with manifold option
STr tr; // 3D Delaunay triangulation for surface mesh generation
C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation
CGAL::make_surface_mesh(c2t3, // reconstructed mesh
reconstructed_surface, // implicit surface
criteria, // meshing criteria
CGAL::Manifold_tag()); // require manifold mesh
if(tr.number_of_vertices() == 0){
std::cout << "surface mesh generation is failed" << std::endl;
return;
}
Polyhedron surface;
CGAL::output_surface_facets_to_polyhedron(c2t3, surface);
// convert CGAL::surface to TriangleMesh //
std::cout << "converting CGA::surface to TriangleMesh..." << std::endl;
std::vector<Eigen::Vector3d> pts;
std::vector<std::vector<int> > faces;
pts.resize(surface.size_of_vertices());
faces.resize(surface.size_of_facets());
Polyhedron::Point_iterator pit;
int index = 0;
for(pit=surface.points_begin(); pit!=surface.points_end(); ++pit){
pts[index][0] = pit->x();
pts[index][1] = pit->y();
pts[index][2] = pit->z();
index ++;
}
index = 0;
Polyhedron::Face_iterator fit;
for(fit=surface.facets_begin(); fit!=surface.facets_end(); ++fit){
std::vector<int > face(3);
Halfedge_facet_circulator j = fit->facet_begin();
int f_index = 0;
do {
face[f_index] = std::distance(surface.vertices_begin(), j->vertex());
f_index++;
} while ( ++j != fit->facet_begin());
faces[index] = face;
index++;
}
mesh.createFromFaceVertex(pts, faces);
}