Subject: CGAL users discussion list
List archive
- From: "naresh" <>
- To: <>
- Subject: Re: [cgal-discuss] Alpaha shape question
- Date: Thu, 19 Mar 2009 09:49:39 +0530
Hi
I have tried to do as you said but it is not showing shape as it should be . I am posting some code here . Please tell me what i am doing wrong
Alpha_shape alpha_shape;
alpha_shape.make_alpha_shape(Points.begin(), Points.end());
alpha_shape.set_alpha(50);
std::list<Facet> facets;
alpha_shape.get_alpha_shape_facets(std::back_inserter(facets), Alpha_shape::REGULAR);
std::ofstream outfile;
outfile.open ("test.obj");
for(std::list<Facet>::iterator fit = facets.begin(); fit != facets.end(); ++fit)
{
const Cell_handle& ch = fit->first;
const int index = fit->second;
const Point3& a = ch->vertex((index+1)&3)->point();
const Point3& b = ch->vertex((index+2)&3)->point();
const Point3& c = ch->vertex((index+3)&3)->point();
outfile << "v " << a.x() << " " << a.y() << " " << a.z() << std::endl;
outfile << "v " << b.x() << " " << b.y() << " " << b.z() << std::endl;
outfile << "v " << c.x() << " " << c.y() << " " << c.z() << std::endl;
}
int count = 0;
for(std::list<Facet>::iterator fit = facets.begin(); fit != facets.end(); ++fit)
{
int a = count + 0;
int b = count + 1;
int c = count + 2;
count += 3;
outfile << "f " << a << " " << b << " " << c << std::endl;
}
outfile.close();
I hade tried to save wavefront obj file. I have doubt about Faces structure that i had saved.
Alex
----- Original Message ----- From: "Andreas Fabri" <>
To:
<>
Sent: Wednesday, March 18, 2009 3:46 PM
Subject: Re: [cgal-discuss] Alpaha shape question
naresh wrote:
Hi
How can i save Alpha_shape_3 to .off file. ? I want to save trianglulated shape to off file .
Is that any way to save it ?
Alex
Hi Alex,
You have to code it by hand, but that shouldn't be too dificult.
print the header with the number of vertices and facets
Use a std::map<Vertex_handle, int>, traverse all alpha shape
vertices, check if they are in the map, and if not, put them in
there and increment a counter that started at 0. At the same
time print the x y z
Traverse all alpha shape facets and for the three vertices of the
facet read the indices from the map Print 3 i j k
where "3" indicates that the face has three vertices.
Hope this helps,
andreas
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
- [cgal-discuss] How to rotate Segment_2, (continued)
- [cgal-discuss] How to rotate Segment_2, naresh, 03/06/2009
- [cgal-discuss] Sweep Line Running slow, naresh, 03/07/2009
- Re: [cgal-discuss] Sweep Line Running slow, Ophir Setter, 03/07/2009
- [cgal-discuss] Point Rotation problem or Bug ?, naresh, 03/12/2009
- [cgal-discuss] How to find center of mass and principal inertial axis of 3D model?, Samay Kumar, 03/13/2009
- Re: [cgal-discuss] How to find center of mass and principal inertial axis of 3D model?, naresh, 03/13/2009
- Re: [cgal-discuss] How to find center of mass and principal inertial, Ashwin N, 03/14/2009
- Re: [cgal-discuss] Point Rotation problem or Bug ?, Ashwin N, 03/14/2009
- [cgal-discuss] Point Rotation problem or Bug ?, naresh, 03/12/2009
- [cgal-discuss] Alpaha shape question, naresh, 03/18/2009
- Re: [cgal-discuss] Alpaha shape question, Andreas Fabri, 03/18/2009
- Re: [cgal-discuss] Alpaha shape question, naresh, 03/19/2009
- Re: [cgal-discuss] Sweep Line Running slow, Ophir Setter, 03/07/2009
- [cgal-discuss] Sweep Line Running slow, naresh, 03/07/2009
- [cgal-discuss] How to rotate Segment_2, naresh, 03/06/2009
- Re: [cgal-discuss] How to rotate Segment_2, Ashwin N, 03/09/2009
- Re: Re: [cgal-discuss] how to output a point's coordinate, zengming, 03/06/2009
Archive powered by MHonArc 2.6.16.