Skip to content

Commit

Permalink
[fuseCut] DelaunayGraphCut: Use an adaptive epsilon factor for the in…
Browse files Browse the repository at this point in the history
…tersection of geometries
  • Loading branch information
dsmtE committed Aug 4, 2020
1 parent cc3859b commit d4b8063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/aliceVision/fuseCut/DelaunayGraphCut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ DelaunayGraphCut::GeometryIntersection
DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection& inGeometry,
const Point3d& originPt,
const Point3d& dirVect, Point3d& intersectPt,
const float epsilon, const Point3d& lastIntersectPt) const
const double epsilonFactor, const Point3d& lastIntersectPt) const
{

switch (inGeometry.type)
Expand All @@ -1295,7 +1295,7 @@ DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection

const Facet intersectionFacet(tetrahedronIndex, i);

const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, intersectionFacet, intersectPt, epsilon, &lastIntersectPt);
const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, intersectionFacet, intersectPt, epsilonFactor, &lastIntersectPt);
if (result.type != EGeometryType::None)
return result;
}
Expand All @@ -1315,7 +1315,7 @@ DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection
// Define the facet to intersect
const Facet facet(adjCellIndex, localVertexIndex);

const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilon, &lastIntersectPt);
const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilonFactor, &lastIntersectPt);
if (result.type != EGeometryType::None)
return result;
}
Expand All @@ -1339,7 +1339,7 @@ DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection

for (const Facet& facet : opositeFacets)
{
const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilon, &lastIntersectPt);
const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilonFactor, &lastIntersectPt);
if (result.type != EGeometryType::None)
return result;
}
Expand All @@ -1358,7 +1358,7 @@ DelaunayGraphCut::GeometryIntersection DelaunayGraphCut::rayIntersectTriangle(co
const Point3d& DirVec,
const DelaunayGraphCut::Facet& facet,
Point3d& intersectPt,
const float epsilon, const Point3d* lastIntersectPt) const
const double epsilonFactor, const Point3d* lastIntersectPt) const
{
const VertexIndex AvertexIndex = getVertexIndex(facet, 0);
const VertexIndex BvertexIndex = getVertexIndex(facet, 1);
Expand All @@ -1368,6 +1368,7 @@ DelaunayGraphCut::GeometryIntersection DelaunayGraphCut::rayIntersectTriangle(co
const Point3d* B = &_verticesCoords[BvertexIndex];
const Point3d* C = &_verticesCoords[CvertexIndex];

const double epsilon = std::min(std::min((*A - *B).size(), (*B - *C).size()), (*A - *C).size()) * epsilonFactor;
Point3d tempIntersectPt;
const Point2d triangleUv = getLineTriangleIntersectBarycCoords(&tempIntersectPt, A, B, C, &originPt, &DirVec);

Expand Down
10 changes: 6 additions & 4 deletions src/aliceVision/fuseCut/DelaunayGraphCut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,13 @@ class DelaunayGraphCut
* @param originPt ray origin point
* @param dirVect ray direction
* @param intersectPt a reference that will store the computed intersection point for the intersected geometry
* @param epsilon used to define the boundary when we have to consider either a collision with an edge/vertex or a facet
* @param epsilonFactor a multiplicative factor on the smaller side of the facet used to define the boundary when we
* have to consider either a collision with an edge/vertex or a facet.
* @param lastIntersectPt constant reference to the last intersection point used to test the direction.
* @return
*/
GeometryIntersection intersectNextGeom(const GeometryIntersection& inGeometry, const Point3d& originPt,
const Point3d& dirVect, Point3d& intersectPt, const float epsilon, const Point3d& lastIntersectPt) const;
const Point3d& dirVect, Point3d& intersectPt, const double epsilonFactor, const Point3d& lastIntersectPt) const;

/**
* @brief Function that returns the next geometry intersected by the ray on a given facet or None if there are no intersected geometry.
Expand All @@ -393,12 +394,13 @@ class DelaunayGraphCut
* @param DirVec ray direction
* @param facet the given facet to intersect with
* @param intersectPt a reference that will store the computed intersection point for the next intersecting geometry
* @param epsilon used to define the boundary when we have to consider either a collision with an edge/vertex or a facet
* @param epsilonFactor a multiplicative factor on the smaller side of the facet used to define the boundary when we
* have to consider either a collision with an edge/vertex or a facet.
* @param lastIntersectPt pointer to the last intersection point used to test the direction (if not nulllptr)
* @return
*/
GeometryIntersection rayIntersectTriangle(const Point3d& originPt, const Point3d& DirVec, const Facet& facet,
Point3d& intersectPt, const float epsilon, const Point3d* lastIntersectPt = nullptr) const;
Point3d& intersectPt, const double epsilonFactor, const Point3d* lastIntersectPt = nullptr) const;

float distFcn(float maxDist, float dist, float distFcnHeight) const;

Expand Down

0 comments on commit d4b8063

Please sign in to comment.