diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp index 1669ad4941356b63d7f9d3f7a306a6d742a77dce..5422fa378132503c16270ecb1f4295ea0c4f0b9c 100644 --- a/ProcessLib/DeactivatedSubdomain.cpp +++ b/ProcessLib/DeactivatedSubdomain.cpp @@ -50,4 +50,20 @@ bool DeactivatedSubdomain::includesTimeOf(double const t) const t <= time_interval.getSupportMax(); } +bool DeactivatedSubdomain::isDeactivated(MathLib::Point3d const& point, + double const time) const +{ + // Line from a to b. + auto const& a = line_segment.first; + auto const& b = line_segment.second; + // Tangent vector t = (b - a)/|b - a|. + Eigen::Vector3d const t = (b - a).normalized(); + + // Position r on the line at given time. + Eigen::Vector3d const r = a + t * time_interval.getValue(time); + Eigen::Map<Eigen::Vector3d const> const p{point.getCoords(), 3}; + + // Return true if p is "behind" the plane through r. + return (p - r).dot(t) <= 0; +} } // namespace ProcessLib diff --git a/ProcessLib/DeactivatedSubdomain.h b/ProcessLib/DeactivatedSubdomain.h index f48b71c63fae2418514b55ad4b3d030d439cdf14..a2832b63dd470a6580024df06e21bcd2adb21c17 100644 --- a/ProcessLib/DeactivatedSubdomain.h +++ b/ProcessLib/DeactivatedSubdomain.h @@ -18,6 +18,7 @@ #include <vector> #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h" +#include "MathLib/Point3d.h" namespace MeshLib { @@ -49,6 +50,12 @@ struct DeactivatedSubdomain bool includesTimeOf(double const t) const; + /// \returns true if the point is in the deactivated part of the subdomain. + /// The domain is split into two parts by a plane defined as a normal plane + /// of the line segment and the position on the line segment, where the + /// latter is defined by the time curve. + bool isDeactivated(MathLib::Point3d const& point, double const time) const; + MathLib::PiecewiseLinearInterpolation const time_interval; /// Line segment along which excavation progresses. Represented by start and