diff --git a/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt b/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt
index af4ba205b19..db529f4a991 100644
--- a/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt
+++ b/Alpha_shapes_3/doc/Alpha_shapes_3/Alpha_shapes_3.txt
@@ -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<<`. More information in the references of `Alpha_shape_3`.
+
\section AlphaShape3D_ConceptAndModels Concepts and Models
We currently do not specify concepts for the underlying triangulation
diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt
index 287b2662399..d9bc3e5f5be 100644
--- a/BGL/doc/BGL/PackageDescription.txt
+++ b/BGL/doc/BGL/PackageDescription.txt
@@ -588,9 +588,9 @@ model, the properties they support, and any possible caveats that a
user might encounter.
- \link BGLSMGT `boost::graph_traits< CGAL::Surface_mesh
>` \endlink
-- \link BGLPolyGT `boost::graph_traits< CGAL::Polyhedron_3 >` \endlink
+- \link BGLPolyGT `boost::graph_traits< CGAL::Polyhedron_3 >` \endlink
- \link BGLLCCGT `boost::graph_traits< CGAL::Linear_cell_complex_for_combinatorial_map<...> >` \endlink
-- \link BGLSeam_meshGT `boost::graph_traits< CGAL::Seam_mesh >` \endlink
+- \link BGLSeam_meshGT `boost::graph_traits< CGAL::Seam_mesh >` \endlink
- \link BGLT2GT `boost::graph_traits< CGAL::Triangulation_2 >` \endlink
- \link BGLArgtGT `boost::graph_traits< CGAL::Arrangement_2 >` \endlink
- \link BGLOMPAK `boost::graph_traits >` \endlink
diff --git a/BGL/include/CGAL/boost/graph/io.h b/BGL/include/CGAL/boost/graph/io.h
index f8e91ea49c2..9a74ebe93c9 100644
--- a/BGL/include/CGAL/boost/graph/io.h
+++ b/BGL/include/CGAL/boost/graph/io.h
@@ -24,7 +24,16 @@
#include
#include
#include
+#include
+#include
+#ifdef CGAL_USE_VTK
+#include
+#endif
#include
+#include
+#include
+#include
+#include
namespace CGAL {
/*!
@@ -36,6 +45,7 @@ namespace CGAL {
* If this parameter is omitted, an internal property map for
* `CGAL::vertex_point_t` should be available in `FaceGraph`\cgalParamEnd
* \cgalNamedParamsEnd
+ * \see \ref IOStreamWRL
*/
template
bool write_wrl(std::ostream& os,
@@ -124,6 +134,7 @@ bool write_wrl(std::ostream& os,
* \cgalNamedParamsEnd
\sa Overloads of this function for specific models of the concept `FaceGraph`.
+ \see \ref IOStreamOFF
*/
template
@@ -168,7 +179,7 @@ bool write_off(std::ostream& os,
\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`.
-
+ \see \ref IOStreamOFF
*/
template
bool write_off(const char* fname,
@@ -247,6 +258,7 @@ inline std::string next_non_comment(std::istream& is)
\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.
+ \see \ref IOStreamOFF
*/
template
@@ -322,6 +334,7 @@ bool read_off(std::istream& is,
\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.
+ \see \ref IOStreamOFF
*/
template
@@ -404,6 +417,177 @@ bool write_inp(std::ostream& os,
return write_inp(os, g, name, type, parameters::all_default());
}
+namespace GOCAD_internal{
+//Use CRTP to gain access to the protected members without getters/setters.
+template
+class GOCAD_builder : public CGAL::internal::IO::Generic_facegraph_builder >
+{
+ typedef GOCAD_builder Self;
+ typedef CGAL::internal::IO::Generic_facegraph_builder Base;
+ typedef typename Base::Point_3 Point_3;
+ typedef typename Base::Points_3 Points_3;
+ typedef typename Base::Facet Facet;
+ typedef typename Base::Surface Surface;
+public:
+ GOCAD_builder(std::istream& is_)
+ :Base(is_){}
+ void do_construct(Facegraph& graph)
+ {
+ typedef typename boost::graph_traits::vertex_descriptor
+ vertex_descriptor;
+
+ std::vector vertices(this->meshPoints.size());
+ for(std::size_t id = 0; id < this->meshPoints.size(); ++id)
+ {
+ vertices[id] = add_vertex( this->meshPoints[id], graph);
+ }
+ // graph.begin_surface( meshPoints.size(), mesh.size());
+ typedef typename Points_3::size_type size_type;
+
+ for(size_type i=0; i < this->mesh.size(); i++){
+ std::array face;
+ face[0] = vertices[this->mesh[i][0]];
+ face[1] = vertices[this->mesh[i][1]];
+ face[2] = vertices[this->mesh[i][2]];
+
+ CGAL::Euler::add_face(face, graph);
+ }
+ }
+
+ void
+ read(std::istream& input, Points_3& points, Surface& surface)
+ {
+ int offset = 0;
+ char c;
+ std::string s, tface("TFACE");
+ int i,j,k;
+ Point_3 p;
+ bool vertices_read = false;
+ while(input >> s){
+ if(s == tface){
+ break;
+ }
+ std::string::size_type idx;
+
+ if((idx = s.find("name")) != std::string::npos){
+ std::istringstream str(s.substr(idx+5));
+ str >> this->name;
+ }
+ if((idx = s.find("color")) != std::string::npos){
+ std::istringstream str(s.substr(idx+6));
+ str >> this->color;
+ }
+ }
+ std::getline(input, s);
+
+ while(input.get(c)){
+ if((c == 'V')||(c == 'P')){
+ input >> s >> i >> p;
+ if(! vertices_read){
+ vertices_read = true;
+ offset -= i; // Some files start with index 0 others with 1
+ }
+
+ points.push_back(p);
+
+ } else if(vertices_read && (c == 'T')){
+ input >> c >> c >> c >> i >> j >> k;
+ typename Base::Facet new_face(3);
+ new_face[0] = offset+i;
+ new_face[1] = offset+j;
+ new_face[2] = offset+k;
+ surface.push_back(new_face);
+ } else if(c == 'E'){
+ break;
+ }
+ std::getline(input, s);
+ }
+ }
+
+};
+}//end GOCAD_internal
+
+/*!
+ \ingroup PkgBGLIOFct
+ reads the graph `face_graph` from data in the TS format.
+ `name` and `color` will be filled according to the values contained in the file.
+
+ \pre The data must represent a 2-manifold
+ \attention The graph `face_graph` is not cleared, and the data from the stream are added.
+ \see \ref IOStreamGocad
+ */
+template
+bool
+read_gocad(FaceGraph& face_graph, std::istream& in, std::string& name, std::string& color)
+{
+ //typedef typename Polyhedron::HalfedgeDS HDS;
+ typedef typename boost::property_traits::type>::value_type Point_3;
+
+ GOCAD_internal::GOCAD_builder builder(in);
+ builder(face_graph);
+ name=builder.name;
+ color=builder.color;
+
+ return in.good() && face_graph.is_valid();
+}
+
+/*!
+ \ingroup PkgBGLIOFct
+ writes the graph `face_graph` in the TS format into `os`. `name` is the
+ mandatory name that will be assigned to `face_graph`in the file.
+ \see \ref IOStreamGocad
+ */
+template
+bool
+write_gocad(FaceGraph& face_graph, std::ostream& os, const std::string& name)
+{
+ os << "GOCAD TSurf 1\n"
+ "HEADER {\n"
+ "name:";
+ os << name << std::endl;
+ 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";
+
+ os.precision(16);
+ typedef typename boost::property_map::type VPMap;
+ VPMap vpmap = get(CGAL::vertex_point, face_graph);
+ std::map::vertex_descriptor, int> id_map;
+ {
+ typename boost::graph_traits::vertex_iterator it, end;
+ it = vertices(face_graph).begin();
+ end = vertices(face_graph).end();
+ int i=0;
+ for(; it != end; ++it){
+ id_map[*it] = i;
+ os << "VRTX " << i << " " << get(vpmap, *it) << "\n";
+ ++i;
+ }
+ }
+
+ {
+ typename boost::graph_traits::face_iterator it, end;
+ it = faces(face_graph).begin();
+ end = faces(face_graph).end();
+ for(; it != end; ++it){
+ os << "TRGL " << id_map[target(prev(halfedge(*it, face_graph), face_graph), face_graph)] << " "
+ << id_map[target(halfedge(*it, face_graph), face_graph)] << " "
+ << id_map[target(next(halfedge(*it, face_graph), face_graph), face_graph)] << "\n";
+ }
+ }
+
+ os << "END" << std::endl;
+
+ return true;
+}
+
namespace internal {
namespace write_vtp {
@@ -438,7 +622,7 @@ write_polys(std::ostream& os,
offsets.push_back(off);
for(vertex_descriptor v :
vertices_around_face(halfedge(*fit, mesh), mesh))
- connectivity_table.push_back(V[v]);
+ connectivity_table.push_back(get(V, v));
}
write_vector(os,connectivity_table);
write_vector(os,offsets);
@@ -492,7 +676,7 @@ write_polys_tag(std::ostream& os,
{
for(vertex_descriptor v :
vertices_around_face(halfedge(*fit, mesh), mesh))
- os << V[v] << " ";
+ os << get(V, v) << " ";
}
os << " \n";
}
@@ -617,7 +801,7 @@ write_polys_points(std::ostream& os,
} // end namespace CGAL::internal::write_vtp
} // end namespace CGAL::internal
-/*!\ingroup PkgBGLIOFct
+/*! \ingroup PkgBGLIOFct
*
* \brief writes a triangulated surface mesh in the `PolyData` XML format.
*
@@ -642,6 +826,7 @@ write_polys_points(std::ostream& os,
* `CGAL::vertex_index_t` must be available in `TriangleMesh`.
* \cgalParamEnd
* \cgalNamedParamsEnd
+ * \see \ref IOStreamVTK
*/
template
@@ -687,6 +872,348 @@ void write_vtp(std::ostream& os,
write_vtp(os, mesh, CGAL::parameters::all_default());
}
+#ifdef CGAL_USE_VTK
+namespace VTK_internal{
+
+template
+bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data,
+ FaceGraph& face_graph)
+{
+ typedef typename boost::property_map::type VPMap;
+ typedef typename boost::property_map_value::type Point_3;
+ typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor;
+
+ VPMap vpmap = get(CGAL::vertex_point, face_graph);
+
+ // get nb of points and cells
+ vtkIdType nb_points = poly_data->GetNumberOfPoints();
+ vtkIdType nb_cells = poly_data->GetNumberOfCells();
+ //extract points
+ std::vector vertex_map(nb_points);
+ for (vtkIdType i = 0; iGetPoint(i, coords);
+
+ vertex_descriptor v = add_vertex(face_graph);
+ put(vpmap, v, Point_3(coords[0], coords[1], coords[2]));
+ vertex_map[i]=v;
+ }
+
+ //extract cells
+ for (vtkIdType i = 0; iGetCellType(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 vr(nb_vertices);
+ for (vtkIdType k=0; kGetPointId(k);
+ vr[k]=vertex_map[id];
+ }
+
+ CGAL::Euler::add_face(vr, face_graph);
+ }
+ return true;
+}
+} //end VTK_internal
+
+template
+bool read_vtp(const char* filename, FaceGraph& face_graph)
+{
+ vtkSmartPointer data;
+ if(!CGAL::read_vtp_file(filename, data))
+ {
+ return false;
+ }
+ return VTK_internal::vtkPointSet_to_polygon_mesh(data, face_graph);
+}
+#endif //CGAL_USE_VTK
+
+#ifdef DOXYGEN_RUNNING
+/*! \ingroup PkgBGLIOFct
+ * \brief reads a PolyData in the VTP format into a triangulated surface mesh.
+ *
+ * \tparam FaceGraph a model of `FaceListGraph`.
+ *
+ * \param filename the path to the file that will be read.
+ * \param face_graph the output mesh.
+ *
+ * \pre \cgal needs to be configured with the VTK Libraries for this function to be available.
+ */
+template
+bool read_vtp(const char* filename, FaceGraph& face_graph);
+
+#endif
+
+/*!
+ \ingroup PkgBGLIOFct
+ writes the graph `tm` in the stream `out` in the STL format.
+ \pre The graph must contain only triangle faces.
+ \see \ref IOStreamSTL
+ */
+template
+std::ostream&
+write_STL(const TriangleMesh& tm, std::ostream& out)
+{
+ typedef typename boost::graph_traits::face_descriptor face_descriptor;
+ typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor;
+ typedef typename boost::property_map::const_type Vpm;
+ typedef typename boost::property_traits::reference Point_3_ref;
+ typedef typename boost::property_traits::value_type Point_3;
+ typedef typename Kernel_traits::Kernel::Vector_3 Vector_3;
+
+ Vpm vpm = get(boost::vertex_point, tm);
+
+ if (get_mode(out) == IO::BINARY)
+ {
+ out << "FileType: Binary ";
+ const boost::uint32_t N32 = static_cast(faces(tm).size());
+ out.write(reinterpret_cast(&N32), sizeof(N32));
+
+ for(face_descriptor f : faces(tm))
+ {
+ halfedge_descriptor h = halfedge(f, tm);
+ Point_3_ref p = get(vpm, target(h, tm));
+ Point_3_ref q = get(vpm, target(next(h, tm), tm));
+ Point_3_ref r = get(vpm, source(h, tm));
+
+ Vector_3 n = collinear(p,q,r) ? Vector_3(1,0,0):
+ unit_normal(p,q,r);
+
+ const float coords[12]={
+ static_cast(n.x()), static_cast(n.y()), static_cast(n.z()),
+ static_cast(p.x()), static_cast(p.y()), static_cast(p.z()),
+ static_cast(q.x()), static_cast(q.y()), static_cast(q.z()),
+ static_cast(r.x()), static_cast(r.y()), static_cast(r.z()) };
+
+ for (int i=0; i<12; ++i)
+ out.write(reinterpret_cast(&coords[i]), sizeof(coords[i]));
+ out << " ";
+ }
+ }
+ else
+ {
+ out << "solid\n";
+ for(face_descriptor f : faces(tm))
+ {
+ halfedge_descriptor h = halfedge(f, tm);
+ Point_3_ref p = get(vpm, target(h, tm));
+ Point_3_ref q = get(vpm, target(next(h, tm), tm));
+ Point_3_ref r = get(vpm, source(h, tm));
+
+ Vector_3 n = collinear(p,q,r) ? Vector_3(1,0,0):
+ unit_normal(p,q,r);
+ out << "facet normal " << n << "\nouter loop\n";
+ out << "vertex " << p << "\n";
+ out << "vertex " << q << "\n";
+ out << "vertex " << r << "\n";
+ out << "endloop\nendfacet\n";
+ }
+ out << "endsolid\n";
+ }
+ return out;
+}
+
+
+namespace STL_internal
+{
+//Use CRTP to gain access to the protected members without getters/setters.
+template
+class STL_builder : public CGAL::internal::IO::Generic_facegraph_builder >
+{
+ typedef STL_builder Self;
+ typedef CGAL::internal::IO::Generic_facegraph_builder Base;
+ typedef typename Base::Point_3 Point_3;
+ typedef typename Base::Points_3 Points_3;
+ typedef typename Base::Facet Facet;
+ typedef typename Base::Surface Surface;
+public:
+ STL_builder(std::istream& is_)
+ :Base(is_){}
+ void do_construct(Facegraph& graph)
+ {
+ typedef typename boost::graph_traits::vertex_descriptor
+ vertex_descriptor;
+
+ std::vector vertices(this->meshPoints.size());
+ for(std::size_t id = 0; id < this->meshPoints.size(); ++id)
+ {
+ vertices[id] = add_vertex( this->meshPoints[id], graph);
+ }
+ // graph.begin_surface( meshPoints.size(), mesh.size());
+ typedef typename Points_3::size_type size_type;
+
+ for(size_type i=0; i < this->mesh.size(); i++){
+ std::array face;
+ face[0] = vertices[this->mesh[i][0]];
+ face[1] = vertices[this->mesh[i][1]];
+ face[2] = vertices[this->mesh[i][2]];
+
+ CGAL::Euler::add_face(face, graph);
+ }
+ }
+
+ void
+ read(std::istream& input, Points_3& points, Surface& surface)
+ {
+ read_STL(input, points, surface);
+ }
+
+};
+} // end STL_internal
+
+/*!
+ \ingroup PkgBGLIOFct
+ reads the graph `tm` from the stream `in` in the STL format.
+ \returns `true` if the resulting mesh is valid.
+ \pre The data must represent a 2-manifold
+ \see \ref IOStreamSTL
+ */
+template
+bool
+read_STL(TriangleMesh& tm, std::istream& in)
+{
+ //typedef typename Polyhedron::HalfedgeDS HDS;
+ typedef typename boost::property_traits::type>::value_type Point_3;
+
+ STL_internal::STL_builder builder(in);
+ builder(tm);
+ bool ok = in.good() || in.eof();
+ ok &= tm.is_valid();
+ return ok;
+}
+
+
+
+
+
+
+
+namespace OBJ_internal
+{
+//Use CRTP to gain access to the protected members without getters/setters.
+template
+class OBJ_builder : public CGAL::internal::IO::Generic_facegraph_builder >
+{
+ typedef OBJ_builder Self;
+ typedef CGAL::internal::IO::Generic_facegraph_builder Base;
+ typedef typename Base::Point_3 Point_3;
+ typedef typename Base::Points_3 Points_3;
+ typedef typename Base::Facet Facet;
+ typedef typename Base::Surface Surface;
+public:
+ OBJ_builder(std::istream& is_)
+ :Base(is_){}
+ void do_construct(Facegraph& graph)
+ {
+ typedef typename boost::graph_traits::vertex_descriptor
+ vertex_descriptor;
+
+ std::vector vertices(this->meshPoints.size());
+ for(std::size_t id = 0; id < this->meshPoints.size(); ++id)
+ {
+ vertices[id] = add_vertex( this->meshPoints[id], graph);
+ }
+ typedef typename Points_3::size_type size_type;
+
+ for(size_type i=0; i < this->mesh.size(); i++){
+ std::vector face(this->mesh[i].size());
+ for(std::size_t j=0; j< face.size(); ++j)
+ face[j] = vertices[this->mesh[i][j]];
+
+ CGAL::Euler::add_face(face, graph);
+ }
+ }
+
+ void
+ read(std::istream& input, Points_3& points, Surface& surface)
+ {
+ read_OBJ(input, points, surface);
+ }
+
+};
+} // end STL_internal
+
+/*!
+ \ingroup PkgBGLIOFct
+ reads the graph `tm` from the stream `in` in the OBJ format.
+ \returns `true` if the resulting mesh is valid.
+ \pre The data must represent a 2-manifold
+ \see \ref IOStreamOBJ
+ */
+template
+bool
+read_OBJ(TriangleMesh& tm, std::istream& in)
+{
+ //typedef typename Polyhedron::HalfedgeDS HDS;
+ typedef typename boost::property_traits::type>::value_type Point_3;
+
+ OBJ_internal::OBJ_builder builder(in);
+ builder(tm);
+ bool ok = in.good() || in.eof();
+ ok &= tm.is_valid();
+ return ok;
+}
+
+/*!
+ \ingroup PkgBGLIOFct
+ writes the graph `face_graph` in the OBJ format.
+ \returns `true` if writing was successful.
+ \see \ref IOStreamOBJ
+ */
+template
+bool
+write_OBJ(const FaceGraph& face_graph, std::ostream& os)
+{
+ // writes M to `out' in the format provided by `writer'.
+ CGAL::File_writer_wavefront writer;
+ typedef typename boost::graph_traits::vertex_iterator VCI;
+ typedef typename boost::graph_traits::face_iterator FCI;
+ typedef typename boost::property_map::type VPmap;
+ VPmap map = get(CGAL::vertex_point, face_graph);
+ // Print header.
+ writer.write_header( os,
+ num_vertices(face_graph),
+ num_halfedges(face_graph),
+ num_faces(face_graph));
+
+ std::map::vertex_descriptor, std::size_t> index_map;
+ auto hint = index_map.begin();
+ std::size_t id = 0;
+
+ for( VCI vi = vertices(face_graph).begin(); vi != vertices(face_graph).end(); ++vi) {
+ writer.write_vertex( ::CGAL::to_double( get(map, *vi).x()),
+ ::CGAL::to_double( get(map, *vi).y()),
+ ::CGAL::to_double( get(map, *vi).z()));
+
+ hint = index_map.insert(hint, std::make_pair(*vi, id++));
+ }
+
+ writer.write_facet_header();
+ for( FCI fi = faces(face_graph).begin(); fi != faces(face_graph).end(); ++fi) {
+ CGAL::Halfedge_around_face_circulator hc(halfedge(*fi, face_graph), face_graph);
+ auto hc_end = hc;
+ std::size_t n = circulator_size( hc);
+ CGAL_assertion( n >= 3);
+ writer.write_facet_begin( n);
+ do {
+ writer.write_facet_vertex_index(index_map[target(*hc, face_graph)]);
+ ++hc;
+ } while( hc != hc_end);
+ writer.write_facet_end();
+ }
+ writer.write_footer();
+ return os.good();
+}
} // namespace CGAL
+
#endif // CGAL_BOOST_GRAPH_IO_H
diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt
index e7209f704d9..eb4e88f3be4 100644
--- a/BGL/test/BGL/CMakeLists.txt
+++ b/BGL/test/BGL/CMakeLists.txt
@@ -10,7 +10,8 @@ project( BGL_Tests )
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
-
+find_package(VTK QUIET COMPONENTS
+ vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources)
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
@@ -32,11 +33,10 @@ 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
# Creating entries for all .cpp/.C files with "main" routine
@@ -108,3 +108,19 @@ if(OpenMesh_FOUND)
target_link_libraries( test_Properties PRIVATE ${OPENMESH_LIBRARIES})
target_link_libraries( test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES})
endif()
+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)
+ add_definitions(-DCGAL_USE_VTK)
+ target_link_libraries( test_bgl_read_write PRIVATE ${VTK_LIBRARIES})
+ else()
+ message(STATUS "Tests that use VTK will not be compiled.")
+ endif()
+ endif()
+endif() #VTK_FOUND
diff --git a/BGL/test/BGL/test_Surface_mesh.cpp b/BGL/test/BGL/test_Surface_mesh.cpp
index 927f8e9c290..45490b84f79 100644
--- a/BGL/test/BGL/test_Surface_mesh.cpp
+++ b/BGL/test/BGL/test_Surface_mesh.cpp
@@ -7,7 +7,7 @@ BOOST_AUTO_TEST_CASE( edges_test )
edge_iterator eb, ee;
vertex_iterator vb, ve;
- Surface_fixture f;
+ Surface_fixtu re f;
boost::tie(eb, ee) = edges(f.m);
boost::tie(vb, ve) = vertices(f.m);
BOOST_CHECK(std::distance(eb, ee) == 7);
diff --git a/BGL/test/BGL/test_bgl_read_write.cpp b/BGL/test/BGL/test_bgl_read_write.cpp
index 894b772a610..9eb69c2cc06 100644
--- a/BGL/test/BGL/test_bgl_read_write.cpp
+++ b/BGL/test/BGL/test_bgl_read_write.cpp
@@ -7,6 +7,7 @@
#include
#include
+#include
#if defined(CGAL_USE_OPENMESH)
@@ -17,6 +18,7 @@
#endif
#include
+#include
#include
#include
@@ -47,17 +49,186 @@ void test_bgl_read_write(const char* filename)
CGAL::write_off(std::cout, sm);
}
+#ifdef CGAL_USE_VTK
+template
+bool test_bgl_vtp()
+{
+ Mesh fg;
+ CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
+ Point(2, 0, 1), Point(3, 0, 0), fg);
+
+ std::ofstream os("tetrahedron.vtp");
+ CGAL::write_vtp(os, fg);
+ if(!os)
+ {
+ std::cerr<<"vtp writing failed."<
+bool test_bgl_vtp()
+{
+ Polyhedron fg;
+ CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
+ Point(2, 0, 1), Point(3, 0, 0), fg);
+
+ typedef boost::property_map >::type VertexIdMap;
+ VertexIdMap vid = get(CGAL::dynamic_vertex_property_t(), fg);
+ std::size_t id = 0;
+ for(auto v : vertices(fg))
+ put(vid,v, id++);
+ std::ofstream os("tetrahedron.vtp");
+ CGAL::write_vtp(os, fg, CGAL::parameters::vertex_index_map(vid));
+ if(!os)
+ {
+ std::cerr<<"vtp writing failed."<
+bool test_gocad()
+{
+ FaceGraph fg;
+ CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
+ Point(2, 0, 1), Point(3, 0, 0), fg);
+ std::ostringstream out;
+ CGAL::write_gocad(fg, out, "tetrahedron");
+ if(out.fail())
+ {
+ std::cerr<<"Tetrahedron writing failed."<
+bool test_STL()
+{
+ FaceGraph fg;
+ CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0),
+ Point(2, 0, 1), Point(3, 0, 0), fg);
+ std::ostringstream out;
+ CGAL::write_STL(fg, out);
+ if(out.fail())
+ {
+ std::cerr<<"Tetrahedron writing failed."<1)?argv[1]:"data/prim.off";
-
+ //OFF
test_bgl_read_write(filename);
test_bgl_read_write(filename);
test_bgl_read_write(filename);
-
#ifdef CGAL_USE_OPENMESH
test_bgl_read_write(filename);
#endif
+ //GOCAD
+ if(!test_gocad())
+ return 1;
+ if(!test_gocad())
+ return 1;
+ if(!test_gocad())
+ return 1;
+ //STL
+ if(!test_STL())
+ return 1;
+ if(!test_STL())
+ return 1;
+ if(!test_STL())
+ return 1;
+ //VTP
+#ifdef CGAL_USE_VTK
+ if(!test_bgl_vtp())
+ return 1;
+ if(!test_bgl_vtp())
+ return 1;
+ if(!test_bgl_vtp())
+ return 1;
+#endif
return EXIT_SUCCESS;
}
diff --git a/Documentation/doc/resources/1.8.13/stylesheet.css b/Documentation/doc/resources/1.8.13/stylesheet.css
index 41df79908ef..708453e3c2f 100644
--- a/Documentation/doc/resources/1.8.13/stylesheet.css
+++ b/Documentation/doc/resources/1.8.13/stylesheet.css
@@ -150,11 +150,11 @@ a.elRef {
}
a.code, a.code:visited, a.line, a.line:visited {
- color: #4665A2;
+ color: #4665A2;
}
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
- color: #4665A2;
+ color: #4665A2;
}
/* @end */
@@ -896,6 +896,42 @@ table.doxtable th {
padding-top: 5px;
}
+table.iotable caption {
+ caption-side: top;
+}
+
+table.iotable {
+ border-collapse:collapse;
+ margin-top: 4px;
+ margin-bottom: 4px;
+}
+
+table.iotable td, table.iotable th {
+ border: 1px solid #2D4068;
+ padding: 3px 7px 2px;
+}
+
+table.iotable th a,table.iotable th a:visited {
+color: #FFFFFF;
+text-decoration: underline;
+}
+
+table.iotable th {
+ background-color: #374F7F;
+ color: #FFFFFF;
+ font-size: 110%;
+ padding-bottom: 4px;
+ padding-top: 5px;
+}
+
+
+table.iotable th a, table.iotable th a:visited {
+
+font-weight: bold;
+color: #FFFFFF;
+text-decoration: underline;
+}
+
table.fieldtable {
/*width: 100%;*/
margin-bottom: 10px;
@@ -909,6 +945,7 @@ table.fieldtable {
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15);
}
+
.fieldtable td, .fieldtable th {
padding: 3px 7px 2px;
}
diff --git a/Documentation/doc/resources/1.8.14/stylesheet.css b/Documentation/doc/resources/1.8.14/stylesheet.css
index 41df79908ef..f3f5c96b371 100644
--- a/Documentation/doc/resources/1.8.14/stylesheet.css
+++ b/Documentation/doc/resources/1.8.14/stylesheet.css
@@ -154,7 +154,7 @@ a.code, a.code:visited, a.line, a.line:visited {
}
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
- color: #4665A2;
+ color: #4665A2;
}
/* @end */
@@ -896,6 +896,43 @@ table.doxtable th {
padding-top: 5px;
}
+table.iotable caption {
+ caption-side: top;
+}
+
+table.iotable {
+ border-collapse:collapse;
+ margin-top: 4px;
+ margin-bottom: 4px;
+}
+
+table.iotable td, table.iotable th {
+ border: 1px solid #2D4068;
+ padding: 3px 7px 2px;
+}
+
+table.iotable th a,table.iotable th a:visited {
+color: #FFFFFF;
+text-decoration: underline;
+}
+
+table.iotable th {
+ background-color: #374F7F;
+ color: #FFFFFF;
+ font-size: 110%;
+ padding-bottom: 4px;
+ padding-top: 5px;
+}
+
+
+table.iotable th a, table.iotable th a:visited {
+
+font-weight: bold;
+color: #FFFFFF;
+text-decoration: underline;
+}
+
+
table.fieldtable {
/*width: 100%;*/
margin-bottom: 10px;
diff --git a/Documentation/doc/resources/1.8.4/stylesheet.css b/Documentation/doc/resources/1.8.4/stylesheet.css
index 688b81b2557..3ce3bc1e39e 100644
--- a/Documentation/doc/resources/1.8.4/stylesheet.css
+++ b/Documentation/doc/resources/1.8.4/stylesheet.css
@@ -762,6 +762,43 @@ table.doxtable th {
padding-top: 5px;
}
+table.iotable caption {
+ caption-side: top;
+}
+
+table.iotable {
+ border-collapse:collapse;
+ margin-top: 4px;
+ margin-bottom: 4px;
+}
+
+table.iotable td, table.iotable th {
+ border: 1px solid #2D4068;
+ padding: 3px 7px 2px;
+}
+
+table.iotable th a,table.iotable th a:visited {
+color: #FFFFFF;
+text-decoration: underline;
+}
+
+table.iotable th {
+ background-color: #374F7F;
+ color: #FFFFFF;
+ font-size: 110%;
+ padding-bottom: 4px;
+ padding-top: 5px;
+}
+
+
+table.iotable th a, table.iotable th a:visited {
+
+font-weight: bold;
+color: #FFFFFF;
+text-decoration: underline;
+}
+
+
table.fieldtable {
width: 100%;
margin-bottom: 10px;
diff --git a/Inventor/include/CGAL/IO/Alpha_shape_3_VRML_2_ostream.h b/Inventor/include/CGAL/IO/Alpha_shape_3_VRML_2_ostream.h
index 0e68677a9df..bd57ad39305 100644
--- a/Inventor/include/CGAL/IO/Alpha_shape_3_VRML_2_ostream.h
+++ b/Inventor/include/CGAL/IO/Alpha_shape_3_VRML_2_ostream.h
@@ -15,81 +15,12 @@
#ifndef CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
#define CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
+#include
-#include
-#include
-
-#ifdef CGAL_ALPHA_SHAPE_3_H
-namespace CGAL {
-
-template
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- Alpha_shape_3 &as)
-{
- // Finite vertices coordinates.
- Alpha_shape_3::Alpha_shape_vertices_iterator Vlist_it,
- Vlist_begin = as.alpha_shape_vertices_begin(),
- Vlist_end = as.alpha_shape_vertices_end();
-
- std::map::Vertex_handle, int> V;
- int number_of_vertex = 0;
- for( Vlist_it = Vlist_begin; Vlist_it != Vlist_end; Vlist_it++) {
- V[*Vlist_it] = number_of_vertex++;
- }
-
- typename Alpha_shape_3::Alpha_shape_facets_iterator Flist_it,
- Flist_begin = as.alpha_shape_facets_begin(),
- Flist_end = as.alpha_shape_facets_end();
-
- std::map::Facet, int> F;
- int number_of_facets = 0;
- for( Flist_it = Flist_begin; Flist_it != Flist_end; Flist_it++) {
- F[*Flist_it] = number_of_facets++;
- }
-
- const char *Indent = " ";
- os << " Group {\n"
- " children [\n"
- " Shape {\n"
- " appearance USE A1\n"
- " geometry\n"
- " IndexedFaceSet {\n"
- " coord Coordinate {\n"
- " point [ \n"
- << Indent << " ";
- for( Vlist_it = Vlist_begin; Vlist_it != Vlist_end; Vlist_it++) {
- os << CGAL::to_double((*Vlist_it)->point().x()) << " ";
- os << CGAL::to_double((*Vlist_it)->point().y()) << " ";
- os << CGAL::to_double((*Vlist_it)->point().z()) << ",\n" << Indent << " ";
- }
- os << "\n ]\n"
- " } # coord\n"
- " solid FALSE\n"
- << Indent << "coordIndex [\n";
- // Finite facets indices.
- for( Flist_it = Flist_begin; Flist_it != Flist_end; Flist_it++){
- os << Indent << " ";
- for (int i=0; i<4; i++)
- if (i != (*Flist_it).second){
- os << V[(*Flist_it).first->vertex(i)];
- os << ", ";
- }
- if (Flist_it != Flist_end)
- os << "-1,\n";
- else
- os << "-1 \n";
- }
- os << Indent << "]\n";
- " } #IndexedFaceSet\n"
- " } #Shape\n"
- " ] #children\n"
- " } #Group\n";
-
- return os;
-}
-
-} //namespace CGAL
-#endif // CGAL_ALPHA_SHAPE_3_H
+#define CGAL_DEPRECATED_HEADER ""
+#define CGAL_REPLACEMENT_HEADER ""
+#include
+#include
+#include
#endif CGAL_ALPHA_SHAPE_3_VRML_2_OSTREAM_H
diff --git a/Inventor/include/CGAL/IO/Inventor_ostream.h b/Inventor/include/CGAL/IO/Inventor_ostream.h
index 9025c68ff97..ba64a2c4ca7 100644
--- a/Inventor/include/CGAL/IO/Inventor_ostream.h
+++ b/Inventor/include/CGAL/IO/Inventor_ostream.h
@@ -19,108 +19,12 @@
#ifndef CGAL_IO_INVENTOR_OSTREAM_H
#define CGAL_IO_INVENTOR_OSTREAM_H
-#include
-#include
+#include
-// OpenInventor and VRML 1.0 are quite similar formats, so
-// output operators could be shared if they use the following
-// base class, which is common for both output streams.
-
-namespace CGAL {
-
-class Inventor_ostream_base {
-private:
- std::ostream* m_os;
-public:
- Inventor_ostream_base() : m_os(0) {}
- Inventor_ostream_base(std::ostream& o) : m_os(&o) {}
- ~Inventor_ostream_base() { close(); }
- void open(std::ostream& o) { m_os = &o; }
- void close() {
- if ( m_os)
- os() << std::endl;
- m_os = 0;
- }
- explicit operator bool ()
- {
- return m_os && !m_os->fail();
- }
-
- std::ostream& os() {
- // The behaviour if m_os == 0 could be changed to return
- // cerr or a file handle to /dev/null. The latter one would
- // mimick the behaviour that one can still use a stream with
- // an invalid stream, but without producing any output.
- CGAL_assertion( m_os != 0 );
- return *m_os;
- }
-};
-
-
-class Inventor_ostream : public Inventor_ostream_base
-{
-public:
- Inventor_ostream() {}
- Inventor_ostream(std::ostream& o) : Inventor_ostream_base(o) {
- header();
- }
- void open(std::ostream& o) {
- Inventor_ostream_base::open(o);
- header();
- }
-private:
- void header() {
- os() << "#Inventor V2.0 ascii" << std::endl;
- os() << "# File written with the help of the CGAL Library"
- << std::endl;
- }
-};
-
-} //namespace CGAL
-#endif // CGAL_IO_INVENTOR_OSTREAM_H
-
-
-#ifdef CGAL_TETRAHEDRON_3_H
-#ifndef CGAL_INVENTOR_TETRAHEDRON_3
-#define CGAL_INVENTOR_TETRAHEDRON_3
-
-namespace CGAL {
-
-template
-Inventor_ostream&
-operator<<(Inventor_ostream& os,
- const Tetrahedron_3 &t)
-{
- const char *Indent = " ";
- os.os() << "\n Separator {";
- os.os() << "\n Coordinate3 { \n"
- << Indent << "point [\n"
- << Indent << " "
- << CGAL::to_double(t[0].x()) << " "
- << CGAL::to_double(t[0].y()) << " "
- << CGAL::to_double(t[0].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[1].x()) << " "
- << CGAL::to_double(t[1].y()) << " "
- << CGAL::to_double(t[1].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[2].x()) << " "
- << CGAL::to_double(t[2].y()) << " "
- << CGAL::to_double(t[2].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[3].x()) << " "
- << CGAL::to_double(t[3].y()) << " "
- << CGAL::to_double(t[3].z()) << " ]"
- << "\n } #Coordinate3" ;
- os.os() << "\n IndexedFaceSet {"
- << Indent << "coordIndex [ 0,1,2,-1, 1,3,2,-1,\n"
- << Indent << " 0,2,3,-1, 0,3,1,-1 ]\n"
- << "\n } #IndexedFaceSet"
- << "\n } #Separator\n";
- return os;
-}
-
-} //namespace CGAL
+#define CGAL_DEPRECATED_HEADER ""
+#define CGAL_REPLACEMENT_HEADER ""
+#include
+#include
+#include
#endif // CGAL_INVENTOR_TETRAHEDRON_3
-#endif // CGAL_TETRAHEDRON_3_H
diff --git a/Inventor/include/CGAL/IO/VRML_1_ostream.h b/Inventor/include/CGAL/IO/VRML_1_ostream.h
index 073ab4c61bf..badbc9abf4b 100644
--- a/Inventor/include/CGAL/IO/VRML_1_ostream.h
+++ b/Inventor/include/CGAL/IO/VRML_1_ostream.h
@@ -19,82 +19,12 @@
#ifndef CGAL_IO_VRML_1_OSTREAM_H
#define CGAL_IO_VRML_1_OSTREAM_H
-#include
-#include
+#include
-// Declare the common base class for OpenInventor and VRML 1.0 format.
-#include
-
-// OpenInventor and VRML 1.0 are quite similar formats, so
-// output operators could be shared if they use the common
-// base class Inventor_ostream_base, which is common for
-// both output streams.
-
-namespace CGAL {
-
-class VRML_1_ostream : public Inventor_ostream_base {
-public:
- VRML_1_ostream() {}
- VRML_1_ostream(std::ostream& o) : Inventor_ostream_base(o) {
- header();
- }
- void open(std::ostream& o) {
- Inventor_ostream_base::open(o);
- header();
- }
-private:
- void header() {
- os() << "#VRML V1.0 ascii" << std::endl;
- os() << "# File written with the help of the CGAL Library"
- << std::endl;
- }
-};
-
-} //namespace CGAL
-
-#endif // CGAL_IO_VRML_1_OSTREAM_H
-
-#ifdef CGAL_TETRAHEDRON_3_H
-#ifndef CGAL_IO_VRML_1_TETRAHEDRON_3
-#define CGAL_IO_VRML_1_TETRAHEDRON_3
-
-namespace CGAL {
-
-template
-VRML_1_ostream&
-operator<<(VRML_1_ostream& os,
- const Tetrahedron_3 &t)
-{
- const char *Indent = " ";
- os.os() << "\n Separator {";
- os.os() << "\n Coordinate3 { \n"
- << Indent << "point [\n"
- << Indent << " "
- << CGAL::to_double(t[0].x()) << " "
- << CGAL::to_double(t[0].y()) << " "
- << CGAL::to_double(t[0].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[1].x()) << " "
- << CGAL::to_double(t[1].y()) << " "
- << CGAL::to_double(t[1].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[2].x()) << " "
- << CGAL::to_double(t[2].y()) << " "
- << CGAL::to_double(t[2].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[3].x()) << " "
- << CGAL::to_double(t[3].y()) << " "
- << CGAL::to_double(t[3].z()) << " ]"
- << "\n } #Coordinate3" ;
- os.os() << "\n IndexedFaceSet {"
- << Indent << "coordIndex [ 0,1,2,-1, 1,3,2,-1,\n"
- << Indent << " 0,2,3,-1, 0,3,1,-1 ]\n"
- << "\n } #IndexedFaceSet"
- << "\n } #Separator\n";
- return os;
-}
-
-} //namespace CGAL
+#define CGAL_DEPRECATED_HEADER ""
+#define CGAL_REPLACEMENT_HEADER ""
+#include
+#include "
+#include
#endif // CGAL_IO_VRML_1_TETRAHEDRON_3
-#endif // CGAL_TETRAHEDRON_3_H
diff --git a/Inventor/include/CGAL/IO/VRML_2_ostream.h b/Inventor/include/CGAL/IO/VRML_2_ostream.h
index f804912ae41..dfb055bc05e 100644
--- a/Inventor/include/CGAL/IO/VRML_2_ostream.h
+++ b/Inventor/include/CGAL/IO/VRML_2_ostream.h
@@ -18,295 +18,12 @@
#ifndef CGAL_IO_VRML_2_OSTREAM_H
#define CGAL_IO_VRML_2_OSTREAM_H
+#include
-#include
-#include
-
-namespace CGAL {
-
-class VRML_2_ostream {
-public:
- VRML_2_ostream() : m_os(0) {}
- VRML_2_ostream(std::ostream& o) : m_os(&o) { header();}
- ~VRML_2_ostream() { close(); }
- void open(std::ostream& o) { m_os = &o; header(); }
- void close() {
- if ( m_os)
- footer();
- m_os = 0;
- }
- explicit operator bool () {
- return m_os && !m_os->fail();
- }
- std::ostream& os() {
- // The behaviour if m_os == 0 could be changed to return
- // cerr or a file handle to /dev/null. The latter one would
- // mimick the behaviour that one can still use a stream with
- // an invalid stream, but without producing any output.
- CGAL_assertion( m_os != 0 );
- return *m_os;
- }
-private:
- void header() {
- os() << "#VRML V2.0 utf8\n"
- "# File written with the help of the CGAL Library\n"
- "#-- Begin of file header\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"
- " geometry nullptr\n"
- " }\n"
- " #-- End of file header" << std::endl;
- }
- void footer() {
- os() << " #-- Begin of file footer\n"
- " ]\n"
- "}\n"
- "#-- End of file footer" << std::endl;
- }
- std::ostream* m_os;
-};
-
-inline
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- const char* s)
-{
- os.os() << s;
- return os;
-}
-
-inline
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- const double& d)
-{
- os.os() << d;
- return os;
-}
-
-} //namespace CGAL
-
-#endif // CGAL_IO_VRML_2_OSTREAM_H
-
-#ifdef CGAL_TETRAHEDRON_3_H
-#ifndef CGAL_IO_VRML_2_TETRAHEDRON_3
-#define CGAL_IO_VRML_2_TETRAHEDRON_3
-
-namespace CGAL {
-
-template
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- const Tetrahedron_3 &t)
-{
- const char *Indent = " ";
- os << " Group {\n"
- " children [\n"
- " Shape {\n"
- " appearance\n"
- " Appearance {\n"
- " material USE Material\n"
- " } #Appearance\n"
- " geometry\n"
- " IndexedFaceSet {\n"
- " coord Coordinate {\n"
- " point [ \n"
- << Indent << " "
- << CGAL::to_double(t[0].x()) << " "
- << CGAL::to_double(t[0].y()) << " "
- << CGAL::to_double(t[0].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[1].x()) << " "
- << CGAL::to_double(t[1].y()) << " "
- << CGAL::to_double(t[1].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[2].x()) << " "
- << CGAL::to_double(t[2].y()) << " "
- << CGAL::to_double(t[2].z()) << " ,\n"
- << Indent << " "
- << CGAL::to_double(t[3].x()) << " "
- << CGAL::to_double(t[3].y()) << " "
- << CGAL::to_double(t[3].z()) <<
- "\n ]\n"
- " }\n"
- " solid FALSE\n"
- << Indent << "coordIndex [ 0,1,2,-1, 1,3,2,-1,\n"
- << Indent << " 0,2,3,-1, 0,3,1,-1 ]\n"
- " } #IndexedFaceSet\n"
- " } #Shape\n"
- " ] #children\n"
- " } #Group\n";
- return os;
-}
-
-} //namespace CGAL
-
-#endif // CGAL_IO_VRML_2_TETRAHEDRON_3
-#endif // CGAL_TETRAHEDRON_3_H
-
-#ifdef CGAL_POINT_3_H
-#ifndef CGAL_IO_VRML_2_POINT_3
-#define CGAL_IO_VRML_2_POINT_3
-
-namespace CGAL {
-
-template
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- const Point_3 &p)
-{
- const char *Indent = " ";
- os << " Group {\n"
- " children [\n"
- " Shape {\n"
- " appearance USE A1\n"
- " geometry\n"
- " PointSet {\n"
- " coord Coordinate {\n"
- " point [ ";
- os << CGAL::to_double(p.x()) << " " << CGAL::to_double(p.y())
- << " " << CGAL::to_double(p.z()) << " ]\n";
- os << Indent << "}\n";
- os << Indent << "} # PointSet\n";
- os << " } #Shape\n"
- " ] #children\n"
- " } #Group\n";
- return os;
-}
-
-} //namespace CGAL
-
-#endif // CGAL_IO_VRML_2_POINT_3
-#endif // CGAL_POINT_3_H
-
-
-
-#ifdef CGAL_TRIANGLE_3_H
-#ifndef CGAL_IO_VRML_2_TRIANGLE_3
-#define CGAL_IO_VRML_2_TRIANGLE_3
-
-namespace CGAL {
-
-template
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- const Triangle_3 &t)
-{
- const char *Indent = " ";
- os << " Group {\n"
- " children [\n"
- " Shape {\n"
- " appearance USE A1\n"
- " geometry\n"
- " IndexedLineSet {\n"
- " coord Coordinate {\n"
- " point [ \n";
- os << Indent ;
- os << CGAL::to_double(t[0].x()) << " " << CGAL::to_double(t[0].y())
- << " " << CGAL::to_double(t[0].z()) << ",\n";
- os << Indent;
- os << CGAL::to_double(t[1].x()) << " " << CGAL::to_double(t[1].y())
- << " " << CGAL::to_double(t[1].z()) << ",\n";
- os << Indent;
- os << CGAL::to_double(t[2].x()) << " " << CGAL::to_double(t[2].y())
- << " " << CGAL::to_double(t[2].z()) << " ]\n";
- os << Indent << "}\n" << Indent << "coordIndex [ 0 1, 1 2, 2 0 -1 ]\n";
- os << Indent << "} # IndexedLineSet\n";
- os << " } #Shape\n"
- " ] #children\n"
- " } #Group\n";
- return os;
-}
-
-} //namespace CGAL
-
-#endif // CGAL_IO_VRML_2_TRIANGLE_3
-#endif // CGAL_TRIANGLE_3_H
-
-
-#ifdef CGAL_SEGMENT_3_H
-#ifndef CGAL_IO_VRML_2_SEGMENT_3
-#define CGAL_IO_VRML_2_SEGMENT_3
-
-namespace CGAL {
-
-template
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- const Segment_3 &s)
-{
- const char *Indent = " ";
- os << " Group {\n"
- " children [\n"
- " Shape {\n"
- " appearance USE A1\n"
- " geometry\n"
- " IndexedLineSet {\n"
- " coord Coordinate {\n"
- " point [ \n";
- os << Indent << CGAL::to_double(s.source().x());
- os << " " << CGAL::to_double(s.source().y())
- << " " << CGAL::to_double(s.source().z()) << ",\n";
- os << Indent;
- os << CGAL::to_double(s.target().x())
- << " " << CGAL::to_double(s.target().y())
- << " " << CGAL::to_double(s.target().z()) << " ]\n";
- os << Indent << "}\n" << Indent << "coordIndex [ 0 1 -1 ]\n";
- os << Indent << "} # IndexedLineSet\n";
- os << " } #Shape\n"
- " ] #children\n"
- " } #Group\n";
-
- return os;
-}
-
-} //namespace CGAL
+#define CGAL_DEPRECATED_HEADER ""
+#define CGAL_REPLACEMENT_HEADER ""
+#include
+#include
+#include
#endif // CGAL_IO_VRML_2_SEGMENT_3
-#endif // CGAL_SEGMENT_3_H
-
-#ifdef CGAL_SPHERE_3_H
-#ifndef CGAL_IO_VRML_2_SPHERE_3
-#define CGAL_IO_VRML_2_SPHERE_3
-
-namespace CGAL {
-
-template
-VRML_2_ostream&
-operator<<(VRML_2_ostream& os,
- const Sphere_3 &s)
-{
- os << " Group {\n"
- " children [\n"
- " Transform {\n"
- " translation ";
- os << CGAL::to_double(s.center().x()) << " "
- << CGAL::to_double(s.center().y()) << " "
- << CGAL::to_double(s.center().z()) << "\n";
- os << " children Shape {\n"
- " appearance USE A1\n"
- " geometry\n"
- " Sphere { "
- "radius ";
- os << std::sqrt(CGAL::to_double(s.squared_radius())) <<" }\n";
- os << " } #children Shape\n"
- " } # Transform\n"
- " ] #children\n"
- " } #Group\n";
-
- return os;
-}
-
-} //namespace CGAL
-
-#endif // CGAL_IO_VRML_2_SEGMENT_3
-#endif // CGAL_SPHERE_3_H
diff --git a/Mesh_2/doc/Mesh_2/Mesh_2.txt b/Mesh_2/doc/Mesh_2/Mesh_2.txt
index 64012f69e97..3709fa6a895 100644
--- a/Mesh_2/doc/Mesh_2/Mesh_2.txt
+++ b/Mesh_2/doc/Mesh_2/Mesh_2.txt
@@ -327,7 +327,9 @@ in the Reference Manual.
\cgalExample{Mesh_2/mesh_optimization.cpp}
-
+\section secMesh_2_IO Input/Output
+It is possible to export the result of a meshing in VTU, using the function `write_vtu()`.
+For more information about this format, see \ref IOStreamVTK.
*/
} /* namespace CGAL */
diff --git a/Mesh_3/doc/Mesh_3/CGAL/IO/File_avizo.h b/Mesh_3/doc/Mesh_3/CGAL/IO/File_avizo.h
new file mode 100644
index 00000000000..94c1c3684a6
--- /dev/null
+++ b/Mesh_3/doc/Mesh_3/CGAL/IO/File_avizo.h
@@ -0,0 +1,13 @@
+namespace CGAL{
+/**
+ * \ingroup PkgMesh3IOFunctions
+ * @brief outputs mesh to avizo format
+ * @param os the stream
+ * @param c3t3 the mesh complex
+ * \see \ref IOStreamAvizo
+ */
+template
+void
+output_to_avizo(std::ostream& os,
+ const C3T3& c3t3);
+}
diff --git a/Mesh_3/doc/Mesh_3/CGAL/IO/File_tetgen.h b/Mesh_3/doc/Mesh_3/CGAL/IO/File_tetgen.h
new file mode 100644
index 00000000000..b142b41f0c7
--- /dev/null
+++ b/Mesh_3/doc/Mesh_3/CGAL/IO/File_tetgen.h
@@ -0,0 +1,19 @@
+namespace CGAL{
+/**
+ * \ingroup PkgMesh3IOFunctions
+ * @brief outputs a mesh complex to tetgen format
+ * @param filename the path to the output file
+ * @param c3t3 the mesh
+ * @param rebind if true, labels of cells are rebinded into [1..nb_of_labels]
+ * @param show_patches if true, patches are labeled with different labels than
+ * cells. If false, each surface facet is written twice, using label of
+ * each adjacent cell.
+ * \see \ref IOStreamTetgen
+ */
+template
+void
+output_to_tetgen(std::string filename,
+ const C3T3& c3t3,
+ bool rebind = false,
+ bool show_patches = false);
+}
diff --git a/Mesh_3/doc/Mesh_3/Mesh_3.txt b/Mesh_3/doc/Mesh_3/Mesh_3.txt
index 269b5d18e28..666e8839787 100644
--- a/Mesh_3/doc/Mesh_3/Mesh_3.txt
+++ b/Mesh_3/doc/Mesh_3/Mesh_3.txt
@@ -547,6 +547,15 @@ To control the number of threads used, the user may use the tbb::task_scheduler_
See the TBB documentation
for more details.
+\section Mesh_3_section_io Input/Output
+Several formats are supported for writing a mesh:
+ - VTU, with `CGAL::output_to_vtu()`
+ - Avizo with `CGAL::output_to_avizo()`
+ - Medit with `CGAL::output_to_medit()`
+ - Tetgen with `CGAL::output_to_tetgen()`
+
+
+
\section Mesh_3_section_examples Examples
\subsection Mesh_33DDomainsBoundedbyIsosurfaces 3D Domains Bounded by Isosurfaces
diff --git a/Mesh_3/include/CGAL/IO/File_avizo.h b/Mesh_3/include/CGAL/IO/File_avizo.h
index 6d6f20b59fb..704200b069b 100644
--- a/Mesh_3/include/CGAL/IO/File_avizo.h
+++ b/Mesh_3/include/CGAL/IO/File_avizo.h
@@ -146,6 +146,7 @@ output_to_avizo(std::ostream& os,
* @brief outputs mesh to avizo format
* @param os the stream
* @param c3t3 the mesh
+ * \see \ref IOStreamAvizo
*/
template
void
diff --git a/Mesh_3/include/CGAL/IO/File_maya.h b/Mesh_3/include/CGAL/IO/File_maya.h
index dfb7398d498..a0730fa7ee1 100644
--- a/Mesh_3/include/CGAL/IO/File_maya.h
+++ b/Mesh_3/include/CGAL/IO/File_maya.h
@@ -25,11 +25,6 @@
#include
namespace CGAL {
-
-//-------------------------------------------------------
-// IO functions
-//-------------------------------------------------------
-
template
void
output_to_maya(std::ostream& os,
diff --git a/Mesh_3/include/CGAL/IO/File_medit.h b/Mesh_3/include/CGAL/IO/File_medit.h
index acb658a759b..41d6bb991e2 100644
--- a/Mesh_3/include/CGAL/IO/File_medit.h
+++ b/Mesh_3/include/CGAL/IO/File_medit.h
@@ -869,6 +869,7 @@ output_to_medit(std::ostream& os,
* @param show_patches if true, patches are labeled with different labels than
* cells. If false, each surface facet is written twice, using label of
* each adjacent cell.
+ * \see \ref IOStreamMedit
*/
template
void
diff --git a/Mesh_3/include/CGAL/IO/File_tetgen.h b/Mesh_3/include/CGAL/IO/File_tetgen.h
index 9feaa354ef9..39e13ab7768 100644
--- a/Mesh_3/include/CGAL/IO/File_tetgen.h
+++ b/Mesh_3/include/CGAL/IO/File_tetgen.h
@@ -128,7 +128,7 @@ output_to_tetgen(std::string filename,
// Elements
//-------------------------------------------------------
- std::string elem_filename = filename + ".elem";
+ std::string elem_filename = filename + ".ele";
std::ofstream elem_stream(elem_filename.c_str());
elem_stream << std::setprecision(17);
@@ -189,15 +189,6 @@ output_to_tetgen(std::string filename,
-/**
- * @brief outputs mesh to tetgen format
- * @param os the stream
- * @param c3t3 the mesh
- * @param rebind if true, labels of cells are rebinded into [1..nb_of_labels]
- * @param show_patches if true, patches are labeled with different labels than
- * cells. If false, each surface facet is written twice, using label of
- * each adjacent cell.
- */
template
void
output_to_tetgen(std::string filename,
diff --git a/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt b/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt
index 275ecf450fb..205dc7b8114 100644
--- a/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt
+++ b/Point_set_processing_3/doc/Point_set_processing_3/Point_set_processing_3.txt
@@ -240,6 +240,8 @@ container.
\cgalExample{Point_set_processing_3/read_las_example.cpp}
+\sa \ref IOstreamPointSetIO
+
\section Point_set_processing_3Spacing Average Spacing
Function `compute_average_spacing()` computes the average
diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt
index 01a48c330b8..af03a6596d7 100644
--- a/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt
+++ b/Polyhedron/demo/Polyhedron/Plugins/IO/CMakeLists.txt
@@ -44,7 +44,7 @@ if (VTK_FOUND)
polyhedron_demo_plugin(vtk_plugin VTK_io_plugin KEYWORDS IO Mesh_3)
target_link_libraries(vtk_plugin PUBLIC scene_surface_mesh_item scene_polylines_item scene_c3t3_item scene_points_with_normal_item
${VTK_LIBRARIES})
-
+ target_compile_definitions(vtk_plugin PRIVATE -DCGAL_USE_VTK)
else()
message(STATUS "NOTICE : the vtk IO plugin needs VTK libraries and will not be compiled.")
endif()
diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp
index 9aca2423ca0..2612aef2a89 100644
--- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp
@@ -3,12 +3,12 @@
#include "Kernel_type.h"
#include "Scene.h"
#include "SMesh_type.h"
-#include
#include
#include
#include
#include
#include
+#include
#include
#include
diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp
index 66d08020a49..d1d879bd5b4 100644
--- a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp
@@ -8,8 +8,8 @@
#include
#include
-#include
-#include
+#include
+#include
#include
diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp
index 1c340b8f2ad..8f2a66c5588 100644
--- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp
@@ -39,6 +39,7 @@
#include
#include
#include
+#include
#include
#include
@@ -79,98 +80,6 @@ CGAL::vertex_point_t>::type>::value_type Point;
namespace CGAL{
- class ErrorObserverVtk : public vtkCommand
- {
- public:
- ErrorObserverVtk() :
- Error(false),
- Warning(false),
- ErrorMessage(""),
- WarningMessage("") {}
- static ErrorObserverVtk *New() { return new ErrorObserverVtk; }
-
- bool GetError() const { return this->Error; }
- bool GetWarning() const { return this->Warning; }
- std::string GetErrorMessage() { return ErrorMessage; }
- std::string GetWarningMessage() { return WarningMessage; }
-
- void Clear()
- {
- this->Error = false;
- this->Warning = false;
- this->ErrorMessage = "";
- this->WarningMessage = "";
- }
- virtual void Execute(vtkObject *vtkNotUsed(caller),
- unsigned long event,
- void *calldata)
- {
- switch (event)
- {
- case vtkCommand::ErrorEvent:
- ErrorMessage = static_cast(calldata);
- this->Error = true;
- break;
- case vtkCommand::WarningEvent:
- WarningMessage = static_cast(calldata);
- this->Warning = true;
- break;
- }
- }
-
- private:
- bool Error;
- bool Warning;
- std::string ErrorMessage;
- std::string WarningMessage;
- };
-
- template
- bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data,
- TM& tmesh)
- {
- typedef typename boost::property_map::type VPMap;
- typedef typename boost::property_map_value::type Point_3;
- typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor;
-
- VPMap vpmap = get(CGAL::vertex_point, tmesh);
-
- // get nb of points and cells
- vtkIdType nb_points = poly_data->GetNumberOfPoints();
- vtkIdType nb_cells = poly_data->GetNumberOfCells();
-
- //extract points
- std::vector vertex_map(nb_points);
- for (vtkIdType i = 0; iGetPoint(i, coords);
-
- vertex_descriptor v = add_vertex(tmesh);
- put(vpmap, v, Point_3(coords[0], coords[1], coords[2]));
- vertex_map[i]=v;
- }
-
- //extract cells
- for (vtkIdType i = 0; iGetCellType(i) != 5
- && poly_data->GetCellType(i) != 7
- && poly_data->GetCellType(i) != 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 vr(nb_vertices);
- for (vtkIdType k=0; kGetPointId(k)];
-
- CGAL::Euler::add_face(vr, tmesh);
- }
- return true;
- }
template
void extract_segments_from_vtkPointSet(vtkPointSet* poly_data,
@@ -354,19 +263,6 @@ public:
bool canLoad(QFileInfo) const { return true; }
- template
- vtkSmartPointer
- read_vtk_file(const std::string& input_filename,
- vtkSmartPointer errorObserver)
- {
- vtkSmartPointer reader = vtkSmartPointer::New();
- reader->AddObserver(vtkCommand::ErrorEvent, errorObserver);
- reader->AddObserver(vtkCommand::WarningEvent, errorObserver);
- reader->SetFileName(input_filename.data());
- reader->Update();
- return reader;
- }
-
QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene)
{
std::string extension=fileinfo.suffix().toLower().toStdString();
@@ -392,20 +288,21 @@ public:
}
vtkSmartPointer data;
- vtkSmartPointer obs =
- vtkSmartPointer::New();
+ vtkSmartPointer obs =
+ vtkSmartPointer::New();
if (extension=="vtp")
- data = read_vtk_file(fname,obs)
+ data = CGAL::VTK_internal::read_vtk_file(fname,obs)
->GetOutput();
else
if (extension=="vtu")
- data = read_vtk_file(fname,obs)
+ data = CGAL::VTK_internal::
+ read_vtk_file(fname,obs)
->GetOutput();
else{
//read non-XML data
vtkSmartPointer reader =
- read_vtk_file(fname,obs);
+ CGAL::VTK_internal::read_vtk_file(fname,obs);
data = vtkPolyData::SafeDownCast(reader->GetOutput());
if (!data)
data = vtkUnstructuredGrid::SafeDownCast(reader->GetOutput());
@@ -433,28 +330,6 @@ public:
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
}
- if (obs->GetError())
- {
- QMessageBox msgBox;
- msgBox.setText("This type of data can't be opened");
- msgBox.setInformativeText(QString("VTK error message :\n")
- .append(QString(obs->GetErrorMessage().data())));
- msgBox.setStandardButtons(QMessageBox::Ok);
- msgBox.setIcon(QMessageBox::Critical);
- msgBox.exec();
- ok = false;
- return QList();
- }
- if (obs->GetWarning())
- {
- QMessageBox msgBox;
- msgBox.setText("This file generates a warning");
- msgBox.setInformativeText(QString("VTK warning message :\n")
- .append(QString(obs->GetWarningMessage().data())));
- msgBox.setStandardButtons(QMessageBox::Ok);
- msgBox.setIcon(QMessageBox::Warning);
- msgBox.exec();
- }
//check celltypes
bool is_polygon_mesh(false),
@@ -481,7 +356,7 @@ public:
if(is_polygon_mesh)
{
FaceGraph* poly = new FaceGraph();
- if (CGAL::vtkPointSet_to_polygon_mesh(data, *poly))
+ if (CGAL::VTK_internal::vtkPointSet_to_polygon_mesh(data, *poly))
{
Scene_facegraph_item* poly_item = new Scene_facegraph_item(poly);
if(group)
diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp
index 7b6febf0ff9..a648b3e4cf3 100644
--- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp
@@ -44,6 +44,7 @@
#include
#include
#include
+#include
#include
#include
@@ -1491,12 +1492,15 @@ bool
Scene_surface_mesh_item::load_obj(std::istream& in)
{
typedef SMesh::Point Point;
- std::vector points;
- std::vector > faces;
- bool failed = !CGAL::read_OBJ(in,points,faces);
+ bool failed = !CGAL::read_OBJ(*d->smesh_, in);
+ if(failed){
+ std::vector points;
+ std::vector > faces;
+ failed = !CGAL::read_OBJ(in,points,faces);
- CGAL::Polygon_mesh_processing::orient_polygon_soup(points,faces);
- CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points,faces,*(d->smesh_));
+ CGAL::Polygon_mesh_processing::orient_polygon_soup(points,faces);
+ CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points,faces,*(d->smesh_));
+ }
if ( (! failed) && !isEmpty() )
{
invalidate(ALL);
@@ -1508,9 +1512,8 @@ Scene_surface_mesh_item::load_obj(std::istream& in)
bool
Scene_surface_mesh_item::save_obj(std::ostream& out) const
{
- CGAL::File_writer_wavefront writer;
- CGAL::generic_print_surface_mesh(out, *(d->smesh_), writer);
- return out.good();
+
+ return CGAL::write_OBJ(*d->smesh_, out);
}
void
diff --git a/Polyhedron/demo/Polyhedron/include/CGAL/gocad_io.h b/Polyhedron/demo/Polyhedron/include/CGAL/gocad_io.h
deleted file mode 100644
index ef4a23e11a9..00000000000
--- a/Polyhedron/demo/Polyhedron/include/CGAL/gocad_io.h
+++ /dev/null
@@ -1,163 +0,0 @@
-#ifndef CGAL_GOCAD_IO_H
-#define CGAL_GOCAD_IO_H
-
-#include