41 std::pair<double,double>* weights)
46 double dotp_0 = plane_normal.
Dot(v0);
47 double dotp_1 = plane_normal.
Dot(v1);
49 bool sense_0 = (dotp_0 >= 0.0);
50 bool sense_1 = (dotp_1 >= 0.0);
52 if (sense_0 != sense_1)
54 double dotp_total = std::fabs(dotp_0) + std::fabs(dotp_1);
55 double w0 = (std::fabs(dotp_0)/dotp_total);
57 intersection_point = line_point_0*w1 + line_point_1*w0;
59 if (weights !=
nullptr)
84 double* distance_to_intersection)
87 std::pair<double,double> weights;
90 strip_normal, strip_point0,
91 line_point0, line_point1,
92 plane_intersection_point, &weights);
94 if (!intersects_plane)
return false;
100 bool sense1 = edge_vec.
Dot(ints_vec1)>=0.0;
101 bool sense2 = edge_vec.
Dot(ints_vec2)>=0.0;
103 if (distance_to_intersection !=
nullptr)
104 *distance_to_intersection =
105 (plane_intersection_point - line_point0).Norm();
107 if (sense1 != sense2)
109 intersection_point = plane_intersection_point;
130 double* distance_to_intersection)
132 double epsilon = 1.0e-12;
144 double a = edge1.
Dot(h);
145 if (std::fabs(a) < epsilon)
155 double u = f*(s.
Dot(h));
164 double v = f*ray_dir.
Dot(q);
165 if (v<0.0 or (u+v)>1.0)
168 double t = f*edge2.
Dot(q);
170 if (distance_to_intersection !=
nullptr)
171 *distance_to_intersection = t;
173 if (t > epsilon and t<(1.0/epsilon))
175 intersection_point = ray_posi + ray_dir*t;
197 auto v0p = point - v0;
198 auto v1p = point - v1;
199 auto v2p = point - v2;
201 auto vc0 = v01.
Cross(v0p);
202 auto vc1 = v12.
Cross(v1p);
203 auto vc2 = v20.
Cross(v2p);
205 bool dp0 = (vc0.Dot(n) >= 0.0);
206 bool dp1 = (vc1.Dot(n) >= 0.0);
207 bool dp2 = (vc2.Dot(n) >= 0.0);
209 if (dp0 and dp1 and dp2)
228 const std::vector<chi_mesh::Vector3>& tet_points)
230 bool current_sense =
false;
232 size_t num_points = tet_points.size();
233 for (
size_t i=0; i<num_points; i++)
236 double dotp = plane_normal.
Dot(v);
238 bool new_sense = (dotp >= 0.0);
241 current_sense = new_sense;
242 else if (new_sense != current_sense)
258 std::vector<double> &segment_lengths)
261 std::set<double> distance_set;
264 if (segment_lengths.empty())
266 track_length = (line_point1-line_point0).Norm();
267 segment_lengths.push_back(track_length);
270 track_length = segment_lengths.front();
271 distance_set.insert(track_length);
288 for (
auto& face : cell.
faces_)
291 const auto& v0 = grid.
vertices[face.vertex_ids_[0]];
300 line_point0, line_point1,
301 intersection_point, &d);
306 distance_set.insert(d);
316 for (
auto& face : cell.
faces_)
319 auto& vfc = face.centroid_;
322 for (
auto vi : face.vertex_ids_)
330 vert,vfc,vcc,line_point0,omega,intersection_point,&d);
334 if (d < track_length)
335 distance_set.insert(d);
340 for (
int v=0; v<face.vertex_ids_.size(); ++v)
342 uint64_t vid_0 = face.vertex_ids_[v];
343 uint64_t vid_1 = (v<(face.vertex_ids_.size() - 1)) ?
344 face.vertex_ids_[v + 1] :
355 v0,v1,v2,line_point0,omega,intersection_point,&d);
359 if (d < track_length)
360 distance_set.insert(d);
369 segment_lengths.clear();
370 double last_distance = 0.0;
371 for (
double dl : distance_set)
373 double new_seg_length = dl - last_distance;
375 segment_lengths.push_back(new_seg_length);
std::vector< CellFace > faces_
bool CheckPlaneTetIntersect(const chi_mesh::Normal &plane_normal, const chi_mesh::Vector3 &plane_point, const std::vector< chi_mesh::Vector3 > &tet_points)
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)
bool CheckPlaneLineIntersect(const chi_mesh::Normal &plane_normal, const chi_mesh::Vector3 &plane_point, const chi_mesh::Vector3 &line_point_0, const chi_mesh::Vector3 &line_point_1, chi_mesh::Vector3 &intersection_point, std::pair< double, double > *weights=nullptr)
void PopulateRaySegmentLengths(const chi_mesh::MeshContinuum &grid, const Cell &cell, const chi_mesh::Vector3 &line_point0, const chi_mesh::Vector3 &line_point1, const chi_mesh::Vector3 &omega, std::vector< double > &segment_lengths)
bool CheckLineIntersectStrip(const chi_mesh::Vector3 &strip_point0, const chi_mesh::Vector3 &strip_point1, const chi_mesh::Vector3 &strip_normal, const chi_mesh::Vector3 &line_point0, const chi_mesh::Vector3 &line_point1, chi_mesh::Vector3 &intersection_point, double *distance_to_intersection=nullptr)
bool CheckPointInTriangle(const chi_mesh::Vector3 &v0, const chi_mesh::Vector3 &v1, const chi_mesh::Vector3 &v2, const chi_mesh::Normal &n, const chi_mesh::Vector3 &point)
Vector3 Cross(const Vector3 &that) const
Vector3 Normalized() const
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const