mirror of https://github.com/CGAL/cgal
almost fix the example with tet remeshing
This commit is contained in:
parent
e88f04acd9
commit
8a3c91c8cc
|
|
@ -11,11 +11,10 @@
|
|||
#include <CGAL/draw_triangulation_3.h>
|
||||
|
||||
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using Vb = CGAL::Constrained_Delaunay_triangulation_vertex_base_3<K, CGAL::Tetrahedral_remeshing::Remeshing_vertex_base_3<K>>;
|
||||
using Cb = CGAL::Constrained_Delaunay_triangulation_cell_base_3<K, CGAL::Tetrahedral_remeshing::Remeshing_cell_base_3<K>>;
|
||||
using Vb = CGAL::Constrained_Delaunay_triangulation_vertex_base_3<K>;
|
||||
using Cb = CGAL::Constrained_Delaunay_triangulation_cell_base_3<K>;
|
||||
using Tds = CGAL::Triangulation_data_structure_3<Vb, Cb>;
|
||||
using Tr = CGAL::Triangulation_3<K, Tds>;
|
||||
using CDt = CGAL::Constrained_Delaunay_triangulation_3<K, Tr>;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
#include <CGAL/Constrained_triangulation_3/internal/config.h>
|
||||
|
||||
#include <CGAL/Base_with_time_stamp.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_cell_data_3.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_vertex_base_3.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_cell_base_3.h>
|
||||
#include <CGAL/Triangulation_vertex_base_3.h>
|
||||
#include <CGAL/Triangulation_cell_base_3.h>
|
||||
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
|
||||
|
|
@ -74,6 +74,7 @@
|
|||
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
|
||||
#if 0
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
|
|
@ -170,6 +171,7 @@ namespace CGAL {
|
|||
};
|
||||
|
||||
} // end namespace CGAL
|
||||
#endif // 0
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
@ -524,70 +526,6 @@ concept Range_of_polygon_3 = std::ranges::common_range<Polygons>
|
|||
&& Polygon_3<std::ranges::range_value_t<Polygons>, Kernel>;
|
||||
#endif // concepts
|
||||
|
||||
template <typename Gt, typename Cb = Triangulation_cell_base_3<Gt> >
|
||||
class Constrained_Delaunay_triangulation_cell_base_3
|
||||
: public Base_with_time_stamp<Cb>
|
||||
{
|
||||
using Base = Base_with_time_stamp<Cb>;
|
||||
Constrained_Delaunay_triangulation_cell_data_3 cdt_3_data_;
|
||||
public:
|
||||
// To get correct cell type in TDS
|
||||
template < class TDS3 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Cb::template Rebind_TDS<TDS3>::Other Cb3;
|
||||
typedef Constrained_Delaunay_triangulation_cell_base_3 <Gt, Cb3> Other;
|
||||
};
|
||||
|
||||
// Constructor
|
||||
using Base::Base;
|
||||
|
||||
Constrained_Delaunay_triangulation_cell_data_3& cdt_3_data() {
|
||||
return cdt_3_data_;
|
||||
}
|
||||
|
||||
const Constrained_Delaunay_triangulation_cell_data_3& cdt_3_data() const {
|
||||
return cdt_3_data_;
|
||||
}
|
||||
|
||||
static std::string io_signature() {
|
||||
return Get_io_signature<Base>()() + "+(" + Get_io_signature<int>()()
|
||||
+ ")[4]";
|
||||
}
|
||||
|
||||
friend std::ostream&
|
||||
operator<<(std::ostream& os,
|
||||
const Constrained_Delaunay_triangulation_cell_base_3& c)
|
||||
{
|
||||
os << static_cast<const Base&>(c);
|
||||
for( unsigned li = 0; li < 4; ++li ) {
|
||||
if(IO::is_ascii(os)) {
|
||||
os << " " << c.cdt_3_data().face_id[li];
|
||||
} else {
|
||||
CGAL::write(os, c.cdt_3_data().face_id[li]);
|
||||
}
|
||||
}
|
||||
return os;
|
||||
}
|
||||
friend std::istream&
|
||||
operator>>(std::istream& is,
|
||||
Constrained_Delaunay_triangulation_cell_base_3& c)
|
||||
{
|
||||
is >> static_cast<Base&>(c);
|
||||
if(!is) return is;
|
||||
for( int li = 0; li < 4; ++li ) {
|
||||
int i;
|
||||
if(IO::is_ascii(is)) {
|
||||
is >> i;
|
||||
} else {
|
||||
CGAL::read(is, i);
|
||||
}
|
||||
if(!is) return is;
|
||||
c.face_id[li] = i;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
};
|
||||
|
||||
template <class DSC, bool Const>
|
||||
struct Output_rep<CGAL::internal::CC_iterator<DSC, Const>, With_point_and_info_tag>
|
||||
: public Output_rep<CGAL::internal::CC_iterator<DSC, Const>>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef CGAL_CONSTRAINED_DELAUNAY_TRIANGULATION_CELL_BASE_3_H
|
||||
#define CGAL_CONSTRAINED_DELAUNAY_TRIANGULATION_CELL_BASE_3_H
|
||||
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_cell_data_3.h>
|
||||
#include <CGAL/Triangulation_cell_base_3.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -43,9 +44,93 @@ namespace CGAL {
|
|||
*
|
||||
* \sa `CGAL::Constrained_Delaunay_triangulation_vertex_base_3`
|
||||
*/
|
||||
template < typename Gt, typename Cb = Triangulation_cell_base_3<Gt> >
|
||||
class Constrained_Delaunay_triangulation_cell_base_3 : public Cb {
|
||||
template <typename Gt, typename Cb = Triangulation_cell_base_3<Gt> >
|
||||
class Constrained_Delaunay_triangulation_cell_base_3
|
||||
: public Base_with_time_stamp<Cb>
|
||||
{
|
||||
using Base = Base_with_time_stamp<Cb>;
|
||||
Constrained_Delaunay_triangulation_cell_data_3 cdt_3_data_;
|
||||
|
||||
mutable bool sliver_cache_validity_ = false;
|
||||
CDT_3_face_index subdomain_index_ = -1;
|
||||
double sliver_value_ = 0.;
|
||||
public:
|
||||
// To get correct cell type in TDS
|
||||
template < class TDS3 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Cb::template Rebind_TDS<TDS3>::Other Cb3;
|
||||
typedef Constrained_Delaunay_triangulation_cell_base_3 <Gt, Cb3> Other;
|
||||
};
|
||||
|
||||
// Constructors inherited from the base class
|
||||
using Base::Base;
|
||||
|
||||
Constrained_Delaunay_triangulation_cell_data_3& cdt_3_data() {
|
||||
return cdt_3_data_;
|
||||
}
|
||||
|
||||
const Constrained_Delaunay_triangulation_cell_data_3& cdt_3_data() const {
|
||||
return cdt_3_data_;
|
||||
}
|
||||
|
||||
// model of SimplicialMeshCellBase_3
|
||||
using Surface_patch_index = CDT_3_face_index;
|
||||
using Subdomain_index = CDT_3_face_index;
|
||||
bool is_facet_on_surface(int i) const { return cdt_3_data().is_facet_constrained(i); }
|
||||
Surface_patch_index surface_patch_index(int i) const { return cdt_3_data().face_constraint_index(i) + 1; }
|
||||
void set_surface_patch_index(int i, Surface_patch_index index) { cdt_3_data().face_id[unsigned(i)] = index - 1; }
|
||||
Subdomain_index subdomain_index() const { return subdomain_index_; }
|
||||
void set_subdomain_index(Subdomain_index i) { subdomain_index_ = i; }
|
||||
|
||||
// model of RemeshingCellBase_3
|
||||
void set_sliver_value(double value) {
|
||||
sliver_cache_validity_ = true;
|
||||
sliver_value_ = value;
|
||||
}
|
||||
double sliver_value() const {
|
||||
CGAL_assertion(is_cache_valid());
|
||||
return sliver_value_;
|
||||
}
|
||||
bool is_cache_valid() const { return sliver_cache_validity_; }
|
||||
void reset_cache_validity() const { sliver_cache_validity_ = false; }
|
||||
|
||||
static std::string io_signature() {
|
||||
return Get_io_signature<Base>()() + "+(" + Get_io_signature<int>()()
|
||||
+ ")[4]";
|
||||
}
|
||||
|
||||
friend std::ostream&
|
||||
operator<<(std::ostream& os,
|
||||
const Constrained_Delaunay_triangulation_cell_base_3& c)
|
||||
{
|
||||
os << static_cast<const Base&>(c);
|
||||
for( unsigned li = 0; li < 4; ++li ) {
|
||||
if(IO::is_ascii(os)) {
|
||||
os << " " << c.cdt_3_data().face_id[li];
|
||||
} else {
|
||||
CGAL::write(os, c.cdt_3_data().face_id[li]);
|
||||
}
|
||||
}
|
||||
return os;
|
||||
}
|
||||
friend std::istream&
|
||||
operator>>(std::istream& is,
|
||||
Constrained_Delaunay_triangulation_cell_base_3& c)
|
||||
{
|
||||
is >> static_cast<Base&>(c);
|
||||
if(!is) return is;
|
||||
for( int li = 0; li < 4; ++li ) {
|
||||
int i;
|
||||
if(IO::is_ascii(is)) {
|
||||
is >> i;
|
||||
} else {
|
||||
CGAL::read(is, i);
|
||||
}
|
||||
if(!is) return is;
|
||||
c.face_id[li] = i;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ template < typename Gt, typename Vb = Triangulation_vertex_base_3<Gt> >
|
|||
class Constrained_Delaunay_triangulation_vertex_base_3 : public Base_with_time_stamp<Vb>
|
||||
{
|
||||
Constrained_Delaunay_triangulation_vertex_data_3 cdt_3_data_;
|
||||
bool cache_validity_ = false;
|
||||
CDT_3_face_index index_ = 0;
|
||||
int dim_ = -1;
|
||||
std::size_t number_of_incident_facets_ = 0;
|
||||
std::size_t number_of_components_ = 0;
|
||||
|
||||
public:
|
||||
// To get correct vertex type in TDS
|
||||
template <class TDS3> struct Rebind_TDS
|
||||
|
|
@ -56,16 +62,54 @@ public:
|
|||
using Other = Constrained_Delaunay_triangulation_vertex_base_3<Gt, Vb3>;
|
||||
};
|
||||
|
||||
// constructors, inherited from the base class
|
||||
using Base = Base_with_time_stamp<Vb>;
|
||||
using Base::Base;
|
||||
|
||||
Constrained_Delaunay_triangulation_vertex_data_3& cdt_3_data() {
|
||||
return cdt_3_data_;
|
||||
// model of SimplicialMeshVertexBase_3
|
||||
using Index = CDT_3_face_index;
|
||||
int in_dimension() const { return dim_; }
|
||||
void set_dimension(int d) { dim_ = d; }
|
||||
Index index() const { return index_; }
|
||||
void set_index(Index i) { index_ = i; }
|
||||
bool is_c2t3_cache_valid() const { return cache_validity_; }
|
||||
void invalidate_c2t3_cache() { cache_validity_ = false; }
|
||||
void set_c2t3_cache(std::size_t i, std::size_t j)
|
||||
{
|
||||
number_of_incident_facets_ = i;
|
||||
number_of_components_ = j;
|
||||
cache_validity_ = true;
|
||||
}
|
||||
std::size_t cached_number_of_incident_facets() const { return number_of_incident_facets_; }
|
||||
std::size_t cached_number_of_components() const { return number_of_components_; }
|
||||
|
||||
void sync() {
|
||||
switch(cdt_3_data().vertex_type()) {
|
||||
case CDT_3_vertex_type::FREE:
|
||||
set_dimension(3);
|
||||
set_index(0);
|
||||
break;
|
||||
case CDT_3_vertex_type::CORNER:
|
||||
set_dimension(0);
|
||||
set_index(0);
|
||||
break;
|
||||
case CDT_3_vertex_type::STEINER_ON_EDGE:
|
||||
set_dimension(1);
|
||||
set_index(0);
|
||||
break;
|
||||
case CDT_3_vertex_type::STEINER_IN_FACE:
|
||||
set_dimension(2);
|
||||
set_index(cdt_3_data().face_index());
|
||||
break;
|
||||
default:
|
||||
CGAL_error();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const Constrained_Delaunay_triangulation_vertex_data_3& cdt_3_data() const {
|
||||
return cdt_3_data_;
|
||||
}
|
||||
// model of ConstrainedDelaunayTriangulationVertexBase_3
|
||||
Constrained_Delaunay_triangulation_vertex_data_3& cdt_3_data() { return cdt_3_data_; }
|
||||
const Constrained_Delaunay_triangulation_vertex_data_3& cdt_3_data() const { return cdt_3_data_; }
|
||||
|
||||
static std::string io_signature() {
|
||||
return Get_io_signature<Vb>()();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include <CGAL/Constrained_triangulation_3/internal/config.h>
|
||||
|
||||
#include <bitset>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
|
|
@ -53,6 +55,7 @@ enum class CDT_3_vertex_marker {
|
|||
|
||||
struct Constrained_Delaunay_triangulation_vertex_data_3 {
|
||||
protected:
|
||||
// TODO: check and improve the compactness of this class
|
||||
CDT_3_vertex_type m_vertex_type = CDT_3_vertex_type::FREE;
|
||||
std::bitset<static_cast<int>(CDT_3_vertex_marker::nb_of_markers)> mark{};
|
||||
union U {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,32 @@ Triangulation_3
|
|||
make_constrained_Delaunay_triangulation_3(const PolygonMesh& mesh, const NamedParams& np = parameters::default_values())
|
||||
{
|
||||
Constrained_Delaunay_triangulation_3<typename Triangulation_3::Geom_traits, Triangulation_3> cdt(mesh, np);
|
||||
return std::move(cdt).triangulation();
|
||||
Triangulation_3 tr = std::move(cdt).triangulation();
|
||||
|
||||
for(auto vh : tr.all_vertex_handles()) {
|
||||
vh->sync();
|
||||
}
|
||||
|
||||
for(auto ch : tr.all_cell_handles()) {
|
||||
ch->set_subdomain_index(1);
|
||||
}
|
||||
|
||||
std::stack<typename Triangulation_3::Cell_handle> stack;
|
||||
stack.push(tr.infinite_cell());
|
||||
while(!stack.empty()) {
|
||||
auto ch = stack.top();
|
||||
stack.pop();
|
||||
ch->set_subdomain_index(0);
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
if(ch->is_facet_on_surface(i)) continue;
|
||||
auto n = ch->neighbor(i);
|
||||
if(n->subdomain_index() == 1) {
|
||||
stack.push(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tr;
|
||||
}
|
||||
|
||||
} // end namespace CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue