Correct diagnostic of result of coarse proximity

This commit is contained in:
jgv 2022-09-19 17:36:41 +03:00 committed by jfa
parent 4cf5812a67
commit ac7e1949fb
2 changed files with 41 additions and 30 deletions

View File

@ -3442,31 +3442,46 @@ Standard_Real GEOMImpl_IMeasureOperations::GetPreciseProximity(Handle(GEOM_Objec
if (aShape1.IsNull() || aShape2.IsNull()) if (aShape1.IsNull() || aShape2.IsNull())
return NULL; return NULL;
gp_Pnt aProxPnt1, aProxPnt2; gp_Pnt aProxPnt1, aProxPnt2;
BRepExtrema_ProximityDistTool::ProxPnt_Status aStatus1, aStatus2;
Standard_Integer intStatus1, intStatus2;
aCoarseProximity.GetProximityPoints(aProxPnt1, aProxPnt2); aCoarseProximity.GetProximityPoints(aProxPnt1, aProxPnt2);
aCoarseProximity.GetStatusOfPoints(intStatus1, intStatus2);
aStatus1 = (BRepExtrema_ProximityDistTool::ProxPnt_Status)intStatus1;
aStatus2 = (BRepExtrema_ProximityDistTool::ProxPnt_Status)intStatus2;
GEOMImpl_IProximity aFineProximity(aProximityFuncFine); Standard_Real aResultValue = aCoarseProximity.GetValue();
aFineProximity.SetShapes(aShape1, aShape2);
aFineProximity.SetProximityPoints(aProxPnt1, aProxPnt2);
// Perform // call precise calculator only if at least one point is in the middle of the shape
try if (aStatus1 != BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
aStatus2 != BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
{ {
OCC_CATCH_SIGNALS; GEOMImpl_IProximity aFineProximity(aProximityFuncFine);
if (!GetSolver()->ComputeFunction(aProximityFuncFine)) aFineProximity.SetShapes(aShape1, aShape2);
aFineProximity.SetProximityPoints(aProxPnt1, aProxPnt2);
aFineProximity.SetStatusOfPoints(intStatus1, intStatus2);
// Perform
try
{ {
SetErrorCode("shape proximity driver failed"); OCC_CATCH_SIGNALS;
if (!GetSolver()->ComputeFunction(aProximityFuncFine))
{
SetErrorCode("shape proximity driver failed");
return NULL;
}
}
catch (Standard_Failure& aFail)
{
SetErrorCode(aFail.GetMessageString());
return NULL; return NULL;
} }
}
catch (Standard_Failure& aFail) aResultValue = aFineProximity.GetValue();
{
SetErrorCode(aFail.GetMessageString());
return NULL;
} }
//Make a Python command //Make a Python command
GEOM::TPythonDump(aProximityFuncCoarse) << "value = p.preciseProximity()"; GEOM::TPythonDump(aProximityFuncCoarse) << "value = p.preciseProximity()";
SetErrorCode(OK); SetErrorCode(OK);
return aFineProximity.GetValue(); return aResultValue;
} }

View File

@ -328,7 +328,6 @@ Standard_Integer GEOMImpl_ShapeProximityDriver::Execute(Handle(TFunction_Logbook
aStatus1 = (BRepExtrema_ProximityDistTool::ProxPnt_Status)intStatus1; aStatus1 = (BRepExtrema_ProximityDistTool::ProxPnt_Status)intStatus1;
aStatus2 = (BRepExtrema_ProximityDistTool::ProxPnt_Status)intStatus2; aStatus2 = (BRepExtrema_ProximityDistTool::ProxPnt_Status)intStatus2;
Standard_Real anExactValue = -1;
if (aType1 == TopAbs_EDGE) if (aType1 == TopAbs_EDGE)
{ {
if (aType2 == TopAbs_EDGE) if (aType2 == TopAbs_EDGE)
@ -336,17 +335,17 @@ Standard_Integer GEOMImpl_ShapeProximityDriver::Execute(Handle(TFunction_Logbook
if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaEE(TopoDS::Edge(aShape1), TopoDS::Edge(aShape2), aPnt1, aPnt2); aValue = extremaEE(TopoDS::Edge(aShape1), TopoDS::Edge(aShape2), aPnt1, aPnt2);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaPE(aPnt1, TopoDS::Edge(aShape2), aPnt2); aValue = extremaPE(aPnt1, TopoDS::Edge(aShape2), aPnt2);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
{ {
anExactValue = extremaPE(aPnt2, TopoDS::Edge(aShape1), aPnt1); aValue = extremaPE(aPnt2, TopoDS::Edge(aShape1), aPnt1);
} }
} }
else if (aType2 == TopAbs_FACE) else if (aType2 == TopAbs_FACE)
@ -354,17 +353,17 @@ Standard_Integer GEOMImpl_ShapeProximityDriver::Execute(Handle(TFunction_Logbook
if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaEF(TopoDS::Edge(aShape1), TopoDS::Face(aShape2), aPnt1, aPnt2); aValue = extremaEF(TopoDS::Edge(aShape1), TopoDS::Face(aShape2), aPnt1, aPnt2);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaPF(aPnt1, TopoDS::Face(aShape2), aPnt2); aValue = extremaPF(aPnt1, TopoDS::Face(aShape2), aPnt2);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
{ {
anExactValue = extremaPE(aPnt2, TopoDS::Edge(aShape1), aPnt1); aValue = extremaPE(aPnt2, TopoDS::Edge(aShape1), aPnt1);
} }
} }
} }
@ -375,17 +374,17 @@ Standard_Integer GEOMImpl_ShapeProximityDriver::Execute(Handle(TFunction_Logbook
if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaEF(TopoDS::Edge(aShape2), TopoDS::Face(aShape1), aPnt2, aPnt1); aValue = extremaEF(TopoDS::Edge(aShape2), TopoDS::Face(aShape1), aPnt2, aPnt1);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaPE(aPnt1, TopoDS::Edge(aShape2), aPnt2); aValue = extremaPE(aPnt1, TopoDS::Edge(aShape2), aPnt2);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
{ {
anExactValue = extremaPF(aPnt2, TopoDS::Face(aShape1), aPnt1); aValue = extremaPF(aPnt2, TopoDS::Face(aShape1), aPnt1);
} }
} }
else if (aType2 == TopAbs_FACE) else if (aType2 == TopAbs_FACE)
@ -393,24 +392,21 @@ Standard_Integer GEOMImpl_ShapeProximityDriver::Execute(Handle(TFunction_Logbook
if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaFF(TopoDS::Face(aShape1), TopoDS::Face(aShape2), aPnt1, aPnt2); aValue = extremaFF(TopoDS::Face(aShape1), TopoDS::Face(aShape2), aPnt1, aPnt2);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE)
{ {
anExactValue = extremaPF(aPnt1, TopoDS::Face(aShape2), aPnt2); aValue = extremaPF(aPnt1, TopoDS::Face(aShape2), aPnt2);
} }
else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE && else if (aStatus1 == BRepExtrema_ProximityDistTool::ProxPnt_Status_MIDDLE &&
aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER) aStatus2 == BRepExtrema_ProximityDistTool::ProxPnt_Status_BORDER)
{ {
anExactValue = extremaPF(aPnt2, TopoDS::Face(aShape1), aPnt1); aValue = extremaPF(aPnt2, TopoDS::Face(aShape1), aPnt1);
} }
} }
} }
if (anExactValue != -1)
aValue = anExactValue;
if (aValue >= 0) if (aValue >= 0)
aProximity.SetProximityPoints(aPnt1, aPnt2); aProximity.SetProximityPoints(aPnt1, aPnt2);
else else