-//=======================================================================
-//function : CheckSameDomainFaceInside
-//purpose :
-//=======================================================================
-Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1,
- const TopoDS_Face& theFace2)
-{
- Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.;
- BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax);
- IntTools_Context aContext;
- Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1);
- Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1);
-
- TopExp_Explorer anExpE(theFace1, TopAbs_EDGE);
-
- for(; anExpE.More(); anExpE.Next()) {
- const TopoDS_Edge& anEdge = TopoDS::Edge(anExpE.Current());
- Standard_Real anEdgeTol = BRep_Tool::Tolerance(anEdge);
- aTolerance = (aTolerance < anEdgeTol) ? anEdgeTol : aTolerance;
- }
- aTolerance += BRep_Tool::Tolerance(theFace2);
-
- Standard_Integer nbpoints = 5;
- Standard_Real adeltau = (umax - umin) / (nbpoints + 1);
- Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1);
- Standard_Real U = umin + adeltau;
- GeomAPI_ProjectPointOnSurf& aProjector = aContext.ProjPS(theFace2);
-
- for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) {
- Standard_Real V = vmin + adeltav;
-
- for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) {
- gp_Pnt2d aPoint(U,V);
-
- if(aContext.IsPointInFace(theFace1, aPoint)) {
- gp_Pnt aP3d = aSurface->Value(U, V);
- aProjector.Perform(aP3d);
-
- if(aProjector.IsDone()) {
-
- if(aProjector.LowerDistance() > aTolerance)
- return Standard_False;
- }
- }
- }
- }
-
- return Standard_True;
-}