Subject: CGAL users discussion list
List archive
- From: Atul Thakur <>
- To:
- Subject: [cgal-discuss] Nef_Polyhedron question
- Date: Fri, 20 Mar 2009 12:08:04 -0400
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=nnQfdweo5k6zEX4Bq461EmUZ5jB8FtlOV3u3lWkEV832qbjLK9B43yklC+C0ieHZeW 94DKaI8/POg2pB185Okr1nKl800NDFYeoLJPVygOZDOqXYtp+/3AJ3NocTzrVnXSeHDz qhLqL/utPgrcpAN8xfHbuqv4RHlfxOjYoqSYQ=
Hi,
I am facing difficulty in finding intersection of an Nef_Polyhedron and a plane. I have isolated my problem as the code pasted below my message.
I am trying to find intersection of a tetrahedron formed by points [<0 0 0> <1 0 0> <0 1 0> <0 0 1>] with a plane z=0.5. I am expecting that I get a polygon triangle [<0 0 0.5> <0.5 0 0.5> <0 0.5 0.5>]. But I guess I am doing something wrong in selecting Kernel. I tried three kernels (commented in code snippet below). I get a CGAL warning, when polyhedron.intersection(plane) executes as "Constructor not available for this Kernel".
Another question is that, if I need to find the polyhedron (and not the triangle polygon) obtained by intersection of halfspace represented by the plane and the polyhedron in question, what should I do? I am currently using CGAL 3.3.1. I saw the manual of CGAL 3.4 and found out that we can pass an extra argument in the intersection(plane, option). Are there any options in CGAL3.31 to do the same?
Thank you for your time,
-Atul
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_VRML_1_ostream.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Gmpz.h>
#include <CGAL/Homogeneous.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
//typedef CGAL::Homogeneous<CGAL::Gmpz> Kernel;//tried this but same warning
typedef CGAL::Simple_cartesian<CGAL::Gmpq> Kernel;
//typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;//tried this as well with same warning
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::HalfedgeDS HalfedgeDS;
typedef Kernel::Point_3 Point_3;
typedef Polyhedron::Facet_iterator Facet_iterator;
typedef Polyhedron::Halfedge_around_facet_circulator Halfedge_facet_circulator;
typedef Polyhedron::Vertex_iterator Vertex_iterator;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
typedef Nef_polyhedron::Aff_transformation_3 Aff_transformation_3;
typedef Nef_polyhedron::Plane_3 Plane_3;
void main()
{
Point_3 p( 1.0, 0.0, 0.0);
Point_3 q( 0.0, 1.0, 0.0);
Point_3 r( 0.0, 0.0, 1.0);
Point_3 s( 0.0, 0.0, 0.0);
Polyhedron P;
P.make_tetrahedron( p, q, r, s);
Nef_polyhedron npoly(P);
Kernel::RT a =0.0, b=0.0, c = 1.0, d=0.5;
Plane_3 pl(a,b,c,d);
Nef_polyhedron cnpoly = npoly.intersection(pl);
Polyhedron dispp;
cnpoly.convert_to_Polyhedron(dispp);
//////////////////////////////////////////////////
CGAL::set_ascii_mode( std::cout);
std::cout << "OFF" << std::endl << dispp.size_of_vertices() << ' '
<< dispp.size_of_facets() << " 0" << std::endl;
std::copy( dispp.points_begin(), dispp.points_end(),
std::ostream_iterator<Point_3>( std::cout, "\n"));
for (Facet_iterator i = dispp.facets_begin(); i != dispp.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(dispp.vertices_begin(), j->vertex());
} while ( ++j != i->facet_begin());
std::cout << std::endl;
}
//////////////////////////////////////////////////
}
- [cgal-discuss] Nef_Polyhedron question, Atul Thakur, 03/20/2009
Archive powered by MHonArc 2.6.16.