#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 #include 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 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 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 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