#include <math_BullardGenerator.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
+#include <vector>
+
+// modified by NIZHNY-MKK Mon Jun 21 15:13:40 2004
static
Standard_Boolean FaceNormal (const TopoDS_Face& aF,
const Standard_Real U,
myFace.Nullify();
myState=2;
- aSE.InitShell();
- if (aSE.MoreShell())
+ // Collect faces in sequence to iterate
+ std::vector<TopoDS_Face> aFaces;
+ for (aSE.InitShell(); aSE.MoreShell(); aSE.NextShell())
+ {
+ for (aSE.InitFace(); aSE.MoreFace(); aSE.NextFace())
+ {
+ aFaces.push_back (aSE.CurrentFace());
+ }
+ }
+
+ // iteratively try up to 10 probing points from each face
+ const int NB_MAX_POINTS_PER_FACE = 10;
+ for (int itry = 0; itry < NB_MAX_POINTS_PER_FACE; itry++)
{
- aSE.InitFace();
- if (aSE.MoreFace())
+ for (std::vector<TopoDS_Face>::iterator iFace = aFaces.begin(); iFace != aFaces.end(); ++iFace)
{
- TopoDS_Face aF = aSE.CurrentFace();
+ TopoDS_Face aF = *iFace;
+
TopAbs_State aState = TopAbs_OUT;
IntCurveSurface_TransitionOnCurve aTransition = IntCurveSurface_Tangent;
- TopoDS_Face MinFace = aF;
- for (;;)
- {
+
aParam = 0.1 + 0.8 * aRandomGenerator.NextReal(); // random number in range [0.1, 0.9]
bFound = aSE.FindAPointInTheFace(aF, aPoint, aU, aV, aParam);
- if (!bFound)
- return;
+ if (!bFound || !FaceNormal(aF, aU, aV, aDN))
+ continue;
- if (!FaceNormal(aF, aU, aV, aDN))
- continue;
gp_Lin aLin(aPoint, -aDN);
Standard_Real parmin = RealLast();
for (aSE.InitShell();aSE.MoreShell();aSE.NextShell()) {
parmin = Intersector3d.WParameter(imin);
aState = Intersector3d.State(imin);
aTransition = Intersector3d.Transition(imin);
- MinFace = CurFace;
}
}
}
return;
}
}
- aF = MinFace;
+ } // iteration by faces
+ } // iteration by points
}
- } //if (aSE.MoreFace())
- } //if (aSE.MoreShell())
-}
//=======================================================================
//function : Perform
--- /dev/null
+puts "##################################################"
+puts "0026627: Shape Healing hangs as of OCC 6.8.0"
+puts "##################################################"
+
+# load and check shape
+restore [locate_data_file bug26627_fixed.brep] a
+tolerance a
+checkshape a
+
+# call fixshape -- it should finish in fraction of second
+cpulimit 10
+fixshape result a 1e-6
+
+# result should have positive volume
+if { [regexp {Mass\s*:\s*([0-9.e+-]*)} [vprops result] dummy volume] } {
+ checkreal "Volume of the solid" $volume 4332.63 0.1 0.
+} else {
+ puts "Error: cannot get volume of result!"
+}