Subject: CGAL users discussion list
List archive
[cgal-discuss] subdivision of a triangle with arbitrary number of points inside
Chronological Thread
- From: "Kwangtaek Kim" <>
- To: <>
- Subject: [cgal-discuss] subdivision of a triangle with arbitrary number of points inside
- Date: Thu, 24 Jun 2010 19:36:52 -0400
- Organization: Purdue
Hello, I am trying to implement subdivision with arbitrary number
of points (based on barycentric coordinate) inside each triangle. For example, with
u,v,w of barycentric coordinate, I can define any number of Cartesian points to
add inside a triangle for subdivision. I am modifying Quad-triangle.h written
by Pierre Alliez. However, I feel difficulty to create halfedges in case of points
which are not on the edge. If we look at Quad-triangle.h, it is working for
half subdivision on each edge which is a simple case. But if we have some
points which are not on edge but inside a triangle, how can we create halfedge
to connect all added points? I have tried to implement it as the below but it
did not work. Is there anyone who knows how to solve this problem? Thank
you for your help. Samuel ****************************************************************************** // and as many as #facets with degree > 3 m_pMesh->tag_facets(-1); Polyhedron::Facet_iterator pFacet; for(pFacet = m_pMesh->facets_begin(); pFacet != m_pMesh->facets_end(); pFacet++) { unsigned int degree =
Polyhedron::degree(pFacet); CGAL_assertion(degree >= 3); if(degree == 3) continue; Polyhedron::Halfedge_handle
pHalfedge = pFacet->halfedge(); // Get trhee points of a triangle const Point& p1 =
pHalfedge->vertex()->point(); const Point& p2 =
pHalfedge->opposite()->vertex()->point(); const Point& p3 =
pHalfedge->next()->vertex()->point(); // to get the third vertex of a
traingle // store three points of a triangle into
variables float x0 = p1.x() ; float
y0 = p1.y(); float z0 = p1.z(); float x1 = p2.x() ; float
y1 = p2.y(); float z1 = p2.z(); float x2 = p3.x() ; float
y2 = p3.y(); float z2 = p3.z(); for(int i=0;i<npnts;i++
) // add npnts points inside a triangle for sudbidivion { float
x=0.0;float y=0.0;float z=0.0; // variable to store a cartesian point from
barycentric coordinate float u=
r[i][0]; float v= r[i][1]; float w= r[i][2]; // Prestored barycentric
coordinate // generate
a cartesian point with the corresponding baricentric coordinate (u,v,w)
barycentric.ConvertCartesian(x0,y0,z0,x1,y1,z1,x2,y2,z2,u,v,w,&x,&y,&z); Point
point = Point(x,y,z); // store a cartesian point
B.add_vertex(point); // add to the builder
pFacet->tag(index); // tag index ? I am not sure if this is right index++; } } |
- [cgal-discuss] subdivision of a triangle with arbitrary number of points inside, Kwangtaek Kim, 06/25/2010
Archive powered by MHonArc 2.6.16.