Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Mesh_3/doc/Mesh_3/CGAL/Mesh_cell_base_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace CGAL {
Compact_mesh_cell_base_3, because the later has a different API.
-- Laurent Rineau, 2013/10/16
\deprecated This class is deprecated since \cgal 4.3. Use
`CGAL::Compact_mesh_cell_base_3<Gt,MD,Tds>` instead.
`CGAL::Compact_mesh_cell_base_3<Gt,MD,CurveIndex,Tds>` instead.
-->

The class `Mesh_cell_base_3<Gt, MD, Cb>` is a model of the concept `MeshCellBase_3`.
Expand All @@ -29,7 +29,7 @@ of the concept `RegularTriangulationCellBaseWithWeightedCircumcenter_3` and defa
\cgalModels `MeshCellBase_3`

\sa `CGAL::Mesh_complex_3_in_triangulation_3<Tr,CornerIndex,CurveIndex>`
\sa `CGAL::Compact_mesh_cell_base_3<Gt, MD, Tds>`
\sa `CGAL::Compact_mesh_cell_base_3<Gt, MD, CurveIndex,Tds>`

*/
template< typename Gt, typename MD, typename Cb >
Expand Down
2 changes: 1 addition & 1 deletion Mesh_3/doc/Mesh_3/Concepts/MeshCellBase_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ each cell (see below).
\cgalRefines `RegularTriangulationCellBaseWithWeightedCircumcenter_3`
\cgalRefines `CopyConstructible`

\cgalHasModel `CGAL::Compact_mesh_cell_base_3<Gt,MD,Tds>`
\cgalHasModel `CGAL::Compact_mesh_cell_base_3<Gt,MD,CurveIndex,Tds>`
\cgalHasModel `CGAL::Mesh_cell_base_3<Gt,MD,Cb>`

\sa `CGAL::make_mesh_3()`
Expand Down
94 changes: 84 additions & 10 deletions Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class Compact_mesh_cell_base_3_base<GT, Parallel_tag>
// Adds information to Cb about the cell of the input complex containing it
template< class GT,
class MD,
class CurveIndex = int,
class TDS = void >
class Compact_mesh_cell_base_3
: public Compact_mesh_cell_base_3_base<GT, typename TDS::Concurrency_tag>
Expand All @@ -281,7 +282,7 @@ class Compact_mesh_cell_base_3

template <typename TDS2>
struct Rebind_TDS {
typedef Compact_mesh_cell_base_3<GT, MD, TDS2> Other;
typedef Compact_mesh_cell_base_3<GT, MD, CurveIndex, TDS2> Other;
};


Expand Down Expand Up @@ -679,6 +680,77 @@ class Compact_mesh_cell_base_3
}
///@}

/// Store the curve index of the edges inside the cell for I/O
/// @{
//indices in cis:
//i\j 0 1 2 3
// |---------
//0| - 0 1 2
//1| 0 - 3 4
//2| 1 3 - 5
//3| 2 4 5 -
//
void set_curve_index(std::size_t i, std::size_t j, CurveIndex c)
{
CGAL_assertion(i != j);
if(i<j)
cis[i==0 ? j-1 : j+i] = c;
else
cis[j==0 ? i-1 : i+j] = c;
}

CurveIndex get_curve_index(std::size_t i, std::size_t j)const
{
CGAL_assertion(i != j);
if(i<j)
return cis[i==0 ? j-1 : j+i];
else
return cis[j==0 ? i-1 : i+j];
}

///save extra data per cell
std::ostream& write_data(std::ostream& os,
const CGAL::Unique_hash_map<Vertex_handle, std::size_t > &
)const
{
for (std::size_t i =0; i< 3; ++i)
for (std::size_t j =i+1; j< 4; ++j)
{
if(is_ascii(os))
{
os << get_curve_index(i,j);
if(i == 2 && j == 3 )
os<<"\n";
else
os<<" ";
}
else
{
write(os, get_curve_index(i,j));
}
}
return os;
}

///load extra data per cell
std::istream& read_data(std::istream& is,
std::vector<Cell_handle>&,
std::vector<Vertex_handle>&)
{
int c =0;
for (std::size_t i =0; i< 3; ++i)
for (std::size_t j =i+1; j< 4; ++j)
{
if(is_ascii(is))
is >> c;
else
read(is, c);
set_curve_index(i,j,c);
}
return is;
}

///@}
private:


Expand Down Expand Up @@ -708,16 +780,17 @@ class Compact_mesh_cell_base_3

TDS_data _tds_data;
mutable bool sliver_cache_validity_;
CurveIndex cis[6];


}; // end class Compact_mesh_cell_base_3

template < class GT, class MT, class Cb >
template < class GT, class MT, class Ci, class Cb >
std::istream&
operator>>(std::istream &is,
Compact_mesh_cell_base_3<GT, MT, Cb> &c)
Compact_mesh_cell_base_3<GT, MT, Ci, Cb> &c)
{
typename Compact_mesh_cell_base_3<GT, MT, Cb>::Subdomain_index index;
typename Compact_mesh_cell_base_3<GT, MT, Ci, Cb>::Subdomain_index index;
if(is_ascii(is))
is >> index;
else
Expand All @@ -726,7 +799,7 @@ operator>>(std::istream &is,
c.set_subdomain_index(index);
for(int i = 0; i < 4; ++i)
{
typename Compact_mesh_cell_base_3<GT, MT, Cb>::Surface_patch_index i2;
typename Compact_mesh_cell_base_3<GT, MT, Ci, Cb>::Surface_patch_index i2;
if(is_ascii(is))
is >> iformat(i2);
else
Expand All @@ -739,10 +812,10 @@ operator>>(std::istream &is,
return is;
}

template < class GT, class MT, class Cb >
template < class GT, class MT, class Ci, class Cb >
std::ostream&
operator<<(std::ostream &os,
const Compact_mesh_cell_base_3<GT, MT, Cb> &c)
const Compact_mesh_cell_base_3<GT, MT, Ci, Cb> &c)
{
if(is_ascii(os))
os << c.subdomain_index();
Expand All @@ -760,17 +833,18 @@ operator<<(std::ostream &os,


// Specialization for void.
template <typename GT, typename MD>
class Compact_mesh_cell_base_3<GT, MD, void>
template <typename GT, typename MD, typename CurveIndex>
class Compact_mesh_cell_base_3<GT, MD, CurveIndex, void>
{
public:
typedef internal::Dummy_tds_3 Triangulation_data_structure;
typedef Triangulation_data_structure::Vertex_handle Vertex_handle;
typedef Triangulation_data_structure::Cell_handle Cell_handle;
template <typename TDS2>
struct Rebind_TDS { typedef Compact_mesh_cell_base_3<GT, MD, TDS2> Other; };
struct Rebind_TDS { typedef Compact_mesh_cell_base_3<GT, MD, CurveIndex, TDS2> Other; };
};


} // end namespace CGAL


Expand Down
14 changes: 13 additions & 1 deletion Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,17 @@ rescan_after_load_of_triangulation() {
add_to_complex(vit, Corner_index(1));
}
}
for(typename Tr::Cell_iterator
cit = this->triangulation().cells_begin(),
end = this->triangulation().cells_end();
cit != end; ++cit)
{
for (std::size_t i =0; i< 3; ++i)
for (std::size_t j =i+1; j< 4; ++j)
{
this->add_to_complex(cit->vertex(static_cast<int>(i)), cit->vertex(static_cast<int>(j)), cit->get_curve_index(i,j));
}
}
Base::rescan_after_load_of_triangulation();
}

Expand All @@ -784,7 +795,8 @@ operator>> (std::istream& is,
typedef typename Mesh_complex_3_in_triangulation_3<Tr,CI_,CSI_>::Concurrency_tag Concurrency_tag;
is >> static_cast<
Mesh_3::Mesh_complex_3_in_triangulation_3_base<Tr, Concurrency_tag>&>(c3t3);
c3t3.rescan_after_load_of_triangulation();
//already done in >>
//c3t3.rescan_after_load_of_triangulation();
return is;
}

Expand Down
13 changes: 7 additions & 6 deletions Mesh_3/include/CGAL/Mesh_triangulation_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ template<class MD,
class K_ = Default,
class Concurrency_tag = Sequential_tag,
class Vertex_base_ = Default,
class Cell_base_ = Default>
class Cell_base_ = Default,
class CurveIndex = int>
struct Mesh_triangulation_3;

// Sequential version (default)
template<class MD, class K_, class Concurrency_tag,
class Vertex_base_, class Cell_base_>
class Vertex_base_, class Cell_base_, class CurveIndex>
struct Mesh_triangulation_3
{
private:
Expand All @@ -140,7 +141,7 @@ struct Mesh_triangulation_3
Mesh_vertex_base_3<Geom_traits, MD> >::type Vertex_base;
typedef typename Default::Get<
Cell_base_,
Compact_mesh_cell_base_3<Geom_traits, MD> >::type Cell_base;
Compact_mesh_cell_base_3<Geom_traits, MD, CurveIndex> >::type Cell_base;

typedef Triangulation_data_structure_3<Vertex_base,Cell_base> Tds;
typedef Mesh_3_regular_triangulation_3_wrapper<Geom_traits, Tds> Triangulation;
Expand All @@ -154,8 +155,8 @@ struct Mesh_triangulation_3
// Parallel version (specialization)
//
template<class MD, class K_,
class Vertex_base_, class Cell_base_>
struct Mesh_triangulation_3<MD, K_, Parallel_tag, Vertex_base_, Cell_base_>
class Vertex_base_, class Cell_base_, class CurveIndex>
struct Mesh_triangulation_3<MD, K_, Parallel_tag, Vertex_base_, Cell_base_, CurveIndex>
{
private:
typedef typename Default::Get<K_, typename Kernel_traits<MD>::Kernel>::type K;
Expand All @@ -167,7 +168,7 @@ struct Mesh_triangulation_3<MD, K_, Parallel_tag, Vertex_base_, Cell_base_>
Mesh_vertex_base_3<Geom_traits, MD> >::type Vertex_base;
typedef typename Default::Get<
Cell_base_,
Compact_mesh_cell_base_3<Geom_traits, MD> >::type Cell_base;
Compact_mesh_cell_base_3<Geom_traits, MD, CurveIndex> >::type Cell_base;

typedef Triangulation_data_structure_3<
Vertex_base, Cell_base, Parallel_tag> Tds;
Expand Down
Binary file modified Mesh_3/test/Mesh_3/data/c3t3_io-hetero.binary.cgal
Binary file not shown.
12 changes: 12 additions & 0 deletions Mesh_3/test/Mesh_3/data/c3t3_io-hetero.cgal
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,15 @@ CGAL c3t3 Triangulation_3(Weighted_point<Point_3>,Vb(Tvb_3+i+boost::variant<enum
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 5 6 0
0 0 0 0 0 0
0 0 0 0 0 0
0 5 6 0 0 0
0 5 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 6 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 5 0 0 0 0
Binary file modified Mesh_3/test/Mesh_3/data/c3t3_io-homo.binary.cgal
Binary file not shown.
12 changes: 12 additions & 0 deletions Mesh_3/test/Mesh_3/data/c3t3_io-homo.cgal
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,15 @@ CGAL c3t3 Triangulation_3(Weighted_point<Point_3>,Vb(Tvb_3+i+i),Cb(i+RTcb_3+(i)[
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 5 6 0
0 0 0 0 0 0
0 0 0 0 0 0
0 5 6 0 0 0
0 5 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 6 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 5 0 0 0 0
22 changes: 16 additions & 6 deletions Mesh_3/test/Mesh_3/test_c3t3_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ struct Test_c3t3_io {
const Tr& t1 = c1.triangulation();
const Tr& t2 = c2.triangulation();
if(t1.number_of_vertices() != t2.number_of_vertices()) {
std::cout<<t1.number_of_vertices()<<" != "<<t2.number_of_vertices()<<std::endl;
assert(false);
return false;
}
Expand Down Expand Up @@ -342,13 +343,17 @@ struct Test_c3t3_io {
<< "\n******end******" << std::endl;
}
stream.seekg(0);

assert(stream);
C3t3 c3t3_bis;
stream >> c3t3_bis;
std::cout << "Content of c3t3_bis:\n"
<< "*****begin*****\n"
<< c3t3_bis
<< "\n******end******" << std::endl;

if(!binary) {
std::cout << "Content of c3t3_bis:\n"
<< "*****begin*****\n"
<< c3t3_bis
<< "\n******end******" << std::endl;
}
assert(stream);

{
Expand All @@ -373,7 +378,6 @@ struct Test_c3t3_io {
assert(ss);
}
if(!check_equality(c3t3, c3t3_bis)) return false;

#ifndef CGAL_LITTLE_ENDIAN
// skip binary I/O with the existing file for big endian
return true;
Expand All @@ -383,7 +387,6 @@ struct Test_c3t3_io {
// skip 32bits architectures as well
return true;
}

{
std::string filename(prefix);
filename += "_new";
Expand Down Expand Up @@ -453,6 +456,13 @@ struct Test_c3t3_io {
v5->set_index(Mesh_domain::get_surface_patch_index_1());
v6->set_dimension(3);
v6->set_index(Mesh_domain::get_sub_domain_index_1());
for (auto cit = c3t3.triangulation().cells_begin();
cit != c3t3.triangulation().cells_end(); ++cit)
{
for(std::size_t i =0; i<3; ++i)
for(std::size_t j =i+1; j<4; ++j)
cit->set_curve_index(i,j,c3t3.curve_index(cit->vertex(static_cast<int>(i)), cit->vertex(static_cast<int>(j))));
}

// then test I/O
return test_io(c3t3, prefix, false) && test_io(c3t3, prefix, true);
Expand Down
31 changes: 31 additions & 0 deletions Stream_support/include/CGAL/IO/has_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2019
// GeometryFactory. All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Maxime Gimeno

#ifndef CGAL_HAS_DATA_H
#define CGAL_HAS_DATA_H
#include <CGAL/Has_member.h>
#include <boost/mpl/if.hpp>
namespace CGAL{
CGAL_GENERATE_MEMBER_DETECTOR(read_data);
CGAL_GENERATE_MEMBER_DETECTOR(write_data);
template <class T>
bool has_extra_data(const T& , typename boost::enable_if<has_read_data<T> >::type* = NULL)
{
return true;
}

template <class T>
bool has_extra_data(const T& , typename boost::enable_if<boost::mpl::not_<has_read_data<T> > >::type* = NULL)
{
return false;
}
}
#endif // CGAL_HAS_DATA_H
Loading