Subject: CGAL users discussion list
List archive
- From: Cédric LE MAITRE <>
- To:
- Subject: Re: [cgal-discuss] Intersection of polyhedron
- Date: Wed, 13 Dec 2006 09:46:20 +0100
Hi Peter, Thanks a lot. I think i need to practice still a little to assimiliate CGAL mecanism... For a first time on this mailing list, i really appreciate your reactivity. For the Visual Hull demo, i try it with the latest version of QT but i had problem of compatibility at compilation and after at linkage. So i replace QT by a simple VRML export... and i see like a M and H letter silouhette intersection. So i think it works well. I'll inspire on it. Thanks, Cedric. Peter Hachenberger a écrit : Hi Cedric, first, a Polyhedron_3 can be converted to a Nef_polyhedron_3, if the Polyhedron is 2-manifold. That is not the case in your first example. The second example uses the correct approach, but here you you need to know is, that it is important how that the polyhedron is consistently oriented counterclockwise. The tetrahedra in your example are oriented clockwise. So, if you change P.make_tetrahedron(p_top, p_center, p1, p2); P.make_tetrahedron(p_top, p_center,p2, p3); to P.make_tetrahedron(p_top, p_center, p2, p1); P.make_tetrahedron(p_top, p_center, p3 p2); it works. If they are oriented clockwise, they are inside out. Then the union behaves like an intersection and the other way around. Peter On Tue, 2006-12-12 at 19:02 +0100, Cédric LE MAITRE wrote:Hi Peter, Sorry. i've seen lot of information in French on CGAL. That's why i used French in my previous mail. Indeed, what i want to do is to compute a visual hull from 2d polygon contour of silhouettes. I haven't seen the demo that you've already done for visual hull. And this is a good advice. I will have a look on it (after QT installation...) Concerning my problem with polyhedra intersection. i tried to convert my polyhedra to Nef_Polyhedra. This works well with polyhedra of a simple 3d primitive (cube, tetrahedron). But when i try on more complex polyhedron (like in the next code), my program crashes. i suppose it come of my polyhedron which is an union of tetrahedron which compose my projection cone on the silhouette. So there are some surface inside my polyhedra and maybe this is not compatible with Nef_Polyhedra creation... #include <CGAL/Simple_cartesian.h> #include <CGAL/Polyhedron_3.h> #include <CGAL/IO/Polyhedron_iostream.h> #include <CGAL/IO/Polyhedron_VRML_2_ostream.h> #include <CGAL/IO/Color.h> #include <iostream> #include <CGAL/Gmpz.h> #include <CGAL/Homogeneous.h> #include <CGAL/Nef_polyhedron_3.h> #include <CGAL/IO/Nef_polyhedron_iostream_3.h> typedef CGAL::Homogeneous<CGAL::Gmpz> Kernel; typedef CGAL::Polyhedron_3<Kernel> Polyhedron; typedef Polyhedron::Point_3 Point; typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron; int main() { Point p_top(10.0f, 10.0f, 0.0f); Point p_center(10.0f, 10.0f, -40.0f); Point p1(20.0f, 5.0f, -40.0f); Point p2(5.0f, 5.0f, -40.0f); Point p3(5.0f, 30.0f, -40.0f); Point p4(15.0f, 30.0f, -40.0f); Point p5(25.0f, 10.0f, -40.0f); Polyhedron P; P.make_tetrahedron(p_top, p_center, p1, p2); P.make_tetrahedron(p_top, p_center, p2, p3); P.make_tetrahedron(p_top, p_center, p3, p4); P.make_tetrahedron(p_top, p_center, p4, p5); P.make_tetrahedron(p_top, p_center, p5, p1); CGAL::VRML_2_ostream out( std::cout); Nef_polyhedron N1(P); // it crashes int t = N1.number_of_vertices (); Polyhedron P1; N1.convert_to_Polyhedron(P1); //std::cout << P; out << (Polyhedron)P1; return (1); } So i try with the union of tetrahedra with the Nef_Polyhedron boolean operation. But the union doesn't work. The union resulting polyhedron have 0 vertice... int main() { Point p_top(10.0f, 10.0f, 0.0f); Point p_center(10.0f, 10.0f, -40.0f); Point p1(20.0f, 5.0f, -40.0f); Point p2(5.0f, 5.0f, -40.0f); Point p3(5.0f, 30.0f, -40.0f); Point p4(15.0f, 30.0f, -40.0f); Point p5(25.0f, 10.0f, -40.0f); Polyhedron P; P.make_tetrahedron(p_top, p_center, p1, p2); Polyhedron P2; P2.make_tetrahedron(p_top, p_center, p2, p3); Nef_polyhedron N1(P); int t = N1.number_of_vertices (); // returns 4 Nef_polyhedron N2(P2); N1 += N2 int t2 = N1.number_of_vertices (); // returns 0 return (1); } Thanks a lot for helping me with my introduction into CGAL. Regards, Cedric LE MAITRE. Peter Hachenberger a écrit :Hi Cedric, my French is very bad, but I am in charge of the Nef polyehdra, so I try to help you. Usually you should write in English to this mailing list. First, you can do complex polyhedron intersections with Nef_polyhedron_3. You can get a Nef_polyhedron from a Polyhedron by using the constructor Nef_polyhedron_3(Polyhedron_3). It sounds like you had some problems with that, but my French is not good enough to understand them. If you can state your problems in English, I will help you. An advice. We already wrote a demo program for the visual hull. You can find it in demo/Nef_3. Try to compile visual_hull.cpp and run it with the given example mpi.vsh. Best, Peter On Tue, 2006-12-12 at 17:40 +0100, Cédric LE MAITRE wrote:Bonjour, Je suis novice avec la librairie CGAL et j'utilise pour la 1ere fois cette mailing-list (je ne connais donc pas les uses et coutumes). En tout cas, j'utiliserais pour cela le Français pour communiquer. Et mon message s'adresse à des développeur CGAL. Je cherche à calculer un polyèdre correspondant l'intersection de 2 polyèdres 3D. Mes polyèdres sont des cones de vues constitués d'un sommet et d'une base constituée de n points (correspondant à n points d'un contour sur un plan. L'objectif final étant de reconstruire un visual hull à partir de contour 2D de la silhouette d'une forme). Voici mon code : #include <CGAL/Simple_cartesian.h> #include <CGAL/Polyhedron_3.h> #include <CGAL/IO/Polyhedron_iostream.h> #include <CGAL/IO/Polyhedron_VRML_2_ostream.h> #include <iostream> #include <CGAL/Gmpz.h> #include <CGAL/Homogeneous.h> #include <CGAL/Nef_polyhedron_3.h> #include <CGAL/IO/Nef_polyhedron_iostream_3.h> typedef CGAL::Homogeneous<CGAL::Gmpz> Kernel; typedef CGAL::Polyhedron_3<Kernel> Polyhedron; typedef Polyhedron::Point_3 Point; typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron; int main() { Point p_top(10.0f, 10.0f, 0.0f); Point p_center(10.0f, 10.0f, -40.0f); Point p1(20.0f, 5.0f, -40.0f); Point p2(5.0f, 5.0f, -40.0f); Point p3(5.0f, 30.0f, -40.0f); Point p4(15.0f, 30.0f, -40.0f); Point p5(25.0f, 10.0f, -40.0f); Polyhedron P; P.make_tetrahedron(p_top, p_center, p1, p2); P.make_tetrahedron(p_top, p_center, p2, p3); P.make_tetrahedron(p_top, p_center, p3, p4); P.make_tetrahedron(p_top, p_center, p4, p5); P.make_tetrahedron(p_top, p_center, p5, p1); Point p2_top(20.0f, 10.0f, -10.0f); Point p2_center(-20.0f, 10.0f, -30.0f); Point p21(-20.0f, 5.0f, 0.0f); Point p22(-20.0f, 5.0f, -25.0f); Point p23(-20.0f, 30.0f, -25.0f); Point p24(-20.0f, 30.0f, -5.0f); Point p25(-20.0f, 10.0f, 5.0f); Polyhedron P2; P2.make_tetrahedron(p2_top, p2_center, p21, p22); P2.make_tetrahedron(p2_top, p2_center, p22, p23); P2.make_tetrahedron(p2_top, p2_center, p23, p24); P2.make_tetrahedron(p2_top, p2_center, p24, p25); P2.make_tetrahedron(p2_top, p2_center, p25, p21); CGAL::VRML_2_ostream out( std::cout); out << (Polyhedron)P; out << (Polyhedron)P2; return (1); } J'y crée 2 polyèdre P et P2 (qui possède une zone d'intersection). Mon problème est comment calculer le polyèdre d'intersection ? J'ai essayé de le faire en utilisant la classe Nef_Polyedron et ces opération booléenne. Or: * il est impossible de créer un Nef_Polyhedron directement à partir d'un Polyhedron tel que P et P2 * ex: Nef_polyhedron N1(P); -> plante CGAL * idem lorsque j'assaie de créer un Nef_Polyhedron en faisant l'union de tetrahedron (sans passer ? * Ex: Nef_polyhedron N1(P_tetra); // Nb de vertices de N1 résultat = 4 Nef_polyhedronN2(P_tetra2); N1 += N2; // Nb de vertices de N1 résultat = 0 !! Est-il possible de calculer l'intersection de polyèdre complexe avec CGAL ? Merci d'avance à toute les personnes qui prendront le temps de répondre à mes questions. Cédric.______________________________________________________________________ |
- [CGAL] - Intersection de polyèdres, Cédric LE MAITRE, 12/12/2006
- Re: [cgal-discuss] [CGAL] - Intersection de polyèdres, Peter Hachenberger, 12/12/2006
- Re: [cgal-discuss] Intersection of polyhedron, Cédric LE MAITRE, 12/12/2006
- Re: [cgal-discuss] Intersection of polyhedron, Peter Hachenberger, 12/12/2006
- Re: [cgal-discuss] Intersection of polyhedron, Cédric LE MAITRE, 12/13/2006
- Re: [cgal-discuss] Intersection of polyhedron, Peter Hachenberger, 12/13/2006
- Re: [cgal-discuss] Intersection of polyhedron, Cédric LE MAITRE, 12/13/2006
- Re: [cgal-discuss] Intersection of polyhedron, Peter Hachenberger, 12/12/2006
- Re: [cgal-discuss] Intersection of polyhedron, Cédric LE MAITRE, 12/12/2006
- Re: [cgal-discuss] [CGAL] - Intersection de polyèdres, Ioannis Mademlis, 12/12/2006
- Re: [cgal-discuss] [CGAL] - Intersection de polyèdres, Peter Hachenberger, 12/12/2006
Archive powered by MHonArc 2.6.16.