From 276356c90bac8801ffa70b2a8c8e379a30864fe1 Mon Sep 17 00:00:00 2001 From: duv Date: Mon, 26 Jun 2017 11:22:24 +0300 Subject: [PATCH] 0028731: Restore Face Orientation tool runs very slow for specific CAD files --- .../BRepMesh_RestoreOrientationTool.cxx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/BRepMesh/BRepMesh_RestoreOrientationTool.cxx b/src/BRepMesh/BRepMesh_RestoreOrientationTool.cxx index 3270da0d7f..77ad33346f 100644 --- a/src/BRepMesh/BRepMesh_RestoreOrientationTool.cxx +++ b/src/BRepMesh/BRepMesh_RestoreOrientationTool.cxx @@ -60,6 +60,9 @@ const Standard_Real COHERENCY_WEIGHT = 50.0; // Indicates that ray does not hit any geometry. const Standard_Integer INVALID_HIT = -1; +//! Maximum number of attempts for rejection sampling. +const int MAX_SAMPLING_ATTEMPTS = 10; + //! Samples value from array according to probabilities. Standard_Integer sampleValue (Standard_Real theKsi, const std::vector& theCDF) { @@ -389,11 +392,16 @@ void BRepMesh_RestoreOrientationTool::computeVisibility (BVH_Triangulation 1.0); + + if (aKsi + aPsi > 1.0) + { + break; + } + } const BVH_Vec3d& aPoint0 = thePatch->Vertices[aTriangle.x()]; const BVH_Vec3d& aPoint1 = thePatch->Vertices[aTriangle.y()]; @@ -412,7 +420,7 @@ void BRepMesh_RestoreOrientationTool::computeVisibility (BVH_Triangulation