mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0027467: Modeling Algorithms - class Extrema_ExtCC2d does not find extremum between two intersecting lines
Line / line analytic treatment is added for 2d case. Test case is added.
This commit is contained in:
parent
8d0b864941
commit
15a954deb5
@ -36,9 +36,13 @@
|
|||||||
Extrema_ExtElC2d::Extrema_ExtElC2d () { myDone = Standard_False; }
|
Extrema_ExtElC2d::Extrema_ExtElC2d () { myDone = Standard_False; }
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
Extrema_ExtElC2d::Extrema_ExtElC2d (const gp_Lin2d& C1,
|
//=======================================================================
|
||||||
const gp_Lin2d& C2,
|
//function : Extrema_ExtElC2d
|
||||||
const Standard_Real)
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Extrema_ExtElC2d::Extrema_ExtElC2d (const gp_Lin2d& C1,
|
||||||
|
const gp_Lin2d& C2,
|
||||||
|
const Standard_Real)
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Find min distance between 2 straight lines.
|
Find min distance between 2 straight lines.
|
||||||
@ -57,15 +61,37 @@ Method:
|
|||||||
myIsPar = Standard_False;
|
myIsPar = Standard_False;
|
||||||
myNbExt = 0;
|
myNbExt = 0;
|
||||||
|
|
||||||
gp_Dir2d D1 = C1.Direction();
|
gp_Vec2d D1(C1.Direction());
|
||||||
gp_Dir2d D2 = C2.Direction();
|
gp_Vec2d D2(C2.Direction());
|
||||||
if (D1.IsParallel(D2, Precision::Angular())) {
|
if (D1.IsParallel(D2, Precision::Angular()))
|
||||||
|
{
|
||||||
myIsPar = Standard_True;
|
myIsPar = Standard_True;
|
||||||
mySqDist[0] = C2.SquareDistance(C1.Location());
|
mySqDist[0] = C2.SquareDistance(C1.Location());
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
myNbExt = 0;
|
{
|
||||||
|
// Vector from P1 to P2 (P2 - P1).
|
||||||
|
gp_Vec2d aP1P2(C1.Location(), C2.Location());
|
||||||
|
|
||||||
|
// Solve linear system using Cramer's rule:
|
||||||
|
// D1.X * t1 + D2.X * (-t2) = P2.X - P1.X
|
||||||
|
// D1.Y * t1 + D2.Y * (-t2) = P2.Y - P1.Y
|
||||||
|
|
||||||
|
// There is no division by zero since lines are not parallel.
|
||||||
|
Standard_Real aDelim = 1 / (D1^D2);
|
||||||
|
|
||||||
|
Standard_Real aParam1 = (aP1P2 ^ D2) * aDelim;
|
||||||
|
Standard_Real aParam2 = -(D1 ^ aP1P2) * aDelim; // -1.0 coefficient before t2.
|
||||||
|
|
||||||
|
gp_Pnt2d P1 = ElCLib::Value(aParam1, C1);
|
||||||
|
gp_Pnt2d P2 = ElCLib::Value(aParam2, C2);
|
||||||
|
|
||||||
|
mySqDist[myNbExt] = 0.0;
|
||||||
|
myPoint[myNbExt][0] = Extrema_POnCurv2d(aParam1,P1);
|
||||||
|
myPoint[myNbExt][1] = Extrema_POnCurv2d(aParam2,P2);
|
||||||
|
myNbExt = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
myDone = Standard_True;
|
myDone = Standard_True;
|
||||||
}
|
}
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
28
tests/bugs/moddata_3/bug27467
Normal file
28
tests/bugs/moddata_3/bug27467
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "OCC27467"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
#########################################################################
|
||||||
|
# Modeling Algorithms - class Extrema_ExtCC2d does not find extremum between two intersecting lines
|
||||||
|
# Analytical solver can not work on 2 lines.
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
|
line l1 0 0 0 -1
|
||||||
|
trim l1 l1 0 23
|
||||||
|
|
||||||
|
line l2 1 -9.5 -1 -0
|
||||||
|
trim l2 l2 0 2
|
||||||
|
set info [2dextrema l1 l2]
|
||||||
|
|
||||||
|
# Number of solutions check.
|
||||||
|
# There should be only one solution - intersection point.
|
||||||
|
if {[llength $info] != 4} {
|
||||||
|
ERROR: Incorrect number of solutions.
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check distance.
|
||||||
|
regexp "dist 1: +(\[-0-9.+eE\]+)" $info full aDist
|
||||||
|
set absTol 1.0e-9
|
||||||
|
set relTol 0.001
|
||||||
|
set aDist_Exp 0.0
|
||||||
|
checkreal "Distance value check" $aDist $aDist_Exp $absTol $relTol
|
Loading…
x
Reference in New Issue
Block a user