mirror of https://github.com/CGAL/cgal
Fix PMP IO + doc
This commit is contained in:
parent
33e1329101
commit
0790dc623d
|
|
@ -98,6 +98,8 @@ bool read_polygon_mesh(std::istream& is,
|
|||
* \pre The data must represent a 2-manifold
|
||||
*
|
||||
* \return `true` if reading was successful, `false` otherwise.
|
||||
*
|
||||
* \sa \link PMP_IO_grp `CGAL::Polygon_mesh_processing::read_polygon_mesh()`\endlink if the data is not 2-manifold
|
||||
*/
|
||||
template <class Graph, typename NamedParameters>
|
||||
bool read_polygon_mesh(const std::string& fname,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
///
|
||||
/// \ingroup PkgPolygonMeshProcessingRef
|
||||
|
||||
|
||||
/// \defgroup hole_filling_grp Hole Filling
|
||||
/// Functions to fill holes given as a range of halfedges or as range of points.
|
||||
/// \ingroup PkgPolygonMeshProcessingRef
|
||||
|
|
@ -39,7 +38,6 @@
|
|||
/// Functions to repair polygon soups and polygon meshes.
|
||||
/// \ingroup PkgPolygonMeshProcessingRef
|
||||
|
||||
|
||||
/// \defgroup PMP_distance_grp Distance Functions
|
||||
/// Functions to compute the distance between meshes, between a mesh and a point set and between a point set and a mesh.
|
||||
/// \ingroup PkgPolygonMeshProcessingRef
|
||||
|
|
@ -226,6 +224,8 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage.
|
|||
- `CGAL::Polygon_mesh_processing::border_halfedges()`
|
||||
- `CGAL::Polygon_mesh_processing::extract_boundary_cycles()`
|
||||
- `CGAL::Polygon_mesh_processing::transform()`
|
||||
- \link PMP_IO_grp `CGAL::Polygon_mesh_processing::IO::read_polygon_mesh()`\endlink
|
||||
|
||||
\cgalCRPSection{I/O Functions}
|
||||
- \link PMP_IO_grp `CGAL::Polygon_mesh_processing::read_polygon_mesh()`\endlink
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ Circulator
|
|||
Generator
|
||||
Kernel_23
|
||||
Property_map
|
||||
Polygon_mesh_processing
|
||||
Polyhedron
|
||||
Solver_interface
|
||||
Spatial_sorting
|
||||
|
|
|
|||
|
|
@ -8,21 +8,23 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_PMP_IO_POLYGON_MESH_IO_H
|
||||
#define CGAL_PMP_IO_POLYGON_MESH_IO_H
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/repair_polygon_soup.h>
|
||||
#include <CGAL/license/Polygon_mesh_processing.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
|
||||
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
|
||||
#include <CGAL/Polygon_mesh_processing/repair_polygon_soup.h>
|
||||
|
||||
#include <CGAL/IO/polygon_soup_io.h>
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
#include <CGAL/IO/polygon_soup_io.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
|
@ -31,44 +33,83 @@
|
|||
|
||||
namespace CGAL {
|
||||
namespace Polygon_mesh_processing {
|
||||
namespace IO {
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup PMP_IO_grp
|
||||
|
||||
* \brief read a file as a polygon soup, and then repair and orient it before trying to convert it
|
||||
* into a `FaceGraph`.
|
||||
* \param fname the name of the input file.
|
||||
* \param g the FaceGraph.
|
||||
* \brief Attempts to read a file as a polygon mesh; in case of failure, reads the file as a polygon soup,
|
||||
* repairs and orients it to obtain a polygon mesh.
|
||||
*
|
||||
* \tparam Graph a model of `MutableFaceGraph`
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param fname the name of the input file
|
||||
* \param g the graph
|
||||
* \param np sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamBegin{vertex_point_map}
|
||||
* a model of `WritablePropertyMap`, the property map with the points associated to the vertices of `out`.
|
||||
* If this parameter is omitted, an internal property map for
|
||||
* `CGAL::vertex_point_t` must be available in `PolygonMesh`.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamNBegin{repair_polygon_soup}
|
||||
* \cgalParamDescription{a parameter used indicate whether `CGAL::Polygon_mesh_processing::repair_polygon_soup()`
|
||||
* should be called on the soup in case of issues in the input.}
|
||||
* \cgalParamType{Boolean}
|
||||
* \cgalParamDefault{`true`}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{vertex_point_map}
|
||||
* \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
* \cgalParamType{a class model of `ReadWritePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
* as key type and `%Point_3` as value type}
|
||||
* \cgalParamDefault{`boost::get(CGAL::vertex_point, g)`}
|
||||
* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||
* must be available in `Graph`.}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{geom_traits}
|
||||
* \cgalParamDescription{an instance of a geometric traits class}
|
||||
* \cgalParamType{The traits class must provide the nested functors `Less_xyz_3` and `Equal_3`
|
||||
* to respectivelycompare lexicographically two points and to check if two points
|
||||
* are identical. For each functor `Foo`, a function `Foo foo_object()` must be provided.}
|
||||
* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`}
|
||||
* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{erase_all_duplicates}
|
||||
* \cgalParamDescription{Parameter to indicate, when multiple polygons are duplicates,
|
||||
* whether all the duplicate polygons should be removed
|
||||
* or if one (arbitrarily chosen) face should be kept.}
|
||||
* \cgalParamType{Boolean}
|
||||
* \cgalParamDefault{`false`}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{require_same_orientation}
|
||||
* \cgalParamDescription{Parameter to indicate if polygon orientation should be taken
|
||||
* into account when determining whether two polygons are duplicates,
|
||||
* that is, whether e.g. the triangles `0,1,2` and `0,2,1` are duplicates.}
|
||||
* \cgalParamType{Boolean}
|
||||
* \cgalParamDefault{`false`}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
* `repair_polygon_soup` a boolean that decides if the soup should be repaired or not. Default is `true`; \n
|
||||
* named parameters used for `CGAL::Polygon_mesh_processing::repair_polygon_soup()` can also be used with this function.
|
||||
*
|
||||
* \return `true` if the reading and conversion worked, `false` otherwise.
|
||||
*/
|
||||
template <typename FaceGraph, typename NamedParameter>
|
||||
template <typename Graph, typename NamedParameter>
|
||||
bool read_polygon_mesh(const char* fname,
|
||||
FaceGraph& g,
|
||||
Graph& g,
|
||||
const NamedParameter& np)
|
||||
{
|
||||
typedef typename CGAL::GetVertexPointMap<FaceGraph, NamedParameter>::type VPM;
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, NamedParameter>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
bool ok = ::CGAL::read_polygon_mesh(fname, g, np);
|
||||
bool ok = CGAL::read_polygon_mesh(fname, g, np);
|
||||
|
||||
if(ok)
|
||||
return true;
|
||||
|
||||
if(!ok)
|
||||
{
|
||||
std::vector<Point> points;
|
||||
std::vector<std::vector<std::size_t> > faces;
|
||||
if(!CGAL::read_polygon_soup(fname, points, faces))
|
||||
|
|
@ -80,39 +121,38 @@ bool read_polygon_mesh(const char* fname,
|
|||
std::cout << "Cleaning polygon soup..." << std::endl;
|
||||
const bool do_repair = choose_parameter(get_parameter(np, internal_np::repair_polygon_soup), true);
|
||||
if(do_repair)
|
||||
CGAL::Polygon_mesh_processing::repair_polygon_soup(points, faces, np);
|
||||
PMP::repair_polygon_soup(points, faces, np);
|
||||
|
||||
if(!CGAL::Polygon_mesh_processing::orient_polygon_soup(points, faces))
|
||||
{
|
||||
if(!PMP::orient_polygon_soup(points, faces))
|
||||
std::cerr << "W: File does not describe a polygon mesh" << std::endl;
|
||||
}
|
||||
|
||||
CGAL::Polygon_mesh_processing::
|
||||
polygon_soup_to_polygon_mesh(points, faces, g, parameters::all_default(), np);
|
||||
}
|
||||
if(!PMP::is_polygon_soup_a_polygon_mesh(faces))
|
||||
return false;
|
||||
|
||||
clear(g);
|
||||
PMP::polygon_soup_to_polygon_mesh(points, faces, g, parameters::all_default(), np);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool read_polygon_mesh(const char* fname, FaceGraph& g)
|
||||
template <typename Graph>
|
||||
bool read_polygon_mesh(const char* fname, Graph& g)
|
||||
{
|
||||
return CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename FaceGraph, typename NamedParameter>
|
||||
bool read_polygon_mesh(const std::string& fname,
|
||||
FaceGraph& g,
|
||||
const NamedParameter& np)
|
||||
template <typename Graph, typename NamedParameter>
|
||||
bool read_polygon_mesh(const std::string& fname, Graph& g, const NamedParameter& np)
|
||||
{
|
||||
return CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(fname.c_str(), g, np);
|
||||
}
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool read_polygon_mesh(const std::string& fname, FaceGraph& g)
|
||||
template <typename Graph>
|
||||
bool read_polygon_mesh(const std::string& fname, Graph& g)
|
||||
{
|
||||
return CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
} // namespace IO
|
||||
|
||||
} // namespace Polygon_mesh_processing
|
||||
} // namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -1055,7 +1055,7 @@ std::size_t merge_duplicate_polygons_in_polygon_soup(PointRange& points,
|
|||
/// \cgalParamNBegin{geom_traits}
|
||||
/// \cgalParamDescription{an instance of a geometric traits class}
|
||||
/// \cgalParamType{The traits class must provide the nested functors `Less_xyz_3` and `Equal_3`
|
||||
/// to respectivelycompare lexicographically two points and to check if 2 points
|
||||
/// to respectivelycompare lexicographically two points and to check if two points
|
||||
/// are identical. For each functor `Foo`, a function `Foo foo_object()` must be provided.}
|
||||
/// \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`}
|
||||
/// \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.}
|
||||
|
|
|
|||
Loading…
Reference in New Issue