Skip to content

Instantly share code, notes, and snippets.

View afabri's full-sized avatar

Andreas Fabri afabri

View GitHub Profile
@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)
{}
};
@afabri
afabri / issue7235.cpp
Created February 1, 2023 15:58
Issue 7325
// Created by Dominik Krupke on 14.11.22.
//
#include <vector>
#include <iterator>
#include <iostream>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
@afabri
afabri / sm_ply.cpp
Created January 11, 2023 18:00
Writing and reading PLY files
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/IO/PLY.h>
#include <CGAL/Surface_mesh/IO/PLY.h>
#include <CGAL/boost/graph/generators.h>
#include <CGAL/IO/Color.h>
#include <iostream>
#include <fstream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
#include <CGAL/Timer.h>
#include <cassert>
#include <iostream>