mirror of https://github.com/CGAL/cgal
better snippets for triangulation()
This commit is contained in:
parent
b305122323
commit
a001ee036a
|
|
@ -1,10 +1,11 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/draw_constrained_triangulation_3.h>
|
||||
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
||||
#include <CGAL/IO/write_MEDIT.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
@ -22,16 +23,27 @@ int main(int argc, char* argv[])
|
|||
|
||||
auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh);
|
||||
|
||||
//! [use of ccdt.triangulation()]
|
||||
std::cout << "Number of vertices in the CDT: "
|
||||
<< ccdt.triangulation().number_of_vertices() << '\n'
|
||||
<< "Number of constrained facets in the CDT: "
|
||||
<< ccdt.triangulation().number_of_vertices() << '\n';
|
||||
//! [use of ccdt.triangulation()]
|
||||
std::cout << "Number of constrained facets in the CDT: "
|
||||
<< ccdt.number_of_constrained_facets() << '\n';
|
||||
|
||||
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||
ofs.precision(17);
|
||||
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||
|
||||
CGAL::draw(ccdt);
|
||||
//! [move ccdt to tr]
|
||||
auto tr = std::move(ccdt).triangulation();
|
||||
// Now `tr` is a valid `CGAL::Triangulation_3` object that can be used for further processing.
|
||||
// and the triangulation of `ccdt` is empty.
|
||||
std::cout << "Number of vertices in the triangulation `tr`: "
|
||||
<< tr.number_of_vertices() << '\n';
|
||||
std::cout << "Number of vertices in `ccdt`: "
|
||||
<< ccdt.triangulation().number_of_vertices() << '\n';
|
||||
assert(ccdt.triangulation().number_of_vertices() == 0);
|
||||
//! [move ccdt to tr]
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,12 +58,10 @@ int main(int argc, char* argv[])
|
|||
Constraints_set constraints;
|
||||
Constraints_pmap constraints_pmap(constraints);
|
||||
|
||||
//! [move ccdt to tr]
|
||||
namespace np = CGAL::parameters;
|
||||
namespace Tet_remesh = CGAL::Tetrahedral_remeshing;
|
||||
Tr tr = Tet_remesh::get_remeshing_triangulation(std::move(ccdt),
|
||||
np::edge_is_constrained_map(constraints_pmap));
|
||||
//! [move ccdt to tr]
|
||||
std::cout << "Number of vertices in tr: " << tr.number_of_vertices() << std::endl;
|
||||
|
||||
CGAL::tetrahedral_isotropic_remeshing(tr,
|
||||
|
|
|
|||
|
|
@ -855,7 +855,11 @@ public:
|
|||
* \brief returns a const reference to the underlying triangulation.
|
||||
*
|
||||
* This allows the use of all non-modifying functions of the base triangulation.
|
||||
* See the other overload for a way to move the triangulation out of this object and then modify it.
|
||||
* See the other overload for a way to move the triangulation out of this object and then modify
|
||||
* it.
|
||||
*
|
||||
* Example usage:
|
||||
* \snippet[trimleft] conforming_constrained_Delaunay_triangulation_3.cpp use of ccdt.triangulation()
|
||||
*/
|
||||
const Triangulation& triangulation() const& {
|
||||
return cdt_impl;
|
||||
|
|
@ -865,8 +869,10 @@ public:
|
|||
* \brief moves and returns the underlying triangulation, then clears the object.
|
||||
*
|
||||
* This function allows the underlying triangulation to be moved out of this object.
|
||||
*
|
||||
* Example usage:
|
||||
* \snippet{trimleft} remesh_constrained_Delaunay_triangulation_3.cpp move ccdt to tr
|
||||
* \snippet[trimleft] conforming_constrained_Delaunay_triangulation_3.cpp move ccdt to tr
|
||||
*
|
||||
* After calling this function, `ccdt` will be empty and `tr` will be move-constructed from the underlying triangulation, avoiding any copy.
|
||||
*
|
||||
* \note This function is available only when the object is an rvalue.
|
||||
|
|
|
|||
Loading…
Reference in New Issue