mirror of https://github.com/CGAL/cgal
Fix the I/O of Mesh_complex_3_in_triangulation_3, when the index types are
not all "int". LR part of r61189 from Mesh_3-experimental-GF
This commit is contained in:
parent
c09476db5f
commit
a6f5e84413
|
|
@ -2737,7 +2737,9 @@ Mesh_3/examples/Mesh_3/mesh_3D_image.cpp -text
|
|||
Mesh_3/examples/Mesh_3/mesh_polyhedral_domain.cpp -text
|
||||
Mesh_3/examples/Mesh_3/old_stuff/inputs/cube.mesh -text svneol=unset#application/octet-stream
|
||||
Mesh_3/examples/Mesh_3/old_stuff/inputs/tangle.mesh -text svneol=unset#application/octet-stream
|
||||
Mesh_3/include/CGAL/Mesh_3/Has_features.h -text
|
||||
Mesh_3/include/CGAL/Mesh_3/io_signature.h -text
|
||||
Mesh_3/include/CGAL/internal/Mesh_3/get_index.h -text
|
||||
Mesh_3/package_info/Mesh_3/description.txt -text
|
||||
Mesh_3/package_info/Mesh_3/long_description.txt -text
|
||||
Mesh_3/package_info/Mesh_3/maintainer -text
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
|
||||
// Copyright (c) 2011 GeometryFactory Sarl (France)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
// the terms of the Q Public License version 1.0.
|
||||
// See the file LICENSE.QPL distributed with CGAL.
|
||||
//
|
||||
// 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: https://scm.gforge.inria.fr/svn/cgal/branches/features/Mesh_3-experimental-GF/Mesh_3/include/CGAL/Mesh_3/Has_features.h $
|
||||
// $Id: Has_features.h 61189 2011-02-11 18:09:01Z lrineau $
|
||||
//
|
||||
//
|
||||
// Author(s) : Stéphane Tayeb, Laurent Rineau
|
||||
|
||||
#ifndef CGAL_MESH_3_HAS_FEATURES_H
|
||||
#define CGAL_MESH_3_HAS_FEATURES_H
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <CGAL/tags.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace internal {
|
||||
namespace Mesh_3 {
|
||||
// A type has_Has_features to check if type 'Has_features' is a nested
|
||||
// type of any class
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(Has_features)
|
||||
|
||||
template <typename Mesh_domain,
|
||||
bool has_Has_features = has_Has_features<Mesh_domain>::value>
|
||||
struct Has_features :
|
||||
public CGAL::Boolean_tag<Mesh_domain::Has_features::value>
|
||||
// when Mesh_domain has the nested type Has_features
|
||||
{};
|
||||
|
||||
template <typename Mesh_domain>
|
||||
struct Has_features<Mesh_domain, false> : public CGAL::Tag_false
|
||||
// when Mesh_domain does not have the nested type Has_features
|
||||
{};
|
||||
} // end namespace internal::Mesh_3
|
||||
} // end namespace internal
|
||||
} // end namespace CGAL
|
||||
|
||||
#endif // CGAL_MESH_3_HAS_FEATURES_H
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
#include <CGAL/Bbox_3.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/Mesh_3/io_signature.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Mesh_3 {
|
||||
|
|
@ -475,6 +476,13 @@ public:
|
|||
std::istream &
|
||||
operator>> (std::istream& is,
|
||||
Mesh_complex_3_in_triangulation_3_base<Tr2> &c3t3);
|
||||
|
||||
static
|
||||
std::string io_signature()
|
||||
{
|
||||
return
|
||||
Get_io_signature<Tr>()();
|
||||
}
|
||||
private:
|
||||
// Private date members
|
||||
size_type number_of_facets_;
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ operator<<(std::ostream &os,
|
|||
if(is_ascii(os))
|
||||
os << ' ' << c.surface_patch_index(i);
|
||||
else
|
||||
write(os, static_cast<int>(c.surface_patch_index(i)));
|
||||
write(os, c.surface_patch_index(i));
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@
|
|||
|
||||
#include <CGAL/Triangulation_vertex_base_3.h>
|
||||
#include <CGAL/Surface_mesh_vertex_base_3.h>
|
||||
|
||||
#include <CGAL/Mesh_3/Has_features.h>
|
||||
#include <CGAL/internal/Mesh_3/get_index.h>
|
||||
#include <CGAL/Mesh_3/io_signature.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,169 @@
|
|||
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
// the terms of the Q Public License version 1.0.
|
||||
// See the file LICENSE.QPL distributed with CGAL.
|
||||
//
|
||||
// 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: https://scm.gforge.inria.fr/svn/cgal/branches/features/Mesh_3-experimental-GF/Mesh_3/include/CGAL/internal/Mesh_3/get_index.h $
|
||||
// $Id: get_index.h 67573 2012-02-02 14:54:51Z lrineau $
|
||||
//
|
||||
//
|
||||
// Author(s) : Stéphane Tayeb
|
||||
//
|
||||
//******************************************************************************
|
||||
// File Description :
|
||||
//
|
||||
//
|
||||
//******************************************************************************
|
||||
|
||||
#ifndef CGAL_INTERNAL_MESH_3_GET_INDEX_3_H
|
||||
#define CGAL_INTERNAL_MESH_3_GET_INDEX_3_H
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <CGAL/Mesh_3/Has_features.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal {
|
||||
namespace Mesh_3 {
|
||||
|
||||
|
||||
template <typename T, typename Boost_variant>
|
||||
const T& get_index(const Boost_variant& x,
|
||||
typename boost::disable_if<boost::is_same<T, Boost_variant> >::type * = 0)
|
||||
{ return boost::get<T>(x); }
|
||||
|
||||
template <typename T>
|
||||
const T& get_index(const T& x) { return x; }
|
||||
|
||||
template <typename Mesh_domain,
|
||||
bool has_feature = Has_features<Mesh_domain>::value>
|
||||
struct Read_mesh_domain_index {
|
||||
// here we have has_feature==true
|
||||
|
||||
typedef Mesh_domain MT; // was named "mesh traits" previously
|
||||
|
||||
typename Mesh_domain::Index
|
||||
operator()(int dimension, std::istream& is) const {
|
||||
switch(dimension) {
|
||||
case 0:
|
||||
typename MT::Corner_index ci;
|
||||
if(is_ascii(is)) is >> ci;
|
||||
else CGAL::read(is, ci);
|
||||
return ci;
|
||||
break;
|
||||
case 1:
|
||||
typename MT::Curve_segment_index si;
|
||||
if(is_ascii(is)) is >> si;
|
||||
else CGAL::read(is, si);
|
||||
return si;
|
||||
break;
|
||||
default:
|
||||
return Read_mesh_domain_index<Mesh_domain, false>()(dimension, is);
|
||||
}
|
||||
}
|
||||
}; // end template partial specialization
|
||||
// Read_mesh_domain_index<Mesh_domain, true>
|
||||
|
||||
template <typename Mesh_domain,
|
||||
bool has_feature = Has_features<Mesh_domain>::value>
|
||||
struct Write_mesh_domain_index {
|
||||
// here we have has_feature==true
|
||||
|
||||
typedef Mesh_domain MT; // was named "mesh traits" previously
|
||||
typedef typename MT::Corner_index Ci;
|
||||
typedef typename MT::Curve_segment_index Si;
|
||||
|
||||
void
|
||||
operator()(std::ostream& os, int dimension,
|
||||
const typename Mesh_domain::Index& index) const {
|
||||
switch(dimension) {
|
||||
case 0: {
|
||||
const Ci& ci = get_index<Ci>(index);
|
||||
if(is_ascii(os)) os << ci;
|
||||
else CGAL::write(os, ci);
|
||||
}
|
||||
break;
|
||||
case 1: {
|
||||
const Si& si = get_index<Si>(index);
|
||||
if(is_ascii(os)) os << si;
|
||||
else CGAL::write(os, si);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Write_mesh_domain_index<Mesh_domain, false>()(os, dimension, index);
|
||||
}
|
||||
}
|
||||
}; // end template partial specialization
|
||||
// Write_mesh_domain_index<Mesh_domain, true>
|
||||
|
||||
template <typename Mesh_domain>
|
||||
struct Read_mesh_domain_index<Mesh_domain, false> {
|
||||
// here we have has_feature==false
|
||||
|
||||
typedef Mesh_domain MT; // was named "mesh traits" previously
|
||||
|
||||
typename Mesh_domain::Index
|
||||
operator()(int dimension, std::istream& is) const {
|
||||
switch(dimension) {
|
||||
case 2: {
|
||||
typename MT::Surface_patch_index spi;
|
||||
if(is_ascii(is)) is >> spi;
|
||||
else CGAL::read(is, spi);
|
||||
return spi;
|
||||
}
|
||||
break;
|
||||
default: {// 3
|
||||
typename MT::Subdomain_index di;
|
||||
if(is_ascii(is)) is >> di;
|
||||
else CGAL::read(is, di);
|
||||
return di;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}; // end template partial specialization
|
||||
// Read_mesh_domain_index<Mesh_domain, false>
|
||||
|
||||
template <typename Mesh_domain>
|
||||
struct Write_mesh_domain_index<Mesh_domain, false> {
|
||||
// here we have has_feature==false
|
||||
|
||||
typedef Mesh_domain MT; // was named "mesh traits" previously
|
||||
typedef typename MT::Surface_patch_index Spi;
|
||||
typedef typename MT::Subdomain_index Di;
|
||||
|
||||
void
|
||||
operator()(std::ostream& os, int dimension,
|
||||
const typename Mesh_domain::Index& index) const {
|
||||
switch(dimension) {
|
||||
case 2: {
|
||||
const Spi& spi = get_index<Spi>(index);
|
||||
if(is_ascii(os)) os << spi;
|
||||
else CGAL::write(os, spi);
|
||||
}
|
||||
break;
|
||||
default: {// 3
|
||||
const Di& di = get_index<Di>(index);
|
||||
if(is_ascii(os)) os << di;
|
||||
else CGAL::write(os, di);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}; // end template partial specialization
|
||||
// Write_mesh_domain_index<Mesh_domain, false>
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -29,16 +29,11 @@
|
|||
#include <CGAL/refine_mesh_3.h>
|
||||
#include <CGAL/tags.h>
|
||||
#include <CGAL/Mesh_3/Protect_edges_sizing_field.h>
|
||||
#include <CGAL/Mesh_3/Has_features.h>
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace internal {
|
||||
namespace Mesh_3 {
|
||||
// A type to check if type 'Has_features' is a nested type of any class
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(Has_features)
|
||||
}} // end namespace internal::Mesh_3
|
||||
|
||||
namespace parameters {
|
||||
namespace internal {
|
||||
|
|
|
|||
Loading…
Reference in New Issue