11 bool& intersection_found,
12 bool& backward_tolerance_hit,
15 const auto& grid =
Grid();
18 std::vector<RayTracerOutputInformation> triangle_intersections;
20 size_t num_faces = cell.
faces_.size();
21 triangle_intersections.reserve(num_faces*4);
22 for (
int f=0; f<num_faces; f++)
24 const auto& face = cell.
faces_[f];
26 size_t num_sides = face.vertex_ids_.size();
27 for (
size_t s=0; s<num_sides; s++)
29 size_t v0_index = face.vertex_ids_[s];
30 size_t v1_index = (s<(num_sides-1)) ?
31 face.vertex_ids_[s + 1] :
33 const auto& v0 = grid.vertices[v0_index];
34 const auto& v1 = grid.vertices[v1_index];
35 const auto& v2 = cell.
faces_[f].centroid_;
39 auto n_est = v01.Cross(v02);
41 if (n_est.Dot(omega_i) < 0.0)
continue;
51 triangle_oi.
pos_f = ip;
56 intersection_found =
true;
57 triangle_intersections.emplace_back(std::move(triangle_oi));
67 oi = triangle_intersections.back();
70 auto closest_intersection = &triangle_intersections.back();
71 for (
auto& intersection : triangle_intersections)
72 if (intersection.distance_to_surface <
73 closest_intersection->distance_to_surface)
74 closest_intersection = &intersection;
76 oi = *closest_intersection;
std::vector< CellFace > faces_
bool perform_concavity_checks_
void TracePolyhedron(const Cell &cell, Vector3 &pos_i, Vector3 &omega_i, bool &intersection_found, bool &backward_tolerance_hit, RayTracerOutputInformation &oi)
const chi_mesh::MeshContinuum & Grid() const
bool CheckLineIntersectTriangle2(const chi_mesh::Vector3 &tri_point0, const chi_mesh::Vector3 &tri_point1, const chi_mesh::Vector3 &tri_point2, const chi_mesh::Vector3 &ray_posi, const chi_mesh::Vector3 &ray_dir, chi_mesh::Vector3 &intersection_point, double *distance_to_intersection=nullptr)