I am trying to access the plane parameters from CGAL Polyhedron object. Well, I can see them in the console output but I like to store these plane parameters (A,B,C,D) into a variable or a vector for further processing.
Here is my C++ program:
#define _SCL_SECURE_NO_WARNINGS //to avoid compiler warning for C++ transform parameter
#include <iostream>
#include <vector>
#include <cmath>
//CGAL header files
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <algorithm>
using namespace std;
struct Plane_equation {
template <class Facet>
typename Facet::Plane_3 operator()(Facet& f) {
typename Facet::Halfedge_handle h = f.halfedge();
typedef typename Facet::Plane_3 Plane;
return Plane(h->vertex()->point(),
h->next()->vertex()->point(),
h->next()->next()->vertex()->point());
}
};
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Plane_3 Plane_3;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
int main()
{
Point_3 p(-3, 4, 1);
Point_3 q(0, 2, 5);
Point_3 r(3, 6, -2);
//Point_3 s(24, 4, 4);
Polyhedron P;
P.make_triangle(p, q, r); //define triangle with points a,b,c
std::transform(P.facets_begin(), P.facets_end(), P.planes_begin(),
Plane_equation());
CGAL::set_pretty_mode(std::cout);
std::copy(P.planes_begin(), P.planes_end(),
std::ostream_iterator<Plane_3>(std::cout, "\n"));
std::getchar();
return 0;
}
The output plane parameters which I like to store into variables:
Plane_3(-2,33,18,-156)
Aucun commentaire:
Enregistrer un commentaire