Subject: CGAL users discussion list
List archive
- From: "Shi Yan" <>
- To:
- Subject: Re: [cgal-discuss] how to output a polyhedron to an obj file?
- Date: Sun, 29 Jun 2008 05:56:08 -0700
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=C4mNjB3QdIkpqkEAAsxndFE/NXT/drJDdDHXZa1Ui3br5V95aPxGY7Fb6sW/omC3aV ZYO2s4ezKe3S9MZ4LlOGMKrIWpaiM0LJI6LfbAyoAlfkE/6E9UFgF8yl8uxFxXUIDDQs Trn6xvsrS0lzyAPjGQssAIfj6Ba6w40MuldF4=
so, there is no ready made ostream for obj format, right?
CGAL claims that it supports the obj output format, but i can't find
the obj_ostream.
on this page, only four ostreams are listed:
http://www.math.unizh.ch/sepp/cgal-2.4-mo/basic_lib/Polyhedron/Chapter_main.html
Additional formats supported for writing are OpenInventor (.iv)
[Wer94], VRML 1.0 and 2.0 (.wrl) [BPP95, VRM96, HW96], and Wavefront
Advanced Visualizer object format (.obj). Another convenient output
function writes a polyhedral surface to a GeomView process spawned
from the CGAL program. These output functions are provided as stream
operators, now acting on the stream type of the respective format.
#include <CGAL/IO/Inventor_ostream.h>
#include <CGAL/IO/VRML_1_ostream.h>
#include <CGAL/IO/VRML_2_ostream.h>
#include <CGAL/IO/Geomview_stream.h>
thank you.
On Sun, Jun 29, 2008 at 5:17 AM, Pierre Alliez
<>
wrote:
> hi Bill,
>
> one solution is to hack something like (assume member function of your
> enriched polyhedron)
>
> // write in obj file format (OBJ).
> void write_obj(char *pFilename,
> int incr = 1) // 1-based by default
> {
> std::ofstream stream(pFilename);
>
> // output vertices
> for(Point_iterator pPoint = points_begin();
> pPoint != points_end();
> pPoint++)
> stream << 'v' << ' ' << pPoint->x() << ' ' <<
> pPoint->y() << ' ' <<
> pPoint->z() << std::endl;
>
> // precompute vertex indices
> this->set_index_vertices();
>
> // this assumes you have defined an index per vertex
> // and the function:
>
> void set_index_vertices()
> {
> unsigned int index = 0;
> for(Vertex_iterator v = vertices_begin();
> v!= vertices_end();
> v++)
> v->index(index++);
> }
> // or something with a STL map to associate one index per vertex
>
>
> // output facets
> for(Facet_iterator pFacet = facets_begin();
> pFacet != facets_end();
> pFacet++)
> {
> stream << 'f';
> Halfedge_around_facet_circulator pHalfedge = pFacet->facet_begin();
> do
> stream << ' ' << pHalfedge->vertex()->index()+incr;
> while(++pHalfedge != pFacet->facet_begin());
> stream << std::endl;
> }
> }
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
--
Dept. of Computer Science
University of California, Davis
Homepage:http://wwwcsif.cs.ucdavis.edu/~yans/
- [cgal-discuss] how to output a polyhedron to an obj file?, Shi Yan, 06/29/2008
- Re: [cgal-discuss] how to output a polyhedron to an obj file?, Pierre Alliez, 06/29/2008
- Re: [cgal-discuss] how to output a polyhedron to an obj file?, Shi Yan, 06/29/2008
- Re: [cgal-discuss] how to output a polyhedron to an obj file?, Pierre Alliez, 06/29/2008
Archive powered by MHonArc 2.6.16.