cgal/Parameterization/doc_tex/Parameterization/output.tex

75 lines
2.5 KiB
TeX

\section{Output}
All parameterization methods store the result in the $(u,v)$ fields of
the input mesh vertices and halfedges. A $(u,v)$ pair is provided for
each inner vertex, while a $(u,v)$ pair is provided for each boundary
halfedge (possibly a seam in the mesh). The user has to iterate over
the corresponding mesh elements to get the result.
Note: $(u,v)$ fields do not exist in CGAL \ccc{Polyhedron_3} and
\ccc{Triangulation_data_structure_2}, thus the output traversal is specific to the way the (u,v) fields are implemented.
\subsection{EPS Output Example}
The C++ code below gets the $(u,v)$ fields computed by a
parameterization method in a \ccc{Polyhedron_3} mesh with a
\ccc{Parameterization_polyhedron_adaptor_3} adaptor. Note that
\ccc{Parameterization_polyhedron_adaptor_3} stores $(u,v)$ pairs in
halfedges (both inner and border).
\begin{ccExampleCode}
// CGAL kernel
typedef CGAL::Cartesian<double> Kernel;
// Mesh true type and parameterization adaptors
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Parameterization_polyhedron_adaptor_3<Polyhedron>
Parameterization_polyhedron_adaptor;
...
// Dump parameterized mesh to an eps file
static bool write_file_eps(const Parameterization_polyhedron_adaptor& mesh_adaptor,
const char *pFilename,
double scale = 500.0)
{
// Get actual mesh from adaptor
const Polyhedron* mesh = mesh_adaptor.get_adapted_mesh();
FILE *pFile = fopen(pFilename,"wt");
...
// Get (u,v) pair of each halfedge (either inner or border)
for (pHalfedge = mesh->halfedges_begin();
pHalfedge != mesh->halfedges_end();
pHalfedge++)
{
double x1 = scale * mesh_adaptor.info(pHalfedge->prev())->uv().x();
double y1 = scale * mesh_adaptor.info(pHalfedge->prev())->uv().y();
double x2 = scale * mesh_adaptor.info(pHalfedge)->uv().x();
double y2 = scale * mesh_adaptor.info(pHalfedge)->uv().y();
fprintf(pFile,"%g %g %g %g E\n",x1,y1,x2,y2);
}
...
fclose(pFile);
}
int main(int argc,char * argv[])
{
Polyhedron mesh;
...
// The parameterization package needs an adaptor to handle Polyhedron_3 meshes
Parameterization_polyhedron_adaptor mesh_adaptor(&mesh);
// Parameterization
...
// Write Postscript file
write_file_eps(mesh_adaptor, output_filename);
}
\end{ccExampleCode}
See the complete example in \ccc{Taucs_parameterization.C}.