Subject: CGAL users discussion list
List archive
- From:
- To:
- Subject: Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem]
- Date: Wed, 17 Mar 2010 15:34:20 +0100
- Importance: Normal
Thank you so much, really! you helped me a lot, and I think I'm very close
now :).
I have one more question if you don't mind. I noticed that if I change the
order of the vertices added to a facet the program will give an error, and
I couldn't understand this. For example, in the second facet, if you add
the vertices in the order 1-2-3 rather than 1-3-2 (like you did it) the
program will crash. Could you please tell me why this happens? I mean I'm
going to create random polyhedra with 20 surfaces or more, how will I
judge the right order to take?
Thank you,
Regards,
Samer Afach
>
> wrote:
>> Thank you for the fast answer.
>>
>> This is actually mentioned in the manual, and this is why I'm surprised!
>> how could the program say they are halfedges while they're connected
>> from
>> 2 sides?
>>
> halfedges in polyhedron have a method is_border() (it checks whether the
> halfedge as an incident facet).
>
>> Anyone please, could you please tell me how to convert 2 halfedges to an
>> edge?
>
> There is no edge object. Please have a look at
> http://www.cgal.org/Manual/last/doc_html/cgal_manual/Polyhedron/Chapter_main.html#Section_23.2
>
>
>> I guess this would solve the problem and make my polyhedron closed!
>
> In the example I sent you, the method is_closed() returns true.
>
>> Thank you,
>> Samer Afach
>>
>>>
>>> wrote:
>>>> Thanks for the answer.
>>>>
>>>> But if I have to do this check manually, what's the purpose of the
>>>> Polyhedron::is_closed() function? I thought this function is capable
>>>> of
>>>> doing this.
>>>> And if I'm going to check this manually, why should I use the
>>>> incremental
>>>> builder? one then can create triangles from points, which is a lot
>>>> simpler
>>>> to implement (like my first example I wrote in this e-mail), and then
>>>> do
>>>> this check manually (while the check Polyhedron::is_closed() fails to
>>>> give
>>>> the right answer).
>>>>
>>>> Could you please explain what is_closed() function does?
>>> I am not an export of Polyhedron, I was not aware this function exists.
>>> I had a look at the code for the is_closed, and it is checking that no
>>> halfedge is on the boundary.
>>>> and why I'm
>>>> supposed to use the incremental builder for my task if I'm to do this
>>>> check manually?
>>>>
>>>> Is there a shorter way to create my polyhedra than I'm taking?
>>>>
>>>> Thank you,
>>>> Best regards,
>>>> Samer Afach
>>>>
>>>>>
>>>>> wrote:
>>>>>> Thank you so much for your answer.
>>>>>>
>>>>>> but I still have 1 unclear issue. I've seen that that example
>>>>>> creates
>>>>>> a
>>>>>> triangle, meaning a surface. What if I want to create a closed
>>>>>> polyhedron
>>>>>> (like a cube or a tetrahedron)? as a general question I would like
>>>>>> to
>>>>>> ask,
>>>>>> is CGAL able to form a "closed" polyhedron and know that it's closed
>>>>>> in
>>>>>> an
>>>>>> automatic manner? because as I drew in my first problem, I created
>>>>>> the
>>>>>> surfaces, but the program wasn't able to detect that it's a closed
>>>>>> polyhedron (while it's of course closed, since I followed the same
>>>>>> simple
>>>>>> point-structure of the example).
>>>>>>
>>>>>> How can I tell CGAL to confirm (not check) that my polyhedron is
>>>>>> closed,
>>>>>> so that if I use the check function Polyhedron::is_closed() I would
>>>>>> get
>>>>>> the right answer?
>>>>>>
>>>>>> Is the incremental builder the right tool for that task?
>>>>>>
>>>>>> Thank you again,
>>>>>>
>>>>>> Best Regards,
>>>>>> Samer Afach
>>>>> First note that Polyhedron can only be used to represent one or more
>>>>> surfaces.
>>>>>
>>>>> In the example joint, I manually create a tetrahedron to show that
>>>>> the
>>>>> incremental builder add faces in a clever way (halfedge are reused
>>>>> when
>>>>> you add a facet). The number of halfedges is 12.
>>>>>
>>>>> To know if your surface is closed, you can rely on the theorem of
>>>>> classification of surface and the Euler characteristic
>>>>> (http://en.wikipedia.org/wiki/Euler_characteristic).
>>>>>
>>>>> The Euler characteristic is 2 for each closed surface encoded by the
>>>>> polyhedron (the for each is really important here).
>>>>>
>>>>>
>>>>> S.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> From what I understand you probably need to use the
>>>>>>> Polyhedron_incremental_builder_3.
>>>>>>>
>>>>>>> Have a look here for the documentation (there is an example at the
>>>>>>> end
>>>>>>> of the page)
>>>>>>> http://www.cgal.org/Manual/last/doc_html/cgal_manual/Polyhedron_ref/Class_Polyhedron_incremental_builder_3.html
>>>>>>>
>>>>>>> S.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> wrote:
>>>>>>>> Dear programmers,
>>>>>>>>
>>>>>>>> I've drawn this question but no one has given me an answer. I
>>>>>>>> would
>>>>>>>> really
>>>>>>>> appreciate it so much if someone could even give me a hint to
>>>>>>>> solve
>>>>>>>> this
>>>>>>>> problem. It's really very important for me.
>>>>>>>>
>>>>>>>> Thank you in advance,
>>>>>>>>
>>>>>>>> Sincerely,
>>>>>>>> Samer
>>>>>>>>
>>>>>>>> ---------------------------- Original Message
>>>>>>>> ----------------------------
>>>>>>>> Subject: [cgal-discuss] Tetrahedron-Polyhedron problem
>>>>>>>> From: "Samer Afach"
>>>>>>>> <>
>>>>>>>> Date: Fri, March 12, 2010 5:15 pm
>>>>>>>> To:
>>>>>>>>
>>>>>>>> --------------------------------------------------------------------------
>>>>>>>>
>>>>>>>> Hello :),
>>>>>>>>
>>>>>>>> I'm starting to create some simple polyhedra in order to go to
>>>>>>>> bigger
>>>>>>>> applications, and so I'm trying to understand how this library
>>>>>>>> works
>>>>>>>> with it.
>>>>>>>>
>>>>>>>> I have a problem, the problem is that I'm failing to create 4
>>>>>>>> triangles
>>>>>>>> and form a tetrahedron from them. I'm avoiding using the function
>>>>>>>> Polyhedron::make_tetrahedron(...) because my aim in the future is
>>>>>>>> creating random polyhedra by combining triangles and check whether
>>>>>>>> they
>>>>>>>> are closed and fulfill some conditions. Here's my program:
>>>>>>>>
>>>>>>>> #include <CGAL/Homogeneous.h>
>>>>>>>> #include <CGAL/Polyhedron_traits_with_normals_3.h>
>>>>>>>> #include <CGAL/Polyhedron_3.h>
>>>>>>>> #include <iostream>
>>>>>>>> #include <algorithm>
>>>>>>>>
>>>>>>>> using namespace std;
>>>>>>>>
>>>>>>>> struct Normal_vector
>>>>>>>> {
>>>>>>>> template <class Facet>
>>>>>>>> typename Facet::Plane_3 operator()( Facet& f) {
>>>>>>>> typename Facet::Halfedge_handle h = f.halfedge();
>>>>>>>> // Facet::Plane_3 is the normal vector type. We assume the
>>>>>>>> // CGAL Kernel here and use its global functions.
>>>>>>>> return CGAL::cross_product(
>>>>>>>> h->next()->vertex()->point() - h->vertex()->point(),
>>>>>>>> h->next()->next()->vertex()->point() -
>>>>>>>> h->next()->vertex()->point());
>>>>>>>> }
>>>>>>>> };
>>>>>>>> typedef CGAL::Homogeneous<int> Kernel;
>>>>>>>> typedef Kernel::Point_3 Point_3;
>>>>>>>> typedef Kernel::Vector_3 Vector_3;
>>>>>>>> typedef CGAL::Polyhedron_traits_with_normals_3<Kernel> Traits;
>>>>>>>> typedef CGAL::Polyhedron_3<Traits> Polyhedron;
>>>>>>>> typedef Polyhedron::Halfedge_handle Halfedge_handle;
>>>>>>>> int main() {
>>>>>>>> Point_3 p( 1, 0, 0);
>>>>>>>> Point_3 q( 0, 1, 0);
>>>>>>>> Point_3 r( 0, 0, 1);
>>>>>>>> Point_3 s( 0, 0, 0);
>>>>>>>> Polyhedron P;
>>>>>>>> //P.make_tetrahedron( p, q, r, s);
>>>>>>>>
>>>>>>>> P.make_triangle(p,q,r);
>>>>>>>> P.make_triangle(p,r,s);
>>>>>>>> P.make_triangle(p,s,q);
>>>>>>>> P.make_triangle(q,s,r);
>>>>>>>>
>>>>>>>> if(P.is_closed())
>>>>>>>> {
>>>>>>>> cout<<"It's closed"<<endl;
>>>>>>>> }
>>>>>>>> if(P.is_pure_trivalent())
>>>>>>>> {
>>>>>>>> cout<<"Trivalent"<<endl;
>>>>>>>> }
>>>>>>>> std::transform( P.facets_begin(), P.facets_end(),
>>>>>>>> P.planes_begin(),
>>>>>>>> Normal_vector());
>>>>>>>> CGAL::set_pretty_mode( std::cout);
>>>>>>>> std::copy( P.planes_begin(), P.planes_end(),
>>>>>>>> std::ostream_iterator<Vector_3>( std::cout, "\n"));
>>>>>>>> return 0;
>>>>>>>> }
>>>>>>>>
>>>>>>>> I copied this program from a sample in the manual. What's
>>>>>>>> confusing
>>>>>>>> me
>>>>>>>> is that when I create a tetrahedron using the make_tetrahedron
>>>>>>>> function,
>>>>>>>> the conditions work fine, but I can't get the same output when
>>>>>>>> creating
>>>>>>>> a tetrahedron by "connecting" 3 dimensional triangles. I was even
>>>>>>>> careful having the same output as the example (same order for the
>>>>>>>> norms)
>>>>>>>>
>>>>>>>> Could anyone please tell me why that's happening, and I would
>>>>>>>> appreciate
>>>>>>>> it so much if someone also could apply the function
>>>>>>>> Polyhedron::is_tetrahedron(Polyhedron::Halfedge_handle) also,
>>>>>>>> because
>>>>>>>> I
>>>>>>>> failed to do it because I didn't know how to get the right call
>>>>>>>> for
>>>>>>>> Halfedge_handle.
>>>>>>>>
>>>>>>>> Sincerest regards,
>>>>>>>> Samer Afach
>>>>>>>> Institute of computational physics, University of Stuttgart
>>>>>>>>
>>>>>>> --
>>>>>>> You are currently subscribed to cgal-discuss.
>>>>>>> To unsubscribe or access the archives, go to
>>>>>>> https://lists-sop.inria.fr/wws/info/cgal-discuss
>>>>>>>
>>>>>>
>>>>> --
>>>>> You are currently subscribed to cgal-discuss.
>>>>> To unsubscribe or access the archives, go to
>>>>> https://lists-sop.inria.fr/wws/info/cgal-discuss
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> You are currently subscribed to cgal-discuss.
>>> To unsubscribe or access the archives, go to
>>> https://lists-sop.inria.fr/wws/info/cgal-discuss
>>>
>>
>>
>>
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
- [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/13/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/15/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], samer, 03/17/2010
- Re: [Fwd: [cgal-discuss] Tetrahedron-Polyhedron problem], Sebastien Loriot (GeometryFactory), 03/15/2010
Archive powered by MHonArc 2.6.16.