mirror of https://github.com/CGAL/cgal
Move OFF files from Polyhedron_IO to Polyhedron/include/CGAL/IO
This commit is contained in:
parent
0a38d23764
commit
914c37b72f
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright (c) 1997 ETH Zurich (Switzerland).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||
|
||||
#ifndef CGAL_IO_POLYHEDRON_SCAN_OFF_H
|
||||
#define CGAL_IO_POLYHEDRON_SCAN_OFF_H 1
|
||||
|
||||
#include <CGAL/license/Polyhedron.h>
|
||||
|
||||
#include <CGAL/disable_warnings.h>
|
||||
|
||||
#define CGAL_DEPRECATED_HEADER "<CGAL/IO/Polyhedron_scan_OFF.h>"
|
||||
#define CGAL_REPLACEMENT_HEADER "<CGAL/IO/OFF/Polyhedron_scan_OFF.h>"
|
||||
#include <CGAL/internal/deprecation_warning.h>
|
||||
#include <CGAL/IO/OFF/Polyhedron_scan_OFF.h>
|
||||
|
||||
#include <CGAL/enable_warnings.h>
|
||||
|
||||
#endif // CGAL_IO_POLYHEDRON_SCAN_OFF_H //
|
||||
// EOF //
|
||||
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright (c) 1997 ETH Zurich (Switzerland).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||
|
||||
#ifndef CGAL_IO_PRINT_OFF_H
|
||||
#define CGAL_IO_PRINT_OFF_H 1
|
||||
|
||||
#include <CGAL/license/Polyhedron.h>
|
||||
|
||||
#include <CGAL/disable_warnings.h>
|
||||
|
||||
#define CGAL_DEPRECATED_HEADER "<CGAL/IO/print_OFF.h>"
|
||||
#define CGAL_REPLACEMENT_HEADER "<CGAL/IO/OFF/print_OFF.h>"
|
||||
#include <CGAL/internal/deprecation_warning.h>
|
||||
#include <CGAL/IO/OFF/print_OFF.h>
|
||||
|
||||
#include <CGAL/enable_warnings.h>
|
||||
|
||||
|
||||
#endif // CGAL_IO_PRINT_OFF_H //
|
||||
// EOF //
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 1997 ETH Zurich (Switzerland).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||
|
||||
#ifndef CGAL_IO_SCAN_OFF_H
|
||||
#define CGAL_IO_SCAN_OFF_H 1
|
||||
|
||||
#include <CGAL/license/Polyhedron.h>
|
||||
|
||||
#include <CGAL/disable_warnings.h>
|
||||
|
||||
#define CGAL_DEPRECATED_HEADER "<CGAL/IO/scan_OFF.h>"
|
||||
#define CGAL_REPLACEMENT_HEADER "<CGAL/IO/OFF/scan_OFF.h>"
|
||||
#include <CGAL/internal/deprecation_warning.h>
|
||||
#include <CGAL/IO/OFF/scan_OFF.h>"
|
||||
#include <CGAL/enable_warnings.h>
|
||||
|
||||
#endif // CGAL_IO_SCAN_OFF_H //
|
||||
// EOF //
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
// Copyright (c) 1997 ETH Zurich (Switzerland).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||
|
||||
#ifndef CGAL_IO_OFF_POLYHEDRON_SCAN_OFF_H
|
||||
#define CGAL_IO_OFF_POLYHEDRON_SCAN_OFF_H 1
|
||||
|
||||
#include <CGAL/license/Polyhedron.h>
|
||||
|
||||
#include <CGAL/disable_warnings.h>
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/IO/OFF/File_header_OFF.h>
|
||||
#include <CGAL/IO/OFF/File_scanner_OFF.h>
|
||||
#include <CGAL/Modifier_base.h>
|
||||
#include <CGAL/Polyhedron_incremental_builder_3.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <iostream>
|
||||
#include <cstddef>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template < class HDS>
|
||||
class Polyhedron_scan_OFF : public Modifier_base<HDS> {
|
||||
protected:
|
||||
std::istream& m_in;
|
||||
File_header_OFF m_file_header;
|
||||
public:
|
||||
|
||||
typedef HDS Halfedge_data_structure;
|
||||
|
||||
// DEFINITION
|
||||
//
|
||||
// Polyhedron_scan_OFF<Traits> is a polyhedral surface builder.
|
||||
// It scans a polyhedron given in OFF from a stream and appends it
|
||||
// incrementally using the incremental builder.
|
||||
|
||||
Polyhedron_scan_OFF( std::istream& in, bool verbose = false)
|
||||
: m_in(in), m_file_header( verbose) {}
|
||||
|
||||
// Activation
|
||||
void operator()( HDS& hds);
|
||||
|
||||
const File_header_OFF& header() const { return m_file_header; }
|
||||
};
|
||||
|
||||
template < class HDS >
|
||||
void
|
||||
Polyhedron_scan_OFF<HDS>:: operator()( HDS& target) {
|
||||
File_scanner_OFF scanner( m_in, m_file_header.verbose());
|
||||
if ( ! m_in) {
|
||||
if ( scanner.verbose()) {
|
||||
std::cerr << " " << std::endl;
|
||||
std::cerr << "Polyhedron_scan_OFF<HDS>::" << std::endl;
|
||||
std::cerr << "operator(): input error: file format is not in "
|
||||
"OFF." << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
m_file_header = scanner; // Remember file header after return.
|
||||
|
||||
Polyhedron_incremental_builder_3<HDS> B( target, scanner.verbose());
|
||||
B.begin_surface( scanner.size_of_vertices(),
|
||||
scanner.size_of_facets(),
|
||||
scanner.size_of_halfedges());
|
||||
|
||||
typedef typename HDS::Traits Traits;
|
||||
typedef typename Traits::Point_3 Point;
|
||||
|
||||
// read in all vertices
|
||||
std::size_t i;
|
||||
for ( i = 0; i < scanner.size_of_vertices(); i++) {
|
||||
Point p;
|
||||
file_scan_vertex( scanner, p);
|
||||
B.add_vertex( p);
|
||||
if(scanner.has_colors())
|
||||
{
|
||||
Color c;
|
||||
file_scan_color(scanner, c);
|
||||
}
|
||||
else
|
||||
scanner.skip_to_next_vertex( i);
|
||||
}
|
||||
if ( ! m_in || B.error()) {
|
||||
B.rollback();
|
||||
m_in.clear( std::ios::badbit);
|
||||
return;
|
||||
}
|
||||
|
||||
// read in all facets
|
||||
for ( i = 0; i < scanner.size_of_facets(); i++) {
|
||||
B.begin_facet();
|
||||
std::size_t no;
|
||||
scanner.scan_facet( no, i);
|
||||
if( ! m_in || B.error() || no < 3) {
|
||||
if ( scanner.verbose()) {
|
||||
std::cerr << " " << std::endl;
|
||||
std::cerr << "Polyhedron_scan_OFF<Traits>::" << std::endl;
|
||||
std::cerr << "operator()(): input error: facet " << i
|
||||
<< " has less than 3 vertices." << std::endl;
|
||||
}
|
||||
B.rollback();
|
||||
m_in.clear( std::ios::badbit);
|
||||
return;
|
||||
}
|
||||
for ( std::size_t j = 0; j < no; j++) {
|
||||
std::size_t index;
|
||||
scanner.scan_facet_vertex_index( index, i);
|
||||
B.add_vertex_to_facet( index);
|
||||
}
|
||||
//TO DO : Insert read color
|
||||
B.end_facet();
|
||||
scanner.skip_to_next_facet( i);
|
||||
}
|
||||
if ( ! m_in || B.error()) {
|
||||
B.rollback();
|
||||
m_in.clear( std::ios::badbit);
|
||||
return;
|
||||
}
|
||||
if ( B.check_unconnected_vertices()) {
|
||||
if ( ! B.remove_unconnected_vertices()) {
|
||||
if ( scanner.verbose()) {
|
||||
std::cerr << " " << std::endl;
|
||||
std::cerr << "Polyhedron_scan_OFF<Traits>::" << std::endl;
|
||||
std::cerr << "operator()(): input error: cannot "
|
||||
"successfully remove isolated vertices."
|
||||
<< std::endl;
|
||||
}
|
||||
B.rollback();
|
||||
m_in.clear( std::ios::badbit);
|
||||
return;
|
||||
}
|
||||
}
|
||||
B.end_surface();
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#include <CGAL/enable_warnings.h>
|
||||
|
||||
#endif // CGAL_IO_OFF_POLYHEDRON_SCAN_OFF_H //
|
||||
// EOF //
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
// Copyright (c) 1997 ETH Zurich (Switzerland).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||
|
||||
#ifndef CGAL_IO_OFF_PRINT_OFF_H
|
||||
#define CGAL_IO_OFF_PRINT_OFF_H 1
|
||||
|
||||
#include <CGAL/license/Polyhedron.h>
|
||||
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/IO/OFF/File_writer_OFF.h>
|
||||
#include <CGAL/IO/generic_print_polyhedron.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class Polyhedron, class Vpm>
|
||||
void print_polyhedron_with_header_OFF( std::ostream& out,
|
||||
const Polyhedron& P,
|
||||
const File_header_OFF& header,
|
||||
const Vpm& vpm) {
|
||||
File_writer_OFF writer( header);
|
||||
writer.header().set_polyhedral_surface( true);
|
||||
writer.header().set_halfedges( P.size_of_halfedges());
|
||||
generic_print_polyhedron( out, P, writer, vpm);
|
||||
}
|
||||
|
||||
template <class Polyhedron>
|
||||
void print_polyhedron_with_header_OFF( std::ostream& out,
|
||||
const Polyhedron& P,
|
||||
const File_header_OFF& header)
|
||||
{
|
||||
print_polyhedron_with_header_OFF(out, P, header, get(CGAL::vertex_point, P));
|
||||
}
|
||||
|
||||
template <class Polyhedron>
|
||||
void print_polyhedron_OFF( std::ostream& out,
|
||||
const Polyhedron& P,
|
||||
bool verbose = false) {
|
||||
File_header_OFF header( verbose);
|
||||
header.set_binary( is_binary( out));
|
||||
header.set_no_comments( ! is_pretty( out));
|
||||
print_polyhedron_with_header_OFF( out, P, header);
|
||||
}
|
||||
|
||||
|
||||
// Deprecated global functions, replaced with functions above
|
||||
|
||||
template < class Traits,
|
||||
class Items,
|
||||
template < class T, class I, class A>
|
||||
class HDS, class Alloc>
|
||||
void
|
||||
print_OFF( std::ostream& out,
|
||||
const Polyhedron_3<Traits,Items,HDS,Alloc>& P,
|
||||
bool verbose = false) {
|
||||
File_writer_OFF writer( verbose);
|
||||
writer.header().set_binary( is_binary( out));
|
||||
writer.header().set_no_comments( ! is_pretty( out));
|
||||
writer.header().set_polyhedral_surface( true);
|
||||
writer.header().set_halfedges( P.size_of_halfedges());
|
||||
generic_print_polyhedron( out, P, writer);
|
||||
}
|
||||
|
||||
template < class Traits,
|
||||
class Items,
|
||||
template < class T, class I, class A>
|
||||
class HDS, class Alloc>
|
||||
void
|
||||
print_OFF( std::ostream& out,
|
||||
const Polyhedron_3<Traits,Items,HDS,Alloc>& P,
|
||||
const File_header_OFF& header) {
|
||||
File_writer_OFF writer( header);
|
||||
writer.header().set_polyhedral_surface( true);
|
||||
writer.header().set_halfedges( P.size_of_halfedges());
|
||||
generic_print_polyhedron( out, P, writer);
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
#endif // CGAL_IO_OFF_PRINT_OFF_H //
|
||||
// EOF //
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
// Copyright (c) 1997 ETH Zurich (Switzerland).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||
|
||||
#ifndef CGAL_IO_OFF_SCAN_OFF_H
|
||||
#define CGAL_IO_OFF_SCAN_OFF_H 1
|
||||
|
||||
#include <CGAL/license/Polyhedron.h>
|
||||
|
||||
|
||||
#include <CGAL/IO/OFF/Polyhedron_scan_OFF.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template < class Traits,
|
||||
class Items,
|
||||
template < class T, class I, class A>
|
||||
class HDS, class Alloc>
|
||||
void scan_OFF( std::istream& in,
|
||||
Polyhedron_3<Traits,Items,HDS,Alloc>& P,
|
||||
File_header_OFF& header) {
|
||||
// reads a polyhedron from `in' and appends it to P.
|
||||
// Returns also the File_header_OFF structure of the object.
|
||||
typedef Polyhedron_3<Traits,Items,HDS,Alloc> Polyhedron;
|
||||
typedef typename Polyhedron::HalfedgeDS HalfedgeDS;
|
||||
typedef Polyhedron_scan_OFF<HalfedgeDS> Scanner;
|
||||
Scanner scanner( in, header.verbose());
|
||||
P.delegate(scanner);
|
||||
header = scanner.header();
|
||||
}
|
||||
|
||||
template < class Traits,
|
||||
class Items,
|
||||
template < class T, class I, class A>
|
||||
class HDS, class Alloc>
|
||||
void scan_OFF( std::istream& in, Polyhedron_3<Traits,Items,HDS,Alloc>& P,
|
||||
bool verbose = false) {
|
||||
// reads a polyhedron from `in' and appends it to P.
|
||||
typedef Polyhedron_3<Traits,Items,HDS,Alloc> Polyhedron;
|
||||
typedef typename Polyhedron::HalfedgeDS HalfedgeDS;
|
||||
typedef Polyhedron_scan_OFF<HalfedgeDS> Scanner;
|
||||
Scanner scanner( in, verbose);
|
||||
P.delegate(scanner);
|
||||
}
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
#endif // CGAL_IO_OFF_SCAN_OFF_H //
|
||||
// EOF //
|
||||
Loading…
Reference in New Issue