Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Find the perimeter of a shell with no volume

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Find the perimeter of a shell with no volume


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Find the perimeter of a shell with no volume
  • Date: Tue, 07 Jun 2011 10:42:58 +0200

One solution is to look at all halffacets and count the number of time
edges contribute to the facet. If an edge contributes only twice then
it is on the boundary.

See this example:


#include <CGAL/Simple_cartesian.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Gmpq.h>
#include <CGAL/IO/Nef_polyhedron_iostream_3.h>
#include <CGAL/OFF_to_nef_3.h>
#include <fstream>

typedef CGAL::Simple_cartesian<CGAL::Gmpq> K;
typedef CGAL::Nef_polyhedron_3<K> Nef;

Nef::Halfedge_const_handle get_edge_id(Nef::Halfedge_const_handle h){
return h < h->twin()?h:h->twin();
}

int main(int,char** argv)
{
std::ifstream in(argv[1]);
Nef N;
CGAL::OFF_to_nef_3(in,N);

std::map<Nef::Halfedge_const_handle,int> mult;
Nef::Halffacet_const_iterator halffacets_it=N.halffacets_begin();
Nef::Halffacet_const_iterator halffacets_end=N.halffacets_end();
for (;halffacets_it!=halffacets_end;++halffacets_it)
{
Nef::Halffacet_cycle_const_iterator cycles_it
= halffacets_it->facet_cycles_begin();
Nef::Halffacet_cycle_const_iterator cycles_end
= halffacets_it->facet_cycles_end();
for (;cycles_it!=cycles_end;++cycles_it){
if ( cycles_it.is_shalfedge() ){
Nef::SHalfedge_const_handle sh=cycles_it;
Nef::SHalfedge_around_facet_const_circulator hc(sh), he(hc);
CGAL_For_all(hc,he){
Nef::Halfedge_const_handle h=hc->source();
h=get_edge_id(h);
mult.insert(std::make_pair(h,0)).first->second+=1;
}
}
}
}

for (std::map<Nef::Halfedge_const_handle,int>::iterator
it=mult.begin();it!=mult.end();++it)
{
if (it->second==2){
//it->first and it->first->twin() are boundary halfedges
std::cout << it->first->source()->point() << " "
<< it->first->target()->point() << std::endl;
}
}
}

Sebastien.



wrote:
Suppose I have a Nef_polyhedron_3 consisting of a pair of non coplanar facets.
The facets share an edge.
For example if you have the vertices in [x,y,z] notation.

a=[0,0,0], b=[0,10,0], c= [10,0,0], d=[10,10,2]

and the triangles [a,b,c] and [b,d,c] they both share the edge from b to c.

how do I find the perimeter of this Nef_polyhedron_3, that is to say the four
outer edges that are not shared by more than one facet?

I am trying to find something that will work for surfaces consisting of any
number of faces which may have adjacent non coplanar facets.

I was looking at "exploring a sphere map" am I going in the right direction?

Regards

Giles





Archive powered by MHonArc 2.6.16.

Top of Page