Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] iteration over facet of volumes nef_polyhedron_3

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] iteration over facet of volumes nef_polyhedron_3


Chronological Thread 
  • From: Atul Thakur <>
  • To:
  • Subject: Re: [cgal-discuss] iteration over facet of volumes nef_polyhedron_3
  • Date: Tue, 16 Feb 2010 11:48:37 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=p9Qc2Zp002ZL4k4OcpjVZfmNmXmVpqjvpPQtn+w373WrPkQUXfuGI6VxUOe7D+6/K7 D4w9skCh9Bdh6+NZgQECixTEiO6CliNzpow6t2V3qEtcDwe0+xrWIpcZoLnpa6afUQYQ ZYZG1o15UiXmhI75l7NyVaeQvtJimrJVmyhog=

Hi,

I am not an expert in CGAL but I used visitor pattern for exploring
the Nef based on "overwhelming" (i agree with you) documentation . May
be my code is not the optimal way of doing this but this works for me.

What essentially it does, is that, it goes through each "volume" of
the Nef and then there through each half facet and stores in my native
structure "triangle". So the output of code is vector of "triangle"s
for each volume.

You can implement various "visit" functions as given in Shell_Explorer
class, to suit your needs.

Hope the code is of some help.

-Atul


struct
{
Point_3 p1, p2, p3;
}triangle;

class Shell_explorer
{
bool first;
const Nef_polyhedron& N;
vector<triangle> m_triangle_list;

public:
Shell_explorer(const Nef_polyhedron& N_)
: first(true), N(N_) {}

void visit(Vertex_const_handle v){}
void visit(Halfedge_const_handle ){}
void visit(Halffacet_const_handle facet)
{
for (Halffacet_cycle_const_iterator it =
facet->facet_cycles_begin(); it != facet->facet_cycles_end(); it++)
{
SHalfedge_const_handle se = SHalfedge_const_handle(it);
CGAL_assertion(se!=0);
SHalfedge_around_facet_const_circulator hc_start(se);
SHalfedge_around_facet_const_circulator hc_end(hc_start);
vector <Point_3> vertices;
int count = 0;
CGAL_For_all(hc_start,hc_end)
{
SVertex_const_handle svert = hc_start->source();
Point_3 vpoint = svert->center_vertex()->point();

vertices.push_back(vpoint);
}
for (int i=0; i<vertices.size()-2; i++)
{
triangle t;
t.p1 = vertices[0];
t.p3 = vertices[i+1];
t.p2 = vertices[i+2];
m_triangle_list.push_back(t);
}

}
}
void visit(SHalfedge_const_handle ) {}
void visit(SHalfloop_const_handle ) {}
void visit(SFace_const_handle sf) {}

vector<triangle>getTriangleList()
{
vector<triangle> templist;
for (int i=0; i<m_triangle_list.size(); i++)
templist.push_back(m_triangle_list[i]);
m_triangle_list.clear();
return templist;
}
void reset_minimal_vertex() { first = true; }
};

Usage:
void main()
{
Nef_polyhedron nPoly;
Volume_const_iterator c;
Shell_explorer SE(nPoly);

CGAL_forall_volumes(c,nPoly)
{
Shell_entry_const_iterator it;
int shellcount = 0;
vector <triangle> temp;
CGAL_forall_shells_of(it,c)
{
SE.reset_minimal_vertex();
entrypaths.visit_shell_objects(SFace_const_handle(it),SE);
vector<triangle> tris = SE.getTriangleList();

}
}
}


On Tue, Feb 16, 2010 at 11:16 AM, Andre Massing
<>
wrote:
> Hi!
>
> I am looking for an way to iterate over all facets, which belong to a
> bounded volume of a Nef_polyhedron_3. ATM I am kind of overwhelmed by the
> documentation, so I am guess it's possible, but I don't see an easy way to
> accomplish this. Maybe there is somebody who give me quick hint which kind
> of iterator (combination?) I could employ??
>
> Kind regards,
> Andre Massing
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
>



--
Atul Thakur
3rd Year PhD Student,
Department of Mechanical Engineering,
University of Maryland, College Park, 20742

Home Page: http://terpconnect.umd.edu/~athakur/index.htm
Lab. Page: http://www.aml.umd.edu/facstaff/students.html



Archive powered by MHonArc 2.6.16.

Top of Page