mirror of https://github.com/CGAL/cgal
Merge remote-tracking branch 'cgal/master' into Demo-Add_dependency_to_qt5_moc_and_dependencies-maxGimeno
This commit is contained in:
commit
2500331070
|
|
@ -92,7 +92,7 @@ jobs:
|
|||
egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true
|
||||
echo "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./tmp.html
|
||||
mv tmp.html index.html
|
||||
git add ${PR_NUMBER}/$ROUND && git commit -q --amend -m "base commit" && git push -q -f -u origin master
|
||||
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "base commit" && git push -q -f -u origin master
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
59
.travis.yml
59
.travis.yml
|
|
@ -23,36 +23,35 @@ env:
|
|||
- PACKAGE='Homogeneous_kernel Hyperbolic_triangulation_2 Inscribed_areas '
|
||||
- PACKAGE='Installation Interpolation Intersections_2 '
|
||||
- PACKAGE='Intersections_3 Interval_skip_list Interval_support '
|
||||
- PACKAGE='Inventor Jet_fitting_3 Kernel_23 '
|
||||
- PACKAGE='Kernel_d LEDA Linear_cell_complex '
|
||||
- PACKAGE='MacOSX Maintenance Matrix_search '
|
||||
- PACKAGE='Mesh_2 Mesh_3 Mesher_level '
|
||||
- PACKAGE='Minkowski_sum_2 Minkowski_sum_3 Modifier '
|
||||
- PACKAGE='Modular_arithmetic Nef_2 Nef_3 '
|
||||
- PACKAGE='Nef_S2 NewKernel_d Number_types '
|
||||
- PACKAGE='OpenNL Optimal_bounding_box Optimal_transportation_reconstruction_2 '
|
||||
- PACKAGE='Optimisation_basic Partition_2 Periodic_2_triangulation_2 '
|
||||
- PACKAGE='Periodic_3_mesh_3 Periodic_3_triangulation_3 Periodic_4_hyperbolic_triangulation_2 '
|
||||
- PACKAGE='Point_set_2 Point_set_3 Point_set_processing_3 '
|
||||
- PACKAGE='Poisson_surface_reconstruction_3 Polygon Polygon_mesh_processing '
|
||||
- PACKAGE='Polygonal_surface_reconstruction Polyhedron Polyhedron_IO '
|
||||
- PACKAGE='Polyline_simplification_2 Polynomial Polytope_distance_d '
|
||||
- PACKAGE='Principal_component_analysis Principal_component_analysis_LGPL Profiling_tools '
|
||||
- PACKAGE='Property_map QP_solver Random_numbers '
|
||||
- PACKAGE='Ridges_3 STL_Extension Scale_space_reconstruction_3 '
|
||||
- PACKAGE='Scripts SearchStructures Segment_Delaunay_graph_2 '
|
||||
- PACKAGE='Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 Shape_detection '
|
||||
- PACKAGE='Skin_surface_3 Snap_rounding_2 Solver_interface '
|
||||
- PACKAGE='Spatial_searching Spatial_sorting Straight_skeleton_2 '
|
||||
- PACKAGE='Stream_lines_2 Stream_support Subdivision_method_3 '
|
||||
- PACKAGE='Surface_mesh Surface_mesh_approximation Surface_mesh_deformation '
|
||||
- PACKAGE='Surface_mesh_parameterization Surface_mesh_segmentation Surface_mesh_shortest_path '
|
||||
- PACKAGE='Surface_mesh_simplification Surface_mesh_skeletonization Surface_mesh_topology '
|
||||
- PACKAGE='Surface_mesher Surface_sweep_2 TDS_2 '
|
||||
- PACKAGE='TDS_3 Testsuite Tetrahedral_remeshing '
|
||||
- PACKAGE='Three Triangulation Triangulation_2 '
|
||||
- PACKAGE='Triangulation_3 Union_find Visibility_2 '
|
||||
- PACKAGE='Voronoi_diagram_2 wininst '
|
||||
- PACKAGE='Jet_fitting_3 Kernel_23 Kernel_d '
|
||||
- PACKAGE='LEDA Linear_cell_complex MacOSX '
|
||||
- PACKAGE='Maintenance Matrix_search Mesh_2 '
|
||||
- PACKAGE='Mesh_3 Mesher_level Minkowski_sum_2 '
|
||||
- PACKAGE='Minkowski_sum_3 Modifier Modular_arithmetic '
|
||||
- PACKAGE='Nef_2 Nef_3 Nef_S2 '
|
||||
- PACKAGE='NewKernel_d Number_types OpenNL '
|
||||
- PACKAGE='Optimal_bounding_box Optimal_transportation_reconstruction_2 Optimisation_basic '
|
||||
- PACKAGE='Partition_2 Periodic_2_triangulation_2 Periodic_3_mesh_3 '
|
||||
- PACKAGE='Periodic_3_triangulation_3 Periodic_4_hyperbolic_triangulation_2 Point_set_2 '
|
||||
- PACKAGE='Point_set_3 Point_set_processing_3 Poisson_surface_reconstruction_3 '
|
||||
- PACKAGE='Polygon Polygon_mesh_processing Polygonal_surface_reconstruction '
|
||||
- PACKAGE='Polyhedron Polyline_simplification_2 Polynomial '
|
||||
- PACKAGE='Polytope_distance_d Principal_component_analysis Principal_component_analysis_LGPL '
|
||||
- PACKAGE='Profiling_tools Property_map QP_solver '
|
||||
- PACKAGE='Random_numbers Ridges_3 STL_Extension '
|
||||
- PACKAGE='Scale_space_reconstruction_3 Scripts SearchStructures '
|
||||
- PACKAGE='Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 '
|
||||
- PACKAGE='Shape_detection Skin_surface_3 Snap_rounding_2 '
|
||||
- PACKAGE='Solver_interface Spatial_searching Spatial_sorting '
|
||||
- PACKAGE='Straight_skeleton_2 Stream_lines_2 Stream_support '
|
||||
- PACKAGE='Subdivision_method_3 Surface_mesh Surface_mesh_approximation '
|
||||
- PACKAGE='Surface_mesh_deformation Surface_mesh_parameterization Surface_mesh_segmentation '
|
||||
- PACKAGE='Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization '
|
||||
- PACKAGE='Surface_mesh_topology Surface_mesher Surface_sweep_2 '
|
||||
- PACKAGE='TDS_2 TDS_3 Testsuite '
|
||||
- PACKAGE='Tetrahedral_remeshing Three Triangulation '
|
||||
- PACKAGE='Triangulation_2 Triangulation_3 Union_find '
|
||||
- PACKAGE='Visibility_2 Voronoi_diagram_2 wininst '
|
||||
compiler: clang
|
||||
install:
|
||||
- echo "$PWD"
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ Intersections_2
|
|||
Intersections_3
|
||||
Interval_skip_list
|
||||
Interval_support
|
||||
Inventor
|
||||
Jet_fitting_3
|
||||
Kernel_23
|
||||
Kernel_d
|
||||
|
|
@ -87,7 +86,6 @@ Polygon
|
|||
Polygon_mesh_processing
|
||||
Polygonal_surface_reconstruction
|
||||
Polyhedron
|
||||
Polyhedron_IO
|
||||
Polyline_simplification_2
|
||||
Polynomial
|
||||
Polytope_distance_d
|
||||
|
|
|
|||
|
|
@ -19,18 +19,16 @@
|
|||
#include <QApplication>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
QApplication app(argc, argv);
|
||||
app.setOrganizationDomain("inria.fr");
|
||||
app.setOrganizationName("INRIA");
|
||||
app.setApplicationName("AABB tree demo");
|
||||
//for windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
app.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
|
||||
// Import resources from libCGALQt (Qt5).
|
||||
CGAL_QT_INIT_RESOURCES;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
m_pViewer->makeCurrent();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ void Scene::compile_shaders()
|
|||
//Vertex source code
|
||||
const char vertex_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 f_matrix;\n"
|
||||
"void main(void)\n"
|
||||
|
|
@ -103,10 +103,11 @@ void Scene::compile_shaders()
|
|||
//Vertex source code
|
||||
const char fragment_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"#version 150 \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = color; \n"
|
||||
"out_color = color; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -139,12 +140,12 @@ void Scene::compile_shaders()
|
|||
//Vertex source code
|
||||
const char tex_vertex_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec2 tex_coord; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec2 tex_coord; \n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 f_matrix;\n"
|
||||
"varying highp vec2 texc;\n"
|
||||
"out highp vec2 texc;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = mvp_matrix * f_matrix * vertex;\n"
|
||||
|
|
@ -154,11 +155,12 @@ void Scene::compile_shaders()
|
|||
//Vertex source code
|
||||
const char tex_fragment_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"uniform sampler2D texture;\n"
|
||||
"varying highp vec2 texc;\n"
|
||||
"#version 150 \n"
|
||||
"uniform sampler2D s_texture;\n"
|
||||
"in highp vec2 texc;\n"
|
||||
"out highp vec4 out_color; \n"
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = texture2D(texture, texc.st);\n"
|
||||
"out_color = vec4(texture(s_texture, texc));\n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -1319,12 +1321,8 @@ void Scene::deactivate_cutting_plane()
|
|||
}
|
||||
void Scene::initGL()
|
||||
{
|
||||
gl = new QOpenGLFunctions_2_1();
|
||||
if(!gl->initializeOpenGLFunctions())
|
||||
{
|
||||
qFatal("ERROR : OpenGL Functions not initialized. Check your OpenGL Verison (should be >=3.3)");
|
||||
exit(1);
|
||||
}
|
||||
gl = new QOpenGLFunctions();
|
||||
gl->initializeOpenGLFunctions();
|
||||
|
||||
gl->glGenTextures(1, &textureId);
|
||||
compile_shaders();
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
private:
|
||||
// member data
|
||||
QOpenGLFunctions_2_1 *gl;
|
||||
QOpenGLFunctions *gl;
|
||||
Bbox m_bbox;
|
||||
Polyhedron *m_pPolyhedron;
|
||||
std::list<Point> m_points;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
\cgalCRPSection{Primitives}
|
||||
- `CGAL::AABB_triangle_primitive<GeomTraits, Iterator, CacheDatum>`
|
||||
- `CGAL::AABB_segment_primitive<GeomTraits, Iterator, CacheDatum>`
|
||||
- `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
|
||||
- `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,ExternalPropertyMaps,CacheDatum>`
|
||||
- `CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,Vpm,OneHalfedgeGraphPerTree,CacheDatum>`
|
||||
- `CGAL::AABB_face_graph_triangle_primitive<FaceGraph,Vpm,OneFaceGraphPerTree,CacheDatum>`
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/AABB_tree.h>
|
||||
#include <CGAL/AABB_traits.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
|
|
@ -9,6 +7,9 @@
|
|||
#include <CGAL/AABB_face_graph_triangle_primitive.h>
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef K::FT FT;
|
||||
typedef K::Point_3 Point_3;
|
||||
|
|
@ -26,8 +27,12 @@ void triangle_mesh(const char* fname)
|
|||
typedef CGAL::AABB_tree<Traits> Tree;
|
||||
|
||||
TriangleMesh tmesh;
|
||||
std::ifstream in(fname);
|
||||
in >> tmesh;
|
||||
if(!CGAL::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh))
|
||||
{
|
||||
std::cerr << "Invalid input." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Timer t;
|
||||
t.start();
|
||||
Tree tree(faces(tmesh).first, faces(tmesh).second, tmesh);
|
||||
|
|
@ -36,7 +41,6 @@ void triangle_mesh(const char* fname)
|
|||
std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Bbox_3 bbox(boost::graph_traits<Surface_mesh>::face_descriptor fd,
|
||||
const Surface_mesh& p)
|
||||
{
|
||||
|
|
@ -47,7 +51,6 @@ Bbox_3 bbox(boost::graph_traits<Surface_mesh>::face_descriptor fd,
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
void surface_mesh_cache_bbox(const char* fname)
|
||||
{
|
||||
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
|
||||
|
|
@ -64,9 +67,9 @@ void surface_mesh_cache_bbox(const char* fname)
|
|||
t.start();
|
||||
Bbox_pmap bb = tmesh.add_property_map<face_descriptor,Bbox_3>("f:bbox",Bbox_3()).first;
|
||||
|
||||
for(face_descriptor fd : faces(tmesh)){
|
||||
for(face_descriptor fd : faces(tmesh))
|
||||
put(bb, fd, bbox(fd,tmesh));
|
||||
}
|
||||
|
||||
Traits traits(bb);
|
||||
Tree tree(traits);
|
||||
tree.insert(faces(tmesh).first, faces(tmesh).second, tmesh);
|
||||
|
|
@ -77,7 +80,6 @@ void surface_mesh_cache_bbox(const char* fname)
|
|||
std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::cout << "Polyhedron_3" << std::endl;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/AABB_tree.h>
|
||||
#include <CGAL/AABB_traits.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/AABB_face_graph_triangle_primitive.h>
|
||||
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
|
||||
#include <CGAL/Polygon_mesh_processing/orientation.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef K::FT FT;
|
||||
typedef K::Point_3 Point;
|
||||
|
|
@ -24,8 +25,8 @@ typedef CGAL::AABB_traits<K, Primitive> Traits;
|
|||
typedef CGAL::AABB_tree<Traits> Tree;
|
||||
typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
|
||||
|
||||
|
||||
struct Skip {
|
||||
struct Skip
|
||||
{
|
||||
face_descriptor fd;
|
||||
|
||||
Skip(const face_descriptor fd)
|
||||
|
|
@ -44,14 +45,20 @@ struct Skip {
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* filename = (argc > 1) ? argv[1] : "data/tetrahedron.off";
|
||||
std::ifstream input(filename);
|
||||
|
||||
Mesh mesh;
|
||||
input >> mesh;
|
||||
if(!CGAL::read_polygon_mesh(filename, mesh))
|
||||
{
|
||||
std::cerr << "Invalid input." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Tree tree(faces(mesh).first, faces(mesh).second, mesh);
|
||||
|
||||
double d = CGAL::Polygon_mesh_processing::is_outward_oriented(mesh)?-1:1;
|
||||
|
||||
for(face_descriptor fd : faces(mesh)){
|
||||
for(face_descriptor fd : faces(mesh))
|
||||
{
|
||||
halfedge_descriptor hd = halfedge(fd,mesh);
|
||||
Point p = CGAL::centroid(mesh.point(source(hd,mesh)),
|
||||
mesh.point(target(hd,mesh)),
|
||||
|
|
@ -61,13 +68,16 @@ int main(int argc, char* argv[])
|
|||
Ray ray(p,d * v);
|
||||
Skip skip(fd);
|
||||
Ray_intersection intersection = tree.first_intersection(ray, skip);
|
||||
if(intersection){
|
||||
if(intersection)
|
||||
{
|
||||
if(boost::get<Point>(&(intersection->first))){
|
||||
const Point* p = boost::get<Point>(&(intersection->first) );
|
||||
std::cout << *p << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "done" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <CGAL/internal/AABB_tree/Primitive_helper.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
/// \file AABB_traits.h
|
||||
|
||||
|
|
@ -274,13 +273,13 @@ public:
|
|||
switch(Traits::longest_axis(bbox))
|
||||
{
|
||||
case AT::CGAL_AXIS_X: // sort along x
|
||||
std::nth_element(first, middle, beyond, boost::bind(Traits::less_x,_1,_2,m_traits));
|
||||
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); });
|
||||
break;
|
||||
case AT::CGAL_AXIS_Y: // sort along y
|
||||
std::nth_element(first, middle, beyond, boost::bind(Traits::less_y,_1,_2,m_traits));
|
||||
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); });
|
||||
break;
|
||||
case AT::CGAL_AXIS_Z: // sort along z
|
||||
std::nth_element(first, middle, beyond, boost::bind(Traits::less_z,_1,_2,m_traits));
|
||||
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_z(p1, p2, this->m_traits); });
|
||||
break;
|
||||
default:
|
||||
CGAL_error();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <CGAL/Delaunay_triangulation_3.h>
|
||||
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
|
||||
#include <CGAL/Advancing_front_surface_reconstruction.h>
|
||||
#include <CGAL/IO/read_xyz_points.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/disable_warnings.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
|
@ -113,11 +113,8 @@ int main (int argc, char* argv[])
|
|||
|
||||
const char* fname = (argc>1) ? argv[1] : "data/cube.pwn";
|
||||
// Loading point set from a file.
|
||||
std::ifstream stream(fname);
|
||||
|
||||
if (!stream ||
|
||||
!CGAL::read_xyz_points(stream,
|
||||
std::back_inserter(points),
|
||||
if (!CGAL::read_points(fname, std::back_inserter(points),
|
||||
CGAL::parameters::point_map(Point_map()).
|
||||
normal_map(Normal_map())))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ Modular_arithmetic
|
|||
Number_types
|
||||
Polygon
|
||||
Polyhedron
|
||||
Polyhedron_IO
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Spatial_sorting
|
||||
Stream_support
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
/*! \file CGAL/Algebraic_extension_traits.h
|
||||
* \brief Defines traits class CGAL::Algebraic_extension_traits.
|
||||
* \brief defines traits class CGAL::Algebraic_extension_traits.
|
||||
*/
|
||||
|
||||
#ifndef CGAL_ALGEBRAIC_NUMBER_TRAITS_H
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
// =============================================================================
|
||||
|
||||
/*! \file NiX/Coercion_traits.h
|
||||
* \brief Defines class NiX::Coercion_traits.
|
||||
* \brief defines class NiX::Coercion_traits.
|
||||
*
|
||||
* Provides the general definition of the \c Coercion_traits<A,B> class, with
|
||||
* specializations for the builtin number types.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
// they may be wrong now.
|
||||
|
||||
/*! \file NiX/Fraction_traits.h
|
||||
\brief Defines class NiX::Fraction_traits.
|
||||
\brief defines class NiX::Fraction_traits.
|
||||
|
||||
Provides dependent types and function objects for all the functions
|
||||
beyond operators with specializations of the \c Fraction_traits<NT>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace CGAL {
|
|||
class Parens_as_product_tag {};
|
||||
|
||||
/*! \ingroup NiX_io_parens
|
||||
* \brief Decides whether this number requires parentheses
|
||||
* \brief decides whether this number requires parentheses
|
||||
* in case it appears within a produkt.
|
||||
*/
|
||||
template <class NT>
|
||||
|
|
@ -36,7 +36,7 @@ struct Needs_parens_as_product{
|
|||
};
|
||||
|
||||
/*! \ingroup NiX_io_parens
|
||||
* \brief Decides whether this number requires parentheses
|
||||
* \brief decides whether this number requires parentheses
|
||||
* in case it appears within a produkt.
|
||||
*/
|
||||
template <class NT>
|
||||
|
|
|
|||
|
|
@ -180,13 +180,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/*! \brief Refines the isolating interval. */
|
||||
/*! \brief refines the isolating interval. */
|
||||
void refine() const{ this->ptr()->refine(); }
|
||||
|
||||
/*! \brief Bisects the isolating interval. */
|
||||
void bisect() const{ this->ptr()->bisect(); }
|
||||
|
||||
/*! \brief Refines the isolating interval until \a m is outside
|
||||
/*! \brief refines the isolating interval until \a m is outside
|
||||
* the \c closed interval
|
||||
*/
|
||||
template < class NTX >
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ public:
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Gives an opportunity to process the nodes after
|
||||
* \brief gives an opportunity to process the nodes after
|
||||
* the subdivision steps are finished
|
||||
*
|
||||
* This method must be specialised by derived classes, but can
|
||||
|
|
@ -386,7 +386,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
/*! \brief Returns whether the \c i th root is definitely a simple root
|
||||
/*! \brief returns whether the \c i th root is definitely a simple root
|
||||
* of the isolated polynomial
|
||||
*
|
||||
* Must be specialised by derived class
|
||||
|
|
@ -396,7 +396,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
/*! \brief Returns whether the \c i th root is definitely a multiple root
|
||||
/*! \brief returns whether the \c i th root is definitely a multiple root
|
||||
* of the isolated polynomial
|
||||
*
|
||||
* Must be specialised by derived class
|
||||
|
|
@ -1040,7 +1040,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
/*! \brief Returns whether the \c i th root is definitely a simple root
|
||||
/*! \brief returns whether the \c i th root is definitely a simple root
|
||||
* of the isolated polynomial
|
||||
*
|
||||
*/
|
||||
|
|
@ -1048,7 +1048,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
/*! \brief Returns whether the \c i th root is definitely
|
||||
/*! \brief returns whether the \c i th root is definitely
|
||||
* a multiple root
|
||||
* of the isolated polynomial
|
||||
*
|
||||
|
|
@ -1372,7 +1372,7 @@ public:
|
|||
bool is_exact_root(int) const { return false; }
|
||||
|
||||
/*!
|
||||
* \brief Returns true if the <tt>i</tt>th root is known to be a simple
|
||||
* \brief returns true if the <tt>i</tt>th root is known to be a simple
|
||||
* root of the curve.
|
||||
*/
|
||||
bool is_certainly_simple_root(int i) const {
|
||||
|
|
@ -1381,7 +1381,7 @@ public:
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns true if the <tt>i</tt>th root is known to be a multiple
|
||||
* \brief returns true if the <tt>i</tt>th root is known to be a multiple
|
||||
* root of the curve.
|
||||
*/
|
||||
bool is_certainly_multiple_root(int i) const {
|
||||
|
|
@ -1391,7 +1391,7 @@ public:
|
|||
|
||||
|
||||
/*!
|
||||
* \brief Returns the multiplicity of the root if know, otherwise -1
|
||||
* \brief returns the multiplicity of the root if know, otherwise -1
|
||||
*/
|
||||
int multiplicity_of_root(int i) const {
|
||||
CGAL_assertion(is_isolated());
|
||||
|
|
@ -1407,7 +1407,7 @@ public:
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the isolator of the polynomial f(1/x + q), if known
|
||||
* \brief returns the isolator of the polynomial f(1/x + q), if known
|
||||
*/
|
||||
Self inverse_transform_isolator() const {
|
||||
return this->ptr()->inverse_transform_isolator();
|
||||
|
|
|
|||
|
|
@ -707,13 +707,13 @@ public:
|
|||
this->ptr()->node_list_.erase(n);
|
||||
}
|
||||
|
||||
/*! \brief Replace traits class
|
||||
/*! \brief replaces traits class
|
||||
*/
|
||||
void set_traits(TRAITS& traits) {
|
||||
this->ptr()->b_from_p_.set_traits(traits);
|
||||
}
|
||||
|
||||
/*! \brief Returns a copy of this with its own representation
|
||||
/*! \brief returns a copy of this with its own representation
|
||||
*/
|
||||
Self make_unique() const {
|
||||
Self tmp = *this;
|
||||
|
|
|
|||
|
|
@ -1079,7 +1079,7 @@ public:
|
|||
this->ptr()->node_list_.erase(n);
|
||||
}
|
||||
|
||||
/*! \brief Replace traits class
|
||||
/*! \brief replaces traits class
|
||||
*/
|
||||
void set_traits(TRAITS& traits) {
|
||||
|
||||
|
|
@ -1090,7 +1090,7 @@ public:
|
|||
|
||||
}
|
||||
|
||||
/*! \brief Returns a copy of this with its own representation
|
||||
/*! \brief returns a copy of this with its own representation
|
||||
*/
|
||||
Self make_unique() const {
|
||||
Self tmp = *this;
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ public:
|
|||
private:
|
||||
|
||||
/*
|
||||
* \brief Sets all status lines at events and of intervals
|
||||
* \brief sets all status lines at events and of intervals
|
||||
*
|
||||
* Writes the status lines of events and interval into the object.
|
||||
* The value type of both \c InputIterator1 and \c InputIterator2
|
||||
|
|
@ -571,7 +571,7 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
/*! \brief Returns whether the curve has a valid defining polynomial
|
||||
/*! \brief returns whether the curve has a valid defining polynomial
|
||||
*/
|
||||
bool has_defining_polynomial() const {
|
||||
return bool(this->ptr()->f);
|
||||
|
|
@ -579,7 +579,7 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
/*! \brief Sets the defining polynomial.
|
||||
/*! \brief sets the defining polynomial.
|
||||
*
|
||||
* \pre The object has no defining polynomial yet.
|
||||
*/
|
||||
|
|
@ -595,7 +595,7 @@ public:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns whether the curve is y-regular
|
||||
* \brief returns whether the curve is y-regular
|
||||
*
|
||||
* A curve is called y-regular if the leading coefficient of its defining
|
||||
* polynomial wrt y is a constant, i.e., contains no x
|
||||
|
|
@ -646,7 +646,7 @@ public:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns the number of event lines of the curve
|
||||
* \brief returns the number of event lines of the curve
|
||||
*
|
||||
* Algebraically, the number of real roots of the discriminant of
|
||||
* the curve's defining equation is returned.
|
||||
|
|
@ -664,7 +664,7 @@ public:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns whether the given x-coordinate is critical for the curve
|
||||
* \brief returns whether the given x-coordinate is critical for the curve
|
||||
* and which event or interval index the x-coordinate belongs to.
|
||||
*
|
||||
* \param is_event is set to \c true if the curve has an event
|
||||
|
|
@ -734,7 +734,7 @@ public:
|
|||
private:
|
||||
|
||||
/*
|
||||
* \brief Returns a status line for an exact value \c alpha that
|
||||
* \brief returns a status line for an exact value \c alpha that
|
||||
* is not an event of the curve
|
||||
*
|
||||
* This function controls the internal cache that stores already created
|
||||
|
|
@ -1167,7 +1167,7 @@ private:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns the status line for the interval
|
||||
* \brief returns the status line for the interval
|
||||
* preceeding the <tt>i</tt>th event
|
||||
*
|
||||
* Returns a status line for a reference x-coordinate of the <tt>i</tt>th
|
||||
|
|
@ -1235,7 +1235,7 @@ public:
|
|||
private:
|
||||
|
||||
/*
|
||||
* \brief Creates an intermediate line at position \c ar.
|
||||
* \brief creates an intermediate line at position \c ar.
|
||||
*
|
||||
* It is required that none of the following situations occurs at position
|
||||
* <tt>ar</tt>: singularity, vertical tangent line, vertical asymptote.\n
|
||||
|
|
@ -1279,7 +1279,7 @@ private:
|
|||
private:
|
||||
|
||||
/*
|
||||
* \brief Returns an Event_line_builder instance
|
||||
* \brief returns an Event_line_builder instance
|
||||
*
|
||||
* Note: So far, a new instance is created each time the function is called
|
||||
*/
|
||||
|
|
@ -1444,7 +1444,7 @@ private:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns the <tt>i</tt>th Sturm-Habicht polynomial
|
||||
* \brief returns the <tt>i</tt>th Sturm-Habicht polynomial
|
||||
* of the primitive part of the defining polynomial
|
||||
*/
|
||||
Polynomial_2 sturm_habicht_of_primitive(size_type i) const
|
||||
|
|
@ -1458,7 +1458,7 @@ public:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns the <tt>i</tt>th principal Sturm-Habicht coefficient
|
||||
* \brief returns the <tt>i</tt>th principal Sturm-Habicht coefficient
|
||||
* of the primitive part of the defining polynomial
|
||||
*/
|
||||
Polynomial_1 principal_sturm_habicht_of_primitive(size_type i) const
|
||||
|
|
@ -1477,7 +1477,7 @@ public:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns the <tt>i</tt>th coprincipal Sturm-Habicht coefficient
|
||||
* \brief returns the <tt>i</tt>th coprincipal Sturm-Habicht coefficient
|
||||
* of the primitive part of the defining polynomial
|
||||
*
|
||||
* The coprincipal Sturm-Habicht coefficient is the coefficient
|
||||
|
|
@ -1498,7 +1498,7 @@ public:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns an iterator to the principal Sturm-Habicht coefficients,
|
||||
* \brief returns an iterator to the principal Sturm-Habicht coefficients,
|
||||
* starting with the <tt>0</tt>th one (the resultant)
|
||||
*/
|
||||
Principal_sturm_habicht_iterator principal_sturm_habicht_begin() const {
|
||||
|
|
@ -1930,7 +1930,7 @@ private:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns a \c Curve_analysis_2 object for a sheared curve.
|
||||
* \brief returns a \c Curve_analysis_2 object for a sheared curve.
|
||||
*
|
||||
* The shear factor is given by the integer \c s.
|
||||
* This functions only shears the primitive part of the defining equation.
|
||||
|
|
@ -2082,7 +2082,7 @@ public:
|
|||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns the limit an infinite arc converges to
|
||||
* \brief returns the limit an infinite arc converges to
|
||||
*
|
||||
* \pre <tt>loc==CGAL::LEFT_BOUNDARY ||
|
||||
* loc==CGAL::RIGHT_BOUNDARY</tt>
|
||||
|
|
@ -2399,7 +2399,7 @@ private:
|
|||
}; // class Algebraic_curve_2_2
|
||||
|
||||
|
||||
//! \brief Prints the objects.
|
||||
//! \brief prints the objects.
|
||||
template<typename AlgebraicKernelWithAnalysis_2,
|
||||
typename Rep_>
|
||||
std::ostream& operator<< (
|
||||
|
|
@ -2507,7 +2507,7 @@ std::ostream& operator<< (
|
|||
return out;
|
||||
}
|
||||
|
||||
//! \brief Reads the objects from stream
|
||||
//! \brief reads the objects from stream
|
||||
template<typename AlgebraicKernelWithAnalysis_2,
|
||||
typename Rep_>
|
||||
std::istream& operator>> (
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ public:
|
|||
public:
|
||||
|
||||
/*
|
||||
* \brief Returns the indices of the <tt>i</tt>th event value
|
||||
* \brief returns the indices of the <tt>i</tt>th event value
|
||||
*
|
||||
* Returns a Event_indices <tt>(fg,ffy,ggy)</tt> such that
|
||||
* the <tt>i</tt>th event root is the <tt>fg</tt>th root of the
|
||||
|
|
@ -963,7 +963,7 @@ public:
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the number of event slices
|
||||
* \brief returns the number of event slices
|
||||
*
|
||||
* Precisely, this is the number of points which are either root of
|
||||
* the resultant of the two curves, or root of discriminant of one
|
||||
|
|
@ -1171,7 +1171,7 @@ private:
|
|||
Integer s) const;
|
||||
|
||||
/*
|
||||
* \brief Reduces the number of possible intersections
|
||||
* \brief reduces the number of possible intersections
|
||||
*
|
||||
* At the position given by the event lins \c e1 and \c e2 and the slice
|
||||
* info object \c slice, the points on the event lines are further refined
|
||||
|
|
@ -1197,7 +1197,7 @@ private:
|
|||
|
||||
}; // end of Curve_pair_analysis_2
|
||||
|
||||
//! \brief Prints the objects.
|
||||
//! \brief prints the objects.
|
||||
template<typename AlgebraicKernelWithAnalysis_2>
|
||||
std::ostream& operator<<
|
||||
(std::ostream& out,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
// they may be wrong now.
|
||||
|
||||
/*! \file NiX/Descartes.h
|
||||
\brief Defines class NiX::Descartes.
|
||||
\brief defines class NiX::Descartes.
|
||||
|
||||
Isolate real roots of polynomials.
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public:
|
|||
|
||||
|
||||
/*!
|
||||
* \brief Creates an event line at position \c alpha for the specified
|
||||
* \brief creates an event line at position \c alpha for the specified
|
||||
* curve.
|
||||
*
|
||||
* Additionally, the \c id of the event line to be created has to be
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ set_union_with_source(InputIterator1 first_begin,
|
|||
}
|
||||
|
||||
/*
|
||||
* \brief Removes the leading term of the polynomial \c f as long as it
|
||||
* \brief removes the leading term of the polynomial \c f as long as it
|
||||
* vanishes at \c alpha
|
||||
*
|
||||
*/
|
||||
|
|
@ -169,7 +169,7 @@ template<typename AlgebraicKernel_1> typename AlgebraicKernel_1::Bound
|
|||
|
||||
|
||||
/*!
|
||||
* \brief Produces intermediate rational values for a list of
|
||||
* \brief produces intermediate rational values for a list of
|
||||
* algebraic reals.
|
||||
*
|
||||
* For a list of Algebraic real values with \c n elements, a list with
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace CGAL {
|
|||
|
||||
namespace internal {
|
||||
|
||||
/*! \brief Tries to find a SIMPLE rational q with a<q<b.
|
||||
/*! \brief tries to find a SIMPLE rational q with a<q<b.
|
||||
*
|
||||
* In this context, simple means that the denominator of <tt>q</tt>
|
||||
* is a power of two, and is not too big. There is no guarantee to find
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace internal {
|
|||
} // namespace internal
|
||||
|
||||
/*!
|
||||
* \brief Represents different strategies how to handle
|
||||
* \brief represents different strategies how to handle
|
||||
* degenerate cases during the analysis
|
||||
*
|
||||
* Currently, there are two possible strategies implemented. See the
|
||||
|
|
|
|||
|
|
@ -5,18 +5,16 @@
|
|||
|
||||
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication application(argc,argv);
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
|
||||
QApplication application(argc,argv);
|
||||
application.setOrganizationDomain("geometryfactory.com");
|
||||
application.setOrganizationName("GeometryFactory");
|
||||
application.setApplicationName("Alpha Shape Reconstruction");
|
||||
//for Windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
application.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
|
||||
// Import resources from libCGALQt (Qt5).
|
||||
// See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ void Viewer::compile_shaders()
|
|||
//Vertex source code
|
||||
const char vertex_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec3 normal;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec3 normal;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 mv_matrix; \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"out highp vec4 fP; \n"
|
||||
"out highp vec3 fN; \n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
|
|
@ -47,15 +47,16 @@ void Viewer::compile_shaders()
|
|||
//Fragment source code
|
||||
const char fragment_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 fP; \n"
|
||||
"in highp vec3 fN; \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"uniform highp vec4 light_pos; \n"
|
||||
"uniform highp vec4 light_diff; \n"
|
||||
"uniform highp vec4 light_spec; \n"
|
||||
"uniform highp vec4 light_amb; \n"
|
||||
"uniform float spec_power ; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ void Viewer::compile_shaders()
|
|||
" highp vec4 diffuse = abs(dot(N,L)) * light_diff * color; \n"
|
||||
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
|
||||
|
||||
"gl_FragColor = light_amb*color + diffuse + specular ; \n"
|
||||
"out_color = light_amb*color + diffuse + specular ; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -105,8 +106,8 @@ rendering_program.bind();
|
|||
//Vertex source code
|
||||
const char vertex_source_points[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp float point_size;\n"
|
||||
|
|
@ -119,11 +120,12 @@ const char vertex_source_points[] =
|
|||
//Vertex source code
|
||||
const char fragment_source_points[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"#version 150 \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = color; \n"
|
||||
"out_color = color; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public:
|
|||
Viewer(QWidget* parent);
|
||||
~Viewer()
|
||||
{
|
||||
makeCurrent();
|
||||
buffers[0].destroy();
|
||||
buffers[1].destroy();
|
||||
buffers[2].destroy();
|
||||
|
|
|
|||
|
|
@ -192,6 +192,10 @@ the vertices, edges, facets and cells of the different types
|
|||
(`EXTERIOR`, `SINGULAR`, `REGULAR` or
|
||||
`INTERIOR`).
|
||||
|
||||
\subsection AlphaShape3DIO Input/Output
|
||||
It is possible to export a 3D alpha shape to a `std::ostream` or to a `Geomview_stream`
|
||||
using the `operator<<`, see the documentation of the class `Alpha_shape_3` for more information.
|
||||
|
||||
\section AlphaShape3D_ConceptAndModels Concepts and Models
|
||||
|
||||
We currently do not specify concepts for the underlying triangulation
|
||||
|
|
|
|||
|
|
@ -5,21 +5,23 @@
|
|||
// Max-Planck-Institute Saarbruecken (Germany),
|
||||
// and Tel-Aviv University (Israel). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
//
|
||||
// $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) : Andreas Fabri
|
||||
|
||||
#ifndef CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
|
||||
#define CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/IO/VRML_2_ostream.h>
|
||||
#include <CGAL/license/Alpha_shapes_3.h>
|
||||
|
||||
#include <CGAL/Alpha_shape_3.h>
|
||||
#include <CGAL/IO/VRML/VRML_2_ostream.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
|
||||
#ifdef CGAL_ALPHA_SHAPE_3_H
|
||||
namespace CGAL {
|
||||
|
||||
template <class Dt >
|
||||
|
|
@ -90,6 +92,5 @@ operator<<(VRML_2_ostream& os,
|
|||
}
|
||||
|
||||
} //namespace CGAL
|
||||
#endif // CGAL_ALPHA_SHAPE_3_H
|
||||
|
||||
#endif CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
|
||||
#endif // CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
// Author(s) : Oren Salzman <orenzalz@post.tau.ac.il >
|
||||
// Michael Hemmer <Michael.Hemmer@sophia.inria.fr>
|
||||
|
||||
//TODO: somehow use the fact the the x-value is the same in all comparisons
|
||||
//TODO: somehow use the fact the x-value is the same in all comparisons
|
||||
|
||||
#ifndef CGAL_ARR_VERTICAL_SEGMENT_TRAITS
|
||||
#define CGAL_ARR_VERTICAL_SEGMENT_TRAITS
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ if (CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND)
|
|||
add_compile_definitions(QT_NO_KEYWORDS)
|
||||
include_directories( BEFORE ./ )
|
||||
|
||||
# Arrangement package includes
|
||||
add_definitions(-DQT_NO_KEYWORDS)
|
||||
option(COMPILE_UTILS_INCREMENTALLY
|
||||
"Compile files in Utils directory incrementally, or compile them all as a unit. \
|
||||
Incremental compilation will be better for development and consume less \
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ typedef unspecified_type Split_2;
|
|||
/// \name
|
||||
/// \attention The two following function-object types are
|
||||
/// optional. If they are supported, the `Has_merge_category` tag
|
||||
/// should be defined as `Tag_true` (and `Tag_false` otherwise.
|
||||
/// should be defined as `Tag_true` and otherwise as `Tag_false`.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
|
@ -114,8 +114,8 @@ Split_2 split_2_object() const;
|
|||
|
||||
/// \name
|
||||
/// The two following methods are optional. If they are supported, the
|
||||
/// `Has_merge_category` tag should be defined as `Tag_true` (and
|
||||
/// `Tag_false` otherwise.
|
||||
/// `Has_merge_category` tag should be defined as `Tag_true` and otherwise
|
||||
/// as `Tag_false`.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -159,11 +159,11 @@ namespace CGAL {
|
|||
{ return CK_Equal_2()(a0, a1); }
|
||||
|
||||
result_type
|
||||
operator() ( const Line_arc_2 &a0, const Circular_arc_2 &a1) const
|
||||
operator() ( const Line_arc_2 &/*a0*/, const Circular_arc_2 &/*a1*/) const
|
||||
{ return false; }
|
||||
|
||||
result_type
|
||||
operator() ( const Circular_arc_2 &a0, const Line_arc_2 &a1) const
|
||||
operator() ( const Circular_arc_2 &/*a0*/, const Line_arc_2 &/*a1*/) const
|
||||
{ return false; }
|
||||
|
||||
result_type
|
||||
|
|
|
|||
|
|
@ -1068,7 +1068,7 @@ public:
|
|||
* LARGER - x(xcv1, ce) > x(xcv2, ce).
|
||||
* \pre the ce end of the arc xcv1 lies on a pole.
|
||||
* \pre the ce end of the arc xcv2 lies on a pole.
|
||||
* \pre the the $x$-coordinates of xcv1 and xcv2 at their ce end are
|
||||
* \pre the $x$-coordinates of xcv1 and xcv2 at their ce end are
|
||||
* equal (implying that the curves overlap).
|
||||
* \pre xcv1 does not coincide with the vertical identification curve.
|
||||
* \pre xcv2 does not coincide with the vertical identification curve.
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ public:
|
|||
}
|
||||
|
||||
/*!
|
||||
* Compare the the two points xy-lexicographically.
|
||||
* Compare the two points xy-lexicographically.
|
||||
* \param pt The other point.
|
||||
* \param cache A cache for the vertical tangency points and the
|
||||
* intersection points.
|
||||
|
|
|
|||
|
|
@ -1139,7 +1139,7 @@ public:
|
|||
* that xcv1 is vertical.
|
||||
* \pre the ce end of the line xcv2 lies on a boundary, implying
|
||||
* that xcv2 is vertical.
|
||||
* \pre the the $x$-coordinates of xcv1 and xcv2 at their ce ends are
|
||||
* \pre the $x$-coordinates of xcv1 and xcv2 at their ce ends are
|
||||
* equal, implying that the curves overlap!
|
||||
*/
|
||||
Comparison_result
|
||||
|
|
|
|||
|
|
@ -1488,7 +1488,7 @@ Trapezoidal_decomposition_2<Td_traits>::insert(Halfedge_const_handle he)
|
|||
// if the edge starts at a vertex, we should not insert it into the DAG.
|
||||
// Instead, we should update all the edges incident to the vertex.
|
||||
// Otherwise, this is a new vertex, insert a node to the DAG that represents
|
||||
// the new vertex. In this case, the the edge itself is the only incident
|
||||
// the new vertex. In this case, the edge itself is the only incident
|
||||
// edge, and so it is a trivial operation.
|
||||
Td_map_item p1_item = (lt1 == POINT) ?
|
||||
update_vtx_with_new_edge(he, ce1, item1, lt1) :
|
||||
|
|
|
|||
|
|
@ -781,7 +781,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// Check if the the left endpoint lies on the other polycurve.
|
||||
// Check if the left endpoint lies on the other polycurve.
|
||||
bool left_coincides = (left_res == EQUAL);
|
||||
bool left_overlap = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ compare_y_at_x(const Point_2& p, const Halfedge* he) const
|
|||
return m_geom_traits->compare_y_at_x_2_object()(p, he->curve());
|
||||
}
|
||||
|
||||
/*! \brief determine whether a vertex is associated with a curve end */
|
||||
/*! \brief determines whether a vertex is associated with a curve end */
|
||||
template <typename GeomTraits, typename Dcel>
|
||||
bool Arr_spherical_topology_traits_2<GeomTraits, Dcel>::
|
||||
are_equal(const Vertex* v,
|
||||
|
|
@ -812,7 +812,7 @@ _locate_around_pole(Vertex* v,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/*! \brief Return the face that lies below the given vertex, which lies
|
||||
/*! \brief returns the face that lies below the given vertex, which lies
|
||||
* on the line of discontinuity.
|
||||
*/
|
||||
template <typename GeomTraits, typename Dcel>
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ public:
|
|||
/*! Operate
|
||||
* \param xcv1 the first curve
|
||||
* \param xcv2 the second curve
|
||||
* \return true if the the two curve are mergeable and false otherwise.
|
||||
* \return true if the two curve are mergeable and false otherwise.
|
||||
* Two curves are mergeable if they have the same underlying theoretical
|
||||
* curve
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1513,7 +1513,7 @@ bool Arrangement_zone_2<Arrangement, ZoneVisitor>::_zone_in_overlap()
|
|||
// In this case m_overlap_cv has a finite right endpoint. In this case,
|
||||
// if the right vertex of m_intersect_he is associated with a finite point,
|
||||
// we check whether it is equal to cv_right_pt. Otherwise, we know that
|
||||
// m_intersect_he extends to the the right of m_overlap_cv, and there is no
|
||||
// m_intersect_he extends to the right of m_overlap_cv, and there is no
|
||||
// vertex currently associated with m_overlap_cv's right endpoint.
|
||||
if (! he_right_v->is_at_open_boundary() &&
|
||||
equal(cv_right_pt, he_right_v->point()))
|
||||
|
|
|
|||
|
|
@ -1485,7 +1485,7 @@ public:
|
|||
* \pre cv1's source and cv2's target equal the endpoints of the curve
|
||||
* currently assoicated with e (respectively), and cv1's target equals
|
||||
* cv2's target, and this is the split point (ot vice versa).
|
||||
* \return A handle for the halfedge whose source is the source of the the
|
||||
* \return A handle for the halfedge whose source is the source of the
|
||||
* original halfedge e, and whose target is the split point.
|
||||
*/
|
||||
Halfedge_handle split_edge(Halfedge_handle e,
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ public:
|
|||
* \param e The edge to split (one of the pair of twin halfedges).
|
||||
* \param p The split point.
|
||||
* \pre p lies in the interior of the curve associated with e.
|
||||
* \return A handle for the halfedge whose source is the source of the the
|
||||
* \return A handle for the halfedge whose source is the source of the
|
||||
* original halfedge e, and whose target is the split point.
|
||||
*/
|
||||
Halfedge_handle split_edge (Halfedge_handle e, const Point_2& p);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_ARC_2_H
|
||||
|
||||
/*!\file include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h
|
||||
*\brief Defines class \c Arc_2 that represents an arc on a curve that
|
||||
*\brief defines class \c Arc_2 that represents an arc on a curve that
|
||||
* can be analyzed.
|
||||
*/
|
||||
|
||||
|
|
@ -2695,9 +2695,9 @@ protected:
|
|||
* if arcs' x-ranges overlap; otherwise returns \c false
|
||||
*
|
||||
* \param cv2 The second arc
|
||||
* \param pt_low Output: Point indicating the lower bound of the the joint
|
||||
* \param pt_low Output: Point indicating the lower bound of the joint
|
||||
* x-range
|
||||
* \param pt_high Output: Point indicating the upper bound of the the joint
|
||||
* \param pt_high Output: Point indicating the upper bound of the joint
|
||||
* x-range
|
||||
* \return \c true, if arcs overlap, \c false otherwise
|
||||
*
|
||||
|
|
@ -3364,7 +3364,7 @@ std::ostream& operator<<(
|
|||
}
|
||||
|
||||
|
||||
//! \brief Reads the objects from stream.
|
||||
//! \brief reads the objects from stream.
|
||||
template < class CurvedKernelViaAnalysis_2, class Rep_ >
|
||||
std::istream& operator>> (
|
||||
std::istream& is,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_MAKE_X_MONOTONE_2_H
|
||||
|
||||
/*!\file include/CGAL/Curved_kernel_via_analysis_2/Make_x_monotone_2.h
|
||||
* \brief Defines \c Make_x_monotone_2 functor
|
||||
* \brief defines \c Make_x_monotone_2 functor
|
||||
*/
|
||||
|
||||
#include <CGAL/config.h>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_POINT_2_H
|
||||
|
||||
/*!\file include/CGAL/Curved_kernel_via_analysis_2/Point_2.h
|
||||
* \brief Defines class \c Point_2 that represents a point on a curve that can
|
||||
* \brief defines class \c Point_2 that represents a point on a curve that can
|
||||
* be analyzed.
|
||||
*/
|
||||
|
||||
|
|
@ -817,7 +817,7 @@ std::ostream& operator <<(std::ostream& os,
|
|||
}
|
||||
|
||||
|
||||
//! \brief Reads the objects from stream.
|
||||
//! \brief reads the objects from stream.
|
||||
template < class CurvedKernelViaAnalysis_2, class Rep_ >
|
||||
std::istream& operator>> (
|
||||
std::istream& is,
|
||||
|
|
|
|||
|
|
@ -295,13 +295,6 @@ public:
|
|||
return y;
|
||||
}
|
||||
|
||||
//! \brief the same as \c evaluate but arguments are passed by value
|
||||
//! (needed to substitute variables in bivariate polynomial)
|
||||
inline static NT binded_eval(Poly_1 poly, NT x)
|
||||
{
|
||||
return evaluate(poly, x);
|
||||
}
|
||||
|
||||
//! \brief evalutates a polynomial at certain x-coordinate
|
||||
static NT evaluate(const Poly_1& poly, const NT& x,
|
||||
bool *error_bounds_ = nullptr)
|
||||
|
|
@ -913,10 +906,9 @@ void get_precached_poly(int var, const NT& key, int /* level */, Poly_1& poly)
|
|||
// }
|
||||
|
||||
if(not_cached||not_found) {
|
||||
poly = Poly_1(::boost::make_transform_iterator(coeffs->begin(),
|
||||
boost::bind2nd(std::ptr_fun(binded_eval), key1)),
|
||||
::boost::make_transform_iterator(coeffs->end(),
|
||||
boost::bind2nd(std::ptr_fun(binded_eval), key1)));
|
||||
auto fn = [&key1](const Poly_1& poly){ return evaluate(poly, key1); };
|
||||
poly = Poly_1(::boost::make_transform_iterator(coeffs->begin(), fn),
|
||||
::boost::make_transform_iterator(coeffs->end(), fn));
|
||||
if(not_cached)
|
||||
return;
|
||||
// all available space consumed: drop the least recently used entry
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/function_objects.h>
|
||||
#include <boost/functional.hpp>
|
||||
|
||||
/*! \file CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h
|
||||
* \brief
|
||||
|
|
@ -107,11 +106,13 @@ struct Transform {
|
|||
|
||||
template <class X>
|
||||
OutputPoly_2 operator()(const CGAL::Polynomial<X>& p, Op op = Op()) const {
|
||||
|
||||
Transform<typename OutputPoly_2::NT, typename InputPoly_2::NT, Op> tr;
|
||||
typedef typename InputPoly_2::NT NT_in;
|
||||
typedef typename OutputPoly_2::NT NT_out;
|
||||
Transform<NT_out, NT_in, Op> tr;
|
||||
auto fn = [&op, &tr](const NT_in& v){ return tr(v, op); };
|
||||
return OutputPoly_2(
|
||||
::boost::make_transform_iterator(p.begin(), boost::bind2nd(tr, op)),
|
||||
::boost::make_transform_iterator(p.end(), boost::bind2nd(tr, op)));
|
||||
::boost::make_transform_iterator(p.begin(), fn),
|
||||
::boost::make_transform_iterator(p.end(), fn));
|
||||
}
|
||||
|
||||
OutputPoly_2 operator()(
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ private:
|
|||
//!@}
|
||||
}; // class Subdivision_1<>
|
||||
|
||||
//! \brief main rasterization procedure, copies in the the output iterator
|
||||
//! \brief main rasterization procedure, copies in the output iterator
|
||||
//! \c oi a set of pixel coordinates
|
||||
|
||||
template <class Coeff_, class Algebraic_curve_2_>
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ private:
|
|||
//! for univariate case
|
||||
void get_range_AARD_1(int var, const NT& lower, const NT& upper,
|
||||
const Poly_1& poly, NT& l, NT& h);
|
||||
//! \brief Recursive Taylor, bivariate case
|
||||
//! \brief recursive Taylor, bivariate case
|
||||
//!
|
||||
//! returns a range of polynomial values as Affine_form
|
||||
void get_range_RT_2(const NT& x_low, const NT& x_high, const NT& y_low,
|
||||
|
|
@ -283,7 +283,7 @@ void Subdivision_2<NT_, Algebraic_curve_2_>::subdivide(const NT& x_low,
|
|||
quad_tree(x_mid,x_high,y_low,y_mid);
|
||||
}
|
||||
|
||||
//! \brief Recursive Taylor, bivariate case
|
||||
//! \brief recursive Taylor, bivariate case
|
||||
template <class NT_, class Algebraic_curve_2_>
|
||||
void Subdivision_2<NT_, Algebraic_curve_2_>::get_range_RT_2(
|
||||
const NT& x_low, const NT& x_high, const NT& y_low, const NT& y_high,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* by the elements in the two pairs above, respectively.
|
||||
* 5. Initialize the data field of each halfedge with the number of curves
|
||||
* that induced that halfedge if the halfedge is directed left-to-right
|
||||
* and twice the the number of curves that induced that halfedge if the
|
||||
* and twice the number of curves that induced that halfedge if the
|
||||
* halfedge is directed right-to-left. We initialize the data field of
|
||||
* each face with the total sum of the data of the halfedges on the
|
||||
* boundary of the face. We initialize the data field of each isolated
|
||||
|
|
|
|||
|
|
@ -519,6 +519,19 @@ a `double` value to the halfedges of a graph.
|
|||
|
||||
\cgalExample{Property_map/dynamic_properties.cpp}
|
||||
|
||||
\subsection BGLGraphIO Graph I/O
|
||||
|
||||
Using a common graph concept enables having common input/output functions for all the models
|
||||
of this concept. The following file formats are supported for models of `FaceGraph`:
|
||||
- \ref IOStreamOFF (`.off`)
|
||||
- \ref IOStreamOBJ (`.obj`)
|
||||
- \ref IOStreamSTL (`.stl`)
|
||||
- \ref IOStreamPLY (`.ply`)
|
||||
- \ref IOStreamGocad (`.ts`)
|
||||
- \ref IOStreamVTK (`.vtp`)
|
||||
|
||||
See the page \ref PkgBGLIOFct for an exhaustive description of the I/O functions of this package.
|
||||
|
||||
\section BGLEulerOperations Euler Operations
|
||||
|
||||
There are two categories of mutating operations. The first category comprises
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Euler_operations.h \
|
|||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Dual.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Seam_mesh.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/io.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/IO/ \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/partition.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/METIS/partition_graph.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/METIS/partition_dual_graph.h \
|
||||
|
|
@ -37,7 +38,8 @@ HIDE_UNDOC_CLASSES = YES
|
|||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \
|
||||
CGAL_BGL_NP_CLASS
|
||||
CGAL_BGL_NP_CLASS \
|
||||
CGAL_DEPRECATED
|
||||
|
||||
|
||||
# macros to be used inside the code
|
||||
|
|
|
|||
|
|
@ -467,6 +467,41 @@ the requirement for traversal of all faces in a graph.
|
|||
/// \defgroup PkgBGLIOFct I/O Functions
|
||||
/// \ingroup PkgBGLRef
|
||||
|
||||
/// \defgroup PkgBGLIoFuncsSTL STL I/O Functions
|
||||
/// I/O Functions for the \ref IOStreamSTL
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIoFuncsPLY PLY I/O Functions
|
||||
/// I/O Functions for the \ref IOStreamPLY
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIoFuncsOBJ OBJ I/O Functions
|
||||
/// I/O Functions for the \ref IOStreamOBJ
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIoFuncsOFF OFF I/O Functions
|
||||
/// I/O Functions for the \ref IOStreamOFF
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIoFuncsVTP VTP I/O Functions
|
||||
/// I/O Functions for the \ref IOStreamVTK
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIoFuncsGOCAD GOCAD I/O Functions
|
||||
/// I/O Functions for the \ref IOStreamGocad
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIoFuncsWRL WRL I/O Functions
|
||||
/// I/O Functions for the \ref IOStreamWRL
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIoFuncs3MF 3MF I/O Functions
|
||||
/// I/O Functions for the \ref IOStream3MF
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/// \defgroup PkgBGLIOFctDeprecated I/O Functions (Deprecated)
|
||||
/// \ingroup PkgBGLIOFct
|
||||
|
||||
/*!
|
||||
\addtogroup PkgBGLPropertiesDynamic
|
||||
The dynamic property tags enable to associate information to simplices of a `FaceGraph` on the fly.
|
||||
|
|
@ -592,9 +627,9 @@ model, the properties they support, and any possible caveats that a
|
|||
user might encounter.
|
||||
|
||||
- \link BGLSMGT `boost::graph_traits<CGAL::Surface_mesh<P> >` \endlink
|
||||
- \link BGLPolyGT `boost::graph_traits<CGAL::Polyhedron_3<T> >` \endlink
|
||||
- \link BGLPolyGT `boost::graph_traits< CGAL::Polyhedron_3<K> >` \endlink
|
||||
- \link BGLLCCGT `boost::graph_traits<CGAL::Linear_cell_complex_for_combinatorial_map<...> >` \endlink
|
||||
- \link BGLSeam_meshGT `boost::graph_traits<CGAL::Seam_mesh<T> >` \endlink
|
||||
- \link BGLSeam_meshGT `boost::graph_traits< CGAL::Seam_mesh<G> >` \endlink
|
||||
- \link BGLT2GT `boost::graph_traits<CGAL::Triangulation_2<GT, TDS> >` \endlink and other 2D triangulations
|
||||
- \link BGLArgtGT `boost::graph_traits<CGAL::Arrangement_2<T, DC> >` \endlink
|
||||
- \link BGLOMPAK `boost::graph_traits<OpenMesh::PolyMesh_ArrayKernelT<K> >` \endlink
|
||||
|
|
@ -721,19 +756,21 @@ user might encounter.
|
|||
- `CGAL::alpha_expansion_graphcut()`
|
||||
|
||||
\cgalCRPSection{I/O Functions}
|
||||
- \link PkgBGLIOFct `CGAL::read_off()` \endlink
|
||||
- \link PkgBGLIOFct `CGAL::write_off()` \endlink
|
||||
- \link PkgBGLIOFct `CGAL::write_wrl()` \endlink
|
||||
- `CGAL::write_vtp()`
|
||||
|
||||
- `CGAL::read_polygon_mesh()`
|
||||
- `CGAL::write_polygon_mesh()`
|
||||
- \link PkgBGLIoFuncsSTL I/O for STL files \endlink
|
||||
- \link PkgBGLIoFuncsPLY I/O for PLY files \endlink
|
||||
- \link PkgBGLIoFuncsOBJ I/O for OBJ files \endlink
|
||||
- \link PkgBGLIoFuncsOFF I/O for OFF files \endlink
|
||||
- \link PkgBGLIoFuncsGOCAD I/O for GOCAD files \endlink
|
||||
- \link PkgBGLIoFuncsVTP I/O for VTP files \endlink
|
||||
- \link PkgBGLIoFuncs3MF I/O for 3MF files \endlink
|
||||
- \link PkgBGLIoFuncsWRL I/O for WRL files \endlink
|
||||
*/
|
||||
|
||||
/*!
|
||||
\addtogroup PkgBGLEulerOperations
|
||||
|
||||
We call high level operations that maintain the validity of a halfedge graph <em>%Euler Operations</em>.
|
||||
|
||||
We call high-level operations that maintain the validity of a halfedge graph <em>%Euler Operations</em>.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
|
||||
|
||||
#include <CGAL/boost/graph/copy_face_graph.h>
|
||||
#include <CGAL/boost/graph/IO/OFF.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -38,7 +39,7 @@ int main(int argc, char* argv[])
|
|||
Target1 T1;
|
||||
{
|
||||
CGAL::copy_face_graph(S, T1);
|
||||
CGAL::write_off("lcc.off", T1);
|
||||
CGAL::write_OFF("lcc.off", T1);
|
||||
}
|
||||
|
||||
S.clear();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
|
||||
#include <boost/graph/breadth_first_search.hpp>
|
||||
|
||||
|
|
@ -18,7 +20,7 @@ typedef boost::graph_traits<LCC>::vertex_iterator vertex_iterator;
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
LCC lcc;
|
||||
CGAL::read_off((argc>1)?argv[1]:"cube.off", lcc);
|
||||
CGAL::read_polygon_mesh((argc>1)?argv[1]:"cube.off", lcc);
|
||||
|
||||
// This is the vector where the distance gets written to
|
||||
std::vector<int> distance(lcc.vertex_attributes().size());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -49,7 +51,7 @@ OutputIterator adjacent_vertices_V2(const LCC& g,
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
LCC lcc;
|
||||
CGAL::read_off((argc>1)?argv[1]:"cube.off", lcc);
|
||||
CGAL::read_polygon_mesh((argc>1)?argv[1]:"cube.off", lcc);
|
||||
|
||||
GraphTraits::vertex_iterator vi = vertices(lcc).first;
|
||||
std::list<vertex_descriptor> V;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
#include <fstream>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_3 Point;
|
||||
|
|
@ -67,7 +70,7 @@ int main(int argc, char** argv)
|
|||
Face_index_map;
|
||||
|
||||
LCC lcc;
|
||||
CGAL::read_off((argc>1)?argv[1]:"cube.off", lcc);
|
||||
CGAL::read_polygon_mesh((argc>1)?argv[1]:"cube.off", lcc);
|
||||
|
||||
// Ad hoc property_map to store normals. Face_index_map is used to
|
||||
// map face_descriptors to a contiguous range of indices. See
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/Iterator_range.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
|
||||
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
|
@ -51,7 +52,7 @@ void fct(const LCC& lcc)
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
LCC lcc;
|
||||
CGAL::read_off((argc>1)?argv[1]:"cube.off", lcc);
|
||||
CGAL::read_polygon_mesh((argc>1)?argv[1]:"cube.off", lcc);
|
||||
|
||||
fct(lcc);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/iterator/transform_iterator.hpp>
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
|
@ -41,7 +43,7 @@ struct Source {
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
LCC lcc;
|
||||
CGAL::read_off((argc>1)?argv[1]:"cube.off", lcc);
|
||||
CGAL::read_polygon_mesh((argc>1)?argv[1]:"cube.off", lcc);
|
||||
GraphTraits::vertex_descriptor vd = *(vertices(lcc).first);
|
||||
|
||||
typedef boost::transform_iterator<Source<LCC>,halfedge_around_target_iterator> adjacent_vertex_iterator;
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@
|
|||
#include <CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h>
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
|
||||
typedef OpenMesh::TriMesh_ArrayKernelT</* MyTraits*/> Mesh;
|
||||
|
|
@ -22,19 +21,20 @@ typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
|||
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
||||
|
||||
int main(int argc, char** argv )
|
||||
{
|
||||
Mesh mesh;
|
||||
|
||||
std::vector<vertex_descriptor> V;
|
||||
std::ifstream in((argc>1)?argv[1]:"in.off");
|
||||
CGAL::read_off(in, mesh);
|
||||
const char* filename = (argc>1)?argv[1]:"in.off";
|
||||
const char* outname= (argc>2)?argv[2]:"out.off";
|
||||
CGAL::read_polygon_mesh(filename, mesh);
|
||||
|
||||
for(vertex_descriptor vd : vertices(mesh)){
|
||||
for(halfedge_descriptor hd : CGAL::halfedges_around_target(vd,mesh)){
|
||||
if(! CGAL::is_border(edge(hd,mesh),mesh)){
|
||||
CGAL::Euler::flip_edge(hd,mesh);
|
||||
CGAL::write_off((argc>2)?argv[2]:"out.off", mesh);
|
||||
CGAL::write_polygon_mesh(outname, mesh);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/selection.h>
|
||||
#include <CGAL/boost/graph/IO/OFF.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
|
@ -20,7 +21,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
Mesh mesh;
|
||||
CGAL::read_off (in, mesh);
|
||||
CGAL::read_OFF (in, mesh);
|
||||
|
||||
boost::unordered_map<Face_index, bool> is_selected_map;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,23 +19,6 @@ if(NOT Boost_FOUND)
|
|||
|
||||
endif()
|
||||
|
||||
find_package(OpenMesh QUIET)
|
||||
|
||||
if(OpenMesh_FOUND)
|
||||
include(UseOpenMesh)
|
||||
add_definitions(-DCGAL_USE_OPENMESH)
|
||||
else()
|
||||
message(STATUS "Examples that use OpenMesh will not be compiled.")
|
||||
endif()
|
||||
|
||||
find_package(METIS)
|
||||
|
||||
if(METIS_FOUND)
|
||||
include_directories(${METIS_INCLUDE_DIRS})
|
||||
else()
|
||||
message(STATUS "Examples that use the METIS library will not be compiled.")
|
||||
endif()
|
||||
|
||||
# include for local directory
|
||||
|
||||
# include for local package
|
||||
|
|
@ -59,11 +42,21 @@ create_single_source_cgal_program("transform_iterator.cpp")
|
|||
|
||||
create_single_source_cgal_program("copy_polyhedron.cpp")
|
||||
|
||||
find_package( OpenMesh QUIET )
|
||||
if(OpenMesh_FOUND)
|
||||
target_link_libraries(copy_polyhedron PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_link_libraries( copy_polyhedron PRIVATE ${OPENMESH_LIBRARIES} )
|
||||
target_compile_definitions( copy_polyhedron PRIVATE -DCGAL_USE_OPENMESH )
|
||||
else()
|
||||
message(STATUS "Examples that use OpenMesh will not be compiled.")
|
||||
endif()
|
||||
|
||||
if(METIS_FOUND)
|
||||
create_single_source_cgal_program("polyhedron_partition.cpp")
|
||||
target_link_libraries(polyhedron_partition PRIVATE ${METIS_LIBRARIES})
|
||||
find_package( METIS )
|
||||
if( METIS_FOUND )
|
||||
create_single_source_cgal_program( "polyhedron_partition.cpp" )
|
||||
if( METIS_FOUND )
|
||||
target_include_directories( polyhedron_partition PRIVATE ${METIS_INCLUDE_DIRS} )
|
||||
target_link_libraries( polyhedron_partition PRIVATE ${METIS_LIBRARIES} )
|
||||
else()
|
||||
message( STATUS "Examples that use the METIS library will not be compiled." )
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -13,12 +13,10 @@ create_single_source_cgal_program("surface_mesh_dual.cpp")
|
|||
create_single_source_cgal_program("connected_components.cpp")
|
||||
|
||||
find_package(METIS)
|
||||
|
||||
if(METIS_FOUND)
|
||||
include_directories(${METIS_INCLUDE_DIRS})
|
||||
|
||||
create_single_source_cgal_program("surface_mesh_partition.cpp")
|
||||
target_link_libraries(surface_mesh_partition PRIVATE ${METIS_LIBRARIES})
|
||||
if( METIS_FOUND )
|
||||
create_single_source_cgal_program( "surface_mesh_partition.cpp" )
|
||||
target_include_directories( surface_mesh_partition PRIVATE ${METIS_INCLUDE_DIRS} )
|
||||
target_link_libraries( surface_mesh_partition PRIVATE ${METIS_LIBRARIES} )
|
||||
else()
|
||||
message(STATUS "Examples that use the METIS library will not be compiled.")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -14,9 +14,14 @@ typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* filename = (argc > 1) ? argv[1] : "data/prim.off";
|
||||
|
||||
Mesh sm;
|
||||
std::ifstream in((argc>1)?argv[1]:"data/prim.off");
|
||||
in >> sm;
|
||||
if(!CGAL::read_polygon_mesh(filename, sm))
|
||||
{
|
||||
std::cerr << "Invalid input." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Mesh::Property_map<vertex_descriptor,int> ccmap;
|
||||
ccmap = sm.add_property_map<vertex_descriptor,int>("v:CC").first;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,15 @@ typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* filename = (argc>1) ? argv[1] : "data/prim.off";
|
||||
|
||||
Mesh P;
|
||||
//std::cin >> P;
|
||||
std::ifstream in((argc>1)?argv[1]:"data/prim.off");
|
||||
in >> P;
|
||||
if(!CGAL::read_polygon_mesh(filename, P))
|
||||
{
|
||||
std::cerr << "Invalid input." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Mesh::Property_map<vertex_descriptor,vertex_descriptor> predecessor;
|
||||
predecessor = P.add_property_map<vertex_descriptor,vertex_descriptor>("v:predecessor").first;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@
|
|||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/boost/graph/Seam_mesh.h>
|
||||
#include <CGAL/boost/graph/io.h>
|
||||
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_3 Point;
|
||||
typedef CGAL::Surface_mesh<Point> Mesh;
|
||||
|
|
@ -30,12 +31,16 @@ typedef boost::graph_traits<Seam_mesh>::halfedge_descriptor halfedge_descr
|
|||
typedef boost::graph_traits<Seam_mesh>::edge_descriptor edge_descriptor;
|
||||
typedef boost::graph_traits<Seam_mesh>::face_descriptor face_descriptor;
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* filename = (argc>1) ? argv[1] : "data/cube.off";
|
||||
|
||||
Mesh sm;
|
||||
std::ifstream in((argc>1) ? argv[1] : "data/cube.off");
|
||||
in >> sm;
|
||||
if(!CGAL::read_polygon_mesh(filename, sm))
|
||||
{
|
||||
std::cerr << "Invalid input." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Seam_edge_pmap seam_edge_pm =
|
||||
sm.add_property_map<SM_edge_descriptor, bool>("e:on_seam", false).first;
|
||||
|
|
|
|||
|
|
@ -37,12 +37,13 @@ typedef boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Mesh primal;
|
||||
const char* filename = (argc > 1) ? argv[1] : "data/prim.off";
|
||||
std::ifstream in(filename);
|
||||
if(!(in >> primal)) {
|
||||
std::cerr << "Error reading polyhedron from file " << filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
Mesh primal;
|
||||
if(!CGAL::read_polygon_mesh(filename, primal))
|
||||
{
|
||||
std::cerr << "Invalid input." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Dual dual(primal);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/boost/graph/Face_filtered_graph.h>
|
||||
#include <CGAL/boost/graph/partition.h>
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
|
@ -11,16 +13,15 @@ typedef CGAL::Surface_mesh<K::Point_3> SM;
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::ifstream in((argc>1) ? argv[1] : "data/blobby.off");
|
||||
const char* filename = (argc>1) ? argv[1] : "data/blobby.off";
|
||||
int number_of_parts = (argc>2) ? atoi(argv[2]) : 8;
|
||||
|
||||
if(!in) {
|
||||
std::cerr << "Error: could not read input file" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
SM sm;
|
||||
CGAL::read_off(in, sm);
|
||||
if(!CGAL::read_polygon_mesh(filename, sm))
|
||||
{
|
||||
std::cerr << "Invalid input." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// The vertex <--> partition_id property map
|
||||
typedef SM::Property_map<SM::Vertex_index, std::size_t> Vertex_id_map;
|
||||
|
|
@ -43,9 +44,7 @@ int main(int argc, char** argv)
|
|||
CGAL::copy_face_graph(filtered_sm, part_sm);
|
||||
|
||||
// Output the mesh extracted from subpart n°0
|
||||
std::ofstream out("sm_part_0.off");
|
||||
out.precision(17);
|
||||
CGAL::write_off(out, part_sm);
|
||||
CGAL::write_polygon_mesh("sm_part_0.off", part_sm, CGAL::parameters::stream_precision(17));
|
||||
|
||||
// Output all the vertices that are in the part n°0
|
||||
std::ofstream outxyz("out.xyz");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/boost/graph/io.h>
|
||||
|
||||
#include <iostream>
|
||||
|
|
@ -21,6 +22,7 @@ int main()
|
|||
|
||||
std::ofstream out("out.inp");
|
||||
out.precision(17);
|
||||
CGAL::write_inp(out, sm, "out.inp", "S4R");
|
||||
return 0;
|
||||
CGAL::write_INP(out, "out.inp", "S4R", sm);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ struct Face_filtered_graph
|
|||
* \tparam NamedParameters a sequence of named parameters
|
||||
*
|
||||
* \param graph the underlying graph
|
||||
* \param face_patch_index_map the property_map that assigns a patch index to each face
|
||||
* \param face_patch_index_map the property map that assigns a patch index to each face
|
||||
* \param selected_face_patch_indices a range of the face patch indices to select
|
||||
* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
*
|
||||
|
|
@ -256,7 +256,7 @@ struct Face_filtered_graph
|
|||
* \tparam NamedParameters a sequence of named parameters
|
||||
*
|
||||
* \param graph the underlying graph.
|
||||
* \param face_patch_index_map the property_map that assigns a patch index to each face
|
||||
* \param face_patch_index_map the property map that assigns a patch index to each face
|
||||
* \param selected_face_patch_index the index of the face patch selected
|
||||
* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,121 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_3MF_H
|
||||
#define CGAL_BGL_IO_3MF_H
|
||||
|
||||
#include <CGAL/IO/3MF.h>
|
||||
#include <CGAL/IO/helpers.h>
|
||||
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#if defined(CGAL_LINKED_WITH_3MF) || defined(DOXYGEN_RUNNING)
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
/*!
|
||||
* \ingroup PkgBGLIoFuncs3MF
|
||||
*
|
||||
* \brief writes the triangle meshes contained in `gs` into the file `filename`, using the \ref IOStream3MF.
|
||||
*
|
||||
* \tparam GraphRange a model of the concepts `RandomAccessContainer`
|
||||
* and `BackInsertionSequence` whose `value_type` is
|
||||
* a model of the concepts `FaceGraph` and `HalfedgeListGraph`
|
||||
* that has only triangle faces.
|
||||
*
|
||||
* \param filename the name of the 3mf file to write
|
||||
* \param gs a container of triangle meshes to write. An internal property map for `CGAL::vertex_point_t`
|
||||
* must be available for each mesh.
|
||||
* \param names a range of `std::string` associating a name to each mesh to be written out, which
|
||||
* will appear in the output
|
||||
*
|
||||
* \return `true` if the writing is successful, `false` otherwise.
|
||||
*
|
||||
* \sa `read_3MF()`
|
||||
*/
|
||||
template<typename GraphRange>
|
||||
bool write_3MF(const std::string& filename,
|
||||
const GraphRange& gs,
|
||||
const std::vector<std::string>& names
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<
|
||||
IO::internal::is_Point_set_or_Range_or_Iterator<
|
||||
typename boost::range_value<GraphRange>::type> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
typedef typename boost::range_value<GraphRange>::type FaceGraph;
|
||||
typedef typename boost::property_map<FaceGraph, boost::vertex_point_t>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||
|
||||
// @todo `Triangle` ought to be just array<int, 3>
|
||||
typedef std::vector<int> Triangle;
|
||||
typedef std::vector<Triangle> TriangleRange;
|
||||
typedef std::vector<Point> PointRange;
|
||||
|
||||
std::vector<PointRange> all_points;
|
||||
std::vector<TriangleRange> all_triangles;
|
||||
|
||||
for(const FaceGraph& g : gs)
|
||||
{
|
||||
PointRange points;
|
||||
points.reserve(num_vertices(g));
|
||||
TriangleRange triangles;
|
||||
triangles.reserve(num_faces(g));
|
||||
|
||||
VPM vpm = get(boost::vertex_point, g);
|
||||
|
||||
// @todo dynamic pmap
|
||||
std::unordered_map<typename boost::graph_traits<FaceGraph>::vertex_descriptor, int> vertex_id_map;
|
||||
|
||||
int i = 0;
|
||||
for(const vertex_descriptor v : vertices(g))
|
||||
{
|
||||
points.push_back(get(vpm, v));
|
||||
vertex_id_map[v] = i++;
|
||||
}
|
||||
|
||||
all_points.push_back(points);
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
Triangle triangle;
|
||||
for(vertex_descriptor vert : CGAL::vertices_around_face(halfedge(f, g), g))
|
||||
triangle.push_back(vertex_id_map[vert]);
|
||||
|
||||
CGAL_assertion(triangle.size() == 3);
|
||||
triangles.push_back(triangle);
|
||||
}
|
||||
|
||||
all_triangles.push_back(triangles);
|
||||
}
|
||||
|
||||
return write_3MF(filename, all_points, all_triangles, names);
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // defined(CGAL_LINKED_WITH_3MF) || defined(DOXYGEN_RUNNING)
|
||||
|
||||
#endif // CGAL_BGL_IO_3MF_H
|
||||
|
|
@ -0,0 +1,473 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_GOCAD_H
|
||||
#define CGAL_BGL_IO_GOCAD_H
|
||||
|
||||
#include <CGAL/IO/GOCAD.h>
|
||||
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_builder.h>
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_BGL_NP_CLASS NamedParameters
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
// Use CRTP to gain access to the protected members without getters/setters.
|
||||
template <typename Graph, typename Point>
|
||||
class GOCAD_builder
|
||||
: public Generic_facegraph_builder<Graph, Point, GOCAD_builder<Graph, Point> >
|
||||
{
|
||||
typedef GOCAD_builder<Graph, Point> Self;
|
||||
typedef Generic_facegraph_builder<Graph, Point, Self> Base;
|
||||
|
||||
typedef typename Base::Point_container Point_container;
|
||||
typedef typename Base::Face Face;
|
||||
typedef typename Base::Face_container Face_container;
|
||||
|
||||
public:
|
||||
GOCAD_builder(std::istream& is) : Base(is) { }
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool read(std::istream& is,
|
||||
Point_container& points,
|
||||
Face_container& faces,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
std::pair<std::string, std::string> name_and_color;
|
||||
bool res = read_GOCAD(is, name_and_color, points, faces, np);
|
||||
if(res)
|
||||
{
|
||||
name = name_and_color.first;
|
||||
color = name_and_color.second;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
std::string color;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/// \ingroup PkgBGLIoFuncsGOCAD
|
||||
///
|
||||
/// \brief reads the graph `g` from the input stream, using the \ref IOStreamGocad.
|
||||
///
|
||||
/// The data is expected to represent a 2-manifold (possibly with borders).
|
||||
///
|
||||
/// \attention The graph `g` is not cleared, and the data from the stream are appended.
|
||||
///
|
||||
/// \tparam Graph a model of `MutableFaceGraph`
|
||||
/// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
///
|
||||
/// \param is the input stream
|
||||
/// \param name_and_color name and color of the mesh
|
||||
/// \param g the graph to be built from the input data
|
||||
/// \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
///
|
||||
/// \cgalNamedParamsBegin
|
||||
/// \cgalParamNBegin{vertex_point_map}
|
||||
/// \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
/// \cgalParamType{a class model of `WritablePropertyMap` 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{verbose}
|
||||
/// \cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
/// \cgalParamType{Boolean}
|
||||
/// \cgalParamDefault{`false`}
|
||||
/// \cgalParamNEnd
|
||||
/// \cgalNamedParamsEnd
|
||||
///
|
||||
/// \returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
///
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_GOCAD(std::istream& is,
|
||||
std::pair<std::string, std::string>& name_and_color,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
|
||||
IO::internal::GOCAD_builder<Graph, Point> builder(is);
|
||||
if(!builder(g, np))
|
||||
return false;
|
||||
|
||||
name_and_color.first = builder.name;
|
||||
name_and_color.second = builder.color;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_GOCAD(std::istream& is, std::pair<std::string, std::string>& name_and_color, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_GOCAD(is, name_and_color, g, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_GOCAD(std::istream& is, Graph& g, const CGAL_BGL_NP_CLASS& np,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
std::pair<std::string, std::string> dummy;
|
||||
return read_GOCAD(is, dummy, g, np);
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
bool read_GOCAD(std::istream& is, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_GOCAD(is, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/// \ingroup PkgBGLIoFuncsGOCAD
|
||||
///
|
||||
/// \brief reads the graph `g` from the file `fname`, using the \ref IOStreamGocad.
|
||||
///
|
||||
/// The data is expected to represent a 2-manifold (possibly with borders).
|
||||
///
|
||||
/// \attention The graph `g` is not cleared, and the data from the file are appended.
|
||||
///
|
||||
/// \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 name_and_color name and color of the mesh
|
||||
/// \param g the graph to be built from the input data
|
||||
/// \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
///
|
||||
/// \cgalNamedParamsBegin
|
||||
/// \cgalParamNBegin{vertex_point_map}
|
||||
/// \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
/// \cgalParamType{a class model of `WritablePropertyMap` 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{verbose}
|
||||
/// \cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
/// \cgalParamType{Boolean}
|
||||
/// \cgalParamDefault{`false`}
|
||||
/// \cgalParamNEnd
|
||||
/// \cgalNamedParamsEnd
|
||||
///
|
||||
/// \sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
///
|
||||
/// \returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
///
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_GOCAD(const std::string& fname,
|
||||
std::pair<std::string, std::string>& name_and_color,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
CGAL::set_mode(is, CGAL::IO::ASCII);
|
||||
return read_GOCAD(is, name_and_color, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_GOCAD(const std::string& fname, std::pair<std::string, std::string>& name_and_color, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_GOCAD(fname, name_and_color, g, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_GOCAD(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
std::pair<std::string, std::string> dummy;
|
||||
return read_GOCAD(fname, dummy, g, np);
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
bool read_GOCAD(const std::string& fname, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_GOCAD(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
/// \ingroup PkgBGLIoFuncsGOCAD
|
||||
///
|
||||
/// \brief writes the graph `g` into the output stream `os`, using the \ref IOStreamGocad.
|
||||
///
|
||||
/// \tparam Graph a model of `FaceListGraph`
|
||||
/// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
///
|
||||
/// \param os the output stream
|
||||
/// \param name the name that will be assigned to `g` in the output file
|
||||
/// \param g the graph to be written
|
||||
/// \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
///
|
||||
/// \cgalNamedParamsBegin
|
||||
/// \cgalParamNBegin{vertex_point_map}
|
||||
/// \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
/// \cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
/// \cgalParamType{int}
|
||||
/// \cgalParamDefault{`6`}
|
||||
/// \cgalParamNEnd
|
||||
/// \cgalNamedParamsEnd
|
||||
///
|
||||
/// \returns `true` if writing was successful, `false` otherwise.
|
||||
///
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_GOCAD(std::ostream& os,
|
||||
const char* name,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::vertices_size_type vertices_size_type;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::const_type
|
||||
vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
if(!os.good())
|
||||
return false;
|
||||
|
||||
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||
os.precision(precision);
|
||||
|
||||
os << "GOCAD TSurf 1\n"
|
||||
"HEADER {\n"
|
||||
"name:";
|
||||
os << name << "\n";
|
||||
os << "*border:on\n"
|
||||
"*border*bstone:on\n"
|
||||
"}\n"
|
||||
"GOCAD_ORIGINAL_COORDINATE_SYSTEM\n"
|
||||
"NAME Default\n"
|
||||
"AXIS_NAME \"X\" \"Y\" \"Z\"\n"
|
||||
"AXIS_UNIT \"m\" \"m\" \"m\"\n"
|
||||
"ZPOSITIVE Elevation\n"
|
||||
"END_ORIGINAL_COORDINATE_SYSTEM\n"
|
||||
"TFACE\n";
|
||||
|
||||
boost::container::flat_map<vertex_descriptor, vertices_size_type> reindex;
|
||||
|
||||
vertices_size_type i = 0;
|
||||
for(const vertex_descriptor v : vertices(g))
|
||||
{
|
||||
os << "VRTX " << i << " " << get(vpm, v) << "\n";
|
||||
reindex[v] = i++;
|
||||
}
|
||||
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
halfedge_descriptor h = halfedge(f, g);
|
||||
os << "TRGL " << reindex[target(prev(h, g), g)] << " "
|
||||
<< reindex[target(h, g)] << " "
|
||||
<< reindex[target(next(h, g), g)] << "\n";
|
||||
}
|
||||
|
||||
os << "END" << std::endl;
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_GOCAD(std::ostream& os, const char* name, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_GOCAD(os, name, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/// \ingroup PkgBGLIoFuncsGOCAD
|
||||
///
|
||||
/// \brief writes the graph `g` in the \ref IOStreamGocad into `os`.
|
||||
///
|
||||
/// The name assigned to `g`in the output is `anonymous`.
|
||||
///
|
||||
/// \tparam Graph a model of `FaceListGraph`
|
||||
/// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
///
|
||||
/// \param os the output stream
|
||||
/// \param g the graph to be written
|
||||
/// \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
///
|
||||
/// \cgalNamedParamsBegin
|
||||
/// \cgalParamNBegin{vertex_point_map}
|
||||
/// \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
/// \cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
/// \cgalParamType{int}
|
||||
/// \cgalParamDefault{`6`}
|
||||
/// \cgalParamNEnd
|
||||
/// \cgalNamedParamsEnd
|
||||
///
|
||||
/// \returns `true` if writing was successful, `false` otherwise.
|
||||
///
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_GOCAD(std::ostream& os,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return write_GOCAD(os, "anonymous", g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_GOCAD(std::ostream& os, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_GOCAD(os, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/// \ingroup PkgBGLIoFuncsGOCAD
|
||||
///
|
||||
/// \brief writes the graph `g` into a file named `fname`, using the \ref IOStreamGocad.
|
||||
///
|
||||
/// In this overload, `fname` is used as the name of the graph within the file.
|
||||
///
|
||||
/// \tparam Graph a model of `FaceListGraph`
|
||||
/// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
///
|
||||
/// \param fname the name of the output file
|
||||
/// \param g the graph to be written
|
||||
/// \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
///
|
||||
/// \cgalNamedParamsBegin
|
||||
/// \cgalParamNBegin{vertex_point_map}
|
||||
/// \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
/// \cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
/// \cgalParamType{int}
|
||||
/// \cgalParamDefault{`6`}
|
||||
/// \cgalParamNEnd
|
||||
/// \cgalNamedParamsEnd
|
||||
///
|
||||
/// \sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
///
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_GOCAD(const std::string& fname,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
CGAL::set_mode(os, CGAL::IO::ASCII);
|
||||
return write_GOCAD(os, fname.c_str(), g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_GOCAD(const std::string& fname, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_GOCAD(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_GOCAD_H
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
// Copyright (c) 2019 GeometryFactory
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org);
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Maxime Gimeno
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_GENERIC_FACEGRAPH_BUILDER_H
|
||||
#define CGAL_BGL_IO_GENERIC_FACEGRAPH_BUILDER_H
|
||||
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace CGAL{
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
template <typename Graph, typename Point, typename Derived>
|
||||
class Generic_facegraph_builder
|
||||
{
|
||||
protected:
|
||||
typedef std::vector<Point> Point_container;
|
||||
typedef typename Point_container::size_type size_type;
|
||||
typedef std::vector<std::size_t> Face;
|
||||
typedef std::vector<Face> Face_container;
|
||||
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
|
||||
public:
|
||||
Generic_facegraph_builder(std::istream& in_) : m_is(in_) { }
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool operator()(Graph& g, const NamedParameters& np)
|
||||
{
|
||||
typedef typename GetK<Graph, NamedParameters>::Kernel Kernel;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
typedef typename Kernel::Point_2 Texture;
|
||||
typedef CGAL::Color Color;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, NamedParameters>::type VPM;
|
||||
|
||||
// usually will be true, but might not be the case if using custom type points
|
||||
// CGAL_static_assertion((std::is_same<typename Kernel::Point_3,
|
||||
// typename boost::property_traits<VPM>::value_type>::value));
|
||||
// CGAL_static_assertion((std::is_same<typename Kernel::Point_3,
|
||||
// typename boost::range_value<Point_container>::type>::value));
|
||||
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::vertex_normal_map_t, NamedParameters,
|
||||
Constant_property_map<vertex_descriptor, Vector> >::type VNM;
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::vertex_color_map_t, NamedParameters,
|
||||
Constant_property_map<vertex_descriptor, Color> >::type VCM;
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::vertex_texture_map_t, NamedParameters,
|
||||
Constant_property_map<vertex_descriptor, Texture> >::type VTM;
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::face_color_map_t, NamedParameters,
|
||||
Constant_property_map<face_descriptor, Color> >::type FCM;
|
||||
|
||||
typedef typename boost::property_traits<VNM>::value_type Vertex_normal;
|
||||
typedef typename boost::property_traits<VCM>::value_type Vertex_color;
|
||||
typedef typename boost::property_traits<VTM>::value_type Vertex_texture;
|
||||
typedef typename boost::property_traits<FCM>::value_type Face_color;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::is_default_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
const bool is_vnm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map)));
|
||||
const bool is_vcm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_color_map)));
|
||||
const bool is_vtm_requested = !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map)));
|
||||
const bool is_fcm_requested = !(is_default_parameter(get_parameter(np, internal_np::face_color_map)));
|
||||
|
||||
std::vector<Vertex_normal> vertex_normals;
|
||||
std::vector<Vertex_color> vertex_colors;
|
||||
std::vector<Vertex_texture> vertex_textures;
|
||||
std::vector<Face_color> face_colors;
|
||||
|
||||
const bool verbose = choose_parameter(get_parameter(np, internal_np::verbose), false);
|
||||
const bool binary = choose_parameter(get_parameter(np, internal_np::use_binary_mode), true);
|
||||
|
||||
bool ok =
|
||||
static_cast<Derived*>(this)->read(m_is, m_points, m_faces,
|
||||
parameters::vertex_normal_output_iterator(std::back_inserter(vertex_normals))
|
||||
.vertex_color_output_iterator(std::back_inserter(vertex_colors))
|
||||
.vertex_texture_output_iterator(std::back_inserter(vertex_textures))
|
||||
.face_color_output_iterator(std::back_inserter(face_colors))
|
||||
.verbose(verbose)
|
||||
.use_binary_mode(binary));
|
||||
if(!ok)
|
||||
return false;
|
||||
|
||||
// Construct the graph
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(CGAL::vertex_point, g));
|
||||
VNM vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), VNM());
|
||||
VCM vcm = choose_parameter(get_parameter(np, internal_np::vertex_color_map), VCM());
|
||||
VTM vtm = choose_parameter(get_parameter(np, internal_np::vertex_texture_map), VTM());
|
||||
FCM fcm = choose_parameter(get_parameter(np, internal_np::face_color_map), FCM());
|
||||
|
||||
const bool has_vertex_normals = (is_vnm_requested && !(vertex_normals.empty()));
|
||||
const bool has_vertex_colors = (is_vcm_requested && !(vertex_colors.empty()));
|
||||
const bool has_vertex_textures = (is_vtm_requested && !(vertex_textures.empty()));
|
||||
const bool has_face_colors = (is_fcm_requested && !(face_colors.empty()));
|
||||
|
||||
if(has_vertex_normals && vertex_normals.size() != m_points.size())
|
||||
return false;
|
||||
if(has_vertex_colors && vertex_colors.size() != m_points.size())
|
||||
return false;
|
||||
if(has_vertex_textures && vertex_textures.size() != m_points.size())
|
||||
return false;
|
||||
if(has_face_colors && face_colors.size() != m_faces.size())
|
||||
return false;
|
||||
|
||||
std::vector<vertex_descriptor> vertices(m_points.size());
|
||||
|
||||
for(std::size_t id=0, ps=m_points.size(); id<ps; ++id)
|
||||
{
|
||||
vertices[id] = add_vertex(g);
|
||||
put(vpm, vertices[id], m_points[id]);
|
||||
|
||||
// extra properties
|
||||
if(has_vertex_normals)
|
||||
put(vnm, vertices[id], vertex_normals[id]);
|
||||
if(has_vertex_colors)
|
||||
put(vcm, vertices[id], vertex_colors[id]);
|
||||
if(has_vertex_textures)
|
||||
put(vtm, vertices[id], vertex_textures[id]);
|
||||
}
|
||||
|
||||
for(size_type i=0, fs=m_faces.size(); i<fs; ++i)
|
||||
{
|
||||
std::vector<vertex_descriptor> face(m_faces[i].size());
|
||||
for(std::size_t j=0, fis=face.size(); j<fis; ++j)
|
||||
face[j] = vertices[m_faces[i][j]];
|
||||
|
||||
face_descriptor f = CGAL::Euler::add_face(face, g);
|
||||
if(f == boost::graph_traits<Graph>::null_face())
|
||||
return false;
|
||||
|
||||
if(has_face_colors)
|
||||
put(fcm, f, face_colors[i]);
|
||||
}
|
||||
|
||||
return is_valid(g);
|
||||
}
|
||||
|
||||
bool operator()(Graph& g) { return operator()(g, parameters::all_default()); }
|
||||
|
||||
protected:
|
||||
std::istream& m_is;
|
||||
|
||||
Point_container m_points;
|
||||
Face_container m_faces;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_GENERIC_FACEGRAPH_BUILDER_H
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
// Copyright (c) 2019 GeometryFactory
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org);
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_GENERIC_FACEGRAPH_PRINTER_H
|
||||
#define CGAL_BGL_IO_GENERIC_FACEGRAPH_PRINTER_H
|
||||
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace CGAL{
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
// Unfortunately, we don't know the value type of the normal/texture property maps
|
||||
template <typename VNM>
|
||||
struct Normal_writer
|
||||
{
|
||||
Normal_writer(const VNM vnm) : vnm(vnm) { }
|
||||
|
||||
template <typename Writer, typename VD>
|
||||
void operator()(Writer& writer, const VD v) const
|
||||
{
|
||||
const typename boost::property_traits<VNM>::reference n = get(vnm, v);
|
||||
writer.write_vertex_normal(to_double(n.x()), to_double(n.y()), to_double(n.z()));
|
||||
}
|
||||
|
||||
private:
|
||||
const VNM vnm;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Normal_writer<internal_np::Param_not_found>
|
||||
{
|
||||
Normal_writer(const internal_np::Param_not_found&) { }
|
||||
|
||||
template <typename Writer, typename VD>
|
||||
void operator()(Writer&, const VD) const { }
|
||||
};
|
||||
|
||||
template <typename VTM>
|
||||
struct Texture_writer
|
||||
{
|
||||
Texture_writer(const VTM vtm) : vtm(vtm) { }
|
||||
|
||||
template <typename Writer, typename VD>
|
||||
void operator()(Writer& writer, const VD v) const
|
||||
{
|
||||
const typename boost::property_traits<VTM>::reference t = get(vtm, v);
|
||||
writer.write_vertex_texture(to_double(t.x()), to_double(t.y()));
|
||||
}
|
||||
|
||||
private:
|
||||
const VTM vtm;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Texture_writer<internal_np::Param_not_found>
|
||||
{
|
||||
Texture_writer(const internal_np::Param_not_found&) { }
|
||||
|
||||
template <typename Writer, typename VD>
|
||||
void operator()(Writer&, const VD) const { }
|
||||
};
|
||||
|
||||
template <typename Stream, typename Graph, typename FileWriter>
|
||||
class Generic_facegraph_printer
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::vertices_size_type vertices_size_type;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
|
||||
public:
|
||||
Generic_facegraph_printer(Stream& os) : m_os(os) { }
|
||||
Generic_facegraph_printer(Stream& os, FileWriter writer) : m_os(os), m_writer(writer) { }
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool operator()(const Graph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename GetVertexPointMap<Graph, NamedParameters>::const_type VPM;
|
||||
typedef typename boost::property_traits<VPM>::reference Point_ref;
|
||||
|
||||
typedef CGAL::Color Color;
|
||||
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::vertex_color_map_t, NamedParameters,
|
||||
Constant_property_map<vertex_descriptor, Color> >::type VCM;
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::face_color_map_t, NamedParameters,
|
||||
Constant_property_map<face_descriptor, Color> >::type FCM;
|
||||
|
||||
// No default because value_type is unknown, but the pmap is only used if provided via NP
|
||||
typedef typename internal_np::Get_param<
|
||||
typename NamedParameters::base, internal_np::vertex_normal_map_t>::type VNM;
|
||||
typedef typename internal_np::Get_param<
|
||||
typename NamedParameters::base, internal_np::vertex_texture_map_t>::type VTM;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::is_default_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
if(!m_os.good())
|
||||
return false;
|
||||
|
||||
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||
m_os.precision(precision);
|
||||
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
const bool has_vertex_normals = !(is_default_parameter(get_parameter(np, internal_np::vertex_normal_map)));
|
||||
const bool has_vertex_colors = !(is_default_parameter(get_parameter(np, internal_np::vertex_color_map)));
|
||||
const bool has_vertex_textures = !(is_default_parameter(get_parameter(np, internal_np::vertex_texture_map)));
|
||||
const bool has_face_colors = !(is_default_parameter(get_parameter(np, internal_np::face_color_map)));
|
||||
|
||||
VNM vnm = get_parameter(np, internal_np::vertex_normal_map);
|
||||
VTM vtm = get_parameter(np, internal_np::vertex_texture_map);
|
||||
VCM vcm = choose_parameter<VCM>(get_parameter(np, internal_np::vertex_color_map));
|
||||
FCM fcm = choose_parameter<FCM>(get_parameter(np, internal_np::face_color_map));
|
||||
|
||||
Normal_writer<VNM> nw(vnm);
|
||||
Texture_writer<VTM> tw(vtm);
|
||||
|
||||
// @todo bench that against CGAL::Inverse_index and std::unordered_map
|
||||
boost::container::flat_map<vertex_descriptor, vertices_size_type> index_map;
|
||||
m_writer.write_header(m_os, vertices(g).size(), halfedges(g).size(), faces(g).size(),
|
||||
has_face_colors || has_vertex_colors,
|
||||
has_vertex_normals ,
|
||||
has_vertex_textures );
|
||||
|
||||
vertices_size_type id = 0;
|
||||
for(const vertex_descriptor v : vertices(g))
|
||||
{
|
||||
const Point_ref p = get(vpm, v);
|
||||
m_writer.write_vertex(to_double(p.x()), to_double(p.y()), to_double(p.z()));
|
||||
|
||||
if(has_vertex_normals)
|
||||
nw(m_writer, v);
|
||||
|
||||
if(has_vertex_colors)
|
||||
{
|
||||
const CGAL::Color& vc = get(vcm, v);
|
||||
m_writer.write_vertex_color(vc.red(), vc.green(), vc.blue()); // @fixme correct?
|
||||
}
|
||||
|
||||
if(has_vertex_textures)
|
||||
tw(m_writer, v);
|
||||
|
||||
index_map[v] = id++;
|
||||
}
|
||||
|
||||
m_writer.write_facet_header();
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
CGAL::Halfedge_around_face_circulator<Graph> hc(halfedge(f, g), g);
|
||||
CGAL::Halfedge_around_face_circulator<Graph> hc_end = hc;
|
||||
|
||||
const std::size_t n = circulator_size(hc);
|
||||
CGAL_assertion(n >= 3);
|
||||
|
||||
m_writer.write_facet_begin(n);
|
||||
do
|
||||
{
|
||||
m_writer.write_facet_vertex_index(index_map[target(*hc, g)]);
|
||||
++hc;
|
||||
}
|
||||
while(hc != hc_end);
|
||||
|
||||
if(has_face_colors)
|
||||
{
|
||||
const CGAL::Color& fc = get(fcm, f);
|
||||
m_writer.write_face_color(fc.red(), fc.green(), fc.blue());
|
||||
}
|
||||
|
||||
m_writer.write_facet_end();
|
||||
}
|
||||
m_writer.write_footer();
|
||||
|
||||
return m_os.good();
|
||||
}
|
||||
|
||||
bool operator()(const Graph& g) { return operator()(g, parameters::all_default()); }
|
||||
|
||||
protected:
|
||||
Stream& m_os;
|
||||
FileWriter m_writer;
|
||||
};
|
||||
|
||||
} // end internal
|
||||
} // end IO
|
||||
} // end CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_GENERIC_FACEGRAPH_PRINTER_H
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_INP_H
|
||||
#define CGAL_BGL_IO_INP_H
|
||||
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_INP(std::ostream& os,
|
||||
const std::string& name,
|
||||
const std::string& type,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::vertices_size_type vertices_size_type;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::const_type VPM;
|
||||
typedef typename boost::property_traits<VPM>::reference Point_ref;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
if(!os.good())
|
||||
return false;
|
||||
|
||||
os << "*Part, name=" << name << "\n*Node\n";
|
||||
boost::container::flat_map<vertex_descriptor,vertices_size_type> reindex;
|
||||
int n = 1;
|
||||
for(const vertex_descriptor v : vertices(g))
|
||||
{
|
||||
Point_ref p = get(vpm,v);
|
||||
os << n << ", " << p.x() << ", " << p.y() << ", " << p.z() << '\n';
|
||||
reindex[v] = n++;
|
||||
}
|
||||
|
||||
n = 1;
|
||||
os << "*Element, type=" << type << std::endl;
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
os << n++;
|
||||
for(const vertex_descriptor v : CGAL::vertices_around_face(halfedge(f, g), g))
|
||||
os << ", " << reindex[v];
|
||||
|
||||
os << '\n';
|
||||
}
|
||||
|
||||
os << "*End Part"<< std::endl;
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_INP(const std::string& fname,
|
||||
const std::string& type,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
return write_INP(os, fname, type, g, np);
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
bool write_INP(std::ostream& os, const std::string& name, const std::string& type, const Graph& g)
|
||||
{
|
||||
return write_INP(os, name, type, g, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
bool write_INP(const std::string& fname, const std::string& type, const Graph& g)
|
||||
{
|
||||
return write_INP(fname, type, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_INP_H
|
||||
|
|
@ -0,0 +1,322 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_OBJ_H
|
||||
#define CGAL_BGL_IO_OBJ_H
|
||||
|
||||
#include <CGAL/IO/OBJ.h>
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_builder.h>
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_printer.h>
|
||||
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_BGL_NP_CLASS NamedParameters
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
// Use CRTP to gain access to the protected members without getters/setters.
|
||||
template <typename Graph, typename Point>
|
||||
class OBJ_builder
|
||||
: public Generic_facegraph_builder<Graph, Point, OBJ_builder<Graph, Point> >
|
||||
{
|
||||
typedef OBJ_builder<Graph, Point> Self;
|
||||
typedef Generic_facegraph_builder<Graph, Point, Self> Base;
|
||||
|
||||
typedef typename Base::Point_container Point_container;
|
||||
typedef typename Base::Face Face;
|
||||
typedef typename Base::Face_container Face_container;
|
||||
|
||||
public:
|
||||
OBJ_builder(std::istream& is) : Base(is) { }
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool read(std::istream& is,
|
||||
Point_container& points,
|
||||
Face_container& faces,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_OBJ(is, points, faces, np);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOBJ
|
||||
|
||||
\brief reads the graph `g` from the stream `in`, using the \ref IOStreamOBJ.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
|
||||
Ignores comment lines which start with a hash, and lines with whitespace.
|
||||
|
||||
\attention The graph `g` is not cleared, and the data from the stream are appended.
|
||||
|
||||
\tparam Graph a model of `MutableFaceGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param is the input stream
|
||||
\param g the graph to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` 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{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OBJ(std::istream& is,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
|
||||
IO::internal::OBJ_builder<Graph, Point> builder(is);
|
||||
return builder(g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_OBJ(std::istream& is, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_OBJ(is, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOBJ
|
||||
|
||||
\brief reads the graph `g` from the file `fname`, using the \ref IOStreamOBJ.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
|
||||
Ignores comment lines which start with a hash, and lines with whitespace.
|
||||
|
||||
\attention The graph `g` is not cleared, and the data from the file are appended.
|
||||
|
||||
\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 to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` 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{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OBJ(const std::string& fname,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
CGAL::set_mode(is, CGAL::IO::ASCII);
|
||||
return read_OBJ(is, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_OBJ(const std::string& fname, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_OBJ(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOBJ
|
||||
|
||||
\brief writes the graph `g` into the output stream, using the \ref IOStreamOBJ.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param os the output stream
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OBJ(std::ostream& os,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
IO::internal::Generic_facegraph_printer<std::ostream, Graph, CGAL::File_writer_wavefront> printer(os);
|
||||
return printer(g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_OBJ(std::ostream& os, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_OBJ(os, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOBJ
|
||||
|
||||
\brief writes the graph `g` into a file named `fname`, using the \ref IOStreamOBJ.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param fname the output file
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OBJ(const std::string& fname,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
CGAL::set_mode(os, CGAL::IO::ASCII);
|
||||
return write_OBJ(os, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_OBJ(const std::string& fname, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_OBJ(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_OBJ_H
|
||||
|
|
@ -0,0 +1,528 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_OFF_H
|
||||
#define CGAL_BGL_IO_OFF_H
|
||||
|
||||
#include <CGAL/IO/OFF.h>
|
||||
#include <CGAL/IO/helpers.h>
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_builder.h>
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_printer.h>
|
||||
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_BGL_NP_CLASS NamedParameters
|
||||
#define CGAL_DEPRECATED
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
// Use CRTP to gain access to the protected members without getters/setters.
|
||||
template <typename Graph, typename Point>
|
||||
class OFF_builder
|
||||
: public Generic_facegraph_builder<Graph, Point, OFF_builder<Graph, Point> >
|
||||
{
|
||||
typedef OFF_builder<Graph, Point> Self;
|
||||
typedef Generic_facegraph_builder<Graph, Point, Self> Base;
|
||||
|
||||
typedef typename Base::Point_container Point_container;
|
||||
typedef typename Base::Face Face;
|
||||
typedef typename Base::Face_container Face_container;
|
||||
|
||||
public:
|
||||
OFF_builder(std::istream& is) : Base(is) { }
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool read(std::istream& is,
|
||||
Point_container& points,
|
||||
Face_container& faces,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_OFF(is, points, faces, np);
|
||||
}
|
||||
};
|
||||
|
||||
// Because some packages can provide overloads with the same signature to automatically initialize
|
||||
// property maps (see Surface_mesh/IO/ for example)
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OFF_BGL(std::istream& is,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
|
||||
IO::internal::OFF_builder<Graph, Point> builder(is);
|
||||
return builder(g, np);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOFF
|
||||
|
||||
\brief reads the graph `g` from data in the input stream, using the \ref IOStreamOFF.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
|
||||
This function reads the point property as well as vertex normals (NOFF), vertex and face colors (COFF),
|
||||
and texture vertex coordinates (TOFF). Those properties are stored in property maps that
|
||||
are passed through named parameters (see below), when passed.
|
||||
|
||||
Ignores comment lines which start with a hash, and lines with whitespace.
|
||||
|
||||
\attention The graph `g` is not cleared, and the data from the stream are appended.
|
||||
|
||||
\tparam Graph a model of `MutableFaceGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param is the input stream
|
||||
\param g the graph to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` 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{vertex_normal_map}
|
||||
\cgalParamDescription{a property map associating normals to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Vector_3` as value type}
|
||||
\cgalParamDefault{vertex normals that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{vertex colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_texture_map}
|
||||
\cgalParamDescription{a property map associating textures to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Point_2` as value type}
|
||||
\cgalParamDefault{vertex textures that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{face colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OFF(std::istream& is,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return IO::internal::read_OFF_BGL(is, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_OFF(std::istream& is, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_OFF(is, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOFF
|
||||
|
||||
\brief reads the graph `g` from the file `fname`, using the \ref IOStreamOFF.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
|
||||
This function reads the point property as well as vertex normals (NOFF), vertex and face colors (COFF),
|
||||
and texture vertex coordinates (TOFF). Those properties are stored in property maps that
|
||||
are passed through named parameters (see below), when passed.
|
||||
|
||||
Ignores comment lines which start with a hash, and lines with whitespace.
|
||||
|
||||
\attention The graph `g` is not cleared, and the data from the file are appended.
|
||||
|
||||
\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 to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` 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{vertex_normal_map}
|
||||
\cgalParamDescription{a property map associating normals to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Vector_3` as value type}
|
||||
\cgalParamDefault{vertex normals that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{vertex colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_texture_map}
|
||||
\cgalParamDescription{a property map associating textures to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Point_2` as value type}
|
||||
\cgalParamDefault{vertex textures that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{face colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_OFF(const std::string& fname,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return read_OFF(is, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_OFF(const std::string& fname, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_OFF(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFctDeprecated
|
||||
|
||||
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF()` should be used instead.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
CGAL_DEPRECATED bool read_off(std::ostream& os, Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_OFF(os, g, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFctDeprecated
|
||||
|
||||
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF()` should be used instead.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
CGAL_DEPRECATED bool read_off(const char* fname, Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return read_OFF(fname, g, np);
|
||||
}
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF_BGL(std::ostream& os,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
IO::internal::Generic_facegraph_printer<std::ostream, Graph, CGAL::File_writer_OFF> printer(os);
|
||||
return printer(g, np);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOFF
|
||||
|
||||
\brief writes the graph `g` in the output stream, using the \ref IOStreamOFF.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param os the output stream
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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{vertex_normal_map}
|
||||
\cgalParamDescription{a property map associating normals to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Vector_3` as value type}
|
||||
\cgalParamDefault{no vertex normals in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{no vertex colors in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_texture_map}
|
||||
\cgalParamDescription{a property map associating textures to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Point_2` as value type}
|
||||
\cgalParamDefault{no vertex textures in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{no face colors in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(std::ostream& os,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return IO::internal::write_OFF_BGL(os, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_OFF(std::ostream& os, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_OFF(os, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsOFF
|
||||
|
||||
\brief writes the graph `g` in the file `fname`, using the \ref IOStreamOFF.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param fname the name of the output file
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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{vertex_normal_map}
|
||||
\cgalParamDescription{a property map associating normals to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Vector_3` as value type}
|
||||
\cgalParamDefault{no vertex normals in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{no vertex colors in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_texture_map}
|
||||
\cgalParamDescription{a property map associating textures to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `%Point_2` as value type}
|
||||
\cgalParamDefault{no vertex textures in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{no face colors in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_OFF(const std::string& fname,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
if(!os)
|
||||
{
|
||||
std::cerr<<"Could not create file.";
|
||||
return false;
|
||||
}
|
||||
return write_OFF(os, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_OFF(const std::string& fname, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_OFF(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFctDeprecated
|
||||
|
||||
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_OFF()` should be used instead.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_OFF(os, g, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFctDeprecated
|
||||
|
||||
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_OFF()` should be used instead.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_OFF(fname, g, np);
|
||||
}
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_OFF_H
|
||||
|
|
@ -0,0 +1,584 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_PLY_H
|
||||
#define CGAL_BGL_IO_PLY_H
|
||||
|
||||
#include <CGAL/IO/PLY.h>
|
||||
#include <CGAL/IO/helpers.h>
|
||||
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_builder.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_BGL_NP_CLASS NamedParameters
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
// Use CRTP to gain access to the protected members without getters/setters.
|
||||
template <typename Graph, typename Point>
|
||||
class PLY_builder
|
||||
: public Generic_facegraph_builder<Graph, Point, PLY_builder<Graph, Point> >
|
||||
{
|
||||
typedef PLY_builder<Graph, Point> Self;
|
||||
typedef Generic_facegraph_builder<Graph, Point, Self> Base;
|
||||
|
||||
typedef typename Base::Point_container Point_container;
|
||||
typedef typename Base::Face Face;
|
||||
typedef typename Base::Face_container Face_container;
|
||||
|
||||
public:
|
||||
PLY_builder(std::istream& is) : Base(is) { }
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool read(std::istream& is,
|
||||
Point_container& points,
|
||||
Face_container& faces,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_PLY(is, points, faces, np);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY_BGL(std::istream& is,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
|
||||
IO::internal::PLY_builder<Graph, Point> builder(is);
|
||||
return builder(g, np);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsPLY
|
||||
|
||||
\brief reads the graph `g` from the input stream, using the \ref IOStreamPLY.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
|
||||
\attention When reading a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ifstream`.
|
||||
|
||||
\tparam Graph a model of `MutableFaceGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param is the input stream
|
||||
\param g the graph to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` 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{vertex_index_map}
|
||||
\cgalParamDescription{a property map associating to each vertex of `graph` a unique index}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `std::size_t` as value type}
|
||||
\cgalParamDefault{vertex indices that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{vertex colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{face colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(std::istream& is,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return IO::internal::read_PLY_BGL(is, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_PLY(std::istream& is, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return IO::internal::read_PLY_BGL(is, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsPLY
|
||||
|
||||
\brief reads the graph `g` from a file named `fname`, using the \ref IOStreamPLY.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
|
||||
\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 to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{use_binary_mode}
|
||||
\cgalParamDescription{indicates whether data should be read in binary (`true`) or in ASCII (`false`)}
|
||||
\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 `WritablePropertyMap` 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{vertex_index_map}
|
||||
\cgalParamDescription{a property map associating to each vertex of `graph` a unique index}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `std::size_t` as value type}
|
||||
\cgalParamDefault{vertex indices that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{vertex colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{face colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_PLY(const std::string& fname,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
||||
if(binary)
|
||||
{
|
||||
std::ifstream is(fname, std::ios::binary);
|
||||
CGAL::set_mode(is, CGAL::IO::BINARY);
|
||||
return IO::internal::read_PLY_BGL(is, g, np);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
CGAL::set_mode(is, CGAL::IO::ASCII);
|
||||
return IO::internal::read_PLY_BGL(is, g, np);
|
||||
}
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_PLY(const std::string& fname, Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return read_PLY(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsPLY
|
||||
|
||||
\brief writes the graph in an output stream, using the \ref IOStreamPLY.
|
||||
|
||||
\attention When writing a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ofstream`.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param os the output stream
|
||||
\param g the graph to be written
|
||||
\param comments a string included line by line in the header of the PLY stream (each line will be precedeed by "comment ")
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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{vertex_index_map}
|
||||
\cgalParamDescription{a property map associating to each vertex of `graph` a unique index}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `std::size_t` as value type}
|
||||
\cgalParamDefault{vertex indices that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{vertex colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{face colors that may exist in the input will be ignored}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_PLY(std::ostream& os,
|
||||
const Graph& g,
|
||||
const std::string& comments,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
|
||||
typedef typename CGAL::GetInitializedVertexIndexMap<Graph, CGAL_BGL_NP_CLASS>::const_type VIMap;
|
||||
typedef typename GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::const_type Vpm;
|
||||
typedef typename boost::property_traits<Vpm>::reference Point_3;
|
||||
typedef CGAL::Color Color;
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::vertex_color_map_t,
|
||||
CGAL_BGL_NP_CLASS,
|
||||
Constant_property_map<vertex_descriptor, Color> >::type VCM;
|
||||
typedef typename internal_np::Lookup_named_param_def<
|
||||
internal_np::face_color_map_t,
|
||||
CGAL_BGL_NP_CLASS,
|
||||
Constant_property_map<face_descriptor, Color> >::type FCM;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::is_default_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
VCM vcm = choose_parameter(get_parameter(np, internal_np::vertex_color_map), VCM());
|
||||
FCM fcm = choose_parameter(get_parameter(np, internal_np::face_color_map), FCM());
|
||||
|
||||
bool has_vcolor = !is_default_parameter(get_parameter(np, internal_np::vertex_color_map));
|
||||
bool has_fcolor = !is_default_parameter(get_parameter(np, internal_np::face_color_map));
|
||||
VIMap vim = CGAL::get_initialized_vertex_index_map(g, np);
|
||||
Vpm vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(boost::vertex_point, g));
|
||||
|
||||
if(!os.good())
|
||||
return false;
|
||||
|
||||
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||
os.precision(precision);
|
||||
|
||||
// Write header
|
||||
os << "ply" << std::endl
|
||||
<< ((get_mode(os) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl
|
||||
<< "comment Generated by the CGAL library" << std::endl;
|
||||
|
||||
if(comments != std::string())
|
||||
{
|
||||
std::istringstream iss(comments);
|
||||
std::string line;
|
||||
while(getline(iss, line))
|
||||
{
|
||||
if(line != "Generated by the CGAL library") // Avoid repeating the line if multiple savings
|
||||
os << "comment " << line << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << "element vertex " << vertices(g).size() << std::endl;
|
||||
IO::internal::output_property_header(os, make_ply_point_writer (CGAL::Identity_property_map<Point_3>()));
|
||||
//if vcm is not default add v:color property
|
||||
if(has_vcolor)
|
||||
{
|
||||
os << "property uchar red" << std::endl
|
||||
<< "property uchar green" << std::endl
|
||||
<< "property uchar blue" << std::endl
|
||||
<< "property uchar alpha" << std::endl;
|
||||
}
|
||||
|
||||
os << "element face " << faces(g).size() << std::endl;
|
||||
IO::internal::output_property_header(
|
||||
os, std::make_pair(CGAL::Identity_property_map<std::vector<std::size_t> >(),
|
||||
PLY_property<std::vector<int> >("vertex_indices")));
|
||||
//if fcm is not default add f:color property
|
||||
if(has_fcolor)
|
||||
{
|
||||
os << "property uchar red" << std::endl
|
||||
<< "property uchar green" << std::endl
|
||||
<< "property uchar blue" << std::endl
|
||||
<< "property uchar alpha" << std::endl;
|
||||
}
|
||||
os << "end_header" << std::endl;
|
||||
|
||||
for(vertex_descriptor vd : vertices(g))
|
||||
{
|
||||
Point_3 p = get(vpm, vd);
|
||||
IO::internal::output_properties(os, &p, make_ply_point_writer (CGAL::Identity_property_map<Point_3>()));
|
||||
if(has_vcolor)
|
||||
{
|
||||
const CGAL::Color& c = get(vcm, vd);
|
||||
if(get_mode(os) == CGAL::IO::ASCII)
|
||||
os << c << std::endl;
|
||||
else
|
||||
os.write(reinterpret_cast<const char*>(&c), sizeof(c));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::size_t> polygon;
|
||||
for(face_descriptor fd : faces(g))
|
||||
{
|
||||
polygon.clear();
|
||||
for(halfedge_descriptor hd : halfedges_around_face(halfedge(fd, g), g))
|
||||
polygon.push_back(get(vim, target(hd,g)));
|
||||
|
||||
IO::internal::output_properties(os, &polygon,
|
||||
std::make_pair(CGAL::Identity_property_map<std::vector<std::size_t> >(),
|
||||
PLY_property<std::vector<int> >("vertex_indices")));
|
||||
if(has_fcolor)
|
||||
{
|
||||
const CGAL::Color& c = get(fcm, fd);
|
||||
if(get_mode(os) == CGAL::IO::ASCII)
|
||||
os << c << std::endl;
|
||||
else
|
||||
os.write(reinterpret_cast<const char*>(&c), sizeof(c));
|
||||
}
|
||||
}
|
||||
|
||||
os << std::flush; // write() doesn't flush
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_PLY(std::ostream& os, const Graph& g, const std::string& comments,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_PLY(os, g, comments, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_PLY(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_PLY(os, g, std::string(), np);
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
bool write_PLY(std::ostream& os, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_PLY(os, g, std::string(), parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsPLY
|
||||
|
||||
\brief writes the graph in the output file `fname`, using the \ref IOStreamPLY.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param fname the name of the output file
|
||||
\param g the graph to be written
|
||||
\param comments a string included line by line in the header of the PLY stream (each line will be precedeed by "comment ")
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{use_binary_mode}
|
||||
\cgalParamDescription{indicates whether data should be written in binary (`true`) or in ASCII (`false`)}
|
||||
\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 `ReadablePropertyMap` 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{vertex_index_map}
|
||||
\cgalParamDescription{a property map associating to each vertex of `graph` a unique index between `0` and `num_vertices(graph) - 1`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `std::size_t` as value type}
|
||||
\cgalParamDefault{no vertex indices in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{vertex_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{no vertex color in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{face_color_map}
|
||||
\cgalParamDescription{a property map associating colors to the faces of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%face_descriptor`
|
||||
as key type and `CGAL::Color` as value type}
|
||||
\cgalParamDefault{no face color in the output}
|
||||
\cgalParamNEnd
|
||||
|
||||
\cgalParamNBegin{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_PLY(const std::string& fname,
|
||||
const Graph& g,
|
||||
const std::string& comments,
|
||||
const CGAL_BGL_NP_CLASS& np
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
, typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
||||
if(binary)
|
||||
{
|
||||
std::ofstream os(fname, std::ios::binary);
|
||||
CGAL::set_mode(os, CGAL::IO::BINARY);
|
||||
return write_PLY(os, g, comments, np);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
CGAL::set_mode(os, CGAL::IO::ASCII);
|
||||
return write_PLY(os, g, comments, np);
|
||||
}
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_PLY(const std::string& fname, const Graph& g, const std::string comments,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_PLY(fname, g, comments, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_PLY(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_PLY(fname, g, std::string(), np);
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
bool write_PLY(const std::string& fname, const Graph& g,
|
||||
typename boost::disable_if<IO::internal::is_Point_set_or_Range_or_Iterator<Graph> >::type* = nullptr)
|
||||
{
|
||||
return write_PLY(fname, g, std::string(), parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_PLY_H
|
||||
|
|
@ -0,0 +1,390 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_STL_H
|
||||
#define CGAL_BGL_IO_STL_H
|
||||
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_builder.h>
|
||||
#include <CGAL/IO/STL.h>
|
||||
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_BGL_NP_CLASS NamedParameters
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
// Use CRTP to gain access to the protected members without getters/setters.
|
||||
template <typename Graph, typename Point>
|
||||
class STL_builder
|
||||
: public Generic_facegraph_builder<Graph, Point, STL_builder<Graph, Point> >
|
||||
{
|
||||
typedef STL_builder<Graph, Point> Self;
|
||||
typedef Generic_facegraph_builder<Graph, Point, Self> Base;
|
||||
|
||||
typedef typename Base::Point_container Point_container;
|
||||
typedef typename Base::Face Face;
|
||||
typedef typename Base::Face_container Face_container;
|
||||
|
||||
public:
|
||||
STL_builder(std::istream& is) : Base(is) { }
|
||||
|
||||
template <typename NamedParameters>
|
||||
bool read(std::istream& is,
|
||||
Point_container& points,
|
||||
Face_container& faces,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
return read_STL(is, points, faces, np);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsSTL
|
||||
|
||||
\brief reads the graph `g` from the input stream, using the \ref IOStreamSTL.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
|
||||
\attention The graph `g` is not cleared, and the data from the stream are appended.
|
||||
|
||||
\attention When reading a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ifstream`.
|
||||
|
||||
\tparam Graph a model of `MutableFaceGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param is the input stream
|
||||
\param g the graph to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` 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{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_STL(std::istream& is,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
if(!is.good())
|
||||
return false;
|
||||
IO::internal::STL_builder<Graph, Point> builder(is);
|
||||
return builder(g, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsSTL
|
||||
|
||||
\brief reads the graph `g` from the file `fname`, using the \ref IOStreamSTL.
|
||||
|
||||
The data is expected to represent a 2-manifold (possibly with borders).
|
||||
If `use_binary_mode` is `true`, but the reading fails, ASCII reading will be automatically tested.
|
||||
|
||||
\attention The graph `g` is not cleared, and the data from the file are appended.
|
||||
|
||||
\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 to be built from the input data
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{use_binary_mode}
|
||||
\cgalParamDescription{indicates whether data should be read in binary (`true`) or in ASCII (`false`)}
|
||||
\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 `WritablePropertyMap` 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{verbose}
|
||||
\cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
\cgalParamType{Boolean}
|
||||
\cgalParamDefault{`false`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if reading was successful and the resulting mesh is valid, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_STL(const std::string& fname,
|
||||
Graph& g, const
|
||||
CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
const bool binary = choose_parameter(get_parameter(np, internal_np::use_binary_mode), true);
|
||||
if(binary)
|
||||
{
|
||||
std::ifstream is(fname, std::ios::binary);
|
||||
CGAL::set_mode(is, CGAL::IO::BINARY);
|
||||
if(read_STL(is, g, np))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
g.clear();
|
||||
}
|
||||
std::ifstream is(fname);
|
||||
CGAL::set_mode(is, CGAL::IO::ASCII);
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::type VPM;
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_property_map(CGAL::vertex_point, g));
|
||||
bool v = choose_parameter(get_parameter(np, internal_np::verbose),
|
||||
false);
|
||||
return read_STL(is, g, CGAL::parameters::use_binary_mode(false).vertex_point_map(vpm).verbose(v));
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool read_STL(std::istream& is, Graph& g) { return read_STL(is, g, parameters::all_default()); }
|
||||
template <typename Graph>
|
||||
bool read_STL(const std::string& fname, Graph& g) { return read_STL(fname, g, parameters::all_default()); }
|
||||
|
||||
/// \endcond
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsSTL
|
||||
|
||||
\brief writes the graph `g` in the output stream `os`, using the \ref IOStreamSTL.
|
||||
|
||||
\attention When writing a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ofstream`.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param os the output stream
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\pre The graph must contain only triangle faces.
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_STL(std::ostream& os,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, CGAL_BGL_NP_CLASS>::const_type VPM;
|
||||
typedef typename boost::property_traits<VPM>::reference Point_ref;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
typedef typename Kernel_traits<Point>::Kernel::Vector_3 Vector;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
if(!os.good())
|
||||
return false;
|
||||
|
||||
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||
os.precision(precision);
|
||||
|
||||
if(get_mode(os) == IO::BINARY)
|
||||
{
|
||||
os << "FileType: Binary ";
|
||||
const boost::uint32_t N32 = static_cast<boost::uint32_t>(faces(g).size());
|
||||
os.write(reinterpret_cast<const char *>(&N32), sizeof(N32));
|
||||
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
const halfedge_descriptor h = halfedge(f, g);
|
||||
Point_ref p = get(vpm, target(h, g));
|
||||
Point_ref q = get(vpm, target(next(h, g), g));
|
||||
Point_ref r = get(vpm, source(h, g));
|
||||
|
||||
Vector n = collinear(p, q, r) ? Vector(1, 0, 0) : unit_normal(p, q, r);
|
||||
|
||||
const float coords[12] =
|
||||
{
|
||||
static_cast<float>(to_double(n.x())), static_cast<float>(to_double(n.y())), static_cast<float>(to_double(n.z())),
|
||||
static_cast<float>(to_double(p.x())), static_cast<float>(to_double(p.y())), static_cast<float>(to_double(p.z())),
|
||||
static_cast<float>(to_double(q.x())), static_cast<float>(to_double(q.y())), static_cast<float>(to_double(q.z())),
|
||||
static_cast<float>(to_double(r.x())), static_cast<float>(to_double(r.y())), static_cast<float>(to_double(r.z())) };
|
||||
|
||||
for(int i=0; i<12; ++i)
|
||||
os.write(reinterpret_cast<const char *>(&coords[i]), sizeof(coords[i]));
|
||||
os << " ";
|
||||
}
|
||||
os << std::flush;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "solid" << std::endl;
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
halfedge_descriptor h = halfedge(f, g);
|
||||
Point_ref p = get(vpm, target(h, g));
|
||||
Point_ref q = get(vpm, target(next(h, g), g));
|
||||
Point_ref r = get(vpm, source(h, g));
|
||||
Vector n = collinear(p, q, r) ? Vector(1, 0, 0) : unit_normal(p, q, r);
|
||||
|
||||
os << "facet normal " << n << "\nouter loop"<< "\n";
|
||||
os << "vertex " << p << "\n";
|
||||
os << "vertex " << q << "\n";
|
||||
os << "vertex " << r << "\n";
|
||||
os << "endloop\nendfacet" << "\n";
|
||||
}
|
||||
os << "endsolid" << std::endl;
|
||||
}
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsSTL
|
||||
|
||||
\brief writes the graph `g` into a file named `fname`, using the \ref IOStreamSTL.
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param fname the name of the output stream
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{use_binary_mode}
|
||||
\cgalParamDescription{indicates whether data should be written in binary (`true`) or in ASCII (`false`)}
|
||||
\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 `WritablePropertyMap` 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{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\pre The graph must contain only triangle faces.
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_STL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
||||
if(binary)
|
||||
{
|
||||
std::ofstream os(fname, std::ios::binary);
|
||||
CGAL::set_mode(os, CGAL::IO::BINARY);
|
||||
return write_STL(os, g, np);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ofstream os(fname);
|
||||
CGAL::set_mode(os, CGAL::IO::ASCII);
|
||||
return write_STL(os, g, np);
|
||||
}
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <typename Graph>
|
||||
bool write_STL(std::ostream& os, const Graph& g) { return write_STL(os, g, parameters::all_default()); }
|
||||
template <typename Graph>
|
||||
bool write_STL(const std::string& fname, const Graph& g) { return write_STL(fname, g, parameters::all_default()); }
|
||||
|
||||
/// \endcond
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_STL_H
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
// Copyright (c) 2015-2021 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Maxime Gimeno
|
||||
// Mariette Yvinec
|
||||
|
||||
#ifndef CGAL_BGL_IO_TDS_2_OFF_H
|
||||
#define CGAL_BGL_IO_TDS_2_OFF_H
|
||||
#include <CGAL/IO/OFF.h>
|
||||
#include <CGAL/Triangulation_data_structure_2.h>
|
||||
|
||||
|
||||
namespace CGAL {
|
||||
namespace IO {
|
||||
|
||||
template < class Vb, class Fb>
|
||||
typename Triangulation_data_structure_2<Vb,Fb>::Vertex_handle
|
||||
off_file_input( std::istream& is, Triangulation_data_structure_2<Vb,Fb>& tds, bool verbose = false)
|
||||
{
|
||||
typedef typename Triangulation_data_structure_2<Vb,Fb>::Vertex_handle Vertex_handle;
|
||||
typedef typename Triangulation_data_structure_2<Vb,Fb>::Face_iterator Face_handle;
|
||||
typedef std::pair<Vertex_handle,Vertex_handle> Vh_pair;
|
||||
typedef std::pair<Face_handle, int> Edge;
|
||||
// input from an OFF file
|
||||
// assume a dimension 2 triangulation
|
||||
// create an infinite-vertex and infinite faces with the
|
||||
// boundary edges if any.
|
||||
// return the infinite vertex if created
|
||||
Vertex_handle vinf;
|
||||
File_scanner_OFF scanner(is, verbose);
|
||||
if (! is) {
|
||||
if (scanner.verbose()) {
|
||||
std::cerr << " " << std::endl;
|
||||
std::cerr << "TDS::off_file_input" << std::endl;
|
||||
std::cerr << " input error: file format is not OFF." << std::endl;
|
||||
}
|
||||
return vinf;
|
||||
}
|
||||
|
||||
if(tds.number_of_vertices() != 0) tds.clear();
|
||||
int dim = 2;
|
||||
tds.set_dimension(dim);
|
||||
|
||||
std::vector<Vertex_handle > vvh(scanner.size_of_vertices());
|
||||
std::map<Vh_pair, Edge> edge_map;
|
||||
typedef typename Vb::Point Point;
|
||||
|
||||
// read vertices
|
||||
std::size_t i;
|
||||
for ( i = 0; i < scanner.size_of_vertices(); i++) {
|
||||
Point p;
|
||||
file_scan_vertex( scanner, p);
|
||||
vvh[i] = tds.create_vertex();
|
||||
vvh[i]->set_point(p);
|
||||
scanner.skip_to_next_vertex( i);
|
||||
}
|
||||
if ( ! is ) {
|
||||
is.clear( std::ios::badbit);
|
||||
return vinf;
|
||||
}
|
||||
//vinf = vvh[0];
|
||||
|
||||
// create the facets
|
||||
for ( i = 0; i < scanner.size_of_facets(); i++) {
|
||||
Face_handle fh = tds.create_face();
|
||||
std::size_t no;
|
||||
scanner.scan_facet( no, i);
|
||||
if( ! is || no != 3) {
|
||||
if ( scanner.verbose()) {
|
||||
std::cerr << " " << std::endl;
|
||||
std::cerr << "TDS::off_file_input" << std::endl;
|
||||
std::cerr << "facet " << i << "does not have 3 vertices."
|
||||
<< std::endl;
|
||||
}
|
||||
is.clear( std::ios::badbit);
|
||||
return vinf;
|
||||
}
|
||||
|
||||
for ( std::size_t j = 0; j < no; ++j) {
|
||||
std::size_t index;
|
||||
scanner.scan_facet_vertex_index( index, j+1, i);
|
||||
fh->set_vertex(j, vvh[index]);
|
||||
vvh[index]->set_face(fh);
|
||||
}
|
||||
|
||||
for (std::size_t ih = 0; ih < no; ++ih) {
|
||||
tds.set_adjacency(fh, ih, edge_map);
|
||||
}
|
||||
}
|
||||
|
||||
// deal with boundaries
|
||||
if ( !edge_map.empty()) {
|
||||
vinf = tds.create_vertex();
|
||||
std::map<Vh_pair, Edge> inf_edge_map;
|
||||
while (!edge_map.empty()) {
|
||||
Face_handle fh = edge_map.begin()->second.first;
|
||||
int ih = edge_map.begin()->second.second;
|
||||
Face_handle fn = tds.create_face( vinf,
|
||||
fh->vertex(tds.cw(ih)),
|
||||
fh->vertex(tds.ccw(ih)));
|
||||
vinf->set_face(fn);
|
||||
tds.set_adjacency(fn, 0, fh, ih);
|
||||
tds.set_adjacency(fn, 1, inf_edge_map);
|
||||
tds.set_adjacency(fn, 2, inf_edge_map);
|
||||
edge_map.erase(edge_map.begin());
|
||||
}
|
||||
CGAL_triangulation_assertion(inf_edge_map.empty());
|
||||
}
|
||||
|
||||
|
||||
// coherent orientation
|
||||
tds.reorient_faces();
|
||||
return vinf;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif // CGAL_BGL_IO_TDS_2_OFF_H
|
||||
|
|
@ -0,0 +1,573 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_VTK_H
|
||||
#define CGAL_BGL_IO_VTK_H
|
||||
|
||||
#include <CGAL/IO/VTK.h>
|
||||
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef CGAL_USE_VTK
|
||||
#include <vtkCell.h>
|
||||
#include <vtkXMLPolyDataReader.h>
|
||||
#include <vtkPointSet.h>
|
||||
#include <vtkPolyData.h>
|
||||
#endif
|
||||
|
||||
#if defined(CGAL_USE_VTK) || defined(DOXYGEN_RUNNING)
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_BGL_NP_CLASS NamedParameters
|
||||
#define CGAL_DEPRECATED
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
template <typename Graph, typename NameddParameters>
|
||||
bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data,
|
||||
Graph& g,
|
||||
const NameddParameters& np)
|
||||
{
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, NameddParameters>::type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_property_map(CGAL::vertex_point, g));
|
||||
|
||||
vtkIdType nb_points = poly_data->GetNumberOfPoints();
|
||||
vtkIdType nb_cells = poly_data->GetNumberOfCells();
|
||||
|
||||
reserve(g, num_vertices(g) + static_cast<typename boost::graph_traits<Graph>::vertices_size_type>(nb_points),
|
||||
num_edges(g) + static_cast<typename boost::graph_traits<Graph>::edges_size_type>(nb_points + nb_cells),
|
||||
num_faces(g) + static_cast<typename boost::graph_traits<Graph>::faces_size_type>(nb_cells));
|
||||
|
||||
// extract points
|
||||
std::vector<vertex_descriptor> vertex_map(nb_points);
|
||||
for(vtkIdType i=0; i<nb_points; ++i)
|
||||
{
|
||||
double coords[3];
|
||||
poly_data->GetPoint(i, coords);
|
||||
|
||||
vertex_descriptor v = add_vertex(g);
|
||||
put(vpm, v, Point(coords[0], coords[1], coords[2]));
|
||||
vertex_map[i] = v;
|
||||
}
|
||||
|
||||
// extract cells
|
||||
for(vtkIdType i=0; i<nb_cells; ++i)
|
||||
{
|
||||
int cell_type = poly_data->GetCellType(i);
|
||||
if(cell_type != 5
|
||||
&& cell_type != 7
|
||||
&& cell_type != 9) // only supported cells are triangles, quads and polygons
|
||||
continue;
|
||||
|
||||
vtkCell* cell_ptr = poly_data->GetCell(i);
|
||||
|
||||
vtkIdType nb_vertices = cell_ptr->GetNumberOfPoints();
|
||||
if(nb_vertices < 3)
|
||||
return false;
|
||||
|
||||
std::vector<vertex_descriptor> vr(nb_vertices);
|
||||
for(vtkIdType k=0; k<nb_vertices; ++k)
|
||||
{
|
||||
vtkIdType id = cell_ptr->GetPointId(k);
|
||||
vr[k] = vertex_map[id];
|
||||
}
|
||||
|
||||
face_descriptor f = CGAL::Euler::add_face(vr, g);
|
||||
if(f == boost::graph_traits<Graph>::null_face())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*!
|
||||
* \ingroup PkgBGLIoFuncsVTP
|
||||
*
|
||||
* \brief reads a PolyData in the \ref IOStreamVTK into a triangulated surface mesh.
|
||||
*
|
||||
* The data is expected to represent a 2-manifold (possibly with borders).
|
||||
*
|
||||
* \attention The graph `g` is not cleared, and the data from the file are appended.
|
||||
*
|
||||
* \tparam Graph a model of `MutableFaceGraph`
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param fname the path to the file that will be read
|
||||
* \param g the output mesh
|
||||
* \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{vertex_point_map}
|
||||
* \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
* \cgalParamType{a class model of `WritablePropertyMap` 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
|
||||
*
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
*
|
||||
* \returns `true` if reading was successful, `false` otherwise.
|
||||
*/
|
||||
template<typename Graph,
|
||||
typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool read_VTP(const std::string& fname,
|
||||
Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ifstream test(fname);
|
||||
if(!test.good())
|
||||
{
|
||||
std::cerr<<"File doesn't exist."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
test.close();
|
||||
vtkSmartPointer<vtkPointSet> data;
|
||||
vtkSmartPointer<IO::internal::ErrorObserverVtk> obs =
|
||||
vtkSmartPointer<IO::internal::ErrorObserverVtk>::New();
|
||||
|
||||
data = vtkPolyData::SafeDownCast(IO::internal::read_vtk_file<vtkXMLPolyDataReader>(fname, obs)->GetOutput());
|
||||
if (obs->GetError())
|
||||
return false;
|
||||
return IO::internal::vtkPointSet_to_polygon_mesh(data, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template<typename Graph>
|
||||
bool read_VTP(const std::string& fname, Graph& g) { return read_VTP(fname, g, parameters::all_default()); }
|
||||
|
||||
/// \endcond
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
namespace IO {
|
||||
namespace internal {
|
||||
|
||||
// writes the polys appended data at the end of the .vtp file
|
||||
template <typename Graph, typename NamedParameters>
|
||||
void write_polys(std::ostream& os,
|
||||
const Graph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
|
||||
typedef typename CGAL::GetInitializedVertexIndexMap<Graph, NamedParameters>::const_type Vimap;
|
||||
Vimap V = CGAL::get_initialized_vertex_index_map(g, np);
|
||||
|
||||
std::vector<std::size_t> connectivity_table;
|
||||
std::vector<std::size_t> offsets;
|
||||
std::vector<unsigned char> cell_type(faces(g).size(), 5); // triangle == 5
|
||||
|
||||
std::size_t off = 0;
|
||||
|
||||
for(const face_descriptor f : faces(g))
|
||||
{
|
||||
off += 3;
|
||||
offsets.push_back(off);
|
||||
for(const vertex_descriptor v : vertices_around_face(halfedge(f, g), g))
|
||||
connectivity_table.push_back(get(V, v));
|
||||
}
|
||||
|
||||
write_vector<std::size_t>(os, connectivity_table);
|
||||
write_vector<std::size_t>(os, offsets);
|
||||
write_vector<unsigned char>(os, cell_type);
|
||||
}
|
||||
|
||||
//todo use named params for maps
|
||||
template <typename Graph, typename NamedParameters>
|
||||
void write_polys_tag(std::ostream& os,
|
||||
const Graph& g,
|
||||
bool binary,
|
||||
std::size_t& offset,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
|
||||
|
||||
typedef typename CGAL::GetInitializedVertexIndexMap<Graph, NamedParameters>::const_type Vimap;
|
||||
Vimap V = CGAL::get_initialized_vertex_index_map(g, np);
|
||||
|
||||
std::string formatattribute = binary ? " format=\"appended\"" : " format=\"ascii\"";
|
||||
|
||||
std::string typeattribute;
|
||||
switch(sizeof(std::size_t))
|
||||
{
|
||||
case 8: typeattribute = " type=\"UInt64\""; break;
|
||||
case 4: typeattribute = " type=\"UInt32\""; break;
|
||||
default: CGAL_error_msg("Unknown size of std::size_t");
|
||||
}
|
||||
|
||||
// Write connectivity table
|
||||
os << " <Polys>\n"
|
||||
<< " <DataArray Name=\"connectivity\""
|
||||
<< formatattribute << typeattribute;
|
||||
|
||||
// if binary output, just write the xml tag
|
||||
if(binary)
|
||||
{
|
||||
os << " offset=\"" << offset << "\"/>\n";
|
||||
offset += (3 * faces(g).size() + 1) * sizeof(std::size_t);
|
||||
// 3 indices (size_t) per triangle + length of the encoded data (size_t)
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ">\n";
|
||||
|
||||
for(face_descriptor f : faces(g))
|
||||
{
|
||||
for(vertex_descriptor v : vertices_around_face(halfedge(f, g), g))
|
||||
os << get(V, v) << " ";
|
||||
}
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
|
||||
// Write offsets
|
||||
os << " <DataArray Name=\"offsets\""
|
||||
<< formatattribute << typeattribute;
|
||||
|
||||
if(binary) { // if binary output, just write the xml tag
|
||||
os << " offset=\"" << offset << "\"/>\n";
|
||||
offset += (faces(g).size() + 1) * sizeof(std::size_t);
|
||||
// 1 offset (size_t) per triangle + length of the encoded data (size_t)
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ">\n";
|
||||
std::size_t polys_offset = 0;
|
||||
|
||||
for(std::size_t i = 0; i< faces(g).size(); ++i)
|
||||
{
|
||||
polys_offset += 3;
|
||||
os << polys_offset << " ";
|
||||
}
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
|
||||
// Write cell type (triangle == 5)
|
||||
os << " <DataArray Name=\"types\""
|
||||
<< formatattribute << " type=\"UInt8\"";
|
||||
|
||||
if(binary)
|
||||
{
|
||||
os << " offset=\"" << offset << "\"/>\n";
|
||||
offset += faces(g).size() + sizeof(std::size_t);
|
||||
// 1 unsigned char per cell + length of the encoded data (size_t)
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ">\n";
|
||||
for(std::size_t i=0; i<faces(g).size(); ++i)
|
||||
os << "5 ";
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
os << " </Polys>\n";
|
||||
}
|
||||
|
||||
//todo : use namedparams for points and ids
|
||||
//overload for facegraph
|
||||
template <typename Graph, typename NamedParameters>
|
||||
void write_points_tag(std::ostream& os,
|
||||
const Graph& g,
|
||||
bool binary,
|
||||
std::size_t& offset,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, NamedParameters>::const_type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
typedef typename CGAL::Kernel_traits<Point>::Kernel Gt;
|
||||
typedef typename Gt::FT FT;
|
||||
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
std::string format = binary ? "appended" : "ascii";
|
||||
std::string type = (sizeof(FT) == 8) ? "Float64" : "Float32";
|
||||
|
||||
os << " <Points>\n"
|
||||
<< " <DataArray type =\"" << type << "\" NumberOfComponents=\"3\" format=\""
|
||||
<< format;
|
||||
|
||||
if(binary)
|
||||
{
|
||||
os << "\" offset=\"" << offset << "\"/>\n";
|
||||
offset += 3 * vertices(g).size() * sizeof(FT) + sizeof(std::size_t);
|
||||
// 3 coords per points + length of the encoded data (size_t)
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "\">\n";
|
||||
for(const vertex_descriptor v : vertices(g))
|
||||
os << get(vpm, v).x() << " " << get(vpm, v).y() << " " << get(vpm, v).z() << " ";
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
os << " </Points>\n";
|
||||
}
|
||||
|
||||
// writes the points appended data at the end of the .vtp file
|
||||
template <typename Graph, typename NamedParameters>
|
||||
void write_polys_points(std::ostream& os,
|
||||
const Graph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<Graph, NamedParameters>::const_type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point;
|
||||
typedef typename CGAL::Kernel_traits<Point>::Kernel Gt;
|
||||
typedef typename Gt::FT FT;
|
||||
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
std::vector<FT> coordinates;
|
||||
|
||||
for(vertex_descriptor v : vertices(g))
|
||||
{
|
||||
coordinates.push_back(get(vpm, v).x());
|
||||
coordinates.push_back(get(vpm, v).y());
|
||||
coordinates.push_back(get(vpm, v).z());
|
||||
}
|
||||
|
||||
write_vector<FT>(os, coordinates);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace IO
|
||||
|
||||
/*! \ingroup PkgBGLIoFuncsVTP
|
||||
*
|
||||
* \brief writes a triangulated surface mesh in the `PolyData` XML format (\ref IOStreamVTK).
|
||||
*
|
||||
* \tparam Graph a model of `FaceListGraph`
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param os the output stream
|
||||
* \param g the triangle mesh to be output
|
||||
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{use_binary_mode}
|
||||
* \cgalParamDescription{indicates whether data should be written in binary (`true`) or in ASCII (`false`)}
|
||||
* \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 `ReadablePropertyMap` 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{vertex_index_map}
|
||||
* \cgalParamDescription{a property map associating to each vertex of `graph` a unique index between `0` and `num_vertices(graph) - 1`}
|
||||
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
* as key type and `std::size_t` as value type}
|
||||
* \cgalParamDefault{no vertex indices in the output}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{stream_precision}
|
||||
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
* \cgalParamType{int}
|
||||
* \cgalParamDefault{`6`}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* \pre `g` contains only triangular faces
|
||||
*
|
||||
* \returns `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template<typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_VTP(std::ostream& os,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
|
||||
if(!os.good())
|
||||
return false;
|
||||
|
||||
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
|
||||
os.precision(precision);
|
||||
|
||||
os << "<?xml version=\"1.0\"?>\n"
|
||||
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";
|
||||
|
||||
#ifdef CGAL_LITTLE_ENDIAN
|
||||
os << " byte_order=\"LittleEndian\"";
|
||||
#else // CGAL_BIG_ENDIAN
|
||||
os << " byte_order=\"BigEndian\"";
|
||||
#endif
|
||||
|
||||
switch(sizeof(std::size_t))
|
||||
{
|
||||
case 4: os << " header_type=\"UInt32\""; break;
|
||||
case 8: os << " header_type=\"UInt64\""; break;
|
||||
default: CGAL_error_msg("Unknown size of std::size_t"); return false;
|
||||
}
|
||||
|
||||
os << ">\n"
|
||||
<< " <PolyData>" << "\n";
|
||||
os << " <Piece NumberOfPoints=\"" << vertices(g).size()
|
||||
<< "\" NumberOfPolys=\"" << faces(g).size() << "\">\n";
|
||||
|
||||
std::size_t offset = 0;
|
||||
const bool binary = choose_parameter(get_parameter(np, internal_np::use_binary_mode), true);
|
||||
|
||||
IO::internal::write_points_tag(os, g, binary, offset, np);
|
||||
IO::internal::write_polys_tag(os, g, binary, offset, np);
|
||||
|
||||
os << " </Piece>\n"
|
||||
<< " </PolyData>\n";
|
||||
if(binary)
|
||||
{
|
||||
os << "<AppendedData encoding=\"raw\">\n_";
|
||||
IO::internal::write_polys_points(os, g, np);
|
||||
IO::internal::write_polys(os, g, np);
|
||||
}
|
||||
os << "</VTKFile>" << std::endl;
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
/*! \ingroup PkgBGLIoFuncsVTP
|
||||
*
|
||||
* \brief writes a triangulated surface mesh the file `fname`, in the `PolyData` XML format (\ref IOStreamVTK).
|
||||
*
|
||||
* \tparam Graph a model of `FaceListGraph`
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param fname the name of the output file
|
||||
* \param g the triangle mesh to be output
|
||||
* \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the
|
||||
* ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{use_binary_mode}
|
||||
* \cgalParamDescription{indicates whether data should be written in binary (`true`) or in ASCII (`false`)}
|
||||
* \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 `ReadablePropertyMap` 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{vertex_index_map}
|
||||
* \cgalParamDescription{a property map associating to each vertex of `graph` a unique index between `0` and `num_vertices(graph) - 1`}
|
||||
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<Graph>::%vertex_descriptor`
|
||||
* as key type and `std::size_t` as value type}
|
||||
* \cgalParamDefault{no vertex indices in the output}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{stream_precision}
|
||||
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
* \cgalParamType{int}
|
||||
* \cgalParamDefault{`6`}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* \pre `g` contains only triangular faces
|
||||
*
|
||||
* \returns `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template<typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
||||
std::ofstream os;
|
||||
if(binary){
|
||||
os.open(fname, std::ios::binary);
|
||||
CGAL::set_mode(os, CGAL::IO::BINARY);
|
||||
}
|
||||
else
|
||||
os.open(fname);
|
||||
return write_VTP(os, g, np);
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template<typename Graph>
|
||||
bool write_VTP(std::ostream& os, const Graph& g) { return write_VTP(os, g, CGAL::parameters::all_default()); }
|
||||
template<typename Graph>
|
||||
bool write_VTP(const std::string& fname, const Graph& g) { return write_VTP(fname, g, parameters::all_default()); }
|
||||
|
||||
/// \endcond
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFctDeprecated
|
||||
|
||||
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_VTP()` should be used instead.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_VTP(os, g, np);
|
||||
}
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // defined(CGAL_USE_VTK) || defined(DOXYGEN_RUNNING)
|
||||
|
||||
#endif // CGAL_BGL_IO_VTK_H
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
// Copyright (c) 2015-2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BGL_IO_WRL_H
|
||||
#define CGAL_BGL_IO_WRL_H
|
||||
|
||||
#include <CGAL/IO/VRML.h>
|
||||
|
||||
#include <CGAL/boost/graph/IO/Generic_facegraph_printer.h>
|
||||
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters
|
||||
#define CGAL_BGL_NP_CLASS NamedParameters
|
||||
#define CGAL_DEPRECATED
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsWRL
|
||||
|
||||
\brief writes the graph `g` into the output stream, using the \ref IOStreamWRL (VRML 2.0).
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param os the output stream
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_WRL(std::ostream& os,
|
||||
const Graph& g,
|
||||
const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
IO::internal::Generic_facegraph_printer<std::ostream, Graph, CGAL::File_writer_VRML_2> printer(os);
|
||||
return printer(g, np);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIoFuncsWRL
|
||||
|
||||
\brief writes the graph `g` into the output file, using the \ref IOStreamWRL (VRML 2.0).
|
||||
|
||||
\tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
\tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
|
||||
\param fname the name of the output file
|
||||
\param g the graph to be written
|
||||
\param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
\cgalParamType{int}
|
||||
\cgalParamDefault{`6`}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\returns `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
bool write_WRL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
std::ifstream is(fname);
|
||||
return write_WRL(is, g, np);
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
bool write_WRL(std::ostream& os, const Graph& g) { return write_WRL(os, g, parameters::all_default()); }
|
||||
template <typename Graph>
|
||||
bool write_WRL(const std::string& fname, const Graph& g) { return write_WRL(fname, g, parameters::all_default()); }
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFctDeprecated
|
||||
|
||||
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_WRL()` should be used instead.
|
||||
*/
|
||||
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
|
||||
CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g, const CGAL_BGL_NP_CLASS& np)
|
||||
{
|
||||
return write_WRL(os, g, np);
|
||||
}
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BGL_IO_WRL_H
|
||||
|
|
@ -0,0 +1,280 @@
|
|||
// Copyright (c) 2020 GeometryFactory (France). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org)
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
// Author(s) : Maxime Gimeno
|
||||
// Mael Rouxel-Labbé
|
||||
|
||||
#ifndef CGAL_BOOST_GRAPH_POLYGON_MESH_IO_H
|
||||
#define CGAL_BOOST_GRAPH_POLYGON_MESH_IO_H
|
||||
|
||||
#include <CGAL/boost/graph/IO/3MF.h>
|
||||
#include <CGAL/boost/graph/IO/GOCAD.h>
|
||||
#include <CGAL/boost/graph/IO/INP.h>
|
||||
#include <CGAL/boost/graph/IO/OBJ.h>
|
||||
#include <CGAL/boost/graph/IO/OFF.h>
|
||||
#include <CGAL/boost/graph/IO/PLY.h>
|
||||
#include <CGAL/boost/graph/IO/STL.h>
|
||||
#include <CGAL/boost/graph/IO/VTK.h>
|
||||
#include <CGAL/boost/graph/IO/WRL.h>
|
||||
#include <CGAL/IO/helpers.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
|
||||
//not for now : some readers will return "ok" despite not managing to read anything
|
||||
/*
|
||||
template <class Graph, typename NamedParameters>
|
||||
bool read_polygon_mesh(std::istream& is,
|
||||
Graph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
bool ok = false;
|
||||
ok = read_OFF(is, g, np, false);
|
||||
if(ok)
|
||||
return true;
|
||||
g.clear();
|
||||
is.clear();//reset the error state
|
||||
is.seekg (0, is.beg);
|
||||
ok = read_OBJ(is, g, np, false);
|
||||
if(ok)
|
||||
return true;
|
||||
g.clear();
|
||||
is.clear();
|
||||
is.seekg (0, is.beg);
|
||||
ok = read_PLY(is, g, np, false);
|
||||
if(ok)
|
||||
return true;
|
||||
g.clear();
|
||||
is.clear();
|
||||
is.seekg (0, is.beg);
|
||||
ok = read_STL(is, g, np, false);
|
||||
if(ok)
|
||||
return true;
|
||||
g.clear();
|
||||
is.clear();
|
||||
is.seekg (0, is.beg);
|
||||
ok = read_GOCAD(is, g, np, false);
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <class Graph>
|
||||
bool read_polygon_mesh(std::istream& is,
|
||||
Graph& g)
|
||||
{
|
||||
return read_polygon_mesh(is, g, parameters::all_default());
|
||||
}
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup PkgBGLIOFct
|
||||
*
|
||||
* \brief reads a polygon mesh from a file.
|
||||
*
|
||||
* Supported file formats are the following:
|
||||
* - \ref IOStreamOFF (`.off`)
|
||||
* - \ref IOStreamOBJ (`.obj`)
|
||||
* - \ref IOStreamSTL (`.stl`)
|
||||
* - \ref IOStreamPLY (`.ply`)
|
||||
* - \ref IOStreamGocad (`.ts`)
|
||||
* - \ref IOStreamVTK (`.vtp`)
|
||||
*
|
||||
* The format is detected from the filename extension (letter case is not important).
|
||||
*
|
||||
* The data is expected to represent a 2-manifold (possibly with borders).
|
||||
*
|
||||
* \tparam Graph a model of `MutableFaceGraph`
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param fname the name of the file
|
||||
* \param g the mesh
|
||||
* \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{vertex_point_map}
|
||||
* \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
* \cgalParamType{a class model of `WritablePropertyMap` 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{verbose}
|
||||
* \cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
* \cgalParamType{Boolean}
|
||||
* \cgalParamDefault{`false`}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* Other named parameters may be used according to the file extension, see \ref PkgBGLIOFct for an exhaustive list.
|
||||
*
|
||||
* \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,
|
||||
Graph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false);
|
||||
|
||||
const std::string ext = IO::internal::get_file_extension(fname);
|
||||
if(ext == std::string())
|
||||
{
|
||||
if(verbose)
|
||||
std::cerr << "Error: cannot read from file without extension" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ext == "obj")
|
||||
return read_OBJ(fname, g, np);
|
||||
else if(ext == "off")
|
||||
return read_OFF(fname, g, np);
|
||||
else if(ext == "ply")
|
||||
return read_PLY(fname, g, np);
|
||||
else if(ext == "stl")
|
||||
return read_STL(fname, g, np);
|
||||
else if(ext == "ts")
|
||||
return read_GOCAD(fname, g, np);
|
||||
#ifdef CGAL_USE_VTK
|
||||
else if(ext == "vtp")
|
||||
return read_VTP(fname, g, np);
|
||||
#endif
|
||||
|
||||
if(verbose)
|
||||
{
|
||||
std::cerr << "Error: unknown input file extension: " << ext << "\n"
|
||||
<< "Please refer to the documentation for the list of supported file formats" << std::endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <class Graph>
|
||||
bool read_polygon_mesh(const std::string& fname, Graph& g)
|
||||
{
|
||||
return read_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
|
||||
/*!
|
||||
* \ingroup PkgBGLIOFct
|
||||
*
|
||||
* \brief writes a polygon mesh in a file.
|
||||
*
|
||||
* Supported file formats are the following:
|
||||
* - \ref IOStreamOFF (`.off`)
|
||||
* - \ref IOStreamOBJ (`.obj`)
|
||||
* - \ref IOStreamSTL (`.stl`)
|
||||
* - \ref IOStreamPLY (`.ply`)
|
||||
* - \ref IOStreamGocad (`.ts`)
|
||||
* - \ref IOStreamVTK (`.vtp`)
|
||||
*
|
||||
* The format is detected from the filename extension (letter case is not important).
|
||||
*
|
||||
* \tparam Graph a model of `FaceListGraph` and `HalfedgeListGraph`
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param fname the name of the file
|
||||
* \param g the mesh to be output
|
||||
* \param np optional \ref bgl_namedparameters "Named Parameters" described below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{vertex_point_map}
|
||||
* \cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
* \cgalParamType{a class model of `ReadablePropertyMap` 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{stream_precision}
|
||||
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
|
||||
* \cgalParamType{int}
|
||||
* \cgalParamDefault{`6`}
|
||||
* \cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{verbose}
|
||||
* \cgalParamDescription{whether extra information is printed when an incident occurs during reading}
|
||||
* \cgalParamType{Boolean}
|
||||
* \cgalParamDefault{`false`}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* Other named parameters may be used according to the file extension, see \ref PkgBGLIOFct for an exhaustive list.
|
||||
*
|
||||
* \return `true` if writing was successful, `false` otherwise.
|
||||
*/
|
||||
template <class Graph, typename NamedParameters>
|
||||
bool write_polygon_mesh(const std::string& fname,
|
||||
Graph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false);
|
||||
|
||||
const std::string ext = IO::internal::get_file_extension(fname);
|
||||
if(ext == std::string())
|
||||
{
|
||||
if(verbose)
|
||||
std::cerr << "Error: trying to output to file without extension" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ext == "obj")
|
||||
return write_OBJ(fname, g, np);
|
||||
else if(ext == "off")
|
||||
return write_OFF(fname, g, np);
|
||||
else if(ext == "ply")
|
||||
return write_PLY(fname, g, np);
|
||||
else if(ext == "stl")
|
||||
return write_STL(fname, g, np);
|
||||
else if(ext == "ts")
|
||||
return write_GOCAD(fname, g, np);
|
||||
#ifdef CGAL_USE_VTK
|
||||
else if(ext == "vtp")
|
||||
return write_VTP(fname, g, np);
|
||||
#endif
|
||||
|
||||
if(verbose)
|
||||
{
|
||||
std::cerr << "Error: unknown output file extension: " << ext << "\n"
|
||||
<< "Please refer to the documentation for the list of supported file formats" << std::endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
|
||||
template <class Graph>
|
||||
bool write_polygon_mesh(const std::string& fname, Graph& g)
|
||||
{
|
||||
return write_polygon_mesh(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BOOST_GRAPH_POLYGON_MESH_IO_H
|
||||
|
|
@ -167,6 +167,8 @@ void copy_face_graph_impl(const SourceMesh& sm, TargetMesh& tm,
|
|||
for(tm_vertex_descriptor v : vertices(tm))
|
||||
{
|
||||
tm_halfedge_descriptor h = halfedge(v, tm);
|
||||
if (h==boost::graph_traits<TargetMesh>::null_halfedge())
|
||||
continue;
|
||||
tm_halfedge_descriptor next_around_vertex=h;
|
||||
do{
|
||||
next_around_vertex=opposite(next(next_around_vertex, tm), tm);
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ random_face_in_mesh(const Graph& g, CGAL::Random& rnd = get_default_random())
|
|||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
*
|
||||
* \brief Creates an isolated triangle
|
||||
* \brief creates an isolated triangle
|
||||
* with its vertices initialized to `p0`, `p1` and `p2`, and adds it to the graph `g`.
|
||||
*
|
||||
* \returns the non-border halfedge that has the target vertex associated with `p0`.
|
||||
|
|
@ -249,7 +249,7 @@ struct Default_grid_maker
|
|||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
*
|
||||
* \brief Creates an isolated quad with
|
||||
* \brief creates an isolated quad with
|
||||
* its vertices initialized to `p0`, `p1`, `p2`, and `p3`, and adds it to the graph `g`.
|
||||
*
|
||||
* \returns the non-border halfedge that has the target vertex associated with `p0`.
|
||||
|
|
@ -279,7 +279,7 @@ make_quad(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
|
|||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \brief Creates an isolated hexahedron
|
||||
* \brief creates an isolated hexahedron
|
||||
* with its vertices initialized to `p0`, `p1`, ...\ , and `p7`, and adds it to the graph `g`.
|
||||
* \image html hexahedron.png
|
||||
* \image latex hexahedron.png
|
||||
|
|
@ -341,7 +341,7 @@ make_hexahedron(const P& p0, const P& p1, const P& p2, const P& p3,
|
|||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \brief Creates an isolated tetrahedron
|
||||
* \brief creates an isolated tetrahedron
|
||||
* with its vertices initialized to `p0`, `p1`, `p2`, and `p3`, and adds it to the graph `g`.
|
||||
* \image html tetrahedron.png
|
||||
* \image latex tetrahedron.png
|
||||
|
|
@ -440,7 +440,7 @@ make_tetrahedron(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
|
|||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
*
|
||||
* \brief Creates a triangulated regular prism, outward oriented,
|
||||
* \brief creates a triangulated regular prism, outward oriented,
|
||||
* having `nb_vertices` vertices in each of its bases and adds it to the graph `g`.
|
||||
* If `center` is (0, 0, 0), then the first point of the prism is (`radius`, `height`, 0)
|
||||
*
|
||||
|
|
@ -483,15 +483,15 @@ make_regular_prism(typename boost::graph_traits<Graph>::vertices_size_type nb_ve
|
|||
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i < nb_vertices; ++i)
|
||||
{
|
||||
put(vpmap, vertices[i],
|
||||
P(0.5*diameter * cos(i*precision*to_rad) + base_center.x(),
|
||||
P(0.5*diameter * cos(to_double(FT(i)*precision*to_rad)) + base_center.x(),
|
||||
height+base_center.y(),
|
||||
-0.5*diameter * sin(i*precision*to_rad) + base_center.z()));
|
||||
-0.5*diameter * sin(to_double(FT(i)*precision*to_rad)) + base_center.z()));
|
||||
|
||||
put(vpmap,
|
||||
vertices[i+nb_vertices],
|
||||
P(0.5*diameter * cos(i*precision*to_rad) + base_center.x(),
|
||||
P(0.5*diameter * cos(to_double(FT(i)*precision*to_rad)) + base_center.x(),
|
||||
base_center.y(),
|
||||
-0.5*diameter * sin(i*precision*to_rad) + base_center.z()));
|
||||
-0.5*diameter * sin(to_double(FT(i)*precision*to_rad)) + base_center.z()));
|
||||
}
|
||||
|
||||
//fill faces
|
||||
|
|
@ -539,7 +539,7 @@ make_regular_prism(typename boost::graph_traits<Graph>::vertices_size_type nb_ve
|
|||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \brief Creates a pyramid, outward oriented, having `nb_vertices` vertices in its base and adds it to the graph `g`.
|
||||
* \brief creates a pyramid, outward oriented, having `nb_vertices` vertices in its base and adds it to the graph `g`.
|
||||
*
|
||||
* If `center` is `(0, 0, 0)`, then the first point of the base is `(radius, 0, 0)`
|
||||
*
|
||||
|
|
@ -589,9 +589,9 @@ make_pyramid(typename boost::graph_traits<Graph>::vertices_size_type nb_vertices
|
|||
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
|
||||
{
|
||||
put(vpmap, vertices[i],
|
||||
P(0.5*diameter*cos(i*precision*to_rad)+base_center.x(),
|
||||
P(0.5*diameter*cos(to_double(FT(i)*precision*to_rad))+base_center.x(),
|
||||
base_center.y(),
|
||||
-0.5*diameter*sin(i*precision*to_rad)+base_center.z()));
|
||||
-0.5*diameter*sin(to_double(FT(i)*precision*to_rad))+base_center.z()));
|
||||
}
|
||||
|
||||
//fill faces
|
||||
|
|
@ -628,7 +628,7 @@ make_pyramid(typename boost::graph_traits<Graph>::vertices_size_type nb_vertices
|
|||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
*
|
||||
* \brief Creates an icosahedron, outward oriented, centered in `center` and adds it to the graph `g`.
|
||||
* \brief creates an icosahedron, outward oriented, centered in `center` and adds it to the graph `g`.
|
||||
*
|
||||
* \param g the graph in which the icosahedron will be created.
|
||||
* \param center the center of the sphere in which the icosahedron is inscribed.
|
||||
|
|
@ -721,7 +721,7 @@ make_icosahedron(Graph& g,
|
|||
/*!
|
||||
* \ingroup PkgBGLHelperFct
|
||||
*
|
||||
* \brief Creates a row major ordered grid with `i` cells along the width and `j` cells
|
||||
* \brief creates a row major ordered grid with `i` cells along the width and `j` cells
|
||||
* along the height and adds it to the graph `g`.
|
||||
* An internal property map for `CGAL::vertex_point_t` must be available in `Graph`.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ BOOST_concept(HalfedgeGraph,(G))
|
|||
|
||||
BOOST_CONCEPT_USAGE(HalfedgeGraph)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<halfedge_descriptor>)) CGAL_UNUSED;
|
||||
BOOST_CONCEPT_ASSERT((boost::EqualityComparable<halfedge_descriptor>)) CGAL_UNUSED;
|
||||
BOOST_CONCEPT_ASSERT((boost::Assignable<halfedge_descriptor>)) CGAL_UNUSED;
|
||||
BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<halfedge_descriptor>));
|
||||
BOOST_CONCEPT_ASSERT((boost::EqualityComparable<halfedge_descriptor>));
|
||||
BOOST_CONCEPT_ASSERT((boost::Assignable<halfedge_descriptor>));
|
||||
|
||||
|
||||
e = edge(h, g);
|
||||
|
|
@ -97,9 +97,9 @@ BOOST_concept(FaceGraph,(G))
|
|||
|
||||
BOOST_CONCEPT_USAGE(FaceGraph)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<face_descriptor>)) CGAL_UNUSED;
|
||||
BOOST_CONCEPT_ASSERT((boost::EqualityComparable<face_descriptor>)) CGAL_UNUSED;
|
||||
BOOST_CONCEPT_ASSERT((boost::Assignable<face_descriptor>)) CGAL_UNUSED;
|
||||
BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<face_descriptor>));
|
||||
BOOST_CONCEPT_ASSERT((boost::EqualityComparable<face_descriptor>));
|
||||
BOOST_CONCEPT_ASSERT((boost::Assignable<face_descriptor>));
|
||||
|
||||
f = face(h, g);
|
||||
h = halfedge(f, g);
|
||||
|
|
|
|||
|
|
@ -631,20 +631,19 @@ void clear(OPEN_MESH_CLASS& sm)
|
|||
CGAL_postcondition(num_faces(sm) == 0);
|
||||
}
|
||||
|
||||
//doesn't seem to work. Use BGL default IO functions instead.
|
||||
//template<typename K>
|
||||
//bool read_OFF(std::istream& is, OPEN_MESH_CLASS& sm)
|
||||
//{
|
||||
// OpenMesh::IO::Options ropt;
|
||||
// return OpenMesh::IO::read_mesh(sm, is, ".OFF", ropt, false);
|
||||
//}
|
||||
|
||||
template<typename K>
|
||||
bool read_off(std::istream& is, OPEN_MESH_CLASS& sm)
|
||||
{
|
||||
OpenMesh::IO::Options ropt;
|
||||
return OpenMesh::IO::read_mesh(sm, is, ".OFF", ropt, false);
|
||||
}
|
||||
|
||||
|
||||
template<typename K>
|
||||
bool write_off(std::ostream& os, OPEN_MESH_CLASS& sm)
|
||||
{
|
||||
return OpenMesh::IO::write_mesh(sm, os, ".OFF");
|
||||
}
|
||||
//template<typename K>
|
||||
//bool write_OFF(std::ostream& os, OPEN_MESH_CLASS& sm)
|
||||
//{
|
||||
// return OpenMesh::IO::write_mesh(sm, os, ".OFF");
|
||||
//}
|
||||
|
||||
}
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
|
|
|||
|
|
@ -341,10 +341,12 @@ bool is_valid_face_descriptor( typename boost::graph_traits<FaceGraph>::face_des
|
|||
* and all of its associations are reciprocal.
|
||||
* For example, `prev(next(h, g), g)` must be `h`,
|
||||
* and `next(prev(h, g), g)` must be `h`.
|
||||
* \param g the `Graph` to test.
|
||||
* \param verb : if `true`, the details of the check will be written in the standard output.
|
||||
*
|
||||
* \tparam `Graph` a model of `HalfedgeListGraph`
|
||||
* \param g the `Graph` to test.
|
||||
* \param verb if `true`, the details of the check will be written in the standard output.
|
||||
*
|
||||
* \tparam Graph a model of `HalfedgeListGraph`
|
||||
*
|
||||
* \return `true` if `g` is valid, `false` otherwise.
|
||||
*
|
||||
*/
|
||||
|
|
@ -524,10 +526,12 @@ bool is_valid_halfedge_graph(const Graph& g, bool verb = false)
|
|||
* of the `FaceListGraph` concept, and all of its associations are reciprocal.
|
||||
* For example, `face(halfedge(f,g),g)` must be `f`.
|
||||
* calls `is_valid_halfedge_graph()`
|
||||
* \param g the `Graph` to test.
|
||||
* \param verb : if `true`, the details of the check will be written in the standard output.
|
||||
*
|
||||
* \tparam `Graph` a model of `FaceListGraph`
|
||||
* \param g the `Graph` to test.
|
||||
* \param verb if `true`, the details of the check will be written in the standard output.
|
||||
*
|
||||
* \tparam Graph a model of `FaceListGraph`
|
||||
*
|
||||
* \return `true` if `g` is valid, `false` otherwise.
|
||||
*
|
||||
* \see `is_valid_halfedge_graph()`
|
||||
|
|
|
|||
|
|
@ -6,719 +6,20 @@
|
|||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
|
||||
#ifndef CGAL_BOOST_GRAPH_IO_H
|
||||
#define CGAL_BOOST_GRAPH_IO_H
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
#include <CGAL/boost/graph/Named_function_parameters.h>
|
||||
#include <CGAL/IO/write_vtk.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFct
|
||||
|
||||
writes the graph `g` in the wrl format (VRML 2.0).
|
||||
|
||||
\param os the output stream
|
||||
\param g the graph to be written
|
||||
\param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<FaceGraph>::%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 `FaceGraph`.}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
*/
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool write_wrl(std::ostream& os,
|
||||
const FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertices_size_type vertices_size_type;
|
||||
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
|
||||
typename CGAL::GetVertexPointMap<FaceGraph, NamedParameters>::const_type
|
||||
vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
boost::container::flat_map<vertex_descriptor,vertices_size_type> reindex;
|
||||
int n = 0;
|
||||
|
||||
os << "#VRML V2.0 utf8\n"
|
||||
"Group {\n"
|
||||
"children [\n"
|
||||
"Shape {\n"
|
||||
"appearance DEF A1 Appearance {\n"
|
||||
"material Material {\n"
|
||||
"diffuseColor .6 .5 .9\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
"appearance\n"
|
||||
"Appearance {\n"
|
||||
"material DEF Material Material {}\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
"Group {\n"
|
||||
"children [\n"
|
||||
"Shape {\n"
|
||||
"appearance Appearance { material USE Material }\n"
|
||||
"geometry IndexedFaceSet {\n"
|
||||
"convex FALSE\n"
|
||||
"solid FALSE\n"
|
||||
"coord Coordinate {\n"
|
||||
"point [\n";
|
||||
|
||||
for(vertex_descriptor v : vertices(g)){
|
||||
os << get(vpm,v) << ",\n";
|
||||
reindex[v]=n++;
|
||||
}
|
||||
os << "] #point\n"
|
||||
"} #coord Coordinate\n"
|
||||
"coordIndex [\n";
|
||||
for(face_descriptor f : faces(g)){
|
||||
for(vertex_descriptor v : vertices_around_face(halfedge(f,g),g)){
|
||||
os << reindex[v] << ",";
|
||||
}
|
||||
os << "-1,\n";
|
||||
}
|
||||
|
||||
os << "] #coordIndex\n"
|
||||
"} #geometry\n"
|
||||
"} #Shape\n"
|
||||
"] #children\n"
|
||||
"} #group\n"
|
||||
"]\n"
|
||||
"}\n";
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool write_wrl(std::ostream& os,
|
||||
const FaceGraph& g)
|
||||
{
|
||||
return write_wrl(os, g,
|
||||
parameters::all_default());
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFct
|
||||
|
||||
writes the graph `g` in the OFF format.
|
||||
|
||||
\param os the output stream
|
||||
\param g the graph to be written
|
||||
\param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<FaceGraph>::%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 `FaceGraph`.}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
*/
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool write_off(std::ostream& os,
|
||||
const FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertices_size_type vertices_size_type;
|
||||
typedef typename boost::graph_traits<FaceGraph>::faces_size_type faces_size_type;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
typename CGAL::GetVertexPointMap<FaceGraph, NamedParameters>::const_type
|
||||
vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
vertices_size_type nv = static_cast<vertices_size_type>(std::distance(vertices(g).first, vertices(g).second));
|
||||
faces_size_type nf = static_cast<faces_size_type>(std::distance(faces(g).first, faces(g).second));
|
||||
|
||||
os << "OFF\n" << nv << " " << nf << " 0\n";
|
||||
boost::container::flat_map<vertex_descriptor,vertices_size_type> reindex;
|
||||
int n = 0;
|
||||
for(vertex_descriptor v : vertices(g)){
|
||||
os << get(vpm,v) << '\n';
|
||||
reindex[v]=n++;
|
||||
}
|
||||
|
||||
for(face_descriptor f : faces(g)){
|
||||
os << degree(f,g);
|
||||
for(vertex_descriptor v : vertices_around_face(halfedge(f,g),g)){
|
||||
os << " " << reindex[v];
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFct
|
||||
writes the graph `g` in the OFF format into a file named `fname`.
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
|
||||
*/
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool write_off(const char* fname,
|
||||
const FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
std::ofstream out(fname);
|
||||
if(out.good()){
|
||||
return write_off(out,g, np);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool write_off(const std::string& fname,
|
||||
const FaceGraph& g,
|
||||
const NamedParameters& np)
|
||||
{ return write_off(fname.c_str(), g, np); }
|
||||
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool write_off(std::ostream& os,
|
||||
const FaceGraph& g)
|
||||
{
|
||||
return write_off(os, g,
|
||||
parameters::all_default());
|
||||
}
|
||||
template <typename FaceGraph>
|
||||
bool write_off(const char* fname,
|
||||
const FaceGraph& g)
|
||||
{
|
||||
return write_off(fname,g,
|
||||
parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool write_off(const std::string& fname,
|
||||
const FaceGraph& g)
|
||||
{ return write_off(fname, g,
|
||||
parameters::all_default()); }
|
||||
|
||||
namespace internal { namespace read_off_tools {
|
||||
|
||||
inline bool is_whitespace(const std::string& s)
|
||||
{
|
||||
for(unsigned int i=0; i < s.size(); i++){
|
||||
if(s[i] != ' ' && s[i] != '\t'){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline std::string next_non_comment(std::istream& is)
|
||||
{
|
||||
std::string line;
|
||||
do {
|
||||
std::getline(is, line);
|
||||
}while(line[0] == '#' || is_whitespace(line));
|
||||
return line;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFct
|
||||
|
||||
reads the graph `g` from data in the OFF format. Ignores comment lines which start with a hash, and lines with whitespace.
|
||||
|
||||
\param is the input stream
|
||||
\param g the graph to be read
|
||||
\param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
|
||||
\cgalNamedParamsBegin
|
||||
\cgalParamNBegin{vertex_point_map}
|
||||
\cgalParamDescription{a property map associating points to the vertices of `g`}
|
||||
\cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits<FaceGraph>::%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 `FaceGraph`.}
|
||||
\cgalParamNEnd
|
||||
\cgalNamedParamsEnd
|
||||
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
\pre The data must represent a 2-manifold
|
||||
|
||||
\attention The graph `g` is not cleared, and the data from the stream are added.
|
||||
*/
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool read_off(std::istream& is,
|
||||
FaceGraph& g,
|
||||
NamedParameters np)
|
||||
{
|
||||
using namespace internal::read_off_tools;
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertices_size_type vertices_size_type;
|
||||
typedef typename boost::graph_traits<FaceGraph>::faces_size_type faces_size_type;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<FaceGraph, NamedParameters>::type Vpm;
|
||||
typedef typename boost::property_traits<Vpm>::value_type Point_3;
|
||||
|
||||
Vpm vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_property_map(CGAL::vertex_point, g));
|
||||
vertices_size_type nv, nvf;
|
||||
faces_size_type nf;
|
||||
int ignore;
|
||||
|
||||
std::string line = next_non_comment(is);
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
std::string off;
|
||||
iss >> off;
|
||||
CGAL_assertion( off == "OFF" || off == "COFF");
|
||||
}
|
||||
line = next_non_comment(is);
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
iss >> nv >> nf >> ignore;
|
||||
}
|
||||
|
||||
std::vector<vertex_descriptor> vertices(nv);
|
||||
Point_3 p;
|
||||
for(vertices_size_type i=0; i < nv; i++){
|
||||
line = next_non_comment(is);
|
||||
std::istringstream iss(line);
|
||||
iss >> p;
|
||||
vertices[i] = add_vertex(g);
|
||||
put(vpm,vertices[i],p);
|
||||
}
|
||||
|
||||
for(faces_size_type i=0; i < nf; i++){
|
||||
line = next_non_comment(is);
|
||||
std::istringstream iss(line);
|
||||
iss >> nvf;
|
||||
std::vector<vertex_descriptor> face(nvf);
|
||||
for(vertices_size_type j = 0; j < nvf; j++){
|
||||
faces_size_type fvi;
|
||||
iss >> fvi;
|
||||
face[j] = vertices[fvi];
|
||||
}
|
||||
Euler::add_face(face,g);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool read_off(std::istream& is,
|
||||
FaceGraph& g)
|
||||
{
|
||||
return read_off(is, g, parameters::all_default());
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLIOFct
|
||||
reads the graph `g` from data in the OFF format. Ignores comment lines which start with a hash, and lines with whitespace.
|
||||
\sa Overloads of this function for specific models of the concept `FaceGraph`.
|
||||
\pre The data must represent a 2-manifold
|
||||
\attention The graph `g` is not cleared, and the data from the stream are added.
|
||||
|
||||
*/
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool read_off(const char* fname,
|
||||
FaceGraph& g,
|
||||
NamedParameters np)
|
||||
{
|
||||
std::ifstream in(fname);
|
||||
if(in.good()){
|
||||
return read_off(in, g, np);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool read_off(const char* fname,
|
||||
FaceGraph& g)
|
||||
{
|
||||
return read_off(fname, g, parameters::all_default());
|
||||
}
|
||||
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool read_off(const std::string& fname,
|
||||
FaceGraph& g,
|
||||
NamedParameters np)
|
||||
{ return read_off(fname.c_str(), g, np); }
|
||||
|
||||
template <typename FaceGraph>
|
||||
bool read_off(const std::string& fname,
|
||||
FaceGraph& g)
|
||||
{ return read_off(fname, g, parameters::all_default()); }
|
||||
|
||||
template <typename FaceGraph, typename NamedParameters>
|
||||
bool write_inp(std::ostream& os,
|
||||
const FaceGraph& g,
|
||||
std::string name,
|
||||
std::string type,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||
typedef typename boost::graph_traits<FaceGraph>::vertices_size_type vertices_size_type;
|
||||
|
||||
typedef typename CGAL::GetVertexPointMap<FaceGraph, NamedParameters>::const_type VPM;
|
||||
typedef typename boost::property_traits<VPM>::value_type Point_3;
|
||||
|
||||
using parameters::choose_parameter;
|
||||
using parameters::get_parameter;
|
||||
|
||||
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, g));
|
||||
|
||||
os << "*Part, name=" << name << "\n*Node\n";
|
||||
boost::container::flat_map<vertex_descriptor,vertices_size_type> reindex;
|
||||
int n = 1;
|
||||
for(vertex_descriptor v : vertices(g)){
|
||||
Point_3 p = get(vpm,v);
|
||||
os << n << ", " << p.x() << ", " << p.y() << ", " << p.z() << '\n';
|
||||
reindex[v]=n++;
|
||||
}
|
||||
n = 1;
|
||||
os << "*Element, type=" << type << std::endl;
|
||||
for(face_descriptor f : faces(g)){
|
||||
os << n++;
|
||||
for(vertex_descriptor v : vertices_around_face(halfedge(f,g),g)){
|
||||
os << ", " << reindex[v];
|
||||
}
|
||||
os << '\n';
|
||||
}
|
||||
os << "*End Part"<< std::endl;
|
||||
return os.good();
|
||||
}
|
||||
// conveniance overload
|
||||
template <typename FaceGraph>
|
||||
bool write_inp(std::ostream& os,
|
||||
const FaceGraph& g,
|
||||
std::string name,
|
||||
std::string type)
|
||||
{
|
||||
return write_inp(os, g, name, type, parameters::all_default());
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
namespace write_vtp {
|
||||
|
||||
// writes the polys appended data at the end of the .vtp file
|
||||
template <class Mesh,
|
||||
typename NamedParameters>
|
||||
void
|
||||
write_polys(std::ostream& os,
|
||||
const Mesh & mesh,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Mesh>::face_iterator face_iterator;
|
||||
|
||||
typedef typename CGAL::GetInitializedVertexIndexMap<Mesh, NamedParameters>::const_type Vimap;
|
||||
Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np);
|
||||
|
||||
std::vector<std::size_t> connectivity_table;
|
||||
std::vector<std::size_t> offsets;
|
||||
std::vector<unsigned char> cell_type(num_faces(mesh),5); // triangle == 5
|
||||
|
||||
std::size_t off = 0;
|
||||
for( face_iterator fit = faces(mesh).begin() ;
|
||||
fit != faces(mesh).end() ;
|
||||
++fit )
|
||||
{
|
||||
off += 3;
|
||||
offsets.push_back(off);
|
||||
for(vertex_descriptor v :
|
||||
vertices_around_face(halfedge(*fit, mesh), mesh))
|
||||
connectivity_table.push_back(V[v]);
|
||||
}
|
||||
write_vector<std::size_t>(os,connectivity_table);
|
||||
write_vector<std::size_t>(os,offsets);
|
||||
write_vector<unsigned char>(os,cell_type);
|
||||
}
|
||||
//todo use named params for maps
|
||||
template <class Mesh,
|
||||
typename NamedParameters>
|
||||
void
|
||||
write_polys_tag(std::ostream& os,
|
||||
const Mesh & mesh,
|
||||
bool binary,
|
||||
std::size_t& offset,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<Mesh>::face_iterator face_iterator;
|
||||
|
||||
typedef typename CGAL::GetInitializedVertexIndexMap<Mesh, NamedParameters>::const_type Vimap;
|
||||
Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np);
|
||||
|
||||
std::string formatattribute =
|
||||
binary ? " format=\"appended\"" : " format=\"ascii\"";
|
||||
|
||||
std::string typeattribute;
|
||||
switch(sizeof(std::size_t)) {
|
||||
case 8: typeattribute = " type=\"UInt64\""; break;
|
||||
case 4: typeattribute = " type=\"UInt32\""; break;
|
||||
default: CGAL_error_msg("Unknown size of std::size_t");
|
||||
}
|
||||
|
||||
// Write connectivity table
|
||||
os << " <Polys>\n"
|
||||
<< " <DataArray Name=\"connectivity\""
|
||||
<< formatattribute << typeattribute;
|
||||
|
||||
if (binary) { // if binary output, just write the xml tag
|
||||
os << " offset=\"" << offset << "\"/>\n";
|
||||
offset += (3 * num_faces(mesh)+ 1) * sizeof(std::size_t);
|
||||
// 3 indices (size_t) per triangle + length of the encoded data (size_t)
|
||||
}
|
||||
else {
|
||||
os << "\">\n";
|
||||
for( face_iterator fit = faces(mesh).begin() ;
|
||||
fit != faces(mesh).end() ;
|
||||
++fit )
|
||||
{
|
||||
for(vertex_descriptor v :
|
||||
vertices_around_face(halfedge(*fit, mesh), mesh))
|
||||
os << V[v] << " ";
|
||||
}
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
|
||||
// Write offsets
|
||||
os << " <DataArray Name=\"offsets\""
|
||||
<< formatattribute << typeattribute;
|
||||
|
||||
if (binary) { // if binary output, just write the xml tag
|
||||
os << " offset=\"" << offset << "\"/>\n";
|
||||
offset += (num_faces(mesh) + 1) * sizeof(std::size_t);
|
||||
// 1 offset (size_t) per triangle + length of the encoded data (size_t)
|
||||
}
|
||||
else {
|
||||
os << "\">\n";
|
||||
std::size_t polys_offset = 0;
|
||||
for( face_iterator fit = faces(mesh).begin() ;
|
||||
fit != faces(mesh).end() ;
|
||||
++fit )
|
||||
{
|
||||
polys_offset += 3;
|
||||
os << polys_offset << " ";
|
||||
}
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
|
||||
// Write cell type (triangle == 5)
|
||||
os << " <DataArray Name=\"types\""
|
||||
<< formatattribute << " type=\"UInt8\"";
|
||||
|
||||
if (binary) {
|
||||
os << " offset=\"" << offset << "\"/>\n";
|
||||
offset += num_faces(mesh) + sizeof(std::size_t);
|
||||
// 1 unsigned char per cell + length of the encoded data (size_t)
|
||||
}
|
||||
else {
|
||||
os << "\">\n";
|
||||
for(std::size_t i = 0; i< num_faces(mesh); ++i)
|
||||
os << "5 ";
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
os << " </Polys>\n";
|
||||
}
|
||||
|
||||
//todo : use namedparams for points and ids
|
||||
//overload for facegraph
|
||||
template <class Mesh,
|
||||
typename NamedParameters>
|
||||
void
|
||||
write_points_tag(std::ostream& os,
|
||||
const Mesh & mesh,
|
||||
bool binary,
|
||||
std::size_t& offset,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Mesh>::vertex_iterator vertex_iterator;
|
||||
typedef typename CGAL::GetVertexPointMap<Mesh, NamedParameters>::const_type Vpmap;
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
Vpmap vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, mesh));
|
||||
typedef typename boost::property_traits<Vpmap>::value_type Point_t;
|
||||
typedef typename CGAL::Kernel_traits<Point_t>::Kernel Gt;
|
||||
typedef typename Gt::FT FT;
|
||||
|
||||
std::string format = binary ? "appended" : "ascii";
|
||||
std::string type = (sizeof(FT) == 8) ? "Float64" : "Float32";
|
||||
|
||||
os << " <Points>\n"
|
||||
<< " <DataArray type =\"" << type << "\" NumberOfComponents=\"3\" format=\""
|
||||
<< format;
|
||||
|
||||
if (binary) {
|
||||
os << "\" offset=\"" << offset << "\"/>\n";
|
||||
offset += 3 * num_vertices(mesh) * sizeof(FT) + sizeof(std::size_t);
|
||||
// 3 coords per points + length of the encoded data (size_t)
|
||||
}
|
||||
else {
|
||||
os << "\">\n";
|
||||
for( vertex_iterator vit = vertices(mesh).begin();
|
||||
vit != vertices(mesh).end();
|
||||
++vit)
|
||||
{
|
||||
os << get(vpm, *vit).x() << " " << get(vpm, *vit).y() << " "
|
||||
<< get(vpm, *vit).z() << " ";
|
||||
}
|
||||
os << " </DataArray>\n";
|
||||
}
|
||||
os << " </Points>\n";
|
||||
}
|
||||
|
||||
|
||||
// writes the points appended data at the end of the .vtp file
|
||||
template <class Mesh,
|
||||
class NamedParameters>
|
||||
void
|
||||
write_polys_points(std::ostream& os,
|
||||
const Mesh & mesh,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef typename boost::graph_traits<Mesh>::vertex_iterator vertex_iterator;
|
||||
typedef typename CGAL::GetVertexPointMap<Mesh, NamedParameters>::const_type Vpmap;
|
||||
using parameters::get_parameter;
|
||||
using parameters::choose_parameter;
|
||||
Vpmap vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
|
||||
get_const_property_map(CGAL::vertex_point, mesh));
|
||||
typedef typename boost::property_traits<Vpmap>::value_type Point_t;
|
||||
typedef typename CGAL::Kernel_traits<Point_t>::Kernel Gt;
|
||||
typedef typename Gt::FT FT;
|
||||
std::vector<FT> coordinates;
|
||||
for( vertex_iterator vit = vertices(mesh).begin();
|
||||
vit != vertices(mesh).end();
|
||||
++vit)
|
||||
{
|
||||
coordinates.push_back(get(vpm, *vit).x());
|
||||
coordinates.push_back(get(vpm, *vit).y());
|
||||
coordinates.push_back(get(vpm, *vit).z());
|
||||
}
|
||||
write_vector<FT>(os,coordinates);
|
||||
}
|
||||
|
||||
} // end namespace CGAL::internal::write_vtp
|
||||
} // end namespace CGAL::internal
|
||||
|
||||
/*!\ingroup PkgBGLIOFct
|
||||
*
|
||||
* \brief writes a triangulated surface mesh in the `PolyData` XML format.
|
||||
*
|
||||
* \tparam TriangleMesh a model of `FaceListGraph` with only triangle faces.
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param os the stream used for writing.
|
||||
* \param mesh the triangle mesh to be written.
|
||||
* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{use_binary_mode}
|
||||
* \cgalParamDescription{Boolean indicating if the data should be written in binary (`true`) or in ASCII (`false`)}
|
||||
* \cgalParamType{Boolean}
|
||||
* \cgalParamDefault{`true`}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{vertex_point_map}
|
||||
* \cgalParamDescription{a property map associating points to the vertices of `mesh`}
|
||||
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
|
||||
* as key type and `%Point_3` as value type}
|
||||
* \cgalParamDefault{`boost::get(CGAL::vertex_point, mesh)`}
|
||||
* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
|
||||
* must be available in `TriangleMesh`.}
|
||||
* \cgalParamNEnd
|
||||
*
|
||||
* \cgalParamNBegin{vertex_index_map}
|
||||
* \cgalParamDescription{a property map associating to each vertex of `mesh` a unique index between `0` and `num_vertices(mesh) - 1`}
|
||||
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<TriangleMesh>::%vertex_descriptor`
|
||||
* as key type and `std::size_t` as value type}
|
||||
* \cgalParamDefault{an automatically indexed internal map}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*/
|
||||
template<class TriangleMesh,
|
||||
class NamedParameters>
|
||||
void write_vtp(std::ostream& os,
|
||||
const TriangleMesh& mesh,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
os << "<?xml version=\"1.0\"?>\n"
|
||||
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";
|
||||
#ifdef CGAL_LITTLE_ENDIAN
|
||||
os << " byte_order=\"LittleEndian\"";
|
||||
#else // CGAL_BIG_ENDIAN
|
||||
os << " byte_order=\"BigEndian\"";
|
||||
#endif
|
||||
switch(sizeof(std::size_t)) {
|
||||
case 4: os << " header_type=\"UInt32\""; break;
|
||||
case 8: os << " header_type=\"UInt64\""; break;
|
||||
default: CGAL_error_msg("Unknown size of std::size_t");
|
||||
}
|
||||
os << ">\n"
|
||||
<< " <PolyData>" << "\n";
|
||||
|
||||
os << " <Piece NumberOfPoints=\"" << num_vertices(mesh)
|
||||
<< "\" NumberOfPolys=\"" << num_faces(mesh) << "\">\n";
|
||||
std::size_t offset = 0;
|
||||
const bool binary = parameters::choose_parameter(parameters::get_parameter(np, internal_np::use_binary_mode), true);
|
||||
internal::write_vtp::write_points_tag(os,mesh,binary,offset, np);
|
||||
internal::write_vtp::write_polys_tag(os,mesh,binary,offset, np);
|
||||
os << " </Piece>\n"
|
||||
<< " </PolyData>\n";
|
||||
if (binary) {
|
||||
os << "<AppendedData encoding=\"raw\">\n_";
|
||||
internal::write_vtp::write_polys_points(os,mesh, np);
|
||||
internal::write_vtp::write_polys(os,mesh, np);
|
||||
}
|
||||
os << "</VTKFile>\n";
|
||||
}
|
||||
|
||||
template<class TriangleMesh>
|
||||
void write_vtp(std::ostream& os,
|
||||
const TriangleMesh& mesh)
|
||||
{
|
||||
write_vtp(os, mesh, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
#include <CGAL/boost/graph/IO/3MF.h>
|
||||
#include <CGAL/boost/graph/IO/GOCAD.h>
|
||||
#include <CGAL/boost/graph/IO/INP.h>
|
||||
#include <CGAL/boost/graph/IO/OBJ.h>
|
||||
#include <CGAL/boost/graph/IO/OFF.h>
|
||||
#include <CGAL/boost/graph/IO/PLY.h>
|
||||
#include <CGAL/boost/graph/IO/STL.h>
|
||||
#include <CGAL/boost/graph/IO/VTK.h>
|
||||
#include <CGAL/boost/graph/IO/WRL.h>
|
||||
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
|
||||
|
||||
#endif // CGAL_BOOST_GRAPH_IO_H
|
||||
|
|
|
|||
|
|
@ -128,8 +128,6 @@ namespace CGAL {
|
|||
> ::type const_type;
|
||||
};
|
||||
|
||||
namespace Polygon_mesh_processing {
|
||||
|
||||
template<typename PolygonMesh, typename NamedParameters>
|
||||
class GetK
|
||||
{
|
||||
|
|
@ -140,8 +138,6 @@ namespace CGAL {
|
|||
typedef typename CGAL::Kernel_traits<Point>::Kernel Kernel;
|
||||
};
|
||||
|
||||
} // namespace Polygon_mesh_processing
|
||||
|
||||
template<typename PolygonMesh,
|
||||
typename NamedParametersGT = Named_function_parameters<bool, internal_np::all_default_t>,
|
||||
typename NamedParametersVPM = NamedParametersGT >
|
||||
|
|
@ -159,7 +155,7 @@ namespace CGAL {
|
|||
struct Fake_GT {};//to be used if there is no internal vertex_point_map in PolygonMesh
|
||||
|
||||
typedef typename boost::mpl::if_c<Has_internal_pmap::value || !boost::is_same<internal_np::Param_not_found, NP_vpm>::value,
|
||||
typename Polygon_mesh_processing::GetK<PolygonMesh, NamedParametersVPM>::Kernel,
|
||||
typename GetK<PolygonMesh, NamedParametersVPM>::Kernel,
|
||||
Fake_GT>::type DefaultKernel;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -39,6 +39,20 @@ CGAL_add_named_parameter(face_to_face_map_t, face_to_face_map, face_to_face_map)
|
|||
CGAL_add_named_parameter(implementation_tag_t, implementation_tag, implementation_tag)
|
||||
CGAL_add_named_parameter(prevent_unselection_t, prevent_unselection, prevent_unselection)
|
||||
|
||||
CGAL_add_named_parameter(stream_precision_t, stream_precision, stream_precision)
|
||||
CGAL_add_named_parameter(verbose_t, verbose, verbose)
|
||||
|
||||
// List of named parameters used for IO
|
||||
CGAL_add_named_parameter(vertex_normal_output_iterator_t, vertex_normal_output_iterator, vertex_normal_output_iterator)
|
||||
CGAL_add_named_parameter(vertex_color_output_iterator_t, vertex_color_output_iterator, vertex_color_output_iterator)
|
||||
CGAL_add_named_parameter(vertex_texture_output_iterator_t, vertex_texture_output_iterator, vertex_texture_output_iterator)
|
||||
CGAL_add_named_parameter(face_color_output_iterator_t, face_color_output_iterator, face_color_output_iterator)
|
||||
CGAL_add_named_parameter(vertex_normal_map_t, vertex_normal_map, vertex_normal_map)
|
||||
CGAL_add_named_parameter(vertex_color_map_t, vertex_color_map, vertex_color_map)
|
||||
CGAL_add_named_parameter(vertex_texture_map_t, vertex_texture_map, vertex_texture_map)
|
||||
CGAL_add_named_parameter(face_color_map_t, face_color_map, face_color_map)
|
||||
CGAL_add_named_parameter(repair_polygon_soup_t, repair_polygon_soup, repair_polygon_soup)
|
||||
|
||||
// List of named parameters that we use in the package 'Mesh_3'
|
||||
CGAL_add_named_parameter(vertex_feature_degree_t, vertex_feature_degree, vertex_feature_degree_map)
|
||||
|
||||
|
|
@ -103,10 +117,12 @@ CGAL_add_named_parameter(volume_threshold_t, volume_threshold, volume_threshold)
|
|||
CGAL_add_named_parameter(dry_run_t, dry_run, dry_run)
|
||||
CGAL_add_named_parameter(do_not_modify_t, do_not_modify, do_not_modify)
|
||||
CGAL_add_named_parameter(allow_self_intersections_t, allow_self_intersections, allow_self_intersections)
|
||||
CGAL_add_named_parameter(polyhedral_envelope_epsilon_t, polyhedral_envelope_epsilon, polyhedral_envelope_epsilon)
|
||||
|
||||
// List of named parameters that we use in the package 'Surface Mesh Simplification'
|
||||
CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost)
|
||||
CGAL_add_named_parameter(get_placement_policy_t, get_placement_policy, get_placement)
|
||||
CGAL_add_named_parameter(filter_t, filter, filter)
|
||||
|
||||
//to be documented
|
||||
CGAL_add_named_parameter(face_normal_t, face_normal, face_normal_map)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#define CGAL_BGL_PARTITION_H
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLRef
|
||||
* \ingroup PkgBGLPartition
|
||||
* \file CGAL/boost/graph/partition.h
|
||||
* Convenience header file including the headers for all the partitioning-related
|
||||
* free functions of this package.
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ struct Is_writable_property_map<PropertyMap, boost::read_write_property_map_tag>
|
|||
// 'lvalue_pmap_tag' is annoying, because the property map is allowed to be non-mutable,
|
||||
// but boost::lvalue_property_map_tag is defined as:
|
||||
// struct lvalue_property_map_tag : public read_write_property_map_tag
|
||||
// so we can't just check that 'writable_property_map_tag' is a base of the the lvalue tag.
|
||||
// so we can't just check that 'writable_property_map_tag' is a base of the lvalue tag.
|
||||
//
|
||||
// This checks if the reference is non-const, which is not completely correct: map[key] returning
|
||||
// a non-const reference doesn't mean that 'put(map, key, val)' exists, which is what a writable
|
||||
|
|
@ -177,7 +177,7 @@ struct Is_writable_property_map<PropertyMap, boost::lvalue_property_map_tag>
|
|||
|
||||
} // namespace internal
|
||||
|
||||
// Needed by PMP::detec_features and Mesh_3
|
||||
// Needed by PMP::detect_features and Mesh_3
|
||||
enum vertex_feature_degree_t { vertex_feature_degree };
|
||||
enum edge_is_feature_t { edge_is_feature };
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ split_graph_into_polylines(const Graph& graph,
|
|||
#endif
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLRef
|
||||
\ingroup PkgBGLPartition
|
||||
splits into polylines the graph `g` at vertices of degree greater than 2
|
||||
and at vertices for which `is_terminal(v,graph)==true`.
|
||||
The polylines are reported using a visitor.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ if(OpenMesh_FOUND)
|
|||
include(UseOpenMesh)
|
||||
add_definitions(-DCGAL_USE_OPENMESH)
|
||||
else()
|
||||
message(STATUS "Examples that use OpenMesh will not be compiled.")
|
||||
message(STATUS "Tests that use OpenMesh will not be compiled.")
|
||||
endif()
|
||||
|
||||
# include for local package
|
||||
|
|
@ -93,8 +93,6 @@ create_single_source_cgal_program("test_graph_traits.cpp")
|
|||
|
||||
create_single_source_cgal_program("test_Properties.cpp")
|
||||
|
||||
create_single_source_cgal_program("test_wrl.cpp")
|
||||
|
||||
create_single_source_cgal_program(
|
||||
"bench_read_from_stream_vs_add_face_and_add_faces.cpp")
|
||||
|
||||
|
|
@ -102,10 +100,51 @@ create_single_source_cgal_program( "graph_traits_inheritance.cpp" )
|
|||
|
||||
if(OpenMesh_FOUND)
|
||||
target_link_libraries(test_clear PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_compile_definitions(test_clear PRIVATE -DCGAL_USE_OPENMESH)
|
||||
target_link_libraries(test_Euler_operations PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_compile_definitions(test_Euler_operations PRIVATE -DCGAL_USE_OPENMESH)
|
||||
target_link_libraries(test_Collapse_edge PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_compile_definitions(test_Collapse_edge PRIVATE -DCGAL_USE_OPENMESH)
|
||||
target_link_libraries(test_Face_filtered_graph PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_link_libraries(test_graph_traits PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_compile_definitions(test_Face_filtered_graph PRIVATE -DCGAL_USE_OPENMESH)
|
||||
target_link_libraries(test_graph_traits PRIVATE ${OPENMESH_LIBRARIES} )
|
||||
target_compile_definitions(test_graph_traits PRIVATE -DCGAL_USE_OPENMESH)
|
||||
target_link_libraries(test_Properties PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_compile_definitions(test_Properties PRIVATE -DCGAL_USE_OPENMESH)
|
||||
target_link_libraries(test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES})
|
||||
target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_OPENMESH)
|
||||
endif()
|
||||
|
||||
find_package(VTK QUIET COMPONENTS vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources)
|
||||
if (VTK_FOUND)
|
||||
if(VTK_USE_FILE)
|
||||
include(${VTK_USE_FILE})
|
||||
endif()
|
||||
|
||||
if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5)
|
||||
if(TARGET VTK::CommonCore)
|
||||
set(VTK_LIBRARIES VTK::CommonCore VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::FiltersCore VTK::FiltersSources)
|
||||
endif()
|
||||
|
||||
if(VTK_LIBRARIES)
|
||||
target_link_libraries(test_bgl_read_write PRIVATE ${VTK_LIBRARIES})
|
||||
target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_VTK)
|
||||
else()
|
||||
message(STATUS "Tests that use VTK will not be compiled.")
|
||||
endif()
|
||||
endif()
|
||||
endif() #VTK_FOUND
|
||||
|
||||
find_path(3MF_INCLUDE_DIR
|
||||
NAMES Model/COM/NMR_DLLInterfaces.h
|
||||
DOC "Path to lib3MF headers"
|
||||
)
|
||||
find_library(3MF_LIBRARIES NAMES 3MF DOC "Path to the lib3MF library")
|
||||
if(3MF_LIBRARIES AND 3MF_INCLUDE_DIR AND EXISTS "${3MF_INCLUDE_DIR}/Model/COM/NMR_DLLInterfaces.h")
|
||||
include_directories(${3MF_INCLUDE_DIR})
|
||||
create_single_source_cgal_program( test_3mf_to_sm.cpp )
|
||||
target_link_libraries(test_3mf_to_sm PRIVATE ${3MF_LIBRARIES})
|
||||
target_compile_definitions(test_3mf_to_sm PRIVATE -DCGAL_LINKED_WITH_3MF)
|
||||
else()
|
||||
message(STATUS "NOTICE : This program requires the lib3MF library, and will not be compiled.")
|
||||
endif()
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue