Skip to content

Instantly share code, notes, and snippets.

View afabri's full-sized avatar

Andreas Fabri afabri

View GitHub Profile
@afabri
afabri / binary.cpp
Created March 7, 2025 10:52
issue 8773
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/Polyhedral_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/IO/output_to_vtu.h>
@afabri
afabri / issue-8735.cpp
Created February 12, 2025 11:54
Bug in polyline simplification
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyline_simplification_2/simplify.h>
#include <vector>
namespace PS = CGAL::Polyline_simplification_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef PS::Vertex_base_2<K> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> TDS;
@afabri
afabri / structural.c
Created October 7, 2024 08:54
Structural Repair with GEOS
#include <stdio.h>
#include <stdarg.h>
#include <geos_c.h>
/*
* GEOS requires two message handlers to return
* error and notice message to the calling program.
*
* typedef void(* GEOSMessageHandler) (const char *fmt,...)
@afabri
afabri / mpz_cpp_int.cpp
Last active May 2, 2024 09:00
Speed difference between mpz_int and cpp_int for function convert_to<std::string>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/gmp.hpp>
#include <chrono>
#include <iostream>
#include <string>
template <typename Number>
void fct(const std::string& forth)
{
const auto start{ std::chrono::steady_clock::now() };
@afabri
afabri / radius_of_inscribed_circle.cpp
Created March 11, 2024 14:33
Radius of inscribed circle in a simple polygon
#include <iostream>
#include <fstream>
#include <cassert>
#include <string>
// define the kernel
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Segment_2 Segment_2;
@afabri
afabri / read_stl.cpp
Created October 30, 2023 15:24
read_STL
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/boost/graph/IO/STL.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel C_Kernel;
typedef CGAL::Polyhedron_3<C_Kernel> C_Polyhedron;
int main()
{
@afabri
afabri / CMakeLists.txt
Created October 25, 2023 09:45
Example for read_VTK()
cmake_minimum_required(VERSION 3.1...3.23)
project(Stroman)
# CGAL and its components
find_package(CGAL REQUIRED)
create_single_source_cgal_program("readVTK.cpp")
find_package(VTK QUIET COMPONENTS vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources)
if (VTK_FOUND)
@afabri
afabri / iterate.cpp
Created September 28, 2023 15:08
iterate over vertices
#include <CGAL/Surface_mesh.h>
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Surface_mesh;
int main()
{
Surface_mesh sm;
@afabri
afabri / boost-mp-operator-eigen-VC2017bug.cpp
Created March 20, 2023 07:14
Minimal code showing a compilation problem for boost multiprecision and operator, combined with Eigen on VC2017
#include <boost/operators.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <Eigen/Dense>
// Quotient
template <class NT_>
class Toto
: boost::additive2 < Toto<NT_>, NT_ >
{
@afabri
afabri / expression.cpp
Created March 10, 2023 13:08
Problem with expression templates of boost::mp
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_rational Rat;
struct E {
Rat rat;
E(const Rat& rat)
: rat(rat)
{}
};