mirror of https://github.com/CGAL/cgal
Repair the I/O of Mesh_vertex_3
This commit is contained in:
parent
b64a1718c4
commit
86496e469e
|
|
@ -131,26 +131,29 @@ template<class MD, class K_, class Concurrency_tag,
|
|||
struct Mesh_triangulation_3
|
||||
{
|
||||
private:
|
||||
typedef typename Default::Lazy_get<K_, Kernel_traits<MD> >::type K;
|
||||
using K = typename Default::Lazy_get<K_, Kernel_traits<MD> >::type;
|
||||
|
||||
typedef typename details::Mesh_geom_traits_generator<K>::type Geom_traits;
|
||||
using Geom_traits = typename details::Mesh_geom_traits_generator<K>::type;
|
||||
|
||||
typedef typename Default::Get<
|
||||
using Indices_tuple = Mesh_3::internal::Indices_tuple_t<MD>;
|
||||
using Vertex_base = typename Default::Get<
|
||||
Vertex_base_,
|
||||
Mesh_vertex_generator_3<Geom_traits, typename MD::Index> >::type Vertex_base;
|
||||
typedef typename Default::Get<
|
||||
Mesh_vertex_generator_3<Geom_traits,
|
||||
Indices_tuple,
|
||||
typename MD::Index> >::type;
|
||||
using Cell_base = typename Default::Get<
|
||||
Cell_base_,
|
||||
Compact_mesh_cell_generator_3<Geom_traits,
|
||||
typename MD::Subdomain_index,
|
||||
typename MD::Surface_patch_index,
|
||||
typename MD::Index> >::type Cell_base;
|
||||
typename MD::Index> >::type;
|
||||
|
||||
struct Tds : public Triangulation_data_structure_3<Vertex_base,Cell_base> {};
|
||||
typedef Mesh_3_regular_triangulation_3_wrapper<Geom_traits, Tds> Triangulation;
|
||||
using Triangulation = Mesh_3_regular_triangulation_3_wrapper<Geom_traits, Tds>;;
|
||||
|
||||
public:
|
||||
typedef Triangulation type;
|
||||
typedef type Type;
|
||||
using type = Triangulation;
|
||||
using Type = type;;
|
||||
}; // end struct Mesh_triangulation_3
|
||||
} // end namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
|
||||
#include <CGAL/Regular_triangulation_vertex_base_3.h>
|
||||
#include <CGAL/internal/Mesh_3/get_index.h>
|
||||
#include <CGAL/internal/Mesh_3/indices_management.h>
|
||||
#include <CGAL/Mesh_3/io_signature.h>
|
||||
#include <CGAL/Has_timestamp.h>
|
||||
#include <CGAL/tags.h>
|
||||
|
|
@ -92,8 +92,9 @@ protected:
|
|||
// Adds information to Vb about the localization of the vertex in regards
|
||||
// to the 3D input complex.
|
||||
template<class GT,
|
||||
class Indices_tuple,
|
||||
class Index_,
|
||||
class Vb = Regular_triangulation_vertex_base_3<GT> >
|
||||
class Vb>
|
||||
class Mesh_vertex_3
|
||||
: public Vb,
|
||||
public Mesh_vertex_base_3_base<
|
||||
|
|
@ -257,7 +258,8 @@ public:
|
|||
CGAL_assertion(v.in_dimension() >= -1);
|
||||
CGAL_assertion(v.in_dimension() < 4);
|
||||
Index index =
|
||||
Mesh_3::internal::Read_write_index<Index>()(is, v.in_dimension());
|
||||
Mesh_3::internal::Read_write_index<Indices_tuple,
|
||||
Index>()(is, v.in_dimension());
|
||||
v.set_index(index);
|
||||
return is;
|
||||
}
|
||||
|
|
@ -271,7 +273,8 @@ public:
|
|||
} else {
|
||||
CGAL::write(os, v.in_dimension());
|
||||
}
|
||||
Mesh_3::internal::Read_write_index<Index>()(os,
|
||||
Mesh_3::internal::Read_write_index<Indices_tuple,
|
||||
Index>()(os,
|
||||
v.in_dimension(),
|
||||
v.index());
|
||||
return os;
|
||||
|
|
@ -282,29 +285,32 @@ template<class GT,
|
|||
class MD,
|
||||
class Vb = Regular_triangulation_vertex_base_3<GT> >
|
||||
struct Mesh_vertex_base_3 {
|
||||
typedef internal::Dummy_tds_3 Triangulation_data_structure;
|
||||
typedef Triangulation_data_structure::Vertex_handle Vertex_handle;
|
||||
typedef Triangulation_data_structure::Cell_handle Cell_handle;
|
||||
using Triangulation_data_structure = internal::Dummy_tds_3;
|
||||
using Vertex_handle = typename Triangulation_data_structure::Vertex_handle;
|
||||
using Cell_handle = typename Triangulation_data_structure::Cell_handle;
|
||||
|
||||
template < class TDS3 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Vb::template Rebind_TDS<TDS3>::Other Vb3;
|
||||
typedef Mesh_vertex_3 <GT, typename MD::Index, Vb3> Other;
|
||||
using Vb3 = typename Vb::template Rebind_TDS<TDS3>::Other;
|
||||
using Other = Mesh_vertex_3 <GT,
|
||||
Mesh_3::internal::Indices_tuple_t<MD>,
|
||||
typename MD::Index, Vb3>;
|
||||
};
|
||||
};
|
||||
|
||||
template<class GT,
|
||||
class Indices_tuple,
|
||||
class Index,
|
||||
class Vb = Regular_triangulation_vertex_base_3<GT> >
|
||||
struct Mesh_vertex_generator_3 {
|
||||
typedef internal::Dummy_tds_3 Triangulation_data_structure;
|
||||
typedef Triangulation_data_structure::Vertex_handle Vertex_handle;
|
||||
typedef Triangulation_data_structure::Cell_handle Cell_handle;
|
||||
using Triangulation_data_structure = internal::Dummy_tds_3;
|
||||
using Vertex_handle = typename Triangulation_data_structure::Vertex_handle;
|
||||
using Cell_handle = typename Triangulation_data_structure::Cell_handle;
|
||||
|
||||
template < class TDS3 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Vb::template Rebind_TDS<TDS3>::Other Vb3;
|
||||
typedef Mesh_vertex_3 <GT, Index, Vb3> Other;
|
||||
typedef Mesh_vertex_3 <GT, Indices_tuple, Index, Vb3> Other;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#include <CGAL/Mesh_3/Has_features.h>
|
||||
#include <CGAL/IO/io.h>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Mesh_3 {
|
||||
namespace internal {
|
||||
|
|
@ -51,6 +53,26 @@ struct Index_generator<T, T>
|
|||
typedef Index type;
|
||||
};
|
||||
|
||||
template <typename MD, bool has_feature = Has_features<MD>::value>
|
||||
struct Indices_tuple_generator
|
||||
{
|
||||
using type = std::tuple<typename MD::Subdomain_index,
|
||||
typename MD::Surface_patch_index,
|
||||
typename MD::Curve_index,
|
||||
typename MD::Corner_index
|
||||
>;
|
||||
};
|
||||
|
||||
template <typename MD>
|
||||
struct Indices_tuple_generator<MD, false>
|
||||
{
|
||||
using type = std::tuple<typename MD::Subdomain_index,
|
||||
typename MD::Surface_patch_index>;
|
||||
};
|
||||
|
||||
template <typename MD>
|
||||
using Indices_tuple_t = typename Indices_tuple_generator<MD>::type;
|
||||
|
||||
// Nasty meta-programming to get a boost::variant of four types that
|
||||
// may not be all different.
|
||||
template <typename T0> struct seq1 {
|
||||
|
|
@ -247,7 +269,7 @@ struct Write_mesh_domain_index<Mesh_domain, false> {
|
|||
}; // end template partial specialization
|
||||
// Write_mesh_domain_index<Mesh_domain, false>
|
||||
|
||||
template <typename Index>
|
||||
template <typename, typename Index>
|
||||
struct Read_write_index {
|
||||
void operator()(std::ostream& os, int, Index index) const {
|
||||
if(is_ascii(os)) os << oformat(index);
|
||||
|
|
@ -270,10 +292,10 @@ struct Variant_write_visitor {
|
|||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
template <typename Index>
|
||||
struct Variant_read_visitor {
|
||||
std::istream& is;
|
||||
boost::variant<Args...>& variant;
|
||||
Index& variant;
|
||||
template <typename T>
|
||||
void operator()(T) const {
|
||||
T v;
|
||||
|
|
@ -282,17 +304,25 @@ struct Variant_read_visitor {
|
|||
variant = v;
|
||||
}
|
||||
};
|
||||
template <typename... Args>
|
||||
struct Read_write_index<boost::variant<Args...>> {
|
||||
|
||||
template <typename Indices_types, typename... Args>
|
||||
struct Read_write_index<Indices_types, boost::variant<Args...>> {
|
||||
using Index = boost::variant<Args...>;
|
||||
using index_seq = std::make_index_sequence<sizeof...(Args)>;
|
||||
|
||||
template <std::size_t... Is>
|
||||
Index get_index(int dimension, std::index_sequence<Is...>) const{
|
||||
static const Index variants[] = { std::tuple_element_t<Is, Indices_types>{}... };
|
||||
return variants[3-dimension];
|
||||
}
|
||||
|
||||
void operator()(std::ostream& os, int, Index index) const {
|
||||
Variant_write_visitor visitor{os};
|
||||
apply_visitor(visitor, index);
|
||||
}
|
||||
Index operator()(std::istream& is, int dimension) const {
|
||||
static const Index variants[] = { Args{}... };
|
||||
Index index = variants[dimension];
|
||||
Variant_read_visitor<Args...> visitor{is, index};
|
||||
Index index = get_index(dimension, index_seq{});
|
||||
Variant_read_visitor<Index> visitor{is, index};
|
||||
apply_visitor(visitor, index);
|
||||
return index;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue