@@ -35,6 +35,9 @@ function tet_x_plane!(
3535 tol = 0.0
3636 )
3737
38+
39+ debug = false
40+
3841 # If all nodes lie on one side of the plane, no intersection
3942 @fastmath if (
4043 mapreduce (a -> a < - tol, * , planeq_values) ||
@@ -44,23 +47,32 @@ function tet_x_plane!(
4447 end
4548 # Interpolate coordinates and function_values according to
4649 # evaluation of the plane equation
47- nxs = 0
50+ intersection_counter = 0
51+ prohibitedList = @MArray zeros (Bool, 4 )
52+ debug && @info node_indices
4853 @inbounds @simd for n1 in 1 : 3
4954 N1 = node_indices[n1]
5055 @inbounds @fastmath @simd for n2 in (n1 + 1 ): 4
5156 N2 = node_indices[n2]
5257 if planeq_values[n1] != planeq_values[n2] &&
53- planeq_values[n1] * planeq_values[n2] < tol
54- nxs += 1
58+ planeq_values[n1] * planeq_values[n2] < tol # &&
59+ # abs(planeq_values[n2]) > tol
60+ #= if abs(planeq_values[n1] - planeq_values[n2]) > tol && prohibitedList[n1] == false && prohibitedList[n2] == false
61+ if planeq_values[n2] == 0
62+ prohibitedList[n2] = true
63+ end=#
64+ intersection_counter += 1
5565 t = planeq_values[n1] / (planeq_values[n1] - planeq_values[n2])
56- ixcoord[1 , nxs] = pointlist[1 , N1] + t * (pointlist[1 , N2] - pointlist[1 , N1])
57- ixcoord[2 , nxs] = pointlist[2 , N1] + t * (pointlist[2 , N2] - pointlist[2 , N1])
58- ixcoord[3 , nxs] = pointlist[3 , N1] + t * (pointlist[3 , N2] - pointlist[3 , N1])
59- ixvalues[nxs] = function_values[N1] + t * (function_values[N2] - function_values[N1])
66+ ixcoord[1 , intersection_counter] = pointlist[1 , N1] + t * (pointlist[1 , N2] - pointlist[1 , N1])
67+ ixcoord[2 , intersection_counter] = pointlist[2 , N1] + t * (pointlist[2 , N2] - pointlist[2 , N1])
68+ ixcoord[3 , intersection_counter] = pointlist[3 , N1] + t * (pointlist[3 , N2] - pointlist[3 , N1])
69+ ixvalues[intersection_counter] = function_values[N1] + t * (function_values[N2] - function_values[N1])
70+ debug && @show ixcoord
6071 end
6172 end
6273 end
63- return nxs
74+ debug && @info " amount of intersections: " intersection_counter
75+ return intersection_counter
6476end
6577
6678"""
@@ -190,7 +202,7 @@ function marching_tetrahedra(
190202
191203 function pushtris (ns, ixcoord, ixvalues)
192204 # number of intersection points can be 3 or 4
193- return if ns >= 3
205+ if ns >= 3
194206 last_i = length (all_ixvalues)
195207 for is in 1 : ns
196208 @views push! (all_ixcoord, ixcoord[:, is])
@@ -201,6 +213,7 @@ function marching_tetrahedra(
201213 push! (all_ixfaces, (last_i + 3 , last_i + 2 , last_i + 4 ))
202214 end
203215 end
216+ return nothing
204217 end
205218
206219 for igrid in 1 : length (allcoords)
@@ -407,3 +420,28 @@ function marching_triangles(
407420 end
408421 return points, adjacencies, values
409422end
423+
424+
425+ """
426+ Function to estimate amount of intersections of plane and tetrahedron
427+ This was used as a testing function and is not used otherwise
428+ """
429+
430+ function getAmountOfIntersections (planeq_values, tol)
431+ prohibitedList = @MArray zeros (Bool, 4 )
432+ amountOfIntersections = 0
433+ for i in 1 : (length (planeq_values) - 1 )
434+ for j in (i + 1 ): length (planeq_values)
435+ #= if planeq_values[n1] != planeq_values[n2] &&
436+ planeq_values[n1] * planeq_values[n2] < tol &&
437+ abs(planeq_values[n2]) > tol =#
438+ if abs (planeq_values[i] - planeq_values[j]) > tol && prohibitedList[i] == false && prohibitedList[j] == false
439+ amountOfIntersections += 1
440+ if planeq_values[j] == 0
441+ prohibitedList[j] = true
442+ end
443+ end
444+ end
445+ end
446+ return amountOfIntersections
447+ end
0 commit comments