Skip to content

Commit e697b85

Browse files
jgvsmoskvin
authored andcommitted
0032747: Modeling Algorithms - Exact HLR algorithm gives wrong result
Modify the method IntWalk_IWalking::TestArretCadre: correct the value of scalar product of two vectors according to the tolerances in U and V.
1 parent 9967602 commit e697b85

7 files changed

Lines changed: 55 additions & 19 deletions

File tree

src/IntWalk/IntWalk_IWalking_2.gxx

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
#define No_Standard_OutOfRange
2323
#endif
2424

25+
static void CutVectorByTolerances (gp_Vec2d& theVector,
26+
const math_Vector& theTolerance)
27+
{
28+
if (Abs(theVector.X()) < theTolerance(1))
29+
theVector.SetX (0.);
30+
if (Abs(theVector.Y()) < theTolerance(2))
31+
theVector.SetY (0.);
32+
}
2533

2634
// _______________________________________________
2735
//
@@ -771,8 +779,13 @@ void IntWalk_IWalking::TestArretCadre
771779
Line->Value(j).ParametersOnS1(Uc,Vc);
772780
}
773781

774-
Scal = (Up-wd1[i].ustart) * (Uc-wd1[i].ustart) +
775-
(Vp-wd1[i].vstart) * (Vc-wd1[i].vstart);
782+
gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
783+
aVec2 (Uc-wd1[i].ustart, Vc-wd1[i].vstart);
784+
CutVectorByTolerances (aVec1, tolerance);
785+
CutVectorByTolerances (aVec2, tolerance);
786+
787+
Scal = aVec1 * aVec2;
788+
776789
// if a stop point is found: stop the line on this point.
777790
if (Scal < 0) {
778791
Line->Cut(j); nbp= Line->NbPoints();
@@ -791,8 +804,14 @@ void IntWalk_IWalking::TestArretCadre
791804
}
792805
else if (nbMultiplicities[i] > 0) {
793806
for (Standard_Integer k = N+1; k <= N + nbMultiplicities[i]; k++) {
794-
Scal = (Up-Umult(k)) * (Uc-Umult(k)) +
795-
(Vp-Vmult(k)) * (Vc-Vmult(k));
807+
808+
aVec1.SetCoord (Up-Umult(k), Vp-Vmult(k)),
809+
aVec2.SetCoord (Uc-Umult(k), Vc-Vmult(k));
810+
CutVectorByTolerances (aVec1, tolerance);
811+
CutVectorByTolerances (aVec2, tolerance);
812+
813+
Scal = aVec1 * aVec2;
814+
796815
if (Scal < 0) {
797816
Line->Cut(j); nbp= Line->NbPoints();
798817
Irang=i;
@@ -847,11 +866,13 @@ void IntWalk_IWalking::TestArretCadre
847866
// now the last point of the line and the last calculated point are compated.
848867
// there will be no need to "Cut"
849868

850-
Scal = (Up-wd1[i].ustart) * (UV(1)-wd1[i].ustart) +
851-
// (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
852-
// modified by NIZHNY-MKK Fri Oct 27 12:29:41 2000
853-
(Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
854-
869+
gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
870+
aVec2 (UV(1)-wd1[i].ustart, UV(2)-wd1[i].vstart);
871+
CutVectorByTolerances (aVec1, tolerance);
872+
CutVectorByTolerances (aVec2, tolerance);
873+
874+
Scal = aVec1 * aVec2;
875+
855876
if (Scal < 0) {
856877
Irang = i;
857878
UV(1) = wd1[Irang].ustart;
@@ -867,8 +888,14 @@ void IntWalk_IWalking::TestArretCadre
867888
}
868889
else if (nbMultiplicities[i] > 0) {
869890
for (Standard_Integer j = N+1; j <= N+nbMultiplicities[i]; j++) {
870-
Scal = (Up-Umult(j)) * (UV(1)-Umult(j)) +
871-
(Vp-Vmult(j)) * (UV(2)-Vmult(j));
891+
892+
aVec1.SetCoord (Up-Umult(j), Vp-Vmult(j));
893+
aVec2.SetCoord (UV(1)-Umult(j), UV(2)-Vmult(j));
894+
CutVectorByTolerances (aVec1, tolerance);
895+
CutVectorByTolerances (aVec2, tolerance);
896+
897+
Scal = aVec1 * aVec2;
898+
872899
if (Scal < 0) {
873900
Irang=i;
874901
UV(1) = wd1[Irang].ustart;

tests/hlr/exact_hlr/C13

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
puts "TODO OCC30286 ALL: Error : The length of result shape is 9589.21, expected 9547.11"
2-
31
set viewname "vright"
42
set length 9547.11
53

tests/hlr/exact_hlr/C18

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
puts "TODO OCC30286 Windows: Error : The length of result shape is 2416.66, expected 2418.08"
2-
puts "TODO OCC30286 Linux: Error : The length of result shape is 2414.48, expected 2418.08"
3-
41
set viewname "vright"
52
set length 2418.08
63

tests/hlr/exact_hlr/C3

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
puts "TODO OCC30286 Linux: Error : The length of result shape is 3249.9, expected 3234.6"
2-
31
set viewname "vright"
4-
set length 3234.6
2+
set length 3237.63
53

64
testreadstep [locate_data_file bug27341_570-DWLNL-40-08-L_131LANG_16VERSATZ_DIN.stp] a
75
COMPUTE_HLR $viewname $algotype

tests/hlr/exact_hlr/bug32747

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
puts "================================================"
2+
puts "OCC32747: Exact HLR algorithm gives wrong result"
3+
puts "================================================"
4+
puts ""
5+
6+
set viewname "vfront"
7+
set length 34.3597
8+
9+
restore [locate_data_file bug32747.brep] a
10+
COMPUTE_HLR $viewname $algotype

tests/hlr/exact_hlr/end

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
checkprops result -l ${length}
2+
3+
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
4+
5+
# to end a test script
6+
puts "TEST COMPLETED"
File renamed without changes.

0 commit comments

Comments
 (0)