Skip to content

SMDS_3 - add class Simplicial_mesh_triangulation_3 to ease the use of C3t3 #8868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions SMDS_3/doc/SMDS_3/examples.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*!
\example SMDS_3/c3t3_example.cpp
\example SMDS_3/c3t3_complete_example.cpp
\example SMDS_3/tetrahedron_soup_to_c3t3_example.cpp
*/
1 change: 1 addition & 0 deletions SMDS_3/examples/SMDS_3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ project(SMDS_3_Examples)
find_package(CGAL REQUIRED)

create_single_source_cgal_program("c3t3_example.cpp")
create_single_source_cgal_program("c3t3_complete_example.cpp")
create_single_source_cgal_program("tetrahedron_soup_to_c3t3_example.cpp")
67 changes: 67 additions & 0 deletions SMDS_3/examples/SMDS_3/c3t3_complete_example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/Triangulation_3.h>
#include <CGAL/Triangulation_data_structure_3.h>
#include <CGAL/Simplicial_mesh_cell_base_3.h>
#include <CGAL/Simplicial_mesh_vertex_base_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>

#include <CGAL/tetrahedral_remeshing.h>

#include <CGAL/tags.h>

#include <CGAL/IO/File_medit.h>
#include <fstream>


using K = CGAL::Exact_predicates_inexact_constructions_kernel;

using Subdomain_index = int;
using Surface_patch_index = unsigned char;
using Curve_index = char;
using Corner_index = short;

using Cb = CGAL::Simplicial_mesh_cell_base_3<K, Subdomain_index, Surface_patch_index>;
using Vb = CGAL::Simplicial_mesh_vertex_base_3<K, Subdomain_index, Surface_patch_index,
Curve_index, Corner_index>;

using Tds = CGAL::Triangulation_data_structure_3<Vb, Cb, CGAL::Sequential_tag>;
using Triangulation = CGAL::Triangulation_3<K, Tds>;

using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3<Triangulation>;


int main(int argc, char* argv[])
{
std::cout.precision(17);
std::cerr.precision(17);

std::string filename = (argc > 1) ? std::string(argv[1])
: CGAL::data_file_path("meshes/elephant.mesh");

Triangulation tr;

std::ifstream is(filename, std::ios_base::in);
if(!CGAL::IO::read_MEDIT(is, tr))
{
std::cerr << "Failed to read" << std::endl;
return EXIT_FAILURE;
}

// [call a remeshing algorithm]

std::ofstream os("after_remeshing.mesh");
CGAL::IO::write_MEDIT(os, tr, CGAL::parameters::all_vertices(true));
os.close();

Triangulation tr2;
std::ifstream is2("after_remeshing.mesh");
if(!CGAL::IO::read_MEDIT(is2, tr2))
{
std::cerr << "Failed to read (#2)" << std::endl;
return EXIT_FAILURE;
}

std::cout << "Done" << std::endl;
return EXIT_SUCCESS;
}
38 changes: 5 additions & 33 deletions SMDS_3/examples/SMDS_3/c3t3_example.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/Triangulation_3.h>
#include <CGAL/Triangulation_data_structure_3.h>
#include <CGAL/Simplicial_mesh_cell_base_3.h>
#include <CGAL/Simplicial_mesh_vertex_base_3.h>
#include <CGAL/Simplicial_mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>

#include <CGAL/tetrahedral_remeshing.h>

#include <CGAL/tags.h>

#include <CGAL/IO/File_medit.h>
#include <fstream>


using K = CGAL::Exact_predicates_inexact_constructions_kernel;

using Subdomain_index = int;
using Surface_patch_index = unsigned char;
using Curve_index = char;
using Corner_index = short;

using Cb = CGAL::Simplicial_mesh_cell_base_3<K, Subdomain_index, Surface_patch_index>;
using Vb = CGAL::Simplicial_mesh_vertex_base_3<K, Subdomain_index, Surface_patch_index,
Curve_index, Corner_index>;

using Tds = CGAL::Triangulation_data_structure_3<Vb, Cb, CGAL::Sequential_tag>;
using Triangulation = CGAL::Triangulation_3<K, Tds>;

using Triangulation = CGAL::Simplicial_mesh_triangulation_3<K>;
using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3<Triangulation>;


int main(int argc, char* argv[])
{
std::cout.precision(17);
Expand All @@ -48,20 +28,12 @@ int main(int argc, char* argv[])
return EXIT_FAILURE;
}

// [call a remeshing algorithm]
C3t3 c3t3;
c3t3.triangulation() = tr;

std::ofstream os("after_remeshing.mesh");
std::ofstream os("out.mesh");
CGAL::IO::write_MEDIT(os, tr, CGAL::parameters::all_vertices(true));
os.close();

Triangulation tr2;
std::ifstream is2("after_remeshing.mesh");
if(!CGAL::IO::read_MEDIT(is2, tr2))
{
std::cerr << "Failed to read (#2)" << std::endl;
return EXIT_FAILURE;
}

std::cout << "Done" << std::endl;
return EXIT_SUCCESS;
}
51 changes: 51 additions & 0 deletions SMDS_3/include/CGAL/Simplicial_mesh_triangulation_3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2006-2007 INRIA Sophia-Antipolis (France).
// Copyright (c) 2008,2011 GeometryFactory Sarl (France)
// 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
//
// Author(s) : Laurent Rineau, Stephane Tayeb, Andreas Fabri, Jane Tournois

#ifndef CGAL_SIMPLICIAL_MESH_TRIANGULATION_3_H
#define CGAL_SIMPLICIAL_MESH_TRIANGULATION_3_H

#include <CGAL/license/SMDS_3.h>

#include <CGAL/Simplicial_mesh_vertex_base_3.h>
#include <CGAL/Simplicial_mesh_cell_base_3.h>
#include <CGAL/Triangulation_data_structure_3.h>
#include <CGAL/Triangulation_3.h>

namespace CGAL
{
/**
*\ingroup PkgSMDS3Classes
* `Simplicial_mesh_triangulation_3`
* @todo
*/
template<typename K,
typename SubdomainIndex = int,
typename SurfacePatchIndex = int,
typename CurveIndex = int,
typename CornerIndex = int>
using Simplicial_mesh_triangulation_3 =
CGAL::Triangulation_3<K,
CGAL::Triangulation_data_structure_3<
CGAL::Simplicial_mesh_vertex_base_3<K,
SubdomainIndex,
SurfacePatchIndex,
CurveIndex,
CornerIndex>,
CGAL::Simplicial_mesh_cell_base_3<K, SubdomainIndex, SurfacePatchIndex>,
CGAL::Sequential_tag
>
>;
};

#endif // CGAL_SIMPLICIAL_MESH_TRIANGULATION_3_H