Subject: CGAL users discussion list
List archive
- From: "Pedro Machado Manhães de Castro" <>
- To:
- Subject: Re: [cgal-discuss] Triangulation 2 data structure problem
- Date: Wed, 26 Mar 2008 11:01:42 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=fHVEEskqGoQflvy0hVi2dZ2U+at1U66q0krCzvkhzJnSGmt8NLQEArfXRnXYlbHYHN9cT1ro0kpK9rnYpwwQVWJKY0F5aZIopYe/h4iLBLVMSAYs4nOVyNn9gLecqZ+f/5EKdXLA2Ww0zrk6SLy1bbyTOkbY0GFopufLdWspu9A=
Hello Louis,
I've implemented a program that begins a TDS from the very beginning.
One important thing to notice is that the TDS() is independent of the geometry, and the Triangulation is not.
So if you wanna use the tds() of the Triangulation extra care have to be taken, it is very error prone.
I also tried to comment what I think it is important to you to know.
However, I really suggest you to use the Triangulation_2 insert() and remove() methods instead, believe me, you will have happier days.
Best regard,
Pedro Machado
PS: code att
On Wed, Mar 26, 2008 at 10:02 AM, <> wrote:
The most important information here might be the fact that "the set of
maintained faces is topologically equivalent to a two-dimensional
triangulated sphere." See the user manual (Section 1 - definition, in
particular 26.1.2 The Set of Faces and Vertices, that also mentions the
lower dimensional cases).
best
Monique Teillaud
Louis wrote:
> Thanks for the information Pedro. Initially I didn't set the
> neighborhood information because I don't know what are done
> automatically in by the data structure itself or what the user has to
> specify. When I insert a vertex or face, calling vertex.is_valid() or
> face.is_valid() all returned true. But the triangulation data
> structure remained invalid. Now after I set the neighborhood
> information, the triangulation still says it's invalid. I'm also not
> sure about boundary faces where 1 or 2 neighbor faces are not defined,
> do I need to do anything special in this case?
>
> What's frustrating is the lack of information in the documentation on
> what are the necessary steps to build a valid triangulation using this
> data structure. There are many weird behaviors in this data structure
> that need answers. Why does the class initialize with 0 vertices, 1
> face, 1 edge? Calling tds.clear() made sure they became 0, but when
> you add the first vertex, somehow it's not counted
> (number_of_vertices() returns 0).
>
> I wonder if anyone has a concrete example or maybe skeleton code that
> shows how to build a triangulation data structure from vertices and
> faces.
>
> Thanks,
> Louis
>
>
> On Tue, Mar 25, 2008 at 7:27 AM, Pedro Machado Manhães de Castro
> <> wrote:
>
>>I meant stuffs like:
>>
>>fHandle->set_neighbor(0, some_face_handle_1);
>>fHandle->set_neighbor(1, some_face_handle_2);
>>fHandle->set_neighbor(2, some_face_handle_3);
>>sry (to not confuse even more),
>>Pedro
>>
>>
>>
>>On Tue, Mar 25, 2008 at 3:25 PM, Pedro Machado Manhães de Castro
>><> wrote:
>>
>>>Hello,
>>>
>>>Do you define the neighborhood of your face inside your 2nd for iteration?
>>>
>>>Stuffs like:
>>>fHandle->set_neighbor(0, some_face_handle_1);
>>>fHandle->set_neighbor(0, some_face_handle_2);
>>>fHandle->set_neighbor(0, some_face_handle_3);
>>>inside
>>>
>>>?
>>>
>>>This constructor here is easier to use:
>>>create_face(Face_handle f1, int i1,
>>> Face_handle f2, int i2,
>>> Face_handle f3, int i3)
>>>
>>>You define a face by its 3 neighbors, i1, i2, i3 are any sequence defined
>>
>>by the indices 0, 1, 2.
>>
>>>Hope it could help,
>>>Best Regard,
>>>Pedro Machado
>>>
>>>
>>>
>>>
>>>
>>>On Tue, Mar 25, 2008 at 11:43 AM, Louis Feng <>
>>
>>wrote:
>>
>>>>Hello,
>>>>
>>>>I'm trying to construct a 2D triangle mesh from a list of vertices and
>>>>faces. I didn't want to use Polyhedron because I needed some properties
>>
>>from
>>
>>>>the 2D triangulation class. I'm using Triangulation_2 and
>>>>Triangulation_data_structure_2. Basically I use T.tds() to get a
>>
>>reference
>>
>>>>to the internal data structure. Then I add vertices and faces to it. But
>>>>this has become very confusing and I couldn't find examples on this.
>>>>
>>>>An outline of my code:
>>>>
>>>>triDS.set_dimension(2);
>>>>for(...) {
>>>> VertexHandle vHandle = triDS.create_vertex();
>>>> vHandle->set_point(Point2(...));
>>>>}
>>>>for(...) {
>>>> FaceHandle fHandle = triDS.create_face(vHandle1, vHandle2, vHandle3); }
>>>>
>>>>When I check triDS.is_valid() at the end, it returns false. More
>>>>interestingly, before I add anything to triDS, when I check the
>>
>>vertices,
>>
>>>>edge, etc. I get this
>>>>
>>>>Triangulation vertices: 0
>>>>Triangulation faces: 1
>>>>Triangulation full faces: 1
>>>>Triangulation edges: 1
>>>>
>>>>So am I suppose to clear this before I add something to it? Looking at
>>
>>the
>>
>>>>template file for the data structure, it check this:
>>>>
>>>>case 2:
>>>> result = result && edge_count == 3*face_count/2 ;
>>>> CGAL_triangulation_assertion(edge_count == 3*face_count/2);
>>>> break;
>>>>
>>>>I'm not sure what the expected behavior is. Could someone tell me what
>>
>>I'm
>>
>>>>doing wrong and how this class suppose to be used? Thanks!
>>>>
>>>>Louis
>>>>
>>>>--
>>>>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
#ifndef MY_TEST #define MY_TEST //CGAL headers #include <CGAL/Simple_cartesian.h> #include <CGAL/Filtered_kernel.h> #include <CGAL/Lazy_exact_nt.h> #include <CGAL/Interval_nt.h> #include <CGAL/Quotient.h> #include <CGAL/MP_Float.h> #include <CGAL/Lazy_kernel.h> #include <CGAL/Triangulation_2.h> #include <CGAL/Triangulation_data_structure_2.h> typedef CGAL::Interval_nt<false> Interval; typedef CGAL::Lazy_exact_nt< CGAL::Quotient< CGAL::MP_Float > > FT; typedef CGAL::Simple_cartesian< FT > NonFilteredKernel; typedef CGAL::Filtered_kernel< NonFilteredKernel > K; template <typename T> void small_example() { typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Face_handle Face_handle; typedef typename T::Point Point; T tr; // T tr begins with a vertex and a face // (vertex at infinity, and "dimension -1 :)" // if you wanna start from the very begining // you need to clear // see: std::cout << tr.tds().number_of_vertices() << std::endl; std::cout << tr.tds().number_of_full_dim_faces() << std::endl; tr.tds().clear(); // I'll make a small triangulation DS consisting of 4 faces and 4 vertices // note that at this level tds geometric info as point do not matter // but if you need to visualize think v1, v2, v3 are counterclockwise // on the plane and v4 is a point at the infinity Vertex_handle v1 = tr.tds().create_vertex(); Vertex_handle v2 = tr.tds().create_vertex(); Vertex_handle v3 = tr.tds().create_vertex(); Vertex_handle v4 = tr.tds().create_vertex(); Face_handle f1 = tr.tds().create_face(v1, v2, v3); Face_handle f2 = tr.tds().create_face(v1, v4, v2); Face_handle f3 = tr.tds().create_face(v1, v3, v4); Face_handle f4 = tr.tds().create_face(v2, v4, v3); f1->set_neighbor(0, f4); f1->set_neighbor(1, f3); f1->set_neighbor(2, f2); f2->set_neighbor(0, f4); f2->set_neighbor(1, f1); f2->set_neighbor(2, f3); f3->set_neighbor(0, f4); f3->set_neighbor(1, f2); f3->set_neighbor(2, f1); f4->set_neighbor(0, f3); f4->set_neighbor(1, f1); f4->set_neighbor(2, f2); // each created vertex needs to point do a face that contains it // so we can use all the features that need circulator // and circulator itself v1->set_face(f1); v2->set_face(f2); v3->set_face(f3); v4->set_face(f4); // you need to do that if you want to work with only the tds() // ignoring what Triangulation_2 can give to you automaticaly tr.tds().set_dimension(2); std::cout << tr.tds().is_valid() << std::endl; } int main() { small_example< CGAL::Triangulation_2<K> >(); return 0; } #endif //MY_TEST
- Triangulation 2 data structure problem, Louis Feng, 03/25/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Pedro Machado Manhães de Castro, 03/25/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Pedro Machado Manhães de Castro, 03/25/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Louis, 03/25/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Monique . Teillaud, 03/26/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Pedro Machado Manhães de Castro, 03/26/2008
- RE: [cgal-discuss] Triangulation 2 data structure problem, Louis Feng, 03/30/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Pedro Machado Manhães de Castro, 03/26/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Monique . Teillaud, 03/26/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Louis, 03/25/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Pedro Machado Manhães de Castro, 03/25/2008
- Re: [cgal-discuss] Triangulation 2 data structure problem, Pedro Machado Manhães de Castro, 03/25/2008
Archive powered by MHonArc 2.6.16.