mirror of https://github.com/CGAL/cgal
Redo all the modifs to remove all the cpp files from cgal.
First step where all the XXX.cpp are copied into XXX_impl.h files. The macro CGAL_HEADER_ONLY allows to know if impl files need to be included or not into header files; and allow to decide if functions are in impl files are inline or not. Next step: process with static variables for the header only version.
This commit is contained in:
parent
15bfc64808
commit
1182319f5d
|
|
@ -96,4 +96,8 @@ inline bool do_intersect(
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/Bbox_2_Line_2_intersection_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,213 @@
|
||||||
|
// Copyright (c) 2000
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Geert-Jan Giezeman
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
#include <CGAL/Bbox_2_Line_2_intersection.h>
|
||||||
|
typedef CGAL::Simple_cartesian<double> Lcart;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
class Bbox_2_Line_2_pair_impl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Bbox_2_Line_2_pair_impl() {}
|
||||||
|
Bbox_2_Line_2_pair_impl(Bbox_2 const &bb, Lcart::Line_2 const &line)
|
||||||
|
: _bbox(bb), _line(line), _known(false) {}
|
||||||
|
Bbox_2 _bbox;
|
||||||
|
Lcart::Line_2 _line;
|
||||||
|
mutable bool _known;
|
||||||
|
mutable Bbox_2_Line_2_pair::Intersection_results _result;
|
||||||
|
mutable double _min, _max;
|
||||||
|
};
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Line_2_pair::~Bbox_2_Line_2_pair()
|
||||||
|
{
|
||||||
|
delete pimpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Line_2_pair::Bbox_2_Line_2_pair()
|
||||||
|
{
|
||||||
|
pimpl = new Bbox_2_Line_2_pair_impl;
|
||||||
|
pimpl->_known = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Line_2_pair::Bbox_2_Line_2_pair(Bbox_2_Line_2_pair const &o)
|
||||||
|
{
|
||||||
|
pimpl = new Bbox_2_Line_2_pair_impl(*o.pimpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Line_2_pair::Bbox_2_Line_2_pair(
|
||||||
|
Bbox_2 const &bbox, double line_a, double line_b, double line_c)
|
||||||
|
{
|
||||||
|
pimpl = new Bbox_2_Line_2_pair_impl(bbox,
|
||||||
|
Lcart::Line_2(line_a, line_b, line_c));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Line_2_pair &
|
||||||
|
Bbox_2_Line_2_pair::operator=(Bbox_2_Line_2_pair const &o)
|
||||||
|
{
|
||||||
|
*pimpl = *o.pimpl;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Line_2_pair::Intersection_results
|
||||||
|
Bbox_2_Line_2_pair::intersection_type() const
|
||||||
|
{
|
||||||
|
if (pimpl->_known)
|
||||||
|
return pimpl->_result;
|
||||||
|
// The non const this pointer is used to cast away const.
|
||||||
|
pimpl->_known = true;
|
||||||
|
const Lcart::Point_2 &ref_point = pimpl->_line.point();
|
||||||
|
const Lcart::Vector_2 &dir =
|
||||||
|
pimpl->_line.direction().to_vector();
|
||||||
|
bool to_infinity = true;
|
||||||
|
// first on x value
|
||||||
|
if (dir.x() == 0.0) {
|
||||||
|
if (ref_point.x() < pimpl->_bbox.xmin()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
if (ref_point.x() > pimpl->_bbox.xmax()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
double newmin, newmax;
|
||||||
|
if (dir.x() > 0.0) {
|
||||||
|
newmin = (pimpl->_bbox.xmin()-ref_point.x())/dir.x();
|
||||||
|
newmax = (pimpl->_bbox.xmax()-ref_point.x())/dir.x();
|
||||||
|
} else {
|
||||||
|
newmin = (pimpl->_bbox.xmax()-ref_point.x())/dir.x();
|
||||||
|
newmax = (pimpl->_bbox.xmin()-ref_point.x())/dir.x();
|
||||||
|
}
|
||||||
|
if (to_infinity) {
|
||||||
|
pimpl->_min = newmin;
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
} else {
|
||||||
|
if (newmin > pimpl->_min)
|
||||||
|
pimpl->_min = newmin;
|
||||||
|
if (newmax < pimpl->_max)
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
if (pimpl->_max < pimpl->_min) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
to_infinity = false;
|
||||||
|
}
|
||||||
|
// now on y value
|
||||||
|
if (dir.y() == 0.0) {
|
||||||
|
if (ref_point.y() < pimpl->_bbox.ymin()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
if (ref_point.y() > pimpl->_bbox.ymax()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
double newmin, newmax;
|
||||||
|
if (dir.y() > 0.0) {
|
||||||
|
newmin = (pimpl->_bbox.ymin()-ref_point.y())/dir.y();
|
||||||
|
newmax = (pimpl->_bbox.ymax()-ref_point.y())/dir.y();
|
||||||
|
} else {
|
||||||
|
newmin = (pimpl->_bbox.ymax()-ref_point.y())/dir.y();
|
||||||
|
newmax = (pimpl->_bbox.ymin()-ref_point.y())/dir.y();
|
||||||
|
}
|
||||||
|
if (to_infinity) {
|
||||||
|
pimpl->_min = newmin;
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
} else {
|
||||||
|
if (newmin > pimpl->_min)
|
||||||
|
pimpl->_min = newmin;
|
||||||
|
if (newmax < pimpl->_max)
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
if (pimpl->_max < pimpl->_min) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
to_infinity = false;
|
||||||
|
}
|
||||||
|
CGAL_kernel_assertion(!to_infinity);
|
||||||
|
if (pimpl->_max == pimpl->_min) {
|
||||||
|
pimpl->_result = POINT;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
pimpl->_result = SEGMENT;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool
|
||||||
|
Bbox_2_Line_2_pair::intersection(
|
||||||
|
double &x1, double &y1, double &x2, double &y2) const
|
||||||
|
{
|
||||||
|
if (!pimpl->_known)
|
||||||
|
intersection_type();
|
||||||
|
if (pimpl->_result != SEGMENT)
|
||||||
|
return false;
|
||||||
|
Lcart::Point_2 p1(pimpl->_line.point()
|
||||||
|
+ pimpl->_min*pimpl->_line.direction().to_vector());
|
||||||
|
Lcart::Point_2 p2(pimpl->_line.point()
|
||||||
|
+ pimpl->_max*pimpl->_line.direction().to_vector());
|
||||||
|
x1 = p1.x();
|
||||||
|
y1 = p1.y();
|
||||||
|
x2 = p2.x();
|
||||||
|
y2 = p2.y();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool
|
||||||
|
Bbox_2_Line_2_pair::intersection(
|
||||||
|
double &x, double &y) const
|
||||||
|
{
|
||||||
|
if (!pimpl->_known)
|
||||||
|
intersection_type();
|
||||||
|
if (pimpl->_result != POINT)
|
||||||
|
return false;
|
||||||
|
Lcart::Point_2 pt(pimpl->_line.point()
|
||||||
|
+ pimpl->_min*pimpl->_line.direction().to_vector());
|
||||||
|
x = pt.x();
|
||||||
|
y = pt.y();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
|
@ -75,6 +75,8 @@ inline bool do_intersect_ray_2(
|
||||||
}
|
}
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/Ray_2_Bbox_2_intersection_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,209 @@
|
||||||
|
// Copyright (c) 2000
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Geert-Jan Giezeman
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
#include <CGAL/Ray_2_Bbox_2_intersection.h>
|
||||||
|
typedef CGAL::Simple_cartesian<double> Rcart;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
class Bbox_2_Ray_2_pair_impl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Bbox_2_Ray_2_pair_impl():_known(false) {}
|
||||||
|
Bbox_2_Ray_2_pair_impl(Bbox_2 const &bbox, Rcart::Point_2 const &pt,
|
||||||
|
Rcart::Vector_2 const &dir)
|
||||||
|
:_box(bbox), _known(false), _ref_point(pt), _dir(dir), _min(0.0) {}
|
||||||
|
Ray_2< Rcart > _ray;
|
||||||
|
Bbox_2 _box;
|
||||||
|
bool _known;
|
||||||
|
Bbox_2_Ray_2_pair::Intersection_results _result;
|
||||||
|
Rcart::Point_2 _ref_point;
|
||||||
|
Rcart::Vector_2 _dir;
|
||||||
|
double _min, _max;
|
||||||
|
};
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Ray_2_pair::~Bbox_2_Ray_2_pair()
|
||||||
|
{
|
||||||
|
delete pimpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair()
|
||||||
|
{
|
||||||
|
pimpl = new Bbox_2_Ray_2_pair_impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair(Bbox_2_Ray_2_pair const &o)
|
||||||
|
{
|
||||||
|
pimpl = new Bbox_2_Ray_2_pair_impl(*o.pimpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair(
|
||||||
|
Bbox_2 const &bbox, double x, double y, double dx, double dy)
|
||||||
|
{
|
||||||
|
pimpl = new Bbox_2_Ray_2_pair_impl(bbox,
|
||||||
|
Rcart::Point_2(x,y), Rcart::Vector_2(dx,dy));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Ray_2_pair &
|
||||||
|
Bbox_2_Ray_2_pair::operator=(Bbox_2_Ray_2_pair const &o)
|
||||||
|
{
|
||||||
|
*pimpl = *o.pimpl;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
Bbox_2_Ray_2_pair::Intersection_results
|
||||||
|
Bbox_2_Ray_2_pair::intersection_type() const
|
||||||
|
{
|
||||||
|
if (pimpl->_known)
|
||||||
|
return pimpl->_result;
|
||||||
|
pimpl->_known = true;
|
||||||
|
bool to_infinity = true;
|
||||||
|
// first on x value
|
||||||
|
if (pimpl->_dir.x() == 0.0) {
|
||||||
|
if (pimpl->_ref_point.x() < pimpl->_box.xmin()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
if (pimpl->_ref_point.x() > pimpl->_box.xmax()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
double newmin, newmax;
|
||||||
|
if (pimpl->_dir.x() > 0.0) {
|
||||||
|
newmin =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
||||||
|
newmax =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
||||||
|
} else {
|
||||||
|
newmin =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
||||||
|
newmax =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
||||||
|
}
|
||||||
|
if (newmin > pimpl->_min)
|
||||||
|
pimpl->_min = newmin;
|
||||||
|
if (to_infinity) {
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
} else {
|
||||||
|
if (newmax < pimpl->_max)
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
}
|
||||||
|
if (pimpl->_max < pimpl->_min){
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
to_infinity = false;
|
||||||
|
}
|
||||||
|
// now on y value
|
||||||
|
if (pimpl->_dir.y() == 0.0) {
|
||||||
|
if (pimpl->_ref_point.y() < pimpl->_box.ymin()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
if (pimpl->_ref_point.y() > pimpl->_box.ymax()) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
double newmin, newmax;
|
||||||
|
if (pimpl->_dir.y() > 0.0) {
|
||||||
|
newmin =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
||||||
|
newmax =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
||||||
|
} else {
|
||||||
|
newmin =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
||||||
|
newmax =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
||||||
|
}
|
||||||
|
if (newmin > pimpl->_min)
|
||||||
|
pimpl->_min = newmin;
|
||||||
|
if (to_infinity) {
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
} else {
|
||||||
|
if (newmax < pimpl->_max)
|
||||||
|
pimpl->_max = newmax;
|
||||||
|
}
|
||||||
|
if (pimpl->_max < pimpl->_min) {
|
||||||
|
pimpl->_result = NO_INTERSECTION;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
to_infinity = false;
|
||||||
|
}
|
||||||
|
CGAL_kernel_assertion(!to_infinity);
|
||||||
|
if (pimpl->_max == pimpl->_min) {
|
||||||
|
pimpl->_result = POINT;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
pimpl->_result = SEGMENT;
|
||||||
|
return pimpl->_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool Bbox_2_Ray_2_pair::
|
||||||
|
intersection(double &x1, double &y1, double &x2, double &y2) const
|
||||||
|
{
|
||||||
|
if (!pimpl->_known)
|
||||||
|
intersection_type();
|
||||||
|
if (pimpl->_result != SEGMENT)
|
||||||
|
return false;
|
||||||
|
Rcart::Point_2 p1(pimpl->_ref_point + pimpl->_min*pimpl->_dir);
|
||||||
|
Rcart::Point_2 p2(pimpl->_ref_point + pimpl->_max*pimpl->_dir);
|
||||||
|
x1 = p1.x();
|
||||||
|
y1 = p1.y();
|
||||||
|
x2 = p2.x();
|
||||||
|
y2 = p2.y();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool Bbox_2_Ray_2_pair::intersection(double &x, double &y) const
|
||||||
|
{
|
||||||
|
if (!pimpl->_known)
|
||||||
|
intersection_type();
|
||||||
|
if (pimpl->_result != POINT)
|
||||||
|
return false;
|
||||||
|
Rcart::Point_2 pt = pimpl->_ref_point + pimpl->_min*pimpl->_dir;
|
||||||
|
x = pt.x();
|
||||||
|
y = pt.y();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool do_intersect_ray_2(
|
||||||
|
const Bbox_2 &box, double x, double y, double dx, double dy)
|
||||||
|
{
|
||||||
|
Bbox_2_Ray_2_pair pair(box, x, y, dx, dy);
|
||||||
|
return pair.intersection_type() != Bbox_2_Ray_2_pair::NO_INTERSECTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
|
@ -22,346 +22,5 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Geert-Jan Giezeman
|
// Author(s) : Geert-Jan Giezeman
|
||||||
|
|
||||||
|
#include <CGAL/Bbox_2_Line_2_intersection_impl.h>
|
||||||
#include <CGAL/Simple_cartesian.h>
|
#include <CGAL/Ray_2_Bbox_2_intersection_impl.h>
|
||||||
#include <CGAL/Bbox_2_Line_2_intersection.h>
|
|
||||||
#include <CGAL/Ray_2_Bbox_2_intersection.h>
|
|
||||||
typedef CGAL::Simple_cartesian<double> Rcart;
|
|
||||||
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
class Bbox_2_Line_2_pair_impl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Bbox_2_Line_2_pair_impl() {}
|
|
||||||
Bbox_2_Line_2_pair_impl(Bbox_2 const &bb, Rcart::Line_2 const &line)
|
|
||||||
: _bbox(bb), _line(line), _known(false) {}
|
|
||||||
Bbox_2 _bbox;
|
|
||||||
Rcart::Line_2 _line;
|
|
||||||
mutable bool _known;
|
|
||||||
mutable Bbox_2_Line_2_pair::Intersection_results _result;
|
|
||||||
mutable double _min, _max;
|
|
||||||
};
|
|
||||||
|
|
||||||
Bbox_2_Line_2_pair::~Bbox_2_Line_2_pair()
|
|
||||||
{
|
|
||||||
delete pimpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Line_2_pair::Bbox_2_Line_2_pair()
|
|
||||||
{
|
|
||||||
pimpl = new Bbox_2_Line_2_pair_impl;
|
|
||||||
pimpl->_known = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Line_2_pair::Bbox_2_Line_2_pair(Bbox_2_Line_2_pair const &o)
|
|
||||||
{
|
|
||||||
pimpl = new Bbox_2_Line_2_pair_impl(*o.pimpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Line_2_pair::Bbox_2_Line_2_pair(
|
|
||||||
Bbox_2 const &bbox, double line_a, double line_b, double line_c)
|
|
||||||
{
|
|
||||||
pimpl = new Bbox_2_Line_2_pair_impl(bbox,
|
|
||||||
Rcart::Line_2(line_a, line_b, line_c));
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Line_2_pair &
|
|
||||||
Bbox_2_Line_2_pair::operator=(Bbox_2_Line_2_pair const &o)
|
|
||||||
{
|
|
||||||
*pimpl = *o.pimpl;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Bbox_2_Line_2_pair::Intersection_results
|
|
||||||
Bbox_2_Line_2_pair::intersection_type() const
|
|
||||||
{
|
|
||||||
if (pimpl->_known)
|
|
||||||
return pimpl->_result;
|
|
||||||
// The non const this pointer is used to cast away const.
|
|
||||||
pimpl->_known = true;
|
|
||||||
const Rcart::Point_2 &ref_point = pimpl->_line.point();
|
|
||||||
const Rcart::Vector_2 &dir =
|
|
||||||
pimpl->_line.direction().to_vector();
|
|
||||||
bool to_infinity = true;
|
|
||||||
// first on x value
|
|
||||||
if (dir.x() == 0.0) {
|
|
||||||
if (ref_point.x() < pimpl->_bbox.xmin()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
if (ref_point.x() > pimpl->_bbox.xmax()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
double newmin, newmax;
|
|
||||||
if (dir.x() > 0.0) {
|
|
||||||
newmin = (pimpl->_bbox.xmin()-ref_point.x())/dir.x();
|
|
||||||
newmax = (pimpl->_bbox.xmax()-ref_point.x())/dir.x();
|
|
||||||
} else {
|
|
||||||
newmin = (pimpl->_bbox.xmax()-ref_point.x())/dir.x();
|
|
||||||
newmax = (pimpl->_bbox.xmin()-ref_point.x())/dir.x();
|
|
||||||
}
|
|
||||||
if (to_infinity) {
|
|
||||||
pimpl->_min = newmin;
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
} else {
|
|
||||||
if (newmin > pimpl->_min)
|
|
||||||
pimpl->_min = newmin;
|
|
||||||
if (newmax < pimpl->_max)
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
if (pimpl->_max < pimpl->_min) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
to_infinity = false;
|
|
||||||
}
|
|
||||||
// now on y value
|
|
||||||
if (dir.y() == 0.0) {
|
|
||||||
if (ref_point.y() < pimpl->_bbox.ymin()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
if (ref_point.y() > pimpl->_bbox.ymax()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
double newmin, newmax;
|
|
||||||
if (dir.y() > 0.0) {
|
|
||||||
newmin = (pimpl->_bbox.ymin()-ref_point.y())/dir.y();
|
|
||||||
newmax = (pimpl->_bbox.ymax()-ref_point.y())/dir.y();
|
|
||||||
} else {
|
|
||||||
newmin = (pimpl->_bbox.ymax()-ref_point.y())/dir.y();
|
|
||||||
newmax = (pimpl->_bbox.ymin()-ref_point.y())/dir.y();
|
|
||||||
}
|
|
||||||
if (to_infinity) {
|
|
||||||
pimpl->_min = newmin;
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
} else {
|
|
||||||
if (newmin > pimpl->_min)
|
|
||||||
pimpl->_min = newmin;
|
|
||||||
if (newmax < pimpl->_max)
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
if (pimpl->_max < pimpl->_min) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
to_infinity = false;
|
|
||||||
}
|
|
||||||
CGAL_kernel_assertion(!to_infinity);
|
|
||||||
if (pimpl->_max == pimpl->_min) {
|
|
||||||
pimpl->_result = POINT;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
pimpl->_result = SEGMENT;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
Bbox_2_Line_2_pair::intersection(
|
|
||||||
double &x1, double &y1, double &x2, double &y2) const
|
|
||||||
{
|
|
||||||
if (!pimpl->_known)
|
|
||||||
intersection_type();
|
|
||||||
if (pimpl->_result != SEGMENT)
|
|
||||||
return false;
|
|
||||||
Rcart::Point_2 p1(pimpl->_line.point()
|
|
||||||
+ pimpl->_min*pimpl->_line.direction().to_vector());
|
|
||||||
Rcart::Point_2 p2(pimpl->_line.point()
|
|
||||||
+ pimpl->_max*pimpl->_line.direction().to_vector());
|
|
||||||
x1 = p1.x();
|
|
||||||
y1 = p1.y();
|
|
||||||
x2 = p2.x();
|
|
||||||
y2 = p2.y();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
Bbox_2_Line_2_pair::intersection(
|
|
||||||
double &x, double &y) const
|
|
||||||
{
|
|
||||||
if (!pimpl->_known)
|
|
||||||
intersection_type();
|
|
||||||
if (pimpl->_result != POINT)
|
|
||||||
return false;
|
|
||||||
Rcart::Point_2 pt(pimpl->_line.point()
|
|
||||||
+ pimpl->_min*pimpl->_line.direction().to_vector());
|
|
||||||
x = pt.x();
|
|
||||||
y = pt.y();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Bbox_2_Ray_2_pair_impl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Bbox_2_Ray_2_pair_impl():_known(false) {}
|
|
||||||
Bbox_2_Ray_2_pair_impl(Bbox_2 const &bbox, Rcart::Point_2 const &pt,
|
|
||||||
Rcart::Vector_2 const &dir)
|
|
||||||
:_box(bbox), _known(false), _ref_point(pt), _dir(dir), _min(0.0) {}
|
|
||||||
Ray_2< Rcart > _ray;
|
|
||||||
Bbox_2 _box;
|
|
||||||
bool _known;
|
|
||||||
Bbox_2_Ray_2_pair::Intersection_results _result;
|
|
||||||
Rcart::Point_2 _ref_point;
|
|
||||||
Rcart::Vector_2 _dir;
|
|
||||||
double _min, _max;
|
|
||||||
};
|
|
||||||
|
|
||||||
Bbox_2_Ray_2_pair::~Bbox_2_Ray_2_pair()
|
|
||||||
{
|
|
||||||
delete pimpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair()
|
|
||||||
{
|
|
||||||
pimpl = new Bbox_2_Ray_2_pair_impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair(Bbox_2_Ray_2_pair const &o)
|
|
||||||
{
|
|
||||||
pimpl = new Bbox_2_Ray_2_pair_impl(*o.pimpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Ray_2_pair::Bbox_2_Ray_2_pair(
|
|
||||||
Bbox_2 const &bbox, double x, double y, double dx, double dy)
|
|
||||||
{
|
|
||||||
pimpl = new Bbox_2_Ray_2_pair_impl(bbox,
|
|
||||||
Rcart::Point_2(x,y), Rcart::Vector_2(dx,dy));
|
|
||||||
}
|
|
||||||
|
|
||||||
Bbox_2_Ray_2_pair &
|
|
||||||
Bbox_2_Ray_2_pair::operator=(Bbox_2_Ray_2_pair const &o)
|
|
||||||
{
|
|
||||||
*pimpl = *o.pimpl;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Bbox_2_Ray_2_pair::Intersection_results
|
|
||||||
Bbox_2_Ray_2_pair::intersection_type() const
|
|
||||||
{
|
|
||||||
if (pimpl->_known)
|
|
||||||
return pimpl->_result;
|
|
||||||
pimpl->_known = true;
|
|
||||||
bool to_infinity = true;
|
|
||||||
// first on x value
|
|
||||||
if (pimpl->_dir.x() == 0.0) {
|
|
||||||
if (pimpl->_ref_point.x() < pimpl->_box.xmin()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
if (pimpl->_ref_point.x() > pimpl->_box.xmax()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
double newmin, newmax;
|
|
||||||
if (pimpl->_dir.x() > 0.0) {
|
|
||||||
newmin =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
|
||||||
newmax =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
|
||||||
} else {
|
|
||||||
newmin =(pimpl->_box.xmax()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
|
||||||
newmax =(pimpl->_box.xmin()-pimpl->_ref_point.x())/pimpl->_dir.x();
|
|
||||||
}
|
|
||||||
if (newmin > pimpl->_min)
|
|
||||||
pimpl->_min = newmin;
|
|
||||||
if (to_infinity) {
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
} else {
|
|
||||||
if (newmax < pimpl->_max)
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
}
|
|
||||||
if (pimpl->_max < pimpl->_min){
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
to_infinity = false;
|
|
||||||
}
|
|
||||||
// now on y value
|
|
||||||
if (pimpl->_dir.y() == 0.0) {
|
|
||||||
if (pimpl->_ref_point.y() < pimpl->_box.ymin()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
if (pimpl->_ref_point.y() > pimpl->_box.ymax()) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
double newmin, newmax;
|
|
||||||
if (pimpl->_dir.y() > 0.0) {
|
|
||||||
newmin =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
|
||||||
newmax =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
|
||||||
} else {
|
|
||||||
newmin =(pimpl->_box.ymax()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
|
||||||
newmax =(pimpl->_box.ymin()-pimpl->_ref_point.y())/pimpl->_dir.y();
|
|
||||||
}
|
|
||||||
if (newmin > pimpl->_min)
|
|
||||||
pimpl->_min = newmin;
|
|
||||||
if (to_infinity) {
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
} else {
|
|
||||||
if (newmax < pimpl->_max)
|
|
||||||
pimpl->_max = newmax;
|
|
||||||
}
|
|
||||||
if (pimpl->_max < pimpl->_min) {
|
|
||||||
pimpl->_result = NO_INTERSECTION;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
to_infinity = false;
|
|
||||||
}
|
|
||||||
CGAL_kernel_assertion(!to_infinity);
|
|
||||||
if (pimpl->_max == pimpl->_min) {
|
|
||||||
pimpl->_result = POINT;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
pimpl->_result = SEGMENT;
|
|
||||||
return pimpl->_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Bbox_2_Ray_2_pair::
|
|
||||||
intersection(double &x1, double &y1, double &x2, double &y2) const
|
|
||||||
{
|
|
||||||
if (!pimpl->_known)
|
|
||||||
intersection_type();
|
|
||||||
if (pimpl->_result != SEGMENT)
|
|
||||||
return false;
|
|
||||||
Rcart::Point_2 p1(pimpl->_ref_point + pimpl->_min*pimpl->_dir);
|
|
||||||
Rcart::Point_2 p2(pimpl->_ref_point + pimpl->_max*pimpl->_dir);
|
|
||||||
x1 = p1.x();
|
|
||||||
y1 = p1.y();
|
|
||||||
x2 = p2.x();
|
|
||||||
y2 = p2.y();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Bbox_2_Ray_2_pair::intersection(double &x, double &y) const
|
|
||||||
{
|
|
||||||
if (!pimpl->_known)
|
|
||||||
intersection_type();
|
|
||||||
if (pimpl->_result != POINT)
|
|
||||||
return false;
|
|
||||||
Rcart::Point_2 pt = pimpl->_ref_point + pimpl->_min*pimpl->_dir;
|
|
||||||
x = pt.x();
|
|
||||||
y = pt.y();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool do_intersect_ray_2(
|
|
||||||
const Bbox_2 &box, double x, double y, double dx, double dy)
|
|
||||||
{
|
|
||||||
Bbox_2_Ray_2_pair pair(box, x, y, dx, dy);
|
|
||||||
return pair.intersection_type() != Bbox_2_Ray_2_pair::NO_INTERSECTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
|
|
|
||||||
|
|
@ -42,4 +42,8 @@ CGAL_EXPORT extern const Null_vector NULL_VECTOR;
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/Origin_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_ORIGIN_H
|
#endif // CGAL_ORIGIN_H
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
// Copyright (c) 1999
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Andreas Fabri, Stefan Schirra
|
||||||
|
|
||||||
|
#include <CGAL/Origin.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
const Origin ORIGIN = Origin();
|
||||||
|
const Null_vector NULL_VECTOR = Null_vector();
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
|
@ -36,12 +36,16 @@ class Scaling {};
|
||||||
class Reflection {};
|
class Reflection {};
|
||||||
class Identity_transformation {};
|
class Identity_transformation {};
|
||||||
|
|
||||||
CGAL_EXPORT extern Translation TRANSLATION;
|
CGAL_EXPORT extern const Translation TRANSLATION;
|
||||||
CGAL_EXPORT extern Rotation ROTATION;
|
CGAL_EXPORT extern const Rotation ROTATION;
|
||||||
CGAL_EXPORT extern Scaling SCALING;
|
CGAL_EXPORT extern const Scaling SCALING;
|
||||||
CGAL_EXPORT extern Reflection REFLECTION;
|
CGAL_EXPORT extern const Reflection REFLECTION;
|
||||||
CGAL_EXPORT extern Identity_transformation IDENTITY;
|
CGAL_EXPORT extern const Identity_transformation IDENTITY;
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/aff_transformation_tags_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_AFF_TRANSFORMATION_TAGS_H
|
#endif // CGAL_AFF_TRANSFORMATION_TAGS_H
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright (c) 1999
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Andreas Fabri, Stefan Schirra
|
||||||
|
|
||||||
|
#include <CGAL/aff_transformation_tags.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
const Translation TRANSLATION;
|
||||||
|
const Rotation ROTATION;
|
||||||
|
const Scaling SCALING;
|
||||||
|
const Reflection REFLECTION;
|
||||||
|
const Identity_transformation IDENTITY;
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
|
@ -22,18 +22,5 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Andreas Fabri, Stefan Schirra
|
// Author(s) : Andreas Fabri, Stefan Schirra
|
||||||
|
|
||||||
#include <CGAL/Origin.h>
|
#include <CGAL/Origin_impl.h>
|
||||||
#include <CGAL/aff_transformation_tags.h>
|
#include <CGAL/aff_transformation_tags_impl.h>
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
Translation TRANSLATION;
|
|
||||||
Rotation ROTATION;
|
|
||||||
Scaling SCALING;
|
|
||||||
Reflection REFLECTION;
|
|
||||||
Identity_transformation IDENTITY;
|
|
||||||
|
|
||||||
const Origin ORIGIN = Origin();
|
|
||||||
const Null_vector NULL_VECTOR = Null_vector();
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
|
|
|
||||||
|
|
@ -343,4 +343,8 @@ inline bool possibly(Uncertain<bool> c);
|
||||||
// But the macros need CGAL::possibly().
|
// But the macros need CGAL::possibly().
|
||||||
#include <CGAL/Uncertain.h>
|
#include <CGAL/Uncertain.h>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/assertions_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_ASSERTIONS_H
|
#endif // CGAL_ASSERTIONS_H
|
||||||
|
|
|
||||||
|
|
@ -22,201 +22,5 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Geert-Jan Giezeman and Sven Schönherr
|
// Author(s) : Geert-Jan Giezeman and Sven Schönherr
|
||||||
|
|
||||||
#include <CGAL/config.h>
|
|
||||||
#include <CGAL/assertions.h>
|
#include <CGAL/assertions.h>
|
||||||
#include <CGAL/assertions_behaviour.h>
|
#include <CGAL/assertions_impl.h>
|
||||||
#include <CGAL/exceptions.h>
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// behaviour variables
|
|
||||||
// -------------------
|
|
||||||
|
|
||||||
Failure_behaviour _error_behaviour = THROW_EXCEPTION;
|
|
||||||
Failure_behaviour _warning_behaviour = CONTINUE;
|
|
||||||
|
|
||||||
// standard error handlers
|
|
||||||
// -----------------------
|
|
||||||
void
|
|
||||||
_standard_error_handler(
|
|
||||||
const char* what,
|
|
||||||
const char* expr,
|
|
||||||
const char* file,
|
|
||||||
int line,
|
|
||||||
const char* msg )
|
|
||||||
{
|
|
||||||
#if defined(__GNUG__) && !defined(__llvm__)
|
|
||||||
// After g++ 3.4, std::terminate defaults to printing to std::cerr itself.
|
|
||||||
if (_error_behaviour == THROW_EXCEPTION)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
std::cerr << "CGAL error: " << what << " violation!" << std::endl
|
|
||||||
<< "Expression : " << expr << std::endl
|
|
||||||
<< "File : " << file << std::endl
|
|
||||||
<< "Line : " << line << std::endl
|
|
||||||
<< "Explanation: " << msg << std::endl
|
|
||||||
<< "Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// standard warning handler
|
|
||||||
// ------------------------
|
|
||||||
void
|
|
||||||
_standard_warning_handler( const char *,
|
|
||||||
const char* expr,
|
|
||||||
const char* file,
|
|
||||||
int line,
|
|
||||||
const char* msg )
|
|
||||||
{
|
|
||||||
#if defined(__GNUG__) && !defined(__llvm__)
|
|
||||||
// After g++ 3.4, std::terminate defaults to printing to std::cerr itself.
|
|
||||||
if (_warning_behaviour == THROW_EXCEPTION)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
std::cerr << "CGAL warning: check violation!" << std::endl
|
|
||||||
<< "Expression : " << expr << std::endl
|
|
||||||
<< "File : " << file << std::endl
|
|
||||||
<< "Line : " << line << std::endl
|
|
||||||
<< "Explanation: " << msg << std::endl
|
|
||||||
<< "Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// default handler settings
|
|
||||||
// ------------------------
|
|
||||||
Failure_function _error_handler = _standard_error_handler;
|
|
||||||
Failure_function _warning_handler = _standard_warning_handler;
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
// failure functions
|
|
||||||
// -----------------
|
|
||||||
void
|
|
||||||
assertion_fail( const char* expr,
|
|
||||||
const char* file,
|
|
||||||
int line,
|
|
||||||
const char* msg)
|
|
||||||
{
|
|
||||||
_error_handler("assertion", expr, file, line, msg);
|
|
||||||
switch (_error_behaviour) {
|
|
||||||
case ABORT:
|
|
||||||
std::abort();
|
|
||||||
case EXIT:
|
|
||||||
std::exit(1); // EXIT_FAILURE
|
|
||||||
case EXIT_WITH_SUCCESS:
|
|
||||||
std::exit(0); // EXIT_SUCCESS
|
|
||||||
case CONTINUE: // The CONTINUE case should not be used anymore.
|
|
||||||
case THROW_EXCEPTION:
|
|
||||||
default:
|
|
||||||
throw Assertion_exception("CGAL", expr, file, line, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
precondition_fail( const char* expr,
|
|
||||||
const char* file,
|
|
||||||
int line,
|
|
||||||
const char* msg)
|
|
||||||
{
|
|
||||||
_error_handler("precondition", expr, file, line, msg);
|
|
||||||
switch (_error_behaviour) {
|
|
||||||
case ABORT:
|
|
||||||
std::abort();
|
|
||||||
case EXIT:
|
|
||||||
std::exit(1); // EXIT_FAILURE
|
|
||||||
case EXIT_WITH_SUCCESS:
|
|
||||||
std::exit(0); // EXIT_SUCCESS
|
|
||||||
case CONTINUE:
|
|
||||||
case THROW_EXCEPTION:
|
|
||||||
default:
|
|
||||||
throw Precondition_exception("CGAL", expr, file, line, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
postcondition_fail(const char* expr,
|
|
||||||
const char* file,
|
|
||||||
int line,
|
|
||||||
const char* msg)
|
|
||||||
{
|
|
||||||
_error_handler("postcondition", expr, file, line, msg);
|
|
||||||
switch (_error_behaviour) {
|
|
||||||
case ABORT:
|
|
||||||
std::abort();
|
|
||||||
case EXIT:
|
|
||||||
std::exit(1); // EXIT_FAILURE
|
|
||||||
case EXIT_WITH_SUCCESS:
|
|
||||||
std::exit(0); // EXIT_SUCCESS
|
|
||||||
case CONTINUE:
|
|
||||||
case THROW_EXCEPTION:
|
|
||||||
default:
|
|
||||||
throw Postcondition_exception("CGAL", expr, file, line, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// warning function
|
|
||||||
// ----------------
|
|
||||||
void
|
|
||||||
warning_fail( const char* expr,
|
|
||||||
const char* file,
|
|
||||||
int line,
|
|
||||||
const char* msg)
|
|
||||||
{
|
|
||||||
_warning_handler("warning", expr, file, line, msg);
|
|
||||||
switch (_warning_behaviour) {
|
|
||||||
case ABORT:
|
|
||||||
std::abort();
|
|
||||||
case EXIT:
|
|
||||||
std::exit(1); // EXIT_FAILURE
|
|
||||||
case EXIT_WITH_SUCCESS:
|
|
||||||
std::exit(0); // EXIT_SUCCESS
|
|
||||||
case THROW_EXCEPTION:
|
|
||||||
throw Warning_exception("CGAL", expr, file, line, msg);
|
|
||||||
case CONTINUE:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// error handler set functions
|
|
||||||
// ---------------------------
|
|
||||||
Failure_function
|
|
||||||
set_error_handler( Failure_function handler)
|
|
||||||
{
|
|
||||||
Failure_function result = _error_handler;
|
|
||||||
_error_handler = handler;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Failure_function
|
|
||||||
set_warning_handler( Failure_function handler)
|
|
||||||
{
|
|
||||||
Failure_function result = _warning_handler;
|
|
||||||
_warning_handler = handler;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Failure_behaviour
|
|
||||||
set_error_behaviour(Failure_behaviour eb)
|
|
||||||
{
|
|
||||||
Failure_behaviour result = _error_behaviour;
|
|
||||||
_error_behaviour = eb;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Failure_behaviour
|
|
||||||
set_warning_behaviour(Failure_behaviour eb)
|
|
||||||
{
|
|
||||||
Failure_behaviour result = _warning_behaviour;
|
|
||||||
_warning_behaviour = eb;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
|
|
|
||||||
|
|
@ -95,4 +95,8 @@ CGAL_EXPORT extern const Color YELLOW ;
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/Color_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_COLOR_H
|
#endif // CGAL_COLOR_H
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Andreas Fabri, Hervé Brönnimann
|
||||||
|
|
@ -116,5 +116,10 @@ CGAL_EXPORT std::ostream& operator<<( std::ostream& out, const File_header_OFF&
|
||||||
CGAL_EXPORT std::istream& operator>>( std::istream& in, File_header_OFF& h);
|
CGAL_EXPORT std::istream& operator>>( std::istream& in, File_header_OFF& h);
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/File_header_OFF_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_IO_FILE_HEADER_OFF_H //
|
#endif // CGAL_IO_FILE_HEADER_OFF_H //
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,409 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cctype>
|
||||||
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
#include <CGAL/IO/binary_file_io.h>
|
||||||
|
#include <CGAL/IO/File_header_OFF.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <boost/cstdint.hpp>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF::File_header_OFF( bool verbose)
|
||||||
|
: File_header_extended_OFF( verbose),
|
||||||
|
n_vertices(0),
|
||||||
|
n_facets(0),
|
||||||
|
m_skel(false),
|
||||||
|
m_binary(false),
|
||||||
|
m_no_comments(false),
|
||||||
|
m_offset(0),
|
||||||
|
m_colors(false),
|
||||||
|
m_normals(false),
|
||||||
|
m_tag4(false),
|
||||||
|
m_tagDim(false),
|
||||||
|
m_dim(3)
|
||||||
|
{}
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF::File_header_OFF(
|
||||||
|
bool binary, bool noc, bool skel, bool verbose)
|
||||||
|
: File_header_extended_OFF( verbose),
|
||||||
|
n_vertices(0),
|
||||||
|
n_facets(0),
|
||||||
|
m_skel(skel),
|
||||||
|
m_binary(binary),
|
||||||
|
m_no_comments(noc),
|
||||||
|
m_offset(0),
|
||||||
|
m_colors(false),
|
||||||
|
m_normals(false),
|
||||||
|
m_tag4(false),
|
||||||
|
m_tagDim(false),
|
||||||
|
m_dim(3)
|
||||||
|
{}
|
||||||
|
//CGAL_INLINE_FUNCTION
|
||||||
|
//File_header_OFF::File_header_OFF( int v, int h, int f,
|
||||||
|
// bool verbose)
|
||||||
|
//: File_header_extended_OFF( verbose),
|
||||||
|
// n_vertices(v),
|
||||||
|
// n_facets(f),
|
||||||
|
// m_skel(false),
|
||||||
|
// m_binary(false),
|
||||||
|
// m_no_comments(false),
|
||||||
|
// m_offset(0),
|
||||||
|
// m_colors(false),
|
||||||
|
// m_normals(false),
|
||||||
|
// m_tag4(false),
|
||||||
|
// m_tagDim(false),
|
||||||
|
// m_dim(3)
|
||||||
|
//{
|
||||||
|
// set_halfedges(h);
|
||||||
|
//}
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF::File_header_OFF( std::size_t v, std::size_t h, std::size_t f,
|
||||||
|
bool binary, bool noc, bool skel, bool verbose)
|
||||||
|
: File_header_extended_OFF( verbose),
|
||||||
|
n_vertices(v),
|
||||||
|
n_facets(f),
|
||||||
|
m_skel(skel),
|
||||||
|
m_binary(binary),
|
||||||
|
m_no_comments(noc),
|
||||||
|
m_offset(0),
|
||||||
|
m_colors(false),
|
||||||
|
m_normals(false),
|
||||||
|
m_tag4(false),
|
||||||
|
m_tagDim(false),
|
||||||
|
m_dim(3)
|
||||||
|
{
|
||||||
|
set_halfedges(h);
|
||||||
|
}
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF::File_header_OFF(
|
||||||
|
const File_header_extended_OFF& ext_header)
|
||||||
|
: File_header_extended_OFF( ext_header),
|
||||||
|
n_vertices(0),
|
||||||
|
n_facets(0),
|
||||||
|
m_skel(false),
|
||||||
|
m_binary(false),
|
||||||
|
m_no_comments(false),
|
||||||
|
m_offset(0),
|
||||||
|
m_colors(false),
|
||||||
|
m_normals(false),
|
||||||
|
m_tag4(false),
|
||||||
|
m_tagDim(false),
|
||||||
|
m_dim(3)
|
||||||
|
{}
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF::File_header_OFF(
|
||||||
|
const File_header_extended_OFF& ext_header,
|
||||||
|
bool binary, bool noc, bool skel)
|
||||||
|
: File_header_extended_OFF( ext_header),
|
||||||
|
n_vertices(0),
|
||||||
|
n_facets(0),
|
||||||
|
m_skel(skel),
|
||||||
|
m_binary(binary),
|
||||||
|
m_no_comments(noc),
|
||||||
|
m_offset(0),
|
||||||
|
m_colors(false),
|
||||||
|
m_normals(false),
|
||||||
|
m_tag4(false),
|
||||||
|
m_tagDim(false),
|
||||||
|
m_dim(3)
|
||||||
|
{}
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF::File_header_OFF(
|
||||||
|
std::size_t v, std::size_t h, std::size_t f,
|
||||||
|
const File_header_extended_OFF& ext_header)
|
||||||
|
: File_header_extended_OFF( ext_header),
|
||||||
|
n_vertices(v),
|
||||||
|
n_facets(f),
|
||||||
|
m_skel(false),
|
||||||
|
m_binary(false),
|
||||||
|
m_no_comments(false),
|
||||||
|
m_offset(0),
|
||||||
|
m_colors(false),
|
||||||
|
m_normals(false),
|
||||||
|
m_tag4(false),
|
||||||
|
m_tagDim(false),
|
||||||
|
m_dim(3)
|
||||||
|
{
|
||||||
|
set_halfedges(h);
|
||||||
|
}
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF::File_header_OFF(
|
||||||
|
std::size_t v, std::size_t h, std::size_t f,
|
||||||
|
const File_header_extended_OFF& ext_header,
|
||||||
|
bool binary, bool noc, bool skel)
|
||||||
|
: File_header_extended_OFF( ext_header),
|
||||||
|
n_vertices(v),
|
||||||
|
n_facets(f),
|
||||||
|
m_skel(skel),
|
||||||
|
m_binary(binary),
|
||||||
|
m_no_comments(noc),
|
||||||
|
m_offset(0),
|
||||||
|
m_colors(false),
|
||||||
|
m_normals(false),
|
||||||
|
m_tag4(false),
|
||||||
|
m_tagDim(false),
|
||||||
|
m_dim(3)
|
||||||
|
{
|
||||||
|
set_halfedges(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_OFF& File_header_OFF::
|
||||||
|
operator+=( const File_header_OFF& header) {
|
||||||
|
(File_header_extended_OFF&)(*this) = header;
|
||||||
|
n_vertices += header.n_vertices;
|
||||||
|
n_facets += header.n_facets;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write header.
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
std::ostream& operator<<( std::ostream& out, const File_header_OFF& h) {
|
||||||
|
if ( h.comments()) {
|
||||||
|
out << "# Output of a CGAL tool\n";
|
||||||
|
out << static_cast<const File_header_extended_OFF&>( h);
|
||||||
|
}
|
||||||
|
if ( h.has_normals())
|
||||||
|
out << 'N';
|
||||||
|
if ( h.skel())
|
||||||
|
out << "SKEL";
|
||||||
|
else
|
||||||
|
out << "OFF";
|
||||||
|
if ( h.binary()) {
|
||||||
|
out << " BINARY\n";
|
||||||
|
I_Binary_write_big_endian_integer32( out, static_cast<int>(h.size_of_vertices()));
|
||||||
|
I_Binary_write_big_endian_integer32( out, static_cast<int>(h.size_of_facets()));
|
||||||
|
if ( h.off())
|
||||||
|
I_Binary_write_big_endian_integer32( out, 0);
|
||||||
|
} else {
|
||||||
|
out << '\n';
|
||||||
|
out << h.size_of_vertices() << ' '<< h.size_of_facets();
|
||||||
|
if ( h.off())
|
||||||
|
out << " 0";
|
||||||
|
if ( h.comments()) {
|
||||||
|
out << "\n\n# " << h.size_of_vertices() << " vertices\n";
|
||||||
|
out << "# ------------------------------------------\n";
|
||||||
|
}
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan header. Marks streams badbit if not in SKEL format nor in OFF.
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
std::istream& operator>>( std::istream& in, File_header_OFF& h) {
|
||||||
|
// read in the first character and scan for comments, `OFF', or `NOFF',
|
||||||
|
// or `SKEL', or `4SKEL'.
|
||||||
|
h.set_off_header( false);
|
||||||
|
char c;
|
||||||
|
while ( (in >> c) && c == '#') {
|
||||||
|
if ( in.get(c) && c == 'C' &&
|
||||||
|
in.get(c) && c == 'B' &&
|
||||||
|
in.get(c) && c == 'P') {
|
||||||
|
in >> static_cast<File_header_extended_OFF&>( h);
|
||||||
|
} else if ( c != '\n')
|
||||||
|
in >> skip_until_EOL;
|
||||||
|
}
|
||||||
|
if ( ! in)
|
||||||
|
return in;
|
||||||
|
h.set_skel( false);
|
||||||
|
h.set_binary( false);
|
||||||
|
h.set_index_offset( 1);
|
||||||
|
h.set_colors( false);
|
||||||
|
h.set_normals( false);
|
||||||
|
h.set_homogeneous( false);
|
||||||
|
h.set_dimensional( false);
|
||||||
|
h.set_dimension( 3);
|
||||||
|
|
||||||
|
const int max_keyword = 42;
|
||||||
|
char keyword[max_keyword] = "";
|
||||||
|
int i = 0;
|
||||||
|
keyword[i++] = c;
|
||||||
|
while( i < max_keyword - 1 && in.get(c) && std::isalnum(c))
|
||||||
|
keyword[i++] = c;
|
||||||
|
keyword[i] = '\0';
|
||||||
|
if ( i < 2 || (std::isdigit(keyword[0]) && keyword[0] != '4')
|
||||||
|
|| std::isdigit(keyword[1])) {
|
||||||
|
h.set_vertices( std::atoi( keyword));
|
||||||
|
} else {
|
||||||
|
h.set_index_offset( 0);
|
||||||
|
int j = 0;
|
||||||
|
if ( j < i && keyword[j] == 'C') {
|
||||||
|
h.set_colors( true);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
if ( j < i && keyword[j] == 'N') {
|
||||||
|
h.set_normals( true);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
if ( j < i && keyword[j] == '4') {
|
||||||
|
h.set_homogeneous( true);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
if ( j < i && keyword[j] == 'n') {
|
||||||
|
h.set_dimensional( true);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
if ( i-j != 3 || keyword[j] != 'O'
|
||||||
|
|| keyword[j+1] != 'F'
|
||||||
|
|| keyword[j+2] != 'F') {
|
||||||
|
if ( i-j != 4 || keyword[j] != 'S'
|
||||||
|
|| keyword[j+1] != 'K'
|
||||||
|
|| keyword[j+2] != 'E'
|
||||||
|
|| keyword[j+3] != 'L') {
|
||||||
|
in.clear( std::ios::badbit);
|
||||||
|
if ( h.verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "error: File_header_OFF: "
|
||||||
|
"wrong format: neither OFF nor SKEL."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return in;
|
||||||
|
} else {
|
||||||
|
h.set_skel( true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
in >> skip_comment_OFF >> c;
|
||||||
|
if ( std::isdigit(c)) {
|
||||||
|
in.putback(c);
|
||||||
|
int n;
|
||||||
|
in >> n;
|
||||||
|
h.set_vertices(n);
|
||||||
|
} else {
|
||||||
|
i = 0;
|
||||||
|
keyword[i++] = c;
|
||||||
|
while( i < max_keyword - 1 && in.get(c) &&
|
||||||
|
std::isalnum(c))
|
||||||
|
keyword[i++] = c;
|
||||||
|
keyword[i] = '\0';
|
||||||
|
if ( std::strcmp( keyword, "BINARY") == 0) {
|
||||||
|
h.set_binary( true);
|
||||||
|
if ( c != '\n')
|
||||||
|
in >> skip_until_EOL;
|
||||||
|
} else {
|
||||||
|
in.clear( std::ios::badbit);
|
||||||
|
if ( h.verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "error: File_header_OFF(): "
|
||||||
|
"wrong format: neither OFF nor SKEL."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Read remaining size value(s).
|
||||||
|
int n_h;
|
||||||
|
if ( h.binary()) {
|
||||||
|
boost::int32_t a, b, c;
|
||||||
|
I_Binary_read_big_endian_integer32( in, a);
|
||||||
|
if ( h.n_dimensional()) {
|
||||||
|
h.set_dimension( a);
|
||||||
|
I_Binary_read_big_endian_integer32( in, a);
|
||||||
|
}
|
||||||
|
I_Binary_read_big_endian_integer32( in, b);
|
||||||
|
if ( h.off())
|
||||||
|
I_Binary_read_big_endian_integer32( in, c);
|
||||||
|
else
|
||||||
|
c = 0;
|
||||||
|
h.set_vertices( a);
|
||||||
|
if (b<0){
|
||||||
|
in.clear( std::ios::badbit );
|
||||||
|
if ( h.verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "error: File_header_OFF(): File contains < 0 facets."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
h.set_facets( b);
|
||||||
|
n_h = c;
|
||||||
|
} else {
|
||||||
|
int n;
|
||||||
|
if ( h.n_dimensional()) {
|
||||||
|
h.set_dimension( static_cast<int>(h.size_of_vertices()));
|
||||||
|
in >> n;
|
||||||
|
h.set_vertices(n);
|
||||||
|
}
|
||||||
|
in >> n;
|
||||||
|
if (n < 0){
|
||||||
|
in.clear( std::ios::badbit );
|
||||||
|
if ( h.verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "error: File_header_OFF(): File contains < 0 facets."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
h.set_facets(n);
|
||||||
|
if ( h.off())
|
||||||
|
in >> n_h;
|
||||||
|
else
|
||||||
|
n_h = 0;
|
||||||
|
}
|
||||||
|
if ( n_h == 0)
|
||||||
|
h.set_index_offset( 0);
|
||||||
|
if ( ! in || h.size_of_vertices() <= 0 ) {
|
||||||
|
in.clear( std::ios::badbit);
|
||||||
|
if ( h.verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "error: File_header_OFF(): File contains <= 0 vertices."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
if ( h.size_of_halfedges() == 0) {
|
||||||
|
// be careful, because border edges count twice
|
||||||
|
h.set_halfedges( 2 * n_h);
|
||||||
|
// check against the Eulerian equation for connected planar graphs.
|
||||||
|
// We do not know the number of holes we must represent as dummy
|
||||||
|
// facets and we do not know the genus of the surface.
|
||||||
|
// So we add 12 and a factor of 5 percent.
|
||||||
|
if ( h.size_of_halfedges() == 0
|
||||||
|
|| h.size_of_halfedges() > (h.size_of_vertices()
|
||||||
|
+ h.size_of_facets() - 2 + 12) * 2.1
|
||||||
|
|| h.size_of_halfedges() < (h.size_of_vertices()
|
||||||
|
+ h.size_of_facets() - 2) * 2
|
||||||
|
)
|
||||||
|
h.set_halfedges( int((h.size_of_vertices() +
|
||||||
|
h.size_of_facets() - 2 + 12) * 2.1));
|
||||||
|
}
|
||||||
|
h.set_off_header( h.off());
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
// EOF //
|
||||||
|
|
@ -124,5 +124,10 @@ inline std::istream& skip_comment_OFF( std::istream& in) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/File_header_extended_OFF_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_IO_FILE_HEADER_EXTENDED_OFF_H //
|
#endif // CGAL_IO_FILE_HEADER_EXTENDED_OFF_H //
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,212 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/IO/File_header_extended_OFF.h>
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cctype>
|
||||||
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool File_header_extended_OFF::
|
||||||
|
is_POL() const {
|
||||||
|
return is_OFF() && polyhedral_surface();
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool File_header_extended_OFF::
|
||||||
|
is_CBP() const {
|
||||||
|
return is_POL() && triangulated() && non_empty_facets() &&
|
||||||
|
normalized_to_sphere() && radius() <= 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
bool File_header_extended_OFF::
|
||||||
|
is_TRN() const { return is_CBP() && terrain(); }
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
int File_header_extended_OFF::
|
||||||
|
is_CBPn() const {
|
||||||
|
if ( is_POL() && triangulated() && non_empty_facets() &&
|
||||||
|
normalized_to_sphere() && rounded() &&
|
||||||
|
(radius() <= ( 1l << rounded_bits())))
|
||||||
|
return rounded_bits();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
int File_header_extended_OFF::
|
||||||
|
is_TRNn() const { return ( terrain() ? is_CBPn() : 0); }
|
||||||
|
|
||||||
|
|
||||||
|
// The proper file suffix with respect to file format.
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
std::string File_header_extended_OFF::
|
||||||
|
suffix() const {
|
||||||
|
if ( is_TRNn()) {
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "trn" << m_rounded_bits << '\0';
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
if ( is_TRN())
|
||||||
|
return std::string("trn");
|
||||||
|
if ( is_CBPn()) {
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "cbp" << m_rounded_bits << '\0';
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
if ( is_CBP())
|
||||||
|
return std::string("cbp");
|
||||||
|
if ( is_POL())
|
||||||
|
return std::string("pol");
|
||||||
|
return std::string("off");
|
||||||
|
}
|
||||||
|
|
||||||
|
// The proper format name.
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
std::string File_header_extended_OFF::
|
||||||
|
format_name() const {
|
||||||
|
if ( is_TRNn()) {
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "TRN" << m_rounded_bits << '\0';
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
if ( is_TRN())
|
||||||
|
return std::string("TRN");
|
||||||
|
if ( is_CBPn()) {
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "CBP" << m_rounded_bits << '\0';
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
if ( is_CBP())
|
||||||
|
return std::string("CBP");
|
||||||
|
if ( is_POL())
|
||||||
|
return std::string("POL");
|
||||||
|
return std::string("OFF");
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
File_header_extended_OFF& File_header_extended_OFF::
|
||||||
|
operator+=( const File_header_extended_OFF& header) {
|
||||||
|
m_verbose = m_verbose || header.m_verbose;
|
||||||
|
m_polyhedral_surface = m_polyhedral_surface &&
|
||||||
|
header.m_polyhedral_surface;
|
||||||
|
m_halfedges += header.m_halfedges;
|
||||||
|
m_triangulated = m_triangulated && header.m_triangulated;
|
||||||
|
m_non_empty_facets = m_non_empty_facets &&
|
||||||
|
header.m_non_empty_facets;
|
||||||
|
m_terrain = m_terrain && header.m_terrain;
|
||||||
|
m_normalized_to_sphere = m_normalized_to_sphere &&
|
||||||
|
header.m_normalized_to_sphere;
|
||||||
|
m_radius = (std::max)(m_radius, header.m_radius);
|
||||||
|
m_rounded = m_rounded && header.m_rounded;
|
||||||
|
m_rounded_bits = (std::max)( m_rounded_bits,
|
||||||
|
header.m_rounded_bits);
|
||||||
|
m_off_header = m_off_header && header.m_off_header;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CGAL_OUT(item) out << "# " #item " " << h.item() << '\n'
|
||||||
|
#define CGAL_OUTBOOL(item) out << "# " #item " " <<(h.item() ? '1':'0') << '\n'
|
||||||
|
|
||||||
|
// Write extended header incl. CGAL/ENDCBP keywords.
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
std::ostream& operator<<( std::ostream& out,
|
||||||
|
const File_header_extended_OFF& h) {
|
||||||
|
out << "#CBP\n";
|
||||||
|
CGAL_OUTBOOL( polyhedral_surface);
|
||||||
|
CGAL_OUT( halfedges);
|
||||||
|
CGAL_OUTBOOL( triangulated);
|
||||||
|
CGAL_OUTBOOL( non_empty_facets);
|
||||||
|
CGAL_OUTBOOL( terrain);
|
||||||
|
CGAL_OUTBOOL( normalized_to_sphere);
|
||||||
|
CGAL_OUT( radius);
|
||||||
|
CGAL_OUTBOOL( rounded);
|
||||||
|
CGAL_OUT( rounded_bits);
|
||||||
|
out << "# ENDCBP\n" << std::endl;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
#undef CGAL_OUT
|
||||||
|
#undef OUTBOOL
|
||||||
|
|
||||||
|
#define CGAL_IN(item,type) \
|
||||||
|
else if ( std::strcmp( keyword, #item) == 0) { \
|
||||||
|
type t; \
|
||||||
|
in >> t; \
|
||||||
|
h.set_##item( t); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CGAL_INBOOL(item) \
|
||||||
|
else if ( std::strcmp( keyword, #item) == 0) { \
|
||||||
|
in >> c; \
|
||||||
|
h.set_##item( c == '1'); \
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan extended header. The CBP keyword must be read already.
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
std::istream& operator>>( std::istream& in, File_header_extended_OFF& h) {
|
||||||
|
const int max_keyword = 42;
|
||||||
|
char c;
|
||||||
|
char keyword[max_keyword] = "";
|
||||||
|
in >> keyword;
|
||||||
|
while ( in && std::strcmp( keyword, "ENDCBP") != 0) {
|
||||||
|
if ( std::strcmp( keyword, "#") == 0)
|
||||||
|
;
|
||||||
|
CGAL_INBOOL( polyhedral_surface)
|
||||||
|
CGAL_IN( halfedges, int)
|
||||||
|
CGAL_INBOOL( triangulated)
|
||||||
|
CGAL_INBOOL( non_empty_facets)
|
||||||
|
CGAL_INBOOL( terrain)
|
||||||
|
CGAL_INBOOL( normalized_to_sphere)
|
||||||
|
CGAL_IN( radius, double)
|
||||||
|
CGAL_INBOOL( rounded)
|
||||||
|
CGAL_IN( rounded_bits, int)
|
||||||
|
else if ( h.verbose()) {
|
||||||
|
std::cerr << "warning: File_header_extended_OFF: unknown key '"
|
||||||
|
<< keyword << "'." << std::endl;
|
||||||
|
}
|
||||||
|
in >> keyword;
|
||||||
|
}
|
||||||
|
in >> skip_until_EOL >> skip_comment_OFF;
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
#undef CGAL_IN
|
||||||
|
#undef CGAL_INBOOL
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
// EOF //
|
||||||
|
|
@ -462,5 +462,9 @@ file_scan_normal( File_scanner_OFF& scanner, Vector& v) {
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/File_scanner_OFF_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_IO_FILE_SCANNER_OFF_H //
|
#endif // CGAL_IO_FILE_SCANNER_OFF_H //
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <CGAL/IO/binary_file_io.h>
|
||||||
|
#include <CGAL/IO/File_scanner_OFF.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_scanner_OFF::
|
||||||
|
skip_to_next_vertex( std::size_t current_vertex) {
|
||||||
|
CGAL_assertion( current_vertex < size_of_vertices());
|
||||||
|
if ( binary()) {
|
||||||
|
float f;
|
||||||
|
if ( has_normals() && ! normals_read) {
|
||||||
|
I_Binary_read_big_endian_float32( m_in, f);
|
||||||
|
I_Binary_read_big_endian_float32( m_in, f);
|
||||||
|
I_Binary_read_big_endian_float32( m_in, f);
|
||||||
|
if ( is_homogeneous())
|
||||||
|
I_Binary_read_big_endian_float32( m_in, f);
|
||||||
|
}
|
||||||
|
if ( has_colors()) {
|
||||||
|
// It is not well stated in the Geomview manual
|
||||||
|
// how color is coded following a vertex. It is
|
||||||
|
// parsed similar to the optional color for facets.
|
||||||
|
boost::int32_t k;
|
||||||
|
I_Binary_read_big_endian_integer32( m_in, k);
|
||||||
|
if (k<0 || k>4) {
|
||||||
|
m_in.clear( std::ios::badbit);
|
||||||
|
if ( verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "File_scanner_OFF::" << std::endl;
|
||||||
|
std::cerr << "skip_to_next_vertex(): input error: bad "
|
||||||
|
" number of color indices at vertex "
|
||||||
|
<< current_vertex << "." << std::endl;
|
||||||
|
}
|
||||||
|
set_off_header( false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (k--) {
|
||||||
|
float dummy;
|
||||||
|
I_Binary_read_big_endian_float32( m_in, dummy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( has_normals() && ! normals_read) {
|
||||||
|
double dummy;
|
||||||
|
if ( is_homogeneous()) {
|
||||||
|
m_in >> dummy >> dummy >> dummy >> dummy;
|
||||||
|
} else {
|
||||||
|
m_in >> dummy >> dummy >> dummy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( has_colors()) { // skip color entries (1 to 4)
|
||||||
|
m_in >> skip_until_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( ! m_in) {
|
||||||
|
if ( verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "File_scanner_OFF::" << std::endl;
|
||||||
|
std::cerr << "skip_to_next_vertex(): input error: cannot read "
|
||||||
|
"OFF file beyond vertex " << current_vertex << "."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
set_off_header( false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
normals_read = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_scanner_OFF::
|
||||||
|
skip_to_next_facet( std::size_t current_facet) {
|
||||||
|
// Take care of trailing informations like color triples.
|
||||||
|
if ( binary()) {
|
||||||
|
boost::int32_t k;
|
||||||
|
I_Binary_read_big_endian_integer32( m_in, k);
|
||||||
|
if (k<0 || k>4) {
|
||||||
|
m_in.clear( std::ios::badbit);
|
||||||
|
if ( verbose()) {
|
||||||
|
std::cerr << " " << std::endl;
|
||||||
|
std::cerr << "File_scanner_OFF::" << std::endl;
|
||||||
|
std::cerr << "skip_to_next_facet(): input error: bad "
|
||||||
|
"number of color indices at vertex "
|
||||||
|
<< current_facet << "." << std::endl;
|
||||||
|
}
|
||||||
|
set_off_header( false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (k--) {
|
||||||
|
float dummy;
|
||||||
|
I_Binary_read_big_endian_float32( m_in, dummy);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_in >> skip_until_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
// EOF //
|
||||||
|
|
@ -104,5 +104,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/File_writer_OFF_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_IO_FILE_WRITER_OFF_H //
|
#endif // CGAL_IO_FILE_WRITER_OFF_H //
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <CGAL/IO/File_writer_OFF.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_writer_OFF::
|
||||||
|
write_header( std::ostream& o,
|
||||||
|
std::size_t vertices,
|
||||||
|
std::size_t halfedges,
|
||||||
|
std::size_t facets,
|
||||||
|
bool normals) {
|
||||||
|
m_out = &o;
|
||||||
|
m_header.set_vertices( vertices);
|
||||||
|
// Don't. This halfdges aren't trusted:
|
||||||
|
// m_header.set_halfedges( halfedges);
|
||||||
|
(void)halfedges;
|
||||||
|
m_header.set_facets( facets);
|
||||||
|
m_header.set_normals( normals);
|
||||||
|
// Print header.
|
||||||
|
out() << m_header;
|
||||||
|
}
|
||||||
|
} //namespace CGAL
|
||||||
|
// EOF //
|
||||||
|
|
@ -55,5 +55,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/File_writer_VRML_2_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_IO_FILE_WRITER_VRML_2_H //
|
#endif // CGAL_IO_FILE_WRITER_VRML_2_H //
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <CGAL/IO/File_writer_VRML_2.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_writer_VRML_2::
|
||||||
|
write_header( std::ostream& o,
|
||||||
|
std::size_t vertices,
|
||||||
|
std::size_t halfedges,
|
||||||
|
std::size_t facets) {
|
||||||
|
m_out = &o;
|
||||||
|
m_facets = facets;
|
||||||
|
|
||||||
|
out() << " #-- Begin of Polyhedron_3\n";
|
||||||
|
out() << " # " << vertices << " vertices\n";
|
||||||
|
out() << " # " << halfedges << " halfedges\n";
|
||||||
|
out() << " # " << facets << " facets\n";
|
||||||
|
out() << " 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 [" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
File_writer_VRML_2::
|
||||||
|
write_facet_header() const {
|
||||||
|
out() << " ] #point\n"
|
||||||
|
" } #coord Coordinate\n"
|
||||||
|
" coordIndex [" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
File_writer_VRML_2::
|
||||||
|
write_footer() const {
|
||||||
|
out() << " ] #coordIndex\n"
|
||||||
|
" } #geometry\n"
|
||||||
|
" } #Shape\n"
|
||||||
|
" ] #children\n"
|
||||||
|
" } #Group" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
// EOF //
|
||||||
|
|
@ -52,5 +52,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/File_writer_inventor_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_IO_FILE_WRITER_INVENTOR_H //
|
#endif // CGAL_IO_FILE_WRITER_INVENTOR_H //
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/IO/File_writer_inventor.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_writer_inventor::
|
||||||
|
write_header( std::ostream& o,
|
||||||
|
std::size_t vertices,
|
||||||
|
std::size_t halfedges,
|
||||||
|
std::size_t facets){
|
||||||
|
m_out = &o;
|
||||||
|
m_facets = facets;
|
||||||
|
out() << "# " << vertices << " vertices\n";
|
||||||
|
out() << "# " << halfedges << " halfedges\n";
|
||||||
|
out() << "# " << facets << " facets\n\n";
|
||||||
|
out() << "Separator {\n"
|
||||||
|
" Coordinate3 {\n"
|
||||||
|
" point [" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_writer_inventor::
|
||||||
|
write_facet_header() const {
|
||||||
|
out() << " ] #point\n"
|
||||||
|
" } #Coordinate3\n"
|
||||||
|
" # " << m_facets << " facets\n"
|
||||||
|
" IndexedFaceSet {\n"
|
||||||
|
" coordIndex [\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_writer_inventor::
|
||||||
|
write_footer() const {
|
||||||
|
out() << " ] #coordIndex\n"
|
||||||
|
" } #IndexedFaceSet\n"
|
||||||
|
"} #Separator" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
// EOF //
|
||||||
|
|
@ -56,5 +56,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/File_writer_wavefront_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#endif // CGAL_IO_FILE_WRITER_WAVEFRONT_H //
|
#endif // CGAL_IO_FILE_WRITER_WAVEFRONT_H //
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
// 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); you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser 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$
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#define CGAL_INLINE_FUNCTION inline
|
||||||
|
#else
|
||||||
|
#define CGAL_INLINE_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <CGAL/IO/File_writer_wavefront.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
CGAL_INLINE_FUNCTION
|
||||||
|
void
|
||||||
|
File_writer_wavefront::
|
||||||
|
write_header( std::ostream& o,
|
||||||
|
std::size_t vertices,
|
||||||
|
std::size_t halfedges,
|
||||||
|
std::size_t facets){
|
||||||
|
m_out = &o;
|
||||||
|
m_facets = facets;
|
||||||
|
// Print header.
|
||||||
|
out() << "# file written from a CGAL tool in Wavefront obj format\n";
|
||||||
|
out() << "# " << vertices << " vertices\n";
|
||||||
|
out() << "# " << halfedges << " halfedges\n";
|
||||||
|
out() << "# " << facets << " facets\n\n";
|
||||||
|
|
||||||
|
out() << "\n# " << vertices << " vertices\n";
|
||||||
|
out() << "# ------------------------------------------\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
// EOF //
|
||||||
|
|
@ -304,7 +304,9 @@ void swallow(std::istream &is, char d);
|
||||||
CGAL_EXPORT
|
CGAL_EXPORT
|
||||||
void swallow(std::istream &is, const std::string& s );
|
void swallow(std::istream &is, const std::string& s );
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
#include <CGAL/IO/io_impl.h>
|
||||||
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
// Author(s) : Andreas Fabri, Hervé Brönnimann
|
// Author(s) : Andreas Fabri, Hervé Brönnimann
|
||||||
|
|
||||||
#include <CGAL/IO/Color.h>
|
#include <CGAL/IO/Color.h>
|
||||||
|
#include <CGAL/IO/Color_impl.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,371 +22,7 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cctype>
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <CGAL/IO/binary_file_io.h>
|
|
||||||
#include <CGAL/IO/File_header_OFF.h>
|
#include <CGAL/IO/File_header_OFF.h>
|
||||||
#include <algorithm>
|
#include <CGAL/IO/File_header_OFF_impl.h>
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
File_header_OFF::File_header_OFF( bool verbose)
|
|
||||||
: File_header_extended_OFF( verbose),
|
|
||||||
n_vertices(0),
|
|
||||||
n_facets(0),
|
|
||||||
m_skel(false),
|
|
||||||
m_binary(false),
|
|
||||||
m_no_comments(false),
|
|
||||||
m_offset(0),
|
|
||||||
m_colors(false),
|
|
||||||
m_normals(false),
|
|
||||||
m_tag4(false),
|
|
||||||
m_tagDim(false),
|
|
||||||
m_dim(3)
|
|
||||||
{}
|
|
||||||
File_header_OFF::File_header_OFF(
|
|
||||||
bool binary, bool noc, bool skel, bool verbose)
|
|
||||||
: File_header_extended_OFF( verbose),
|
|
||||||
n_vertices(0),
|
|
||||||
n_facets(0),
|
|
||||||
m_skel(skel),
|
|
||||||
m_binary(binary),
|
|
||||||
m_no_comments(noc),
|
|
||||||
m_offset(0),
|
|
||||||
m_colors(false),
|
|
||||||
m_normals(false),
|
|
||||||
m_tag4(false),
|
|
||||||
m_tagDim(false),
|
|
||||||
m_dim(3)
|
|
||||||
{}
|
|
||||||
//File_header_OFF::File_header_OFF( int v, int h, int f,
|
|
||||||
// bool verbose)
|
|
||||||
//: File_header_extended_OFF( verbose),
|
|
||||||
// n_vertices(v),
|
|
||||||
// n_facets(f),
|
|
||||||
// m_skel(false),
|
|
||||||
// m_binary(false),
|
|
||||||
// m_no_comments(false),
|
|
||||||
// m_offset(0),
|
|
||||||
// m_colors(false),
|
|
||||||
// m_normals(false),
|
|
||||||
// m_tag4(false),
|
|
||||||
// m_tagDim(false),
|
|
||||||
// m_dim(3)
|
|
||||||
//{
|
|
||||||
// set_halfedges(h);
|
|
||||||
//}
|
|
||||||
File_header_OFF::File_header_OFF( std::size_t v, std::size_t h, std::size_t f,
|
|
||||||
bool binary, bool noc, bool skel, bool verbose)
|
|
||||||
: File_header_extended_OFF( verbose),
|
|
||||||
n_vertices(v),
|
|
||||||
n_facets(f),
|
|
||||||
m_skel(skel),
|
|
||||||
m_binary(binary),
|
|
||||||
m_no_comments(noc),
|
|
||||||
m_offset(0),
|
|
||||||
m_colors(false),
|
|
||||||
m_normals(false),
|
|
||||||
m_tag4(false),
|
|
||||||
m_tagDim(false),
|
|
||||||
m_dim(3)
|
|
||||||
{
|
|
||||||
set_halfedges(h);
|
|
||||||
}
|
|
||||||
File_header_OFF::File_header_OFF(
|
|
||||||
const File_header_extended_OFF& ext_header)
|
|
||||||
: File_header_extended_OFF( ext_header),
|
|
||||||
n_vertices(0),
|
|
||||||
n_facets(0),
|
|
||||||
m_skel(false),
|
|
||||||
m_binary(false),
|
|
||||||
m_no_comments(false),
|
|
||||||
m_offset(0),
|
|
||||||
m_colors(false),
|
|
||||||
m_normals(false),
|
|
||||||
m_tag4(false),
|
|
||||||
m_tagDim(false),
|
|
||||||
m_dim(3)
|
|
||||||
{}
|
|
||||||
File_header_OFF::File_header_OFF(
|
|
||||||
const File_header_extended_OFF& ext_header,
|
|
||||||
bool binary, bool noc, bool skel)
|
|
||||||
: File_header_extended_OFF( ext_header),
|
|
||||||
n_vertices(0),
|
|
||||||
n_facets(0),
|
|
||||||
m_skel(skel),
|
|
||||||
m_binary(binary),
|
|
||||||
m_no_comments(noc),
|
|
||||||
m_offset(0),
|
|
||||||
m_colors(false),
|
|
||||||
m_normals(false),
|
|
||||||
m_tag4(false),
|
|
||||||
m_tagDim(false),
|
|
||||||
m_dim(3)
|
|
||||||
{}
|
|
||||||
File_header_OFF::File_header_OFF(
|
|
||||||
std::size_t v, std::size_t h, std::size_t f,
|
|
||||||
const File_header_extended_OFF& ext_header)
|
|
||||||
: File_header_extended_OFF( ext_header),
|
|
||||||
n_vertices(v),
|
|
||||||
n_facets(f),
|
|
||||||
m_skel(false),
|
|
||||||
m_binary(false),
|
|
||||||
m_no_comments(false),
|
|
||||||
m_offset(0),
|
|
||||||
m_colors(false),
|
|
||||||
m_normals(false),
|
|
||||||
m_tag4(false),
|
|
||||||
m_tagDim(false),
|
|
||||||
m_dim(3)
|
|
||||||
{
|
|
||||||
set_halfedges(h);
|
|
||||||
}
|
|
||||||
File_header_OFF::File_header_OFF(
|
|
||||||
std::size_t v, std::size_t h, std::size_t f,
|
|
||||||
const File_header_extended_OFF& ext_header,
|
|
||||||
bool binary, bool noc, bool skel)
|
|
||||||
: File_header_extended_OFF( ext_header),
|
|
||||||
n_vertices(v),
|
|
||||||
n_facets(f),
|
|
||||||
m_skel(skel),
|
|
||||||
m_binary(binary),
|
|
||||||
m_no_comments(noc),
|
|
||||||
m_offset(0),
|
|
||||||
m_colors(false),
|
|
||||||
m_normals(false),
|
|
||||||
m_tag4(false),
|
|
||||||
m_tagDim(false),
|
|
||||||
m_dim(3)
|
|
||||||
{
|
|
||||||
set_halfedges(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
File_header_OFF& File_header_OFF::
|
|
||||||
operator+=( const File_header_OFF& header) {
|
|
||||||
(File_header_extended_OFF&)(*this) = header;
|
|
||||||
n_vertices += header.n_vertices;
|
|
||||||
n_facets += header.n_facets;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write header.
|
|
||||||
std::ostream& operator<<( std::ostream& out, const File_header_OFF& h) {
|
|
||||||
if ( h.comments()) {
|
|
||||||
out << "# Output of a CGAL tool\n";
|
|
||||||
out << static_cast<const File_header_extended_OFF&>( h);
|
|
||||||
}
|
|
||||||
if ( h.has_normals())
|
|
||||||
out << 'N';
|
|
||||||
if ( h.skel())
|
|
||||||
out << "SKEL";
|
|
||||||
else
|
|
||||||
out << "OFF";
|
|
||||||
if ( h.binary()) {
|
|
||||||
out << " BINARY\n";
|
|
||||||
I_Binary_write_big_endian_integer32( out, static_cast<int>(h.size_of_vertices()));
|
|
||||||
I_Binary_write_big_endian_integer32( out, static_cast<int>(h.size_of_facets()));
|
|
||||||
if ( h.off())
|
|
||||||
I_Binary_write_big_endian_integer32( out, 0);
|
|
||||||
} else {
|
|
||||||
out << '\n';
|
|
||||||
out << h.size_of_vertices() << ' '<< h.size_of_facets();
|
|
||||||
if ( h.off())
|
|
||||||
out << " 0";
|
|
||||||
if ( h.comments()) {
|
|
||||||
out << "\n\n# " << h.size_of_vertices() << " vertices\n";
|
|
||||||
out << "# ------------------------------------------\n";
|
|
||||||
}
|
|
||||||
out << std::endl;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scan header. Marks streams badbit if not in SKEL format nor in OFF.
|
|
||||||
std::istream& operator>>( std::istream& in, File_header_OFF& h) {
|
|
||||||
// read in the first character and scan for comments, `OFF', or `NOFF',
|
|
||||||
// or `SKEL', or `4SKEL'.
|
|
||||||
h.set_off_header( false);
|
|
||||||
char c;
|
|
||||||
while ( (in >> c) && c == '#') {
|
|
||||||
if ( in.get(c) && c == 'C' &&
|
|
||||||
in.get(c) && c == 'B' &&
|
|
||||||
in.get(c) && c == 'P') {
|
|
||||||
in >> static_cast<File_header_extended_OFF&>( h);
|
|
||||||
} else if ( c != '\n')
|
|
||||||
in >> skip_until_EOL;
|
|
||||||
}
|
|
||||||
if ( ! in)
|
|
||||||
return in;
|
|
||||||
h.set_skel( false);
|
|
||||||
h.set_binary( false);
|
|
||||||
h.set_index_offset( 1);
|
|
||||||
h.set_colors( false);
|
|
||||||
h.set_normals( false);
|
|
||||||
h.set_homogeneous( false);
|
|
||||||
h.set_dimensional( false);
|
|
||||||
h.set_dimension( 3);
|
|
||||||
|
|
||||||
const int max_keyword = 42;
|
|
||||||
char keyword[max_keyword] = "";
|
|
||||||
int i = 0;
|
|
||||||
keyword[i++] = c;
|
|
||||||
while( i < max_keyword - 1 && in.get(c) && std::isalnum(c))
|
|
||||||
keyword[i++] = c;
|
|
||||||
keyword[i] = '\0';
|
|
||||||
if ( i < 2 || (std::isdigit(keyword[0]) && keyword[0] != '4')
|
|
||||||
|| std::isdigit(keyword[1])) {
|
|
||||||
h.set_vertices( std::atoi( keyword));
|
|
||||||
} else {
|
|
||||||
h.set_index_offset( 0);
|
|
||||||
int j = 0;
|
|
||||||
if ( j < i && keyword[j] == 'C') {
|
|
||||||
h.set_colors( true);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
if ( j < i && keyword[j] == 'N') {
|
|
||||||
h.set_normals( true);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
if ( j < i && keyword[j] == '4') {
|
|
||||||
h.set_homogeneous( true);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
if ( j < i && keyword[j] == 'n') {
|
|
||||||
h.set_dimensional( true);
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
if ( i-j != 3 || keyword[j] != 'O'
|
|
||||||
|| keyword[j+1] != 'F'
|
|
||||||
|| keyword[j+2] != 'F') {
|
|
||||||
if ( i-j != 4 || keyword[j] != 'S'
|
|
||||||
|| keyword[j+1] != 'K'
|
|
||||||
|| keyword[j+2] != 'E'
|
|
||||||
|| keyword[j+3] != 'L') {
|
|
||||||
in.clear( std::ios::badbit);
|
|
||||||
if ( h.verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "error: File_header_OFF: "
|
|
||||||
"wrong format: neither OFF nor SKEL."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
return in;
|
|
||||||
} else {
|
|
||||||
h.set_skel( true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in >> skip_comment_OFF >> c;
|
|
||||||
if ( std::isdigit(c)) {
|
|
||||||
in.putback(c);
|
|
||||||
int n;
|
|
||||||
in >> n;
|
|
||||||
h.set_vertices(n);
|
|
||||||
} else {
|
|
||||||
i = 0;
|
|
||||||
keyword[i++] = c;
|
|
||||||
while( i < max_keyword - 1 && in.get(c) &&
|
|
||||||
std::isalnum(c))
|
|
||||||
keyword[i++] = c;
|
|
||||||
keyword[i] = '\0';
|
|
||||||
if ( std::strcmp( keyword, "BINARY") == 0) {
|
|
||||||
h.set_binary( true);
|
|
||||||
if ( c != '\n')
|
|
||||||
in >> skip_until_EOL;
|
|
||||||
} else {
|
|
||||||
in.clear( std::ios::badbit);
|
|
||||||
if ( h.verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "error: File_header_OFF(): "
|
|
||||||
"wrong format: neither OFF nor SKEL."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Read remaining size value(s).
|
|
||||||
int n_h;
|
|
||||||
if ( h.binary()) {
|
|
||||||
boost::int32_t a, b, c;
|
|
||||||
I_Binary_read_big_endian_integer32( in, a);
|
|
||||||
if ( h.n_dimensional()) {
|
|
||||||
h.set_dimension( a);
|
|
||||||
I_Binary_read_big_endian_integer32( in, a);
|
|
||||||
}
|
|
||||||
I_Binary_read_big_endian_integer32( in, b);
|
|
||||||
if ( h.off())
|
|
||||||
I_Binary_read_big_endian_integer32( in, c);
|
|
||||||
else
|
|
||||||
c = 0;
|
|
||||||
h.set_vertices( a);
|
|
||||||
if (b<0){
|
|
||||||
in.clear( std::ios::badbit );
|
|
||||||
if ( h.verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "error: File_header_OFF(): File contains < 0 facets."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
h.set_facets( b);
|
|
||||||
n_h = c;
|
|
||||||
} else {
|
|
||||||
int n;
|
|
||||||
if ( h.n_dimensional()) {
|
|
||||||
h.set_dimension( static_cast<int>(h.size_of_vertices()));
|
|
||||||
in >> n;
|
|
||||||
h.set_vertices(n);
|
|
||||||
}
|
|
||||||
in >> n;
|
|
||||||
if (n < 0){
|
|
||||||
in.clear( std::ios::badbit );
|
|
||||||
if ( h.verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "error: File_header_OFF(): File contains < 0 facets."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
h.set_facets(n);
|
|
||||||
if ( h.off())
|
|
||||||
in >> n_h;
|
|
||||||
else
|
|
||||||
n_h = 0;
|
|
||||||
}
|
|
||||||
if ( n_h == 0)
|
|
||||||
h.set_index_offset( 0);
|
|
||||||
if ( ! in || h.size_of_vertices() <= 0 ) {
|
|
||||||
in.clear( std::ios::badbit);
|
|
||||||
if ( h.verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "error: File_header_OFF(): File contains <= 0 vertices."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
if ( h.size_of_halfedges() == 0) {
|
|
||||||
// be careful, because border edges count twice
|
|
||||||
h.set_halfedges( 2 * n_h);
|
|
||||||
// check against the Eulerian equation for connected planar graphs.
|
|
||||||
// We do not know the number of holes we must represent as dummy
|
|
||||||
// facets and we do not know the genus of the surface.
|
|
||||||
// So we add 12 and a factor of 5 percent.
|
|
||||||
if ( h.size_of_halfedges() == 0
|
|
||||||
|| h.size_of_halfedges() > (h.size_of_vertices()
|
|
||||||
+ h.size_of_facets() - 2 + 12) * 2.1
|
|
||||||
|| h.size_of_halfedges() < (h.size_of_vertices()
|
|
||||||
+ h.size_of_facets() - 2) * 2
|
|
||||||
)
|
|
||||||
h.set_halfedges( int((h.size_of_vertices() +
|
|
||||||
h.size_of_facets() - 2 + 12) * 2.1));
|
|
||||||
}
|
|
||||||
h.set_off_header( h.off());
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -23,174 +23,6 @@
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
#include <CGAL/IO/File_header_extended_OFF.h>
|
#include <CGAL/IO/File_header_extended_OFF.h>
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/IO/File_header_extended_OFF_impl.h>
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cctype>
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
bool File_header_extended_OFF::
|
|
||||||
is_POL() const {
|
|
||||||
return is_OFF() && polyhedral_surface();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool File_header_extended_OFF::
|
|
||||||
is_CBP() const {
|
|
||||||
return is_POL() && triangulated() && non_empty_facets() &&
|
|
||||||
normalized_to_sphere() && radius() <= 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool File_header_extended_OFF::
|
|
||||||
is_TRN() const { return is_CBP() && terrain(); }
|
|
||||||
|
|
||||||
int File_header_extended_OFF::
|
|
||||||
is_CBPn() const {
|
|
||||||
if ( is_POL() && triangulated() && non_empty_facets() &&
|
|
||||||
normalized_to_sphere() && rounded() &&
|
|
||||||
(radius() <= ( 1l << rounded_bits())))
|
|
||||||
return rounded_bits();
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int File_header_extended_OFF::
|
|
||||||
is_TRNn() const { return ( terrain() ? is_CBPn() : 0); }
|
|
||||||
|
|
||||||
|
|
||||||
// The proper file suffix with respect to file format.
|
|
||||||
std::string File_header_extended_OFF::
|
|
||||||
suffix() const {
|
|
||||||
if ( is_TRNn()) {
|
|
||||||
std::ostringstream out;
|
|
||||||
out << "trn" << m_rounded_bits << '\0';
|
|
||||||
return out.str();
|
|
||||||
}
|
|
||||||
if ( is_TRN())
|
|
||||||
return std::string("trn");
|
|
||||||
if ( is_CBPn()) {
|
|
||||||
std::ostringstream out;
|
|
||||||
out << "cbp" << m_rounded_bits << '\0';
|
|
||||||
return out.str();
|
|
||||||
}
|
|
||||||
if ( is_CBP())
|
|
||||||
return std::string("cbp");
|
|
||||||
if ( is_POL())
|
|
||||||
return std::string("pol");
|
|
||||||
return std::string("off");
|
|
||||||
}
|
|
||||||
|
|
||||||
// The proper format name.
|
|
||||||
std::string File_header_extended_OFF::
|
|
||||||
format_name() const {
|
|
||||||
if ( is_TRNn()) {
|
|
||||||
std::ostringstream out;
|
|
||||||
out << "TRN" << m_rounded_bits << '\0';
|
|
||||||
return out.str();
|
|
||||||
}
|
|
||||||
if ( is_TRN())
|
|
||||||
return std::string("TRN");
|
|
||||||
if ( is_CBPn()) {
|
|
||||||
std::ostringstream out;
|
|
||||||
out << "CBP" << m_rounded_bits << '\0';
|
|
||||||
return out.str();
|
|
||||||
}
|
|
||||||
if ( is_CBP())
|
|
||||||
return std::string("CBP");
|
|
||||||
if ( is_POL())
|
|
||||||
return std::string("POL");
|
|
||||||
return std::string("OFF");
|
|
||||||
}
|
|
||||||
|
|
||||||
File_header_extended_OFF& File_header_extended_OFF::
|
|
||||||
operator+=( const File_header_extended_OFF& header) {
|
|
||||||
m_verbose = m_verbose || header.m_verbose;
|
|
||||||
m_polyhedral_surface = m_polyhedral_surface &&
|
|
||||||
header.m_polyhedral_surface;
|
|
||||||
m_halfedges += header.m_halfedges;
|
|
||||||
m_triangulated = m_triangulated && header.m_triangulated;
|
|
||||||
m_non_empty_facets = m_non_empty_facets &&
|
|
||||||
header.m_non_empty_facets;
|
|
||||||
m_terrain = m_terrain && header.m_terrain;
|
|
||||||
m_normalized_to_sphere = m_normalized_to_sphere &&
|
|
||||||
header.m_normalized_to_sphere;
|
|
||||||
m_radius = (std::max)(m_radius, header.m_radius);
|
|
||||||
m_rounded = m_rounded && header.m_rounded;
|
|
||||||
m_rounded_bits = (std::max)( m_rounded_bits,
|
|
||||||
header.m_rounded_bits);
|
|
||||||
m_off_header = m_off_header && header.m_off_header;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CGAL_OUT(item) out << "# " #item " " << h.item() << '\n'
|
|
||||||
#define CGAL_OUTBOOL(item) out << "# " #item " " <<(h.item() ? '1':'0') << '\n'
|
|
||||||
|
|
||||||
// Write extended header incl. CGAL/ENDCBP keywords.
|
|
||||||
std::ostream& operator<<( std::ostream& out,
|
|
||||||
const File_header_extended_OFF& h) {
|
|
||||||
out << "#CBP\n";
|
|
||||||
CGAL_OUTBOOL( polyhedral_surface);
|
|
||||||
CGAL_OUT( halfedges);
|
|
||||||
CGAL_OUTBOOL( triangulated);
|
|
||||||
CGAL_OUTBOOL( non_empty_facets);
|
|
||||||
CGAL_OUTBOOL( terrain);
|
|
||||||
CGAL_OUTBOOL( normalized_to_sphere);
|
|
||||||
CGAL_OUT( radius);
|
|
||||||
CGAL_OUTBOOL( rounded);
|
|
||||||
CGAL_OUT( rounded_bits);
|
|
||||||
out << "# ENDCBP\n" << std::endl;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
#undef CGAL_OUT
|
|
||||||
#undef OUTBOOL
|
|
||||||
|
|
||||||
#define CGAL_IN(item,type) \
|
|
||||||
else if ( std::strcmp( keyword, #item) == 0) { \
|
|
||||||
type t; \
|
|
||||||
in >> t; \
|
|
||||||
h.set_##item( t); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CGAL_INBOOL(item) \
|
|
||||||
else if ( std::strcmp( keyword, #item) == 0) { \
|
|
||||||
in >> c; \
|
|
||||||
h.set_##item( c == '1'); \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scan extended header. The CBP keyword must be read already.
|
|
||||||
std::istream& operator>>( std::istream& in, File_header_extended_OFF& h) {
|
|
||||||
const int max_keyword = 42;
|
|
||||||
char c;
|
|
||||||
char keyword[max_keyword] = "";
|
|
||||||
in >> keyword;
|
|
||||||
while ( in && std::strcmp( keyword, "ENDCBP") != 0) {
|
|
||||||
if ( std::strcmp( keyword, "#") == 0)
|
|
||||||
;
|
|
||||||
CGAL_INBOOL( polyhedral_surface)
|
|
||||||
CGAL_IN( halfedges, int)
|
|
||||||
CGAL_INBOOL( triangulated)
|
|
||||||
CGAL_INBOOL( non_empty_facets)
|
|
||||||
CGAL_INBOOL( terrain)
|
|
||||||
CGAL_INBOOL( normalized_to_sphere)
|
|
||||||
CGAL_IN( radius, double)
|
|
||||||
CGAL_INBOOL( rounded)
|
|
||||||
CGAL_IN( rounded_bits, int)
|
|
||||||
else if ( h.verbose()) {
|
|
||||||
std::cerr << "warning: File_header_extended_OFF: unknown key '"
|
|
||||||
<< keyword << "'." << std::endl;
|
|
||||||
}
|
|
||||||
in >> keyword;
|
|
||||||
}
|
|
||||||
in >> skip_until_EOL >> skip_comment_OFF;
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
#undef CGAL_IN
|
|
||||||
#undef CGAL_INBOOL
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -22,104 +22,7 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <iostream>
|
|
||||||
#include <CGAL/IO/binary_file_io.h>
|
|
||||||
#include <CGAL/IO/File_scanner_OFF.h>
|
#include <CGAL/IO/File_scanner_OFF.h>
|
||||||
|
#include <CGAL/IO/File_scanner_OFF_impl.h>
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
void
|
|
||||||
File_scanner_OFF::
|
|
||||||
skip_to_next_vertex( std::size_t current_vertex) {
|
|
||||||
CGAL_assertion( current_vertex < size_of_vertices());
|
|
||||||
if ( binary()) {
|
|
||||||
float f;
|
|
||||||
if ( has_normals() && ! normals_read) {
|
|
||||||
I_Binary_read_big_endian_float32( m_in, f);
|
|
||||||
I_Binary_read_big_endian_float32( m_in, f);
|
|
||||||
I_Binary_read_big_endian_float32( m_in, f);
|
|
||||||
if ( is_homogeneous())
|
|
||||||
I_Binary_read_big_endian_float32( m_in, f);
|
|
||||||
}
|
|
||||||
if ( has_colors()) {
|
|
||||||
// It is not well stated in the Geomview manual
|
|
||||||
// how color is coded following a vertex. It is
|
|
||||||
// parsed similar to the optional color for facets.
|
|
||||||
boost::int32_t k;
|
|
||||||
I_Binary_read_big_endian_integer32( m_in, k);
|
|
||||||
if (k<0 || k>4) {
|
|
||||||
m_in.clear( std::ios::badbit);
|
|
||||||
if ( verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "File_scanner_OFF::" << std::endl;
|
|
||||||
std::cerr << "skip_to_next_vertex(): input error: bad "
|
|
||||||
" number of color indices at vertex "
|
|
||||||
<< current_vertex << "." << std::endl;
|
|
||||||
}
|
|
||||||
set_off_header( false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (k--) {
|
|
||||||
float dummy;
|
|
||||||
I_Binary_read_big_endian_float32( m_in, dummy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( has_normals() && ! normals_read) {
|
|
||||||
double dummy;
|
|
||||||
if ( is_homogeneous()) {
|
|
||||||
m_in >> dummy >> dummy >> dummy >> dummy;
|
|
||||||
} else {
|
|
||||||
m_in >> dummy >> dummy >> dummy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( has_colors()) { // skip color entries (1 to 4)
|
|
||||||
m_in >> skip_until_EOL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( ! m_in) {
|
|
||||||
if ( verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "File_scanner_OFF::" << std::endl;
|
|
||||||
std::cerr << "skip_to_next_vertex(): input error: cannot read "
|
|
||||||
"OFF file beyond vertex " << current_vertex << "."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
set_off_header( false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
normals_read = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
File_scanner_OFF::
|
|
||||||
skip_to_next_facet( std::size_t current_facet) {
|
|
||||||
// Take care of trailing informations like color triples.
|
|
||||||
if ( binary()) {
|
|
||||||
boost::int32_t k;
|
|
||||||
I_Binary_read_big_endian_integer32( m_in, k);
|
|
||||||
if (k<0 || k>4) {
|
|
||||||
m_in.clear( std::ios::badbit);
|
|
||||||
if ( verbose()) {
|
|
||||||
std::cerr << " " << std::endl;
|
|
||||||
std::cerr << "File_scanner_OFF::" << std::endl;
|
|
||||||
std::cerr << "skip_to_next_facet(): input error: bad "
|
|
||||||
"number of color indices at vertex "
|
|
||||||
<< current_facet << "." << std::endl;
|
|
||||||
}
|
|
||||||
set_off_header( false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (k--) {
|
|
||||||
float dummy;
|
|
||||||
I_Binary_read_big_endian_float32( m_in, dummy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_in >> skip_until_EOL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -22,28 +22,7 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <CGAL/IO/File_writer_OFF.h>
|
#include <CGAL/IO/File_writer_OFF.h>
|
||||||
|
#include <CGAL/IO/File_writer_OFF_impl.h>
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_OFF::
|
|
||||||
write_header( std::ostream& o,
|
|
||||||
std::size_t vertices,
|
|
||||||
std::size_t halfedges,
|
|
||||||
std::size_t facets,
|
|
||||||
bool normals) {
|
|
||||||
m_out = &o;
|
|
||||||
m_header.set_vertices( vertices);
|
|
||||||
// Don't. This halfdges aren't trusted:
|
|
||||||
// m_header.set_halfedges( halfedges);
|
|
||||||
(void)halfedges;
|
|
||||||
m_header.set_facets( facets);
|
|
||||||
m_header.set_normals( normals);
|
|
||||||
// Print header.
|
|
||||||
out() << m_header;
|
|
||||||
}
|
|
||||||
} //namespace CGAL
|
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -22,54 +22,7 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <CGAL/IO/File_writer_VRML_2.h>
|
#include <CGAL/IO/File_writer_VRML_2.h>
|
||||||
|
#include <CGAL/IO/File_writer_VRML_2_impl.h>
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_VRML_2::
|
|
||||||
write_header( std::ostream& o,
|
|
||||||
std::size_t vertices,
|
|
||||||
std::size_t halfedges,
|
|
||||||
std::size_t facets) {
|
|
||||||
m_out = &o;
|
|
||||||
m_facets = facets;
|
|
||||||
|
|
||||||
out() << " #-- Begin of Polyhedron_3\n";
|
|
||||||
out() << " # " << vertices << " vertices\n";
|
|
||||||
out() << " # " << halfedges << " halfedges\n";
|
|
||||||
out() << " # " << facets << " facets\n";
|
|
||||||
out() << " 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 [" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_VRML_2::
|
|
||||||
write_facet_header() const {
|
|
||||||
out() << " ] #point\n"
|
|
||||||
" } #coord Coordinate\n"
|
|
||||||
" coordIndex [" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_VRML_2::
|
|
||||||
write_footer() const {
|
|
||||||
out() << " ] #coordIndex\n"
|
|
||||||
" } #geometry\n"
|
|
||||||
" } #Shape\n"
|
|
||||||
" ] #children\n"
|
|
||||||
" } #Group" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -23,42 +23,6 @@
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
#include <CGAL/IO/File_writer_inventor.h>
|
#include <CGAL/IO/File_writer_inventor.h>
|
||||||
|
#include <CGAL/IO/File_writer_inventor_impl.h>
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_inventor::
|
|
||||||
write_header( std::ostream& o,
|
|
||||||
std::size_t vertices,
|
|
||||||
std::size_t halfedges,
|
|
||||||
std::size_t facets){
|
|
||||||
m_out = &o;
|
|
||||||
m_facets = facets;
|
|
||||||
out() << "# " << vertices << " vertices\n";
|
|
||||||
out() << "# " << halfedges << " halfedges\n";
|
|
||||||
out() << "# " << facets << " facets\n\n";
|
|
||||||
out() << "Separator {\n"
|
|
||||||
" Coordinate3 {\n"
|
|
||||||
" point [" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_inventor::
|
|
||||||
write_facet_header() const {
|
|
||||||
out() << " ] #point\n"
|
|
||||||
" } #Coordinate3\n"
|
|
||||||
" # " << m_facets << " facets\n"
|
|
||||||
" IndexedFaceSet {\n"
|
|
||||||
" coordIndex [\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_inventor::
|
|
||||||
write_footer() const {
|
|
||||||
out() << " ] #coordIndex\n"
|
|
||||||
" } #IndexedFaceSet\n"
|
|
||||||
"} #Separator" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -22,29 +22,7 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <CGAL/IO/File_writer_wavefront.h>
|
#include <CGAL/IO/File_writer_wavefront.h>
|
||||||
|
#include <CGAL/IO/File_writer_wavefront_impl.h>
|
||||||
|
|
||||||
namespace CGAL {
|
|
||||||
|
|
||||||
void
|
|
||||||
File_writer_wavefront::
|
|
||||||
write_header( std::ostream& o,
|
|
||||||
std::size_t vertices,
|
|
||||||
std::size_t halfedges,
|
|
||||||
std::size_t facets){
|
|
||||||
m_out = &o;
|
|
||||||
m_facets = facets;
|
|
||||||
// Print header.
|
|
||||||
out() << "# file written from a CGAL tool in Wavefront obj format\n";
|
|
||||||
out() << "# " << vertices << " vertices\n";
|
|
||||||
out() << "# " << halfedges << " halfedges\n";
|
|
||||||
out() << "# " << facets << " facets\n\n";
|
|
||||||
|
|
||||||
out() << "\n# " << vertices << " vertices\n";
|
|
||||||
out() << "# ------------------------------------------\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
|
||||||
// EOF //
|
// EOF //
|
||||||
|
|
|
||||||
|
|
@ -22,104 +22,11 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Andreas Fabri
|
// Author(s) : Andreas Fabri
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <CGAL/IO/io.h>
|
#include <CGAL/IO/io.h>
|
||||||
#include <CGAL/assertions.h>
|
#include <CGAL/IO/io_impl.h>
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
int IO::mode = std::ios::xalloc();
|
int IO::mode = std::ios::xalloc();
|
||||||
|
|
||||||
|
|
||||||
IO::Mode
|
|
||||||
get_mode(std::ios& i)
|
|
||||||
{
|
|
||||||
return static_cast<IO::Mode>(i.iword(IO::mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
IO::Mode
|
|
||||||
set_ascii_mode(std::ios& i)
|
|
||||||
{
|
|
||||||
IO::Mode m = get_mode(i);
|
|
||||||
i.iword(IO::mode) = IO::ASCII;
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IO::Mode
|
|
||||||
set_binary_mode(std::ios& i)
|
|
||||||
{
|
|
||||||
IO::Mode m = get_mode(i);
|
|
||||||
i.iword(IO::mode) = IO::BINARY;
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IO::Mode
|
|
||||||
set_pretty_mode(std::ios& i)
|
|
||||||
{
|
|
||||||
IO::Mode m = get_mode(i);
|
|
||||||
i.iword(IO::mode) = IO::PRETTY;
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
IO::Mode
|
|
||||||
set_mode(std::ios& i, IO::Mode m)
|
|
||||||
{
|
|
||||||
IO::Mode old = get_mode(i);
|
|
||||||
i.iword(IO::mode) = m;
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
is_pretty(std::ios& i)
|
|
||||||
{
|
|
||||||
return i.iword(IO::mode) == IO::PRETTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
is_ascii(std::ios& i)
|
|
||||||
{
|
|
||||||
return i.iword(IO::mode) == IO::ASCII;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
is_binary(std::ios& i)
|
|
||||||
{
|
|
||||||
return i.iword(IO::mode) == IO::BINARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char*
|
|
||||||
mode_name( IO::Mode m) {
|
|
||||||
static const char* const names[] = {"ASCII", "PRETTY", "BINARY" };
|
|
||||||
CGAL_assertion( IO::ASCII <= m && m <= IO::BINARY );
|
|
||||||
return names[m];
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swallow(std::istream &is, char d) {
|
|
||||||
char c;
|
|
||||||
do is.get(c); while (isspace(c));
|
|
||||||
if (c != d) {
|
|
||||||
std::stringstream msg;
|
|
||||||
msg << "input error: expected '" << d << "' but got '" << c << "'";
|
|
||||||
CGAL_error_msg( msg.str().c_str() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swallow(std::istream &is, const std::string& s ) {
|
|
||||||
std::string t;
|
|
||||||
is >> t;
|
|
||||||
if (s != t) {
|
|
||||||
std::stringstream msg;
|
|
||||||
msg << "input error: expected '" << s << "' but got '" << t << "'";
|
|
||||||
CGAL_error_msg( msg.str().c_str() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue