Skip to content

Commit

Permalink
Extract all lines: correct results
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Haumont committed May 26, 2024
1 parent 18e0d87 commit f22e915
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 67 deletions.
7 changes: 7 additions & 0 deletions visilib/plucker_polytope.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ namespace visilib
{
return true;
}
const std::vector<size_t>& facets1 = polyhedron->getFacetsDescription(iter->first);
const std::vector<size_t>& facets2 = polyhedron->getFacetsDescription(iter->second);

if (facets1.size() == facets2.size() && std::equal(facets1.begin(), facets1.end(), facets2.begin()))
{
return true;
}
}

return false;
Expand Down
68 changes: 38 additions & 30 deletions visilib/visibility_aperture_finder.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace visilib

VisibilityResult resolve();
private:
VisibilityResult resolveInternal(PluckerPolytope<P>* aPolytope, const std::string& occlusionTreeNodeSymbol, const std::vector<Silhouette*>& anOccluders, const std::vector<P>& aPolytopeLines, int depth);
VisibilityResult resolveInternal(VisibilityResult& aGlobalResult, PluckerPolytope<P>* aPolytope, const std::string& occlusionTreeNodeSymbol, const std::vector<Silhouette*>& anOccluders, const std::vector<P>& aPolytopeLines, int depth);
void resize(size_t myInitiaLineCount, PluckerPolyhedron<P>* myPolyhedron, PluckerPolytope<P>* aPolytope);
void extractStabbingLines(PluckerPolyhedron<P>* myPolyhedron, PluckerPolytope<P>* aPolytope);

Expand All @@ -80,11 +80,15 @@ namespace visilib
template <class P, class S>
VisibilityResult VisibilityApertureFinder<P, S>::resolve()
{
return resolveInternal(reinterpret_cast<PluckerPolytope<P>*>(VisibilitySolver<P, S>::mQuery->getComplex()->getRoot()), "*", std::vector<Silhouette*>(), std::vector<P>(), 0);
VisibilityResult myGlobalResult = HIDDEN;

resolveInternal(myGlobalResult, reinterpret_cast<PluckerPolytope<P>*>(VisibilitySolver<P, S>::mQuery->getComplex()->getRoot()), "*", std::vector<Silhouette*>(), std::vector<P>(), 0);

return myGlobalResult;
}

template<class P, class S>
VisibilityResult VisibilityApertureFinder<P, S>::resolveInternal(PluckerPolytope<P>* aPolytope, const std::string& occlusionTreeNodeSymbol, const std::vector<Silhouette*>& anOccluders, const std::vector<P>& aPolytopeLines, int aDepth)
VisibilityResult VisibilityApertureFinder<P, S>::resolveInternal(VisibilityResult& aGlobalResult, PluckerPolytope<P>* aPolytope, const std::string& occlusionTreeNodeSymbol, const std::vector<Silhouette*>& anOccluders, const std::vector<P>& aPolytopeLines, int aDepth)
{
PluckerPolyhedron<P>* myPolyhedron = reinterpret_cast<PluckerPolyhedron<P>*> (VisibilitySolver<P, S>::mQuery->getComplex()->getPolyhedron());
size_t myInitiaLineCount = myPolyhedron->getLinesCount();
Expand All @@ -94,14 +98,13 @@ namespace visilib
V_LOG(debugOutput, "Resolve internal ", occlusionTreeNodeSymbol);
aPolytope->outputProperties(debugOutput, myPolyhedron);
#endif
VisibilityResult globalResult = HIDDEN;
if (aDepth > 2000)
{
std::cerr << "Overflow detected: more than 200 recursive calls...." << std::endl;
#ifdef OUTPUT_DEBUG_FILE
V_LOG(debugOutput, "RESULT FAILURE: Overflow detected : more than 2000 recursive calls....", occlusionTreeNodeSymbol);
#endif
V_ASSERT(0);
aGlobalResult = FAILURE;
return FAILURE;
}
{
Expand All @@ -111,7 +114,7 @@ namespace visilib
if (!aPolytope->containsRealLines())
{
#ifdef OUTPUT_DEBUG_FILE
V_LOG(debugOutput, "RESULT UNKNOWN: polytope does not contains real line", occlusionTreeNodeSymbol);
V_LOG(debugOutput, "RESULT HIDDEN: polytope does not contains real line", occlusionTreeNodeSymbol);
#endif
return HIDDEN;
}
Expand All @@ -130,10 +133,10 @@ namespace visilib
V_LOG(debugOutput, "RAY: IS VISIBLE", occlusionTreeNodeSymbol);
#endif
hasRay = true;
globalResult = VISIBLE;
aGlobalResult = VISIBLE;
if (mDetectApertureOnly)
{
return globalResult;
return VISIBLE;
}
}
else
Expand All @@ -144,24 +147,23 @@ namespace visilib
}
}

if (mDetectApertureOnly)
{
HelperScopedTimer timer(VisibilitySolver<P, S>::mQuery->getStatistic(), OCCLUDER_TREATMENT);
if (VisibilitySolver<P, S>::mQuery->isOccluded(aPolytope, myPolyhedron, myOccluders, polytopeLines))
{
HelperScopedTimer timer(VisibilitySolver<P, S>::mQuery->getStatistic(), OCCLUDER_TREATMENT);
if (VisibilitySolver<P, S>::mQuery->isOccluded(aPolytope, myPolyhedron, myOccluders, polytopeLines))
{
#ifdef OUTPUT_DEBUG_FILE
V_LOG(debugOutput, "COUNT: IS OCCLUDED", occlusionTreeNodeSymbol);
V_LOG(debugOutput, "COUNT: IS OCCLUDED", occlusionTreeNodeSymbol);
#endif
return HIDDEN;
}
else
{
return HIDDEN;
}
else
{
#ifdef OUTPUT_DEBUG_FILE
V_LOG(debugOutput, "COUNT: maybe VISIBLE", occlusionTreeNodeSymbol);
V_LOG(debugOutput, "COUNT: maybe VISIBLE", occlusionTreeNodeSymbol);
#endif

}
}
}
Silhouette* mySilhouette = nullptr;
size_t mySilhouetteEdgeIndex = 0;

Expand Down Expand Up @@ -287,18 +289,20 @@ namespace visilib

if (reuseOccluders[i])
{
result = resolveInternal(myPolytopes[i], ss.str(), myOccluders, polytopeLines, aDepth + 1);
result = resolveInternal(aGlobalResult, myPolytopes[i], ss.str(), myOccluders, polytopeLines, aDepth + 1);
}
else
{
result = resolveInternal(myPolytopes[i], ss.str(), std::vector<Silhouette*>(), std::vector<P>(), aDepth + 1);
result = resolveInternal(aGlobalResult, myPolytopes[i], ss.str(), std::vector<Silhouette*>(), std::vector<P>(), aDepth + 1);
}
if (result == FAILURE)
return result;

{
aGlobalResult = FAILURE;
return FAILURE;
}
if (result == VISIBLE)
{
globalResult = VISIBLE;
aGlobalResult = VISIBLE;
if (mDetectApertureOnly) // Early stop - an aperture has been found
{
#ifdef OUTPUT_DEBUG_FILE
Expand All @@ -307,7 +311,7 @@ namespace visilib
delete myPolytopeLeft; myPolytopeLeft = nullptr;
delete myPolytopeRight; myPolytopeRight = nullptr;

return result;
return VISIBLE;
}
}
if (hasBeenAdded)
Expand All @@ -325,16 +329,16 @@ namespace visilib
#ifdef OUTPUT_DEBUG_FILE
ss << occlusionTreeNodeSymbol << "|" << face->getFaceIndex() << "-" << myVisibilitySilhouetteEdge.mEdgeIndex << "*";
#endif
VisibilityResult result = resolveInternal(aPolytope, ss.str(), anOccluders, aPolytopeLines, aDepth + 1);
VisibilityResult result = resolveInternal(aGlobalResult, aPolytope, ss.str(), anOccluders, aPolytopeLines, aDepth + 1);
if (result == FAILURE)
return result;

if (result == VISIBLE)
{
globalResult = VISIBLE;
aGlobalResult = VISIBLE;
if (mDetectApertureOnly) // Early stop - an aperture has been found
{
return result;
return VISIBLE;
}
}
}
Expand All @@ -355,15 +359,19 @@ namespace visilib
V_LOG(debugOutput, "visible polytope found: exporting stabbing lines", occlusionTreeNodeSymbol);
#endif
extractStabbingLines(myPolyhedron, aPolytope);
globalResult = VISIBLE;
aGlobalResult = VISIBLE;
if (mDetectApertureOnly) // Early stop - an aperture has been found
{
return VISIBLE;
}
}
}

if (myPolyhedron->getLinesCount() != myInitiaLineCount)
{
// resize(myInitiaLineCount, myPolyhedron, aPolytope);
}
return globalResult;
return UNKNOWN;

}

Expand Down
70 changes: 33 additions & 37 deletions visilib/visibility_exact_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,49 +529,45 @@ namespace visilib
std::set<SilhouetteMeshFace*> intersectedFaces;
bool hit = findSceneIntersection(centerLine.first, centerLine.second, intersectedFaces, 0, aPolytope);

if (!hit)
if (!hit && !mConfiguration.detectApertureOnly)
{
if (mConfiguration.detectApertureOnly)
return false;
{
HelperScopedTimer timer(getStatistic(), STABBING_LINE_EXTRACTION);
{
HelperScopedTimer timer(getStatistic(), STABBING_LINE_EXTRACTION);

if (aPolytope->getExtremalStabbingLinesCount() == 0)
{
aPolytope->computeExtremalStabbingLines(polyhedron, mTolerance);
}
}

if(aPolytope->getExtremalStabbingLinesCount() == 0)
if (aPolytope->getExtremalStabbingLinesCount() == 0)
{
aPolytope->computeExtremalStabbingLines(polyhedron, mTolerance);
}
}

if(aPolytope->getExtremalStabbingLinesCount() == 0)
{
V_ASSERT(0);
return true;
}
S myMaxDistance = 0;
S myDistance = 0;

for (size_t i = 0; i < aPolytope->getExtremalStabbingLinesCount(); i++)
{
std::pair<MathVector3d, MathVector3d> line = MathGeometry::getBackTo3D(aPolytope->getExtremalStabbingLine(i),
aPlane0,
aPlane1);

myDistance = (line.first - centerLine.first).getSquaredNorm();
if (myDistance> myMaxDistance)
{
V_ASSERT(0);
return true;
myMaxDistance = myDistance;
}
S myMaxDistance = 0;
S myDistance = 0;

for (size_t i = 0; i < aPolytope->getExtremalStabbingLinesCount(); i++)
myDistance = (line.second - centerLine.second).getSquaredNorm();
if (myDistance> myMaxDistance)
{
std::pair<MathVector3d, MathVector3d> line = MathGeometry::getBackTo3D(aPolytope->getExtremalStabbingLine(i),
aPlane0,
aPlane1);

myDistance = (line.first - centerLine.first).getSquaredNorm();
if (myDistance> myMaxDistance)
{
myMaxDistance = myDistance;
}

myDistance = (line.second - centerLine.second).getSquaredNorm();
if (myDistance> myMaxDistance)
{
myMaxDistance = myDistance;
}
myMaxDistance = myDistance;
}
myMaxDistance = MathArithmetic<S>::getSqrt(myMaxDistance);
hit = findSceneIntersection(centerLine.first, centerLine.second, intersectedFaces, myMaxDistance, aPolytope);
if (!hit)
return false;
}
myMaxDistance = MathArithmetic<S>::getSqrt(myMaxDistance);
findSceneIntersection(centerLine.first, centerLine.second, intersectedFaces, myMaxDistance, aPolytope);
}
for (auto myFace : intersectedFaces)
{
Expand All @@ -580,7 +576,7 @@ namespace visilib
if (s)
occluders.push_back(s);
}
return true;
return hit;
}

}

0 comments on commit f22e915

Please sign in to comment.