Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp


Chronological Thread 
  • From: Alejandro Aguilar Sierra <>
  • To:
  • Subject: Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp
  • Date: Wed, 7 Oct 2009 09:23:45 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=EMLdP2Dxioa0ml/gBbkuARPKzXzZNYu4Prvf7XLeS2XnU8jz55ufKBWzYd5WONqoFC weJHa76X541YiPI6QFcpg5M9ZZ/BpGNYBxtmvwe0dWFlXCrH/Uyr6nJMKIbozXVG+9pe uBim7Lts4cpyQDVTiCFl6eGHyUA2yORDhkcGc=

Hi Matt,

Thank you for the hint. Actually what I want is to get the index of
the vertices on the container so I can build a drawable OBJ file.

A dirrty way to do it is using this code:

for (CDT::Face_iterator fit = cdt.faces_begin(); fit!=
cdt.faces_end(); ++fit) {
int idx = 0;
int i0, i1, i2;

for (CDT::Vertex_iterator vit = cdt.vertices_begin(); vit!=
cdt.vertices_end(); ++vit) {
idx++;
if ((*vit).point() == (*fit).vertex(0)->point()) i0 = idx;
if ((*vit).point() == (*fit).vertex(1)->point()) i1 = idx;
if ((*vit).point() == (*fit).vertex(2)->point()) i2 = idx;
}

std::cout << "f " << i0 << " " << cdt.triangle(fit) << std::endl;
}

And I get a drawable mesh. Is there a cleaner way?

Regards.

-- A.


On Wed, Oct 7, 2009 at 7:21 AM, Matthew Denno
<>
wrote:
> Alejandro,
>
> Here is a link to the thread on Nabble:
>
> http://www.nabble.com/Question-on-Triangulation-ts25388558.html
>
> Hope it helps.
>
> Matt
>
> On Wed, Oct 7, 2009 at 8:04 AM, Matthew Denno
> <>
> wrote:
>>
>> I am not at my computer right now but if I recall there was a thread
>> discussing how to do this a few weeks back.  Maybe you could search and
>> find
>> it.
>>
>> On Oct 7, 2009 12:56 AM, "Alejandro Aguilar Sierra"
>> <>
>> wrote:
>>
>> Hello:
>>
>> I am studyng example examples/Mesh_2/mesh_global.cpp. The last line
>> prints the number of vertices.
>>
>> std::cout << "Number of vertices: " << cdt.number_of_vertices() <<
>> std::endl;
>>
>> I want to print instead the vertices and then the faces, so I can draw
>> the mesh with any mesh viewer.  Actually I am trying to create an OBJ
>> file.
>>
>> First I print the vertices
>>
>> for (CDT::Vertex_iterator vit = cdt.vertices_begin(); vit!=
>> cdt.vertices_end(); ++vit) {
>>    std::cout << "v " << (*vit) << " 0" << std::endl;
>>  }
>>
>> Now I want to print the faces, but just the individual faces prints
>> nothing.
>>
>> for (CDT::Face_iterator fit = cdt.faces_begin(); fit!=
>> cdt.faces_end(); ++fit) {
>>    std::cout << "f " << (*fit) << std::endl;
>> }
>>
>> Yes I am looking and trying, but no success so far.
>>
>> How can I get the vertices information from the faces?
>>
>> Any hint?
>>
>> Regards,
>>
>> --
>> Alejandro Sierra
>> --
>> You are currently subscribed to cgal-discuss.
>> To unsubscribe or access the archives, go to
>> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
>



Archive powered by MHonArc 2.6.16.

Top of Page