CGAL: как я могу получить все вершины выпуклой оболочки 3?

У меня есть элементарный вопрос о выпуклой оболочке 3 в CGAL. ​​Я создаю выпуклую оболочку, и я хотел бы вычислить центр этой выпуклой оболочки, а затем вычислить площадь такого вида треугольника: (vertex [i], vertex [i +] 1], в центре)
но я не знаю, как получить вершины ….

вот мой код:

#include <CGAL/Simple_cartesian.h>
#include <CGAL/linear_least_squares_fitting_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/convex_hull_3.h>
#include <CGAL/Plane_3.h>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <vector>
#include <numeric>
#include <functional>
#include <fstream>
#include <ostream>
#include <sstream>
#include <string>
#include <iostream>
#include <boost/iterator/transform_iterator.hpp>
typedef CGAL::Simple_cartesian<double>  K;
typedef CGAL::Polyhedron_3<K>               Polyhedron_3;
typedef K::Plane_3                  Plane;
typedef K::Point_3                  Point;
typedef Polyhedron_3::Vertex_iterator Vertex_iterator;
typedef Polyhedron_3::Vertex_handle Vertex_handle;struct CxhullVertices
{
//template <class Facet>
Polyhedron_3::Point_3 operator()(Polyhedron_3::Facet& f)
{
Polyhedron_3::Halfedge_handle h = f.halfedge();
return Polyhedron_3::Point_3(h->vertex()->point(),
h->next()->vertex()->point(),
h->next()->next()->vertex()->point());
}
};
int main()
{

std::vector<double> alldata;
std::ifstream infile;
infile.open("V1L3.txt");
double temp;
if(!infile) return 0.0;
while(!infile.eof())
{
infile>>temp;
alldata.push_back(temp);
}
infile.close();
std::vector<Point> points1;
for(int i2=0;i2<alldata.size()/3;i2++)
{
double a1 = alldata[3*i2+0];
double a2 = alldata[3*i2+1];
double a3 = alldata[3*i2+2];
points1.push_back(Point(a1,a2,a3));
}
Polyhedron_3 poly;
CGAL::convex_hull_3(points1.begin(),points1.end(),poly);
std::transform( poly.facets_begin(), poly.facets_end(), poly.planes_begin(),CxhullVertices());
CGAL::set_ascii_mode( std::cout);
std::copy(poly.vertices_begin(),poly.vertices_end(),std::ostream_iterator<Point>( std::cout, "\n"));

return 0;
}

Я знаю, что должны быть проблемы с моим кодом, но я не знаю, что делать, пожалуйста, помогите мне, спасибо

0

Решение

Задача ещё не решена.

Другие решения


По вопросам рекламы ammmcru@yandex.ru
Adblock
detector