Subject: CGAL users discussion list
List archive
- From: 马良 <>
- To:
- Subject: [cgal-discuss] How to connect Segments into Loop?
- Date: Wed, 18 Jul 2012 14:29:58 +0800
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.
//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.
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(V1,V6,V5);
P.make_triangle(V1,V2,V6);
P.make_triangle(V2,V7,V6);
P.make_triangle(V2,V3,V7);
P.make_triangle(V2,V3,V7);
P.make_triangle(V3,V8,V7);
P.make_triangle(V3,V4,V8);
P.make_triangle(V3,V4,V8);
P.make_triangle(V4,V5,V8);
P.make_triangle(V4,V1,V5);
P.make_triangle(V4,V1,V5);
P.make_triangle(V5,V6,V7);
P.make_triangle(V5,V7,V8);
P.make_triangle(V5,V7,V8);
P.make_triangle(V1,V3,V2);
P.make_triangle(V1,V4,V3);
//4.
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);
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
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));
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);
}
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
State Key Laboratory of Solidification Processing
Northwestern Polytechnical University
Xi'an 710072, Shanxi
P. R. China
Tel/Fax:+86(29)88460520
- [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.