aTolVnew = aTolMin;
}
}
- // <-LXBR
- {
- Standard_Integer nVS[2], iFound;
- Standard_Real aTolVx, aD2, aDT2;
- TColStd_MapOfInteger aMV;
- gp_Pnt aPx;
- //
- iFound=0;
- j=-1;
- aMV.Add(nV[0]);
- aMV.Add(nV[1]);
- //
- if (aMV.Contains(nV[2])) {
- ++j;
- nVS[j]=nV[2];
- }
- if (aMV.Contains(nV[3])) {
- ++j;
- nVS[j]=nV[3];
- }
- //
- for (Standard_Integer k1=0; k1<=j; ++k1) {
- const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k1]));
- aTolVx=BRep_Tool::Tolerance(aVx);
- aPx=BRep_Tool::Pnt(aVx);
- aD2=aPnew.SquareDistance(aPx);
- //
- aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
- //
- if (aD2<aDT2) {
- iFound=1;
- break;
- }
- }
- //
- if (iFound) {
- continue;
- }
- }
- //
+
// 1
BOPDS_InterfEE& aEE=aEEs.Appended();
iX=aEEs.Length()-1;
gp_Pnt2d& theP2D,
const Handle(IntTools_Context)& theContext)
{
- Standard_Integer i, iErr = 1;
- Standard_Real aUMin, aUMax, aVMin, aVMax, aUx;
- //
+ // Error status
+ Standard_Integer iErr = 1;
+
+ // Get UV bounds of the face
+ Standard_Real aUMin, aUMax, aVMin, aVMax;
theContext->UVBounds(theF, aUMin, aUMax, aVMin, aVMax);
- //
- gp_Dir2d aD2D(0. , 1.);
- aUx = IntTools_Tools::IntermediatePoint(aUMin, aUMax);
- //
- for (i = 0; i < 2; ++i) {
- gp_Pnt2d aP2D(aUx, 0.);
+
+ // Middle point of the 2d bounding box of the face
+ Standard_Real aUx = IntTools_Tools::IntermediatePoint(aUMin, aUMax),
+ aVx = IntTools_Tools::IntermediatePoint(aVMin, aVMax);
+
+ for (Standard_Integer i = 0; i < 4; ++i)
+ {
+ // Point to start the hatching line
+ gp_Pnt2d aP2D(aUx, aVx);
+ // Direction for the hatching line
+ gp_Dir2d aD2D = (i < 2) ? gp::DY2d() : gp::DX2d();
Handle(Geom2d_Line) aL2D = new Geom2d_Line (aP2D, aD2D);
iErr = BOPTools_AlgoTools3D::PointInFace
(theF, aL2D, theP, theP2D, theContext);
- if (iErr == 0) {
+ if (iErr == 0)
// done
- break;
- }
- else {
- // possible reason - incorrect computation of the 2d box of the face.
- // try to compute the point with the translated line.
- aUx = aUMax - (aUx - aUMin);
+ return iErr;
+ else
+ {
+ // Possible reason - incorrect computation of the 2d box of the face.
+ // Try to compute the point with the translated line.
+ if (i < 2)
+ aUx = aUMax - (aUx - aUMin);
+ else
+ aVx = aVMax - (aVx - aVMin);
}
}
- //
+
+ // The tries to find the point using the hatching line passing through
+ // the middle of the bounding box of the face have failed.
+ // Try to start hatching line at the middle of the edges of the face.
+ TopExp_Explorer anExpE(theF, TopAbs_EDGE);
+ for (; anExpE.More(); anExpE.Next())
+ {
+ const TopoDS_Edge& aE = TopoDS::Edge(anExpE.Current());
+ Standard_Real aT1, aT2;
+ BRep_Tool::Range(aE, aT1, aT2);
+ iErr = BOPTools_AlgoTools3D::PointInFace
+ (theF, aE, 0.5 * (aT1 + aT2), 0.0, theP, theP2D, theContext);
+ if (iErr == 0)
+ return iErr;
+ }
+
return iErr;
}
//=======================================================================