Files
ViewDesignEngine/include/vde/boolean/boolean_mesh.h
T
2026-07-23 12:36:39 +00:00

48 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "vde/boolean/boolean_2d.h"
#include "vde/core/polygon.h"
#include "vde/mesh/halfedge_mesh.h"
namespace vde::boolean {
using core::Point2D;
using core::Polygon2D;
using mesh::HalfedgeMesh;
/// ── Core 3D mesh boolean operations ──────────────────────
/// Union: A B — keep faces of each mesh whose centroids lie outside the other
HalfedgeMesh mesh_union(const HalfedgeMesh& a, const HalfedgeMesh& b);
/// Intersection: A ∩ B — keep faces whose centroids lie inside the other
HalfedgeMesh mesh_intersection(const HalfedgeMesh& a, const HalfedgeMesh& b);
/// Difference: A B — keep A-faces outside B
HalfedgeMesh mesh_difference(const HalfedgeMesh& a, const HalfedgeMesh& b);
/// Symmetric difference: (A B) (B A)
HalfedgeMesh mesh_sym_diff(const HalfedgeMesh& a, const HalfedgeMesh& b);
/// ── Helpers ──────────────────────────────────────────────
/// Crop mesh `a` by mesh `b`'s boundary: keep faces of `a` whose
/// centroids lie OUTSIDE the volume of `b`.
/// If `invert_b` is true, test against the flipped-volume (inside↔outside) of `b`.
HalfedgeMesh clip_mesh(const HalfedgeMesh& a, const HalfedgeMesh& b,
bool invert_b = false);
/// Invert all face orientations in the mesh
HalfedgeMesh invert_mesh(const HalfedgeMesh& m);
/// Merge two meshes into one (concatenate vertices and faces)
HalfedgeMesh merge_meshes(const HalfedgeMesh& a, const HalfedgeMesh& b);
/// Convenience dispatcher — route by BooleanOp enum
HalfedgeMesh mesh_boolean(const HalfedgeMesh& a, const HalfedgeMesh& b, BooleanOp op);
/// ── Point classification ─────────────────────────────────
/// Test whether point `p` is inside `mesh` using ray-casting
bool is_point_inside_mesh(const core::Point3D& p, const HalfedgeMesh& mesh);
} // namespace vde::boolean