implement trimming of a mesh with a plane

This commit is contained in:
wmayer
2019-09-14 17:05:20 +02:00
parent b48e8b0f0d
commit 79a722830d
8 changed files with 296 additions and 44 deletions

View File

@@ -268,6 +268,25 @@ bool MeshGeomEdge::IntersectWithLine (const Base::Vector3f &rclPt,
return dist2 + dist3 <= dist1 + eps;
}
bool MeshGeomEdge::IntersectWithPlane (const Base::Vector3f &rclPt,
const Base::Vector3f &rclDir,
Base::Vector3f &rclRes) const
{
float dist1 = _aclPoints[0].DistanceToPlane(rclPt, rclDir);
float dist2 = _aclPoints[1].DistanceToPlane(rclPt, rclDir);
// either both points are below or above the plane
if (dist1 * dist2 >= 0.0f)
return false;
Base::Vector3f u = _aclPoints[1] - _aclPoints[0];
Base::Vector3f b = rclPt - _aclPoints[0];
float t = b.Dot(rclDir) / u.Dot(rclDir);
rclRes = _aclPoints[0] + t * u;
return true;
}
void MeshGeomEdge::ProjectPointToLine (const Base::Vector3f &rclPoint,
Base::Vector3f &rclProj) const
{