(#397) Added line triangle intersection direction to intersection method

Preparing for Well Log Extraction
This commit is contained in:
Jacob Støren 2015-08-30 21:27:53 +02:00
parent 7794a66b04
commit 62bc5963ff
2 changed files with 9 additions and 3 deletions

View File

@ -374,9 +374,11 @@ double GeometryTools::linePointSquareDist(const cvf::Vec3d& p1, const cvf::Vec3d
int GeometryTools::intersectLineSegmentTriangle( const cvf::Vec3d p0, const cvf::Vec3d p1,
const cvf::Vec3d t0, const cvf::Vec3d t1, const cvf::Vec3d t2,
cvf::Vec3d* intersectionPoint )
cvf::Vec3d* intersectionPoint , bool * isLineDirDotNormalNegative)
{
CVF_ASSERT(intersectionPoint != NULL);
CVF_TIGHT_ASSERT(intersectionPoint != NULL);
CVF_TIGHT_ASSERT(isLineDirDotNormalNegative != NULL);
cvf::Vec3d u, v, n; // triangle vectors
cvf::Vec3d dir, w0, w; // ray vectors
double r, a, b; // params to calc ray-plane intersect
@ -392,6 +394,9 @@ int GeometryTools::intersectLineSegmentTriangle( const cvf::Vec3d p0, const cvf:
w0 = p0 - t0;
a = -dot(n, w0);
b = dot(n, dir);
(*isLineDirDotNormalNegative) = (b < 0.0);
if (fabs(b) < SMALL_NUM) { // ray is parallel to triangle plane
if (a == 0) // ray lies in triangle plane
return 2;

View File

@ -39,7 +39,8 @@ public:
static double linePointSquareDist(const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& p3);
static int intersectLineSegmentTriangle( const cvf::Vec3d p0, const cvf::Vec3d p1,
const cvf::Vec3d t0, const cvf::Vec3d t1, const cvf::Vec3d t2,
cvf::Vec3d* intersectionPoint );
cvf::Vec3d* intersectionPoint,
bool * isLineDirDotNormalNegative);
static cvf::Vec3d barycentricCoords(const cvf::Vec3d& t0, const cvf::Vec3d& t1, const cvf::Vec3d& t2, const cvf::Vec3d& p);
static cvf::Vec4d barycentricCoords(const cvf::Vec3d& v0, const cvf::Vec3d& v1, const cvf::Vec3d& v2, const cvf::Vec3d& v3, const cvf::Vec3d& p);
static double interpolateQuad(const cvf::Vec3d& v1, double s1,