document two functions in Constrained_Delaunay_triangulation_cell_data_3

This commit is contained in:
Laurent Rineau 2024-06-21 10:50:53 +02:00
parent 84900137fb
commit 1324c08706
4 changed files with 74 additions and 26 deletions

View File

@ -95,8 +95,11 @@ public:
void reset_cache_validity() const { sliver_cache_validity_ = false; }
static std::string io_signature() {
return Get_io_signature<Base>()() + "+(" + Get_io_signature<int>()()
+ ")[4]";
static_assert(
std::is_same_v<
decltype(std::declval<Constrained_Delaunay_triangulation_cell_data_3>().face_constraint_index(0)), int>);
return Get_io_signature<Base>()() + "+(" + Get_io_signature<int>()() + ")[4]";
}
friend std::ostream&
@ -106,9 +109,9 @@ public:
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];
os << " " << c.cdt_3_data().face_constraint_index(li);
} else {
CGAL::write(os, c.cdt_3_data().face_id[li]);
CGAL::write(os, c.cdt_3_data().face_constraint_index(li));
}
}
return os;

View File

@ -29,18 +29,6 @@
#include <bitset>
namespace CGAL {
#ifdef DOXYGEN_RUNNING
/*!
* @brief Internal per-cell data for \cgal 3D constrained Delaunay triangulations
*
* This class is an internal detail of the implementation of \cgal 3D constrained Delaunay triangulations.
*
* Any model of the `ConstrainedDelaunayTriangulationCellBase_3` concept must include one object of this type
* as a non-static data member.
*/
struct Constrained_Delaunay_triangulation_cell_data_3 {};
#else // DOXYGEN_RUNNING
enum class CDT_3_cell_marker {
CLEAR = 0,
IN_REGION = 1,
@ -49,7 +37,19 @@ enum class CDT_3_cell_marker {
nb_of_markers
};
struct Constrained_Delaunay_triangulation_cell_data_3 {
/*!
* @brief Internal per-cell data for \cgal 3D constrained Delaunay triangulations
*
* This class is an internal detail of the implementation of \cgal 3D constrained Delaunay triangulations.
*
* Any model of the `ConstrainedDelaunayTriangulationCellBase_3` concept must include one object of this type
* as a non-static data member.
*/
class Constrained_Delaunay_triangulation_cell_data_3 {
/// @cond SKIP_IN_MANUAL
template <typename Tr> friend class Constrained_Delaunay_triangulation_3_impl;
/// @endcond
std::array<CDT_3_face_index, 4> face_id = { -1, -1, -1, -1 };
std::array<void*, 4> facet_2d = {nullptr, nullptr, nullptr, nullptr};
std::bitset<static_cast<unsigned>(CDT_3_cell_marker::nb_of_markers)> markers;
@ -60,8 +60,6 @@ struct Constrained_Delaunay_triangulation_cell_data_3 {
void clear_mark(CDT_3_cell_marker m) { markers.reset(static_cast<unsigned>(m)); }
void clear_marks() { markers.reset(); }
bool is_facet_constrained(int i) const { return face_id[unsigned(i)] >= 0; }
template <typename Facet_handle>
void set_facet_constraint(int i, CDT_3_face_index face_id,
Facet_handle facet_2d)
@ -70,19 +68,24 @@ struct Constrained_Delaunay_triangulation_cell_data_3 {
this->facet_2d[unsigned(i)] = static_cast<void*>(facet_2d == Facet_handle{} ? nullptr : std::addressof(*facet_2d));
}
CDT_3_face_index face_constraint_index(int i) const {
return face_id[unsigned(i)];
}
template <typename CDT_2>
auto face_2 (const CDT_2& cdt, int i) const {
using Face = typename CDT_2::Face;
auto ptr = static_cast<Face*>(facet_2d[unsigned(i)]);
return cdt.tds().faces().iterator_to(*ptr);
}
public:
/// @brief Returns if the i-th facet of the cell is constrained.
bool is_facet_constrained(int i) const { return face_id[unsigned(i)] >= 0; }
/// @brief Returns the index of the constraint that constrains the
/// i-th facet of the cell.
/// @pre `is_facet_constrained(i)`
CDT_3_face_index face_constraint_index(int i) const {
return face_id[unsigned(i)];
}
};
#endif // DOXYGEN_RUNNING
} // namespace CGAL
#endif // CGAL_CONSTRAINED_DELAUNAY_TRIANGULATION_CELL_DATA_3_H

View File

@ -25,6 +25,8 @@
#include <CGAL/config.h>
#include <CGAL/Constrained_triangulation_3_types.h>
#if CGAL_CAN_USE_CXX20_FORMAT
# define CGAL_CDT_3_CAN_USE_CXX20_FORMAT 1
# include <format>
@ -32,8 +34,6 @@
namespace CGAL {
using CDT_3_face_index = int; // must be signed
#if CGAL_CDT_3_CAN_USE_CXX20_FORMAT
constexpr bool cdt_3_can_use_cxx20_format() {

View File

@ -0,0 +1,42 @@
// Copyright (c) 2024 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// 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$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Laurent Rineau
#ifndef CGAL_CT_3_TYPES_H
#define CGAL_CT_3_TYPES_H
#include <CGAL/license/Triangulation_3.h>
#include <CGAL/config.h>
namespace CGAL {
/**
* @addtogroup PkgCT_3Classes
* @typedef CDT_3_face_index
* Integral type to store the index of constraints.
* @see `Constrained_Delaunay_triangulation_cell_data_3`
* @see `Constrained_Delaunay_triangulation_vertex_base_3`
*
*/
using CDT_3_face_index = int; // must be signed
} // namespace CGAL
#endif // CGAL_CT_3_TYPES_H