40#ifndef GEOGRAM_MESH_MESH_SURFACE_INTERSECTION_INTERNAL 
   41#define GEOGRAM_MESH_MESH_SURFACE_INTERSECTION_INTERNAL 
  116                UNINITIALIZED, MESH_VERTEX, PRIMARY_ISECT, SECONDARY_ISECT
 
  145                type = PRIMARY_ISECT;
 
 
  159                type = SECONDARY_ISECT;
 
  161                init_sym(NO_INDEX, NO_INDEX, T1_RGN_T, T2_RGN_T);
 
 
  169                type = UNINITIALIZED;
 
  171                init_sym(NO_INDEX, NO_INDEX, T1_RGN_T, T2_RGN_T);
 
  172                mesh_vertex_index = NO_INDEX;
 
 
  188            void print(std::ostream& out=std::cerr) 
const;
 
  196                std::ostringstream out;
 
 
  201            vec2 get_UV_approx()
 const {
 
  202                double u = point_exact[mit->u_].estimate();
 
  203                double v = point_exact[mit->v_].estimate();
 
  204                double w = point_exact.w.estimate();
 
  205                return vec2(u/w,v/w);
 
  223                mesh_vertex_index = NO_INDEX;
 
 
  248#ifndef GEOGRAM_USE_EXACT_NT 
 
  321            return vec3(
mesh().vertices.point_ptr(v));
 
  326            return mesh_vertex(v);
 
  331            return vec2(p[u_], p[v_]);
 
  336            return mesh_vertex_UV(v);
 
  340        void log_err()
 const {
 
  341            std::cerr << 
"Houston, we got a problem (while remeshing facet " 
  342                      << f1_ << 
"):" << std::endl;
 
  416        void save(
const std::string& filename) 
const override;
 
  419        void begin_insert_transaction() 
override;
 
  420        void commit_insert_transaction() 
override;
 
  421        void rollback_insert_transaction() 
override;
 
  434        bool has_planar_isect_;
 
  436        mutable std::map<trindex, Sign> pred_cache_;
 
  437        bool use_pred_cache_insert_buffer_;
 
  438        mutable std::vector< std::pair<trindex, Sign> >
 
  439        pred_cache_insert_buffer_;
 
 
  462            std::swap(A_rgn_f1, A_rgn_f2);
 
  465            std::swap(B_rgn_f1, B_rgn_f2);
 
 
  475                A_rgn_f1 == B_rgn_f1 &&
 
  476                A_rgn_f2 == B_rgn_f2 ;
 
 
 
  510            double angle_tolerance = 0.0
 
  615            return facets_.
size();
 
 
  626                facet_is_marked[f] = 1;
 
 
  633        double angle_tolerance_;
 
  662            ) : mesh_(coplanar_facets.mesh_) {
 
  672                v_first_halfedge_.resize(mesh_.vertices.
nb(), NO_INDEX);
 
  673                h_next_around_v_.resize(mesh_.facet_corners.
nb(), NO_INDEX);
 
  677                    v_first_halfedge_[vertex(h,0)] = NO_INDEX;
 
  678                    h_next_around_v_[h] = NO_INDEX;
 
  680                halfedges_.resize(0);
 
  692                return mesh_.facets.
vertex(f,lv);
 
  716                for(
index_t h2: mesh_.facets.corners(t2)) {
 
  729                halfedges_.push_back(h);
 
  731                h_next_around_v_[h] = v_first_halfedge_[v1];
 
  732                v_first_halfedge_[v1] = h;
 
  739            vector<index_t>::const_iterator begin()
 const {
 
  740                return halfedges_.begin();
 
  747            vector<index_t>::const_iterator end()
 const {
 
  748                return halfedges_.end();
 
  757                return v_first_halfedge_[v];
 
  767                return h_next_around_v_[h];
 
  778                    index_t h = vertex_first_halfedge(v);
 
  780                    h = next_around_vertex(h)
 
  798                if(nb_halfedges_around_vertex(v2) != 1) {
 
  801                return vertex_first_halfedge(v2);
 
  806            vector<index_t> halfedges_;
 
  807            vector<index_t> v_first_halfedge_;
 
  808            vector<index_t> h_next_around_v_;
 
  823            Polylines(CoplanarFacets& CF) : CF_(CF) {
 
  832                polyline_start_.resize(0);
 
  833                polyline_start_.push_back(0);
 
  841                return polyline_start_.size() - 1;
 
  848            index_as_iterator begin()
 const {
 
  849                return index_as_iterator(0);
 
  857            index_as_iterator end()
 const {
 
  858                return index_as_iterator(nb());
 
  866            const_index_ptr_range halfedges(
index_t polyline)
 const {
 
  868                return const_index_ptr_range(
 
  869                    H_, polyline_start_[polyline], polyline_start_[polyline+1]
 
  876            void begin_polyline() {
 
  882            void end_polyline() {
 
  883                polyline_start_.push_back(H_.size());
 
  902                index_t h = H_[polyline_start_[polyline]];
 
  903                return CF_.halfedges_.vertex(h,0);
 
  914                index_t h = H_[polyline_start_[polyline+1]-1];
 
  915                return CF_.halfedges_.vertex(h,1);
 
  925                if(first_vertex(polyline) != last_vertex(polyline)) {
 
  928                index_t h = H_[polyline_start_[polyline+1]-1];
 
  929                return CF_.halfedges_.vertex(h,0);
 
  935            vector<index_t> polyline_start_;
 
 
Constained Delaunay triangulation in 2D.
 
#define geo_assert_not_reached
Sets a non reachable point in the program.
 
#define geo_assert(x)
Verifies that a condition is met.
 
#define geo_debug_assert(x)
Verifies that a condition is met.
 
Manages an attribute attached to a set of object.
 
Base class for constrained Delaunay triangulation.
 
Detects and retriangulates a set of coplanar facets for MeshSurfaceIntersection.
 
bool edges_are_colinear(const ExactPoint &P1, const ExactPoint &P2, const ExactPoint &P3) const
Tests whether two edges are co-linear.
 
index_t nb_facets()
Gets the number of coplanar facets.
 
void mark_vertices_to_keep()
Marks the vertices that need to be kept in the simplified facets.
 
void save_borders(const std::string &filename)
For debugging purposes, saves border edges to a file.
 
bool triangles_are_coplanar(const ExactPoint &P1, const ExactPoint &P2, const ExactPoint &P3, const ExactPoint &P4) const
Tests whether two adjacent triangles are coplanar.
 
void save_facet_group(const std::string &filename)
For debugging purposes, saves all the facets of the group to a file.
 
void find_coplanar_facets()
Finds all the pairs of coplanar facets.
 
void triangulate()
Triangulates the kept vertices.
 
CoplanarFacets(MeshSurfaceIntersection &I, bool clear_attributes, double angle_tolerance=0.0)
Constructs a CoplanarFacets object associated with a MeshSurfaceIntersection.
 
static coord_index_t triangle_normal_axis(const ExactPoint &p1, const ExactPoint &p2, const ExactPoint &p3)
Gets the coordinate along which one can project a triangle without creating degeneracies.
 
void get(index_t f, index_t group_id)
Gets the set of coplanar facets from a given facet and group id.
 
void mark_facets(vector< index_t > &facet_is_marked)
Marks the facets.
 
Constrained Delaunay Triangulation with vertices that are exact points. Can be used to implement 2D C...
 
index_t vertex(index_t f, index_t lv) const
Gets a vertex by facet and local vertex index.
 
A vertex of the triangulation.
 
void init_geometry(const ExactPoint &P)
Optimizes exact numbers in generated points and computes approximate coordinates.
 
Vertex(MeshInTriangle *M, index_t f1, index_t f2, TriangleRegion R1, TriangleRegion R2)
Constructor for intersections with other facets.
 
void init_sym(index_t f1, index_t f2, TriangleRegion R1, TriangleRegion R2)
Initializes the symbolic information of this Vertex.
 
std::string to_string() const
Gets a string representation of this Vertex.
 
Vertex(MeshInTriangle *M, const ExactPoint &point_exact_in)
Constructor for intersections between constraints.
 
const Mesh & mesh() const
Gets the mesh.
 
void print(std::ostream &out=std::cerr) const
Prints this vertex.
 
ExactPoint compute_geometry()
Gets the geometry of this vertex.
 
Vertex()
Default constructor.
 
Vertex(MeshInTriangle *M, index_t f, index_t lv)
Constructor for macro-triangle vertices.
 
Meshes a single triangle with the constraints that come from the intersections with the other triangl...
 
void get_edge_edge_intersection(index_t e1, index_t e2, ExactPoint &I) const
Computes the intersection between two edges.
 
index_t create_intersection(index_t e1, index_t i, index_t j, index_t e2, index_t k, index_t l) override
Given two segments that have an intersection, create the intersection.
 
Sign incircle(index_t v1, index_t v2, index_t v3, index_t v4) const override
Tests the relative position of a point with respect to the circumscribed circle of a triangle.
 
Sign orient2d(index_t v1, index_t v2, index_t v3) const override
Tests the orientation of three vertices.
 
const Mesh & mesh() const
Gets the readonly initial mesh.
 
void get_edge_edge_intersection_2D(index_t e1, index_t e2, ExactPoint &I) const
Auxilliary function used by get_edge_edge_intersection() for the special case when the two edges are ...
 
void save_constraints(const std::string &filename)
For debugging, save constraints to a file.
 
Mesh & target_mesh()
Gets the target mesh.
 
void set_dry_run(bool x)
In dry run mode, the computed local triangulations are not inserted in the global mesh....
 
void save(const std::string &filename) const override
Saves this CDT to a geogram mesh file.
 
void commit()
Creates new vertices and new triangles in target mesh.
 
void get_constraints(Mesh &M, bool with_edges=true) const
For debugging, copies the constraints to a mesh.
 
index_t nb() const
Gets the number of (sub-)elements.
 
Computes surface intersections.
 
Mesh & target_mesh()
Gets the target mesh.
 
const double * point_ptr(index_t v) const
Gets a point.
 
3d vector with homogeneous coordinates
 
Vector with aligned memory allocation.
 
index_t size() const
Gets the number of elements.
 
Exact predicates and constructs.
 
Common include file, providing basic definitions. Should be included before anything else by all head...
 
Classes for managing tuples of indices.
 
The class that represents a mesh.
 
Functions to load and save meshes.
 
Functions for computing intersections between surfacic meshes and for boolean operations.
 
void initialize()
Initializes the command line framework.
 
Global Vorpaline namespace.
 
TriangleRegion
Encodes the location of a point within a triangle.
 
TriangleRegion swap_T1_T2(TriangleRegion R)
Replaces T1 with T2 or T2 with T1 in a region code.
 
vecng< 3, Numeric::float64 > vec3
Represents points and vectors in 3d.
 
bool mesh_save(const Mesh &M, const std::string &filename, const MeshIOFlags &ioflags=MeshIOFlags())
Saves a mesh to a file.
 
geo_index_t index_t
The type for storing and manipulating indices.
 
Sign
Integer constants that represent the sign of a value.
 
vecng< 2, Numeric::float64 > vec2
Represents points and vectors in 2d.
 
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
 
Stores information about a triangle-triangle intersection.
 
bool is_point() const
Tests whether intersection is just a point.
 
Symbolic computation of triangle-triangle intersection.