(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"),
model.selection("EDGE", "([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])"),
0,
- 60),
+ 100.0),
(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"),
model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_1_2][Extrusion_2_1/To_Face]"),
16.00781059,
(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"),
model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_1_2"),
8.412291828,
- 165.748725311),
+ "NA"),
(model.selection("VERTEX", "Sketch_1/SketchCircle_1_2__cc"),
model.selection("FACE", "Plane_1"),
35.35533906,
(model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2"),
model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_1_2"),
0,
- 165.748725311),
+ 165.799606),
(model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2"),
model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5"),
27.63932023,
- 27.61462299114),
+ 40.0),
(model.selection("SOLID", "Extrusion_1_1"),
model.selection("FACE", "Extrusion_2_1/To_Face"),
12.5,
#include <Extrema_GenLocateExtCS.hxx>
#include <Extrema_GenLocateExtSS.hxx>
+#include <Extrema_GenLocateExtPS.hxx>
#include <Extrema_LocateExtCC.hxx>
+#include <Extrema_LocateExtPC.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Curve.hxx>
return aValue;
}
+static Standard_Real extremaPE(const gp_Pnt& thePoint,
+ const TopoDS_Edge& theEdge,
+ gp_Pnt& thePointOnEdge)
+{
+ BRepAdaptor_Curve aCurve (theEdge);
+
+ TopLoc_Location aLoc;
+ Standard_Real aTol = BRep_Tool::Tolerance(theEdge);
+ Handle(Poly_Polygon3D) aPoly = BRep_Tool::Polygon3D (theEdge, aLoc);
+ if (!aPoly.IsNull())
+ aTol = Max (aTol, aPoly->Deflection());
+
+ Standard_Real aParam = paramOnCurve (aCurve, thePointOnEdge, 2*aTol);
+
+ Standard_Real aValue = -1.0;
+ Extrema_LocateExtPC anExtr (thePoint, aCurve, aParam, Precision::PConfusion());
+ if (anExtr.IsDone())
+ {
+ aValue = Sqrt(anExtr.SquareDistance());
+
+ Extrema_POnCurv aPointOnCurve = anExtr.Point();
+ thePointOnEdge = aPointOnCurve.Value();
+ }
+ return aValue;
+}
+
+static Standard_Real extremaPF(const gp_Pnt& thePoint,
+ const TopoDS_Face& theFace,
+ gp_Pnt& thePointOnFace)
+{
+ BRepAdaptor_Surface aSurf (theFace);
+
+ TopLoc_Location aLoc;
+ Standard_Real aTol = BRep_Tool::Tolerance(theFace);
+ Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation (theFace, aLoc);
+ if (!aTria.IsNull())
+ aTol = Max (aTol, aTria->Deflection());
+
+ Standard_Real aU, aV;
+ paramsOnSurf(aSurf, thePointOnFace, 2*aTol, aU, aV);
+
+ Standard_Real aValue = -1.0;
+ Extrema_GenLocateExtPS anExtr (aSurf);
+ anExtr.Perform (thePoint, aU, aV);
+ if (anExtr.IsDone())
+ {
+ aValue = Sqrt(anExtr.SquareDistance());
+
+ Extrema_POnSurf aPointOnSurf = anExtr.Point();
+ thePointOnFace = aPointOnSurf.Value();
+ }
+ return aValue;
+}
+
static Standard_Real extremaEF(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
const gp_Pnt& thePonE,
double GeomAlgoAPI_ShapeTools::shapeProximity(const GeomShapePtr& theShape1,
const GeomShapePtr& theShape2)
{
- double aResult = Precision::Infinite();
+ double aResult = -1.0;
if (!theShape1.get() || !theShape2.get())
return aResult;
aResult = aDist.Proximity();
// refine the result
- const gp_Pnt& aPonS1 = aDist.ProximityPoint1();
- const gp_Pnt& aPonS2 = aDist.ProximityPoint2();
+ gp_Pnt aPnt1 = aDist.ProximityPoint1();
+ gp_Pnt aPnt2 = aDist.ProximityPoint2();
+
+ BRepExtrema_ProximityDistTool::ProxPnt_Status aStatus1 = aDist.ProxPntStatus1();
+ BRepExtrema_ProximityDistTool::ProxPnt_Status aStatus2 = aDist.ProxPntStatus2();
+
+ double aValue = -1.0;
- double anExtrema = -1.0;
if (aType1 == TopAbs_EDGE)
{
if (aType2 == TopAbs_EDGE)
- anExtrema = extremaEE(TopoDS::Edge(aShape1), TopoDS::Edge(aShape2), aPonS1, aPonS2);
+ {
+ if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaEE(TopoDS::Edge(aShape1), TopoDS::Edge(aShape2), aPnt1, aPnt2);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaPE(aPnt1, TopoDS::Edge(aShape2), aPnt2);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
+ {
+ aValue = extremaPE(aPnt2, TopoDS::Edge(aShape1), aPnt1);
+ }
+ }
else if (aType2 == TopAbs_FACE)
- anExtrema = extremaEF(TopoDS::Edge(aShape1), TopoDS::Face(aShape2), aPonS1, aPonS2);
+ {
+ if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaEF(TopoDS::Edge(aShape1), TopoDS::Face(aShape2), aPnt1, aPnt2);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaPF(aPnt1, TopoDS::Face(aShape2), aPnt2);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
+ {
+ aValue = extremaPE(aPnt2, TopoDS::Edge(aShape1), aPnt1);
+ }
+ }
}
else if (aType1 == TopAbs_FACE)
{
if (aType2 == TopAbs_EDGE)
- anExtrema = extremaEF(TopoDS::Edge(aShape2), TopoDS::Face(aShape1), aPonS2, aPonS1);
+ {
+ if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaEF(TopoDS::Edge(aShape2), TopoDS::Face(aShape1), aPnt2, aPnt1);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaPE(aPnt1, TopoDS::Edge(aShape2), aPnt2);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
+ {
+ aValue = extremaPF(aPnt2, TopoDS::Face(aShape1), aPnt1);
+ }
+ }
else if (aType2 == TopAbs_FACE)
- anExtrema = extremaFF(TopoDS::Face(aShape1), TopoDS::Face(aShape2), aPonS1, aPonS2);
+ {
+ if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaFF(TopoDS::Face(aShape1), TopoDS::Face(aShape2), aPnt1, aPnt2);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
+ {
+ aValue = extremaPF(aPnt1, TopoDS::Face(aShape2), aPnt2);
+ }
+ else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
+ aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
+ {
+ aValue = extremaPF(aPnt2, TopoDS::Face(aShape1), aPnt1);
+ }
+ }
}
- if (anExtrema > 0.0)
- aResult = anExtrema;
+
+ if (aValue > 0.0)
+ aResult = aValue;
}
return aResult;
}