From 4dd34a08d4cb5f475fee7a2ab38f69ce76d4c0a9 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 8 May 2021 17:29:59 +0100 Subject: [PATCH 1/6] Add with_marks parameter to shell_to_nef --- Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h b/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h index 77f024d7fb3..2691e33cda3 100644 --- a/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h +++ b/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h @@ -62,9 +62,10 @@ class Shell_to_nef_3 private: SNC_structure& S; + bool with_marks; public: - Shell_to_nef_3(SNC_structure& S_) : S(S_) {} + Shell_to_nef_3(SNC_structure& S_, bool m_) : S(S_), with_marks(m_) {} void visit(Vertex_const_handle ) {} void visit(Halfedge_const_handle ) {} @@ -83,7 +84,7 @@ class Shell_to_nef_3 Vertex_const_handle pv = sf->center_vertex(); Vertex_handle nv = S.new_vertex(); nv->point() = pv->point(); - nv->mark() = true; + nv->mark() = with_marks ? pv->mark() : true; SM_decorator SM(&*nv); SHalfedge_around_sface_const_circulator @@ -91,7 +92,7 @@ class Shell_to_nef_3 SVertex_handle sv_0 = SM.new_svertex(pe->source()->point()); - sv_0->mark() = true; + sv_0->mark() = with_marks ? pe->source()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS sv_0->set_index(pe->source()->get_index()); #endif @@ -100,7 +101,7 @@ class Shell_to_nef_3 do { SVertex_handle sv = SM.new_svertex(pe->source()->point()); - sv->mark() = true; + sv->mark() = with_marks ? pe->source()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS sv->set_index(pe->source()->get_index()); #endif @@ -108,7 +109,8 @@ class Shell_to_nef_3 SHalfedge_handle e = SM.new_shalfedge_pair(sv_prev, sv); e->circle() = pe_prev->circle(); e->twin()->circle() = pe_prev->twin()->circle(); - e->mark() = e->twin()->mark() = true; + e->mark() = with_marks ? pe_prev->mark() : true; + e->twin()->mark() = with_marks ? pe_prev->twin()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS e->set_index(pe_prev->get_index()); e->twin()->set_index(pe_prev->twin()->get_index()); @@ -123,7 +125,8 @@ class Shell_to_nef_3 e = SM.new_shalfedge_pair(sv_prev, sv_0); e->circle() = pe_prev->circle(); e->twin()->circle() = pe_prev->twin()->circle(); - e->mark() = e->twin()->mark() = true; + e->mark() = with_marks ? pe_prev->mark() : true; + e->twin()->mark() = with_marks ? pe_prev->twin()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS e->set_index(pe_prev->get_index()); e->twin()->set_index(pe_prev->twin()->get_index()); @@ -144,9 +147,10 @@ class Shell_to_nef_3 template void shell_to_nef_3(const Nef_polyhedron& N, typename Nef_polyhedron::SFace_const_handle sf, - typename Nef_polyhedron::SNC_structure& S) + typename Nef_polyhedron::SNC_structure& S, + bool with_marks = false) { - Shell_to_nef_3 s2n(S); + Shell_to_nef_3 s2n(S,with_marks); N.visit_shell_objects(sf, s2n); } From 7fc5f0eb91e2b8978a3684888ac37416fca3b227 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Mon, 3 Jan 2022 13:36:24 +0000 Subject: [PATCH 2/6] Rename with_marks to preserve_marks --- Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h b/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h index 2691e33cda3..8afb0a2aaa8 100644 --- a/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h +++ b/Nef_3/include/CGAL/Nef_3/shell_to_nef_3.h @@ -62,10 +62,10 @@ class Shell_to_nef_3 private: SNC_structure& S; - bool with_marks; + bool preserve_marks; public: - Shell_to_nef_3(SNC_structure& S_, bool m_) : S(S_), with_marks(m_) {} + Shell_to_nef_3(SNC_structure& S_, bool m_) : S(S_), preserve_marks(m_) {} void visit(Vertex_const_handle ) {} void visit(Halfedge_const_handle ) {} @@ -84,7 +84,7 @@ class Shell_to_nef_3 Vertex_const_handle pv = sf->center_vertex(); Vertex_handle nv = S.new_vertex(); nv->point() = pv->point(); - nv->mark() = with_marks ? pv->mark() : true; + nv->mark() = preserve_marks ? pv->mark() : true; SM_decorator SM(&*nv); SHalfedge_around_sface_const_circulator @@ -92,7 +92,7 @@ class Shell_to_nef_3 SVertex_handle sv_0 = SM.new_svertex(pe->source()->point()); - sv_0->mark() = with_marks ? pe->source()->mark() : true; + sv_0->mark() = preserve_marks ? pe->source()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS sv_0->set_index(pe->source()->get_index()); #endif @@ -101,7 +101,7 @@ class Shell_to_nef_3 do { SVertex_handle sv = SM.new_svertex(pe->source()->point()); - sv->mark() = with_marks ? pe->source()->mark() : true; + sv->mark() = preserve_marks ? pe->source()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS sv->set_index(pe->source()->get_index()); #endif @@ -109,8 +109,8 @@ class Shell_to_nef_3 SHalfedge_handle e = SM.new_shalfedge_pair(sv_prev, sv); e->circle() = pe_prev->circle(); e->twin()->circle() = pe_prev->twin()->circle(); - e->mark() = with_marks ? pe_prev->mark() : true; - e->twin()->mark() = with_marks ? pe_prev->twin()->mark() : true; + e->mark() = preserve_marks ? pe_prev->mark() : true; + e->twin()->mark() = preserve_marks ? pe_prev->twin()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS e->set_index(pe_prev->get_index()); e->twin()->set_index(pe_prev->twin()->get_index()); @@ -125,8 +125,8 @@ class Shell_to_nef_3 e = SM.new_shalfedge_pair(sv_prev, sv_0); e->circle() = pe_prev->circle(); e->twin()->circle() = pe_prev->twin()->circle(); - e->mark() = with_marks ? pe_prev->mark() : true; - e->twin()->mark() = with_marks ? pe_prev->twin()->mark() : true; + e->mark() = preserve_marks ? pe_prev->mark() : true; + e->twin()->mark() = preserve_marks ? pe_prev->twin()->mark() : true; #ifndef CGAL_NEF_NO_INDEXED_ITEMS e->set_index(pe_prev->get_index()); e->twin()->set_index(pe_prev->twin()->get_index()); @@ -148,9 +148,9 @@ template void shell_to_nef_3(const Nef_polyhedron& N, typename Nef_polyhedron::SFace_const_handle sf, typename Nef_polyhedron::SNC_structure& S, - bool with_marks = false) + bool preserve_marks = false) { - Shell_to_nef_3 s2n(S,with_marks); + Shell_to_nef_3 s2n(S,preserve_marks); N.visit_shell_objects(sf, s2n); } From 2d2507b3644ee9b232cfb4c3a931bb951d01ffdf Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Mon, 3 Jan 2022 16:01:29 +0000 Subject: [PATCH 3/6] Implement append operation in Nef_polyhedron_3 --- Nef_3/include/CGAL/Nef_3/Append_volumes.h | 42 +++++++++++++++++++++++ Nef_3/include/CGAL/Nef_polyhedron_3.h | 11 ++++++ 2 files changed, 53 insertions(+) create mode 100644 Nef_3/include/CGAL/Nef_3/Append_volumes.h diff --git a/Nef_3/include/CGAL/Nef_3/Append_volumes.h b/Nef_3/include/CGAL/Nef_3/Append_volumes.h new file mode 100644 index 00000000000..69a292fa7c2 --- /dev/null +++ b/Nef_3/include/CGAL/Nef_3/Append_volumes.h @@ -0,0 +1,42 @@ +// Copyright (c) 2022 Max-Planck-Institute Saarbruecken (Germany). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// + +#ifndef CGAL_NEF3_APPEND_VOLUMES_H +#define CGAL_NEF3_APPEND_VOLUMES_H + +#include + + +#include +#include + +namespace CGAL { + +template +class Append_volumes : public Modifier_base +{ + typedef typename Nef_3::SNC_structure SNC_structure; + typedef typename Nef_3::Shell_entry_const_iterator Shell_entry_const_iterator; +public: + Append_volumes (const Nef_3& n) : nef(n) {} + + void operator()(SNC_structure& snc) + { + Shell_entry_const_iterator si; + CGAL_forall_shells_of(si,nef.volumes_begin()) + CGAL::shell_to_nef_3(nef,si,snc); + } +private: + const Nef_3& nef; +}; + +} //namespace CGAL +#endif // CGAL_NEF3_APPEND_VOLUMES_H diff --git a/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Nef_3/include/CGAL/Nef_polyhedron_3.h index 74bb56ba885..48c23dcc085 100644 --- a/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -1441,6 +1442,16 @@ protected: return res; } + Nef_polyhedron_3 + append(const Nef_polyhedron_3& N1) + /*{\Mop returns |\Mvar| with N1 appended }*/ { + CGAL_NEF_TRACEN(" append between nef3 "<<&*this<<" and "<<&N1); + Append_volumes appender(N1); + delegate(appender,true,false); + mark_bounded_volumes(); + return *this; + } + Nef_polyhedron_3 difference(const Nef_polyhedron_3& N1) const /*{\Mop returns |\Mvar| $-$ |N1|. }*/ { From 9f70823aa83261079937c939d8f2b88312e436ee Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Mon, 3 Jan 2022 16:09:52 +0000 Subject: [PATCH 4/6] Use the preserve_marks parameter in Append_volumes --- Nef_3/include/CGAL/Nef_3/Append_volumes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nef_3/include/CGAL/Nef_3/Append_volumes.h b/Nef_3/include/CGAL/Nef_3/Append_volumes.h index 69a292fa7c2..19f609e8d50 100644 --- a/Nef_3/include/CGAL/Nef_3/Append_volumes.h +++ b/Nef_3/include/CGAL/Nef_3/Append_volumes.h @@ -32,7 +32,7 @@ public: { Shell_entry_const_iterator si; CGAL_forall_shells_of(si,nef.volumes_begin()) - CGAL::shell_to_nef_3(nef,si,snc); + CGAL::shell_to_nef_3(nef,si,snc,true); } private: const Nef_3& nef; From 6b1dd03935f5f574be34b7caf873f9ed46126488 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Mon, 7 Feb 2022 19:46:45 +0000 Subject: [PATCH 5/6] Remove need for Append_volumes within append --- Nef_3/include/CGAL/Nef_3/Append_volumes.h | 42 ----------------------- Nef_3/include/CGAL/Nef_polyhedron_3.h | 10 ++++-- 2 files changed, 7 insertions(+), 45 deletions(-) delete mode 100644 Nef_3/include/CGAL/Nef_3/Append_volumes.h diff --git a/Nef_3/include/CGAL/Nef_3/Append_volumes.h b/Nef_3/include/CGAL/Nef_3/Append_volumes.h deleted file mode 100644 index 19f609e8d50..00000000000 --- a/Nef_3/include/CGAL/Nef_3/Append_volumes.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2022 Max-Planck-Institute Saarbruecken (Germany). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// - -#ifndef CGAL_NEF3_APPEND_VOLUMES_H -#define CGAL_NEF3_APPEND_VOLUMES_H - -#include - - -#include -#include - -namespace CGAL { - -template -class Append_volumes : public Modifier_base -{ - typedef typename Nef_3::SNC_structure SNC_structure; - typedef typename Nef_3::Shell_entry_const_iterator Shell_entry_const_iterator; -public: - Append_volumes (const Nef_3& n) : nef(n) {} - - void operator()(SNC_structure& snc) - { - Shell_entry_const_iterator si; - CGAL_forall_shells_of(si,nef.volumes_begin()) - CGAL::shell_to_nef_3(nef,si,snc,true); - } -private: - const Nef_3& nef; -}; - -} //namespace CGAL -#endif // CGAL_NEF3_APPEND_VOLUMES_H diff --git a/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Nef_3/include/CGAL/Nef_polyhedron_3.h index 48c23dcc085..bb9fe4d4844 100644 --- a/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -1446,9 +1445,14 @@ protected: append(const Nef_polyhedron_3& N1) /*{\Mop returns |\Mvar| with N1 appended }*/ { CGAL_NEF_TRACEN(" append between nef3 "<<&*this<<" and "<<&N1); - Append_volumes appender(N1); - delegate(appender,true,false); + Shell_entry_const_iterator si; + CGAL_forall_shells_of(si,N1.volumes_begin()) + CGAL::shell_to_nef_3(N1,si,snc(),true); + SNC_external_structure es(snc()); + es.clear_external_structure(); + build_external_structure(); mark_bounded_volumes(); + return *this; } From dd70f9c11b72606056b121a7e828f123dbf1708e Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Fri, 22 Apr 2022 21:40:57 +0100 Subject: [PATCH 6/6] Implement append for Nef_3 that takes a range --- Nef_3/include/CGAL/Nef_polyhedron_3.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Nef_3/include/CGAL/Nef_polyhedron_3.h index bb9fe4d4844..fdb2fedae27 100644 --- a/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -1456,6 +1456,24 @@ protected: return *this; } + template + Nef_polyhedron_3 + append(const Range& N) + /*{\Mop returns |\Mvar| with the range N appended }*/ { + for(typename Range::const_iterator N1=N.begin(); N1!=N.end(); ++N1) { + CGAL_NEF_TRACEN(" append between nef3 "<<&*this<<" and "<<&*N1); + Shell_entry_const_iterator si; + CGAL_forall_shells_of(si,N1->volumes_begin()) + CGAL::shell_to_nef_3(*N1,si,snc(),true); + } + SNC_external_structure es(snc()); + es.clear_external_structure(); + build_external_structure(); + mark_bounded_volumes(); + + return *this; + } + Nef_polyhedron_3 difference(const Nef_polyhedron_3& N1) const /*{\Mop returns |\Mvar| $-$ |N1|. }*/ {