feat(v3.6): TrimmedSurface — B-Rep fundamental primitive
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
#include "vde/curves/nurbs_surface.h"
|
||||
#include "vde/curves/nurbs_curve.h"
|
||||
#include "vde/core/point.h"
|
||||
#include "vde/core/aabb.h"
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace vde::brep {
|
||||
|
||||
/// A p-curve: 2D curve in the parameter space of a surface
|
||||
/// We reuse NurbsCurve with Z=0 — only X (u) and Y (v) are meaningful.
|
||||
using PCurve = curves::NurbsCurve;
|
||||
|
||||
/// Trimming loop: closed contour in parameter space (u, v)
|
||||
/// An outer loop defines the boundary; inner loops define holes.
|
||||
struct TrimLoop {
|
||||
std::vector<PCurve> p_curves; ///< parameter-space curves forming the loop
|
||||
bool is_outer = true; ///< true = outer boundary, false = hole
|
||||
};
|
||||
|
||||
/// A trimmed surface: base NURBS surface + trimming loops in parameter space
|
||||
///
|
||||
/// Point classification: a parameter (u, v) is INSIDE if it lies within
|
||||
/// the outer loop AND outside all inner loops.
|
||||
///
|
||||
/// This is the fundamental B-Rep primitive used by all industrial CAD kernels
|
||||
/// (Parasolid, ACIS, CGM).
|
||||
///
|
||||
/// @ingroup brep
|
||||
struct TrimmedSurface {
|
||||
curves::NurbsSurface base_surface; ///< Underlying geometry
|
||||
std::vector<TrimLoop> loops; ///< Trimming loops (first = outer boundary if marked)
|
||||
|
||||
/// Evaluate the surface at (u, v).
|
||||
/// Returns the 3D point only if (u, v) is inside the trimmed region.
|
||||
/// @return Point3D if inside, std::nullopt if outside
|
||||
[[nodiscard]] std::optional<core::Point3D> evaluate(double u, double v) const;
|
||||
|
||||
/// Check if a parameter point is inside the trimmed region
|
||||
[[nodiscard]] bool is_inside(double u, double v) const;
|
||||
|
||||
/// Get the axis-aligned bounding box of the trimmed surface
|
||||
[[nodiscard]] core::AABB3D bounds() const;
|
||||
|
||||
/// Create an untrimmed surface (full parameter domain)
|
||||
static TrimmedSurface from_surface(const curves::NurbsSurface& surf);
|
||||
|
||||
/// Create a rectangular trimmed surface
|
||||
static TrimmedSurface from_rect(const curves::NurbsSurface& surf,
|
||||
double u0, double u1, double v0, double v1);
|
||||
};
|
||||
|
||||
} // namespace vde::brep
|
||||
Reference in New Issue
Block a user