40#ifndef GEOGRAM_MESH_MESH_SURFACE_INTERSECTION
41#define GEOGRAM_MESH_MESH_SURFACE_INTERSECTION
80 void remove_external_shell();
82 void remove_internal_shells();
107 approx_incircle_ = x;
115 radial_sort_.set_approx_predicates(x);
124 detect_intersecting_neighbors_ = x;
135 use_radial_sort_ = x;
149 void save_exact(
const std::string& filename);
162 Process::acquire_spinlock(lock_);
169 Process::release_spinlock(lock_);
240 void build_Weiler_model();
250 return mesh_.facets.vertex(f,lv);
255 index_t t2 = mesh_.facet_corners.adjacent_facet(h);
259 for(index_t h2: mesh_.facets.corners(t2)) {
260 if(mesh_.facet_corners.adjacent_facet(h2) == t1) {
267 void sew2(index_t h1, index_t h2) {
269 halfedge_vertex(h1,0) == halfedge_vertex(h2,1)
272 halfedge_vertex(h2,0) == halfedge_vertex(h1,1)
276 mesh_.facet_corners.set_adjacent_facet(h1,t2);
277 mesh_.facet_corners.set_adjacent_facet(h2,t1);
280 index_t alpha3(index_t h)
const {
281 return facet_corner_alpha3_[h];
284 index_t alpha3_facet(index_t f)
const {
285 return alpha3(3*f)/3;
288 void sew3(index_t h1, index_t h2) {
290 halfedge_vertex(h1,0) == halfedge_vertex(h2,1)
293 halfedge_vertex(h2,0) == halfedge_vertex(h1,1)
295 facet_corner_alpha3_[h1] = h2;
296 facet_corner_alpha3_[h2] = h1;
299 void save_triangle(
const std::string& name, index_t h) {
300 std::ofstream out(name +
".obj");
301 index_t v1 = halfedge_vertex(h,0);
302 index_t v2 = halfedge_vertex(h,1);
303 index_t v3 = halfedge_vertex(h,2);
304 out <<
"v " <<
vec3(mesh_.vertices.point_ptr(v1)) << std::endl;
305 out <<
"v " <<
vec3(mesh_.vertices.point_ptr(v2)) << std::endl;
306 out <<
"v " <<
vec3(mesh_.vertices.point_ptr(v3)) << std::endl;
307 out <<
"f 1 2 3" << std::endl;
311 const std::string& name,
312 vector<index_t>::iterator b, vector<index_t>::iterator e
314 std::ofstream out(name +
".obj");
316 for(vector<index_t>::iterator i=b; i!=e; ++i) {
318 index_t v1 = mesh_.facets.vertex(t,0);
319 index_t v2 = mesh_.facets.vertex(t,1);
320 index_t v3 = mesh_.facets.vertex(t,2);
322 <<
vec3(mesh_.vertices.point_ptr(v1)) << std::endl;
324 <<
vec3(mesh_.vertices.point_ptr(v2)) << std::endl;
326 <<
vec3(mesh_.vertices.point_ptr(v3)) << std::endl;
328 << v_ofs+1 <<
" " << v_ofs+2 <<
" " << v_ofs+3
348 approx_predicates_(false),
360 approx_predicates_ = x;
420 Sign o_ref1 = h_orient(h_ref_, h1);
421 Sign o_ref2 = h_orient(h_ref_, h2);
422 Sign oN_ref1 = h_refNorient(h1);
423 Sign oN_ref2 = h_refNorient(h2);
424 Sign o_12 = h_orient(h1,h2);
426 <<
" o_ref1=" << int(o_ref1) <<
" o_ref2=" << int(o_ref2)
427 <<
" oN_ref1=" << int(oN_ref1) <<
" oN_ref2=" << int(oN_ref2)
428 <<
" o_12=" << int(o_12)
434 bool approx_predicates_;
440 mutable bool degenerate_;
451 std::map<vec3HE,index_t,vec3HELexicoCompare> exact_point_to_vertex_;
452 RadialSort radial_sort_;
455 bool detect_intersecting_neighbors_;
456 bool approx_incircle_;
457 bool use_radial_sort_;
459 vec3 normalize_center_;
460 double normalize_radius_;
483 const std::string& attribute=
"",
bool reorder=
true
511 Mesh& M,
const std::string& expr,
512 const std::string& attribute=
"",
bool reorder=
true
528 Mesh& result,
Mesh& A,
Mesh& B,
const std::string& operation
#define geo_assert_not_reached
Sets a non reachable point in the program.
#define geo_debug_assert(x)
Verifies that a condition is met.
Generic mechanism for attributes.
Common include file, providing basic definitions. Should be included before anything else by all head...
Manages an attribute attached to a set of object.
Meshes a single triangle with the constraints that come from the intersections with the other triangl...
Sign h_orient(index_t h1, index_t h2) const
Computes the relative orientations of two halfedges.
Sign h_refNorient(index_t h2) const
Computes the normal orientation of a halfedge relative to h_ref.
void init(index_t h_ref)
Initializes radial sorting around a given halfedge.
void set_approx_predicates(bool x)
Specifies whether approximate predicates shoud be used.
bool degenerate() const
Tests if a degeneracy was encountered.
RadialSort(const MeshSurfaceIntersection &mesh)
RadialSort constructor.
static vec3E exact_direction(const vec3HE &p1, const vec3HE &p2)
Computes a vector of arbitrary length with its direction given by two points.
bool operator()(index_t h1, index_t h2) const
Compares two halfedges.
Computes surface intersections.
void set_verbose(bool x)
Display information while computing the intersection. Default is unset.
vec3HE exact_vertex(index_t v) const
Gets the exact point associated with a vertex.
void unlock()
Releases the lock associated with this mesh.
void set_detect_intersecting_neighbors(bool x)
detect and compute intersections between facets that share a facet or an edge. Set to false if input ...
void set_normalize(bool x)
Specifies whether coordinates should be normalized during computation. If set, original coordinates a...
void set_approx_incircle(bool x)
If set, then Delaunay mode uses approximated incircle predicate (else it uses exact arithmetics)....
const Mesh & readonly_mesh() const
Gets a copy of the initial mesh passed to the constructor.
const Mesh & target_mesh() const
Gets the target mesh.
void set_radial_sort(bool x)
Specifies whether surfaces should be duplicated and radial edges sorted in order to create the volume...
index_t find_or_create_exact_vertex(const vec3HE &p)
Finds or creates a vertex in the mesh, by exact coordinates.
void lock()
Acquires a lock on this mesh.
bool radial_sort(vector< index_t >::iterator b, vector< index_t >::iterator e)
Sorts a range of halfedges in radial order.
void mark_external_shell(vector< index_t > &on_external_shell)
Marks all the facets that are on the external shell.
Mesh & target_mesh()
Gets the target mesh.
void set_delaunay(bool x)
If set, compute constrained Delaunay triangulation in the intersected triangles. If there are interse...
void set_approx_radial_sort(bool x)
If set, do not use exact geometry for ordering triangles around radial edge. Default is unset.
Vector with aligned memory allocation.
Exact predicates and constructs.
The class that represents a mesh.
Global Vorpaline namespace.
bool mesh_facets_have_intersection(Mesh &M, index_t f1, index_t f2)
Tests whether two mesh facets have a non-degenerate intersection.
void mesh_boolean_operation(Mesh &result, Mesh &A, Mesh &B, const std::string &operation)
Computes the union of two surface meshes.
void mesh_intersection(Mesh &result, Mesh &A, Mesh &B)
Computes the intersection of two surface meshes.
vecng< 3, Numeric::float64 > vec3
Represents points and vectors in 3d.
void mesh_classify_intersections(Mesh &M, std::function< bool(index_t)> eqn, const std::string &attribute="", bool reorder=true)
Classifies the facets of the result of mesh_intersect_surface() based on a boolean function.
geo_index_t index_t
The type for storing and manipulating indices.
Sign
Integer constants that represent the sign of a value.
void mesh_union(Mesh &result, Mesh &A, Mesh &B)
Computes the union of two surface meshes.
void mesh_difference(Mesh &result, Mesh &A, Mesh &B)
Computes the difference of two surface meshes.
void mesh_remove_intersections(Mesh &M, index_t max_iter=3)
Attempts to make a surface mesh conformal by removing intersecting facets and re-triangulating the ho...
Function and classes for process manipulation.
3D vector in homogeneous coordinates with coordinates as arithmetic expansions.