11#ifndef EASY3D_ALGO_EXT_SELF_INTERSECTION_H
12#define EASY3D_ALGO_EXT_SELF_INTERSECTION_H
15#include <unordered_map>
20#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
21#include <CGAL/intersections.h>
22#include <CGAL/box_intersection_d.h>
23#include <CGAL/Constrained_Delaunay_triangulation_2.h>
24#include <CGAL/Constrained_triangulation_plus_2.h>
26#include <easy3d/core/surface_mesh.h>
60 std::vector<std::pair<SurfaceMesh::Face, SurfaceMesh::Face> >
74 typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
77 typedef CGAL::Point_3<Kernel> Point_3;
78 typedef CGAL::Vector_3<Kernel> Vector_3;
79 typedef CGAL::Triangle_3<Kernel> Triangle_3;
80 typedef CGAL::Segment_3<Kernel> Segment_3;
81 typedef CGAL::Plane_3<Kernel> Plane_3;
84 typedef CGAL::Triangulation_vertex_base_2<Kernel> TVB_2;
85 typedef CGAL::Constrained_triangulation_face_base_2<Kernel> CTFB_2;
86 typedef CGAL::Triangulation_data_structure_2<TVB_2, CTFB_2> TDS_2;
87 typedef CGAL::Exact_intersections_tag Itag;
88 typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel, TDS_2, Itag> CDT_2;
89 typedef CGAL::Constrained_triangulation_plus_2<CDT_2> CDT_plus_2;
91 typedef std::vector<std::pair<int, CGAL::Object> > ObjectList;
95 Triangle(
const Point_3 &a,
const Point_3 &b,
const Point_3 &c,
SurfaceMesh::Face f) : triangle(a, b, c),
101 std::vector<SurfaceMesh::Vertex> vertices;
105 typedef std::vector<Triangle> Triangles;
106 typedef typename Triangles::iterator TrianglesIterator;
107 typedef CGAL::Box_intersection_d::Box_with_handle_d<double, 3, TrianglesIterator> Box;
111 void mesh_to_cgal_triangle_list(
SurfaceMesh *mesh);
114 bool do_intersect(
const Triangle &A,
const Triangle &B);
131 const std::vector<CGAL::Object> &objects,
133 std::vector<Point_3> &vertices,
134 std::vector<std::vector<int> > &faces
151 void insert_into_cdt(
const CGAL::Object &obj,
const Plane_3 &P, CDT_plus_2 &cdt);
157 inline void mark_offensive(
int f);
160 inline void count_intersection(
int fa,
int fb);
169 inline bool intersect(
const Triangle &A,
const Triangle &B);
181 inline bool single_shared_vertex(
const Triangle &A,
const Triangle &B,
int va,
int vb);
184 inline bool single_shared_vertex(
const Triangle &A,
const Triangle &B,
int va);
190 inline bool double_shared_vertex(
193 const std::vector<std::pair<int, int> > &shared
199 bool construct_intersection_;
201 Triangles triangle_faces_;
204 std::unordered_map<int, SurfaceMesh::Face> original_face;
208 std::unordered_map<int, ObjectList> offending_;
211 int total_comb_duplicate_face_;
212 int total_geom_duplicate_face_;
Detects and resolves self-intersection for surface mesh.
Definition: self_intersection.h:49
std::vector< std::pair< SurfaceMesh::Face, SurfaceMesh::Face > > detect(SurfaceMesh *mesh, bool construct=false)
Detect intersecting face pairs.
Definition: self_intersection.cpp:40
bool remesh(SurfaceMesh *mesh, bool stitch)
Detect and remesh the intersecting faces.
Definition: self_intersection.cpp:427
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
Definition: collider.cpp:182
Definition: surface_mesh.h:134