feat: P1 complete - geodesic, CDT, NURBS surface
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#include "vde/curves/bspline_curve.h"
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
namespace vde::curves {
|
||||
|
||||
class NurbsSurface {
|
||||
public:
|
||||
NurbsSurface(std::vector<std::vector<Point3D>> control_grid,
|
||||
std::vector<double> knots_u, std::vector<double> knots_v,
|
||||
std::vector<std::vector<double>> weights,
|
||||
int degree_u, int degree_v);
|
||||
|
||||
[[nodiscard]] Point3D evaluate(double u, double v) const;
|
||||
[[nodiscard]] Vector3D derivative_u(double u, double v) const;
|
||||
[[nodiscard]] Vector3D derivative_v(double u, double v) const;
|
||||
[[nodiscard]] Vector3D normal(double u, double v) const;
|
||||
|
||||
[[nodiscard]] int degree_u() const { return degree_u_; }
|
||||
[[nodiscard]] int degree_v() const { return degree_v_; }
|
||||
[[nodiscard]] std::array<int, 2> num_control_points() const {
|
||||
return {static_cast<int>(cp_.size()), static_cast<int>(cp_.empty()?0:cp_[0].size())};
|
||||
}
|
||||
[[nodiscard]] const std::vector<double>& knots_u() const { return knots_u_; }
|
||||
[[nodiscard]] const std::vector<double>& knots_v() const { return knots_v_; }
|
||||
[[nodiscard]] const std::vector<std::vector<Point3D>>& control_points() const { return cp_; }
|
||||
[[nodiscard]] const std::vector<std::vector<double>>& weights() const { return weights_; }
|
||||
|
||||
/// Create a ruled surface between two NURBS curves
|
||||
static NurbsSurface ruled(const NurbsCurve& c1, const NurbsCurve& c2);
|
||||
|
||||
/// Create a surface of revolution
|
||||
static NurbsSurface revolve(const NurbsCurve& profile, const Point3D& axis_origin,
|
||||
const Vector3D& axis_dir, double angle_rad);
|
||||
|
||||
/// Tessellate to triangle mesh
|
||||
[[nodiscard]] std::pair<std::vector<Point3D>, std::vector<std::array<int,3>>>
|
||||
tessellate(int res_u, int res_v) const;
|
||||
|
||||
private:
|
||||
std::vector<std::vector<Point3D>> cp_;
|
||||
std::vector<double> knots_u_, knots_v_;
|
||||
std::vector<std::vector<double>> weights_;
|
||||
int degree_u_, degree_v_;
|
||||
};
|
||||
|
||||
} // namespace vde::curves
|
||||
@@ -21,6 +21,7 @@ using Point2D = Point<double, 2>;
|
||||
using Point3D = Point<double, 3>;
|
||||
using Point2f = Point<float, 2>;
|
||||
using Point3f = Point<float, 3>;
|
||||
using Point4D = Eigen::Matrix<double, 4, 1>;
|
||||
|
||||
using Vector2D = Vector<double, 2>;
|
||||
using Vector3D = Vector<double, 3>;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "vde/mesh/delaunay_2d.h"
|
||||
#include "vde/core/line.h"
|
||||
#include <vector>
|
||||
|
||||
namespace vde::mesh {
|
||||
|
||||
/// Constrained Delaunay Triangulation (CDT) in 2D
|
||||
/// Ensures specified constraint edges appear in the triangulation
|
||||
DelaunayResult constrained_delaunay_2d(
|
||||
const std::vector<Point2D>& points,
|
||||
const std::vector<std::pair<int, int>>& constraints);
|
||||
|
||||
} // namespace vde::mesh
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "vde/mesh/halfedge_mesh.h"
|
||||
#include <vector>
|
||||
|
||||
namespace vde::mesh {
|
||||
|
||||
/// Geodesic distance from source vertices using the Heat Method (Crane et al. 2013)
|
||||
/// Returns per-vertex distance from the nearest source
|
||||
/// @param sources Source vertex indices
|
||||
/// @param t Time step (default = average edge length squared)
|
||||
std::vector<double> geodesic_distance(const HalfedgeMesh& mesh,
|
||||
const std::vector<int>& sources,
|
||||
double t = -1.0);
|
||||
|
||||
} // namespace vde::mesh
|
||||
Reference in New Issue
Block a user