Skip to content

Commit

Permalink
Fix issue in SliceTriangleGeometry where double/triple points were be…
Browse files Browse the repository at this point in the history
…ing generated.

Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Dec 27, 2024
1 parent db072b6 commit 87b16da
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Parameters SliceTriangleGeometryFilter::parameters() const
params.insertSeparator(Parameters::Separator{"Input Parameter(s)"});
params.insertLinkableParameter(std::make_unique<ChoicesParameter>(k_SliceRange_Key, "Slice Range", "Type of slice range to use, either Full Range or User Defined Range", 0,
ChoicesParameter::Choices{"Full Range", "User Defined Range"}));
params.insert(std::make_unique<Float32Parameter>(k_Zstart_Key, "Slicing Start", "The z axis start value", 0.0f));
params.insert(std::make_unique<Float32Parameter>(k_Zend_Key, "Slicing End", "The z axis stop value", 0.0f));
params.insert(std::make_unique<Float32Parameter>(k_Zstart_Key, "Slicing Start", "The z axis start value. Only needed for 'User Defined Range'", 0.0f));
params.insert(std::make_unique<Float32Parameter>(k_Zend_Key, "Slicing End", "The z axis stop value. Only needed for 'User Defined Range'", 0.0f));
params.insert(std::make_unique<Float32Parameter>(k_SliceResolution_Key, "Slice Spacing", "The spacing between slices", 1.0f));

params.insertSeparator(Parameters::Separator{"Input Geometry"});
Expand All @@ -88,7 +88,7 @@ Parameters SliceTriangleGeometryFilter::parameters() const
// Associate the Linkable Parameter(s) to the children parameters that they control
params.linkParameters(k_HaveRegionIds_Key, k_RegionIdArrayPath_Key, true);

params.linkParameters(k_SliceRange_Key, k_Zstart_Key, slice_triangle_geometry::constants::k_FullRange);
params.linkParameters(k_SliceRange_Key, k_Zstart_Key, slice_triangle_geometry::constants::k_UserDefinedRange);
params.linkParameters(k_SliceRange_Key, k_Zend_Key, slice_triangle_geometry::constants::k_UserDefinedRange);
return params;
}
Expand Down
48 changes: 26 additions & 22 deletions src/simplnx/Utilities/GeometryUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ struct PointInfo
{
location = 1; // Above the plane
}
else if(SignedDistance < EPSILON)
else if(SignedDistance < -EPSILON)
{
location = 2; // Below the plane
}
Expand Down Expand Up @@ -380,43 +380,47 @@ Edge IntersectTriangleWithPlane(const Point3Df& v0, const Point3Df& v1, const Po
return e.start + (e.end - e.start) * t; // Return the interpolated point
};

// Handle cases where only one intersection point is found (vertex lies on plane)
// Find the vertex that lies on the plane

if(p0.onPlane() && zeroCount == 1)
{
return {v0, v0};
}
else if(p1.onPlane() && zeroCount == 1)
// Handle case where the triangle lies entirely on the plane
if(zeroCount == 3)
{
return {v1, v1};
// Return any edge of the triangle
// return {v0, v1};
return {}; // Return invalid
}
else if(p2.onPlane() && zeroCount == 1)

// Handle cases where only one intersection point is found (vertex lies on plane)
// Find the vertex that lies on the plane
if(zeroCount == 1)
{
return {v2, v2};
return {};
}
// if(p0.onPlane() && zeroCount == 1)
// {
// return {v0, v0};
// }
// else if(p1.onPlane() && zeroCount == 1)
// {
// return {v1, v1};
// }
// else if(p2.onPlane() && zeroCount == 1)
// {
// return {v2, v2};
// }

// Check edges for coincidence with plane
if(p0.onPlane() && p1.onPlane())
if(p0.onPlane() && p1.onPlane() && zeroCount == 2)
{
return {v0, v1};
}
if(p1.onPlane() && p2.onPlane())
if(p1.onPlane() && p2.onPlane() && zeroCount == 2)
{
return {v1, v2};
}
if(p0.onPlane() && p2.onPlane())
if(p0.onPlane() && p2.onPlane() && zeroCount == 2)
{
return {v0, v2};
}

// Handle case where the triangle lies entirely on the plane
if(zeroCount == 3)
{
// Return any edge of the triangle
return {v0, v1};
}

if(p0.planeSplitsEdge(p1) && p0.planeSplitsEdge(p2))
{
auto intersectionPoint0 = computeIntersection({v0, v1}, p0.SignedDistance, p1.SignedDistance);
Expand Down

0 comments on commit 87b16da

Please sign in to comment.