mirror of https://github.com/CGAL/cgal
Remove OFF_reader.h and Writer_OFF.h
- Writer_OFF.h is simply unused and useless - OFF_reader.h is transfered to OFF.h for clarity
This commit is contained in:
parent
ebb99ee7a8
commit
322c8786da
|
|
@ -15,6 +15,6 @@
|
||||||
#define CGAL_REPLACEMENT_HEADER "<CGAL/IO/OFF.h>"
|
#define CGAL_REPLACEMENT_HEADER "<CGAL/IO/OFF.h>"
|
||||||
#include <CGAL/internal/deprecation_warning.h>
|
#include <CGAL/internal/deprecation_warning.h>
|
||||||
|
|
||||||
#include <CGAL/IO/OFF/OFF_reader.h>
|
#include <CGAL/IO/OFF.h>
|
||||||
|
|
||||||
#endif // CGAL_IO_OFF_READER_H
|
#endif // CGAL_IO_OFF_READER_H
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@
|
||||||
#define CGAL_IO_OFF_H
|
#define CGAL_IO_OFF_H
|
||||||
|
|
||||||
#include <CGAL/IO/reader_helpers.h>
|
#include <CGAL/IO/reader_helpers.h>
|
||||||
#include <CGAL/IO/OFF/OFF_reader.h>
|
|
||||||
#include <CGAL/IO/OFF/OFF_writer.h>
|
|
||||||
#include <CGAL/IO/OFF/File_scanner_OFF.h>
|
#include <CGAL/IO/OFF/File_scanner_OFF.h>
|
||||||
#include <CGAL/IO/OFF/File_writer_OFF.h>
|
#include <CGAL/IO/OFF/File_writer_OFF.h>
|
||||||
|
|
||||||
|
|
@ -24,6 +22,7 @@
|
||||||
#include <CGAL/use.h>
|
#include <CGAL/use.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
template <class Point_3, class Polygon_3>
|
template <class Point_3, class Polygon_3>
|
||||||
bool
|
bool
|
||||||
read_OFF( std::istream& in,
|
read_OFF( std::istream& in,
|
||||||
|
|
@ -31,7 +30,38 @@ read_OFF( std::istream& in,
|
||||||
std::vector< Polygon_3 >& polygons,
|
std::vector< Polygon_3 >& polygons,
|
||||||
bool /* verbose */ = false)
|
bool /* verbose */ = false)
|
||||||
{
|
{
|
||||||
return OFF_internal::read_OFF(in, points, polygons);
|
CGAL::File_scanner_OFF scanner(in);
|
||||||
|
|
||||||
|
points.resize(scanner.size_of_vertices());
|
||||||
|
polygons.resize(scanner.size_of_facets());
|
||||||
|
for (std::size_t i = 0; i < scanner.size_of_vertices(); ++i) {
|
||||||
|
double x, y, z, w;
|
||||||
|
scanner.scan_vertex( x, y, z, w);
|
||||||
|
CGAL_assertion(w!=0);
|
||||||
|
IO::internal::fill_point( x/w, y/w, z/w, points[i] );
|
||||||
|
scanner.skip_to_next_vertex( i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!in)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < scanner.size_of_facets(); ++i) {
|
||||||
|
std::size_t no;
|
||||||
|
|
||||||
|
scanner.scan_facet( no, i);
|
||||||
|
IO::internal::resize(polygons[i], no);
|
||||||
|
for(std::size_t j = 0; j < no; ++j) {
|
||||||
|
std::size_t id;
|
||||||
|
scanner.scan_facet_vertex_index(id, i);
|
||||||
|
if(id < scanner.size_of_vertices()) {
|
||||||
|
polygons[i][j] = id;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return in.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Point_3, class Polygon_3, class Color_rgb >
|
template <class Point_3, class Polygon_3, class Color_rgb >
|
||||||
|
|
@ -43,7 +73,72 @@ read_OFF( std::istream& in,
|
||||||
std::vector<Color_rgb>& vcolors,
|
std::vector<Color_rgb>& vcolors,
|
||||||
bool /* verbose */ = false)
|
bool /* verbose */ = false)
|
||||||
{
|
{
|
||||||
return OFF_internal::read_OFF(in, points, polygons, fcolors, vcolors);
|
CGAL::File_scanner_OFF scanner(in);
|
||||||
|
|
||||||
|
points.resize(scanner.size_of_vertices());
|
||||||
|
polygons.resize(scanner.size_of_facets());
|
||||||
|
|
||||||
|
if(scanner.has_colors())
|
||||||
|
vcolors.resize(scanner.size_of_vertices());
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < scanner.size_of_vertices(); ++i) {
|
||||||
|
double x, y, z, w;
|
||||||
|
scanner.scan_vertex( x, y, z, w);
|
||||||
|
CGAL_assertion(w!=0);
|
||||||
|
IO::internal::fill_point( x/w, y/w, z/w, points[i] );
|
||||||
|
if(scanner.has_colors()) {
|
||||||
|
unsigned char r=0, g=0, b=0;
|
||||||
|
scanner.scan_color( r, g, b);
|
||||||
|
vcolors[i] = Color_rgb(r,g,b);
|
||||||
|
} else {
|
||||||
|
scanner.skip_to_next_vertex(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!in)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_fcolors = false;
|
||||||
|
for (std::size_t i = 0; i < scanner.size_of_facets(); ++i)
|
||||||
|
{
|
||||||
|
std::size_t no;
|
||||||
|
scanner.scan_facet( no, i);
|
||||||
|
|
||||||
|
if(!in)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IO::internal::resize(polygons[i], no);
|
||||||
|
for(std::size_t j = 0; j < no; ++j) {
|
||||||
|
std::size_t id;
|
||||||
|
scanner.scan_facet_vertex_index(id, i);
|
||||||
|
if(id < scanner.size_of_vertices()) {
|
||||||
|
polygons[i][j] = id;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i==0)
|
||||||
|
{
|
||||||
|
std::string col;
|
||||||
|
std::getline(in, col);
|
||||||
|
std::istringstream iss(col);
|
||||||
|
char ci =' ';
|
||||||
|
|
||||||
|
if(iss >> ci) {
|
||||||
|
has_fcolors = true;
|
||||||
|
fcolors.resize(scanner.size_of_facets());
|
||||||
|
std::istringstream iss2(col);
|
||||||
|
fcolors[i] = scanner.get_color_from_line(iss2);
|
||||||
|
}
|
||||||
|
} else if(has_fcolors) {
|
||||||
|
unsigned char r=0, g=0, b=0;
|
||||||
|
scanner.scan_color(r,g,b);
|
||||||
|
fcolors[i] = Color_rgb(r,g,b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return in.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Point_3, class Polygon_3>
|
template <class Point_3, class Polygon_3>
|
||||||
|
|
|
||||||
|
|
@ -1,143 +0,0 @@
|
||||||
|
|
||||||
// Copyright (c) 2015 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) : Laurent Rineau and Sebastien Loriot
|
|
||||||
|
|
||||||
#ifndef CGAL_IO_OFF_OFF_READER_H
|
|
||||||
#define CGAL_IO_OFF_OFF_READER_H
|
|
||||||
|
|
||||||
#include <CGAL/IO/OFF/File_scanner_OFF.h>
|
|
||||||
#include <CGAL/IO/reader_helpers.h>
|
|
||||||
|
|
||||||
#include <CGAL/array.h>
|
|
||||||
#include <CGAL/assertions.h>
|
|
||||||
#include <CGAL/use.h>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
namespace OFF_internal {
|
|
||||||
|
|
||||||
template <class Point_3, class Polygon_3>
|
|
||||||
bool
|
|
||||||
read_OFF( std::istream& in,
|
|
||||||
std::vector< Point_3 >& points,
|
|
||||||
std::vector< Polygon_3 >& polygons,
|
|
||||||
bool /* verbose */ = false)
|
|
||||||
{
|
|
||||||
CGAL::File_scanner_OFF scanner(in);
|
|
||||||
|
|
||||||
points.resize(scanner.size_of_vertices());
|
|
||||||
polygons.resize(scanner.size_of_facets());
|
|
||||||
for (std::size_t i = 0; i < scanner.size_of_vertices(); ++i) {
|
|
||||||
double x, y, z, w;
|
|
||||||
scanner.scan_vertex( x, y, z, w);
|
|
||||||
CGAL_assertion(w!=0);
|
|
||||||
IO::internal::fill_point( x/w, y/w, z/w, points[i] );
|
|
||||||
scanner.skip_to_next_vertex( i);
|
|
||||||
}
|
|
||||||
if(!in)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (std::size_t i = 0; i < scanner.size_of_facets(); ++i) {
|
|
||||||
std::size_t no;
|
|
||||||
|
|
||||||
scanner.scan_facet( no, i);
|
|
||||||
IO::internal::resize(polygons[i], no);
|
|
||||||
for(std::size_t j = 0; j < no; ++j) {
|
|
||||||
std::size_t id;
|
|
||||||
scanner.scan_facet_vertex_index(id, i);
|
|
||||||
if(id < scanner.size_of_vertices())
|
|
||||||
{
|
|
||||||
polygons[i][j] = id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return in.good();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Point_3, class Polygon_3, class Color_rgb >
|
|
||||||
bool
|
|
||||||
read_OFF( std::istream& in,
|
|
||||||
std::vector< Point_3 >& points,
|
|
||||||
std::vector< Polygon_3 >& polygons,
|
|
||||||
std::vector<Color_rgb>& fcolors,
|
|
||||||
std::vector<Color_rgb>& vcolors,
|
|
||||||
bool /* verbose */ = false)
|
|
||||||
{
|
|
||||||
CGAL::File_scanner_OFF scanner(in);
|
|
||||||
points.resize(scanner.size_of_vertices());
|
|
||||||
polygons.resize(scanner.size_of_facets());
|
|
||||||
if(scanner.has_colors())
|
|
||||||
vcolors.resize(scanner.size_of_vertices());
|
|
||||||
for (std::size_t i = 0; i < scanner.size_of_vertices(); ++i) {
|
|
||||||
double x, y, z, w;
|
|
||||||
scanner.scan_vertex( x, y, z, w);
|
|
||||||
CGAL_assertion(w!=0);
|
|
||||||
IO::internal::fill_point( x/w, y/w, z/w, points[i] );
|
|
||||||
if(scanner.has_colors())
|
|
||||||
{
|
|
||||||
unsigned char r=0, g=0, b=0;
|
|
||||||
scanner.scan_color( r, g, b);
|
|
||||||
vcolors[i] = Color_rgb(r,g,b);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
scanner.skip_to_next_vertex(i);
|
|
||||||
if(!in)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool has_fcolors = false;
|
|
||||||
for (std::size_t i = 0; i < scanner.size_of_facets(); ++i) {
|
|
||||||
std::size_t no;
|
|
||||||
scanner.scan_facet( no, i);
|
|
||||||
if(!in)
|
|
||||||
return false;
|
|
||||||
IO::internal::resize(polygons[i], no);
|
|
||||||
for(std::size_t j = 0; j < no; ++j) {
|
|
||||||
std::size_t id;
|
|
||||||
scanner.scan_facet_vertex_index(id, i);
|
|
||||||
if(id < scanner.size_of_vertices())
|
|
||||||
{
|
|
||||||
polygons[i][j] = id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i==0)
|
|
||||||
{
|
|
||||||
std::string col;
|
|
||||||
std::getline(in, col);
|
|
||||||
std::istringstream iss(col);
|
|
||||||
char ci =' ';
|
|
||||||
if(iss >> ci){
|
|
||||||
has_fcolors = true;
|
|
||||||
fcolors.resize(scanner.size_of_facets());
|
|
||||||
std::istringstream iss2(col);
|
|
||||||
fcolors[i] = scanner.get_color_from_line(iss2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(has_fcolors)
|
|
||||||
{
|
|
||||||
unsigned char r=0, g=0, b=0;
|
|
||||||
scanner.scan_color(r,g,b);
|
|
||||||
fcolors[i] = Color_rgb(r,g,b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return in.good();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace CGAL
|
|
||||||
|
|
||||||
#endif // CGAL_IO_OFF_OFF_READER_H
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
// Copyright (c) 1997
|
|
||||||
// Utrecht University (The Netherlands),
|
|
||||||
// ETH Zurich (Switzerland),
|
|
||||||
// INRIA Sophia-Antipolis (France),
|
|
||||||
// Max-Planck-Institute Saarbruecken (Germany),
|
|
||||||
// and Tel-Aviv University (Israel). 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) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
|
||||||
|
|
||||||
#ifndef CGAL_IO_WRITER_OFF_H
|
|
||||||
#define CGAL_IO_WRITER_OFF_H 1
|
|
||||||
#include <CGAL/IO/File_writer_OFF.h>
|
|
||||||
#include <CGAL/IO/Generic_writer.h>
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
template < class Pt >
|
|
||||||
class Writer_OFF : public Generic_writer<File_writer_OFF,Pt> {
|
|
||||||
public:
|
|
||||||
Writer_OFF( std::ostream& out,
|
|
||||||
std::size_t v,
|
|
||||||
std::size_t h,
|
|
||||||
std::size_t f,
|
|
||||||
bool verbose = false)
|
|
||||||
: Generic_writer<File_writer_OFF,Pt>(
|
|
||||||
File_writer_OFF( verbose), out, v, h, f
|
|
||||||
) {}
|
|
||||||
Writer_OFF( std::ostream& out,
|
|
||||||
std::size_t v,
|
|
||||||
std::size_t h,
|
|
||||||
std::size_t f,
|
|
||||||
const File_header_OFF& header)
|
|
||||||
: Generic_writer<File_writer_OFF,Pt>(
|
|
||||||
File_writer_OFF( header), out, v, h, f
|
|
||||||
) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
#endif // CGAL_IO_WRITER_OFF_H //
|
|
||||||
// EOF //
|
|
||||||
Loading…
Reference in New Issue