|
|
|
@ -8,10 +8,9 @@ |
|
|
|
namespace internal |
|
|
|
{ |
|
|
|
|
|
|
|
double integrator_t::calculate(int gauss_order, double (*func)(double u, double v, |
|
|
|
const Eigen::Vector3d& p, |
|
|
|
const Eigen::Vector3d& dU, |
|
|
|
const Eigen::Vector3d& dV)) const |
|
|
|
double integrator_t::calculate( |
|
|
|
int gauss_order, |
|
|
|
double (*func)(double u, double v, const Eigen::Vector3d& p, const Eigen::Vector3d& dU, const Eigen::Vector3d& dV)) const |
|
|
|
{ |
|
|
|
double total_integral = 0.0; |
|
|
|
for (const auto& [subface_index, param_plane] : m_uv_planes) { |
|
|
|
@ -21,17 +20,18 @@ double integrator_t::calculate(int gauss_order, double (*func)(double u, double |
|
|
|
return total_integral; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double integrator_t::calculate_one_subface(const subface& subface, const parametric_plane_t& param_plane, int gauss_order, double (*func)(double u, double v, |
|
|
|
const Eigen::Vector3d& p, |
|
|
|
const Eigen::Vector3d& dU, |
|
|
|
const Eigen::Vector3d& dV)) const |
|
|
|
double integrator_t::calculate_one_subface( |
|
|
|
const subface& subface, |
|
|
|
const parametric_plane_t& param_plane, |
|
|
|
int gauss_order, |
|
|
|
double (*func)(double u, double v, const Eigen::Vector3d& p, const Eigen::Vector3d& dU, const Eigen::Vector3d& dV)) const |
|
|
|
{ |
|
|
|
auto solver = subface.fetch_solver_evaluator(); |
|
|
|
// Gaussian integration in u direction
|
|
|
|
auto u_integrand = [&](double u) { |
|
|
|
// Find exact v intersections for each u
|
|
|
|
stl_vector_mp<double> v_breaks = find_v_intersections_at_u(subface, param_plane, u);; |
|
|
|
stl_vector_mp<double> v_breaks = find_v_intersections_at_u(subface, param_plane, u); |
|
|
|
; |
|
|
|
|
|
|
|
// Gaussian integration in v direction
|
|
|
|
auto v_integrand = [&](double v) { |
|
|
|
@ -103,10 +103,7 @@ double integrator_t::calculate_one_subface(const subface& subface, const paramet |
|
|
|
* TODO: Use a tolerance-based approach to avoid floating-point precision issues |
|
|
|
* when inserting u-values (e.g., merge values within 1e-12). |
|
|
|
*/ |
|
|
|
stl_vector_mp<double> integrator_t::compute_u_breaks( |
|
|
|
const parametric_plane_t& param_plane, |
|
|
|
double u_min, |
|
|
|
double u_max) const |
|
|
|
stl_vector_mp<double> integrator_t::compute_u_breaks(const parametric_plane_t& param_plane, double u_min, double u_max) const |
|
|
|
{ |
|
|
|
std::set<double> break_set; |
|
|
|
|
|
|
|
@ -126,9 +123,7 @@ stl_vector_mp<double> integrator_t::compute_u_breaks( |
|
|
|
return stl_vector_mp<double>(break_set.begin(), break_set.end()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stl_vector_mp<double> integrator_t::find_v_intersections_at_u( |
|
|
|
const subface& subface, |
|
|
|
stl_vector_mp<double> integrator_t::find_v_intersections_at_u(const subface& subface, |
|
|
|
const parametric_plane_t& param_plane, |
|
|
|
double u_val) const |
|
|
|
{ |
|
|
|
@ -162,9 +157,7 @@ stl_vector_mp<double> integrator_t::find_v_intersections_at_u( |
|
|
|
int pos2 = sign_cmp(u2); |
|
|
|
|
|
|
|
// Case 1: Both endpoints on the same side (and not on the line) → no intersection
|
|
|
|
if (pos1 * pos2 > 0) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (pos1 * pos2 > 0) { continue; } |
|
|
|
|
|
|
|
// Case 2: Both endpoints lie exactly on u = u_val → add both v-values
|
|
|
|
if (pos1 == 0 && pos2 == 0) { |
|
|
|
@ -178,8 +171,7 @@ stl_vector_mp<double> integrator_t::find_v_intersections_at_u( |
|
|
|
intersections.push_back(v1_val); |
|
|
|
intersections.push_back(v2_val); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// General case: non-vertical segment crossing u = u_val
|
|
|
|
// Compute linear interpolation parameter t
|
|
|
|
double t = (u_val - u1) / (u2 - u1); |
|
|
|
@ -209,9 +201,7 @@ stl_vector_mp<double> integrator_t::find_v_intersections_at_u( |
|
|
|
} |
|
|
|
|
|
|
|
// Final step: sort and remove duplicates within tolerance
|
|
|
|
if (!intersections.empty()) { |
|
|
|
sort_and_unique_with_tol(intersections, 1e-8); |
|
|
|
} |
|
|
|
if (!intersections.empty()) { sort_and_unique_with_tol(intersections, 1e-8); } |
|
|
|
|
|
|
|
return intersections; |
|
|
|
} |
|
|
|
@ -223,8 +213,7 @@ stl_vector_mp<double> integrator_t::find_v_intersections_at_u( |
|
|
|
NOTE: when v_intersect - v < threshold, further checks are required to accurately determine if the intersection point lies |
|
|
|
precisely on the boundary segment. |
|
|
|
*/ |
|
|
|
bool integrator_t::is_point_inside_domain( |
|
|
|
const subface& subface, |
|
|
|
bool integrator_t::is_point_inside_domain(const subface& subface, |
|
|
|
const parametric_plane_t& param_plane, |
|
|
|
double u, |
|
|
|
double v) const |
|
|
|
@ -238,18 +227,14 @@ bool integrator_t::is_point_inside_domain( |
|
|
|
double diff = v_int - v; |
|
|
|
if (diff > tol_above) { |
|
|
|
count++; |
|
|
|
} |
|
|
|
else if (std::abs(diff) < tol_near) { |
|
|
|
} else if (std::abs(diff) < tol_near) { |
|
|
|
return true; // on boundary → inside
|
|
|
|
} |
|
|
|
} |
|
|
|
return (count % 2) == 1; |
|
|
|
} |
|
|
|
|
|
|
|
bool integrator_t::is_u_near_singularity(double u, double tol) const |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
bool integrator_t::is_u_near_singularity(double u, double tol) const { return false; } |
|
|
|
|
|
|
|
void integrator_t::sort_and_unique_with_tol(stl_vector_mp<double>& vec, double epsilon) const |
|
|
|
{ |
|
|
|
@ -269,8 +254,7 @@ void integrator_t::sort_and_unique_with_tol(stl_vector_mp<double>& vec, double e |
|
|
|
} |
|
|
|
|
|
|
|
// Only accepts functions that return implicit_equation_intermediate
|
|
|
|
double newton_method( |
|
|
|
const std::function<internal::implicit_equation_intermediate(double)>& F, |
|
|
|
double newton_method(const std::function<internal::implicit_equation_intermediate(double)>& F, |
|
|
|
double v_initial, |
|
|
|
double tolerance, |
|
|
|
int max_iterations) |
|
|
|
|