Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] How to connect Segments into Loop?
- Date: Wed, 25 Jul 2012 08:41:10 +0200
A naive way to do that is to use a kernel with exact constructions and
compare endpoints of segment to make a loop. Did you have a look
in boost graph whether they have such an algorithm?
Sebastien.
On 07/18/2012 08:29 AM, 马良 wrote:
> Hello,
> I get many segments by intersecting a plane and polyhedron. But I find
> those segments(start point:Point(x1,y1), end point: Point(x2,y2)) are
> not end to end. I want get a loop (That means adjacent two segments must
> share a same Vertex. That is to say previour segment's end point is
> current segment's start point, and current segment's end point is next
> segment's start point, And so. )
> How can I arrangement those segments?
> I think, firstly, I get a vertex of segment, then find a same vertex in
> remaining segments. Then find next.
> there have easy way to do this in CGAL?
> My source:
> //1.
> typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
> //Facet
> typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron>
> Facet_Primitive;
> typedef CGAL::AABB_traits<Kernel,Facet_Primitive> Facet_Traits;
> typedef CGAL::AABB_tree<Facet_Traits> Facet_tree;
> //
> typedef Facet_tree::Object_and_primitive_id Object_and_primitive_id;
> //
> typedef Kernel::FT FT;
> typedef Kernel::Point_3 Point;
> typedef Kernel::Plane_3 Plane;
> typedef Kernel::Vector_3 Vector;
> typedef Kernel::Segment_3 Segment;
> //2.
> Point V1(0.0,0.0,0.0);
> Point V2(1.0,0.0,0.0);
> Point V3(1.0,1.0,0.0);
> Point V4(0.0,1.0,0.0);
> Point V5(0.0,0.0,1.0);
> Point V6(1.0,0.0,1.0);
> Point V7(1.0,1.0,1.0);
> Point V8(0.0,1.0,1.0);
> //3.
> Polyhedron P;
> P.make_triangle(V1,V6,V5);
> P.make_triangle(V1,V2,V6);
> P.make_triangle(V2,V7,V6);
> P.make_triangle(V2,V3,V7);
> P.make_triangle(V3,V8,V7);
> P.make_triangle(V3,V4,V8);
> P.make_triangle(V4,V5,V8);
> P.make_triangle(V4,V1,V5);
> P.make_triangle(V5,V6,V7);
> P.make_triangle(V5,V7,V8);
> P.make_triangle(V1,V3,V2);
> P.make_triangle(V1,V4,V3);
> //4.
> Vector nor((FT)0.0,(FT)0.0,(FT)1.0);
> Point pnt((FT)0.0,(FT)0.0,0.5);
> Plane plane(pnt,nor);
> //5.1. AABB tree
> Facet_tree tree(P.facets_begin(),P.facets_end());
> //5.2. get intersections a plane and polyhedron
> std::list<Object_and_primitive_id> Intersections;
> tree.all_intersections(plane,std::back_inserter(Intersections));
> std::list<Object_and_primitive_id>::iterator it;
> std::list<Segment> m_segment;
> for(it = Intersections.begin();it!=Intersections.end();it++)
> {
> Object_and_primitive_id op = *it;
> CGAL::Object object = op.first;
> Segment segment;
> if(CGAL::assign(segment,object)) m_segment.push_back(segment);
> }
> Note:
> Here, I get intersection segments. But those segment is not link
> Sequentially.
> How to connect those segments into loop???
> Thanks
> Ma Liang
> --
> 马良 Mr.MaLiang
> State Key Laboratory of Solidification Processing
> Northwestern Polytechnical University
> Xi'an 710072, Shanxi
> P. R. China
> Tel/Fax:+86(29)88460520
> Mobile:+86(0)15829297776
> Email:
>
>
> <mailto:>
> QQ number:394646034
>
- [cgal-discuss] How to connect Segments into Loop?, 马良, 07/18/2012
- Re: [cgal-discuss] How to connect Segments into Loop?, Sebastien Loriot (GeometryFactory), 07/25/2012
- Re: [cgal-discuss] How to connect Segments into Loop?, 马良, 07/26/2012
- Re: [cgal-discuss] How to connect Segments into Loop?, Sebastien Loriot (GeometryFactory), 07/25/2012
Archive powered by MHonArc 2.6.18.