You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1.1 KiB

8 months ago
#include "patch_integrator.hpp"
std::pair<double, double> PatchIntegrator::integrate(const stl_vector_mp<raw_point_t>& vertices,
const stl_vector_mp<polygon_face_t>& faces,
const stl_vector_mp<uint32_t>& face_of_patch_mapping) noexcept
{
std::pair<double, double> result{}; // (surface_integral, volume_integral)
Eigen::Vector3d temp_area_vector{};
for (const auto& face_id : face_of_patch_mapping) {
const auto& face = faces[face_id];
const auto& vertex_ids = face.vertex_indices;
const auto& v0 = vertices[vertex_ids[0]];
Eigen::Vector3d area_vector_sum{};
for (auto iter = vertex_ids.begin() + 2; iter != vertex_ids.end(); ++iter) {
const auto &v1 = vertices[*(iter - 1)], v2 = vertices[*iter];
temp_area_vector = (v1 - v0).cross(v2 - v0);
area_vector_sum += temp_area_vector;
result.first += temp_area_vector.norm() * 0.5;
}
result.second += v0.dot(area_vector_sum) / 6;
}
return result;
}