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;
169 type = UNINITIALIZED;
172 mesh_vertex_index =
index_t(-1);
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 =
index_t(-1);
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_;
461 std::swap(A_rgn_f1, A_rgn_f2);
464 std::swap(B_rgn_f1, B_rgn_f2);
474 A_rgn_f1 == B_rgn_f1 &&
475 A_rgn_f2 == B_rgn_f2 ;
509 double angle_tolerance = 0.0
614 return facets_.
size();
625 facet_is_marked[f] = 1;
632 double angle_tolerance_;
661 ) : mesh_(coplanar_facets.mesh_) {
671 v_first_halfedge_.resize(mesh_.vertices.
nb(), NO_INDEX);
672 h_next_around_v_.resize(mesh_.facet_corners.
nb(), NO_INDEX);
676 v_first_halfedge_[vertex(h,0)] = NO_INDEX;
677 h_next_around_v_[h] = NO_INDEX;
679 halfedges_.resize(0);
691 return mesh_.facets.
vertex(f,lv);
728 halfedges_.push_back(h);
730 h_next_around_v_[h] = v_first_halfedge_[v1];
731 v_first_halfedge_[v1] = h;
738 vector<index_t>::const_iterator begin()
const {
739 return halfedges_.begin();
746 vector<index_t>::const_iterator end()
const {
747 return halfedges_.end();
756 return v_first_halfedge_[v];
766 return h_next_around_v_[h];
777 index_t h = vertex_first_halfedge(v);
779 h = next_around_vertex(h)
797 if(nb_halfedges_around_vertex(v2) != 1) {
800 return vertex_first_halfedge(v2);
805 vector<index_t> halfedges_;
806 vector<index_t> v_first_halfedge_;
807 vector<index_t> h_next_around_v_;
831 polyline_start_.resize(0);
832 polyline_start_.push_back(0);
840 return polyline_start_.size() - 1;
847 index_as_iterator begin()
const {
848 return index_as_iterator(0);
856 index_as_iterator end()
const {
857 return index_as_iterator(nb());
865 const_index_ptr_range halfedges(
index_t polyline)
const {
867 return const_index_ptr_range(
868 H_, polyline_start_[polyline], polyline_start_[polyline+1]
875 void begin_polyline() {
881 void end_polyline() {
882 polyline_start_.push_back(H_.size());
901 index_t h = H_[polyline_start_[polyline]];
902 return CF_.halfedges_.vertex(h,0);
913 index_t h = H_[polyline_start_[polyline+1]-1];
914 return CF_.halfedges_.vertex(h,1);
924 if(first_vertex(polyline) != last_vertex(polyline)) {
927 index_t h = H_[polyline_start_[polyline+1]-1];
928 return CF_.halfedges_.vertex(h,0);
934 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.
Specialization of Attribute for booleans.
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.
index_range corners(index_t f) const
Gets the corners of a facet.
A vertex of the triangulation.
void init_geometry(const ExactPoint &P)
Optimizes exact numbers in generated points and computes approximate coordinates.
const Mesh & mesh() const
Gets the mesh.
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.
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.
Mesh & target_mesh()
Gets the target 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.
const Mesh & mesh() const
Gets the readonly initial 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
Specialization of vector for elements of type bool.
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.
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.
void initialize(int flags=GEOGRAM_INSTALL_NONE)
Initialize Geogram.
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.