Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Is it the right way to do that

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Is it the right way to do that


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Is it the right way to do that
  • Date: Wed, 05 Sep 2012 07:27:02 +0200
  • Organization: GeometryFactory

On 09/04/2012 02:24 PM, babaOroms wrote:
Hi everybody,
I have a question before going in depth in my code.
I have a set of 3D points in the same plane. With the CGAL framework, it's
impossible to do 3D polygons so I have chosen to do a 3D polyhedron with my
3D points. The result is on this picture :
http://cgal-discuss.949826.n4.nabble.com/file/n4655791/poly1.png
The construction of this polyhedron is :

template<class HDS>
void Build_polygon<HDS>::operator()( HDS& hds )
{
if (!polygon)
return;

// Postcondition: `hds' is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B( hds, true);
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;

B.begin_surface( polygon->points().count(), 1, 0); //Surface with
several points

foreach (RPoint3d* p, polygon->points()) { //iterates all points
B.add_vertex(Point(p->x(), p->y(), p->z()));
}
B.begin_facet();
for (int i = 0; i< polygon->points().count(); i++)
B.add_vertex_to_facet( i);
B.end_facet();
B.end_surface();
}

Now I need to have the intersection between this polyhedron and a plane :
Tree tree(polyhedron()->facets_begin(),polyhedron()->facets_end());
Point p((FT)0.0, (FT)0.0, z);
Plane plane(p,normal);
std::list<Object_and_primitive_id> intersections;
tree.all_intersections(plane,std::back_inserter(intersections));

This code crash but if I declare several polyhedron of 3 points instead, the
intersection works.
If the polyhedron is not triangulated and Tree::Primitive::Datum is a
triangle, then this can not work.


The result of the intersection I need is a segment.
Note that the intersection might be several segments.

What you need to use is a AABB_tree with AABB_polyhedron_segment_primitive as primitive [0].

Then compute all the intersections. You will have a set of points
(and segments if the plane contains a segment of the polygon).

You can sort the points using a dot product with the left-down most
point.

Then you can get the segments using adjacent points, taking care that the plane might go through a segment endpoint

[0] http://www.cgal.org/Manual/latest/doc_html/cgal_manual/AABB_tree_ref/Class_AABB_polyhedron_segment_primitive.html

Sebastien.


So to resume, is the polyhedron the best way to have a segment as result ?
Does exists another class instead ?

Laurent Rineau said to me in other topic that I can do 3D triangulation of
my polyhedron. The result is not that I am expected (see the following
picture) :
http://cgal-discuss.949826.n4.nabble.com/file/n4655791/poly2.png
The triangulation gives facets at the exterior of my polehydron.
The good news is that the intersections algorithm works.

Thanks in advance for your advices



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Is-it-the-right-way-to-do-that-tp4655791.html
Sent from the cgal-discuss mailing list archive at Nabble.com.





Archive powered by MHonArc 2.6.18.

Top of Page