Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Error when using Periodic_3_Mesh_3 with a Periodic_3_function_wrapper

Subject: CGAL users discussion list

List archive

[cgal-discuss] Error when using Periodic_3_Mesh_3 with a Periodic_3_function_wrapper


Chronological Thread 
  • From: Nicolas Renaud <>
  • To:
  • Subject: [cgal-discuss] Error when using Periodic_3_Mesh_3 with a Periodic_3_function_wrapper
  • Date: Fri, 30 Apr 2021 17:02:15 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-hdrordr: A9a23:p6yhMa9BkmVWGVJBqnhuk+AnI+orLtY04lQ7vn1ZYxY9SKylvuqpm+kW0gKxtSYJVBgb9OyoFaGcTRrnm6JdzpIWOd6ZNzXOmGztF4166Jun/juIIUzD38pQz71pfaQ7KNCYNzJHpOL75AX9LNo62tmA98mT6dv29HtmQQF0Z6wI1W4QNi+hHkJ7XwVAD5YifaDshPZvnSaqengcc62AaUUtYu6rnaypqLvWJToPBxsq82C1/FaV1II=
  • Ironport-phdr: A9a23:EcLuMRQzgtadk3V4RgH/V3L+vdpsoiyfAWYlgqEPu/d1aq2muq7aFwnh351FslbFUM3h5u5ejKKO6ua8AD1Gu8zc+ylbLdRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfQV6Kf7oFYHMks+5y/69+4HJYwVPmTGxfa5+IA+5oAnMssQam5VuJrgxxxfGv3dEZuRbzn50KFyOmBrx+t2+94N5/SRKvPIh+c9AUaHkcKk9ULdVEjcoPX0r6cPyrRXMQheB6XUaUmUNjxpHGBPF4w3gXpfwqST1qOxw0zSHMMLsTLA0XTOi77p3SBLtlSwKOSI1/H3Rh8dtiq9QvRCvqAFlw4PMb46bNPRwcKDAc90EWWVMRdxeWzBbD46mc4cDE+gMMOBFpIf9vVsOqh6+CBG0CuPu1jBIgXv20rch0+88DQ/JwgogEMgTsHvJsd74M6ESUeGpw6nPyTXMdehW1S3y6IjNaBwhu++DXbRqfsrM1EYiDAzFjlCKpozkOzOZzPgCs2+e7+d5U++klmEopR1rrDe12scslpfGhpgTyl3c9ih03oY7KcOmRENnbtOpHptduiGYOoZyXs4uX39ktSU1xLAHpZO2fCsHxZUkyhDfb/GJfIyF7xPhWeiRLzp1inRoc6+xiRa19Eiv0Oz8Vs+s3VlWoSpKiN3MumoK1xzJ5ciKTOZ28ES52TuXyQzf9uVJLVo3mKfbMZIt3789m5sJvUnMHiL7nlj9grWMeUU+4Oeo7vzqYrX4qZ+YMI95kgT+Pb4vmsy7GOg4Mw8OU3WC9eSy27Du/Vf1QLpNjv0xnanZtI7VKd4Hqa6+Bg9Zyocj6xChADe6yNkUg2ULIVZfdB+Ej4XlIUzCLfH5APuljFmhkC9nx/XcMb3gBpXNIGLDkLDkfbtl7U5cyRY8zddb551OEbENOv3zWkrruNzCEBA5NRa7w/v6B9hm2YMeXHiAAq6dMK/IrVCI4ecvL/GWZIAJoDb9N+Ql5/n2gHAlll8SZ62p0YIKZ3C5BfRpP1iZYWH3gtoaCmcLvg8+TPTwh1GYUD5TYWyyX6Mm6T0hBoKmF9SLeof4i7OI2GK3H4Zde3tdIlGKC3bhMYueCNkWbyfHBM5qlTgNTvCbRokoyB3m4An7wL1jJ/GS9Sher5/l3cV5z+LWnBA2szdzCpLOgCm2U2hokzZQFHcN16dlrBklon+zlJNgivkdLuR9ovNEVgBSHZvVzug/CterHwydI5GGT1GpRtjgCjY0HIpZ6+9LWF50HpCZtj6GxzCja5cakrWKANo/9aeOhxDZF4NG03/DkZIZoRwjS8pLO3ehg8ZX+A3aBoqPmEKcxf/CSA==

Dear CGAL community,

Thanks for all the work developing and maintaining CGAL !

I'm very new to CGAL and I'm trying to mesh an  non-periodic function using `Periodic_3_mesh_3` with a `Periodic_3_function_wrapper` following the documentation for the sphere (https://doc.cgal.org/latest/Periodic_3_mesh_3/index.html#title4).

Most of the times everything works fine. However for some dimensions of the canonical cube I get the following error :

```terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
File: /home/nico/anaconda3/include/CGAL/Mesh_3/Refine_facets_3.h
Line: 1486
Explanation: Mesh_3 ERROR: A facet is not in conflict with its refinement point!```

This is for example the case in the example below where the cube is specified as (0, 0, 0, 1, 1, 0.85). But for a cube of (0, 0, 0, 1, 1, 1) the meshing succeeds.

I don't understand what I'm doing wrong and I would gladly welcome any help !

Thanks for your help !
Nico

#include <CGAL/Periodic_3_mesh_3/config.h>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/make_periodic_3_mesh_3.h>
#include <CGAL/optimize_periodic_3_mesh_3.h>
#include <CGAL/Periodic_3_mesh_3/IO/File_medit.h>
#include <CGAL/Periodic_3_mesh_triangulation_3.h>
#include <CGAL/Periodic_3_function_wrapper.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>

#include <CGAL/number_type_config.h> // CGAL_PI

#include <cmath>
#include <iostream>
#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
typedef K::Point_3 Point;
typedef K::Iso_cuboid_3 Iso_cuboid;

// Domain
typedef FT (Function)(const Point&);
typedef CGAL::Labeled_mesh_domain_3<K> Periodic_mesh_domain;

// Triangulation
typedef CGAL::Periodic_3_mesh_triangulation_3<Periodic_mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;

// Criteria
typedef CGAL::Mesh_criteria_3<Tr> Periodic_mesh_criteria;

typedef CGAL::Periodic_3_function_wrapper<Function, K> Periodic_function;

// To avoid verbose function and named parameters call
using namespace CGAL::parameters;

// Implicit function
// A sphere centered on (0.5, 0.5, 0.5) with radius sqrt(0.2)
FT sphere_function (const Point& p) {
return CGAL::squared_distance(p, Point(0.5, 0.5, 0.5)) - 0.2;
}

int main(int argc, char** argv)
{
// 'int' because the 'schwarz_p' function is periodic over the domain only if
// the length of the side of the domain is an integer.
int domain_size = (argc > 1) ? atoi(argv[1]) : 1;
int number_of_copies_in_output = (argc > 2) ? atoi(argv[2]) : 4; // can be 1, 2, 4, or 8
bool verbose = true;

Iso_cuboid canonical_cube(0, 0, 0, 1, 1, 0.85);

Periodic_mesh_domain domain =
Periodic_mesh_domain::create_implicit_mesh_domain(
Periodic_function(sphere_function, canonical_cube), canonical_cube);

Periodic_mesh_criteria criteria(facet_angle = 30,
facet_size = 0.035 * domain_size,
facet_distance = 0.025 * domain_size,
cell_radius_edge_ratio = 2.,
cell_size = 0.05);

// Mesh generation
if (!verbose) {
// suppress output
std::cerr.setstate(std::ios_base::failbit);
}

// Mesh generation
C3t3 c3t3 = CGAL::make_periodic_3_mesh_3<C3t3>(domain, criteria);

if (!verbose) {
std::cerr.clear();
}

std::ofstream medit_file("output_implicit_shape.mesh");
CGAL::output_periodic_mesh_to_medit(medit_file, c3t3, number_of_copies_in_output);

std::cout << "EXIT SUCCESS" << std::endl;
return 0;
}






Archive powered by MHonArc 2.6.19+.

Top of Page